fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [10215] Merge 10166:10210 from trunk


From: Sigurd Nes
Subject: [Fmsystem-commits] [10215] Merge 10166:10210 from trunk
Date: Mon, 15 Oct 2012 10:38:47 +0000

Revision: 10215
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10215
Author:   sigurdne
Date:     2012-10-15 10:38:47 +0000 (Mon, 15 Oct 2012)
Log Message:
-----------
Merge 10166:10210 from trunk

Modified Paths:
--------------
    branches/Version-1_0-branch/property/inc/class.historylog.inc.php
    branches/Version-1_0-branch/property/inc/class.soadmin_entity.inc.php
    branches/Version-1_0-branch/property/inc/class.soentity.inc.php
    branches/Version-1_0-branch/property/inc/class.soproject.inc.php
    branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php
    branches/Version-1_0-branch/property/inc/class.uiinvoice2.inc.php
    branches/Version-1_0-branch/property/inc/class.uiproject.inc.php
    branches/Version-1_0-branch/property/js/yahoo/project.edit.js
    branches/Version-1_0-branch/property/setup/setup.inc.php
    branches/Version-1_0-branch/property/setup/tables_current.inc.php
    branches/Version-1_0-branch/property/setup/tables_update.inc.php

Removed Paths:
-------------
    branches/Version-1_0-branch/property/js/tinybox2/

Modified: branches/Version-1_0-branch/property/inc/class.historylog.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.historylog.inc.php   
2012-10-15 10:33:33 UTC (rev 10214)
+++ branches/Version-1_0-branch/property/inc/class.historylog.inc.php   
2012-10-15 10:38:47 UTC (rev 10215)
@@ -123,7 +123,7 @@
                }
 
 
-               function add($status,$record_id,$new_value,$old_value 
='',$attrib_id='', $date='',$detail_id='')
+               function add($status,$record_id,$new_value,$old_value 
='',$attrib_id='', $date=0,$detail_id='')
                {
                        $attrib_id_field = $this->attrib_id_field;
                        $attrib_id_value = (isset($attrib_id) && $attrib_id ? 
",$attrib_id" : '');
@@ -139,9 +139,9 @@
                                $timestamp = date($this->db->datetime_format());
                        }
 
