fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [10590] property: more on condition survey


From: Sigurd Nes
Subject: [Fmsystem-commits] [10590] property: more on condition survey
Date: Wed, 12 Dec 2012 14:50:38 +0000

Revision: 10590
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10590
Author:   sigurdne
Date:     2012-12-12 14:50:37 +0000 (Wed, 12 Dec 2012)
Log Message:
-----------
property: more on condition survey

Modified Paths:
--------------
    trunk/phpgwapi/js/yahoo/common.js
    trunk/property/inc/class.socondition_survey.inc.php
    trunk/property/inc/class.uicondition_survey.inc.php
    trunk/property/inc/hook_config.inc.php
    trunk/property/templates/base/config.tpl

Modified: trunk/phpgwapi/js/yahoo/common.js
===================================================================
--- trunk/phpgwapi/js/yahoo/common.js   2012-12-12 10:22:53 UTC (rev 10589)
+++ trunk/phpgwapi/js/yahoo/common.js   2012-12-12 14:50:37 UTC (rev 10590)
@@ -19,7 +19,7 @@
 YAHOO.portico.FormatterAmount0 = function(elCell, oRecord, oColumn, oData)
 {
        var amount = YAHOO.util.Number.format(oData, {decimalPlaces:0, 
decimalSeparator:",", thousandsSeparator:" "});
-       elCell.innerHTML = "<div align=\"right\"><pre>"+amount+"</pre></div>";
+       elCell.innerHTML = "<div class='nowrap' 
align=\"right\">"+amount+"</div>";
 }      
 
 
@@ -400,11 +400,15 @@
        
        var myDataTable = new YAHOO.widget.DataTable(dataTableContainer, 
colDefs, myDataSource, options);
        
+       myDataTable.subscribe("rowMouseoverEvent", 
myDataTable.onEventHighlightRow);
+       myDataTable.subscribe("rowMouseoutEvent", 
myDataTable.onEventUnhighlightRow);
+
        myDataTable.handleDataReturnPayload = function(oRequest, oResponse, 
oPayload) {
           oPayload.totalRecords = oResponse.meta.totalResultsAvailable;
           return oPayload;
    }
        
