[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [8701] property: more on project budget per year
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [8701] property: more on project budget per year |
Date: |
Sun, 29 Jan 2012 20:12:08 +0000 |
Revision: 8701
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8701
Author: sigurdne
Date: 2012-01-29 20:12:08 +0000 (Sun, 29 Jan 2012)
Log Message:
-----------
property: more on project budget per year
Modified Paths:
--------------
trunk/property/inc/class.soproject.inc.php
trunk/property/inc/class.uiproject.inc.php
trunk/property/js/yahoo/project.edit.js
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-01-27 13:54:51 UTC (rev
8700)
+++ trunk/property/inc/class.soproject.inc.php 2012-01-29 20:12:08 UTC (rev
8701)
@@ -1294,23 +1294,78 @@
function get_budget($project_id)
{
$project_id = (int) $project_id;
+
+ $sql = "SELECT id AS order_id FROM fm_workorder WHERE
project_id = {$project_id}";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $orders = array();
+ while ($this->db->next_record())
+ {
+ $orders[] = $this->db->f('order_id');
+ }
+
+ $actual_cost = array();
+ foreach($orders as $order)
+ {
+ $sql = "SELECT sum(godkjentbelop) AS
actual_cost, periode FROM fm_ecobilagoverf WHERE pmwrkord_code = '{$order}'
GROUP BY periode ORDER BY periode ASC ";
+ $this->db->query($sql,__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+ $year = substr(
$this->db->f('periode'), 0, 4 );
+ $actual_cost[$year] +=
$this->db->f('actual_cost');
+ }
+ }
+
+ $sort_year = array();
$values = array();
$sql = "SELECT * FROM fm_project_budget WHERE
project_id = {$project_id}";
$this->db->query($sql,__LINE__,__FILE__);
+
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)
+ {
+ unset($actual_cost[$year]);
+ }
+
+ $sort_year[] = $year;
$values[] = array
(
- 'project_id' =>
$this->db->f('project_id'),
+ 'project_id' => $project_id,
'year' =>
$this->db->f('year'),
'budget' =>
(int)$this->db->f('budget'),
- 'actual_cost' =>
$this->db->f('actual_cost'),
+ '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))
+ {
+ foreach($actual_cost as $year => $_actual_cost)
+ {
+ $sort_year[] = $year;
+ $values[] = array
+ (
+ 'project_id' =>
$project_id,
+ 'year'
=> $year ,
+ 'budget'
=> 0,
+ 'actual_cost' =>
$_actual_cost,
+ 'user_id'
=> 0,
+ 'entry_date' => 0,
+ 'modified_date' => 0
+ );
+ }
+ }
+
+ if($values)
+ {
+ array_multisort($sort_year, SORT_ASC, $values);
+ }
+
return $values;
}
Modified: trunk/property/inc/class.uiproject.inc.php
===================================================================
--- trunk/property/inc/class.uiproject.inc.php 2012-01-27 13:54:51 UTC (rev
8700)
+++ trunk/property/inc/class.uiproject.inc.php 2012-01-29 20:12:08 UTC (rev
8701)
@@ -1610,8 +1610,8 @@
(
'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'=>'FormatterRight'),
-
array('key' =>
'actual_cost','label'=>lang('actual
cost'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterRight'),
+
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' =>
'delete_year','label'=>lang('Delete'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter')))
);
Modified: trunk/property/js/yahoo/project.edit.js
===================================================================
--- trunk/property/js/yahoo/project.edit.js 2012-01-27 13:54:51 UTC (rev
8700)
+++ trunk/property/js/yahoo/project.edit.js 2012-01-29 20:12:08 UTC (rev
8701)
@@ -41,6 +41,17 @@
elCell.innerHTML = "<div align=\"right\">"+oData+"</div>";
}
+ var FormatterAmount0 = function(elCell, oRecord, oColumn, oData)
+ {
+ var amount = YAHOO.util.Number.format(oData, {decimalPlaces:0,
decimalSeparator:",", thousandsSeparator:" "});
+ elCell.innerHTML = "<div align=\"right\">"+amount+"</div>";
+ }
+ var FormatterAmount2 = function(elCell, oRecord, oColumn, oData)
+ {
+ var amount = YAHOO.util.Number.format(oData, {decimalPlaces:2,
decimalSeparator:",", thousandsSeparator:" "});
+ elCell.innerHTML = "<div align=\"right\">"+amount+"</div>";
+ }
+
var FormatterCenter = function(elCell, oRecord, oColumn, oData)
{
elCell.innerHTML = "<center>"+oData+"</center>";
@@ -87,7 +98,7 @@
this.addFooterDatatable1 = 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('calculation',2,paginator,datatable);
tmp_sum3 = getTotalSum('actual_cost',2,paginator,datatable);
tmp_sum4 = getTotalSum('contract_sum',2,paginator,datatable);
Modified: trunk/property/setup/setup.inc.php
===================================================================
--- trunk/property/setup/setup.inc.php 2012-01-27 13:54:51 UTC (rev 8700)
+++ trunk/property/setup/setup.inc.php 2012-01-29 20:12:08 UTC (rev 8701)
@@ -12,7 +12,7 @@
*/
$setup_info['property']['name'] = 'property';
- $setup_info['property']['version'] = '0.9.17.633';
+ $setup_info['property']['version'] = '0.9.17.634';
$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-01-27 13:54:51 UTC (rev
8700)
+++ trunk/property/setup/tables_current.inc.php 2012-01-29 20:12:08 UTC (rev
8701)
@@ -1377,7 +1377,6 @@
'project_id' => array('type' =>
'int','precision' => 4,'nullable' => False),
'year' => array('type' => 'int','precision' =>
4,'nullable' => False),
'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),
'entry_date' => array('type' =>
'int','precision' => 4,'nullable' => True),
'modified_date' => 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 13:54:51 UTC (rev
8700)
+++ trunk/property/setup/tables_update.inc.php 2012-01-29 20:12:08 UTC (rev
8701)
@@ -5828,14 +5828,13 @@
{
$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' => 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),
'entry_date' => array('type' =>
'int','precision' => 4,'nullable' => True),
'modified_date' => array('type' =>
'int','precision' => 4,'nullable' => True)
@@ -5846,9 +5845,10 @@
'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__);
+ $budget_values = array();
while ($GLOBALS['phpgw_setup']->oProc->next_record())
{
$budget_values[] = array
@@ -5863,7 +5863,7 @@
foreach($budget_values as $entry)
{
- if($entry['budget'])
+ if($entry['budget'] && abs($entry['budget']) > 0)
{
$value_set = array
(
@@ -5874,13 +5874,11 @@
'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})";
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
}
-
- $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())
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [8701] property: more on project budget per year,
Sigurd Nes <=