[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11664] report periodizations on paid invoices
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11664] report periodizations on paid invoices |
Date: |
Sun, 09 Feb 2014 16:12:15 +0000 |
Revision: 11664
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11664
Author: sigurdne
Date: 2014-02-09 16:12:13 +0000 (Sun, 09 Feb 2014)
Log Message:
-----------
report periodizations on paid invoices
Modified Paths:
--------------
trunk/property/inc/class.soworkorder.inc.php
trunk/property/inc/class.uiimport.inc.php
Modified: trunk/property/inc/class.soworkorder.inc.php
===================================================================
--- trunk/property/inc/class.soworkorder.inc.php 2014-02-08 13:04:20 UTC
(rev 11663)
+++ trunk/property/inc/class.soworkorder.inc.php 2014-02-09 16:12:13 UTC
(rev 11664)
@@ -1802,6 +1802,7 @@
$budget =
(int)$this->db->f('budget');
$combined_cost =
(int)$this->db->f('combined_cost');
+ $closed_order = (int)$this->db->f('closed');
$_order_budget[$period] = array
(
'order_id' =>
$order_id,
@@ -1811,7 +1812,7 @@
'year' =>
$year,
'month' =>
$month,
'actual_cost' => 0, //for
now..
- 'closed_order' =>
(int)$this->db->f('closed'),
+ 'closed_order' =>
$closed_order,
'active_period' =>
(int)$this->db->f('active'),
);
@@ -1923,20 +1924,88 @@
//_debug_array($sql);
$this->db->query($sql,__LINE__,__FILE__);
$orders_paid_or_pending = array();
+ $orders_paid_or_pending_temp = array();
while ($this->db->next_record())
{
- $orders_paid_or_pending[] = array
+ $orders_paid_or_pending_temp[] = array
(
'periode'
=> $this->db->f('periode'),
'actual_cost' =>
$this->db->f('actual_cost'),
- 'periodization' =>
$this->db->f('periodization'),
+ 'periodization' =>
(int)$this->db->f('periodization'),
'periodization_start' =>
$this->db->f('periodization_start'),
);
}
+ foreach ( $orders_paid_or_pending_temp as $entry)
+ {
+ if($entry['periodization'])
+ {
+ $periodization_start =
$entry['periodization_start'] ? $entry['periodization_start'] :
$entry['periodization'];
+
+ $periodization_start_year =
(int)substr($periodization_start, 0, 4 );
+
+ $sql = "SELECT month, value, dividend,
divisor"
+ . " FROM fm_eco_periodization_outline
WHERE periodization_id = {$entry['periodization']} ORDER BY month ASC";
+
$this->db->query($sql,__LINE__,__FILE__);
+
+ $periodization_outline = array();
+
+ 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')
+ );
+ }
+ if (!$periodization_outline)
+ {
+ $periodization_outline[] = array
+ (
+ 'month' => 1,
+ 'value' => 100,
+ );
+ }
+
+ foreach ($periodization_outline as
$outline)
+ {
+ if ($outline['dividend'] &&
$outline['divisor'])
+ {
+ $partial_actual_cost =
$budget * $outline['dividend'] / $outline['divisor'];
+ }
+ else
+ {
+ $partial_actual_cost =
$budget * $outline['value'] / 100;
+ }
+
+ $_future_year_count =
floor(($outline['month']-1) / 12);
+
+ $_periodization_start_year =
$periodization_start_year + $_future_year_count;
+
+ $_month = $outline['month'] -
($_future_year_count * 12);
+
+ $orders_paid_or_pending[] =
array
+ (
+ 'periode'
=> sprintf("%s%02d",$_periodization_start_year, $_month),
+ 'actual_cost'
=> $partial_actual_cost,
+ 'periodization'
=> $entry['periodization'],
+ );
+ }
+
+ }
+ else
+ {
+ $orders_paid_or_pending[] = $entry;
+ }
+
+ }
+
foreach ( $orders_paid_or_pending as
$_orders_paid_or_pending)
{
+
$periode = $_orders_paid_or_pending['periode'];
$_dummy_period = $periode ? $periode :
date('Y') . '00';
@@ -1948,12 +2017,23 @@
$year = substr( $periode, 0, 4 );
$_found = false;
- if(isset($order_budget[$periode]))
+
+
if(isset($_orders_paid_or_pending['periodization']))
{
$order_budget[$periode]['actual_cost']
+= $_orders_paid_or_pending['actual_cost'];
$order_budget[$periode]['actual_period'] = $periode;
+ $order_budget[$periode]['year'] = $year;
+ $order_budget[$periode]['month'] =
substr( $periode, -2 );
+ $order_budget[$periode]['closed_order']
= $closed_order;
+
$_found = true;
}
+ else if(isset($order_budget[$periode]))
+ {
+ $order_budget[$periode]['actual_cost']
+= $_orders_paid_or_pending['actual_cost'];
+
$order_budget[$periode]['actual_period'] = $periode;
+ $_found = true;
+ }
else
{
for ($i=0;$i<13;$i++)
@@ -1977,7 +2057,7 @@
$order_budget[$_dummy_period]['actual_period'] = $periode;
}
}
-
+//_debug_array($order_budget);die();
$sort_period = array();
$values = array();
$_current_period = date('Ym');
Modified: trunk/property/inc/class.uiimport.inc.php
===================================================================
--- trunk/property/inc/class.uiimport.inc.php 2014-02-08 13:04:20 UTC (rev
11663)
+++ trunk/property/inc/class.uiimport.inc.php 2014-02-09 16:12:13 UTC (rev
11664)
@@ -53,11 +53,13 @@
$this->valid_tables = array
(
- 'fm_vendor' =>
'fm_vendor (' . lang('vendor') . ')',
- 'fm_condition_survey' => 'fm_condition_survey
(' . lang('condition survey') . ')',
- 'fm_ecodimb' => 'fm_ecodimb
(' . lang('dimb') . ')',
- 'fm_budget' =>
'fm_budget (' . lang('budget') . ')',
- 'fm_department' =>
'fm_department (' . lang('department') . ')',
+ 'fm_vendor'
=> 'fm_vendor (' . lang('vendor') . ')',
+ 'fm_condition_survey' =>
'fm_condition_survey (' . lang('condition survey') . ')',
+ 'fm_ecodimb'
=> 'fm_ecodimb (' . lang('dimb') . ')',
+ 'fm_budget'
=> 'fm_budget (' . lang('budget') . ')',
+ 'fm_department'
=> 'fm_department (' . lang('department') . ')',
+ 'fm_eco_periodization_outline' =>
'fm_eco_periodization_outline (' . lang('periodization outline') . ')',
+ 'fm_eco_periodization' =>
'fm_eco_periodization (' . lang('periodization') . ')',
);
$location_types =
execMethod('property.soadmin_location.select_location_type');
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11664] report periodizations on paid invoices,
Sigurd Nes <=