[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [8589] property: forward vouchers
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [8589] property: forward vouchers |
Date: |
Mon, 16 Jan 2012 14:57:43 +0000 |
Revision: 8589
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8589
Author: sigurdne
Date: 2012-01-16 14:57:42 +0000 (Mon, 16 Jan 2012)
Log Message:
-----------
property: forward vouchers
Modified Paths:
--------------
trunk/property/inc/class.soinvoice.inc.php
trunk/property/inc/class.soworkorder.inc.php
trunk/property/inc/class.uiinvoice.inc.php
trunk/property/templates/base/invoice.xsl
Modified: trunk/property/inc/class.soinvoice.inc.php
===================================================================
--- trunk/property/inc/class.soinvoice.inc.php 2012-01-16 12:18:18 UTC (rev
8588)
+++ trunk/property/inc/class.soinvoice.inc.php 2012-01-16 14:57:42 UTC (rev
8589)
@@ -718,14 +718,14 @@
foreach ($update_paid_percent as $workorder_id
=> $paid_percent)
{
$paid_percent = (int) $paid_percent;
- $GLOBALS['phpgw']->db->query("UPDATE
fm_workorder set paid_percent={$paid_percent} WHERE id= $workorder_id");
+ $GLOBALS['phpgw']->db->query("UPDATE
fm_workorder set paid_percent={$paid_percent} WHERE id= '$workorder_id'");
- $this->db->query("SELECT type FROM
fm_orders WHERE id={$workorder_id}",__LINE__,__FILE__);
+ $this->db->query("SELECT type FROM
fm_orders WHERE id='{$workorder_id}'",__LINE__,__FILE__);
$this->db->next_record();
switch ( $this->db->f('type') )
{
case 'workorder':
- $this->db->query("SELECT
project_id FROM fm_workorder WHERE id={$workorder_id}",__LINE__,__FILE__);
+ $this->db->query("SELECT
project_id FROM fm_workorder WHERE id='{$workorder_id}'",__LINE__,__FILE__);
$this->db->next_record();
$project_id =
$this->db->f('project_id');
$workorder->update_planned_cost($project_id);
@@ -879,12 +879,14 @@
function check_count($voucher_id)
{
- $this->db->query("select count(dima) as dima_count ,
count(spbudact_code) as spbudact_code_count from fm_ecobilag where bilagsnr
='$voucher_id'");
+ $this->db->query("SELECT count(id) as invoice_count,
count(dima) as dima_count, count(spbudact_code) as spbudact_code_count FROM
fm_ecobilag WHERE bilagsnr ='$voucher_id'");
$this->db->next_record();
- $check_count=array(
+ $check_count = array
+ (
'dima_count' =>
$this->db->f('dima_count'),
- 'spbudact_code_count' =>
$this->db->f('spbudact_code_count')
+ 'spbudact_code_count' =>
$this->db->f('spbudact_code_count'),
+ 'invoice_count' =>
$this->db->f('invoice_count'),
);
$this->db->query("select count(kostra_id) as
kostra_count from fm_ecobilag where bilagsnr ='$voucher_id' and kostra_id >
0");
@@ -1508,8 +1510,43 @@
*/
public function forward($data)
{
+ $receipt = array();
+ $local_error= false;
if(isset($data['forward']) &&
is_array($data['forward']) && isset($data['voucher_id']) && $data['voucher_id'])
{
+ //start check
+ $check_count =
$this->check_count($data['voucher_id']);
+
+ if (!($check_count['dima_count'] ==
$check_count['invoice_count']))
+ {
+ $receipt['error'][] =
array('msg'=>lang('Dima is missing from sub invoice in:'). "
".$data['voucher_id']);
+ $local_error= true;
+ }
+
+ if (!($check_count['spbudact_code_count'] ==
$check_count['invoice_count']))
+ {
+ $receipt['error'][] =
array('msg'=>lang('Budget code is missing from sub invoice in :'). "
".$data['voucher_id']);
+ $local_error= true;
+ }
+
+ if (!($check_count['kostra_count'] ==
$check_count['invoice_count']))
+ {
+ $receipt['error'][] =
array('msg'=>'Tjenestekode mangler for undebilag: ' . " ".$data['voucher_id']);
+ $local_error= true;
+ }
+
+ if ($this->check_claim($data['voucher_id']))
+ {
+ $receipt['error'][] =
array('msg'=>lang('Tenant claim is not issued for project in voucher
%1',$data['voucher_id']));
+ $local_error= true;
+ }
+
+ if($local_error)
+ {
+ return $receipt;
+ }
+ // end check
+
$value_set = array();
foreach ($data['forward'] as $role => $user_lid)
Modified: trunk/property/inc/class.soworkorder.inc.php
===================================================================
--- trunk/property/inc/class.soworkorder.inc.php 2012-01-16 12:18:18 UTC
(rev 8588)
+++ trunk/property/inc/class.soworkorder.inc.php 2012-01-16 14:57:42 UTC
(rev 8589)
@@ -1236,4 +1236,40 @@
return $values;
}
+
+ public function close_orders($orders)
+ {
+ $config =
CreateObject('phpgwapi.config','property');
+ $config->read();
+ $closed =
isset($config->config_data['workorder_closed_status']) &&
$config->config_data['workorder_closed_status'] ?
$config->config_data['workorder_closed_status'] : 'closed';
+ $this->db->transaction_begin();
+
+ if ($orders && is_array($orders))
+ {
+ $historylog_workorder =
CreateObject('property.historylog','workorder');
+
+ foreach ($orders as $id)
+ {
+ $this->db->query("SELECT type FROM
fm_orders WHERE id='{$id}'",__LINE__,__FILE__);
+ $this->db->next_record();
+ switch ( $this->db->f('type') )
+ {
+ case 'workorder':
+
$historylog_workorder->add($entry,$id,$closed);
+
$GLOBALS['phpgw']->db->query("UPDATE fm_workorder SET status='{$closed}' WHERE
id = '{$id}'");
+
$GLOBALS['phpgw']->db->query("UPDATE fm_workorder SET paid_percent=100 WHERE
id= '{$id}'");
+ $receipt['message'][] =
array('msg'=>lang('Workorder %1 is %2',$id, $closed));
+
$this->db->query("SELECT project_id FROM fm_workorder WHERE
id='{$id}'",__LINE__,__FILE__);
+
$this->db->next_record();
+ $project_id =
$this->db->f('project_id');
+
$this->update_planned_cost($project_id);
+ break;
+ }
+ }
+ }
+
+ $GLOBALS['phpgw']->db->transaction_commit();
+
+ return $receipt;
+ }
}
Modified: trunk/property/inc/class.uiinvoice.inc.php
===================================================================
--- trunk/property/inc/class.uiinvoice.inc.php 2012-01-16 12:18:18 UTC (rev
8588)
+++ trunk/property/inc/class.uiinvoice.inc.php 2012-01-16 14:57:42 UTC (rev
8589)
@@ -3747,19 +3747,34 @@
if (!$receipt['error'])
{
- $redirect = true;
$values['voucher_id'] = $voucher_id;
- $line = $this->bo->forward($values);
+ $receipt = $this->bo->forward($values);
+ if(!$receipt['error'])
+ {
+
execMethod('property.soworkorder.close_orders',phpgw::get_var('orders'));
+ $redirect = true;
+ }
}
}
$voucher = $this->bo->read_single_voucher($voucher_id);
$orders = array();
+ $_orders = array();
foreach ($voucher as $line)
{
- $orders[] = $line['order_id'];
+ if($line['order_id'])
+ {
+ $_orders[] = $line['order_id'];
+ }
}
+
+ $_orders = array_unique($_orders);
+ foreach ($_orders as $_order)
+ {
+ $orders[] = array('id' => $_order);
+ }
+
$approved_list = array();
$approved_list[] = array
@@ -3847,7 +3862,7 @@
'sign_orig'
=> $sign_orig,
'my_initials' =>
$my_initials,
'project_group_data' =>
$project_group_data,
- 'orders'
=> implode('</br>', $orders),
+ 'orders'
=> $orders,
'value_amount' =>
$line['amount'],
'value_currency' =>
$line['currency'],
'value_process_log' =>
isset($values['process_log']) && $values['process_log'] ?
$values['process_log'] : $line['process_log']
Modified: trunk/property/templates/base/invoice.xsl
===================================================================
--- trunk/property/templates/base/invoice.xsl 2012-01-16 12:18:18 UTC (rev
8588)
+++ trunk/property/templates/base/invoice.xsl 2012-01-16 14:57:42 UTC (rev
8589)
@@ -1566,7 +1566,7 @@
<xsl:choose>
<xsl:when test="msgbox_data != ''">
<tr>
- <td align="left"
colspan="2">
+ <td align="left"
colspan="3">
<xsl:call-template name="msgbox"/>
</td>
</tr>
@@ -1621,10 +1621,23 @@
<td class="th_text" align="left"
valign="top" >
<xsl:value-of
select="php:function('lang', 'order id')"/>
</td>
- <td align="left" class="th_text"
valign="top">
- <xsl:value-of
disable-output-escaping="yes" select="orders"/>
+ <td align="left" class="th_text"
valign="top" colspan = '2'>
+ <xsl:value-of
select="php:function('lang', 'close')"/>
+ <table>
+ <xsl:for-each
select="orders">
+ <tr>
+ <td
class="th_text" align="left" valign="top" >
+
<xsl:value-of select="id"/>
+ </td>
+ <td
align="left" class="th_text" valign="top">
+
<input type="checkbox" name="orders[]" value="{id}" checked="checked"/>
+ </td>
+ </tr>
+ </xsl:for-each>
+ </table>
</td>
- </tr> </table>
+ </tr>
+ </table>
</form>
</xsl:template>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [8589] property: forward vouchers,
Sigurd Nes <=