fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [10125] property: more on budgets


From: Sigurd Nes
Subject: [Fmsystem-commits] [10125] property: more on budgets
Date: Sun, 07 Oct 2012 13:14:28 +0000

Revision: 10125
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10125
Author:   sigurdne
Date:     2012-10-07 13:14:28 +0000 (Sun, 07 Oct 2012)
Log Message:
-----------
property: more on budgets

Modified Paths:
--------------
    trunk/property/inc/class.soproject.inc.php
    trunk/property/setup/setup.inc.php
    trunk/property/setup/tables_current.inc.php
    trunk/property/setup/tables_update.inc.php

Modified: trunk/property/inc/class.soproject.inc.php
===================================================================
--- trunk/property/inc/class.soproject.inc.php  2012-10-07 12:24:38 UTC (rev 
10124)
+++ trunk/property/inc/class.soproject.inc.php  2012-10-07 13:14:28 UTC (rev 
10125)
@@ -1018,13 +1018,14 @@
                                        $project['ecodimb'],
                                        $project['b_account_id'],
                                        $project['contact_id'],
-                                       $project['inherit_location']
+                                       $project['inherit_location'],
+                                       $project['budget_periodization'],
                                );
 
                        $values = $this->bocommon->validate_db_insert($values);
 
                        $this->db->query("INSERT INTO fm_project 
(id,project_group,name,access,category,entry_date,start_date,end_date,coordinator,status,"
-                               . 
"descr,budget,reserve,location_code,address,key_deliver,key_fetch,other_branch,key_responsible,user_id,ecodimb,account_group,contact_id,inherit_location
 $cols) "
+                               . 
"descr,budget,reserve,location_code,address,key_deliver,key_fetch,other_branch,key_responsible,user_id,ecodimb,account_group,contact_id,inherit_location,periodization_id
 $cols) "
                                . "VALUES ($values $vals )",__LINE__,__FILE__);
 
                        if($project['budget'])
@@ -1192,7 +1193,8 @@
                                'ecodimb'                       => 
$project['ecodimb'],
                                'account_group'         => 
$project['b_account_id'],
                                'contact_id'            => 
$project['contact_id'],
-                               'inherit_location'      => 
$project['inherit_location']
+                               'inherit_location'      => 
$project['inherit_location'],
+                               'periodization_id'      => 
$project['budget_periodization'],
                        );
 
                        $data_attribute = 
$this->custom->prepare_for_db('fm_project', $values_attribute, $project['id']);
@@ -1717,12 +1719,22 @@
                                }
                        }
 
+                       $this->db->query("SELECT periodization_id FROM 
fm_project WHERE id = {$project_id}",__LINE__,__FILE__);
+                       $this->db->next_record();
+                       if($this->db->f('periodization_id'))
+                       {
+                               $_use_periodization = true;
+                       }
+                       else
+                       {
+                               $_use_periodization = false;                    
+                       }
+
                        $config = CreateObject('phpgwapi.config','property');
                        $config->read();
                        $tax = 1+(($config->config_data['fm_tax'])/100);
 
-//                     $sql = "SELECT fm_workorder.id, EXTRACT(YEAR from 
to_timestamp(start_date) ) as year, sum(calculation) as calculation, 
sum(budget) as budget, sum(contract_sum) as contract_sum, fm_workorder.addition"
-                       $sql = "SELECT fm_workorder.id, sum(calculation) as 
calculation, sum(budget) as budget, sum(contract_sum) as contract_sum, 
fm_workorder.addition"
+                       $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)"
@@ -1732,21 +1744,34 @@
 
                        while ($this->db->next_record())
                        {
-                               $year = date('Y');
                                $_found = false;
+                               $_start_date = $this->db->f('start_date');
+                               $_order_period = date('Ym', $_start_date);
                                
-                               //move to current
-                               $check_months = array(0, date('m'));
+                               $year = date('Y');
                                
-                               foreach ($check_months as $i)
+                               if($_use_periodization)
                                {
-                                       $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)
                                {

Modified: trunk/property/setup/setup.inc.php
===================================================================
--- trunk/property/setup/setup.inc.php  2012-10-07 12:24:38 UTC (rev 10124)
+++ trunk/property/setup/setup.inc.php  2012-10-07 13:14:28 UTC (rev 10125)
@@ -12,7 +12,7 @@
        */
 
        $setup_info['property']['name']                 = 'property';
-       $setup_info['property']['version']              = '0.9.17.651';
+       $setup_info['property']['version']              = '0.9.17.652';
        $setup_info['property']['app_order']    = 8;
        $setup_info['property']['enable']               = 1;
        $setup_info['property']['app_group']    = 'office';

Modified: trunk/property/setup/tables_current.inc.php
===================================================================
--- trunk/property/setup/tables_current.inc.php 2012-10-07 12:24:38 UTC (rev 
10124)
+++ trunk/property/setup/tables_current.inc.php 2012-10-07 13:14:28 UTC (rev 
10125)
@@ -1451,6 +1451,7 @@
                                'contact_id' => array('type' => 
'int','precision' => 4,'nullable' => True),
                                'account_group' => array('type' => 
'int','precision' => 4,'nullable' => True),
                                'inherit_location' => array('type' => 
'int','precision' => 2,'nullable' => True,'default' => 1),
+                               'periodization_id' => array('type'              
=> 'int','precision'    => 4,'nullable' => true)
                        ),
                        'pk' => array('id'),
                        'fk' => array(),

Modified: trunk/property/setup/tables_update.inc.php
===================================================================
--- trunk/property/setup/tables_update.inc.php  2012-10-07 12:24:38 UTC (rev 
10124)
+++ trunk/property/setup/tables_update.inc.php  2012-10-07 13:14:28 UTC (rev 
10125)
@@ -6680,3 +6680,27 @@
                        return $GLOBALS['setup_info']['property']['currentver'];
                }
        }
+
+       /**
+       * Update property version from 0.9.17.651 to 0.9.17.652
+       * Enable to close periode on budget
+       */
+       $test[] = '0.9.17.651';
+       function property_upgrade0_9_17_651()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_project','periodization_id',array(
+                       'type'          => 'int',
+                       'precision'     => 4,
+                       'nullable'      => true
+                       )
+               );
+
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['property']['currentver'] = 
'0.9.17.652';
+                       return $GLOBALS['setup_info']['property']['currentver'];
+               }
+       }
+




reply via email to

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