[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [10621] Property: update accounting reporting
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [10621] Property: update accounting reporting |
Date: |
Fri, 28 Dec 2012 14:17:01 +0000 |
Revision: 10621
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10621
Author: sigurdne
Date: 2012-12-28 14:17:00 +0000 (Fri, 28 Dec 2012)
Log Message:
-----------
Property: update accounting reporting
Modified Paths:
--------------
trunk/property/inc/class.boproject.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/js/yahoo/property2.js
trunk/property/setup/phpgw_no.lang
trunk/property/setup/setup.inc.php
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-12-23 14:23:35 UTC (rev
10620)
+++ trunk/property/inc/class.boproject.inc.php 2012-12-28 14:17:00 UTC (rev
10621)
@@ -897,6 +897,11 @@
return $this->so->get_budget($project_id);
}
+ public function get_buffer_budget($project_id)
+ {
+ return $this->so->get_buffer_budget($project_id);
+ }
+
public function get_periodizations_with_outline()
{
return $this->so->get_periodizations_with_outline();
Modified: trunk/property/inc/class.soproject.inc.php
===================================================================
--- trunk/property/inc/class.soproject.inc.php 2012-12-23 14:23:35 UTC (rev
10620)
+++ trunk/property/inc/class.soproject.inc.php 2012-12-28 14:17:00 UTC (rev
10621)
@@ -1062,7 +1062,7 @@
if($project['budget'])
{
- $this->updat_budget($id,
$project['budget_year'], $project['budget_periodization'], $project['budget']);
+ $this->update_budget($id,
$project['budget_year'], $project['budget_periodization'], $project['budget']);
}
if($project['extra']['contact_phone'] &&
$project['extra']['tenant_id'])
@@ -1287,15 +1287,141 @@
$this->delete_period_from_budget($project['id'], $project['delete_b_period']);
}
- if($project['budget'])
+ $workorders = array();
+
+ if($project['project_type_id']==3)//buffer
{
- $this->updat_budget($project['id'],
$project['budget_year'], $project['budget_periodization'], $project['budget']);
+ if($project['budget'])
+ {
+
$this->_update_buffer_budget($project['id'], $project['budget_year'],
$project['budget'], null,null);
+ }
+
}
+ else // investment or operation
+ {
+ if($project['budget'])
+ {
+ $this->update_budget($project['id'],
$project['budget_year'], $project['budget_periodization'], $project['budget']);
+ }
- $this->db->query("SELECT sum(budget) AS sum_budget FROM
fm_project_budget WHERE project_id = " . (int)$project['id'],__LINE__,__FILE__);
- $this->db->next_record();
- $new_budget =(int)$this->db->f('sum_budget');
+ $this->db->query("SELECT sum(budget) AS
sum_budget FROM fm_project_budget WHERE project_id = " .
(int)$project['id'],__LINE__,__FILE__);
+ $this->db->next_record();
+ $new_budget =(int)$this->db->f('sum_budget');
+ if ($old_budget != $new_budget)
+ {
+ $this->db->query("UPDATE fm_project SET
budget = {$new_budget} WHERE id = " . (int)$project['id'],__LINE__,__FILE__);
+
$historylog->add('B',$project['id'],$project['budget'], $old_budget);
+ }
+
+ $this->db->query("SELECT id FROM fm_workorder
WHERE project_id=" . (int)$project['id'] ,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $workorders[] = $this->db->f('id');
+ }
+
+ if ($workorders)
+ {
+ $historylog_workorder =
CreateObject('property.historylog','workorder');
+ }
+
+ if (isset($project['new_project_id']) &&
$project['new_project_id'] && ($project['new_project_id'] != $project['id']))
+ {
+ $new_project_id = (int)
$project['new_project_id'];
+ reset($workorders);
+ foreach($workorders as $workorder_id)
+ {
+
$historylog_workorder->add('NP',$workorder_id,$new_project_id, $project['id']);
+ }
+
+ $sql = "SELECT sum(budget) AS
sum_budget FROM fm_project_budget WHERE project_id = {$new_project_id}";
+
$this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $old_budget_new_project =
(int)$this->db->f('sum_budget');
+
+ $sql = "SELECT * FROM fm_project_budget
WHERE project_id = " . (int)$project['id'];
+
$this->db->query($sql,__LINE__,__FILE__);
+
+ $budget = array();
+ while ($this->db->next_record())
+ {
+ $budget[] = array
+ (
+ 'project_id'
=> (int)$project['id'],
+ 'year'
=> $this->db->f('year'),
+ 'month'
=> $this->db->f('month'),
+ 'budget'
=> (int)$this->db->f('budget'),
+ 'user_id'
=> $this->db->f('user_id'),
+ 'entry_date'
=> $this->db->f('entry_date'),
+ 'modified_date'
=> $this->db->f('modified_date'),
+ 'closed'
=> $this->db->f('closed'),
+ 'active'
=> $this->db->f('active')
+ );
+ }
+
+ foreach($budget as $entry)
+ {
+ $sql = "SELECT * FROM
fm_project_budget WHERE project_id = {$new_project_id} AND year =
{$entry['year']} AND month = {$entry['month']}";
+
$this->db->query($sql,__LINE__,__FILE__);
+ if($this->db->next_record())
+ {
+ $sql = "UPDATE
fm_project_budget SET budget = budget + {$entry['budget']} WHERE project_id =
{$new_project_id} AND year = {$entry['year']} AND month = {$entry['month']}";
+
$this->db->query($sql,__LINE__,__FILE__);
+ }
+ else
+ {
+ $value_set = array
+ (
+ 'project_id'
=> $new_project_id,
+ 'year'
=> $entry['year'],
+ 'month'
=> $entry['month'],
+ 'budget'
=> $entry['budget'],
+ 'user_id'
=> $entry['user_id'],
+ 'entry_date'
=> $entry['entry_date'],
+ 'modified_date'
=> $entry['modified_date'],
+ 'closed'
=> $entry['closed'],
+ 'active'
=> $entry['active']
+
+ );
+ $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__);
+ }
+ }
+
+ if ($old_budget)
+ {
+
$historylog->add('B',$project['id'],0, $old_budget);
+ }
+
+ $sql = "SELECT sum(budget) AS
sum_budget FROM fm_project_budget WHERE project_id = {$new_project_id}";
+
$this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $new_budget_new_project =
(int)$this->db->f('sum_budget');
+
+ $sql = "SELECT reserve, ecodimb FROM
fm_project WHERE id = " . (int)$project['id'];
+
$this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $reserve_old_project =
(int)$this->db->f('reserve');
+ $ecodimb_old_project =
(int)$this->db->f('ecodimb');
+
+ if ($new_budget_new_project !=
$old_budget_new_project)
+ {
+
$historylog->add('B',$new_project_id, $new_budget_new_project,
$old_budget_new_project);
+ }
+
+ $this->db->query("UPDATE fm_workorder
SET project_id = {$new_project_id}, ecodimb = {$ecodimb_old_project} WHERE
project_id = {$project['id']}",__LINE__,__FILE__);
+ $this->db->query("UPDATE fm_project SET
reserve = 0 WHERE reserve IS NULL AND id = {$new_project_id}"
,__LINE__,__FILE__);
+ $this->db->query("UPDATE fm_project SET
budget = {$new_budget_new_project}, reserve = reserve + {$reserve_old_project}
WHERE id = {$new_project_id}" ,__LINE__,__FILE__);
+ $this->db->query("UPDATE fm_project SET
budget = 0, reserve = 0 WHERE id = " . (int)$project['id'] ,__LINE__,__FILE__);
+ $this->db->query("DELETE FROM
fm_project_budget WHERE project_id = " . (int)$project['id']
,__LINE__,__FILE__);
+
$historylog->add('RM',(int)$project['id'],"Budsjett og alle bestillinger er
overført fra prosjekt {$project['id']} til prosjekt {$new_project_id}");
+
$historylog->add('RM',$new_project_id,"Budsjett og alle bestillinger er
overført fra prosjekt {$project['id']} til prosjekt {$new_project_id}");
+ }
+
+ }
+
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__);
@@ -1323,17 +1449,7 @@
}
$this->update_request_status($project['id'],$project['status'],$project['cat_id'],$project['coordinator']);
- $this->db->query("SELECT id FROM fm_workorder WHERE
project_id=" . (int)$project['id'] ,__LINE__,__FILE__);
- $workorders = array();
- while ($this->db->next_record())
- {
- $workorders[] = $this->db->f('id');
- }
- if ($workorders)
- {
- $historylog_workorder =
CreateObject('property.historylog','workorder');
- }
if (($old_status != $project['status']) ||
$project['confirm_status'])
{
@@ -1443,13 +1559,7 @@
$receipt['notice_owner'][]=lang('Coordinator
changed') . ': ' .
$GLOBALS['phpgw']->accounts->id2name($project['coordinator']);
}
- if ($old_budget != $new_budget)
- {
- $this->db->query("UPDATE fm_project SET budget
= {$new_budget} WHERE id = " . (int)$project['id'],__LINE__,__FILE__);
-
$historylog->add('B',$project['id'],$project['budget'], $old_budget);
- }
-
if ($old_reserve != (int)$project['reserve'])
{
$historylog->add('BR',$project['id'],$project['reserve'], $old_reserve);
@@ -1460,101 +1570,8 @@
$historylog->add('RM',$project['id'],$project['remark']);
}
-// execMethod('property.soworkorder.update_planned_cost',
$project['id']);
- if (isset($project['new_project_id']) &&
$project['new_project_id'] && ($project['new_project_id'] != $project['id']))
- {
- $new_project_id = (int)
$project['new_project_id'];
- reset($workorders);
- foreach($workorders as $workorder_id)
- {
-
$historylog_workorder->add('NP',$workorder_id,$new_project_id, $project['id']);
- }
- $sql = "SELECT sum(budget) AS sum_budget FROM
fm_project_budget WHERE project_id = {$new_project_id}";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $old_budget_new_project =
(int)$this->db->f('sum_budget');
-
- $sql = "SELECT * FROM fm_project_budget WHERE
project_id = " . (int)$project['id'];
- $this->db->query($sql,__LINE__,__FILE__);
-
- $budget = array();
- while ($this->db->next_record())
- {
- $budget[] = array
- (
- 'project_id' =>
(int)$project['id'],
- 'year'
=> $this->db->f('year'),
- 'month'
=> $this->db->f('month'),
- 'budget'
=> (int)$this->db->f('budget'),
- 'user_id'
=> $this->db->f('user_id'),
- 'entry_date' =>
$this->db->f('entry_date'),
- 'modified_date' =>
$this->db->f('modified_date'),
- 'closed'
=> $this->db->f('closed'),
- 'active'
=> $this->db->f('active')
- );
- }
-
- foreach($budget as $entry)
- {
- $sql = "SELECT * FROM fm_project_budget
WHERE project_id = {$new_project_id} AND year = {$entry['year']} AND month =
{$entry['month']}";
-
$this->db->query($sql,__LINE__,__FILE__);
- if($this->db->next_record())
- {
- $sql = "UPDATE
fm_project_budget SET budget = budget + {$entry['budget']} WHERE project_id =
{$new_project_id} AND year = {$entry['year']} AND month = {$entry['month']}";
-
$this->db->query($sql,__LINE__,__FILE__);
- }
- else
- {
- $value_set = array
- (
- 'project_id'
=> $new_project_id,
- 'year'
=> $entry['year'],
- 'month'
=> $entry['month'],
- 'budget'
=> $entry['budget'],
- 'user_id'
=> $entry['user_id'],
- 'entry_date'
=> $entry['entry_date'],
- 'modified_date'
=> $entry['modified_date'],
- 'closed'
=> $entry['closed'],
- 'active'
=> $entry['active']
-
- );
- $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__);
- }
- }
-
- if ($old_budget)
- {
- $historylog->add('B',$project['id'],0,
$old_budget);
- }
-
- $sql = "SELECT sum(budget) AS sum_budget FROM
fm_project_budget WHERE project_id = {$new_project_id}";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $new_budget_new_project =
(int)$this->db->f('sum_budget');
-
- $sql = "SELECT reserve FROM fm_project WHERE id
= " . (int)$project['id'];
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $reserve_old_project =
(int)$this->db->f('reserve');
-
- if ($new_budget_new_project !=
$old_budget_new_project)
- {
- $historylog->add('B',$new_project_id,
$new_budget_new_project, $old_budget_new_project);
- }
-
- $this->db->query("UPDATE fm_workorder SET
project_id = {$new_project_id} WHERE project_id =
{$project['id']}",__LINE__,__FILE__);
- $this->db->query("UPDATE fm_project SET reserve
= 0 WHERE reserve IS NULL AND id = {$new_project_id}" ,__LINE__,__FILE__);
- $this->db->query("UPDATE fm_project SET budget
= {$new_budget_new_project}, reserve = reserve + {$reserve_old_project} WHERE
id = {$new_project_id}" ,__LINE__,__FILE__);
- $this->db->query("UPDATE fm_project SET budget
= 0, reserve = 0 WHERE id = " . (int)$project['id'] ,__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_project_budget
WHERE project_id = " . (int)$project['id'] ,__LINE__,__FILE__);
-
$historylog->add('RM',(int)$project['id'],"Budsjett og alle bestillinger er
overført fra prosjekt {$project['id']} til prosjekt {$new_project_id}");
- $historylog->add('RM',$new_project_id,"Budsjett
og alle bestillinger er overført fra prosjekt {$project['id']} til prosjekt
{$new_project_id}");
- }
-
$receipt['id'] = $project['id'];
$receipt['message'][] = array('msg'=>lang('project %1
has been edited', $project['id']));
@@ -1575,7 +1592,7 @@
}
- function updat_budget($project_id, $year, $periodization_id,
$budget)
+ function update_budget($project_id, $year, $periodization_id,
$budget)
{
$project_id = (int) $project_id;
$year = $year ? (int) $year : date('Y');
@@ -1633,7 +1650,73 @@
return $sum_budget;
}
+ public function get_buffer_budget($project_id)
+ {
+ $sql = "SELECT * FROM fm_project_buffer_budget WHERE
buffer_project_id = {$project_id}";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $values = array();
+ while ($this->db->next_record())
+ {
+ $values[] = array
+ (
+ 'buffer_project_id' =>
$this->db->f('buffer_project_id'),
+ 'year' =>
$this->db->f('year'),
+ 'amount_in' =>
$this->db->f('amount_in'),
+ 'amount_out' =>
$this->db->f('amount_out'),
+ 'from_project' =>
$this->db->f('from_project'),
+ 'to_project' =>
$this->db->f('to_project'),
+ 'user_id' =>
$this->db->f('this->account'),
+ 'entry_date' =>
$this->db->f('entry_date'),
+ 'active' =>
!!$this->db->f('active'),
+ 'remark' =>
$this->db->f('remark',true)
+ );
+ }
+ return $values;
+ }
+ private function _update_buffer_budget($project_id, $year,
$amount, $from_project, $to_project)
+ {
+ $year = (int) $year;
+ $amount = (int) $amount;
+
+ if(!$year)
+ {
+ $year = date('Y');
+ }
+
+ if($from_project || (!$from_project && !$to_project))
+ {
+ $amount_in = $amount;
+ $amount_out = null;
+ }
+ else if ($to_project && !$from_project)
+ {
+ $amount_in = null;
+ $amount_out = $amount;
+ }
+ else
+ {
+ throw new
Exception('property_soproject::update_buffer_budget() - wrong input');
+ }
+
+ $value_set = array
+ (
+ 'buffer_project_id' => $project_id,
+ 'year' => $year,
+ 'amount_in' => $amount_in,
+ 'amount_out' => $amount_out,
+ 'from_project' => $from_project,
+ 'to_project' => $to_project,
+ 'user_id' =>
$this->account,
+ 'entry_date' => time(),
+ 'active' => 1
+ );
+
+ $cols = implode(',', array_keys($value_set));
+ $values =
$this->db->validate_insert(array_values($value_set));
+ $this->db->query("INSERT INTO fm_project_buffer_budget
({$cols}) VALUES ({$values})",__LINE__,__FILE__);
+ }
+
private function _update_budget($project_id, $year, $month,
$budget)
{
$month = (int) $month;
@@ -1676,7 +1759,7 @@
$closed_period = array();
$active_period = array();
$project_budget = array();
- $project_order_amount = array();
+ $project_total_budget = 0;
$sql = "SELECT fm_project_budget.year,
fm_project_budget.month, fm_project_budget.budget, fm_project_budget.closed,
fm_project_budget.active, sum(combined_cost) AS order_amount, start_date"
. " FROM fm_project_budget {$this->left_join}
fm_workorder ON fm_project_budget.project_id = fm_workorder.project_id WHERE
fm_project_budget.project_id = {$project_id}"
@@ -1688,50 +1771,58 @@
$period = $this->db->f('year') .
sprintf("%02s", $this->db->f('month'));
$project_budget[$period] =
(int)$this->db->f('budget');
- $project_order_amount[$period] = $period ==
date('Ym') ? $this->db->f('order_amount') : 0;
$closed_period[$period] =
!!$this->db->f('closed');
$active_period[$period] =
!!$this->db->f('active');
}
+ $project_total_budget = array_sum($project_budget);
- $sql = "SELECT fm_workorder.id AS order_id,
combined_cost, budget,fm_workorder_status.closed"
+ $sql = "SELECT fm_workorder.id AS order_id,
fm_workorder_budget.combined_cost, fm_workorder_budget.budget,
fm_workorder_budget.year, fm_workorder_budget.month, fm_workorder_status.closed"
. " FROM fm_workorder"
. " {$this->join} fm_workorder_status ON
fm_workorder.status = fm_workorder_status.id"
+ . " {$this->join} fm_workorder_budget ON
fm_workorder.id = fm_workorder_budget.order_id"
. " WHERE project_id = {$project_id}";
// _debug_array($sql);
$this->db->query($sql,__LINE__,__FILE__);
+ $_order_list = array();
$_orders = array();
while ($this->db->next_record())
{
- $_orders[$this->db->f('order_id')] = array
+ $period = $this->db->f('year') .
sprintf("%02s", $this->db->f('month'));
+ $_order_list[] = $this->db->f('order_id');
+ $_orders[$period][$this->db->f('order_id')] =
array
(
'combined_cost' =>
$this->db->f('combined_cost'),
'budget' =>
$this->db->f('budget'),
+ 'actual_cost' => 0, //for now..
'closed' =>
!!$this->db->f('closed')
);
}
//_debug_array($_orders);
$test = 0;
- $orders = array();
- if ( $_orders )
+ if ( $_order_list )
{
$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';
+ . ' WHERE order_id IN (' . implode(',',
$_order_list ) .') 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');
+ if(!$periode)
+ {
+ $periode = date('Ym');
+ }
$year = substr( $periode, 0, 4 );
$_found = false;
if(isset($project_budget[$periode]))
{
-
$orders[$periode][$_order_id]['actual_cost'] += $this->db->f('actual_cost');
+
$_orders[$periode][$_order_id]['actual_cost'] += $this->db->f('actual_cost');
$_found = true;
}
else
@@ -1741,7 +1832,7 @@
$_period = $year .
sprintf("%02s", $i);
if(isset($project_budget[$_period]))
{
-
$orders[$_period][$_order_id]['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;
@@ -1751,92 +1842,14 @@
if(!$_found)
{
-
$orders[$periode][$_order_id]['actual_cost'] += $this->db->f('actual_cost');
+
$_orders[$periode][$_order_id]['actual_cost'] += $this->db->f('actual_cost');
}
}
-//_debug_array($orders);die();
}
- $this->db->query("SELECT periodization_id FROM
fm_project WHERE id = {$project_id}",__LINE__,__FILE__);
- $this->db->next_record();
- if($this->db->f('periodization_id'))
- {
- $_use_periodization = true;
- }
- else
- {
- $_use_periodization = false;
- }
+//_debug_array($_orders);die();
- if(!$_use_periodization)
- {
-/*
- $config =
CreateObject('phpgwapi.config','property');
- $config->read();
- $tax = 1+(($config->config_data['fm_tax'])/100);
-*/
-
- $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,
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;
-
- $_order_period = $this->db->f('period');
-
- $year = date('Y');
-
- if($_use_periodization)
- {
- $periode = $_order_period;
-
if(isset($project_budget[$periode]))
- {
- $_found = true;
- }
- }
-
- if(!$_found) //move to current
- {
- $check_months = array(0,
date('m'));
- foreach ($check_months as $i)
- {
- $periode = $year .
sprintf("%02s", $i);
-
if(isset($project_budget[$periode]))
- {
- $_found = true;
- break;
- }
- }
- }
-
- if(!$_found)
- {
- $periode = date('Ym');
- }
-
-
$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('combined_cost' => $_amount);
- }
-
- }
-
-//_debug_array($orders);
-//_debug_array($orders); die();
$sort_period = array();
$values = array();
//_debug_array($project_budget);die();
@@ -1847,22 +1860,22 @@
$_sum_oblications = array();
$_actual_cost = 0;
- if(isset($orders[$period]))
+ if(isset($_orders[$period]))
{
-//_debug_array($orders[$period]);die();
+//_debug_array($_orders[$period]);die();
- foreach ($orders[$period] as $order_id
=> $order)
+ foreach ($_orders[$period] as $order_id
=> $order)
{
$_actual_cost +=
$order['actual_cost'];
//_debug_array( $test+= $order['actual_cost']);
$_sum_orders[$order_id] +=
$order['combined_cost'];
-
if(!$_orders[$order_id]['closed'])
+ if(!$order['closed'])
{
$_sum_oblications[$order_id] -= $order['actual_cost'];
$_sum_oblications[$order_id] += $order['combined_cost'];
-
if($_orders[$order_id]['budget'] >= 0)
+
if($project_total_budget >= 0)
{
if($_sum_oblications[$order_id] < 0)
@@ -1886,7 +1899,7 @@
}
}
- unset($orders[$period]);
+ unset($_orders[$period]);
}
//die();
$values[] = array
@@ -1908,28 +1921,28 @@
unset($order_id);
unset($period);
- reset($orders);
+ reset($_orders);
//remaining
- foreach ($orders as $period => $_orders)
+ foreach ($_orders as $period => $orders)
{
$_sum_orders = array();
$_sum_oblications = array();
$_actual_cost = 0;
- foreach ($_orders as $order_id => $order)
+ foreach ($orders as $order_id => $order)
{
$_actual_cost += $order['actual_cost'];
$_sum_orders[$order_id] +=
$order['combined_cost'];
- if(!$_orders[$order_id]['closed'])
+ if(!$order['closed'])
{
$_sum_oblications[$order_id] -=
$order['actual_cost'];
$_sum_oblications[$order_id] +=
$order['combined_cost'];
-
if($_orders[$order_id]['budget'] >= 0)
+ if($project_total_budget >= 0)
{
if($_sum_oblications[$order_id] < 0)
{
@@ -1984,10 +1997,12 @@
{
$entry['diff'] = 0;
}
-
- $deviation = $entry['budget'] -
$entry['actual_cost'];
- $entry['deviation'] = $deviation;
- $entry['deviation_percent'] =
$deviation/$entry['budget'] * 100;
+ $_deviation = $entry['budget'] -
$entry['actual_cost'];
+ $deviation = abs($entry['actual_cost']) > 0 ?
$_deviation : 0;
+ $entry['deviation_period'] = $deviation;
+ $entry['deviation_acc'] += $deviation;
+ $entry['deviation_percent_period'] =
$deviation/$entry['budget'] * 100;
+ $entry['deviation_percent_acc'] =
$entry['deviation_acc']/$entry['budget'] * 100;
$entry['closed'] =
$closed_period[$entry['period']];
$entry['active'] =
$active_period[$entry['period']];
}
Modified: trunk/property/inc/class.soworkorder.inc.php
===================================================================
--- trunk/property/inc/class.soworkorder.inc.php 2012-12-23 14:23:35 UTC
(rev 10620)
+++ trunk/property/inc/class.soworkorder.inc.php 2012-12-28 14:17:00 UTC
(rev 10621)
@@ -744,7 +744,7 @@
'closed' =>
!!$this->db->f('closed')
);
}
-
+
}
foreach($workorder_list as &$workorder)
@@ -763,7 +763,7 @@
{
$_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'));
@@ -1161,9 +1161,10 @@
$this->db->query("SELECT periodization_id FROM
fm_project WHERE id = {$workorder['project_id']}",__LINE__,__FILE__);
$this->db->next_record();
$periodization_id = $this->db->f('periodization_id');
-
- $this->_update_project_budget($workorder['project_id'],
date('Y', $workorder['start_date']), $periodization_id, $combined_cost);
+// $this->_update_project_budget($workorder['project_id'],
date('Y', $workorder['start_date']), $periodization_id, $combined_cost);
+ $this->_update_order_budget($id, date('Y',
$workorder['start_date']), $periodization_id,
$workorder['budget'],$combined_cost);
+
/*
if($workorder['charge_tenant'])
{
@@ -1340,9 +1341,11 @@
$this->db->query("SELECT periodization_id FROM
fm_project WHERE id = {$workorder['project_id']}",__LINE__,__FILE__);
$this->db->next_record();
$periodization_id = $this->db->f('periodization_id');
-
- $this->_update_project_budget($workorder['project_id'],
date('Y', $workorder['start_date']), $periodization_id,
$combined_cost,$old_combined_cost);
+// $this->_update_project_budget($workorder['project_id'],
date('Y', $workorder['start_date']), $periodization_id,
$combined_cost,$old_combined_cost);
+ $this->_update_order_budget($workorder['id'], date('Y',
$workorder['start_date']), $periodization_id,
$workorder['budget'],$combined_cost);
+
+
/* if($workorder['charge_tenant'])
{
$this->db->query("UPDATE fm_project set
charge_tenant = 1 WHERE id =" . $workorder['project_id']);
@@ -1615,11 +1618,11 @@
$config->read_repository();
$tax = 1+(($config->config_data['fm_tax'])/100);
- $this->db->query("UPDATE fm_project_budget SET
order_amount = 0",__LINE__,__FILE__);
+// $this->db->query("UPDATE fm_project_budget SET
order_amount = 0",__LINE__,__FILE__);
foreach ($orders as $id => $dummy)
{
- $this->db->query("SELECT project_id,
start_date, combined_cost, budget,calculation,contract_sum,addition FROM
fm_workorder WHERE id = {$id}",__LINE__,__FILE__);
+ $this->db->query("SELECT project_id,
start_date, combined_cost, budget,calculation,contract_sum,addition,ecodimb
FROM fm_workorder WHERE id = {$id}",__LINE__,__FILE__);
$this->db->next_record();
$old_combined_cost =
$this->db->f('combined_cost');
@@ -1629,6 +1632,7 @@
$addition =
$this->db->f('addition');
$project_id =
$this->db->f('project_id');
$start_date =
$this->db->f('start_date');
+ $old_ecodimb =
(int)$this->db->f('ecodimb');
if ( abs((int)$contract_sum) > 0)
{
@@ -1650,11 +1654,18 @@
$this->db->query("UPDATE fm_workorder
SET combined_cost = '{$combined_cost}' WHERE id = {$id}",__LINE__,__FILE__);
}
- $this->db->query("SELECT periodization_id FROM
fm_project WHERE id = {$project_id}",__LINE__,__FILE__);
+ $this->db->query("SELECT
periodization_id,ecodimb FROM fm_project WHERE id =
{$project_id}",__LINE__,__FILE__);
$this->db->next_record();
- $periodization_id =
$this->db->f('periodization_id');
+ $periodization_id =
$this->db->f('periodization_id');
+ $ecodimb =
(int)$this->db->f('ecodimb');
- $this->_update_project_budget($project_id,
date('Y', $start_date), $periodization_id, $combined_cost);
+ if($old_ecodimb != $ecodimb)
+ {
+ $this->db->query("UPDATE fm_workorder
SET ecodimb = {$ecodimb} WHERE id = {$id}",__LINE__,__FILE__);
+ }
+
+ // $this->_update_project_budget($project_id,
date('Y', $start_date), $periodization_id, $combined_cost);
+ $this->_update_order_budget($id, date('Y',
$start_date), $periodization_id, $budget, $combined_cost);
}
$config = CreateObject('phpgwapi.config','property');
@@ -1712,7 +1723,7 @@
'month' => 0,
'value' => 100,
);
-
+
}
//FIXME : condsider removed
@@ -1726,4 +1737,92 @@
}
*/
}
+ private function _update_order_budget($order_id, $year,
$periodization_id, $budget, $combined_cost = 0)
+ {
+ $order_id = $order_id;//might be bigint
+ $year = $year ? (int) $year : date('Y');
+
+ $periodization_id = (int) $periodization_id;
+ $periodization_outline = array();
+
+ if($periodization_id)
+ {
+ $this->db->query("SELECT month,
value,dividend,divisor FROM fm_eco_periodization_outline WHERE periodization_id
= {$periodization_id} ORDER BY month ASC",__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+ $periodization_outline[] = array
+ (
+ 'month' =>
$this->db->f('month'),
+ 'value' =>
$this->db->f('value'),
+ 'dividend' =>
$this->db->f('dividend'),
+ 'divisor' =>
$this->db->f('divisor')
+ );
+ }
+ }
+ else
+ {
+ $periodization_outline[] = array
+ (
+ 'month' => 0,
+ 'value' => 100,
+ 'dividend' => 1,
+ 'divisor' => 1,
+
+ );
+
+ }
+
+ $sql = "DELETE FROM fm_workorder_budget WHERE order_id
= '{$order_id}'";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ foreach ($periodization_outline as $outline)
+ {
+ if ($outline['dividend'] && $outline['divisor'])
+ {
+ $partial_budget = $budget *
$outline['dividend'] / $outline['divisor'];
+ $partial_cost = $combined_cost *
$outline['dividend'] / $outline['divisor'];
+ }
+ else
+ {
+ $partial_budget = $budget *
$outline['value'] / 100;
+ $partial_cost = $combined_cost *
$outline['value'] / 100;
+ }
+
+ $this->_update_budget($order_id, $year,
$outline['month'], $partial_budget, $partial_cost);
+ }
+ }
+
+ private function _update_budget($order_id, $year, $month,
$budget,$combined_cost)
+ {
+ $month = (int) $month;
+ $budget = (int) $budget;
+ $now = time();
+
+ $sql = "SELECT order_id FROM fm_workorder_budget WHERE
order_id = {$order_id} AND year = {$year} AND month = {$month}";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+ if ($this->db->next_record())
+ {
+ $sql = "UPDATE fm_workorder_budget SET budget =
'{$budget}', combined_cost = '{$combined_cost}', modified_date = {$now} WHERE
order_id = '{$order_id}' AND year = {$year} AND month = {$month}";
+ $this->db->query($sql,__LINE__,__FILE__);
+ }
+ else
+ {
+ $value_set = array
+ (
+ 'order_id' =>
$order_id,
+ 'year' =>
$year,
+ 'month' =>
$month,
+ 'budget' =>
$budget,
+ 'combined_cost' =>
$combined_cost,
+ '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_workorder_budget ({$cols}) VALUES ({$values})",__LINE__,__FILE__);
+ }
+ }
}
Modified: trunk/property/inc/class.uiproject.inc.php
===================================================================
--- trunk/property/inc/class.uiproject.inc.php 2012-12-23 14:23:35 UTC (rev
10620)
+++ trunk/property/inc/class.uiproject.inc.php 2012-12-28 14:17:00 UTC (rev
10621)
@@ -1188,6 +1188,12 @@
$error_id=true;
}
+ if(!isset($values['project_type_id'])
|| !$values['project_type_id'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a project type!'));
+ $error_id=true;
+ }
+
if(!$values['name'])
{
$receipt['error'][]=array('msg'=>lang('Please enter a project NAME !'));
@@ -1628,6 +1634,7 @@
{
$prefs2 =
$this->bocommon->create_preferences('property', $prefs['approval_from']);
+
if(isset($prefs2['email']))
{
$supervisor_email[] = array
@@ -1719,6 +1726,7 @@
$value_remainder -=
$b_entry['sum_orders'];
$value_remainder -=
$b_entry['actual_cost'];
}
+ unset($b_entry);
}
$values['sum'] = number_format($values['sum'], 0, ',',
' ');
@@ -1726,30 +1734,51 @@
//_debug_array($content_budget);die();
- $datavalues[0] = array
+
+
+
+ if( isset($values['project_type_id']) &&
$values['project_type_id']==3)
+ {
+
+ $myColumnDefs[0] = array
(
- 'name'
=> "0",
- 'values'
=> json_encode($content_budget),
- 'total_records' =>
count($content_budget),
- 'edit_action' => "''",
- 'permission' => "''",
- 'is_paginator' => 1,
- 'footer'
=> 0
+ 'name' => "0",
+ 'values' =>
json_encode(array
+
(
+
array('key' =>
'year','label'=>lang('year'),'sortable'=>false,'resizeable'=>true),
+
array('key' => 'entry_date','label'=>lang('entry
date'),'sortable'=>true,'resizeable'=>true),
+
array('key' => 'amount_in','label'=>lang('amount
in'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+
array('key' => 'from_project','label'=>lang('from
project'),'sortable'=>true,'resizeable'=>true),
+
array('key' => 'amount_out','label'=>lang('amount
out'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+
array('key' => 'to_project','label'=>lang('to
project'),'sortable'=>true,'resizeable'=>true),
+
array('key' =>
'user_name','label'=>lang('user'),'sortable'=>true,'resizeable'=>true)
+
)
+
)
);
-
- $myColumnDefs[0] = array
+ $content_budget =
$this->bo->get_buffer_budget($id);
+ foreach($content_budget as & $b_entry)
+ {
+ $b_entry['entry_date'] =
$GLOBALS['phpgw']->common->show_date($b_entry['entry_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ }
+ unset($b_entry);
+ }
+ else
+ {
+ $myColumnDefs[0] = array
(
'name' => "0",
'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('budget') . '::' .
lang('order'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+
array('key' => 'sum_orders','label'=>
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'),
-
array('key' =>
'deviation_percent','label'=>lang('deviation') . '::' .
lang('percent'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount2'),
+
array('key' =>
'deviation_period','label'=>lang('deviation'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+
array('key' =>
'deviation_acc','label'=>lang('deviation'). '::' .
lang('accumulated'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+
array('key' =>
'deviation_percent_period','label'=>lang('deviation') . '::' .
lang('percent'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount2'),
+
array('key' =>
'deviation_percent_acc','label'=>lang('percent'). '::' .
lang('accumulated'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount2'),
array('key' =>
'closed','label'=>lang('closed'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter'),
array('key' => 'closed_orig','hidden' => true),
array('key' =>
'active','label'=>lang('active'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter'),
@@ -1757,13 +1786,19 @@
array('key' => 'flag_active','hidden' => true),
array('key' =>
'delete_year','label'=>lang('Delete'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter')))
);
+ }
-/*
-
array('key' => 'subtract_sum_orders','hidden'
=> true),
-
array('key' => 'subtract_actual_cost','hidden'
=> true),
-
array('key' => 'subtract_budget','hidden' =>
true),
+ $datavalues[0] = array
+ (
+ 'name'
=> "0",
+ 'values'
=> json_encode($content_budget),
+ 'total_records' =>
count($content_budget),
+ 'edit_action' => "''",
+ 'permission' => "''",
+ 'is_paginator' => 1,
+ 'footer'
=> 0
+ );
-*/
//_debug_array($values['workorder_budget']);die();
$datavalues[1] = array
@@ -1953,6 +1988,7 @@
$data = array
(
'project_types'
=> array('options' =>
$this->bo->get_project_types($values['project_type_id'])),
+ 'project_type_id'
=> $values['project_type_id'],
'inherit_location'
=> $id ? $values['inherit_location'] : 1,
'mode'
=> $mode,
'suppressmeter'
=> isset($config->config_data['project_suppressmeter']) &&
$config->config_data['project_suppressmeter'] ? 1 : '',
@@ -2121,6 +2157,7 @@
phpgwapi_yui::load_widget('dragdrop');
phpgwapi_yui::load_widget('datatable');
+
phpgwapi_yui::load_widget('menu');
phpgwapi_yui::load_widget('connection');
phpgwapi_yui::load_widget('loader');
Modified: trunk/property/js/yahoo/project.edit.js
===================================================================
--- trunk/property/js/yahoo/project.edit.js 2012-12-23 14:23:35 UTC (rev
10620)
+++ trunk/property/js/yahoo/project.edit.js 2012-12-28 14:17:00 UTC (rev
10621)
@@ -84,7 +84,16 @@
/********************************************************************************/
this.myParticularRenderEvent = function()
{
- this.addFooterDatatable0(myPaginator_0,myDataTable_0);
+
+ if(project_type_id == 3)
+ {
+
this.addFooterDatatable_buffer(myPaginator_0,myDataTable_0);
+ }
+ else
+ {
+ this.addFooterDatatable0(myPaginator_0,myDataTable_0);
+ }
+
this.addFooterDatatable1(myPaginator_1,myDataTable_1);
this.addFooterDatatable2(myPaginator_2,myDataTable_2);
}
@@ -113,6 +122,39 @@
}
+ this.addFooterDatatable_buffer = function(paginator,datatable)
+ {
+ //call getTotalSum(name of column) in property.js
+ tmp_sum1 = getTotalSum('amount_in',0,paginator,datatable);
+ tmp_sum2 = getTotalSum('amount_out',0,paginator,datatable);
+ tmp_sum3 = tmp_sum1 + tmp_sum2;
+
+ if(typeof(tableYUI0)=='undefined')
+ {
+ tableYUI0 =
YAHOO.util.Dom.getElementsByClassName("yui-dt-data","tbody")[0].parentNode;
+ tableYUI0.setAttribute("id","tableYUI0");
+ }
+ else
+ {
+ tableYUI0.deleteTFoot();
+ }
+
+ //Create ROW
+ newTR = document.createElement('tr');
+
+ td_sum('Sum');
+ td_empty(1);
+ td_sum(tmp_sum1);
+ td_empty(1);
+ td_sum(tmp_sum2);
+ td_empty(1);
+ td_sum(tmp_sum3);
+
+ myfoot = tableYUI0.createTFoot();
+ myfoot.setAttribute("id","myfoot");
+ myfoot.appendChild(newTR);
+ }
+
this.addFooterDatatable0 = function(paginator,datatable)
{
//call getTotalSum(name of column) in property.js
@@ -144,7 +186,7 @@
td_sum(tmp_sum4);
td_sum(tmp_sum5);
td_sum(tmp_sum6);
- td_empty(7);
+ td_empty(9);
myfoot = tableYUI0.createTFoot();
myfoot.setAttribute("id","myfoot");
Modified: trunk/property/js/yahoo/property2.js
===================================================================
--- trunk/property/js/yahoo/property2.js 2012-12-23 14:23:35 UTC (rev
10620)
+++ trunk/property/js/yahoo/property2.js 2012-12-28 14:17:00 UTC (rev
10621)
@@ -43,7 +43,11 @@
tmp_sum = 0;
for(i = begin; i < end; i++)
{
- tmp_sum = tmp_sum +
parseFloat(datatable.getRecordSet().getRecords(0)[i].getData(name_column));
+ if(tmp_record =
parseFloat(datatable.getRecordSet().getRecords(0)[i].getData(name_column)))
+ {
+ tmp_sum += tmp_record;
+ }
+ //tmp_sum = tmp_sum +
parseFloat(datatable.getRecordSet().getRecords(0)[i].getData(name_column));
}
return tmp_sum = YAHOO.util.Number.format(tmp_sum,
{decimalPlaces:round, decimalSeparator:",", thousandsSeparator:" "});
Modified: trunk/property/setup/phpgw_no.lang
===================================================================
--- trunk/property/setup/phpgw_no.lang 2012-12-23 14:23:35 UTC (rev 10620)
+++ trunk/property/setup/phpgw_no.lang 2012-12-28 14:17:00 UTC (rev 10621)
@@ -14,6 +14,7 @@
accounting tax property no Regnskap mva-kode
accounting voucher category property no Regnskap kategorier
faktura
accounting voucher type property no Regnskap type faktura
+accumulated property no Akkumulert
acl_locastion is missing property no ACL-lokalisering mangler
acquisition date property no Anskaffelses dato
action property no Handling
Modified: trunk/property/setup/setup.inc.php
===================================================================
--- trunk/property/setup/setup.inc.php 2012-12-23 14:23:35 UTC (rev 10620)
+++ trunk/property/setup/setup.inc.php 2012-12-28 14:17:00 UTC (rev 10621)
@@ -12,7 +12,7 @@
*/
$setup_info['property']['name'] = 'property';
- $setup_info['property']['version'] = '0.9.17.660';
+ $setup_info['property']['version'] = '0.9.17.661';
$setup_info['property']['app_order'] = 8;
$setup_info['property']['enable'] = 1;
$setup_info['property']['app_group'] = 'office';
@@ -99,6 +99,7 @@
'fm_b_account',
'fm_b_account_category',
'fm_workorder',
+ 'fm_workorder_budget',
'fm_workorder_history',
'fm_workorder_status',
'fm_activities',
@@ -128,6 +129,7 @@
'fm_ns3420',
'fm_project_status',
'fm_project',
+ 'fm_project_buffer_budget',
'fm_projectbranch',
'fm_project_group',
'fm_project_history',
Modified: trunk/property/setup/tables_current.inc.php
===================================================================
--- trunk/property/setup/tables_current.inc.php 2012-12-23 14:23:35 UTC (rev
10620)
+++ trunk/property/setup/tables_current.inc.php 2012-12-28 14:17:00 UTC (rev
10621)
@@ -550,6 +550,22 @@
'ix' => array(),
'uc' => array()
),
+ 'fm_workorder_budget' => array(
+ 'fd' => array(
+ 'order_id' => array('type' => 'int','precision'
=> 8,'nullable' => False),
+ 'year' => array('type' => 'int','precision' =>
4,'nullable' => False),
+ 'month' => array('type' => 'int','precision' =>
2,'nullable' => False,'default' => 0),
+ 'budget' => array('type' =>
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' =>
'0.00'),
+ 'combined_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)
+ ),
+ 'pk' => array('order_id','year','month'),
+ 'fk' => array('fm_workorder' => array('order_id' =>
'id')),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
'fm_activities' => array(
'fd' => array(
'id' => array('type' => 'int','precision' =>
'4','nullable' => False),
@@ -1547,12 +1563,15 @@
'fm_project_buffer_budget' => array(
'fd' => array(
'id' => array('type' => 'auto','precision' =>
'4','nullable' => False),
+ 'year' => array('type' => 'int','precision' =>
4,'nullable' => False),
+ 'month' => array('type' => 'int','precision' =>
2,'nullable' => False,'default' => 0),
'buffer_project_id' => array('type' =>
'int','precision' => '4','nullable' => False),
'entry_date' => array('type' =>
'int','precision' => '4','nullable' => False),
'amount_in' => array('type' =>
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' =>
'0.00'),
'from_project' => array('type' =>
'int','precision' => '4','nullable' => true),
'amount_out' => array('type' =>
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' =>
'0.00'),
'to_project' => array('type' =>
'int','precision' => '4','nullable' => true),
+ 'active' => array('type' => 'int','precision'
=> 2,'nullable' => True),
'user_id' => array('type' => 'int','precision'
=> '4','nullable' => False),
'remark' => array('type' => 'text','nullable'
=> true),
),
Modified: trunk/property/setup/tables_update.inc.php
===================================================================
--- trunk/property/setup/tables_update.inc.php 2012-12-23 14:23:35 UTC (rev
10620)
+++ trunk/property/setup/tables_update.inc.php 2012-12-28 14:17:00 UTC (rev
10621)
@@ -7081,7 +7081,7 @@
$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'
@@ -7114,7 +7114,7 @@
return $GLOBALS['setup_info']['property']['currentver'];
}
}
-
+
/**
* Update property version from 0.9.17.659 to 0.9.17.660
* Add fraction to periodization outline as an alternative
@@ -7123,8 +7123,8 @@
function property_upgrade0_9_17_659()
{
$GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
-
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_eco_periodization_outline','dividend',array(
'type' => 'int',
'precision' => 4,
@@ -7153,5 +7153,64 @@
return $GLOBALS['setup_info']['property']['currentver'];
}
}
-
+ /**
+ * Update property version from 0.9.17.660 to 0.9.17.661
+ * Add year and active-flag to project_buffer_budget
+ */
+ $test[] = '0.9.17.660';
+ function property_upgrade0_9_17_660()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_project_buffer_budget','year',array(
+ 'type' => 'int',
+ 'precision' => 4,
+ 'nullable' => false
+ )
+ );
+
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_project_buffer_budget','month',array(
+ 'type' => 'int',
+ 'precision' => 4,
+ 'nullable' => false,
+ 'default' => 0
+ )
+ );
+
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_project_buffer_budget','active',array(
+ 'type' => 'int',
+ 'precision' => 2,
+ 'nullable' => true
+ )
+ );
+
+
+ $GLOBALS['phpgw_setup']->oProc->query('UPDATE fm_project_budget
SET active = 1',__LINE__,__FILE__);
+
+ $GLOBALS['phpgw_setup']->oProc->CreateTable(
+ 'fm_workorder_budget', array(
+ 'fd' => array(
+ 'order_id' => array('type' =>
'int','precision' => 8,'nullable' => False),
+ 'year' => array('type' =>
'int','precision' => 4,'nullable' => False),
+ 'month' => array('type' =>
'int','precision' => 2,'nullable' => False,'default' => 0),
+ 'budget' => array('type' =>
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' =>
'0.00'),
+ 'combined_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)
+ ),
+ 'pk' => array('order_id','year','month'),
+ 'fk' => array('fm_workorder' =>
array('order_id' => 'id')),
+ 'ix' => array(),
+ 'uc' => array()
+ )
+ );
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['property']['currentver'] =
'0.9.17.661';
+ return $GLOBALS['setup_info']['property']['currentver'];
+ }
+ }
Modified: trunk/property/templates/base/project.xsl
===================================================================
--- trunk/property/templates/base/project.xsl 2012-12-23 14:23:35 UTC (rev
10620)
+++ trunk/property/templates/base/project.xsl 2012-12-28 14:17:00 UTC (rev
10621)
@@ -40,6 +40,7 @@
{
document.add_sub_entry_form.submit();
}
+ var project_type_id = '<xsl:value-of
select="project_type_id"/>';
</script>
<table cellpadding="2" cellspacing="2" align="center">
<xsl:choose>
@@ -453,6 +454,9 @@
<div
id="datatable-container_0"/>
</td>
</tr>
+ <xsl:choose>
+ <xsl:when test="project_type_id !='3'">
+
<tr>
<td
valign="top">
<xsl:value-of select="lang_reserve"/>
@@ -484,17 +488,11 @@
<xsl:text> % )</xsl:text>
</td>
</tr>
-<!--
+ </xsl:when>
+ <xsl:otherwise>
+ </xsl:otherwise>
+ </xsl:choose>
<tr>
- <td
valign="top">
-
<xsl:value-of select="lang_planned_cost"/>
- </td>
- <td>
-
<xsl:value-of select="value_planned_cost"/><xsl:text> </xsl:text> [
<xsl:value-of select="currency"/> ]
- </td>
- </tr>
--->
- <tr>
<td
class="th_text" valign="top">
<xsl:value-of select="lang_workorder_id"/>
</td>
@@ -522,6 +520,7 @@
<div
id="datatable-container_2"/>
</td>
</tr>
+
</table>
<!-- DATATABLE DEFINITIONS-->
<script type="text/javascript">
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [10621] Property: update accounting reporting,
Sigurd Nes <=