+
        myDataTable.doBeforeLoadData = function(nothing, oResponse, oPayload) {
 
         oPayload.totalRecords = oResponse.meta.totalResultsAvailable;

Modified: trunk/property/inc/class.socondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.socondition_survey.inc.php 2012-12-12 10:22:53 UTC 
(rev 10589)
+++ trunk/property/inc/class.socondition_survey.inc.php 2012-12-12 14:50:37 UTC 
(rev 10590)
@@ -305,21 +305,73 @@
 
                        $sorequest      = CreateObject('property.sorequest');
 
-//_debug_array($survey);                       
+                       $this->_db->transaction_begin();
 
-                       $this->_db->transaction_begin();
+                       $config = CreateObject('phpgwapi.config','property');
+                       $config->read();
+
+                       
if(!isset($config->config_data['condition_survey_import_cat']) || 
!is_array($config->config_data['condition_survey_import_cat']))
+                       {
+                               throw new 
Exception('property_socondition_survey::import - condition survey import 
categories not configured');
+                       }
+
+
+                       
if(!isset($config->config_data['condition_survey_initial_status']) || 
!$config->config_data['condition_survey_initial_status'])
+                       {
+                               throw new 
Exception('property_socondition_survey::import - condition survey initial 
status not configured');
+                       }
+
+                       $cats   = CreateObject('phpgwapi.categories', -1, 
'property', '.project');
+                       $cats->supress_info = true;
+                       $categories = $cats->return_sorted_array(0, false, '', 
'', '', $globals = true, '', $use_acl = false);
+
 /*
-                                       kategorier:
-                                       13 => D - Drift
-                                       202 => Kombinasjon
-                                       14 => U - Investering
-                                       12 => V - Planlagt
+               $cats_candidates = array
+               (
+                       1 => 'Investment',
+                       2 => 'Operation',
+                       3 => 'Combined::Investment/Operation',
+                       4 => 'Special'
+               );
+
 */
                        foreach ($import_data as $entry)
                        {
+
                                if( ctype_digit($entry['condition_degree']) &&  
$entry['condition_degree'] > 0 && strlen($entry['building_part']) > 2)
                                {
                                        $request = array();
+
+                                       if( $entry['percentage_investment'] == 
100)
+                                       {
+                                               
if(isset($config->config_data['condition_survey_import_cat'][1]))
+                                               {
+                                                       $request['cat_id'] = 
(int)$config->config_data['condition_survey_import_cat'][1];
+                                               }
+                                       }
+                                       else 
if(!$entry['percentage_investment'])
+                                       {
+                                               
if(isset($config->config_data['condition_survey_import_cat'][2]))
+                                               {
+                                                       $request['cat_id'] = 
(int)$config->config_data['condition_survey_import_cat'][2];
+                                               }
+                                       }
+                                       else if($entry['percentage_investment'] 
&& $entry['percentage_investment'] < 100)
+                                       {
+                                               
if(isset($config->config_data['condition_survey_import_cat'][3]))
+                                               {
+                                                       $request['cat_id'] = 
(int)$config->config_data['condition_survey_import_cat'][3];
+                                               }
+                                       }
+
+                                       if(!isset($request['cat_id']) || 
!$request['cat_id'])
+                                       {
+                                               $request['cat_id'] = 
(int)$categories[0]['id'];
+                                       }
+
+                                       
$this->_check_building_part($entry['building_part']);
+
+
                                        $request['condition_survey_id'] = 
$survey['id'];
                                        $request['street_name']                 
= $location_data['street_name'];
                                        $request['street_number']               
= $location_data['street_number'];
@@ -329,10 +381,9 @@
                                        $request['origin_item_id']              
= (int)$survey['id'];
                                        $request['title']                       
        = substr($entry['title'], 0, 255);
                                        $request['descr']                       
        = $entry['descr'];
-                                       $request['cat_id']                      
        = 13; //???? FIXME
                                        $request['building_part']               
= $entry['building_part'];
                                        $request['coordinator']                 
= $survey['coordinator_id'];
-                                       $request['status']                      
        = 'registrert';//???? FIXME
+                                       $request['status']                      
        = $config->config_data['condition_survey_initial_status'];
                                        $request['budget']                      
        = $entry['amount'];
                                        $request['planning_date']               
= mktime(13,0,0,7,1, $entry['due_year']?$entry['due_year']:date('Y'));
                                        $request['planning_value']              
= $entry['amount'];
@@ -346,8 +397,20 @@
                                                        'probability' => 
$entry['probability']
                                                )
                                        );
+
 //_debug_array($request);
                                        $sorequest->add($request, 
$values_attribute = array());
+                                       if($entry['amount_extra'] > 0)
+                                       {
+                                               
if(isset($config->config_data['condition_survey_import_cat'][4]))
+                                               {
+                                                       $request['cat_id'] = 
(int)$config->config_data['condition_survey_import_cat'][4];
+                                               }
+
+                                               $request['planning_value']      
=$entry['amount_extra'];
+                                               $request['cat_id']              
                = 13; //???? FIXME
+                                               $sorequest->add($request, 
$values_attribute = array());
+                                       }
                                }
                        }
 //             die();
@@ -355,6 +418,17 @@
                        $this->_db->transaction_commit();
                }
 
+               private function _check_building_part($id)
+               {
+                       $sql = "SELECT id FROM fm_building_part WHERE id = 
'{$id}'";
+                       $this->_db->query($sql,__LINE__,__FILE__);
+                       if(!$this->_db->next_record())
+                       {
+                               $sql = "INSERT INTO fm_building_part (id, 
descr) VALUES ('{$id}', '{$id}::__')";
+                               $this->_db->query($sql,__LINE__,__FILE__);
+                       }
+               }
+
                public function get_summation($id)
                {
                        $table = 'fm_request';

Modified: trunk/property/inc/class.uicondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.uicondition_survey.inc.php 2012-12-12 10:22:53 UTC 
(rev 10589)
+++ trunk/property/inc/class.uicondition_survey.inc.php 2012-12-12 14:50:37 UTC 
(rev 10590)
@@ -958,6 +958,7 @@
                                        'due_year'                              
=> 'År (innen)',
                                        'percentage_investment' => 'Andel % 
aktivering (U)',
                                        'amount'                                
=> 'Kalkyle netto totalt (VU)',
+                                       'amount_extra'                  => 
'Merkostnad ENØK (U)',
                                );
 
                                phpgw::import_class('phpgwapi.sbox');

