[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [8712] property: project budgetting
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [8712] property: project budgetting |
Date: |
Mon, 30 Jan 2012 11:59:32 +0000 |
Revision: 8712
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8712
Author: sigurdne
Date: 2012-01-30 11:59:27 +0000 (Mon, 30 Jan 2012)
Log Message:
-----------
property: project budgetting
Modified Paths:
--------------
trunk/property/inc/class.soproject.inc.php
trunk/property/inc/class.uiproject.inc.php
trunk/property/js/yahoo/project.edit.js
Modified: trunk/property/inc/class.soproject.inc.php
===================================================================
--- trunk/property/inc/class.soproject.inc.php 2012-01-30 11:53:20 UTC (rev
8711)
+++ trunk/property/inc/class.soproject.inc.php 2012-01-30 11:59:27 UTC (rev
8712)
@@ -1311,10 +1311,40 @@
while ($this->db->next_record())
{
$year = substr(
$this->db->f('periode'), 0, 4 );
- $actual_cost[$year] +=
$this->db->f('actual_cost');
+ $cost_info[$year]['actual_cost'] +=
$this->db->f('actual_cost');
}
}
+ $sql = "SELECT EXTRACT(YEAR from
to_timestamp(start_date) ) as year, sum(calculation) as calculation,
sum(budget) as budget, sum(contract_sum) as contract_sum 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"
+ . " GROUP BY fm_workorder.id ORDER BY start_date ASC";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $year = $this->db->f('year');
+
+ if($this->db->f('contract_sum') > 0)
+ {
+ $_sum = $this->db->f('contract_sum');
+ }
+ else if($this->db->f('calculation') > 0)
+ {
+ $_sum = $this->db->f('calculation');
+ }
+ else if($this->db->f('budget') > 0)
+ {
+ $_sum = $this->db->f('budget');
+ }
+ else
+ {
+ $_sum = 0;
+ }
+ $cost_info[$year]['sum_orders'] += $_sum;
+ }
+
+
$sort_year = array();
$values = array();
@@ -1324,10 +1354,11 @@
while ($this->db->next_record())
{
$year = $this->db->f('year');
- $_actual_cost = isset($actual_cost[$year]) &&
$actual_cost[$year] ? $actual_cost[$year] : 0;
- if($_actual_cost)
+ $_actual_cost =
isset($cost_info[$year]['actual_cost']) && $cost_info[$year]['actual_cost'] ?
$cost_info[$year]['actual_cost'] : 0;
+ $_sum_orders =
isset($cost_info[$year]['sum_orders']) && $cost_info[$year]['sum_orders'] ?
$cost_info[$year]['sum_orders'] : 0;
+ if(isset($cost_info[$year]))
{
- unset($actual_cost[$year]);
+ unset($cost_info[$year]);
}
$sort_year[] = $year;
@@ -1336,16 +1367,16 @@
'project_id' => $project_id,
'year' =>
$this->db->f('year'),
'budget' =>
(int)$this->db->f('budget'),
+ 'sum_orders' => $_sum_orders,
'actual_cost' =>
$_actual_cost,
'user_id' =>
$this->db->f('user_id'),
'entry_date' =>
$this->db->f('entry_date'),
'modified_date' =>
$this->db->f('modified_date')
);
}
-
- if($actual_cost && count($actual_cost))
+ if($cost_info && count($cost_info))
{
- foreach($actual_cost as $year => $_actual_cost)
+ foreach($cost_info as $year => $cost_info)
{
$sort_year[] = $year;
$values[] = array
@@ -1353,13 +1384,16 @@
'project_id' =>
$project_id,
'year'
=> $year ,
'budget'
=> 0,
- 'actual_cost' =>
$_actual_cost,
+ 'sum_orders'
=> isset($cost_info['sum_orders']) && $cost_info['sum_orders'] ?
$cost_info['sum_orders'] : 0,
+ 'actual_cost' =>
isset($cost_info['actual_cost']) && $cost_info['actual_cost'] ?
$cost_info['actual_cost'] : 0,
'user_id'
=> 0,
'entry_date' => 0,
'modified_date' => 0
);
}
}
+//_debug_array($values);
+//die();
if($values)
{
Modified: trunk/property/inc/class.uiproject.inc.php
===================================================================
--- trunk/property/inc/class.uiproject.inc.php 2012-01-30 11:53:20 UTC (rev
8711)
+++ trunk/property/inc/class.uiproject.inc.php 2012-01-30 11:59:27 UTC (rev
8712)
@@ -1611,11 +1611,11 @@
'name' => "0",
'values' =>
json_encode(array( array('key' =>
'year','label'=>lang('year'),'sortable'=>false,'resizeable'=>true),
array('key' =>
'budget','label'=>lang('budget'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
-
array('key' =>
'actual_cost','label'=>lang('actual
cost'),'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' =>
'delete_year','label'=>lang('Delete'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter')))
);
-
$datavalues[1] = array
(
'name'
=> "1",
Modified: trunk/property/js/yahoo/project.edit.js
===================================================================
--- trunk/property/js/yahoo/project.edit.js 2012-01-30 11:53:20 UTC (rev
8711)
+++ trunk/property/js/yahoo/project.edit.js 2012-01-30 11:59:27 UTC (rev
8712)
@@ -7,7 +7,7 @@
/********************************************************************************/
YAHOO.widget.DataTable.formatLink = function(elCell, oRecord, oColumn,
oData)
{
- elCell.innerHTML = "<a
href="+datatable[0][0]["edit_action"]+"&id="+oData+">" + oData + "</a>";
+ elCell.innerHTML = "<a
href="+datatable[1][0]["edit_action"]+"&id="+oData+">" + oData + "</a>";
};
@@ -70,7 +70,8 @@
{
//call getTotalSum(name of column) in property.js
tmp_sum1 = getTotalSum('budget',0,paginator,datatable);
- tmp_sum2 = getTotalSum('actual_cost',2,paginator,datatable);
+ tmp_sum2 = getTotalSum('sum_orders',0,paginator,datatable);
+ tmp_sum3 = getTotalSum('actual_cost',2,paginator,datatable);
if(typeof(tableYUI0)=='undefined')
{
@@ -88,6 +89,7 @@
td_sum('Sum');
td_sum(tmp_sum1);
td_sum(tmp_sum2);
+ td_sum(tmp_sum3);
td_empty(1);
myfoot = tableYUI0.createTFoot();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [8712] property: project budgetting,
Sigurd Nes <=