fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [9643] property: minor fixes


From: Sigurd Nes
Subject: [Fmsystem-commits] [9643] property: minor fixes
Date: Thu, 21 Jun 2012 13:01:05 +0000

Revision: 9643
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9643
Author:   sigurdne
Date:     2012-06-21 13:01:02 +0000 (Thu, 21 Jun 2012)
Log Message:
-----------
property: minor fixes

Modified Paths:
--------------
    trunk/property/inc/class.bolookup.inc.php
    trunk/property/inc/class.botts.inc.php
    trunk/property/inc/class.notify.inc.php
    trunk/property/inc/class.soproject.inc.php
    trunk/property/inc/class.uiworkorder.inc.php
    trunk/property/setup/setup.inc.php
    trunk/property/setup/tables_update.inc.php

Modified: trunk/property/inc/class.bolookup.inc.php
===================================================================
--- trunk/property/inc/class.bolookup.inc.php   2012-06-21 12:22:12 UTC (rev 
9642)
+++ trunk/property/inc/class.bolookup.inc.php   2012-06-21 13:01:02 UTC (rev 
9643)
@@ -143,26 +143,36 @@
                        $accounts = $GLOBALS['phpgw']->accounts->get_list();
                        $user_contacts = array();
 
+                       $socommon                       = 
CreateObject('property.socommon');
+                       $prefs = array();
                        foreach($accounts as $account)
                        {
                                if(isset($account->person_id) && 
$account->person_id)
                                {
                                        $user_contacts[] = $account->person_id;
+
+                                       $prefs[$account->person_id] = 
$socommon->create_preferences('property',$account->id);
                                }
                        }
+
+//_debug_array($prefs);die();
                        foreach($contacts as &$contact)
                        {
                                $comms = 
$addressbook->get_comm_contact_data($contact['contact_id'], $fields_comms='', 
$simple=false);
 
                                if ( is_array($comms) && count($comms) )
                                {
-                                       $contact['email'] = 
isset($comms[$contact['contact_id']]['work email']) ? 
$comms[$contact['contact_id']]['work email'] : '';
-                                       $contact['wphone'] = 
isset($comms[$contact['contact_id']]['work phone']) ?  
$comms[$contact['contact_id']]['work phone'] : '';
-                                       $contact['mobile'] = 
isset($comms[$contact['contact_id']]['mobile (cell) phone']) ?  
$comms[$contact['contact_id']]['mobile (cell) phone'] : '';
+                                       $contact['email'] = 
isset($comms[$contact['contact_id']]['work email']) && 
$comms[$contact['contact_id']]['work email'] ? 
$comms[$contact['contact_id']]['work email'] 
:$prefs[$contact['contact_id']]['email'];
+                                       $contact['wphone'] = 
isset($comms[$contact['contact_id']]['work phone']) && 
$comms[$contact['contact_id']]['work phone'] ?  
$comms[$contact['contact_id']]['work phone'] : '';
+                                       $contact['mobile'] = 
isset($comms[$contact['contact_id']]['mobile (cell) phone']) &&  
$comms[$contact['contact_id']]['mobile (cell) phone'] ?  
$comms[$contact['contact_id']]['mobile (cell) phone'] : 
$prefs[$contact['contact_id']]['cellphone'];
                                }
                                if (in_array($contact['contact_id'], 
$user_contacts) )
                                {
                                        $contact['is_user'] = 'X';
+
+                                       $contact['email'] = 
isset($contact['email']) && $contact['email'] ? $contact['email'] 
:$prefs[$contact['contact_id']]['email'];
+                                       $contact['wphone'] = 
isset($contact['wphone']) && $contact['wphone'] ?  $contact['wphone'] : '';
+                                       $contact['mobile'] = 
isset($contact['mobile']) && $contact['mobile'] ?  $contact['mobile'] : 
$prefs[$contact['contact_id']]['cellphone'];
                                }
                        }
 

Modified: trunk/property/inc/class.botts.inc.php
===================================================================
--- trunk/property/inc/class.botts.inc.php      2012-06-21 12:22:12 UTC (rev 
9642)
+++ trunk/property/inc/class.botts.inc.php      2012-06-21 13:01:02 UTC (rev 
9643)
@@ -1097,7 +1097,7 @@
                        
