[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [9822] property: calculation
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [9822] property: calculation |
Date: |
Wed, 01 Aug 2012 14:03:34 +0000 |
Revision: 9822
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9822
Author: sigurdne
Date: 2012-08-01 14:03:34 +0000 (Wed, 01 Aug 2012)
Log Message:
-----------
property: calculation
Modified Paths:
--------------
trunk/property/inc/class.sobudget.inc.php
trunk/property/inc/class.solocation.inc.php
trunk/property/inc/class.soworkorder.inc.php
trunk/property/inc/class.uibudget.inc.php
trunk/property/setup/setup.inc.php
trunk/property/setup/tables_current.inc.php
trunk/property/setup/tables_update.inc.php
Modified: trunk/property/inc/class.sobudget.inc.php
===================================================================
--- trunk/property/inc/class.sobudget.inc.php 2012-08-01 07:32:59 UTC (rev
9821)
+++ trunk/property/inc/class.sobudget.inc.php 2012-08-01 14:03:34 UTC (rev
9822)
@@ -517,7 +517,7 @@
function read_obligations($data)
{
- //_debug_array($data);
+ //_debug_array($data);
$start = isset($data['start']) &&
$data['start'] ? $data['start'] : 0;
$filter = isset($data['filter']) ?
$data['filter'] : 'none';
$query = isset($data['query']) ?
$data['query'] : '';
@@ -546,10 +546,10 @@
$start_date = mktime(1, 1, 1, 1, 1, $year);
$end_date = mktime (23, 59, 59, 12, 31, $year);
-// $filtermethod .= " AND fm_workorder.start_date >=
$start_date AND fm_workorder.start_date <= $end_date";
- $filtermethod .= " AND fm_workorder_status.closed IS
NULL AND fm_workorder.start_date >= $start_date AND fm_workorder.start_date <=
$end_date";
+ $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";
- $where = 'WHERE';
+ $where = 'AND';
$cat_ids = array();
if ($cat_id > 0)
@@ -589,7 +589,7 @@
if($_department_dimb)
{
$filtermethod .= " $where fm_workorder.ecodimb
IN (" . implode(',', $_department_dimb) . ')';
- $where = 'AND';
+ $where = 'AND';
}
if ($grouping > 0)
@@ -604,6 +604,19 @@
$query = $this->db->db_addslashes($query);
}
*/
+ $config =
CreateObject('phpgwapi.config','property');
+ $config->read();
+
+ if(isset($config->config_data['location_at_workorder'])
&& $config->config_data['location_at_workorder'])
+ {
+ $_join_district = "{$this->join}
fm_locations ON fm_workorder.location_code = fm_locations.location_code"
+ . "
{$this->join} fm_location1 ON fm_location1.loc1 = fm_locations.loc1";
+ }
+ else
+ {
+ $_join_district = "{$this->join} fm_location1
ON fm_project.loc1 = fm_location1.loc1";
+ }
+
if( $details )
{
$b_account_field = 'id';
@@ -613,16 +626,17 @@
$b_account_field = 'category';
}
- $sql = "SELECT 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"
+ $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"
. " 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->join fm_location1 ON fm_project.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"
- . " $filtermethod $querymethod GROUP BY
fm_b_account.{$b_account_field},district_id,fm_workorder.ecodimb";
+ . " {$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"
+ . " {$_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";
- //_debug_array($sql);die();
+ //_debug_array($sql);
+ //die();
$this->db->query($sql . $ordermethod,__LINE__,__FILE__);
$sum_obligation_cost = 0;
@@ -631,11 +645,15 @@
while ($this->db->next_record())
{
$_combined_cost =
round($this->db->f('combined_cost'));
- $sum_obligation_cost += $_combined_cost;
$_hits = $this->db->f('hits');
$sum_hits += $_hits;
-
$obligations[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('ecodimb')]
+= $_combined_cost;
+ 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;
+ }
+
$hits[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('ecodimb')]
+= $_hits;
$accout_info[$this->db->f($b_account_field)] =
true;
$district[$this->db->f('district_id')] = true;
@@ -675,7 +693,7 @@
if($_department_dimb)
{
$filtermethod .= " $where
fm_tts_tickets.ecodimb IN (" . implode(',', $_department_dimb) . ')';
- $where = 'AND';
+ $where = 'AND';
}
if ($grouping > 0)
@@ -707,9 +725,9 @@
$district[$this->db->f('district_id')] = true;
$ecodimb[(int)$this->db->f('ecodimb')] = true;
}
+
//_debug_array($obligations);die();
-
$sql = "SELECT sum(budget) as budget,
count(fm_tts_tickets.id) as hits, fm_b_account.{$b_account_field} as
{$b_account_field}, district_id, fm_tts_tickets.ecodimb"
. " FROM fm_tts_tickets"
. " $this->join fm_b_account ON
fm_tts_tickets.b_account_id = fm_b_account.id "
@@ -743,7 +761,7 @@
$filtermethod = '';
$where = 'AND';
if ($grouping > 0)
- {
+ {
$filtermethod .= " $where
fm_b_account.category='$grouping' ";
/*
if (!$details)
@@ -779,7 +797,7 @@
if($_department_dimb)
{
$filtermethod .= " $where ecodimb IN (" .
implode(',', $_department_dimb) . ')';
- $where = 'AND';
+ $where = 'AND';
}
@@ -840,7 +858,7 @@
if($_department_dimb)
{
$filtermethod .= " $where dimb IN (" .
implode(',', $_department_dimb) . ')';
- $where = 'AND';
+ $where = 'AND';
}
@@ -853,17 +871,19 @@
{
$_taxcode[$this->db->f('id')] =
$this->db->f('percent');
}
-
+
+
//-------start check paid workorder-----------
- $sql = "SELECT fm_b_account.{$b_account_field} as
{$b_account_field}, district_id, sum(godkjentbelop) as actual_cost,dimb,mvakode"
+ $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_b_account.{$b_account_field},
district_id, dimb, mvakode";
+ . " 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);
@@ -872,18 +892,54 @@
//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')]
-= $_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_b_account.{$b_account_field} as
{$b_account_field}, district_id, sum(godkjentbelop) as actual_cost,dimb,mvakode"
+ $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"
@@ -891,7 +947,7 @@
. " {$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_b_account.{$b_account_field},
district_id, dimb, mvakode";
+ . " GROUP BY fm_workorder.id, combined_cost,
fm_b_account.{$b_account_field}, district_id, dimb, mvakode";
$this->db->query($sql,__LINE__,__FILE__);
@@ -900,8 +956,40 @@
//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')]
-= $_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;
@@ -936,7 +1024,7 @@
if($_department_dimb)
{
$filtermethod .= " $where
fm_s_agreement_budget.ecodimb IN (" . implode(',', $_department_dimb) . ')';
- $where = 'AND';
+ $where = 'AND';
}
$sql = "SELECT sum(budget) as budget,
count(fm_s_agreement.id) as hits, fm_b_account.{$b_account_field} as
{$b_account_field}, fm_s_agreement_budget.ecodimb"
@@ -981,7 +1069,7 @@
$_actual_cost =
round($this->db->f('actual_cost'));
$_account_value =
$this->db->f($b_account_field);
$_dimb = (int)$this->db->f('ecodimb');
-
+
$sum_actual_cost += $_actual_cost;
$actual_cost[$_account_value][$_dummy_district][$_dimb] += $_actual_cost;
$obligations[$_account_value][$_dummy_district][$_dimb] -= $_actual_cost;
@@ -1018,7 +1106,7 @@
if($_department_dimb)
{
$filtermethod .= " $where
fm_s_agreement_budget.ecodimb IN (" . implode(',', $_department_dimb) . ')';
- $where = 'AND';
+ $where = 'AND';
}
$sql = "SELECT fm_b_account.{$b_account_field} as
{$b_account_field}, sum(fm_ecobilag.godkjentbelop) as
actual_cost,fm_s_agreement_budget.ecodimb"
@@ -1036,7 +1124,7 @@
$_actual_cost =
round($this->db->f('actual_cost'));
$_account_value =
$this->db->f($b_account_field);
$_dimb = (int)$this->db->f('ecodimb');
-
+
$sum_actual_cost += $_actual_cost;
$actual_cost[$_account_value][$_dummy_district][$_dimb] += $_actual_cost;
$obligations[$_account_value][$_dummy_district][$_dimb] -= $_actual_cost;
@@ -1114,14 +1202,14 @@
//cramirez
if($this->total_records == 0)
{
- return $result;
+ return $result;
}
if(!$allrows)
{
$num_rows =
isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'])?intval($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']):15;
-
//_debug_array(array($start,$this->total_records,$this->total_records,$num_rows));
+
//_debug_array(array($start,$this->total_records,$this->total_records,$num_rows));
$page = ceil( ( $start / $this->total_records )
* ($this->total_records/ $num_rows) );
$out = array_chunk($result, $num_rows);
Modified: trunk/property/inc/class.solocation.inc.php
===================================================================
--- trunk/property/inc/class.solocation.inc.php 2012-08-01 07:32:59 UTC (rev
9821)
+++ trunk/property/inc/class.solocation.inc.php 2012-08-01 14:03:34 UTC (rev
9822)
@@ -1279,7 +1279,7 @@
//echo $sql;
$this->db->query($sql,__LINE__,__FILE__);
- $sql = "INSERT INTO fm_locations (level,
location_code) VALUES ({$type_id}, '{$location['location_code']}')";
+ $sql = "INSERT INTO fm_locations (level,
location_code, loc1) VALUES ({$type_id}, '{$location['location_code']}',
'{$location['loc1']}')";
$this->db->query($sql,__LINE__,__FILE__);
$this->db->transaction_commit();
@@ -1520,13 +1520,14 @@
$locations = array();
for ($i=1;$i<($levels+1);$i++)
{
- $this->db->query("SELECT
fm_location{$i}.location_code from fm_location{$i} $this->left_join
fm_locations ON fm_location{$i}.location_code = fm_locations.location_code
WHERE fm_locations.location_code IS NULL");
+ $this->db->query("SELECT
fm_location{$i}.location_code, loc1 FROM fm_location{$i} {$this->left_join}
fm_locations ON fm_location{$i}.location_code = fm_locations.location_code
WHERE fm_locations.location_code IS NULL");
while($this->db->next_record())
{
$locations[] = array
(
'level'
=> $i,
- 'location_code' =>
$this->db->f('location_code')
+ 'location_code' =>
$this->db->f('location_code'),
+ 'loc1'
=> $this->db->f('loc1')
);
}
}
@@ -1534,7 +1535,7 @@
$receipt = array();
foreach ($locations as $location)
{
- $this->db->query("INSERT INTO fm_locations
(level, location_code) VALUES ({$location['level']},
'{$location['location_code']}')");
+ $this->db->query("INSERT INTO fm_locations
(level, location_code, loc1) VALUES ({$location['level']},
'{$location['location_code']}', '{$location['loc1']}')");
$receipt['message'][]=array('msg'=>lang('location %1 added at level %2',
$location['location_code'], $location['level']));
}
Modified: trunk/property/inc/class.soworkorder.inc.php
===================================================================
--- trunk/property/inc/class.soworkorder.inc.php 2012-08-01 07:32:59 UTC
(rev 9821)
+++ trunk/property/inc/class.soworkorder.inc.php 2012-08-01 14:03:34 UTC
(rev 9822)
@@ -1536,5 +1536,41 @@
}
execMethod('property.soXport.update_actual_cost_from_archive',$orders);
+
+ $config = CreateObject('phpgwapi.config','property');
+ $config->read_repository();
+ $tax = 1+(($config->config_data['fm_tax'])/100);
+
+ foreach ($orders as $id => $dummy)
+ {
+ $this->db->query("SELECT combined_cost,
budget,calculation,contract_sum,addition FROM fm_workorder WHERE id =
{$id}",__LINE__,__FILE__);
+ $this->db->next_record();
+
+ $old_combined_cost =
$this->db->f('combined_cost');
+ $budget =
$this->db->f('budget');
+ $calculation =
$this->db->f('calculation');
+ $contract_sum =
$this->db->f('contract_sum');
+ $addition =
$this->db->f('addition');
+
+ if ( abs((int)$contract_sum) > 0)
+ {
+ $addition = 1 + ((int)$addition/100);
+ $combined_cost = (int)$contract_sum *
$addition;
+ }
+ else if (abs($calculation) > 0)
+ {
+ $combined_cost = $calculation * $tax;
+ }
+ else
+ {
+ $combined_cost = (int)$budget;
+ }
+
+ if($old_combined_cost != $combined_cost)
+ {
+
//_debug_array(array($old_combined_cost,$combined_cost));
+ $this->db->query("UPDATE fm_workorder
SET combined_cost = '{$combined_cost}' WHERE id = {$id}",__LINE__,__FILE__);
+ }
+ }
}
}
Modified: trunk/property/inc/class.uibudget.inc.php
===================================================================
--- trunk/property/inc/class.uibudget.inc.php 2012-08-01 07:32:59 UTC (rev
9821)
+++ trunk/property/inc/class.uibudget.inc.php 2012-08-01 14:03:34 UTC (rev
9822)
@@ -993,6 +993,7 @@
$datatable = array();
$values_combo_box = array();
+ $dry_run = false;
if( phpgw::get_var('phpgw_return_as') != 'json' )
{
@@ -1032,16 +1033,19 @@
array_unshift
($values_combo_box[1],$default_value);
$cat_filter =
$this->cats->formatted_xslt_list(array('select_name' => 'cat_id','selected' =>
$this->cat_id,'globals' => True,'link_data' => $link_data));
- $values_combo_box[2] = $cat_filter['cat_list'];
- $default_value = array
('cat_id'=>'','name'=>lang('no category'));
- array_unshift
($values_combo_box[2],$default_value);
-
- foreach($values_combo_box[2] as &$entry)
+ foreach($cat_filter['cat_list'] as $_cat)
{
- $entry['id'] = $entry['cat_id'];
+ $values_combo_box[2][] = array
+ (
+ 'id' => $_cat['cat_id'],
+ 'name' => $_cat['name'],
+ 'selected' => $_cat['selected']
? 1 : 0
+ );
}
+
+ array_unshift ($values_combo_box[2],array
('id'=>'', 'name'=>lang('no category')));
-//_debug_array($values_combo_box[2]);die();
+//_debug_array($values_combo_box[2]);
$values_combo_box[3] =
$this->bo->get_b_group_list($this->grouping);
$default_value = array
('id'=>'','name'=>lang('no grouping'));
@@ -1224,6 +1228,7 @@
)
)
);
+ $dry_run = true;
}
$uicols = array (
@@ -1262,17 +1267,28 @@
'col_name'=>'diff',
'visible'=>true, 'label'=>lang('difference'),'className'=>'rightClasss',
'sortable'=>false, 'sort_field'=>'',
'formatter'=>'')
);
- $location_list = array();
- $location_list = $this->bo->read_obligations();
+ //FIXME
+ if($dry_run)
+ {
+ $location_list = array();
+
+ }
+ else
+ {
+ $location_list = $this->bo->read_obligations();
+ }
+
+
//_debug_array($location_list);
+
$entry = $content = array();
$j = 0;
//cramirez: add this code because "mktime" functions
fire an error
if($this->year == "")
{
$today = getdate();
- $this->year = $today[year];
+ $this->year = $today['year'];
}
if (isset($location_list) && is_array($location_list))
Modified: trunk/property/setup/setup.inc.php
===================================================================
--- trunk/property/setup/setup.inc.php 2012-08-01 07:32:59 UTC (rev 9821)
+++ trunk/property/setup/setup.inc.php 2012-08-01 14:03:34 UTC (rev 9822)
@@ -12,7 +12,7 @@
*/
$setup_info['property']['name'] = 'property';
- $setup_info['property']['version'] = '0.9.17.649';
+ $setup_info['property']['version'] = '0.9.17.650';
$setup_info['property']['app_order'] = 8;
$setup_info['property']['enable'] = 1;
$setup_info['property']['app_group'] = 'office';
Modified: trunk/property/setup/tables_current.inc.php
===================================================================
--- trunk/property/setup/tables_current.inc.php 2012-08-01 07:32:59 UTC (rev
9821)
+++ trunk/property/setup/tables_current.inc.php 2012-08-01 14:03:34 UTC (rev
9822)
@@ -160,7 +160,8 @@
'fd' => array(
'id' => array('type' => 'auto','precision' =>
'4','nullable' => False),
'level' => array('type' => 'int','precision' =>
'4','nullable' => False),
- 'location_code' => array('type' =>
'varchar','precision' => '50','nullable' => False)
+ 'location_code' => array('type' =>
'varchar','precision' => '50','nullable' => False),
+ 'loc1' => array('type' => 'varchar','precision'
=> '6','nullable' => False)
),
'pk' => array('id'),
'fk' => array(),
Modified: trunk/property/setup/tables_update.inc.php
===================================================================
--- trunk/property/setup/tables_update.inc.php 2012-08-01 07:32:59 UTC (rev
9821)
+++ trunk/property/setup/tables_update.inc.php 2012-08-01 14:03:34 UTC (rev
9822)
@@ -6514,9 +6514,10 @@
return $GLOBALS['setup_info']['property']['currentver'];
}
}
+
/**
* Update property version from 0.9.17.648 to 0.9.17.649
- * Update values
+ * Enable periodization of budget at project
*/
$test[] = '0.9.17.648';
function property_upgrade0_9_17_648()
@@ -6603,4 +6604,55 @@
$GLOBALS['setup_info']['property']['currentver'] =
'0.9.17.649';
return $GLOBALS['setup_info']['property']['currentver'];
}
+ }
+ /**
+ * Update property version from 0.9.17.649 to 0.9.17.650
+ * Enable join to locations on loc1
+ */
+ $test[] = '0.9.17.649';
+ function property_upgrade0_9_17_649()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_locations','loc1',array(
+ 'type' => 'varchar',
+ 'precision' => 6,
+ 'nullable' => true
+ )
+ );
+
+
+ $sql = 'SELECT id, location_code FROM fm_locations';
+ $GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+
+ $locations = array();
+ while ($GLOBALS['phpgw_setup']->oProc->next_record())
+ {
+ $location_arr = explode('-',
$GLOBALS['phpgw_setup']->oProc->f('location_code'));
+ $locations[] = array
+ (
+ 'id' =>
$GLOBALS['phpgw_setup']->oProc->f('id'),
+ 'loc1' => $location_arr[0]
+ );
+ }
+
+ foreach ($locations as $location)
+ {
+ $sql = "UPDATE fm_locations SET loc1 =
'{$location['loc1']}' WHERE id = {$location['id']}";
+
$GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+ }
+
+
$GLOBALS['phpgw_setup']->oProc->AlterColumn('fm_locations','loc1',array(
+ 'type' => 'varchar',
+ 'precision' => 6,
+ 'nullable' => false
+ )
+ );
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['property']['currentver'] =
'0.9.17.650';
+ return $GLOBALS['setup_info']['property']['currentver'];
+ }
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [9822] property: calculation,
Sigurd Nes <=