[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11015] property: budget handling
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11015] property: budget handling |
Date: |
Sun, 24 Mar 2013 18:17:04 +0000 |
Revision: 11015
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11015
Author: sigurdne
Date: 2013-03-24 18:17:03 +0000 (Sun, 24 Mar 2013)
Log Message:
-----------
property: budget handling
Modified Paths:
--------------
trunk/property/inc/class.soinvoice.inc.php
trunk/property/inc/class.soproject.inc.php
trunk/property/inc/class.soworkorder.inc.php
trunk/property/inc/class.uibudget.inc.php
trunk/property/inc/class.uiproject.inc.php
trunk/property/inc/class.uiworkorder.inc.php
trunk/property/js/portico/ajax_project_edit.js
trunk/property/js/yahoo/budget.index.js
trunk/property/templates/base/workorder.xsl
Modified: trunk/property/inc/class.soinvoice.inc.php
===================================================================
--- trunk/property/inc/class.soinvoice.inc.php 2013-03-22 14:33:08 UTC (rev
11014)
+++ trunk/property/inc/class.soinvoice.inc.php 2013-03-24 18:17:03 UTC (rev
11015)
@@ -515,6 +515,7 @@
$order = isset($data['order']) ?
$data['order'] : '';
$voucher_id = isset($data['voucher_id']) &&
$data['voucher_id'] ? (int)$data['voucher_id'] : 0;
$paid = isset($data['paid']) ? $data['paid']
: '';
+ $year = isset($data['year']) ? $data['year']
: '';
$project_id = isset($data['project_id']) &&
$data['project_id'] ? (int)$data['project_id'] : 0;
$order_id = isset($data['order_id']) &&
$data['order_id'] ? $data['order_id'] : 0 ;//might be bigint
@@ -562,12 +563,18 @@
$where = 'AND';
}
+ if ($year)
+ {
+ $filtermethod .= " {$where} ({$table}.periode >
{$year}00 AND {$table}.periode < {$year}13)";
+ $where = 'AND';
+ }
+
$groupmethod = "GROUP BY
pmwrkord_code,bilagsnr,bilagsnr_ut,fakturanr,"
. "
currency,budsjettansvarligid,org_name,periode";
$sql = "SELECT DISTINCT
pmwrkord_code,bilagsnr,bilagsnr_ut,fakturanr,sum(belop) as belop,
sum(godkjentbelop) as godkjentbelop,"
. "
currency,budsjettansvarligid,org_name,periode"
- . " FROM $table"
+ . " FROM {$table}"
. " {$this->join} fm_ecoart ON fm_ecoart.id =
$table.artid"
. " {$this->join} fm_workorder ON
fm_workorder.id = $table.pmwrkord_code"
. " {$this->join} fm_project ON
fm_workorder.project_id = fm_project.id"
Modified: trunk/property/inc/class.soproject.inc.php
===================================================================
--- trunk/property/inc/class.soproject.inc.php 2013-03-22 14:33:08 UTC (rev
11014)
+++ trunk/property/inc/class.soproject.inc.php 2013-03-24 18:17:03 UTC (rev
11015)
@@ -2328,21 +2328,30 @@
$entry['year'] = substr( $entry['period'], 0, 4
);
$month = substr( $entry['period'], 4, 2 );
$entry['month'] = $month == '00' ? '' : $month;
- if($active_period[$entry['period']])
+
+ // if($active_period[$entry['period']])
+ if($closed_period[$entry['period']])
{
$_diff_start = abs($entry['budget']) >
0 ? $entry['budget'] : $entry['sum_orders'];
$entry['diff'] = $_diff_start -
$entry['sum_oblications'] - $entry['actual_cost'];
+
+ $_deviation = $entry['budget'] -
$entry['actual_cost'];
+ // $deviation = abs($entry['actual_cost'])
> 0 ? $_deviation : 0;
+ $deviation = $_deviation;
+
+
}
else
{
$entry['diff'] = 0;
+ $deviation = 0;
}
- $_deviation = $entry['budget'] -
$entry['actual_cost'];
- $deviation = abs($entry['actual_cost']) > 0 ?
$_deviation : 0;
+
$entry['deviation_period'] = $deviation;
$budget_acc +=$entry['budget'];
- if($active_period[$entry['period']])
+ // if($active_period[$entry['period']])
+ if($closed_period[$entry['period']])
{
$deviation_acc += $deviation;
}
Modified: trunk/property/inc/class.soworkorder.inc.php
===================================================================
--- trunk/property/inc/class.soworkorder.inc.php 2013-03-22 14:33:08 UTC
(rev 11014)
+++ trunk/property/inc/class.soworkorder.inc.php 2013-03-24 18:17:03 UTC
(rev 11015)
@@ -1715,11 +1715,12 @@
'month' =>
(int)$this->db->f('month'),
'actual_cost' => 0, //for
now..
'closed_order' =>
(int)$this->db->f('closed'),
+ 'active_period' =>
(int)$this->db->f('active'),
);
$active_period[$period] =
$this->db->f('active');
}
-
+//_debug_array($order_budget);die();
foreach ($order_budget as $period => $_budget)
{
$this->db->query("SELECT closed FROM
fm_workorder"
@@ -1786,6 +1787,7 @@
$_current_period = date('Ym');
$_delay_period_sum = 0;
$_delay_period = false;
+
foreach ($order_budget as $period => $_budget)
{
$_sum_orders = 0;
@@ -1796,8 +1798,10 @@
//_debug_array( $test+= $_budget['actual_cost']);
$_sum_orders += $_budget['combined_cost'];
- if(!$_budget['closed_order'])
+ if(!$_budget['closed_order'])// &&
$active_period[$period])
{
+ if($active_period[$period])
+ {
$_sum_oblications +=
$_budget['combined_cost'];
$_sum_oblications -=
$_budget['actual_cost'];
@@ -1816,6 +1820,7 @@
$_sum_oblications = 0;
}
}
+ }
}
/*
@@ -1851,6 +1856,7 @@
'month'
=> $_budget['month'] > 0 ? sprintf("%02s", $_budget['month']) : '',
'period'
=> $period,
'budget'
=> $_budget['budget'],
+ 'combined_cost' =>
$_budget['combined_cost'],
'sum_orders' =>
$_sum_orders,
'sum_oblications' =>
$_sum_oblications,
'actual_cost' =>
$_actual_cost,
@@ -1870,21 +1876,28 @@
$budget_acc = 0;
foreach ($values as &$entry)
{
- if($active_period[$entry['period']])
+ // if($active_period[$entry['period']])
+ if($closed_period[$entry['period']])
{
$_diff_start = abs($entry['budget']) >
0 ? $entry['budget'] : $entry['sum_orders'];
$entry['diff'] = $_diff_start -
$entry['sum_oblications'] - $entry['actual_cost'];
+
+ $_deviation = $entry['budget'] -
$entry['actual_cost'];
+ // $deviation = abs($entry['actual_cost'])
> 0 ? $_deviation : 0;
+ $deviation = $_deviation;
+
}
else
{
$entry['diff'] = 0;
+ $deviation = 0;
}
- $_deviation = $entry['budget'] -
$entry['actual_cost'];
- $deviation = abs($entry['actual_cost']) > 0 ?
$_deviation : 0;
+
$entry['deviation_period'] = $deviation;
$budget_acc +=$entry['budget'];
- if($active_period[$entry['period']])
+ // if($active_period[$entry['period']])
+ if($closed_period[$entry['period']])
{
$deviation_acc += $deviation;
}
Modified: trunk/property/inc/class.uibudget.inc.php
===================================================================
--- trunk/property/inc/class.uibudget.inc.php 2013-03-22 14:33:08 UTC (rev
11014)
+++ trunk/property/inc/class.uibudget.inc.php 2013-03-24 18:17:03 UTC (rev
11015)
@@ -188,14 +188,28 @@
$values_combo_box[3][] = $default_value;
}
- $values_combo_box[4] =
$this->cats->formatted_xslt_list(array('format'=>'filter','selected' =>
$this->cat_id,'globals' => True));
- $default_value = array ('cat_id'=>'','name'=>
lang('no category'));
- array_unshift
($values_combo_box[4]['cat_list'],$default_value);
+ $cat_filter =
$this->cats->formatted_xslt_list(array('select_name' => 'cat_id','selected' =>
$this->cat_id,'globals' => True,'link_data' => $link_data));
+ foreach($cat_filter['cat_list'] as $_cat)
+ {
+ $values_combo_box[4][] = array
+ (
+ 'id' => $_cat['cat_id'],
+ 'name' => $_cat['name'],
+ 'selected' => $_cat['selected']
? 1 : 0
+ );
+ }
+
+ array_unshift ($values_combo_box[4],array
('id'=>'', 'name'=>lang('no category')));
$values_combo_box[5] =
$this->bocommon->select_category_list(array('type'=>'dimb'));
+ foreach($values_combo_box[5] as & $_dimb)
+ {
+ $_dimb['name'] =
"{$_dimb['id']}-{$_dimb['name']}";
+ }
$default_value = array
('id'=>'','name'=>lang('no dimb'));
array_unshift
($values_combo_box[5],$default_value);
+
$datatable['actions']['form'] = array
(
array
@@ -247,21 +261,26 @@
'tab_index' => 4
),
array
- ( //boton
GROUPING
- 'id'
=> 'btn_cat_id',
- 'name'
=> 'cat_id',
- 'value'
=> lang('category'),
- 'type'
=> 'button',
- 'style'
=> 'filter',
+ ( //boton
USER
+ //
'id' => 'btn_user_id',
+ 'id' =>
'sel_cat_id',
+ 'name'
=> 'cat_id',
+ 'value'
=> lang('Category'),
+ 'type'
=> 'select',
+ 'style'
=> 'filter',
+
'values' => $values_combo_box[4],
+
'onchange'=> 'onChangeSelect("cat_id");',
'tab_index' => 5
),
array
- ( //boton
GROUPING
- 'id'
=> 'btn_dimb_id',
- 'name'
=> 'dimb_id',
- 'value'
=> lang('dimb'),
- 'type'
=> 'button',
- 'style'
=> 'filter',
+ (
+ 'id' =>
'sel_dimb_id',
+ 'name'
=> 'dimb_id',
+ 'value'
=> lang('dimb'),
+ 'type'
=> 'select',
+ 'style'
=> 'filter',
+
'values' => $values_combo_box[5],
+
'onchange'=> 'onChangeSelect("dimb_id");',
'tab_index' => 6
),
array
@@ -320,6 +339,7 @@
'id' =>
'values_combo_box_3',
'value'
=> $this->bocommon->select2String($values_combo_box[3])
),
+/*
array
( //div values
combo_box_4
'id' =>
'values_combo_box_4',
@@ -330,6 +350,7 @@
'id' =>
'values_combo_box_5',
'value'
=> $this->bocommon->select2String($values_combo_box[5])
)
+*/
)
)
)
Modified: trunk/property/inc/class.uiproject.inc.php
===================================================================
--- trunk/property/inc/class.uiproject.inc.php 2013-03-22 14:33:08 UTC (rev
11014)
+++ trunk/property/inc/class.uiproject.inc.php 2013-03-24 18:17:03 UTC (rev
11015)
@@ -68,7 +68,8 @@
'bulk_update_status' => true,
'project_group' => true,
'view_file' => true,
- 'get_orders' => true
+ 'get_orders' => true,
+ 'get_vouchers' => true
);
function property_uiproject()
@@ -1945,40 +1946,13 @@
$invoices = array();
+ $content_invoice = array();
+
if ($id)
{
- $active_invoices =
execMethod('property.soinvoice.read_invoice_sub_sum', array('project_id' =>
$id));
- $historical_invoices =
execMethod('property.soinvoice.read_invoice_sub_sum', array('project_id' =>
$id, 'paid' => true));
- $invoices =
array_merge($active_invoices,$historical_invoices);
+ $content_invoice = $this->get_vouchers($id,
date('Y'));
}
- $content_invoice = array();
- foreach($invoices as $entry)
- {
- $content_invoice[] = array
- (
- 'voucher_id' =>
$entry['transfer_time'] ? -1*$entry['voucher_id'] : $entry['voucher_id'],
- 'voucher_out_id' =>
$entry['voucher_out_id'],
- 'workorder_id' =>
$entry['workorder_id'],
- 'status'
=> $entry['status'],
- 'period'
=> $entry['period'],
- 'invoice_id' =>
$entry['invoice_id'],
- 'budget_account' =>
$entry['budget_account'],
- 'dima'
=> $entry['dima'],
- 'dimb'
=> $entry['dimb'],
- 'dimd'
=> $entry['dimd'],
- 'type'
=> $entry['type'],
- 'amount'
=> $entry['amount'],
- 'approved_amount' =>
$entry['approved_amount'],
- 'vendor'
=> $entry['vendor'],
- 'project_group' =>
$entry['project_id'],
- 'currency'
=> $entry['currency'],
- 'budget_responsible' =>
$entry['budget_responsible'],
- 'budsjettsigndato' =>
$entry['budsjettsigndato'] ?
$GLOBALS['phpgw']->common->show_date(strtotime($entry['budsjettsigndato']),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'])
: '',
- 'transfer_time' =>
$entry['transfer_time'] ?
$GLOBALS['phpgw']->common->show_date(strtotime($entry['transfer_time']),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'])
: '',
- );
- }
-
$datavalues[2] = array
(
'name'
=> "2",
@@ -1998,18 +1972,18 @@
(
'name' => "2",
'values' =>
json_encode(array( array('key' =>
'workorder_id','label'=>lang('Workorder'),'sortable'=>true,'resizeable'=>true,'formatter'=>'YAHOO.widget.DataTable.formatLink'),
-
array('key' =>
'voucher_id','label'=>lang('bilagsnr'),'sortable'=>false,'resizeable'=>true,'formatter'=>$_formatter_voucher_link),
+
array('key' =>
'voucher_id','label'=>lang('bilagsnr'),'sortable'=>true,'resizeable'=>true,'formatter'=>$_formatter_voucher_link),
array('key' => 'voucher_out_id','hidden'=>true),
array('key' =>
'invoice_id','label'=>lang('invoice
number'),'sortable'=>false,'resizeable'=>true),
array('key' =>
'vendor','label'=>lang('vendor'),'sortable'=>false,'resizeable'=>true),
-
array('key' =>
'amount','label'=>lang('amount'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterRight'),
-
array('key' =>
'approved_amount','label'=>lang('approved
amount'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterRight'),
-
array('key' =>
'period','label'=>lang('period'),'sortable'=>false,'resizeable'=>true),
+
array('key' =>
'amount','label'=>lang('amount'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount2'),
+
array('key' =>
'approved_amount','label'=>lang('approved
amount'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount2'),
+
array('key' =>
'period','label'=>lang('period'),'sortable'=>true,'resizeable'=>true),
array('key' =>
'currency','label'=>lang('currency'),'sortable'=>false,'resizeable'=>true),
-
array('key' =>
'type','label'=>lang('type'),'sortable'=>false,'resizeable'=>true),
-
array('key' =>
'budget_responsible','label'=>lang('budget
responsible'),'sortable'=>false,'resizeable'=>true),
-
array('key' =>
'budsjettsigndato','label'=>lang('budsjettsigndato'),'sortable'=>false,'resizeable'=>true),
-
array('key' =>
'transfer_time','label'=>lang('transfer
time'),'sortable'=>false,'resizeable'=>true),
+
array('key' =>
'type','label'=>lang('type'),'sortable'=>true,'resizeable'=>true),
+
array('key' =>
'budget_responsible','label'=>lang('budget
responsible'),'sortable'=>true,'resizeable'=>true),
+
array('key' =>
'budsjettsigndato','label'=>lang('budsjettsigndato'),'sortable'=>true,'resizeable'=>true),
+
array('key' =>
'transfer_time','label'=>lang('transfer
time'),'sortable'=>true,'resizeable'=>true),
))
);
@@ -2388,6 +2362,62 @@
return $content;
}
+ public function get_vouchers($project_id = 0, $year = 0)
+ {
+ if(!$project_id)
+ {
+ $project_id = phpgw::get_var('project_id',
'int');
+ }
+ if(!$year)
+ {
+ $year = phpgw::get_var('year', 'int');
+ }
+
+ $active_invoices =
execMethod('property.soinvoice.read_invoice_sub_sum', array('project_id' =>
$project_id, 'year' => $year));
+ $historical_invoices =
execMethod('property.soinvoice.read_invoice_sub_sum', array('project_id' =>
$project_id, 'year' => $year, 'paid' => true));
+ $invoices =
array_merge($active_invoices,$historical_invoices);
+
+ foreach($invoices as $entry)
+ {
+ $content[] = array
+ (
+ 'voucher_id' =>
$entry['transfer_time'] ? -1*$entry['voucher_id'] : $entry['voucher_id'],
+ 'voucher_out_id' =>
$entry['voucher_out_id'],
+ 'workorder_id' =>
$entry['workorder_id'],
+ 'status'
=> $entry['status'],
+ 'period'
=> $entry['period'],
+ 'invoice_id' =>
$entry['invoice_id'],
+ 'budget_account' =>
$entry['budget_account'],
+ 'dima'
=> $entry['dima'],
+ 'dimb'
=> $entry['dimb'],
+ 'dimd'
=> $entry['dimd'],
+ 'type'
=> $entry['type'],
+ 'amount'
=> $entry['amount'],
+ 'approved_amount' =>
$entry['approved_amount'],
+ 'vendor'
=> $entry['vendor'],
+ 'project_group' =>
$entry['project_id'],
+ 'currency'
=> $entry['currency'],
+ 'budget_responsible' =>
$entry['budget_responsible'],
+ 'budsjettsigndato' =>
$entry['budsjettsigndato'] ?
$GLOBALS['phpgw']->common->show_date(strtotime($entry['budsjettsigndato']),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'])
: '',
+ 'transfer_time' =>
$entry['transfer_time'] ?
$GLOBALS['phpgw']->common->show_date(strtotime($entry['transfer_time']),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'])
: '',
+ );
+ }
+
+ if( phpgw::get_var('phpgw_return_as') == 'json' )
+ {
+
+ if(count($content))
+ {
+ return json_encode($content);
+ }
+ else
+ {
+ return "";
+ }
+ }
+ return $content;
+ }
+
function delete()
{
if(!$this->acl_delete)
Modified: trunk/property/inc/class.uiworkorder.inc.php
===================================================================
--- trunk/property/inc/class.uiworkorder.inc.php 2013-03-22 14:33:08 UTC
(rev 11014)
+++ trunk/property/inc/class.uiworkorder.inc.php 2013-03-24 18:17:03 UTC
(rev 11015)
@@ -1843,6 +1843,20 @@
$lang_close = lang('Check to close period');
$lang_active = lang('Check to activate period');
+ $rows_per_page = 10;
+ $initial_page = 1;
+
+ if($content_budget && $project['periodization_id'])
+ {
+ $_year_count = array();
+ foreach ($content_budget as $key => $row)
+ {
+ $_year_count[$row['year']] +=1;
+ $rows_per_page =
$_year_count[$row['year']];
+ }
+ $initial_page =
floor(count($content_budget)/$rows_per_page);
+ }
+
foreach($content_budget as & $b_entry)
{
$checked = $b_entry['active'] ?
'checked="checked"' : '';
@@ -1864,6 +1878,8 @@
'total_records' =>
count($content_budget),
'edit_action' => "''",
'is_paginator' => 1,
+ 'rows_per_page' =>
$rows_per_page,
+ 'initial_page' =>
$initial_page,
'footer'
=> 0
);
Modified: trunk/property/js/portico/ajax_project_edit.js
===================================================================
--- trunk/property/js/portico/ajax_project_edit.js 2013-03-22 14:33:08 UTC
(rev 11014)
+++ trunk/property/js/portico/ajax_project_edit.js 2013-03-24 18:17:03 UTC
(rev 11015)
@@ -27,8 +27,10 @@
$("#order_time_span").change(function(){
var oArgs = {menuaction:'property.uiproject.get_orders',
project_id:project_id, year:$(this).val()};
- var requestUrl = phpGWLink('index.php', oArgs, true);
+// var requestUrl = phpGWLink('index.php', oArgs, true);
execute_async(myDataTable_1, oArgs);
+ oArgs = {menuaction:'property.uiproject.get_vouchers',
project_id:project_id, year:$(this).val()};
+ execute_async(myDataTable_2, oArgs);
});
});
Modified: trunk/property/js/yahoo/budget.index.js
===================================================================
--- trunk/property/js/yahoo/budget.index.js 2013-03-22 14:33:08 UTC (rev
11014)
+++ trunk/property/js/yahoo/budget.index.js 2013-03-24 18:17:03 UTC (rev
11015)
@@ -8,9 +8,9 @@
{order:0, var_URL:'year',
name:'btn_year', style:'',dependiente:[1,3]},
{order:1, var_URL:'revision', name:'btn_revision',
style:'',dependiente:[]},
{order:2, var_URL:'district_id', name:'btn_district_id',
style:'',dependiente:[]},
- {order:3, var_URL:'grouping', name:'btn_grouping',
style:'',dependiente:[]},
- {order:4, var_URL:'cat_id',
name:'btn_cat_id', style:'',dependiente:[]},
- {order:5, var_URL:'dimb_id', name:'btn_dimb_id',
style:'',dependiente:[]}
+ {order:3, var_URL:'grouping', name:'btn_grouping',
style:'',dependiente:[]}
+// {order:4, var_URL:'cat_id',
name:'btn_cat_id', style:'',dependiente:[]},
+// {order:5, var_URL:'dimb_id', name:'btn_dimb_id',
style:'',dependiente:[]}
]
// define buttons
@@ -40,6 +40,22 @@
}
var tableYUI;
+
+ this.onChangeSelect = function(type)
+ {
+ var myselect=document.getElementById("sel_"+ type);
+ for (var i=0; i<myselect.options.length; i++)
+ {
+ if (myselect.options[i].selected==true)
+ {
+ break;
+ }
+ }
+ eval("path_values." +type
+"='"+myselect.options[i].value+"'");
+ execute_ds();
+ }
+
+
/********************************************************************************/
var myFormatDate = function(elCell, oRecord, oColumn, oData)
{
Modified: trunk/property/templates/base/workorder.xsl
===================================================================
--- trunk/property/templates/base/workorder.xsl 2013-03-22 14:33:08 UTC (rev
11014)
+++ trunk/property/templates/base/workorder.xsl 2013-03-24 18:17:03 UTC (rev
11015)
@@ -884,6 +884,12 @@
total_records: <xsl:value-of select="total_records"/>,
edit_action: <xsl:value-of select="edit_action"/>,
is_paginator: <xsl:value-of select="is_paginator"/>,
+ <xsl:if
test="rows_per_page">
+
rows_per_page: "<xsl:value-of select="rows_per_page"/>",
+
</xsl:if>
+ <xsl:if
test="initial_page">
+
initial_page: "<xsl:value-of select="initial_page"/>",
+
</xsl:if>
footer:<xsl:value-of select="footer"/>
}
]
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11015] property: budget handling,
Sigurd Nes <=