fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [8700] property: project budgetting


From: Sigurd Nes
Subject: [Fmsystem-commits] [8700] property: project budgetting
Date: Fri, 27 Jan 2012 13:54:52 +0000

Revision: 8700
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8700
Author:   sigurdne
Date:     2012-01-27 13:54:51 +0000 (Fri, 27 Jan 2012)
Log Message:
-----------
property: project budgetting

Modified Paths:
--------------
    trunk/property/inc/class.boproject.inc.php
    trunk/property/inc/class.soproject.inc.php
    trunk/property/inc/class.uiproject.inc.php
    trunk/property/js/yahoo/project.edit.js
    trunk/property/setup/tables_current.inc.php
    trunk/property/setup/tables_update.inc.php
    trunk/property/templates/base/project.xsl

Modified: trunk/property/inc/class.boproject.inc.php
===================================================================
--- trunk/property/inc/class.boproject.inc.php  2012-01-27 12:59:43 UTC (rev 
8699)
+++ trunk/property/inc/class.boproject.inc.php  2012-01-27 13:54:51 UTC (rev 
8700)
@@ -815,4 +815,9 @@
                {
                        return $this->so->get_user_list();
                }
+
+               public function get_budget($project_id)
+               {
+                       return $this->so->get_budget($project_id);
+               }
        }

Modified: trunk/property/inc/class.soproject.inc.php
===================================================================
--- trunk/property/inc/class.soproject.inc.php  2012-01-27 12:59:43 UTC (rev 
8699)
+++ trunk/property/inc/class.soproject.inc.php  2012-01-27 13:54:51 UTC (rev 
8700)
@@ -116,7 +116,7 @@
                        $wo_hour_cat_id = 
isset($data['wo_hour_cat_id'])?$data['wo_hour_cat_id']:'';
                        $district_id    = 
isset($data['district_id'])?$data['district_id']:'';
                        $dry_run                = isset($data['dry_run']) ? 
$data['dry_run'] : '';
-                       $criteria               = isset($data['criteria']) && 
$data['criteria'] ? $data['criteria'] : array();                          
+                       $criteria               = isset($data['criteria']) && 
$data['criteria'] ? $data['criteria'] : array();
 
                        $sql = $this->bocommon->fm_cache('sql_project_' . 
!!$wo_hour_cat_id);
 
@@ -503,7 +503,7 @@
                                        $matchtypes = array
                                                (
                                                        'exact' => '=',
-                                                       'like'  => $this->like  
                                        
+                                                       'like'  => $this->like
                                                );
 
                                        if(count($criteria) > 1)
@@ -549,7 +549,7 @@
                        //echo substr($sql,strripos($sql,'from'));
 
                        
if($GLOBALS['phpgw_info']['server']['db_type']=='postgres')
-                       {                               
+                       {
                                $sql_minimized = 'SELECT DISTINCT fm_project.id 
'  . substr($sql_full,strripos($sql_full,'FROM'));
                                $sql_count = "SELECT count(id) as cnt FROM 
({$sql_minimized}) as t";
 
@@ -862,6 +862,11 @@
                                . 
"descr,budget,reserve,location_code,address,key_deliver,key_fetch,other_branch,key_responsible,user_id,ecodimb,account_group,contact_id
 $cols) "
                                . "VALUES ($values $vals )",__LINE__,__FILE__);
 