-                       $this->db->query("insert into $this->table 
(history_record_id,"
+                       $this->db->query("INSERT INTO {$this->table} 
(history_record_id,"
                                . 
"history_appname,history_owner,history_status,history_new_value, 
history_old_value, history_timestamp $attrib_id_field $detail_id_field) "
-                               . "values ('$record_id','" . $this->appname . 
"','"
+                               . "values ('{$record_id}','{$this->appname}','"
                                . $this->account . "','$status','"
                                . $this->db->db_addslashes($new_value) . "','"
                                . $this->db->db_addslashes($old_value) . "','" 
. $timestamp

Modified: branches/Version-1_0-branch/property/inc/class.soadmin_entity.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soadmin_entity.inc.php       
2012-10-15 10:33:33 UTC (rev 10214)
+++ branches/Version-1_0-branch/property/inc/class.soadmin_entity.inc.php       
2012-10-15 10:38:47 UTC (rev 10215)
@@ -1136,6 +1136,7 @@
                                                        $values_insert = array
                                                        (
                                                                'id'            
                        => $data['id'],
+                                                               'location_id'   
                => $location_id,
                                                                'type'          
                        => $type,
                                                                'guid'          
                        => $guid,
                                                                
'xml_representation'    => $this->db->db_addslashes($xml),

Modified: branches/Version-1_0-branch/property/inc/class.soentity.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soentity.inc.php     
2012-10-15 10:33:33 UTC (rev 10214)
+++ branches/Version-1_0-branch/property/inc/class.soentity.inc.php     
2012-10-15 10:38:47 UTC (rev 10215)
@@ -1579,7 +1579,8 @@
                        
                        if(!$sql)
                        {
-                               $sql = "SELECT fm_bim_item.* FROM fm_bim_item 
{$this->join} fm_bim_type ON fm_bim_type.id = fm_bim_item.type WHERE 
fm_bim_item.id = {$id} AND location_id = $location_id";                      
+//                             $sql = "SELECT fm_bim_item.* FROM fm_bim_item 
{$this->join} fm_bim_type ON fm_bim_type.id = fm_bim_item.type WHERE 
fm_bim_item.id = {$id} AND location_id = $location_id";                      
+                               $sql = "SELECT * FROM fm_bim_item WHERE 
fm_bim_item.id = {$id} AND location_id = $location_id";                 
                        }
 
                        $this->db->query($sql,__LINE__,__FILE__);
@@ -1762,7 +1763,11 @@
 
                                                if($entry['history'] == 1)
                                                {
-                                                       
$history_set[$entry['attrib_id']] = $entry['value'];
+                                                       
$history_set[$entry['attrib_id']] = array
+                                                       (
+                                                               'value' => 
$entry['value'],
+                                                               'date'  => 
$this->bocommon->date_to_timestamp($entry['date'])
+                                                       );
                                                }
                                        }
                                }
@@ -1822,9 +1827,9 @@
                        if (isset($history_set) AND is_array($history_set))
                        {
                                $historylog     = 
CreateObject('property.historylog',"{$this->type}_{$entity_id}_{$cat_id}");
-                               foreach ($history_set as $attrib_id => 
$new_value)
+                               foreach ($history_set as $attrib_id => $history)
                                {
-                                       
$historylog->add('SO',$values['id'],$new_value,false, $attrib_id);
+                                       
$historylog->add('SO',$values['id'],$history['value'],false, 
$attrib_id,$history['date']);
                                }
                        }
 
@@ -1878,6 +1883,7 @@
                        $values_insert = array
                        (
                                'id'                                    => $id,
+                               'location_id'                   => $location_id,
                                'type'                                  => 
$type,
                                'guid'                                  => 
$guid,
                                'xml_representation'    => 
$this->db->db_addslashes($xml),

Modified: branches/Version-1_0-branch/property/inc/class.soproject.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soproject.inc.php    
2012-10-15 10:33:33 UTC (rev 10214)
+++ branches/Version-1_0-branch/property/inc/class.soproject.inc.php    
2012-10-15 10:38:47 UTC (rev 10215)
@@ -1194,9 +1194,13 @@
                                'account_group'         => 
$project['b_account_id'],
                                'contact_id'            => 
$project['contact_id'],
                                'inherit_location'      => 
$project['inherit_location'],
-                               'periodization_id'      => 
$project['budget_periodization'],
                        );
 
+                       if(isset($project['budget_periodization']) && 
$project['budget_periodization'])
+                       {
+                               $value_set['periodization_id']  = 
$project['budget_periodization'];
+                       }
+
                        $data_attribute = 
$this->custom->prepare_for_db('fm_project', $values_attribute, $project['id']);
 
                        if(isset($data_attribute['value_set']))
@@ -1239,7 +1243,7 @@
 
                        if($project['delete_b_period'])
                        {
-                               
$this->delete_period_from_budget($project['id'], $project['delete_b_year']);
+                               
$this->delete_period_from_budget($project['id'], $project['delete_b_period']);
                        }
 
                        if($project['budget'])
@@ -1610,12 +1614,13 @@
                {
                        $project_id = (int) $project_id;
                        $closed_period = array();
+                       $project_budget = array();
+                       $project_order_amount = array();
 
 
                        $sql = "SELECT * FROM fm_project_budget WHERE 
project_id = {$project_id}";
                        $this->db->query($sql,__LINE__,__FILE__);
 
-                       $project_budget = array();
                        while ($this->db->next_record())
                        {
                                $year = $this->db->f('year');
@@ -1624,6 +1629,7 @@
                                $period = $year . sprintf("%02s", $month);
                                
                                $project_budget[$period] = 
(int)$this->db->f('budget');
+                               $project_order_amount[$period] = 
$this->db->f('order_amount');
                                $closed_period[$period] = 
!!$this->db->f('closed');
                        }
                        unset($year);                   
@@ -1730,74 +1736,87 @@
                                $_use_periodization = false;                    
                        }
 
-                       $config = CreateObject('phpgwapi.config','property');
-                       $config->read();
-                       $tax = 1+(($config->config_data['fm_tax'])/100);
 
-                       $sql = "SELECT fm_workorder.id, sum(calculation) as 
calculation, sum(budget) as budget, sum(contract_sum) as contract_sum, 
fm_workorder.addition, start_date"
-                       . " FROM fm_workorder"
-                       . " {$this->join} fm_workorder_status ON 
fm_workorder.status  = fm_workorder_status.id"
-                       . " WHERE project_id = {$project_id} AND 
(fm_workorder_status.closed IS NULL OR fm_workorder_status.closed != 1)"
-                       . " GROUP BY fm_workorder.id, 
fm_workorder.start_date,fm_workorder.addition ORDER BY start_date ASC";
-                       $this->db->query($sql,__LINE__,__FILE__);
+                       if(!$_use_periodization)
+                       {
+                               $config = 
CreateObject('phpgwapi.config','property');
+                               $config->read();
+                               $tax = 1+(($config->config_data['fm_tax'])/100);
 
+                               $sql = "SELECT fm_workorder.id, 
sum(calculation) as calculation, sum(budget) as budget, sum(contract_sum) as 
contract_sum, fm_workorder.addition, start_date"
+                               . " FROM fm_workorder"
+                               . " {$this->join} fm_workorder_status ON 
fm_workorder.status  = fm_workorder_status.id"
+                               . " WHERE project_id = {$project_id} AND 
(fm_workorder_status.closed IS NULL OR fm_workorder_status.closed != 1)"
+                               . " GROUP BY fm_workorder.id, 
fm_workorder.start_date,fm_workorder.addition ORDER BY start_date ASC";
+                               $this->db->query($sql,__LINE__,__FILE__);
 
-                       while ($this->db->next_record())
-                       {
-                               $_found = false;
-                               $_start_date = $this->db->f('start_date');
-                               $_order_period = date('Ym', $_start_date);
-                               
-                               $year = date('Y');
-                               
-                               if($_use_periodization)
+                               while ($this->db->next_record())
                                {
-                                       $periode = $_order_period;
-                                       if(isset($project_budget[$periode]))
+                                       $_found = false;
+                                       $_start_date = 
$this->db->f('start_date');
+                                       $_order_period = date('Ym', 
$_start_date);
+                                       
+                                       $year = date('Y');
+                                       
+                                       if($_use_periodization)
                                        {
-                                               $_found = true;
-                                       }
-                               }
-
-                               if(!$_found) //move to current
-                               {
-                                       $check_months = array(0, date('m'));
-                                       foreach ($check_months as $i)
-                                       {
-                                               $periode = $year . 
sprintf("%02s", $i);
+                                               $periode = $_order_period;
                                                
if(isset($project_budget[$periode]))
                                                {
                                                        $_found = true;
-                                                       break;
                                                }
                                        }
-                               }
+       
+                                       if(!$_found) //move to current
+                                       {
+                                               $check_months = array(0, 
date('m'));
+                                               foreach ($check_months as $i)
+                                               {
+                                                       $periode = $year . 
sprintf("%02s", $i);
+                                                       
if(isset($project_budget[$periode]))
+                                                       {
+                                                               $_found = true;
+                                                               break;
+                                                       }
+                                               }
+                                       }
                                        
-                               if(!$_found)
-                               {
-                                       $periode = date('Ym');
+                                       if(!$_found)
+                                       {
+                                               $periode = date('Ym');
+                                       }
+       
+                                       if(abs($this->db->f('contract_sum')) > 
0)
+                                       {
+                                               $_amount = 
$this->db->f('contract_sum') * ( 1 + ((int)$this->db->f('addition')/100));
+                                       }
+                                       else 
if(abs($this->db->f('calculation')) > 0)
+                                       {
+                                               $_amount = 
$this->db->f('calculation') * $tax;
+                                       }
+                                       else if(abs($this->db->f('budget')) > 0)
+                                       {
+                                               $_amount = 
$this->db->f('budget');
+                                       }
+                                       else
+                                       {
+                                               $_amount = 0;
+                                       }
+
+                                       
$orders[$periode][$this->db->f('id')]['amount'] = $_amount;
                                }
+                               unset($periode);
+                       }
+                       else
+                       {
 
-                               if(abs($this->db->f('contract_sum')) > 0)
+                               //FIXME
+                               foreach ($project_order_amount as $periode => 
$_amount)
                                {
-                                       $_amount = $this->db->f('contract_sum') 
* ( 1 + ((int)$this->db->f('addition')/100));
+                                       $orders[$periode][] = array('amount' => 
$_amount);
                                }
-                               else if(abs($this->db->f('calculation')) > 0)
-                               {
-                                       $_amount = $this->db->f('calculation') 
* $tax;
-                               }
-                               else if(abs($this->db->f('budget')) > 0)
-                               {
-                                       $_amount = $this->db->f('budget');
-                               }
-                               else
-                               {
-                                       $_amount = 0;
-                               }
 
-                               $orders[$periode][$this->db->f('id')]['amount'] 
= $_amount;
                        }
-                       unset($periode);
 
                        $sort_period = array();
                        $values = array();
@@ -1927,7 +1946,9 @@
                                $month = substr( $entry['period'], 4, 2 );
                                $entry['month'] = $month == '00' ? '' : $month;
                                $entry['diff'] = $entry['budget'] - 
$entry['sum_orders'] - $entry['actual_cost'];
-       //                      $entry['deviation'] = $entry['budget'] - 
$entry['actual_cost'];
+                               $deviation = $entry['budget'] - 
$entry['actual_cost'];
+                               $entry['deviation'] = $deviation;
+                               $entry['deviation_percent'] = 
$deviation/$entry['budget'] * 100;
                                $entry['closed'] = 
$closed_period[$entry['period']];
                        }
 
@@ -1941,7 +1962,7 @@
                        foreach($data as $entry)
                        {
                                $when = explode('_', $entry);
-                               $sql = "DELETE FROM fm_project_budget WHERE 
project_id = {$project_id} AND year =" . (int) $when[0] . ' AND month = ' . 
(int) $when[1];
+                               $sql = "DELETE FROM fm_project_budget WHERE 
project_id = {$project_id} AND year = " . (int) $when[0] . ' AND month = ' . 
(int) $when[1];
                                $this->db->query($sql,__LINE__,__FILE__);
                        }
                }

Modified: branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php  
2012-10-15 10:33:33 UTC (rev 10214)
+++ branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php  
2012-10-15 10:38:47 UTC (rev 10215)
@@ -1077,6 +1077,17 @@
                        }
                        $workorder['contract_sum']              = 
