[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property/inc/class.boinvoice.inc.php, 1.5
From: |
nomail |
Subject: |
[Phpgroupware-cvs] property/inc/class.boinvoice.inc.php, 1.5 |
Date: |
Thu, 12 Aug 2004 20:56:23 +0200 |
Update of /property/inc
Modified Files:
Branch:
class.boinvoice.inc.php
date: 2004/08/12 18:56:23; author: sigurdne; state: Exp; lines: +115 -9
Log Message:
no message
=====================================================================
Index: property/inc/class.boinvoice.inc.php
diff -u property/inc/class.boinvoice.inc.php:1.4
property/inc/class.boinvoice.inc.php:1.5
--- property/inc/class.boinvoice.inc.php:1.4 Thu Jul 29 13:08:46 2004
+++ property/inc/class.boinvoice.inc.php Thu Aug 12 18:56:23 2004
@@ -724,9 +724,9 @@
}
}
- function add($values)
+ function add($values,$debug='')
{
- $soXport =
CreateObject($this->currentapp.'.soXport');
+ $this->soXport =
CreateObject($this->currentapp.'.soXport');
if($values['loc1']=$values['location']['loc1'])
{
$values['dima']=implode('',$values['location']);
@@ -761,18 +761,82 @@
$values['kildeid'] = 1;
$values['kidnr'] =
$values['kid_nr'];
$values['typeid'] =
$values['type'];
-
if($soXport->check_pmwrkord_code(intval($values['order'])))
+ if($order_type =
$this->soXport->check_order(intval($values['order'])))
{
- $values['pmwrkord_code'] =
intval($values['order']);
+ if($order_type=='workorder')
+ {
+ $soworkorder =
CreateObject($this->currentapp.'.soworkorder');
+ $soproject =
CreateObject($this->currentapp.'.soproject');
+ $workorder =
$soworkorder->read_single($values['order']);
+ $project =
$soproject->read_single($workorder['project_id']);
+
+ $values['spvend_code'] =
$workorder['vendor_id'];
+ $values['spbudact_code'] =
$workorder['b_account_id'];
+ $values['location_code']
=$project['location_code'];
+ $values['dima']
=str_replace('-','',$project['location_code']);
+ $values['vendor_name'] =
$this->get_vendor_name($workorder['vendor_id']);
+ $values['pmwrkord_code'] =
intval($values['order']);
+
+ $values =
$this->set_responsible($values,$workorder['user_id'],$workorder['b_account_id']);
+
+ if($values['auto_tax'])
+ {
+ $values['mvakode'] =
$this->soXport->auto_tax($values['dima']);
+ }
+
+ $buffer[0]=$values;
+ }
+
+ if($order_type=='s_agreement')
+ {
+ $sos_agreement =
CreateObject($this->currentapp.'.sos_agreement');
+ $s_agreement =
$sos_agreement->read_single(array('s_agreement_id'=>$values['order']));
+
+ $values['spvend_code'] =
$s_agreement['vendor_id'];
+ $values['spbudact_code'] =
$s_agreement['b_account_id'];
+ $values['vendor_name'] =
$this->get_vendor_name($s_agreement['vendor_id']);
+ $values['pmwrkord_code'] =
intval($values['order']);
+ $values =
$this->set_responsible($values,$s_agreement['user_id'],$s_agreement['b_account_id']);
+
+
+ $s_agreement_detail =
$sos_agreement->read(array('allrows'=>True,'s_agreement_id'=>$values['order'],'detail'=>True));
+
+ $sum_agreement=0;
+ for
($i=0;$i<count($s_agreement_detail);$i++)
+ {
+ $sum_agreement = $sum_agreement
+ $s_agreement_detail[$i]['cost'];
+ }
+
+
+ for
($i=0;$i<count($s_agreement_detail);$i++)
+ {
+ $buffer[$i]=$values;
+
+ $buffer[$i]['location_code']
=$s_agreement_detail[$i]['location_code'];
+ $buffer[$i]['dima']
=str_replace('-','',$s_agreement_detail[$i]['location_code']);
+
+
+ $buffer[$i]['belop'] =
round($values['belop'] / $sum_agreement * $s_agreement_detail[$i]['cost'],2);
+ $buffer[$i]['godkjentbelop']
=$buffer[$i]['belop'];
+
+ if($values['auto_tax'])
+ {
+ $buffer[$i]['mvakode']
= $this->soXport->auto_tax($buffer[$i]['dima']);
+ }
+ }
+ }
+ }
+ else
+ {
+ $buffer[0]=$values;
}
- if($values['auto_tax'])
+ if($debug)
{
- $values['mvakode'] =
$soXport->auto_tax($values['dima']);
+ return $buffer;
}
- $buffer[0]=$values;
- if($soXport->add($buffer)>0)
+ if($this->soXport->add($buffer)>0)
{
$receipt['message'][] =
array('msg'=>lang('Invoice %1 is added',$values['bilagsnr']));
}
@@ -782,5 +846,47 @@
}
return $receipt;
}
+
+ function get_vendor_name($vendor_id='')
+ {
+ $contacts =
CreateObject($this->currentapp.'.soactor');
+ $contacts->role='vendor';
+
+ $vendor_data =
$contacts->read_single(array('actor_id'=>$vendor_id));
+ if(is_array($vendor_data))
+ {
+ foreach($vendor_data['attributes'] as
$attribute)
+ {
+ if($attribute['name']=='org_name')
+ {
+ return $attribute['value'];
+ }
+ }
+ }
+ }
+
+ function set_responsible($values,$user_id='',$b_account_id='')
+ {
+ if (!$values['budget_responsible'])
+ {
+ $values['budget_responsible'] =
$this->soXport->get_responsible($b_account_id);
+ $values['budsjettansvarligid'] =
$values['budget_responsible'];
+ }
+
+ $acl2 =
CreateObject($this->currentapp.'.acl2',$user_id);
+ if($acl2->check('.invoice',32) &&
!$acl2->check('.invoice',64)):
+ {
+ $values['janitor'] =
$GLOBALS['phpgw']->accounts->id2name($user_id);
+ $values['oppsynsmannid'] =
$values['janitor'];
+ }
+ elseif((!$acl2->check('.invoice',32) &&
$acl2->check('.invoice',64)) || ($acl2->check('.invoice',32) &&
$acl2->check('.invoice',64))):
+ {
+ $values['supervisor'] =
$GLOBALS['phpgw']->accounts->id2name($user_id);
+ $values['saksbehandlerid'] =
$values['supervisor'];
+ }
+ endif;
+
+ return $values;
+ }
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] property/inc/class.boinvoice.inc.php, 1.5,
nomail <=