Modified: trunk/property/inc/hook_config.inc.php
===================================================================
--- trunk/property/inc/hook_config.inc.php      2012-12-12 10:22:53 UTC (rev 
10589)
+++ trunk/property/inc/hook_config.inc.php      2012-12-12 14:50:37 UTC (rev 
10590)
@@ -277,4 +277,88 @@
 HTML;
                }
                return $out;
+
        }
+       /**
+       * Get HTML listboks with categories that are candidates for condition 
survey import categories
+       *
+       * @param $config
+       * @return string options for selectbox
+       */
+       function condition_survey_import_cat($config)
+       {
+               $filters = array
+               (
+                       1 => 'Investment',
+                       2 => 'Operation',
+                       3 => 'Combined::Investment/Operation',
+                       4 => 'Special'
+               );
+
+               $cats   = CreateObject('phpgwapi.categories', -1, 'property', 
'.project');
+               $cats->supress_info = true;
+               $values = $cats->return_sorted_array(0, false, '', '', '', 
$globals = true, '', $use_acl = false);
+
+               $filter_assigned = 
isset($config['condition_survey_import_cat']) ? 
$config['condition_survey_import_cat'] : array();
+
+               $out = '';
+               foreach ( $filters as $filter_key => $filter_name)
+               {
+                       $out .=  <<<HTML
+                       <tr><td><label>{$filter_name}</label></td><td><select 
name="newsettings[condition_survey_import_cat][{$filter_key}]">
+HTML;
+                       $out .= '<option value="">' . lang('none selected') . 
'</option>' . "\n";
+                       foreach ( $values as $key => $category)
+                       {
+                               if(! $category['active'])
+                               {
+                                       continue;
+                               }
+
+                               $selected = '';
+                               if ( isset($filter_assigned[$filter_key]) && 
$filter_assigned[$filter_key] == $category['id'])
+                               {
+                                       $selected = 'selected =  "selected"';
+                               }
+
+                               $out .=  <<<HTML
+                               <option value='{$category['id']}'{$selected} 
title = '{$category['description']}'>{$category['name']}</option>
+HTML;
+                       }
+
+                       $out .=  <<<HTML
+                       </select></td></tr>
+HTML;
+               }
+               return $out;
+       }
+
+       /**
+       * Get HTML listbox with initial status that are to be set when 
condition survey are imported
+       *
+       * @param $config
+       * @return string HTML listboxes to be placed in a table
+       */
+       function condition_survey_initial_status($config)
+       {
+               $status_entries = 
execMethod('property.sorequest.select_status_list');
+
+               $status_assigned = 
isset($config['condition_survey_initial_status']) ? 
$config['condition_survey_initial_status'] : array();
+
+               $out = '<option value="">' . lang('none selected') . 
'</option>' . "\n";
+               foreach ( $status_entries as $status)
+               {
+                       $selected = '';
+                       if ( $status_assigned == $status['id'])
+                       {
+                               $selected = 'selected =  "selected"';
+                       }
+
+                       $out .=  <<<HTML
+                       <option 
value='{$status['id']}'{$selected}>{$status['name']}</option>
+HTML;
+               }
+
+               return $out;
+       }
+

Modified: trunk/property/templates/base/config.tpl
===================================================================
--- trunk/property/templates/base/config.tpl    2012-12-12 10:22:53 UTC (rev 
10589)
+++ trunk/property/templates/base/config.tpl    2012-12-12 14:50:37 UTC (rev 
10590)
@@ -479,15 +479,31 @@
        <tr class="row_off">
                <td>{lang_filter_buildingpart}:</td>
                <td>
-                               <!--to be able to blank the setting - need an 
empty value
-                               <input type = 'hidden' 
name="newsettings[list_location_level][]" value="">-->
-                               <table>
-                                       {hook_filter_buildingpart}
-                               </table>
+                       <table>
+                               {hook_filter_buildingpart}
+                       </table>
                </td>
        </tr>
 
+       <tr class="row_on">
+               <td>{lang_condition_survey_import_category}:</td>
+               <td>
+                       <table>
+                               {hook_condition_survey_import_cat}
+                       </table>
+               </td>
+       </tr>
 
+       <tr class="row_off">
+               
<td>{lang_initial_status_that_are_to_be_set_when_condition_survey_are_imported}:</td>
+               <td>
+                       <select 
name="newsettings[condition_survey_initial_status]">
+                               {hook_condition_survey_initial_status}
+                       </select>
+               </td>
+       </tr>
+
+
                <!--
                groupnotification
                -->




reply via email to

[Prev in Thread] Current Thread [Next in Thread]