+                       if($project['budget'])
+                       {
+                               $this->updat_budget($id, $project['year'], 
$project['budget']);
+                       }
+
                        if($project['extra']['contact_phone'] && 
$project['extra']['tenant_id'])
                        {
                                $this->db->query("update fm_tenant set 
contact_phone='". $project['extra']['contact_phone']. "' where id='". 
$project['extra']['tenant_id']. "'",__LINE__,__FILE__);
@@ -883,12 +888,12 @@
                        if(is_array($project['origin']))
                        {
                                if($project['origin'][0]['data'][0]['id'])
-                               {                                       
+                               {
                                        $interlink_data = array
                                                (
                                                        'location1_id'          
=> $GLOBALS['phpgw']->locations->get_id('property', 
$project['origin'][0]['location']),
                                                        'location1_item_id' => 
$project['origin'][0]['data'][0]['id'],
-                                                       'location2_id'          
=> $GLOBALS['phpgw']->locations->get_id('property', '.project'),                
        
+                                                       'location2_id'          
=> $GLOBALS['phpgw']->locations->get_id('property', '.project'),
                                                        'location2_item_id' => 
$id,
                                                        'account_id'            
=> $this->account
                                                );
@@ -1012,7 +1017,6 @@
                                'end_date'                      => 
$project['end_date'],
                                'coordinator'           => 
$project['coordinator'],
                                'descr'                         => 
$project['descr'],
-                               'budget'                        => 
(int)$project['budget'],
                                'reserve'                       => 
(int)$project['reserve'],
                                'key_deliver'           => 
$project['key_deliver'],
                                'key_fetch'                     => 
$project['key_fetch'],
@@ -1056,6 +1060,16 @@
 
                        $this->db->query("UPDATE fm_project SET $value_set 
WHERE id= {$project['id']}",__LINE__,__FILE__);
 
+                       if($project['delete_b_year'])
+                       {
+                               $this->delete_year_from_budget($project['id'], 
$project['delete_b_year']);
+                       }
+
+                       if($project['budget'])
+                       {
+                               $new_budget = 
$this->updat_budget($project['id'], $project['year'], $project['budget']);
+                       }
+
                        if($project['extra']['contact_phone'] && 
$project['extra']['tenant_id'])
                        {
                                $this->db->query("UPDATE fm_tenant SET 
contact_phone='". $project['extra']['contact_phone']. "' WHERE id='". 
$project['extra']['tenant_id']. "'",__LINE__,__FILE__);
@@ -1202,7 +1216,7 @@
                                $receipt['notice_owner'][]=lang('Coordinator 
changed') . ': ' . 
$GLOBALS['phpgw']->accounts->id2name($project['coordinator']);
                        }
 
-                       if ($old_budget != (int)$project['budget'])
+                       if ($old_budget != $new_budget)
                        {
                                
$historylog->add('B',$project['id'],$project['budget'], $old_budget);
                        }
@@ -1239,6 +1253,74 @@
                }
 
 
+               function updat_budget($project_id, $year, $budget)
+               {
+                       $project_id = (int) $project_id;
+                       $year = $year ? (int) $year : date('Y');
+                       $budget = (int) $budget;
+                       $now = time();
+                       $sql = "SELECT budget FROM fm_project_budget WHERE 
project_id = {$project_id} AND year = $year";
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       if ($this->db->next_record())
+                       {
+                               $sql = "UPDATE fm_project_budget SET budget = 
{$budget}, modified_date = {$now} WHERE project_id = {$project_id} AND year = 
$year";
+                               $this->db->query($sql,__LINE__,__FILE__);
+                       }
+                       else
+                       {
+                               $value_set = array
+                               (
+                                       'project_id'            => $project_id,
+                                       'year'                          => 
$year,
+                                       'budget'                        => 
$budget,
+                                       'user_id'                       => 
$this->account,
+                                       'entry_date'            => $now,
+                                       'modified_date'         => $now
+                               );
+
+                               $cols = implode(',', array_keys($value_set));
+                               $values = 
$this->db->validate_insert(array_values($value_set));
+                               $this->db->query("INSERT INTO fm_project_budget 
({$cols}) VALUES ({$values})",__LINE__,__FILE__);
+                       }
+                       $sql = "SELECT sum(budget) as sum_budget FROM 
fm_project_budget WHERE project_id = {$project_id}";
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->next_record();
+                       $sum_budget = (int)$this->db->f('sum_budget');
+                       $sql = "UPDATE fm_project SET budget = {$sum_budget} 
WHERE id = {$project_id}";
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       return $sum_budget;
+               }
+
+               function get_budget($project_id)
+               {
+                       $project_id = (int) $project_id;
+                       $values = array();
+
+                       $sql = "SELECT * FROM fm_project_budget WHERE 
project_id = {$project_id}";
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       while ($this->db->next_record())
+                       {
+                               $values[] = array
+                               (
+                                       'project_id'            => 
$this->db->f('project_id'),
+                                       'year'                          => 
$this->db->f('year'),
+                                       'budget'                        => 
(int)$this->db->f('budget'),
+                                       'actual_cost'           => 
$this->db->f('actual_cost'),
+                                       'user_id'                       => 
$this->db->f('user_id'),
+                                       'entry_date'            => 
$this->db->f('entry_date'),
+                                       'modified_date'         => 
$this->db->f('modified_date')
+                               );
+                       }
+                       return $values;
+               }
+
+               function delete_year_from_budget($project_id, $data)
+               {
+                       $project_id = (int) $project_id;
+                       $sql = "DELETE FROM fm_project_budget WHERE project_id 
= {$project_id} AND year IN(" . implode(',', $data) . ')';
+                       $this->db->query($sql,__LINE__,__FILE__);
+               }
+
                function 
update_request_status($project_id='',$status='',$category=0,$coordinator=0)
                {
                        $historylog_r   = 
CreateObject('property.historylog','request');
@@ -1296,7 +1378,7 @@
                                                (
                                                        'location1_id'          
=> $GLOBALS['phpgw']->locations->get_id('property', '.project.request'),
                                                        'location1_item_id' => 
$add_request['request_id'][$i],
-                                                       'location2_id'          
=> $GLOBALS['phpgw']->locations->get_id('property', '.project'),                
        
+                                                       'location2_id'          
=> $GLOBALS['phpgw']->locations->get_id('property', '.project'),
                                                        'location2_item_id' => 
$id,
                                                        'account_id'            
=> $this->account
                                                );
@@ -1398,7 +1480,7 @@
                                        {
                                                $filter .= " AND (act_mtrl_cost 
> 0 OR act_vendor_cost > 0)";
                                        }
-                                       
+
                                        $table = 'fm_workorder';
                                        $status_table = 'fm_workorder_status';
                                        $title_field = 'fm_workorder.title';
@@ -1473,7 +1555,7 @@
                                                'remark'                        
=> '',
                                                'deadline'                      
=> ''
                                        );
-       
+
                                $this->db->query("SELECT * FROM 
fm_project_status WHERE id = '{$status_new}'");
                                $this->db->next_record();
                                if ($this->db->f('approved') || 
$this->db->f('closed'))

Modified: trunk/property/inc/class.uiproject.inc.php
===================================================================
--- trunk/property/inc/class.uiproject.inc.php  2012-01-27 12:59:43 UTC (rev 
8699)
+++ trunk/property/inc/class.uiproject.inc.php  2012-01-27 13:54:51 UTC (rev 
8700)
@@ -1380,26 +1380,6 @@
                                $values = 
$this->bocommon->preserve_attribute_values($values,$values_attribute);
                        }
 
-/*
-                       $table_header_history[] = array
-                               (
-                                       'lang_date'             => lang('Date'),
-                                       'lang_user'             => lang('User'),
-                                       'lang_action'           => 
lang('Action'),
-                                       'lang_new_value'        => lang('New 
value')
-                               );
-
-                       $table_header_workorder_budget[] = array
-                               (
-                                       'lang_workorder_id'     => 
lang('Workorder'),
-                                       'lang_title'            => 
lang('title'),
-                                       'lang_budget'           => 
lang('Budget'),
-                                       'lang_calculation'      => 
lang('Calculation'),
-                                       'lang_vendor'           => 
lang('Vendor'),
-                                       'lang_status'           => 
lang('status')
-                               );
-
-*/
                        if ($id)
                        {
                                $function_msg = lang("{$mode} project");
@@ -1606,14 +1586,14 @@
 
                        if($id)
                        {
-                               $content_budget = 
array();//$this->bo->get_budget($id);
+                               $content_budget = $this->bo->get_budget($id);
                                $lang_delete = lang('Check to delete year');
                                foreach($content_budget as & $b_entry)
                                {
                                        $b_entry['delete_year'] = "<input 
type='checkbox' name='values[delete_b_year][]' value='{$b_entry['year']}' 
title='{$lang_delete}'>";
                                }
                        }
-
+//_debug_array($content_budget);die();
                        $datavalues[0] = array
                                (
                                        'name'                                  
=> "0",
@@ -1630,11 +1610,8 @@
                                (
                                        'name'          => "0",
                                        'values'        =>      
json_encode(array(      array('key' => 
'year','label'=>lang('year'),'sortable'=>false,'resizeable'=>true),
-                                                                               
                                array('key' => 
'category','label'=>lang('category'),'sortable'=>false,'resizeable'=>true),
-                                                                               
                                array('key' => 
'ecodimb','label'=>lang('dimb'),'sortable'=>false,'resizeable'=>true),
-                                                                               
                                array('key' => 
'budget_account','label'=>lang('budget 
account'),'sortable'=>false,'resizeable'=>true),
-                                                                               
                                array('key' => 
'budget','label'=>lang('budget'),'sortable'=>false,'resizeable'=>true),
-                                                                               
                                array('key' => 
'actual_cost','label'=>lang('actual 
cost'),'sortable'=>false,'resizeable'=>true),
+                                                                               
                                array('key' => 
'budget','label'=>lang('budget'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterRight'),
+                                                                               
                                array('key' => 
'actual_cost','label'=>lang('actual 
cost'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterRight'),
                                                                                
                                array('key' => 
'delete_year','label'=>lang('Delete'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter')))
                                );
 
@@ -1776,6 +1753,21 @@
 
                        $suppresscoordination                   = 
isset($config->config_data['project_suppresscoordination']) && 
$config->config_data['project_suppresscoordination'] ? 1 : '';
 
+
+                       $year   = date('Y') -1;
+                       $limit  = $year + 8;
+
+                       while ($year < $limit)
+                       {
+                               $year_list[] = array
+                               (
+                                       'id'    =>  $year,
+                                       'name'  =>  $year
+                               );
+                               $year++;
+                       }
+
+
                        $data = array
                                (
                                        'mode'                                  
                        => $mode,
@@ -1795,6 +1787,7 @@
                                        'value_origin'                          
                => isset($values['origin']) ? $values['origin'] : '',
                                        'value_origin_type'                     
                => isset($origin)?$origin:'',
                                        'value_origin_id'                       
                => isset($origin_id)?$origin_id:'',
+                                       'year_list'                             
                        => array('options' => $year_list),
                                        'lang_select_request'                   
        => lang('Select request'),
                                        'lang_select_request_statustext'        
=> lang('Add request for this project'),
                                        'lang_request_statustext'               
        => lang('Link to the request for this project'),
@@ -1826,9 +1819,7 @@
                                        'lang_power_meter'                      
                => lang('Power meter'),
                                        'lang_power_meter_statustext'           
=> lang('Enter the power meter'),
                                        'value_power_meter'                     
                => isset($values['power_meter'])?$values['power_meter']:'',
-                                       'lang_budget'                           
                => lang('Budget'),
                                        'value_budget'                          
                => isset($values['budget'])?$values['budget']:'',
-                                       'lang_budget_statustext'                
        => lang('Enter the budget'),
                                        'lang_reserve'                          
                => lang('reserve'),
                                        'value_reserve'                         
                => isset($values['reserve'])?$values['reserve']:'',
                                        'lang_reserve_statustext'               
        => lang('Enter the reserve'),
@@ -1867,12 +1858,7 @@
                                        'value_cat_id'                          
                => isset($values['cat_id'])?$values['cat_id']:'',
                                        'cat_select'                            
                => $this->cats->formatted_xslt_list(array('select_name' => 
'values[cat_id]','selected' => $values['cat_id'])),
                                        'lang_workorder_id'                     
                => lang('Workorder ID'),
-                                       //'sum_workorder_budget'                
        => 
isset($values['sum_workorder_budget'])?$values['sum_workorder_budget']:'',
-                                       //'sum_workorder_calculation'           
=> 
isset($values['sum_workorder_calculation'])?$values['sum_workorder_calculation']:'',
-                                       //'workorder_budget'                    
        => isset($values['workorder_budget'])?$values['workorder_budget']:'',
-                                       //'sum_workorder_actual_cost'           
=> 
isset($values['sum_workorder_actual_cost'])?$values['sum_workorder_actual_cost']:'',
                                        'lang_sum'                              
                        => lang('Sum'),
-                                       //'lang_actual_cost'                    
        => lang('Actual cost'),
                                        'value_remainder'                       
                => $value_remainder,
                                        'lang_remainder'                        
                => lang('remainder'),
                                        'lang_coordinator'                      
                => lang('Coordinator'),
@@ -1911,7 +1897,7 @@
                                        'value_approval_mail_address'           
=> $supervisor_email,
 
                                        'currency'                              
                        => 
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
-                                       'base_java_notify_url'                  
                        => 
"{menuaction:'property.notify.update_data',location_id:{$location_id},location_item_id:{$id}}",
+                                       'base_java_notify_url'                  
        => 
"{menuaction:'property.notify.update_data',location_id:{$location_id},location_item_id:{$id}}",
                                        'edit_action'                           
                => $GLOBALS['phpgw']->link('/index.php',array('menuaction' => 
'property.uiproject.edit', 'id' => $id)),
                                        'lang_edit_statustext'                  
        => lang('Edit this entry '),
                                        'lang_edit'                             
                        => lang('Edit'),

Modified: trunk/property/js/yahoo/project.edit.js
===================================================================
--- trunk/property/js/yahoo/project.edit.js     2012-01-27 12:59:43 UTC (rev 
8699)
+++ trunk/property/js/yahoo/project.edit.js     2012-01-27 13:54:51 UTC (rev 
8700)
@@ -49,7 +49,7 @@
 
/********************************************************************************/
     
        this.myParticularRenderEvent = function()
        {
-       //      this.addFooterDatatable0(myPaginator_0,myDataTable_0);
+               this.addFooterDatatable0(myPaginator_0,myDataTable_0);
                this.addFooterDatatable1(myPaginator_1,myDataTable_1);
                this.addFooterDatatable2(myPaginator_2,myDataTable_2);
        }
@@ -58,27 +58,28 @@
        this.addFooterDatatable0 = function(paginator,datatable)
        {
                //call getTotalSum(name of column) in property.js
-               tmp_sum1 = getTotalSum('budget',2,paginator,datatable);
+               tmp_sum1 = getTotalSum('budget',0,paginator,datatable);
+               tmp_sum2 = getTotalSum('actual_cost',2,paginator,datatable);
 
-               if(typeof(tableYUI)=='undefined')
+               if(typeof(tableYUI0)=='undefined')
                {
-                       tableYUI = 
YAHOO.util.Dom.getElementsByClassName("yui-dt-data","tbody")[0].parentNode;
-                       tableYUI.setAttribute("id","tableYUI");
+                       tableYUI0 = 
YAHOO.util.Dom.getElementsByClassName("yui-dt-data","tbody")[0].parentNode;
+                       tableYUI0.setAttribute("id","tableYUI0");
                }
                else
                {
-                       tableYUI.deleteTFoot();
+                       tableYUI0.deleteTFoot();
                }
 
                //Create ROW
                newTR = document.createElement('tr');
 
                td_sum('Sum');
-               td_empty(3);
                td_sum(tmp_sum1);
-               td_empty(2);
+               td_sum(tmp_sum2);
+               td_empty(1);
 
-               myfoot = tableYUI.createTFoot();
+               myfoot = tableYUI0.createTFoot();
                myfoot.setAttribute("id","myfoot");
                myfoot.appendChild(newTR);
        }
@@ -91,14 +92,14 @@
                tmp_sum3 = getTotalSum('actual_cost',2,paginator,datatable);
                tmp_sum4 = getTotalSum('contract_sum',2,paginator,datatable);
 
-               if(typeof(tableYUI)=='undefined')
+               if(typeof(tableYUI1)=='undefined')
                {
-                       tableYUI = 
YAHOO.util.Dom.getElementsByClassName("yui-dt-data","tbody")[1].parentNode;
-                       tableYUI.setAttribute("id","tableYUI");
+                       tableYUI1 = 
YAHOO.util.Dom.getElementsByClassName("yui-dt-data","tbody")[1].parentNode;
+                       tableYUI1.setAttribute("id","tableYUI1");
                }
                else
                {
-                       tableYUI.deleteTFoot();
+                       tableYUI1.deleteTFoot();
                }
 
                //Create ROW
@@ -112,7 +113,7 @@
                td_sum(tmp_sum3);
                td_empty(5);
 
-               myfoot = tableYUI.createTFoot();
+               myfoot = tableYUI1.createTFoot();
                myfoot.setAttribute("id","myfoot");
                myfoot.appendChild(newTR);
        }
@@ -127,7 +128,7 @@
                if(typeof(tableYUI2)=='undefined')
                {
                        tableYUI2 = 
YAHOO.util.Dom.getElementsByClassName("yui-dt-data","tbody")[2].parentNode;
-                       tableYUI2.setAttribute("id","tableYUI");
+                       tableYUI2.setAttribute("id","tableYUI2");
                }
                else
                {

Modified: trunk/property/setup/tables_current.inc.php
===================================================================
--- trunk/property/setup/tables_current.inc.php 2012-01-27 12:59:43 UTC (rev 
8699)
+++ trunk/property/setup/tables_current.inc.php 2012-01-27 13:54:51 UTC (rev 
8700)
@@ -1376,9 +1376,6 @@
                        'fd' => array(
                                'project_id' => array('type' => 
'int','precision' => 4,'nullable' => False),
                                'year' => array('type' => 'int','precision' => 
4,'nullable' => False),
-                               'budget_account' =>  array('type' => 
'varchar','precision' => 15,'nullable' => False),
-                               'ecodimb' => array('type' => 'int','precision' 
=> 4,'nullable' => True),
-                               'category' => array('type' => 'int','precision' 
=> 4,'nullable' => True),
                                'budget' => array('type' => 
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' => 
'0.00'),
                                'actual_cost' => array('type' => 
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' => 
'0.00'),
                                'user_id' => array('type' => 'int','precision' 
=> 4,'nullable' => True),

Modified: trunk/property/setup/tables_update.inc.php
===================================================================
--- trunk/property/setup/tables_update.inc.php  2012-01-27 12:59:43 UTC (rev 
8699)
+++ trunk/property/setup/tables_update.inc.php  2012-01-27 13:54:51 UTC (rev 
8700)
@@ -5822,21 +5822,18 @@
        * Update property version from 0.9.17.633 to 0.9.17.634
        * Add project budget per year
        */
-/*
+
        $test[] = '0.9.17.633';
        function property_upgrade0_9_17_633()
        {
                $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
                $GLOBALS['phpgw_setup']->oProc->query("DELETE FROM fm_cache");
-
+/*
                $GLOBALS['phpgw_setup']->oProc->CreateTable(
                        'fm_project_budget', array(
                                'fd' => array(
                                        'project_id' => array('type' => 
'int','precision' => 4,'nullable' => False),
                                        'year' => array('type' => 
'int','precision' => 4,'nullable' => False),
-                                       'budget_account' =>  array('type' => 
'varchar','precision' => 15,'nullable' => False),
-                                       'ecodimb' => array('type' => 
'int','precision' => 4,'nullable' => True),
-                                       'category' => array('type' => 
'int','precision' => 4,'nullable' => True),
                                        'budget' => array('type' => 
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' => 
'0.00'),
                                        'actual_cost' => array('type' => 
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' => 
'0.00'),
                                        'user_id' => array('type' => 
'int','precision' => 4,'nullable' => True),
@@ -5849,7 +5846,43 @@
                                'uc' => array()
                        )
                );
+*/
+               $sql = "SELECT id, budget, start_date, user_id,entry_date FROM 
fm_project ORDER BY ID ASC";
+               $GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+               while ($GLOBALS['phpgw_setup']->oProc->next_record())
+               {
+                       $budget_values[] = array
+                       (
+                               'id'                    => 
$GLOBALS['phpgw_setup']->oProc->f('id'),
+                               'budget'                => 
$GLOBALS['phpgw_setup']->oProc->f('budget'),
+                               'start_date'    => 
$GLOBALS['phpgw_setup']->oProc->f('start_date'),
+                               'user_id'               => 
$GLOBALS['phpgw_setup']->oProc->f('user_id'),
+                               'entry_date'    => 
$GLOBALS['phpgw_setup']->oProc->f('entry_date')
+                       );
+               }
 
+               foreach($budget_values as $entry)
+               {
+                       if($entry['budget'])
+                       {
+                               $value_set = array
+                               (
+                                       'project_id'            => $entry['id'],
+                                       'year'                          => 
date('Y',$entry['start_date']),
+                                       'budget'                        => 
$entry['budget'],
+                                       'user_id'                       => 
$entry['user_id'],
+                                       'entry_date'            => 
$entry['entry_date'],
+                                       'modified_date'         => 
$entry['entry_date']
+                               );
+                       }
+
+                       $cols = implode(',', array_keys($value_set));
+                       $values = 
$GLOBALS['phpgw_setup']->oProc->validate_insert(array_values($value_set));
+                       $sql = "INSERT INTO fm_project_budget ({$cols}) VALUES 
({$values})";
+//_debug_array($sql);
+                       
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+               }
+
                if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
                {
                        $GLOBALS['setup_info']['property']['currentver'] = 
'0.9.17.634';
@@ -5857,7 +5890,6 @@
                }
        }
 
-*/
        /**
        * Update property version from 0.9.17.607 to 0.9.17.608
        * Add more room for address at tickets

Modified: trunk/property/templates/base/project.xsl
===================================================================
--- trunk/property/templates/base/project.xsl   2012-01-27 12:59:43 UTC (rev 
8699)
+++ trunk/property/templates/base/project.xsl   2012-01-27 13:54:51 UTC (rev 
8700)
@@ -358,9 +358,32 @@
                                                        </xsl:choose>
                                                        <tr>
                                                                <td 
valign="top">
-                                                                       
<xsl:value-of select="lang_budget"/>
+                                                                       
<xsl:value-of select="php:function('lang', 'budget')"/>
                                                                </td>
-                                                               <td><input 
type="text" name="values[budget]" value="{value_budget}"><xsl:attribute 
name="title"><xsl:value-of 
select="lang_budget_statustext"/></xsl:attribute></input><xsl:text> </xsl:text> 
[ <xsl:value-of select="currency"/> ]
+                                                               <td>
+                                                                       <table>
+                                                                       <tr>
+                                                                       <td>
+                                                                       <input 
type="text" name="values[budget]" value="">
+                                                                               
<xsl:attribute name="title">
+                                                                               
        <xsl:value-of select="php:function('lang', 'Enter the budget')"/>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                                       
<xsl:text> </xsl:text> [ <xsl:value-of select="currency"/> ]
+                                                                       </td>
+                                                                       <td>
+                                                                       <select 
name="values[budget_year]">
+                                                                               
<xsl:attribute name="title">
+                                                                               
        <xsl:value-of select="php:function('lang', 'year')"/>
+                                                                               
</xsl:attribute>
+                                                                               
<option value="0">
+                                                                               
        <xsl:value-of select="php:function('lang', 'year')"/>
+                                                                               
</option>
+                                                                               
<xsl:apply-templates select="year_list/options"/>
+                                                                       
</select>
+                                                                       </td>
+                                                                       </tr>
+                                                                       </table>
                                                                </td>
                                                        </tr>
                                                        <tr>
@@ -654,42 +677,6 @@
                </xsl:choose>
        </xsl:template>
 
-       <!-- New template-->
-       <xsl:template match="workorder_budget">
-               <xsl:variable name="workorder_link"><xsl:value-of 
select="//workorder_link"/>&amp;id=<xsl:value-of 
select="workorder_id"/></xsl:variable>
-               <tr>
-                       <xsl:attribute name="class">
-                               <xsl:choose>
-                                       <xsl:when test="@class">
-                                               <xsl:value-of select="@class"/>
-                                       </xsl:when>
-                                       <xsl:when test="position() mod 2 = 0">
-                                               <xsl:text>row_off</xsl:text>
-                                       </xsl:when>
-                                       <xsl:otherwise>
-                                               <xsl:text>row_on</xsl:text>
-                                       </xsl:otherwise>
-                               </xsl:choose>
-                       </xsl:attribute>
-                       <td align="right">
-                               <a href="{$workorder_link}">
-                                       <xsl:value-of select="workorder_id"/>
-                               </a>
-                       </td>
-                       <td align="right">
-                               <xsl:value-of select="budget"/>
-                       </td>
-                       <td align="right">
-                               <xsl:value-of select="calculation"/>
-                       </td>
-                       <td align="left">
-                               <xsl:value-of select="vendor_name"/>
-                       </td>
-                       <td align="left">
-                               <xsl:value-of select="status"/>
-                       </td>
-               </tr>
-       </xsl:template>
 
        <!-- New template-->
        <xsl:template match="branch_list">




reply via email to

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