[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11032] property: budget handling
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11032] property: budget handling |
Date: |
Sun, 07 Apr 2013 12:31:04 +0000 |
Revision: 11032
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11032
Author: sigurdne
Date: 2013-04-07 12:30:01 +0000 (Sun, 07 Apr 2013)
Log Message:
-----------
property: budget handling
Modified Paths:
--------------
trunk/property/inc/class.soXport.inc.php
trunk/property/inc/class.sobudget.inc.php
trunk/property/inc/class.soworkorder.inc.php
Modified: trunk/property/inc/class.soXport.inc.php
===================================================================
--- trunk/property/inc/class.soXport.inc.php 2013-04-05 13:37:16 UTC (rev
11031)
+++ trunk/property/inc/class.soXport.inc.php 2013-04-07 12:30:01 UTC (rev
11032)
@@ -788,22 +788,26 @@
foreach ($orders as $order)
{
-
phpgwapi_cache::system_clear('property', "budget_order_{$order['order_id']}");
$this->db->query("UPDATE fm_workorder
SET actual_cost = '{$order['actual_cost']}' WHERE id =
'{$order['order_id']}'",__LINE__,__FILE__);
+ }
+ foreach ($orders_affected as $order_id =>
$dummy)
+ {
+
phpgwapi_cache::system_clear('property', "budget_order_{$order_id}");
- $this->db->query("SELECT max(periode)
AS period, max(amount) AS amount FROM fm_orders_paid_or_pending_view WHERE
order_id = {$order['order_id']}",__LINE__,__FILE__);
+ $this->db->query("SELECT max(periode)
AS period, max(amount) AS amount FROM fm_orders_paid_or_pending_view WHERE
order_id = {$order_id} AND periode IS NOT NULL",__LINE__,__FILE__);
$this->db->next_record();
$period =
$this->db->f('period');
$amount =
$this->db->f('amount');
$year = $period ? (int)
substr($period,0,4) : date('Y');
- $this->db->query("SELECT order_id FROM
fm_workorder_budget WHERE order_id = {$order['order_id']} AND year =
{$year}",__LINE__,__FILE__);
- if(!$this->db->next_record())
+ $this->db->query("SELECT order_id FROM
fm_workorder_budget WHERE order_id = {$order_id} AND year =
{$year}",__LINE__,__FILE__);
+
+ if (!$this->db->next_record())
{
try
{
-
$soworkorder->transfer_budget($order['order_id'], array('budget_amount' =>
$amount, 'latest_year' => ($year -1)), $year);
+
$soworkorder->transfer_budget($order_id, array('budget_amount' => $amount,
'latest_year' => ($year -1)), $year);
}
catch(Exception $e)
{
@@ -813,6 +817,32 @@
}
}
}
+
+ // Not yet processed
+ $this->db->query("SELECT max(amount) AS
amount FROM fm_orders_paid_or_pending_view WHERE order_id = {$order_id} AND
periode IS NULL",__LINE__,__FILE__);
+
+ if($this->db->next_record())
+ {
+ $amount =
$this->db->f('amount');
+ $year =
date('Y');
+
+ $this->db->query("SELECT
order_id FROM fm_workorder_budget WHERE order_id = {$order_id} AND year =
{$year}",__LINE__,__FILE__);
+
+ if (!$this->db->next_record())
+ {
+ try
+ {
+
$soworkorder->transfer_budget($order_id, array('budget_amount' => $amount,
'latest_year' => ($year -1)), $year);
+ }
+ catch(Exception $e)
+ {
+ if ( $e )
+ {
+
phpgwapi_cache::message_set($e->getMessage(), 'error');
+ }
+ }
+ }
+ }
}
}
}
Modified: trunk/property/inc/class.sobudget.inc.php
===================================================================
--- trunk/property/inc/class.sobudget.inc.php 2013-04-05 13:37:16 UTC (rev
11031)
+++ trunk/property/inc/class.sobudget.inc.php 2013-04-07 12:30:01 UTC (rev
11032)
@@ -576,19 +576,19 @@
if($cat_ids)
{
- $filtermethod .= " $where fm_workorder.category
IN (". implode(',', $cat_ids) . ')';
+ $filtermethod .= " {$where}
fm_workorder.category IN (". implode(',', $cat_ids) . ')';
$where = 'AND';
}
if ($district_id > 0)
{
- $filtermethod .= " $where district_id=" .
(int)$district_id;
+ $filtermethod .= " {$where} district_id=" .
(int)$district_id;
$where = 'AND';
}
if ($dimb_id > 0)
{
- $filtermethod .= " $where
fm_workorder.ecodimb={$dimb_id}";
+ $filtermethod .= " {$where}
fm_project.ecodimb={$dimb_id}";
$where = 'AND';
}
@@ -605,7 +605,7 @@
if($_department_dimb)
{
- $filtermethod .= " $where fm_workorder.ecodimb
IN (" . implode(',', $_department_dimb) . ')';
+ $filtermethod .= " $where fm_project.ecodimb IN
(" . implode(',', $_department_dimb) . ')';
$where = 'AND';
}
@@ -651,7 +651,7 @@
}
$sql = "SELECT DISTINCT fm_workorder.id AS id,
fm_location1.mva,project_id,"
- . " fm_b_account.{$b_account_field} AS
b_account, district_id, fm_workorder.ecodimb"
+ . " fm_b_account.{$b_account_field} AS
b_account, district_id, fm_project.ecodimb"
. " 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)"
Modified: trunk/property/inc/class.soworkorder.inc.php
===================================================================
--- trunk/property/inc/class.soworkorder.inc.php 2013-04-05 13:37:16 UTC
(rev 11031)
+++ trunk/property/inc/class.soworkorder.inc.php 2013-04-07 12:30:01 UTC
(rev 11032)
@@ -212,7 +212,7 @@
$cols_return[] =
'start_date';
$cols .= ",fm_workorder.end_date as end_date";
$cols_return[] =
'end_date';
- $cols.= ",fm_workorder.ecodimb";
+ $cols.= ",fm_project.ecodimb";
$cols_return[] =
'ecodimb';
$cols.= ",fm_workorder.contract_sum";
$cols_return[] =
'contract_sum';
@@ -471,7 +471,7 @@
$order_field = ",
fm_workorder.end_date";
break;
case 'ecodimb':
- $order_field = ",
fm_workorder.ecodimb";
+ $order_field = ",
fm_project.ecodimb";
break;
case 'budget':
$order_field = ",
fm_workorder.budget";
@@ -563,7 +563,7 @@
if ($ecodimb)
{
- $filtermethod .= " $where fm_workorder.ecodimb
=" . (int) $ecodimb;
+ $filtermethod .= " $where fm_project.ecodimb ="
. (int) $ecodimb;
$where= 'AND';
}
@@ -2036,9 +2036,6 @@
execMethod('property.soXport.update_actual_cost_from_archive',$orders);
-
-
-
$config = CreateObject('phpgwapi.config','property');
$config->read_repository();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11032] property: budget handling,
Sigurd Nes <=