[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [16239] more on integration
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [16239] more on integration |
Date: |
Thu, 2 Feb 2017 12:58:17 -0500 (EST) |
Revision: 16239
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16239
Author: sigurdne
Date: 2017-02-02 12:58:17 -0500 (Thu, 02 Feb 2017)
Log Message:
-----------
more on integration
Modified Paths:
--------------
trunk/property/inc/class.boworkorder.inc.php
trunk/property/inc/class.soXport.inc.php
trunk/property/inc/class.uiwo_hour.inc.php
trunk/property/inc/cron/default/Import_fra_agresso_X205_BK.php
trunk/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
trunk/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php
trunk/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php
trunk/property/templates/base/workorder.xsl
Modified: trunk/property/inc/class.boworkorder.inc.php
===================================================================
--- trunk/property/inc/class.boworkorder.inc.php 2017-02-02 15:54:04 UTC
(rev 16238)
+++ trunk/property/inc/class.boworkorder.inc.php 2017-02-02 17:58:17 UTC
(rev 16239)
@@ -1010,7 +1010,8 @@
public function receive_order( $id, $received_amount )
{
- $receive_order = true; // used as trigger within the
custom function
+ $transfer_action = 'receive_order'; // used as trigger
within the custom function
+
$acl_location = '.project.workorder.transfer';
$criteria = array(
Modified: trunk/property/inc/class.soXport.inc.php
===================================================================
--- trunk/property/inc/class.soXport.inc.php 2017-02-02 15:54:04 UTC (rev
16238)
+++ trunk/property/inc/class.soXport.inc.php 2017-02-02 17:58:17 UTC (rev
16239)
@@ -233,6 +233,11 @@
$this->voucher_id =
$fields['bilagsnr'];
}
+ if($fields['pmwrkord_code'])
+ {
+
phpgwapi_cache::system_clear('property',
"budget_order_{$fields['pmwrkord_code']}");
+ }
+
$values = array(
$fields['project_id'],
$fields['kostra_id'],
Modified: trunk/property/inc/class.uiwo_hour.inc.php
===================================================================
--- trunk/property/inc/class.uiwo_hour.inc.php 2017-02-02 15:54:04 UTC (rev
16238)
+++ trunk/property/inc/class.uiwo_hour.inc.php 2017-02-02 17:58:17 UTC (rev
16239)
@@ -1351,6 +1351,8 @@
'allrows' => true
);
+ $transfer_action = 'workorder'; // trigger for
transfer
+
$custom_functions =
$GLOBALS['phpgw']->custom_functions->find($criteria);
foreach ($custom_functions as $entry)
@@ -3412,6 +3414,8 @@
'allrows' => true
);
+ $transfer_action = 'workorder';
+
$custom_functions =
$GLOBALS['phpgw']->custom_functions->find($criteria);
foreach ($custom_functions as $entry)
Modified: trunk/property/inc/cron/default/Import_fra_agresso_X205_BK.php
===================================================================
--- trunk/property/inc/cron/default/Import_fra_agresso_X205_BK.php
2017-02-02 15:54:04 UTC (rev 16238)
+++ trunk/property/inc/cron/default/Import_fra_agresso_X205_BK.php
2017-02-02 17:58:17 UTC (rev 16239)
@@ -814,7 +814,8 @@
$sql = "SELECT
fm_workorder.location_code,"
. " fm_workorder.vendor_id,"
. " fm_workorder.account_id,"
- . " fm_project.ecodimb,"
+ . " fm_project.ecodimb as
project_ecodimb,"
+ . " fm_workorder.ecodimb,"
. " fm_workorder.category,"
. " fm_workorder.user_id,"
. " fm_workorder.title"
@@ -841,7 +842,8 @@
$order_info['vendor_id'] = $this->db->f('vendor_id');
$order_info['spbudact_code'] =
$this->db->f('account_id');
- $order_info['dimb'] = $this->db->f('ecodimb');
+ $ecodimb = $this->db->f('ecodimb');
+ $order_info['dimb'] = $ecodimb ? $ecodimb :
$this->db->f('project_ecodimb');
$order_info['dime'] = $this->db->f('category');
$order_info['title'] = $this->db->f('title', true);
Modified: trunk/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
===================================================================
--- trunk/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
2017-02-02 15:54:04 UTC (rev 16238)
+++ trunk/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
2017-02-02 17:58:17 UTC (rev 16239)
@@ -53,6 +53,7 @@
var $connection;
var $order_id;
var $voucher_type;
+ var $voucher_id;
var $batchid;
Modified:
trunk/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php
===================================================================
---
trunk/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php
2017-02-02 15:54:04 UTC (rev 16238)
+++
trunk/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php
2017-02-02 17:58:17 UTC (rev 16239)
@@ -35,201 +35,209 @@
*
* @author Sigurd Nes
*/
- if (isset($id) && $id && isset($acl_location) && $acl_location &&
isset($receive_order) && $receive_order)
- {
- $exporter_varemottak = new
lag_agresso_varemottak($acl_location, $id);
- $result = $exporter_varemottak->transfer($id, $received_amount);
- }
- class lag_agresso_varemottak
+ if (!class_exists("lag_agresso_varemottak"))
{
+ class lag_agresso_varemottak
+ {
- private $acl_location;
- private $values;
- private $ordered_amount = 1;
- var $debug = true;
+ private $acl_location;
+ private $values;
+ private $ordered_amount = 1;
+ var $debug = true;
- function __construct( $acl_location, $id )
- {
- switch ($acl_location)
+ function __construct( $acl_location, $id )
{
- case '.ticket':
- $this->acl_location = $acl_location;
- $this->values =
ExecMethod('property.sotts.read_single', $id);
- $this->ordered_amount =
$this->_get_ordered_ticket_amount($id);
- break;
- default:
- $this->acl_location =
'.project.workorder';
- $this->values =
ExecMethod('property.soworkorder.read_single', $id);
- $this->values['order_id'] = $id;
- $this->ordered_amount =
$this->_get_ordered_workorder_amount($id);
- break;
+ switch ($acl_location)
+ {
+ case '.ticket':
+ $this->acl_location =
$acl_location;
+ $this->values =
ExecMethod('property.sotts.read_single', $id);
+ $this->ordered_amount =
$this->_get_ordered_ticket_amount($id);
+ break;
+ default:
+ $this->acl_location =
'.project.workorder';
+ $this->values =
ExecMethod('property.soworkorder.read_single', $id);
+ $this->values['order_id'] = $id;
+ $this->ordered_amount =
$this->_get_ordered_workorder_amount($id);
+ break;
+ }
}
- }
- private function _get_ordered_ticket_amount($id)
- {
- $amount = 0;
- $budgets = ExecMethod('property.botts.get_budgets',$id);
- foreach ($budgets as $budget)
+ private function _get_ordered_ticket_amount($id)
{
+ $amount = 0;
+ $budgets =
ExecMethod('property.botts.get_budgets',$id);
+ foreach ($budgets as $budget)
+ {
- $amount += $budget['amount'];
+ $amount += $budget['amount'];
+ }
+ return $amount ? $amount : 1;
}
- return $amount ? $amount : 1;
- }
- private function _get_ordered_workorder_amount($id)
- {
- return
ExecMethod('property.boworkorder.get_budget_amount',$id);
- }
+ private function _get_ordered_workorder_amount($id)
+ {
+ return
ExecMethod('property.boworkorder.get_budget_amount',$id);
+ }
- public function transfer( $id, $received_amount )
- {
- $values = $this->values;
-// _debug_array($values);die();
+ public function transfer( $id, $received_amount )
+ {
+ $values = $this->values;
+ // _debug_array($values);die();
- /*
- P3: EBF Innkjøpsordre Portico : 45000000-45249999
- V3: EBF Varemotttak Portico : 45500000-45749999
- P4: EBE Innkjøpsordre Portico : 45250000-45499999
- V4: EBE Varemotttak Portico : 45750000-45999999
- */
+ /*
+ P3: EBF Innkjøpsordre Portico :
45000000-45249999
+ V3: EBF Varemotttak Portico :
45500000-45749999
+ P4: EBE Innkjøpsordre Portico :
45250000-45499999
+ V4: EBE Varemotttak Portico :
45750000-45999999
+ */
- $voucher_type = 'P4';
+ $voucher_type = 'P4';
- if($values['order_id'] >= 45000000 &&
$values['order_id'] <= 45249999)
- {
- $voucher_type = 'V3';
- }
- else if ($values['order_id'] >= 45250000 &&
$values['order_id'] <= 45499999)
- {
- $voucher_type = 'V4';
- }
- else
- {
- throw new Exception("Ordrenummer
'{$values['order_id']}' er utenfor serien:<br/>" . __FILE__ . '<br/>linje:' .
__LINE__);
- }
+ if($values['order_id'] >= 45000000 &&
$values['order_id'] <= 45249999)
+ {
+ $voucher_type = 'V3';
+ }
+ else if ($values['order_id'] >= 45250000 &&
$values['order_id'] <= 45499999)
+ {
+ $voucher_type = 'V4';
+ }
+ else
+ {
+ throw new Exception("Ordrenummer
'{$values['order_id']}' er utenfor serien:<br/>" . __FILE__ . '<br/>linje:' .
__LINE__);
+ }
- $param = array(
- 'voucher_type' => $voucher_type,
- 'order_id' => $values['order_id'],
- 'lines' => array(
- array(
- 'UnitCode' => 'STK',
- 'Quantity' =>
($received_amount/$this->ordered_amount),
+ $param = array(
+ 'voucher_type' => $voucher_type,
+ 'order_id' => $values['order_id'],
+ 'lines' => array(
+ array(
+ 'UnitCode' => 'STK',
+ 'Quantity' =>
($received_amount/$this->ordered_amount),
+ )
)
- )
- );
+ );
- $exporter_varemottak = new
BkBygg_exporter_varemottak_til_Agresso(array(
- 'order_id' => $values['order_id'],
- 'voucher_type' => $voucher_type
- ));
- $exporter_varemottak->create_transfer_xml($param);
+ $exporter_varemottak = new
BkBygg_exporter_varemottak_til_Agresso(array(
+ 'order_id' => $values['order_id'],
+ 'voucher_type' => $voucher_type
+ ));
+
$exporter_varemottak->create_transfer_xml($param);
- $export_ok =
$exporter_varemottak->transfer($this->debug);
- if ($export_ok)
- {
- $this->log_transfer( $id, $received_amount );
+ $export_ok =
$exporter_varemottak->transfer($this->debug);
+ if ($export_ok)
+ {
+ $this->log_transfer( $id,
$received_amount );
+ }
+ return $export_ok;
}
- return $export_ok;
- }
- private function log_transfer( $id, $received_amount )
- {
- $id = (int)$id;
- $received_amount = (int)$received_amount;
- switch ($this->acl_location)
+ private function log_transfer( $id, $received_amount )
{
- case '.ticket':
- $historylog =
CreateObject('property.historylog', 'tts');
- $table = 'fm_tts_tickets';
- break;
- default:
- $historylog =
CreateObject('property.historylog', 'workorder');
- $table = 'fm_workorder';
- break;
+ $id = (int)$id;
+ $received_amount = (int)$received_amount;
+ switch ($this->acl_location)
+ {
+ case '.ticket':
+ $historylog =
CreateObject('property.historylog', 'tts');
+ $table = 'fm_tts_tickets';
+ break;
+ default:
+ $historylog =
CreateObject('property.historylog', 'workorder');
+ $table = 'fm_workorder';
+ break;
+ }
+ $historylog->add('RM', $id, "Varemottak:
{$received_amount} overført til agresso");
+ $now = time();
+ $GLOBALS['phpgw']->db->query("UPDATE {$table}
SET order_received = {$now}, order_received_amount = {$received_amount} WHERE
id = {$id}");
}
- $historylog->add('RM', $id, "Varemottak:
{$received_amount} overført til agresso");
- $now = time();
- $GLOBALS['phpgw']->db->query("UPDATE {$table} SET
order_received = {$now}, order_received_amount = {$received_amount} WHERE id =
{$id}");
}
}
- class BkBygg_exporter_varemottak_til_Agresso extends
BkBygg_exporter_data_til_Agresso
+ if (!class_exists("BkBygg_exporter_varemottak_til_Agresso"))
{
+ class BkBygg_exporter_varemottak_til_Agresso extends
BkBygg_exporter_data_til_Agresso
+ {
- var $transfer_xml;
- var $connection;
- var $order_id;
- var $voucher_type;
- var $batch_id;
+ var $transfer_xml;
+ var $connection;
+ var $order_id;
+ var $voucher_type;
+ var $batch_id;
- public function __construct( $param )
- {
- parent::__construct($param);
- }
-
- public function create_transfer_xml( $param )
- {
- $Orders = array();
- $Detail = array();
- $i = 1;
- foreach ($param['lines'] as $line)
+ public function __construct( $param )
{
- $Detail[] = array(
- 'LineNo' => $i,
- 'Status' => 'N',
- 'UnitCode' => $line['UnitCode'],
- 'Quantity' => $line['Quantity'],
- );
- $i++;
+ parent::__construct($param);
}
- $Orders['Order'][] = array(
- 'OrderNo' => $param['order_id'],
- 'VoucherType' => $param['voucher_type'],
- 'TransType' => 51,
- 'Details' => array('Detail' => $Detail)
- );
+ public function create_transfer_xml( $param )
+ {
+ $Orders = array();
+ $Detail = array();
+ $i = 1;
+ foreach ($param['lines'] as $line)
+ {
+ $Detail[] = array(
+ 'LineNo' => $i,
+ 'Status' => 'N',
+ 'UnitCode' => $line['UnitCode'],
+ 'Quantity' => $line['Quantity'],
+ );
+ $i++;
+ }
-// _debug_array($Orders);
-// die();
+ $Orders['Order'][] = array(
+ 'OrderNo' => $param['order_id'],
+ 'VoucherType' => $param['voucher_type'],
+ 'TransType' => 51,
+ 'Details' => array('Detail' => $Detail)
+ );
- $root_attributes = array(
- 'Version' => "542",
- 'xmlns:xsi' =>
"http://www.w3.org/2001/XMLSchema-instance",
- 'xsi:noNamespaceSchemaLocation' =>
"http://services.agresso.com/schema/ABWOrder/2004/07/02/ABWOrder.xsd"
- );
- $xml_creator = new xml_creator('ABWOrder',
$root_attributes);
- $xml_creator->fromArray($Orders);
- $this->transfer_xml = $xml_creator->getDocument();
- return $this->transfer_xml;
- }
+ // _debug_array($Orders);
+ // die();
- protected function create_file_name( $ref = '' )
- {
- if (!$this->batchid)
- {
- throw new
Exception('BkBygg_exporter_data_til_Agresso::create_file_name() Mangler
referanse');
+ $root_attributes = array(
+ 'Version' => "542",
+ 'xmlns:xsi' =>
"http://www.w3.org/2001/XMLSchema-instance",
+ 'xsi:noNamespaceSchemaLocation' =>
"http://services.agresso.com/schema/ABWOrder/2004/07/02/ABWOrder.xsd"
+ );
+ $xml_creator = new xml_creator('ABWOrder',
$root_attributes);
+ $xml_creator->fromArray($Orders);
+ $this->transfer_xml =
$xml_creator->getDocument();
+ return $this->transfer_xml;
}
- $voucher_type = $this->voucher_type;
- if (!$voucher_type)
+
+ protected function create_file_name( $ref = '' )
{
- throw new
Exception('BkBygg_exporter_varemottak_til_Agresso::create_file_name() Mangler
bilagstype');
- }
+ if (!$this->batchid)
+ {
+ throw new
Exception('BkBygg_exporter_data_til_Agresso::create_file_name() Mangler
referanse');
+ }
+ $voucher_type = $this->voucher_type;
+ $order_id = $this->order_id;
+ if (!$voucher_type)
+ {
+ throw new
Exception('BkBygg_exporter_varemottak_til_Agresso::create_file_name() Mangler
bilagstype');
+ }
- $fil_katalog =
$this->config->config_data['export']['path'];
+ $fil_katalog =
$this->config->config_data['export']['path'];
- $filename =
"{$fil_katalog}/{$voucher_type}_varemottak_{$this->batchid}.xml";
+ $filename =
"{$fil_katalog}/{$voucher_type}_varemottak_{$order_id}_{$this->batchid}.xml";
- //Sjekk om filen eksisterer
- if (file_exists($filename))
- {
- unlink($filename);
+ //Sjekk om filen eksisterer
+ if (file_exists($filename))
+ {
+ unlink($filename);
+ }
+
+ return $filename;
}
+ }
+ }
- return $filename;
- }
- }
\ No newline at end of file
+ if (isset($id) && $id && isset($acl_location) && $acl_location &&
isset($transfer_action) && $transfer_action = 'receive_order')
+ {
+ $exporter_varemottak = new
lag_agresso_varemottak($acl_location, $id);
+ $result = $exporter_varemottak->transfer($id, $received_amount);
+ }
Modified:
trunk/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php
===================================================================
---
trunk/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php
2017-02-02 15:54:04 UTC (rev 16238)
+++
trunk/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php
2017-02-02 17:58:17 UTC (rev 16239)
@@ -330,7 +330,9 @@
}
}
// if (!$workorder['order_sent'])
+ if (!empty($transfer_action) && $transfer_action == 'workorder')
{
+
$exporter_ordre = new lag_agresso_ordre_fra_workorder();
try
{
Modified: trunk/property/templates/base/workorder.xsl
===================================================================
--- trunk/property/templates/base/workorder.xsl 2017-02-02 15:54:04 UTC (rev
16238)
+++ trunk/property/templates/base/workorder.xsl 2017-02-02 17:58:17 UTC (rev
16239)
@@ -1016,7 +1016,7 @@
</xsl:attribute>
</input>
</div>
- <xsl:choose>
+ <!--xsl:choose>
<xsl:when
test="value_workorder_id!='' and mode='edit'">
<div
class="pure-control-group">
<label
for="name">
@@ -1052,7 +1052,7 @@
<input
class="pure-custom" type="text" id="order_received_amount" size="6"/>
</div>
</xsl:when>
- </xsl:choose>
+ </xsl:choose-->
<xsl:choose>
<xsl:when
test="value_workorder_id!=''">
<div
class="pure-control-group">
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [16239] more on integration,
sigurdne <=