/**************************************************************\
                         * Display additional notes                             
        *
                         
\**************************************************************/
-                       if($fields_updated)
+//                     if($fields_updated)
                        {
                                $i=1;
 

Modified: trunk/property/inc/class.notify.inc.php
===================================================================
--- trunk/property/inc/class.notify.inc.php     2012-06-21 12:22:12 UTC (rev 
9642)
+++ trunk/property/inc/class.notify.inc.php     2012-06-21 13:01:02 UTC (rev 
9643)
@@ -108,12 +108,29 @@
                                );
                        }
 
+                       $contacts = CreateObject('phpgwapi.contacts');
+
+                       $socommon                       = 
CreateObject('property.socommon');
+
+
                        foreach ($values as &$entry)
                        {
                                $comms = 
execMethod('addressbook.boaddressbook.get_comm_contact_data',$entry['contact_id']);
+
                                $entry['email'] = 
$comms[$entry['contact_id']]['work email'];
                                $entry['sms'] = 
$comms[$entry['contact_id']]['mobile (cell) phone'];
                                $entry['is_active_text'] = $entry['is_active'] 
? $lang_yes : $lang_no;
+
+                               $sql = "SELECT account_id FROM phpgw_accounts 
WHERE person_id = " . (int) $entry['contact_id'];
+                               $this->_db->query($sql,__LINE__,__FILE__);
+                               if($this->_db->next_record())
+                               {
+                                       $account_id             = 
$this->_db->f('account_id');
+                                       $prefs = 
$socommon->create_preferences('property',$account_id);         
+
+                                       $entry['email'] = 
isset($entry['email']) && $entry['email'] ? $entry['email'] : $prefs['email'];
+                                       $entry['sms'] = isset($entry['sms']) && 
$entry['sms'] ?  $entry['sms'] : $prefs['cellphone'];
+                               }
                        }
 
                        return $values;

Modified: trunk/property/inc/class.soproject.inc.php
===================================================================
--- trunk/property/inc/class.soproject.inc.php  2012-06-21 12:22:12 UTC (rev 
9642)
+++ trunk/property/inc/class.soproject.inc.php  2012-06-21 13:01:02 UTC (rev 
9643)
@@ -771,10 +771,11 @@
                {
                        $project_id = (int) $project_id;
                        $project = array();
-                       $sql = "SELECT * from fm_project WHERE 
id={$project_id}";
+                       $sql = "SELECT * FROM fm_project WHERE 
id={$project_id}";
 
                        $this->db->query($sql,__LINE__,__FILE__);
 
+                       $project = array();
                        if ($this->db->next_record())
                        {
                                $project = array
@@ -823,6 +824,14 @@
                                $location_code = $this->db->f('location_code');
                                $project['power_meter']         = 
$this->get_power_meter($location_code);
                        }
+
+                       if($project)
+                       {
+                               $this->db->query("SELECT sum(budget) AS 
sum_budget FROM fm_project_budget WHERE project_id = 
$project_id",__LINE__,__FILE__);
+                               $this->db->next_record();
+                               $project['budget'] 
=(int)$this->db->f('sum_budget');
+                       }
+
                        //_debug_array($project);
                        return $project;
                }
@@ -1366,6 +1375,8 @@
 
                        if ($old_budget != $new_budget)
                        {
+                               $this->db->query("UPDATE fm_project SET budget 
= {$new_budget} WHERE id = " . (int)$project['id'],__LINE__,__FILE__);
+
                                
$historylog->add('B',$project['id'],$project['budget'], $old_budget);
                        }
 
@@ -1631,7 +1642,7 @@
                        {
                                $year = $this->db->f('year');
                                $_actual_cost = 
isset($cost_info[$year]['actual_cost']) &&  $cost_info[$year]['actual_cost'] ? 
$cost_info[$year]['actual_cost'] : 0;
-                               $_sum_orders = 
isset($cost_info[$year]['sum_orders']) &&  $cost_info[$year]['sum_orders'] ? 
$cost_info[$year]['sum_orders'] : 0;
+                               $_sum_orders = 
isset($cost_info[$year]['sum_orders']) &&  $cost_info[$year]['sum_orders'] > 0 
? $cost_info[$year]['sum_orders'] : 0;
                                if(isset($cost_info[$year]))
                                {
                                        unset($cost_info[$year]);
@@ -1650,6 +1661,7 @@
                                        'modified_date'         => 
$this->db->f('modified_date')
                                );
                        }
+
                        if($cost_info && count($cost_info))
                        {
                                foreach($cost_info as $year => $cost_info)
@@ -1668,8 +1680,6 @@
                                        );
                                }
                        }
