[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [10618] Property: update accounting reporting
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [10618] Property: update accounting reporting |
Date: |
Fri, 21 Dec 2012 16:45:43 +0000 |
Revision: 10618
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10618
Author: sigurdne
Date: 2012-12-21 16:45:42 +0000 (Fri, 21 Dec 2012)
Log Message:
-----------
Property: update accounting reporting
Modified Paths:
--------------
trunk/property/inc/class.boproject.inc.php
trunk/property/inc/class.sobudget.inc.php
trunk/property/inc/class.soproject.inc.php
trunk/property/inc/class.soworkorder.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_update.inc.php
Modified: trunk/property/inc/class.boproject.inc.php
===================================================================
--- trunk/property/inc/class.boproject.inc.php 2012-12-21 12:27:55 UTC (rev
10617)
+++ trunk/property/inc/class.boproject.inc.php 2012-12-21 16:45:42 UTC (rev
10618)
@@ -553,6 +553,7 @@
{
$sum_deviation+=
$workorder_data[$i]['deviation'];
+/*
$_cost = (float)number_format(0, 2, ',', '');
if(abs($workorder_data[$i]['contract_sum']) > 0)
{
@@ -566,24 +567,26 @@
{
$_cost =
(float)number_format($workorder_data[$i]['budget'] * $tax, 2, ',', '');
}
-
- $values['workorder_budget'][$i]['cost'] =
$_cost;
-
+*/
+ $values['workorder_budget'][$i]['cost'] =
$workorder_data[$i]['combined_cost'];
+ $values['workorder_budget'][$i]['actual_cost']
= $workorder_data[$i]['actual_cost'];
+
$values['workorder_budget'][$i]['title']=htmlspecialchars_decode($workorder_data[$i]['title']);
$values['workorder_budget'][$i]['workorder_id']=$workorder_data[$i]['workorder_id'];
//
$values['workorder_budget'][$i]['contract_sum']=(float)number_format($workorder_data[$i]['contract_sum']
* (1+(((int)$workorder_data[$i]['addition_percentage'])/100)), 2, ',', '');
- // $values['workorder_budget'][$i]['budget']=
$workorder_data[$i]['budget'];
+ $values['workorder_budget'][$i]['budget']=
$workorder_data[$i]['budget'];
//
$values['workorder_budget'][$i]['calculation']=(float)number_format($workorder_data[$i]['calculation']*$tax,
2, ',', '');
$values['workorder_budget'][$i]['charge_tenant'] =
$workorder_data[$i]['charge_tenant'];
$values['workorder_budget'][$i]['status'] =
$workorder_data[$i]['status'];
- $values['workorder_budget'][$i]['actual_cost']
= (float)number_format($workorder_data[$i]['actual_cost'] ?
$workorder_data[$i]['actual_cost'] : 0, 2, ',', '');
+ // $values['workorder_budget'][$i]['actual_cost']
= (float)number_format($workorder_data[$i]['actual_cost'] ?
$workorder_data[$i]['actual_cost'] : 0, 2, ',', '');
$values['workorder_budget'][$i]['b_account_id']
= $workorder_data[$i]['b_account_id'];
// $values['workorder_budget'][$i]['paid_percent']
= (int)$workorder_data[$i]['paid_percent'];
$values['workorder_budget'][$i]['addition_percentage'] =
$workorder_data[$i]['addition_percentage'];
+ $values['workorder_budget'][$i]['obligation'] =
$workorder_data[$i]['obligation'];
-
$values['workorder_budget'][$i]['combined_cost'] =
$workorder_data[$i]['closed'] ? 0 : ($_cost -
$workorder_data[$i]['actual_cost']);
- $values['workorder_budget'][$i]['diff'] =
$_cost - $values['workorder_budget'][$i]['combined_cost'] -
$values['workorder_budget'][$i]['actual_cost'];
+//
$values['workorder_budget'][$i]['combined_cost'] =
$workorder_data[$i]['closed'] ? 0 : ($_cost -
$workorder_data[$i]['actual_cost']);
+ $values['workorder_budget'][$i]['diff'] =
$workorder_data[$i]['diff'];
if(isset($workorder_data[$i]['vendor_id']) &&
$workorder_data[$i]['vendor_id'])
{
Modified: trunk/property/inc/class.sobudget.inc.php
===================================================================
--- trunk/property/inc/class.sobudget.inc.php 2012-12-21 12:27:55 UTC (rev
10617)
+++ trunk/property/inc/class.sobudget.inc.php 2012-12-21 16:45:42 UTC (rev
10618)
@@ -546,6 +546,11 @@
$start_date = mktime(1, 1, 1, 1, 1, $year);
$end_date = mktime (23, 59, 59, 12, 31, $year);
+
+ $start_periode = date('Ym',mktime(2,0,0,1,1,$year));
+ $end_periode = date('Ym',mktime(2,0,0,12,31,$year));
+
+
$filtermethod .= " WHERE fm_workorder.start_date >=
$start_date AND fm_workorder.start_date <= $end_date";
// $filtermethod .= " WHERE fm_workorder_status.closed IS
NULL AND fm_workorder.start_date >= $start_date AND fm_workorder.start_date <=
$end_date";
@@ -626,40 +631,86 @@
$b_account_field = 'category';
}
- $sql = "SELECT fm_workorder_status.closed,
sum(combined_cost) as combined_cost, count(fm_workorder.id) as hits,
fm_b_account.{$b_account_field} as {$b_account_field}, district_id,
fm_workorder.ecodimb"
+ $this->db->query('SELECT id, percent FROM
fm_ecomva',__LINE__,__FILE__);
+ $_taxcode = array(0 => 0);
+ while ($this->db->next_record())
+ {
+ $_taxcode[$this->db->f('id')] =
$this->db->f('percent');
+ }
+
+ $sql = "SELECT fm_workorder.id,
fm_workorder_status.closed, fm_workorder.budget,
combined_cost,fm_location1.mva,"
+ . "
fm_orders_actual_cost_view.actual_cost,pending_cost,
fm_b_account.{$b_account_field} as {$b_account_field}, district_id,
fm_workorder.ecodimb"
. " FROM fm_workorder"
. " {$this->join} fm_workorder_status ON
fm_workorder.status = fm_workorder_status.id"
. " {$this->join} fm_b_account ON
fm_workorder.account_id = fm_b_account.id"
. " {$this->join} fm_project ON
fm_workorder.project_id = fm_project.id"
+ . " {$this->left_join}
fm_orders_actual_cost_view ON fm_workorder.id =
fm_orders_actual_cost_view.order_id"
+ . " {$this->left_join}
fm_orders_pending_cost_view ON fm_workorder.id =
fm_orders_pending_cost_view.order_id"
. " {$_join_district}"
. " {$this->join} fm_part_of_town ON
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id"
- . " {$filtermethod} {$querymethod} GROUP BY
fm_workorder_status.closed,fm_b_account.{$b_account_field},district_id,fm_workorder.ecodimb";
+ . " {$filtermethod} {$querymethod}";
//_debug_array($sql);
//die();
$this->db->query($sql . $ordermethod,__LINE__,__FILE__);
+ $sum_actual_cost = 0;
+ $actual_cost = array();
$sum_obligation_cost = 0;
$obligations = array();
$sum_hits = 0;
+ $_local_combined_cost = array();
+//$_test=array();
while ($this->db->next_record())
{
- $_combined_cost =
round($this->db->f('combined_cost'));
- $_hits = $this->db->f('hits');
- $sum_hits += $_hits;
+ $_id = $this->db->f('id');
+ if (!isset($_local_combined_cost[$_id]) && !
$_combined_cost = $_local_combined_cost[$_id])
+ {
+ $_local_combined_cost[$_id] =
round($this->db->f('combined_cost'));
+ $_combined_cost =
$_local_combined_cost[$_id];
+ }
+ unset($_id);
+ $_pending_cost =
round($this->db->f('pending_cost'));
+ $_taxfactor = 1 +
($_taxcode[(int)$this->db->f('mvakode')]/100);
+ $_actual_cost =
round($this->db->f('actual_cost')/$_taxfactor);
+ // $_actual_cost =
round($this->db->f('actual_cost'));
+ $_obligation = $_combined_cost - $_actual_cost
- $_pending_cost;
+ $sum_hits += 1;
+
if(!$this->db->f('closed'))
{
- $sum_obligation_cost += $_combined_cost;
-
$obligations[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('ecodimb')]
+= $_combined_cost;
- }
+ if((int)$this->db->f('budget') >= 0)
+ {
+ if($_obligation < 0)
+ {
+//$_test[] = $_obligation;
+ $_obligation = 0;
+ }
+ }
+ else
+ {
+ if($_obligation > 0)
+ {
+ $_obligation = 0;
+ }
+ }
-
$hits[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('ecodimb')]
+= $_hits;
+ $sum_obligation_cost += $_obligation;
+
$obligations[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('ecodimb')]
+= $_obligation;
+ }
+//_debug_array($_test);
+
$hits[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('ecodimb')]
+= 1;
$accout_info[$this->db->f($b_account_field)] =
true;
$district[$this->db->f('district_id')] = true;
$ecodimb[(int)$this->db->f('ecodimb')] = true;
+
+ $sum_actual_cost += $_actual_cost;
+
$actual_cost[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('ecodimb')]
+= $_actual_cost;
+
}
+
// _debug_array($obligations);
//----------- ad hoc order
@@ -738,8 +789,6 @@
$sql = str_replace('budget', 'actual_cost', $sql);
$this->db->query($sql . $ordermethod,__LINE__,__FILE__);
- $sum_actual_cost = 0;
- $actual_cost = array();
while ($this->db->next_record())
{
$_actual_cost =
round($this->db->f('actual_cost'));
@@ -828,176 +877,8 @@
//_debug_array($budget_cost);die();
- $filtermethod = '';
- $where = 'AND';
- if($cat_ids)
- {
- $filtermethod .= " $where fm_workorder.category
IN (". implode(',', $cat_ids) . ')';
- $where = 'AND';
- }
- if ($grouping > 0)
- {
- $filtermethod .= " $where
fm_b_account.category='$grouping' ";
- $where = 'AND';
- }
-
- if ($district_id > 0)
- {
- $filtermethod .= " $where
district_id='$district_id' ";
- $where = 'AND';
- }
-
- if ($dimb_id > 0)
- {
- $filtermethod .= " $where dimb={$dimb_id}";
- $where = 'AND';
- }
-
- if($_department_dimb)
- {
- $filtermethod .= " $where dimb IN (" .
implode(',', $_department_dimb) . ')';
- $where = 'AND';
- }
-
-
- $start_periode = date('Ym',mktime(2,0,0,1,1,$year));
- $end_periode = date('Ym',mktime(2,0,0,12,31,$year));
-
- $this->db->query('SELECT id, percent FROM
fm_ecomva',__LINE__,__FILE__);
- $_taxcode = array(0 => 0);
- while ($this->db->next_record())
- {
- $_taxcode[$this->db->f('id')] =
$this->db->f('percent');
- }
-
-
-//-------start check paid workorder-----------
- $sql = "SELECT
fm_workorder.id,fm_workorder_status.closed,combined_cost,
fm_b_account.{$b_account_field} as {$b_account_field}, district_id,
sum(godkjentbelop) as actual_cost,dimb,mvakode"
- . " FROM fm_ecobilagoverf"
- . " {$this->join} fm_b_account ON
fm_ecobilagoverf.spbudact_code =fm_b_account.id"
- . " {$this->join} fm_location1 ON
fm_ecobilagoverf.loc1 = fm_location1.loc1"
- . " {$this->join} fm_part_of_town ON
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id"
- . " {$this->join} fm_workorder ON
fm_ecobilagoverf.pmwrkord_code = fm_workorder.id"
- . " {$this->join} fm_project ON
fm_workorder.project_id = fm_project.id"
- . " {$this->join} fm_workorder_status ON
fm_workorder.status = fm_workorder_status.id"
- . " WHERE periode >= $start_periode AND periode
<= $end_periode {$filtermethod}"
- . " GROUP BY fm_workorder.id,
fm_workorder_status.closed,combined_cost, fm_b_account.{$b_account_field},
district_id, dimb, mvakode";
-
- $this->db->query($sql,__LINE__,__FILE__);
-//_debug_array($sql);
- while ($this->db->next_record())
- {
-//continue;
- $_taxfactor = 1 +
($_taxcode[(int)$this->db->f('mvakode')]/100);
- $_actual_cost =
round($this->db->f('actual_cost')/$_taxfactor);
-
- $_combined_cost = $this->db->f('combined_cost');
-
- if($this->db->f('closed'))
- {
- $_diff_obligation = 0;
- }
- else if($_combined_cost > 0)
- {
- if(($_combined_cost - $_actual_cost) >
0)
- {
- $_diff_obligation =
$_actual_cost;
- }
- else
- {
- $_diff_obligation =
$_combined_cost;
- }
- }
- else if($_combined_cost < 0)
- {
- if(($_combined_cost - $_actual_cost) <
0)
- {
- $_diff_obligation =
$_actual_cost;
- }
- else
- {
- $_diff_obligation =
$_combined_cost;
- }
- }
- else
- {
- $_diff_obligation = 0;
- }
-
- $sum_obligation_cost -= $_diff_obligation;
- $sum_actual_cost += $_actual_cost;
-
$obligations[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('dimb')]
-= $_diff_obligation;
-
$actual_cost[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('dimb')]
+= $_actual_cost;
- $accout_info[$this->db->f($b_account_field)] =
true;
- $district[(int)$this->db->f('district_id')] =
true;
- $ecodimb[(int)$this->db->f('dimb')] = true;
- }
-
-// _debug_array($obligations);
-//-------end check paid-----------
-
-//-------start check active invoices, workorder-----------
- $sql = "SELECT fm_workorder.id,combined_cost,
fm_b_account.{$b_account_field} as {$b_account_field}, district_id,
sum(godkjentbelop) as actual_cost,dimb,mvakode"
- . " FROM fm_ecobilag"
- . " {$this->join} fm_b_account ON
fm_ecobilag.spbudact_code =fm_b_account.id"
- . " {$this->join} fm_location1 ON
fm_ecobilag.loc1 = fm_location1.loc1"
- . " {$this->join} fm_part_of_town ON
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id"
- . " {$this->join} fm_workorder ON
fm_ecobilag.pmwrkord_code = fm_workorder.id"
- . " {$this->join} fm_project ON
fm_workorder.project_id = fm_project.id"
- . " WHERE (periode >= 0 AND periode <=
$end_periode OR periode IS NULL) {$filtermethod}"
- . " GROUP BY fm_workorder.id, combined_cost,
fm_b_account.{$b_account_field}, district_id, dimb, mvakode";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
-//continue;
- $_taxfactor = 1 +
($_taxcode[(int)$this->db->f('mvakode')]/100);
- $_actual_cost =
round($this->db->f('actual_cost')/$_taxfactor);
-
- $_combined_cost = $this->db->f('combined_cost');
-
- if($_combined_cost > 0)
- {
- if(($_combined_cost - $_actual_cost) >
0)
- {
- $_diff_obligation =
$_actual_cost;
- }
- else
- {
- $_diff_obligation =
$_combined_cost;
- }
- }
- else if($_combined_cost < 0)
- {
- if(($_combined_cost - $_actual_cost) <
0)
- {
- $_diff_obligation =
$_actual_cost;
- }
- else
- {
- $_diff_obligation =
$_combined_cost;
- }
- }
- else
- {
- $_diff_obligation = 0;
- }
-
- $sum_obligation_cost -= $_diff_obligation;
-
- $sum_actual_cost += $_actual_cost;
-
$obligations[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('dimb')]
-= $_diff_obligation;
-
$actual_cost[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('dimb')]
+= $_actual_cost;
- $accout_info[$this->db->f($b_account_field)] =
true;
- $district[(int)$this->db->f('district_id')] =
true;
- $ecodimb[(int)$this->db->f('dimb')] = true;
- }
-
-//-------end check active invoices-----------
-
// start service agreements
$filtermethod = " fm_s_agreement_budget.year = $year";
Modified: trunk/property/inc/class.soproject.inc.php
===================================================================
--- trunk/property/inc/class.soproject.inc.php 2012-12-21 12:27:55 UTC (rev
10617)
+++ trunk/property/inc/class.soproject.inc.php 2012-12-21 16:45:42 UTC (rev
10618)
@@ -671,89 +671,54 @@
$project['actual_cost'] = 0;
$project['billable_hours'] = 0;
- $sql_workder = 'SELECT combined_cost,
actual_cost, billable_hours,closed'//, contract_sum, addition, calculation,
budget'
- . " FROM fm_workorder {$this->join}
fm_workorder_status ON fm_workorder.status = fm_workorder_status.id"
- . " WHERE project_id =
'{$project['project_id']}'";
-//_debug_array($sql_workder);
+ $sql_workder_date_filter = '';
if ($start_date)
{
- $sql_workder .= " AND
fm_workorder.start_date >= $start_date AND fm_workorder.start_date <= $end_date
";
+ $sql_workder_date_filter = "AND
fm_workorder.start_date >= $start_date AND fm_workorder.start_date <= $end_date
";
}
- $this->db->query($sql_workder);
+ $sql_workder = 'SELECT
fm_workorder.id, budget, combined_cost, billable_hours, closed,
sum(fm_orders_paid_or_pending_view.amount) AS actual_cost'//, contract_sum,
addition, calculation, budget'
+ . " FROM fm_workorder"
+ . " {$this->join} fm_workorder_status
ON fm_workorder.status = fm_workorder_status.id"
+ . " {$this->left_join}
fm_orders_paid_or_pending_view ON fm_workorder.id =
fm_orders_paid_or_pending_view.order_id"
+ . " WHERE project_id =
'{$project['project_id']}' {$sql_workder_date_filter}"
+ . " GROUP BY fm_workorder.id, budget,
combined_cost, billable_hours, closed";
+//_debug_array($sql_workder);
+
+
$this->db->query($sql_workder,__LINE__,__FILE__);
+
+ $_obligation = 0;
+ $project['obligation'] = 0;
+
while ($this->db->next_record())
{
- $closed = false;
- if($this->db->f('closed'))
+ $_combined_cost =
$this->db->f('combined_cost');
+ $_actual_cost =
$this->db->f('actual_cost');
+ if(!$this->db->f('closed'))
{
- $_sum = 0;
- $closed = true;
+ $_obligation =
$_combined_cost - $_actual_cost;
+
if((int)$this->db->f('budget') >= 0)
+ {
+ if($_obligation
< 0)
+ {
+
$_obligation = 0;
+ }
+ }
+ else
+ {
+ if($_obligation
> 0)
+ {
+
$_obligation = 0;
+ }
+ }
+ $project['obligation']
+= $_obligation;
}
- else
- {
- $_sum =
$this->db->f('combined_cost');
- }
-/*
- else
if(abs($this->db->f('contract_sum')) > 0)
- {
- $_sum =
$this->db->f('contract_sum') * ( 1 + ((int)$this->db->f('addition')/100));
- }
- else
if(abs($this->db->f('calculation')) > 0)
- {
- $_sum =
$this->db->f('calculation');
- }
- else
if(abs($this->db->f('budget')) > 0)
- {
- $_sum =
$this->db->f('budget');
- }
- else
- {
- $_sum = 0;
- }
-*/
- $_actual_cost =
(int)$this->db->f('actual_cost');
- if($closed)
- {
- $__actual_cost = 0;
- }
- else
- {
- $__actual_cost =
$_actual_cost;
- }
-
- $project['combined_cost']
+= ($_sum - $__actual_cost);
- $project['actual_cost']
+= $_actual_cost;
$project['billable_hours']
+= (int)$this->db->f('billable_hours');
- }
-
- $sql_workder = 'SELECT godkjentbelop
AS actual_cost'
- . " FROM fm_ecobilag {$this->join}
fm_workorder ON fm_ecobilag.pmwrkord_code = fm_workorder.id"
- . " WHERE fm_workorder.project_id =
'{$project['project_id']}'";
-
- $this->db->query($sql_workder);
- while ($this->db->next_record())
- {
- $_actual_cost =
(int)$this->db->f('actual_cost');
- $project['combined_cost']
-= $_actual_cost;
$project['actual_cost']
+= $_actual_cost;
}
- if($project['budget'] >= 0)
- {
- if($project['combined_cost'] <
0)
- {
-
$project['combined_cost'] = 0;
- }
- }
- else
- {
- if($project['combined_cost'] >
0)
- {
-
$project['combined_cost'] = 0;
- }
- }
-
+ $project['combined_cost'] =
$project['obligation'];
$project['diff'] = $project['budget']
- $project['combined_cost'] - $project['actual_cost'];
}
@@ -884,22 +849,26 @@
function project_workorder_data($project_id = 0)
{
$project_id = (int) $project_id;
- $budget = array();
- $this->db->query("SELECT fm_workorder.title,
fm_workorder.actual_cost, fm_workorder.budget, fm_workorder.id as
workorder_id,fm_workorder.contract_sum,"
+ $values = array();
+ $this->db->query("SELECT
fm_workorder.title,combined_cost, fm_workorder.actual_cost,
fm_workorder.budget, fm_workorder.id as workorder_id,fm_workorder.contract_sum,"
. " fm_workorder.vendor_id,
fm_workorder.calculation,fm_workorder.rig_addition,fm_workorder.addition,fm_workorder.deviation,fm_workorder.charge_tenant,"
. " fm_workorder_status.descr as status,
fm_workorder_status.closed, fm_workorder.account_id as b_account_id"
. " FROM fm_workorder {$this->join}
fm_workorder_status ON fm_workorder.status = fm_workorder_status.id"
- . " WHERE project_id={$project_id}");
+ . " WHERE
project_id={$project_id}",__LINE__,__FILE__);
+ $_orders = array();
+
while ($this->db->next_record())
{
- $budget[] = array(
+ $values[] = array(
'workorder_id' =>
$this->db->f('workorder_id'),
'title' =>
$this->db->f('title',true),
'budget' =>
(int)$this->db->f('budget'),
'deviation' =>
$this->db->f('deviation'),
'calculation' =>
$this->db->f('calculation'),
- 'actual_cost' =>
$this->db->f('actual_cost'),
+ 'combined_cost' =>
(int)$this->db->f('combined_cost'),
+ 'actual_cost' => 0,
+ 'obligation' => 0,
'vendor_id' =>
$this->db->f('vendor_id'),
'charge_tenant' =>
$this->db->f('charge_tenant'),
'status' =>
$this->db->f('status'),
@@ -908,16 +877,60 @@
'contract_sum' =>
(int)$this->db->f('contract_sum'),
'addition_percentage' =>
(int)$this->db->f('addition')
);
+ $_orders[] = $this->db->f('workorder_id');
}
- foreach ($budget as &$entry)
+
+ if($_orders)
{
- $this->db->query("SELECT sum(godkjentbelop) AS
actual_cost FROM fm_ecobilag WHERE pmwrkord_code = '{$entry['workorder_id']}'
GROUP BY pmwrkord_code");
- $this->db->next_record();
- $entry['actual_cost']
+=$this->db->f('actual_cost');
+ $_actual_cost_arr = array();
+
+ $sql_cost = "SELECT order_id, sum(amount) AS
actual_cost"
+ . " FROM fm_workorder {$this->join}
fm_orders_paid_or_pending_view ON fm_workorder.id =
fm_orders_paid_or_pending_view.order_id"
+ . ' WHERE order_id IN (' . implode(',',
$_orders ) .') GROUP BY order_id';
+ $this->db->query($sql_cost,__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+
$_actual_cost_arr[$this->db->f('order_id')] = $this->db->f('actual_cost');
+ }
}
- return $budget;
+ foreach ($values as &$entry)
+ {
+ $_combined_cost =
round($entry['combined_cost']);
+
+ $_actual_cost =
isset($_actual_cost_arr[$entry['workorder_id']]) &&
$_actual_cost_arr[$entry['workorder_id']] ?
$_actual_cost_arr[$entry['workorder_id']] : 0;
+
+ // FIXME
+ // $_taxfactor = 1 +
($_taxcode[(int)$this->db->f('mvakode')]/100);
+ // $_actual_cost = round($actual_cost/$_taxfactor);
+
+ $entry['actual_cost'] = $_actual_cost;
+
+ $_obligation = 0;
+ if(!$entry['closed'])
+ {
+ $_obligation = $_combined_cost -
$_actual_cost;
+ if($entry['budget'] >= 0)
+ {
+ if($_obligation < 0)
+ {
+ $_obligation = 0;
+ }
+ }
+ else
+ {
+ if($_obligation > 0)
+ {
+ $_obligation = 0;
+ }
+ }
+ $entry['obligation'] = $_obligation;
+ }
+ $entry['diff'] = $entry['budget'] -
$entry['obligation'] - $entry['actual_cost'];
+ }
+
+ return $values;
}
function branch_p_list($project_id = '')
@@ -1595,7 +1608,7 @@
foreach ($periodization_outline as $outline)
{
$partial_budget = $budget * $outline['value'] /
100;
- $this->_updat_budget($project_id, $year,
$outline['month'], $partial_budget);
+ $this->_update_budget($project_id, $year,
$outline['month'], $partial_budget);
}
$sql = "SELECT sum(budget) as sum_budget FROM
fm_project_budget WHERE project_id = {$project_id}";
@@ -1608,7 +1621,7 @@
}
- private function _updat_budget($project_id, $year, $month,
$budget)
+ private function _update_budget($project_id, $year, $month,
$budget)
{
$month = (int) $month;
$budget = (int) $budget;
@@ -1665,25 +1678,37 @@
$active_period[$period] =
!!$this->db->f('active');
}
- $sql = "SELECT id AS order_id FROM fm_workorder WHERE
project_id = {$project_id}";
+ $sql = "SELECT fm_workorder.id AS order_id,
combined_cost, budget,fm_workorder_status.closed"
+ . " FROM fm_workorder"
+ . " {$this->join} fm_workorder_status ON
fm_workorder.status = fm_workorder_status.id"
+ . " WHERE project_id = {$project_id}";
+// _debug_array($sql);
$this->db->query($sql,__LINE__,__FILE__);
$_orders = array();
while ($this->db->next_record())
{
- $_orders[] = $this->db->f('order_id');
+ $_orders[$this->db->f('order_id')] = array
+ (
+ 'combined_cost' =>
$this->db->f('combined_cost'),
+ 'budget' =>
$this->db->f('budget'),
+ 'closed' =>
!!$this->db->f('closed')
+ );
}
-
+//_debug_array($_orders);
+$test = 0;
$orders = array();
- if($_orders)
+ if ( $_orders )
{
- $_order_filter = implode(',', $_orders);
- $sql = "SELECT sum(godkjentbelop) AS
actual_cost, pmwrkord_code AS order, periode FROM fm_ecobilagoverf WHERE
pmwrkord_code IN ({$_order_filter}) GROUP BY pmwrkord_code, periode ORDER BY
periode ASC ";
-
+ $sql = "SELECT order_id, periode, amount AS
actual_cost"
+ . " FROM fm_workorder {$this->join}
fm_orders_paid_or_pending_view ON fm_workorder.id =
fm_orders_paid_or_pending_view.order_id"
+ . ' WHERE order_id IN (' . implode(',',
array_keys($_orders) ) .') ORDER BY periode ASC';
+//_debug_array($sql);
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
+ $_order_id = $this->db->f('order_id');
$periode = $this->db->f('periode');
$year = substr( $periode, 0, 4 );
@@ -1691,7 +1716,7 @@
$_found = false;
if(isset($project_budget[$periode]))
{
-
$orders[$periode][$this->db->f('order')]['actual_cost'] +=
$this->db->f('actual_cost');
+
$orders[$periode][$_order_id]['actual_cost'] += $this->db->f('actual_cost');
$_found = true;
}
else
@@ -1701,7 +1726,8 @@
$_period = $year .
sprintf("%02s", $i);
if(isset($project_budget[$_period]))
{
-
$orders[$_period][$this->db->f('order')]['actual_cost'] +=
$this->db->f('actual_cost');
+
$orders[$_period][$_order_id]['actual_cost'] += $this->db->f('actual_cost');
+//_debug_array($test+=$this->db->f('actual_cost'));
$_found = true;
break;
}
@@ -1710,47 +1736,10 @@
if(!$_found)
{
-
$orders[$periode][$this->db->f('order')]['actual_cost'] +=
$this->db->f('actual_cost');
+
$orders[$periode][$_order_id]['actual_cost'] += $this->db->f('actual_cost');
}
}
//_debug_array($orders);die();
- $sql = "SELECT sum(godkjentbelop) AS
actual_cost, pmwrkord_code AS order, periode FROM fm_ecobilag WHERE
pmwrkord_code IN ({$_order_filter}) GROUP BY pmwrkord_code, periode ORDER BY
pmwrkord_code, periode ASC ";
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- $periode = $this->db->f('periode');
- $year = substr( $periode, 0, 4 );
- if(!$periode)
- {
- $year = date('Y');
- $periode = date('Ym');
- }
-
- $_found = false;
- if(isset($project_budget[$periode]))
- {
-
$orders[$periode][$this->db->f('order')]['actual_cost'] +=
$this->db->f('actual_cost');
- $_found = true;
- }
- else
- {
- for ($i=0;$i<13;$i++)
- {
- $_period = $year .
sprintf("%02s", $i);
-
if(isset($project_budget[$_period]))
- {
-
$orders[$_period][$this->db->f('order')]['actual_cost'] +=
$this->db->f('actual_cost');
- $_found = true;
- break;
- }
- }
- }
-
- if(!$_found)
- {
-
$orders[$periode][$this->db->f('order')]['actual_cost'] +=
$this->db->f('actual_cost');
- }
- }
}
$this->db->query("SELECT periodization_id FROM
fm_project WHERE id = {$project_id}",__LINE__,__FILE__);
@@ -1767,22 +1756,24 @@
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"
+ $sql = "SELECT fm_workorder.id, combined_cost,
to_char(to_timestamp(start_date), 'YYYYMM') as period"
. " 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";
+ . " WHERE project_id = {$project_id}"// AND
(fm_workorder_status.closed IS NULL OR fm_workorder_status.closed != 1)"
+ . " GROUP BY fm_workorder.id,
to_char(to_timestamp(start_date), 'YYYYMM'),fm_workorder.addition ORDER BY
start_date ASC";
$this->db->query($sql,__LINE__,__FILE__);
-
+//_debug_array($sql);
while ($this->db->next_record())
{
$_found = false;
- $_start_date =
$this->db->f('start_date');
- $_order_period = date('Ym',
$_start_date);
+
+ $_order_period = $this->db->f('period');
$year = date('Y');
@@ -1813,105 +1804,91 @@
{
$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;
+
$orders[$periode][$this->db->f('id')]['combined_cost'] =
$_orders[$this->db->f('id')]['combined_cost'];
}
+
unset($periode);
}
else
{
-
//FIXME
foreach ($project_order_amount as $periode =>
$_amount)
{
- $orders[$periode][] = array('amount' =>
$_amount);
+ $orders[$periode][] =
array('combined_cost' => $_amount);
}
}
+//_debug_array($orders);
+//_debug_array($orders); die();
$sort_period = array();
$values = array();
-
+//_debug_array($project_budget);die();
+//$test = 0;
foreach ($project_budget as $period => $_budget)
{
- $_sum_orders = 0;
+ $_sum_orders = array();
+ $_sum_oblications = array();
$_actual_cost = 0;
if(isset($orders[$period]))
{
+//_debug_array($orders[$period]);die();
+
foreach ($orders[$period] as $order_id
=> $order)
{
- $_sum_orders +=
$order['amount'];
- // $_sum_orders -=
$order['actual_cost'];
+ $_actual_cost +=
$order['actual_cost'];
+//_debug_array( $test+= $order['actual_cost']);
+ $_sum_orders[$order_id] +=
$order['combined_cost'];
- if($_budget >= 0)
+
if(!$_orders[$order_id]['closed'])
{
-
if($order['actual_cost'] >= 0)
- {
- $_sum_orders -=
$order['actual_cost'];
- }
- else
- {
- $_sum_orders +=
$order['actual_cost'];
- }
+
$_sum_oblications[$order_id] -= $order['actual_cost'];
+
$_sum_oblications[$order_id] += $order['combined_cost'];
- $_sum_orders =
$_sum_orders > 0 ? $_sum_orders : 0;
- }
- else // income
- {
-
if($order['actual_cost'] >= 0)
+
if($_orders[$order_id]['budget'] >= 0)
{
- $_sum_orders +=
$order['actual_cost'];
+
+
if($_sum_oblications[$order_id] < 0)
+ {
+
$_sum_oblications[$order_id] = 0;
+ }
}
- else
+ else // income
{
- $_sum_orders -=
$order['actual_cost'];
+
if($_sum_oblications[$order_id] > 0)
+ {
+
$_sum_oblications[$order_id] = 0;
+ }
}
-
- $_sum_orders =
$_sum_orders < 0 ? $_sum_orders : 0;
}
-
- $_actual_cost +=
$order['actual_cost'];
//override if periode is closed
if(isset($closed_period[$period]) && $closed_period[$period])
{
- $_sum_orders = 0;
+
$_sum_oblications[$order_id] = 0;
}
}
unset($orders[$period]);
}
-
+//die();
$values[] = array
(
'project_id' =>
$project_id,
'period'
=> $period,
'budget'
=> $_budget,
- 'sum_orders' =>
$_sum_orders,
+ 'sum_orders' =>
array_sum($_sum_orders),
+ 'sum_oblications' =>
array_sum($_sum_oblications),
'actual_cost' =>
$_actual_cost,
);
$sort_period[] = $period;
}
-//_debug_array($values);die();
+
+
+
unset($order);
unset($order_id);
unset($period);
@@ -1919,35 +1896,45 @@
reset($orders);
//remaining
-//_debug_array($orders);
+
foreach ($orders as $period => $_orders)
{
- $_sum_orders = 0;
+ $_sum_orders = array();
+ $_sum_oblications = array();
$_actual_cost = 0;
foreach ($_orders as $order_id => $order)
{
- $_sum_orders += $order['amount'];
-
- if($order['actual_cost'] > 0 &&
($order['amount'] - $order['actual_cost']) > 0)
+ $_actual_cost += $order['actual_cost'];
+
+ $_sum_orders[$order_id] +=
$order['combined_cost'];
+
+ if(!$_orders[$order_id]['closed'])
{
- $_sum_orders -=
$order['actual_cost'];
- $_sum_orders = $_sum_orders > 0
? $_sum_orders : 0;
+ $_sum_oblications[$order_id] -=
$order['actual_cost'];
+ $_sum_oblications[$order_id] +=
$order['combined_cost'];
+
+
if($_orders[$order_id]['budget'] >= 0)
+ {
+
if($_sum_oblications[$order_id] < 0)
+ {
+
$_sum_oblications[$order_id] = 0;
+ }
+ }
+ else // income
+ {
+
if($_sum_oblications[$order_id] > 0)
+ {
+
$_sum_oblications[$order_id] = 0;
+ }
+ }
}
- else if($order['actual_cost'] < 0 &&
($order['amount'] - $order['actual_cost']) < 0)//income
- {
- $_sum_orders -=
$order['actual_cost'];
- $_sum_orders = $_sum_orders < 0
? $_sum_orders : 0;
- }
- $_actual_cost += $order['actual_cost'];
-
//override if periode is closed
if(isset($closed_period[$period]) &&
$closed_period[$period])
{
- $_sum_orders = 0;
+ $_sum_oblications[$order_id] =
0;
}
-
}
$values[] = array
@@ -1955,7 +1942,8 @@
'project_id' =>
$project_id,
'period'
=> $period,
'budget'
=> 0,
- 'sum_orders' =>
$_sum_orders,
+ 'sum_orders' =>
array_sum($_sum_orders),
+ 'sum_oblications' =>
array_sum($_sum_oblications),
'actual_cost' =>
$_actual_cost,
);
@@ -1975,7 +1963,7 @@
$entry['month'] = $month == '00' ? '' : $month;
if($active_period[$entry['period']])
{
- $entry['diff'] = $entry['budget'] -
$entry['sum_orders'] - $entry['actual_cost'];
+ $entry['diff'] = $entry['budget'] -
$entry['sum_oblications'] - $entry['actual_cost'];
}
else
{
Modified: trunk/property/inc/class.soworkorder.inc.php
===================================================================
--- trunk/property/inc/class.soworkorder.inc.php 2012-12-21 12:27:55 UTC
(rev 10617)
+++ trunk/property/inc/class.soworkorder.inc.php 2012-12-21 16:45:42 UTC
(rev 10618)
@@ -276,6 +276,7 @@
$joinmethod .= " {$this->join}
fm_workorder_status ON (fm_workorder.status = fm_workorder_status.id))";
$paranthesis .='(';
+ $cols .= ',fm_workorder_status.closed';
$cols .= ',fm_vendor.org_name';
$cols_return[] = 'org_name';
$uicols['input_type'][] = 'hidden';
@@ -305,7 +306,7 @@
$cols .= ',fm_workorder.combined_cost';
$cols_return[] = 'combined_cost';
$uicols['input_type'][] = 'text';
- $uicols['name'][] =
'combined_cost';
+ $uicols['name'][] =
'obligation';
$uicols['descr'][] =
lang('sum orders');
$uicols['statustext'][] = lang('Cost -
either budget or calculation');
$uicols['exchange'][] = false;
@@ -716,13 +717,36 @@
$count_cols_return=count($cols_return);
+ $_order_list = array();
while ($this->db->next_record())
{
$workorder_list[] = array('workorder_id' =>
$this->db->f('id'));
+ $_order_list[] = $this->db->f('id');
}
$this->db->set_fetch_single(false);
+ $_actual_cost_arr = array();
+ if($workorder_list)
+ {
+ $sql_cost = "SELECT fm_workorder.id as
order_id,closed, sum(amount) AS actual_cost"
+ . " FROM fm_workorder {$this->left_join}
fm_orders_paid_or_pending_view ON fm_workorder.id =
fm_orders_paid_or_pending_view.order_id"
+ . " {$this->join} fm_workorder_status ON
fm_workorder.status = fm_workorder_status.id"
+ . ' WHERE fm_workorder.id IN (' . implode(',',
$_order_list ) .') GROUP BY fm_workorder.id, closed';
+
+ unset($_order_list);
+ $this->db->query($sql_cost,__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+
$_actual_cost_arr[$this->db->f('order_id')] = array
+ (
+ 'actual_cost' =>
$this->db->f('actual_cost'),
+ 'closed' =>
!!$this->db->f('closed')
+ );
+ }
+
+ }
+
foreach($workorder_list as &$workorder)
{
$this->db->query("{$sql} WHERE fm_workorder.id
= '{$workorder['workorder_id']}'");
@@ -732,8 +756,41 @@
{
$workorder[$cols_return[$i]] =
$this->db->f($cols_return[$i]);
}
- $workorder['budget'] =
$workorder['combined_cost'];
- $workorder['combined_cost'] =
$workorder['combined_cost'] - $workorder['actual_cost'];
+ $workorder['actual_cost'] = 0;
+ $workorder['obligation'] = 0;
+
+ if
(isset($_actual_cost_arr[$workorder['workorder_id']]))
+ {
+ $_combined_cost =
$workorder['combined_cost'];
+ // $_pending_cost =
round($this->db2->f('pending_cost'));
+
+ // $_taxfactor = 1 +
($_taxcode[(int)$this->db2->f('mvakode')]/100);
+ // $_actual_cost =
round($this->db2->f('actual_cost')/$_taxfactor);
+ // $_actual_cost =
round($this->db2->f('actual_cost'));
+ $workorder['actual_cost'] =
$_actual_cost_arr[$workorder['workorder_id']]['actual_cost'];
+
+
if(!$_actual_cost_arr[$workorder['workorder_id']]['closed'])
+ {
+ $_obligation = $_combined_cost
- $workorder['actual_cost'];
+ if((int)$workorder['budget'] >=
0)
+ {
+ if($_obligation < 0)
+ {
+ $_obligation =
0;
+ }
+ }
+ else
+ {
+ if($_obligation > 0)
+ {
+ $_obligation =
0;
+ }
+ }
+ $workorder['obligation'] =
$_obligation;
+ }
+ }
+
+//---------
$workorder['grants'] =
(int)$this->grants[$this->db->f('project_owner')];
$location_code= $this->db->f('location_code');
@@ -746,35 +803,8 @@
$workorder['query_location']['loc' .
($m+1)]=implode("-", array_slice($location, 0, ($m+1)));
}
- $sql_workder = 'SELECT godkjentbelop AS
actual_cost'
- . " FROM fm_ecobilag WHERE pmwrkord_code =
'{$workorder['workorder_id']}'";
- $this->db->query($sql_workder);
- while ($this->db->next_record())
- {
- $_actual_cost =
(int)$this->db->f('actual_cost');
- $workorder['combined_cost'] -=
$_actual_cost;
- $workorder['actual_cost'] +=
$_actual_cost;
- }
-
-
-
- if($workorder['budget'] > 0)
- {
- if($workorder['combined_cost'] < 0)
- {
- $workorder['combined_cost'] = 0;
- }
- }
- else
- {
- if($workorder['combined_cost'] > 0)
- {
- $workorder['combined_cost'] = 0;
- }
- }
-
- $workorder['diff'] = $workorder['budget'] -
$workorder['combined_cost'] - $workorder['actual_cost'];
+ $workorder['diff'] = $workorder['budget'] -
$workorder['obligation'] - $workorder['actual_cost'];
}
return $workorder_list;
Modified: trunk/property/inc/class.uiproject.inc.php
===================================================================
--- trunk/property/inc/class.uiproject.inc.php 2012-12-21 12:27:55 UTC (rev
10617)
+++ trunk/property/inc/class.uiproject.inc.php 2012-12-21 16:45:42 UTC (rev
10618)
@@ -1744,7 +1744,8 @@
'values' =>
json_encode(array( array('key' =>
'year','label'=>lang('year'),'sortable'=>false,'resizeable'=>true),
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' =>
'sum_orders','label'=>lang('budget') . '::' .
lang('order'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+
array('key' =>
'sum_oblications','label'=>lang('sum
orders'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
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'),
@@ -1781,10 +1782,11 @@
'values' =>
json_encode(array( array('key' =>
'workorder_id','label'=>lang('Workorder'),'sortable'=>true,'resizeable'=>true,'formatter'=>'YAHOO.widget.DataTable.formatLink'),
array('key' =>
'title','label'=>lang('title'),'sortable'=>true,'resizeable'=>true),
array('key' =>
'b_account_id','label'=>lang('Budget
account'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterRight'),
-
array('key' =>
'cost','label'=>lang('cost'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount2'),
+
array('key' =>
'budget','label'=>lang('budget'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+
array('key' =>
'cost','label'=>lang('cost'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
array('key' => 'addition_percentage','label'=>
'%','sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterRight'),
-
array('key' =>
'combined_cost','label'=>lang('sum
orders'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
-
array('key' =>
'actual_cost','label'=>lang('actual
cost'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount2'),
+
array('key' => 'obligation','label'=>lang('sum
orders'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+
array('key' =>
'actual_cost','label'=>lang('actual
cost'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
array('key' =>
'diff','label'=>lang('difference'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
array('key' =>
'vendor_name','label'=>lang('Vendor'),'sortable'=>true,'resizeable'=>true),
array('key' =>
'status','label'=>lang('Status'),'sortable'=>true,'resizeable'=>true)))
@@ -2345,6 +2347,7 @@
function view()
{
+
if(!$this->acl_read)
{
$this->bocommon->no_access();
Modified: trunk/property/js/yahoo/project.edit.js
===================================================================
--- trunk/property/js/yahoo/project.edit.js 2012-12-21 12:27:55 UTC (rev
10617)
+++ trunk/property/js/yahoo/project.edit.js 2012-12-21 16:45:42 UTC (rev
10618)
@@ -118,9 +118,10 @@
//call getTotalSum(name of column) in property.js
tmp_sum1 = getTotalSum_active('budget',0,paginator,datatable);
tmp_sum2 =
getTotalSum_active('sum_orders',0,paginator,datatable);
- tmp_sum3 =
getTotalSum_active('actual_cost',0,paginator,datatable);
- tmp_sum4 = getTotalSum_active('diff',0,paginator,datatable);
- tmp_sum5 =
getTotalSum_active('deviation',0,paginator,datatable);
+ tmp_sum3 =
getTotalSum_active('sum_oblications',0,paginator,datatable);
+ tmp_sum4 =
getTotalSum_active('actual_cost',0,paginator,datatable);
+ tmp_sum5 = getTotalSum_active('diff',0,paginator,datatable);
+ tmp_sum6 =
getTotalSum_active('deviation',0,paginator,datatable);
if(typeof(tableYUI0)=='undefined')
{
@@ -142,6 +143,7 @@
td_sum(tmp_sum3);
td_sum(tmp_sum4);
td_sum(tmp_sum5);
+ td_sum(tmp_sum6);
td_empty(7);
myfoot = tableYUI0.createTFoot();
@@ -152,15 +154,16 @@
this.addFooterDatatable1 = function(paginator,datatable)
{
//call getTotalSum(name of column) in property.js
- tmp_sum0 = getTotalSum('cost',2,paginator,datatable);
+ tmp_sum0 = getTotalSum('cost',0,paginator,datatable);
+
+ tmp_sum1 = getTotalSum('budget',0,paginator,datatable);
/*
- tmp_sum1 = getTotalSum('budget',0,paginator,datatable);
tmp_sum2 = getTotalSum('calculation',2,paginator,datatable);
tmp_sum3 = getTotalSum('contract_sum',2,paginator,datatable);
*/
- tmp_sum4 = getTotalSum('combined_cost',2,paginator,datatable);
- tmp_sum5 = getTotalSum('actual_cost',2,paginator,datatable);
- tmp_sum6 = getTotalSum('diff',2,paginator,datatable);
+ tmp_sum4 = getTotalSum('obligation',0,paginator,datatable);
+ tmp_sum5 = getTotalSum('actual_cost',0,paginator,datatable);
+ tmp_sum6 = getTotalSum('diff',0,paginator,datatable);
if(typeof(tableYUI1)=='undefined')
@@ -179,7 +182,7 @@
td_sum('Sum');
td_empty(2);
td_sum(tmp_sum0);
-// td_sum(tmp_sum1);
+ td_sum(tmp_sum1);
// td_sum(tmp_sum2);
// td_sum(tmp_sum3);
td_empty(1);
Modified: trunk/property/setup/setup.inc.php
===================================================================
--- trunk/property/setup/setup.inc.php 2012-12-21 12:27:55 UTC (rev 10617)
+++ trunk/property/setup/setup.inc.php 2012-12-21 16:45:42 UTC (rev 10618)
@@ -12,7 +12,7 @@
*/
$setup_info['property']['name'] = 'property';
- $setup_info['property']['version'] = '0.9.17.658';
+ $setup_info['property']['version'] = '0.9.17.659';
$setup_info['property']['app_order'] = 8;
$setup_info['property']['enable'] = 1;
$setup_info['property']['app_group'] = 'office';
Modified: trunk/property/setup/tables_update.inc.php
===================================================================
--- trunk/property/setup/tables_update.inc.php 2012-12-21 12:27:55 UTC (rev
10617)
+++ trunk/property/setup/tables_update.inc.php 2012-12-21 16:45:42 UTC (rev
10618)
@@ -7069,3 +7069,48 @@
return $GLOBALS['setup_info']['property']['currentver'];
}
}
+
+ /**
+ * Update property version from 0.9.17.658 to 0.9.17.659
+ * Add view on fm_ecobilag
+ */
+ $test[] = '0.9.17.658';
+ function property_upgrade0_9_17_658()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+ $GLOBALS['phpgw_setup']->oProc->query("DELETE FROM fm_cache");
+
+ $sql = 'UPDATE fm_project SET project_type_id = 1 WHERE
project_type_id IS NULL';
+
+ $GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+
+ $sql = 'CREATE OR REPLACE VIEW fm_orders_pending_cost_view AS'
+ . ' SELECT fm_ecobilag.pmwrkord_code AS order_id,
sum(fm_ecobilag.godkjentbelop) AS pending_cost FROM fm_ecobilag GROUP BY
fm_ecobilag.pmwrkord_code';
+
+ $GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+
+ $sql = 'CREATE OR REPLACE VIEW fm_orders_actual_cost_view AS'
+ . ' SELECT fm_ecobilagoverf.pmwrkord_code AS order_id,
sum(fm_ecobilagoverf.godkjentbelop) AS actual_cost FROM fm_ecobilagoverf GROUP
BY fm_ecobilagoverf.pmwrkord_code';
+
+ $GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+
+
+ $sql = 'CREATE OR REPLACE VIEW fm_orders_paid_or_pending_view AS
+ SELECT orders_paid_or_pending.order_id,
orders_paid_or_pending.periode, orders_paid_or_pending.amount
+ FROM ( SELECT fm_ecobilagoverf.pmwrkord_code AS
order_id, fm_ecobilagoverf.periode, sum(fm_ecobilagoverf.godkjentbelop) AS
amount
+ FROM fm_ecobilagoverf
+ GROUP BY fm_ecobilagoverf.pmwrkord_code,
fm_ecobilagoverf.periode
+ UNION ALL
+ SELECT fm_ecobilag.pmwrkord_code AS order_id,
fm_ecobilag.periode, sum(fm_ecobilag.godkjentbelop) AS amount
+ FROM fm_ecobilag
+ GROUP BY fm_ecobilag.pmwrkord_code, fm_ecobilag.periode)
orders_paid_or_pending';
+
+ $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.659';
+ return $GLOBALS['setup_info']['property']['currentver'];
+ }
+ }
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [10618] Property: update accounting reporting,
Sigurd Nes <=