str_replace(array(' ',','),array('','.'),$workorder['contract_sum']);
 
+
+                       if ( abs((int)$workorder['contract_sum']) > 0)
+                       {
+                               $addition = 1 + 
((int)$workorder['addition_percentage']/100);
+                               $combined_cost = 
(int)$workorder['contract_sum'] * $addition;
+                       }
+                       else
+                       {
+                               $combined_cost = (int)$workorder['budget'];
+                       }
+
                        $values= array
                                (
                                        $id,
@@ -1090,7 +1101,7 @@
                                        $workorder['status'],
                                        $workorder['descr'],
                                        (int) $workorder['budget'],
-                                       (int) $workorder['budget'],
+                                       $combined_cost,
                                        $workorder['b_account_id'],
                                        $workorder['addition_rs'],
                                        $workorder['addition_percentage'],
@@ -1107,7 +1118,7 @@
                                        isset($workorder['vendor_email']) && 
is_array($workorder['vendor_email']) ? implode(',', $workorder['vendor_email']) 
: ''
                                );
 
-                       $values = $this->bocommon->validate_db_insert($values);
+                       $values = $this->db->validate_insert($values);
 
                        $this->db->query("INSERT INTO fm_workorder 
(id,num,project_id,title,access,entry_date,start_date,end_date,status,"
                                . 
"descr,budget,combined_cost,account_id,rig_addition,addition,key_deliver,key_fetch,vendor_id,charge_tenant,user_id,ecodimb,category,billable_hours,contract_sum,approved,mail_recipients
  $cols) "
@@ -1115,6 +1126,12 @@
 
                        $this->db->query("INSERT INTO fm_orders (id,type) 
VALUES ({$id},'workorder')");
 
+                       $this->db->query("SELECT periodization_id FROM 
fm_project WHERE id = {$workorder['project_id']}",__LINE__,__FILE__);
+                       $this->db->next_record();
+                       $periodization_id = $this->db->f('periodization_id');
+                       
+                       $this->_update_project_budget($workorder['project_id'], 
date('Y', $workorder['start_date']), $periodization_id, $combined_cost);
+
 /*
                        if($workorder['charge_tenant'])
                        {
@@ -1166,13 +1183,14 @@
                        $workorder['title'] = 
$this->db->db_addslashes($workorder['title']);
                        $workorder['billable_hours'] = 
(float)str_replace(',','.', $workorder['billable_hours']);
 
-                       $this->db->query("SELECT 
status,budget,calculation,billable_hours,approved FROM fm_workorder WHERE id = 
{$workorder['id']}",__LINE__,__FILE__);
+                       $this->db->query("SELECT 
status,budget,calculation,billable_hours,approved,combined_cost FROM 
fm_workorder WHERE id = {$workorder['id']}",__LINE__,__FILE__);
                        $this->db->next_record();
 
                        $old_status                     = 
$this->db->f('status');
                        $old_budget                     = 
$this->db->f('budget');
                        $old_billable_hours     = 
$this->db->f('billable_hours');
                        $old_approved           = $this->db->f('approved');
+                       $old_combined_cost      = $this->db->f('combined_cost');
 
                        if 
(isset($GLOBALS['phpgw_info']['user']['preferences']['common']['currency']))
                        {
@@ -1215,29 +1233,29 @@
                        }
 
                        $value_set = array
-                               (
-                                       'title'                         => 
$workorder['title'],
-                                       'status'                        => 
$workorder['status'],
-                                       'start_date'            => 
$workorder['start_date'],
-                                       'end_date'                      => 
$workorder['end_date'],
-                                       'descr'                         => 
$workorder['descr'],
-                                       'budget'                        => 
(int)$workorder['budget'],
-                                       'combined_cost'         => 
$combined_cost,
-                                       'key_deliver'           => 
$workorder['key_deliver'],
-                                       'key_fetch'                     => 
$workorder['key_fetch'],
-                                       'account_id'            => 
$workorder['b_account_id'],
-                                       'rig_addition'          => 
$workorder['addition_rs'],
-                                       'addition'                      => 
$workorder['addition_percentage'],
-                                       'charge_tenant'         => 
$workorder['charge_tenant'],
-                                       'vendor_id'                     => 
$workorder['vendor_id'],
-                                       'user_id'                       => 
$workorder['user_id'],
-                                       'ecodimb'                       => 
$workorder['ecodimb'],
-                                       'category'                      => 
$workorder['cat_id'],
-                                       'billable_hours'        => 
$workorder['billable_hours'],
-                                       'contract_sum'          => 
$workorder['contract_sum'],
-                                       'approved'                      => 
$workorder['approved'],
-                                       'mail_recipients'       => 
isset($workorder['vendor_email']) && is_array($workorder['vendor_email']) ? 
implode(',', $workorder['vendor_email']) : '',
-                               );
+                       (
+                               'title'                         => 
$workorder['title'],
+                               'status'                        => 
$workorder['status'],
+                               'start_date'            => 
$workorder['start_date'],
+                               'end_date'                      => 
$workorder['end_date'],
+                               'descr'                         => 
$workorder['descr'],
+                               'budget'                        => 
(int)$workorder['budget'],
+                               'combined_cost'         => $combined_cost,
+                               'key_deliver'           => 
$workorder['key_deliver'],
+                               'key_fetch'                     => 
$workorder['key_fetch'],
+                               'account_id'            => 
$workorder['b_account_id'],
+                               'rig_addition'          => 
$workorder['addition_rs'],
+                               'addition'                      => 
$workorder['addition_percentage'],
+                               'charge_tenant'         => 
$workorder['charge_tenant'],
+                               'vendor_id'                     => 
$workorder['vendor_id'],
+                               'user_id'                       => 
$workorder['user_id'],
+                               'ecodimb'                       => 
$workorder['ecodimb'],
+                               'category'                      => 
$workorder['cat_id'],
+                               'billable_hours'        => 
$workorder['billable_hours'],
+                               'contract_sum'          => 
$workorder['contract_sum'],
+                               'approved'                      => 
$workorder['approved'],
+                               'mail_recipients'       => 
isset($workorder['vendor_email']) && is_array($workorder['vendor_email']) ? 
implode(',', $workorder['vendor_email']) : '',
+                       );
 
                        if($workorder['status'] == 'closed')
                        {
@@ -1272,7 +1290,7 @@
                                $value_set['address'] = $address;
                        }
 
-                       $value_set      = 
$this->bocommon->validate_db_update($value_set);
+                       $value_set      = 
$this->db->validate_update($value_set);
 
                        $this->db->transaction_begin();
 
@@ -1283,9 +1301,16 @@
                        $value_set_invoice['dime']                      = 
$workorder['cat_id'];
                        $value_set_invoice['dimb']                      = 
$workorder['ecodimb'];
 
-                       $value_set_invoice      = 
$this->bocommon->validate_db_update($value_set_invoice);
+                       $value_set_invoice      = 
$this->db->validate_update($value_set_invoice);
                        $this->db->query("UPDATE fm_ecobilag SET 
{$value_set_invoice} WHERE pmwrkord_code = '{$workorder['id']}'" 
,__LINE__,__FILE__);
 
+
+                       $this->db->query("SELECT periodization_id FROM 
fm_project WHERE id = {$workorder['project_id']}",__LINE__,__FILE__);
+                       $this->db->next_record();
+                       $periodization_id = $this->db->f('periodization_id');
+                       
+                       $this->_update_project_budget($workorder['project_id'], 
date('Y', $workorder['start_date']), $periodization_id, 
$combined_cost,$old_combined_cost);
+
 /*                     if($workorder['charge_tenant'])
                        {
                                $this->db->query("UPDATE fm_project set 
charge_tenant = 1 WHERE id =" . $workorder['project_id']);
@@ -1540,6 +1565,8 @@
 
                function recalculate()
                {
+                       $this->db->transaction_begin();
+
                        set_time_limit (0);
 
                        $this->db->query("SELECT id FROM fm_workorder ORDER BY 
id ASC",__LINE__,__FILE__);
@@ -1556,9 +1583,11 @@
                        $config->read_repository();
                        $tax = 1+(($config->config_data['fm_tax'])/100);
 
+                       $this->db->query("UPDATE fm_project_budget SET 
order_amount = 0",__LINE__,__FILE__);
+
                        foreach ($orders as $id => $dummy)
                        {
-                               $this->db->query("SELECT combined_cost, 
budget,calculation,contract_sum,addition FROM fm_workorder WHERE id = 
{$id}",__LINE__,__FILE__);
+                               $this->db->query("SELECT project_id, 
start_date, combined_cost, budget,calculation,contract_sum,addition FROM 
fm_workorder WHERE id = {$id}",__LINE__,__FILE__);
                                $this->db->next_record();
 
                                $old_combined_cost      = 
$this->db->f('combined_cost');
@@ -1566,6 +1595,8 @@
                                $calculation            = 
$this->db->f('calculation');
                                $contract_sum           = 
$this->db->f('contract_sum');
                                $addition                       = 
$this->db->f('addition');
+                               $project_id                     = 
$this->db->f('project_id');
+                               $start_date                     = 
$this->db->f('start_date');
 
                                if ( abs((int)$contract_sum) > 0)
                                {
@@ -1586,6 +1617,12 @@
                                        
//_debug_array(array($old_combined_cost,$combined_cost));
                                        $this->db->query("UPDATE fm_workorder 
SET combined_cost = '{$combined_cost}' WHERE id = {$id}",__LINE__,__FILE__);
                                }
+
+                               $this->db->query("SELECT periodization_id FROM 
fm_project WHERE id = {$project_id}",__LINE__,__FILE__);
+                               $this->db->next_record();
+                               $periodization_id = 
$this->db->f('periodization_id');
+
+                               $this->_update_project_budget($project_id, 
date('Y', $start_date), $periodization_id, $combined_cost);
                        }
 
                        $config = CreateObject('phpgwapi.config','property');
@@ -1612,5 +1649,46 @@
                                        $this->db->query("UPDATE fm_workorder 
SET location_code = '{$location_code}' WHERE id = 
{$order['id']}",__LINE__,__FILE__);
                                }
                        }
+
+                       $this->db->transaction_commit();
                }
+
+               protected function _update_project_budget($project_id, $year, 
$periodization_id, $combined_cost, $old_combined_cost = 0)
+               {
+                       $project_id = (int) $project_id;
+                       $year = $year ? (int) $year : date('Y');
+
+                       $periodization_id = (int) $periodization_id;
+                       $periodization_outline = array();
+
+                       if($periodization_id)
+                       {
+                               $this->db->query("SELECT month, value FROM 
fm_eco_periodization_outline WHERE periodization_id = {$periodization_id} ORDER 
BY month ASC",__LINE__,__FILE__);
+                               while ($this->db->next_record())
+                               {
+                                       $periodization_outline[] = array
+                                       (
+                                               'month' => 
$this->db->f('month'),
+                                               'value' => 
$this->db->f('value'),
+                                       );
+                               }
+                       }
+                       else
+                       {
+                               $periodization_outline[] = array
+                               (
+                                       'month' => 0,
+                                       'value' => 100,
+                               );
+                       
+                       }
+
+                       foreach ($periodization_outline as $outline)
+                       {
+                               $partial_amount = $combined_cost * 
$outline['value'] / 100;
+                               $old_partial_amount = $old_combined_cost * 
$outline['value'] / 100;
+                               $sql = "UPDATE fm_project_budget SET 
order_amount = order_amount + {$partial_amount} - {$old_combined_cost} WHERE 
project_id = {$project_id} AND year = {$year} AND month =" . 
(int)$outline['month'];
+                               $this->db->query($sql,__LINE__,__FILE__);
+                       }
+               }
        }

Modified: branches/Version-1_0-branch/property/inc/class.uiinvoice2.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uiinvoice2.inc.php   
2012-10-15 10:33:33 UTC (rev 10214)
+++ branches/Version-1_0-branch/property/inc/class.uiinvoice2.inc.php   
2012-10-15 10:38:47 UTC (rev 10215)
@@ -444,8 +444,8 @@
 
                        self::add_javascript('property', 'portico', 
'ajax_invoice.js');
                        self::add_javascript('property', 'yahoo', 
'invoice2.index.js');
-                       self::add_javascript('property', 'tinybox2', 
'packed.js');
-                       
$GLOBALS['phpgw']->css->add_external_file('property/js/tinybox2/style.css');
+                       self::add_javascript('phpgwapi', 'tinybox2', 
'packed.js');
+                       
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/tinybox2/style.css');
 
                        $GLOBALS['phpgw']->xslttpl->add_file(array('invoice2'));
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('data' => $data));

Modified: branches/Version-1_0-branch/property/inc/class.uiproject.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uiproject.inc.php    
2012-10-15 10:33:33 UTC (rev 10214)
+++ branches/Version-1_0-branch/property/inc/class.uiproject.inc.php    
2012-10-15 10:38:47 UTC (rev 10215)
@@ -1718,9 +1718,10 @@
                                                                                
                                array('key' => 
'month','label'=>lang('month'),'sortable'=>false,'resizeable'=>true),
                                                                                
                                array('key' => 
'budget','label'=>lang('budget'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
                                                                                
                                array('key' => 'sum_orders','label'=>lang('sum 
orders'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
-                                                                               
                                array('key' => 
'actual_cost','label'=>lang('actual 
cost'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount2'),
-                                                                               
                                array('key' => 
'diff','label'=>lang('difference'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount2'),
-                                                                               
//                              array('key' => 
'deviation','label'=>lang('deviation'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount2'),
+                                                                               
                                array('key' => 
'actual_cost','label'=>lang('actual 
cost'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+                                                                               
                                array('key' => 
'diff','label'=>lang('difference'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+                                                                               
                                array('key' => 
'deviation','label'=>lang('deviation'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+                                                                               
                                array('key' => 
'deviation_percent','label'=>lang('deviation') . '::' . 
lang('percent'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount2'),
                                                                                
                                array('key' => 
'closed','label'=>lang('closed'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter'),
                                                                                
                                array('key' => 'closed_orig','hidden' => true),
                                                                                
                                array('key' => 
'delete_year','label'=>lang('Delete'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter')))

Modified: branches/Version-1_0-branch/property/js/yahoo/project.edit.js
===================================================================
--- branches/Version-1_0-branch/property/js/yahoo/project.edit.js       
2012-10-15 10:33:33 UTC (rev 10214)
+++ branches/Version-1_0-branch/property/js/yahoo/project.edit.js       
2012-10-15 10:38:47 UTC (rev 10215)
@@ -95,9 +95,9 @@
                //call getTotalSum(name of column) in property.js
                tmp_sum1 = getTotalSum('budget',0,paginator,datatable);
                tmp_sum2 = getTotalSum('sum_orders',0,paginator,datatable);
-               tmp_sum3 = getTotalSum('actual_cost',2,paginator,datatable);
-               tmp_sum4 = getTotalSum('diff',2,paginator,datatable);
- //            tmp_sum5 = getTotalSum('deviation',2,paginator,datatable);
+               tmp_sum3 = getTotalSum('actual_cost',0,paginator,datatable);
+               tmp_sum4 = getTotalSum('diff',0,paginator,datatable);
+               tmp_sum5 = getTotalSum('deviation',0,paginator,datatable);
 
                if(typeof(tableYUI0)=='undefined')
                {
@@ -118,8 +118,8 @@
                td_sum(tmp_sum2);
                td_sum(tmp_sum3);
                td_sum(tmp_sum4);
-//             td_sum(tmp_sum5);
-               td_empty(3);
+               td_sum(tmp_sum5);
+               td_empty(4);
 
                myfoot = tableYUI0.createTFoot();
                myfoot.setAttribute("id","myfoot");

Modified: branches/Version-1_0-branch/property/setup/setup.inc.php
===================================================================
--- branches/Version-1_0-branch/property/setup/setup.inc.php    2012-10-15 
10:33:33 UTC (rev 10214)
+++ branches/Version-1_0-branch/property/setup/setup.inc.php    2012-10-15 
10:38:47 UTC (rev 10215)
@@ -12,7 +12,7 @@
        */
 
        $setup_info['property']['name']                 = 'property';
-       $setup_info['property']['version']              = '0.9.17.652';
+       $setup_info['property']['version']              = '0.9.17.653';
        $setup_info['property']['app_order']    = 8;
        $setup_info['property']['enable']               = 1;
        $setup_info['property']['app_group']    = 'office';

Modified: branches/Version-1_0-branch/property/setup/tables_current.inc.php
===================================================================
--- branches/Version-1_0-branch/property/setup/tables_current.inc.php   
2012-10-15 10:33:33 UTC (rev 10214)
+++ branches/Version-1_0-branch/property/setup/tables_current.inc.php   
2012-10-15 10:38:47 UTC (rev 10215)
@@ -1244,7 +1244,7 @@
                                'id' => array('type' => 'auto','precision' => 
4,'nullable' => False),
                                'periodization_id' => array('type' => 
'int','precision' => '4','nullable' => False),
                                'month' => array('type' => 'int','precision' => 
'4','nullable' => true),
-                               'value' => array('type' => 
'decimal','precision' => '20','scale' => '2','nullable' => false,'default' => 
'0.00'),
+                               'value' => array('type' => 
'decimal','precision' => '20','scale' => '6','nullable' => false,'default' => 
'0.000000'),
                                'remark' => array('type' => 
'varchar','precision' => '60','nullable' => False),
                        ),
                        'pk' => array('id'),
@@ -1464,6 +1464,7 @@
                                'year' => array('type' => 'int','precision' => 
4,'nullable' => False),
                                'month' => array('type' => 'int','precision' => 
2,'nullable' => False,'default' => 0),
                                'budget' => array('type' => 
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' => 
'0.00'),
+                               'order_amount' => array('type' => 
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' => 
'0.00'),
                                'closed' => array('type' => 'int','precision' 
=> 2,'nullable' => True),
                                'user_id' => array('type' => 'int','precision' 
=> 4,'nullable' => True),
                                'entry_date' => array('type' => 
'int','precision' => 4,'nullable' => True),

Modified: branches/Version-1_0-branch/property/setup/tables_update.inc.php
===================================================================
--- branches/Version-1_0-branch/property/setup/tables_update.inc.php    
2012-10-15 10:33:33 UTC (rev 10214)
+++ branches/Version-1_0-branch/property/setup/tables_update.inc.php    
2012-10-15 10:38:47 UTC (rev 10215)
@@ -6704,3 +6704,37 @@
                }
        }
 
+       /**
+       * Update property version from 0.9.17.652 to 0.9.17.653
+       * Enable to close periode on budget
+       */
+       $test[] = '0.9.17.652';
+       function property_upgrade0_9_17_652()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_project_budget','order_amount',array(
+                       'type'          => 'decimal',
+                       'precision'     => 20,
+                       'scale'         => 2,
+                       'nullable'      => true,
+                       'default'       => '0.00'
+                       )
+               );
+
+               
$GLOBALS['phpgw_setup']->oProc->AlterColumn('fm_eco_periodization_outline','value',array(
+                       'type'          => 'decimal',
+                       'precision'     => '20',
+                       'scale'         => '6',
+                       'nullable'      => false,
+                       'default'       => '0.000000'
+                       )
+               );
+
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['property']['currentver'] = 
'0.9.17.653';
+                       return $GLOBALS['setup_info']['property']['currentver'];
+               }
+       }
+




reply via email to

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