-//_debug_array($values);
-//die();
 
                        if($values)
                        {

Modified: trunk/property/inc/class.uiworkorder.inc.php
===================================================================
--- trunk/property/inc/class.uiworkorder.inc.php        2012-06-21 12:22:12 UTC 
(rev 9642)
+++ trunk/property/inc/class.uiworkorder.inc.php        2012-06-21 13:01:02 UTC 
(rev 9643)
@@ -2217,6 +2217,7 @@
 
                                        if(!$receipt['error']) // all ok
                                        {
+                                               
execMethod('property.soXport.update_actual_cost_from_archive',array($values['order_id']
 => true));
                                                $redirect = true;
                                        }
                                }

Modified: trunk/property/setup/setup.inc.php
===================================================================
--- trunk/property/setup/setup.inc.php  2012-06-21 12:22:12 UTC (rev 9642)
+++ trunk/property/setup/setup.inc.php  2012-06-21 13:01:02 UTC (rev 9643)
@@ -12,7 +12,7 @@
        */
 
        $setup_info['property']['name']                 = 'property';
-       $setup_info['property']['version']              = '0.9.17.646';
+       $setup_info['property']['version']              = '0.9.17.647';
        $setup_info['property']['app_order']    = 8;
        $setup_info['property']['enable']               = 1;
        $setup_info['property']['app_group']    = 'office';

Modified: trunk/property/setup/tables_update.inc.php
===================================================================
--- trunk/property/setup/tables_update.inc.php  2012-06-21 12:22:12 UTC (rev 
9642)
+++ trunk/property/setup/tables_update.inc.php  2012-06-21 13:01:02 UTC (rev 
9643)
@@ -6420,3 +6420,46 @@
                }
        }
 
+       /**
+       * Update property version from 0.9.17.643 to 0.9.17.644
+       * Add update values
+       */
+       $test[] = '0.9.17.646';
+       function property_upgrade0_9_17_646()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+               $GLOBALS['phpgw_setup']->oProc->query("SELECT project_id, 
sum(budget) AS sum_budget FROM fm_project_budget GROUP BY 
project_id",__LINE__,__FILE__);
+
+               $values = array();
+               while ($GLOBALS['phpgw_setup']->oProc->next_record())
+               {
+                       $values[] = array
+                       (
+                               'id'                    => 
(int)$GLOBALS['phpgw_setup']->oProc->f('project_id'),
+                               'budget'                => 
(int)$GLOBALS['phpgw_setup']->oProc->f('sum_budget')
+                       );
+               }
+
+               foreach ($values as $entry)
+               {
+                       $GLOBALS['phpgw_setup']->oProc->query("UPDATE 
fm_project SET budget = {$entry['budget']} WHERE id =  
{$entry['id']}",__LINE__,__FILE__);
+               }
+
+               $GLOBALS['phpgw_setup']->oProc->query("SELECT id FROM 
fm_workorder",__LINE__,__FILE__);
+
+               $orders = array();
+               while ($GLOBALS['phpgw_setup']->oProc->next_record())
+               {
+                       $orders[$GLOBALS['phpgw_setup']->oProc->f('id')] = true;
+               }
+
+               
execMethod('property.soXport.update_actual_cost_from_archive',$orders);
+
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['property']['currentver'] = 
'0.9.17.647';
+                       return $GLOBALS['setup_info']['property']['currentver'];
+               }
+       }
+




reply via email to

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