[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [16141] Stable: Merge 16131:16140 from trunk
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [16141] Stable: Merge 16131:16140 from trunk |
Date: |
Wed, 4 Jan 2017 13:47:01 +0000 (UTC) |
Revision: 16141
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16141
Author: sigurdne
Date: 2017-01-04 13:47:01 +0000 (Wed, 04 Jan 2017)
Log Message:
-----------
Stable: Merge 16131:16140 from trunk
Modified Paths:
--------------
branches/Version-2_0-branch/property/inc/class.soproject.inc.php
branches/Version-2_0-branch/property/inc/class.uiwo_hour.inc.php
branches/Version-2_0-branch/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
branches/Version-2_0-branch/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php
Property Changed:
----------------
branches/Version-2_0-branch/
Property changes on: branches/Version-2_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/dev-syncromind:13653
/branches/dev-syncromind-2:14933-16129
/branches/stavangerkommune:12743-12875,12986
/trunk:14721-14732,14734-14735,14737,14739,14741,14743-14744,14746-14749,14751,14753,14755-14757,14759,14761-14764,14766-14768,14770-14783,14785-14792,14794-14813,14815-14816,14818,14820-14822,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842,14844-14845,14847,14849-14866,14868-14869,14871,14873-14875,14877-14878,14880-14884,14886-14896,14898,14900-14902,14904,14906-14909,14911-14915,14917-14919,14921-14922,14924-14978,14980-15258,15260-15261,15263-15264,15266-15285,15287-15288,15290-15291,15293,15295,15297,15299-15305,15307-15310,15312-15335,15337-15352,15354,15356,15358,15360-15541,15543-15566,15568-15569,15571,15573-15581,15583,15585-15617,15619,15621-15630,15632-15635,15637-15639,15641-15643,15645,15647-15665,15667-15668,15670-15671,15673-15693,15695-15712,15714-15764,15766-15767,15769-15787,15789-15802,15804-15811,15813-15814,15816-15818,15820-15849,15851-15887,15889-15900,15902-16046,16048-16051,16053,16055,16057-16063,16065-16071,16073-16077,16079-16081,16083-16099,16101-16130
+ /branches/dev-syncromind:13653
/branches/dev-syncromind-2:14933-16129
/branches/stavangerkommune:12743-12875,12986
/trunk:14721-14732,14734-14735,14737,14739,14741,14743-14744,14746-14749,14751,14753,14755-14757,14759,14761-14764,14766-14768,14770-14783,14785-14792,14794-14813,14815-14816,14818,14820-14822,14824-14825,14827-14829,14831-14834,14836,14838,14840-14842,14844-14845,14847,14849-14866,14868-14869,14871,14873-14875,14877-14878,14880-14884,14886-14896,14898,14900-14902,14904,14906-14909,14911-14915,14917-14919,14921-14922,14924-14978,14980-15258,15260-15261,15263-15264,15266-15285,15287-15288,15290-15291,15293,15295,15297,15299-15305,15307-15310,15312-15335,15337-15352,15354,15356,15358,15360-15541,15543-15566,15568-15569,15571,15573-15581,15583,15585-15617,15619,15621-15630,15632-15635,15637-15639,15641-15643,15645,15647-15665,15667-15668,15670-15671,15673-15693,15695-15712,15714-15764,15766-15767,15769-15787,15789-15802,15804-15811,15813-15814,15816-15818,15820-15849,15851-15887,15889-15900,15902-16046,16048-16051,16053,16055,16057-16063,16065-16071,16073-16077,16079-16081,16083-16099,16101-16130,16132-16140
Modified: branches/Version-2_0-branch/property/inc/class.soproject.inc.php
===================================================================
--- branches/Version-2_0-branch/property/inc/class.soproject.inc.php
2017-01-04 13:41:49 UTC (rev 16140)
+++ branches/Version-2_0-branch/property/inc/class.soproject.inc.php
2017-01-04 13:47:01 UTC (rev 16141)
@@ -879,7 +879,8 @@
{
$project = array
(
- 'project_id' => $this->db->f('id'),
+ 'id' => $project_id,
+ 'project_id' =>
$this->db->f('id'),//consider this one
'project_type_id' =>
$this->db->f('project_type_id'),
'title' => $this->db->f('title'),
'name' => $this->db->f('name'),
Modified: branches/Version-2_0-branch/property/inc/class.uiwo_hour.inc.php
===================================================================
--- branches/Version-2_0-branch/property/inc/class.uiwo_hour.inc.php
2017-01-04 13:41:49 UTC (rev 16140)
+++ branches/Version-2_0-branch/property/inc/class.uiwo_hour.inc.php
2017-01-04 13:47:01 UTC (rev 16141)
@@ -59,6 +59,7 @@
'edit_deviation' => true,
'pdf_order' => true,
'import_calculation' => true,
+ 'send_all_orders' => true
);
function __construct()
@@ -1332,7 +1333,7 @@
}
else
{
-
if(!$this->_validate_purchase_grant($workorder_id, $project['ecodimb'] ?
$project['ecodimb'] : $workorder['ecodimb']))
+
if(!$this->_validate_purchase_grant($workorder_id, $project['ecodimb'] ?
$project['ecodimb'] : $workorder['ecodimb'], $project['id']))
{
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'property.uiwo_hour.view',
'workorder_id' =>
$workorder_id, 'from' => phpgw::get_var('from')));
@@ -3341,12 +3342,76 @@
return $result;
}
+
+ function send_all_orders( )
+ {
+ if(!$this->acl->check('.admin', PHPGW_ACL_ADD,
'property'))
+ {
+ phpgw::no_access();
+ }
+
+ $start_from = 45000000;
+ $sql = "SELECT id FROM fm_workorder WHERE id >=
$start_from";
+ $db = & $GLOBALS['phpgw']->db;
+ $db->query($sql, __LINE__, __FILE__);
+ $ids = array();
+ while ($db->next_record())
+ {
+ $ids[] = $db->f('id');
+ }
+
+ foreach ($ids as $workorder_id)
+ {
+ try
+ {
+ $this->send_order( $workorder_id );
+ }
+ catch (Exception $e)
+ {
+
phpgwapi_cache::message_set($e->getMessage(), 'error');
+ }
+ }
+ }
+
function send_order( $workorder_id )
{
$workorder =
$this->boworkorder->read_single($workorder_id);
$show_cost = false;
$email_receipt = true;
- $pdfcode = $this->pdf_order($workorder_id, $show_cost);
+
+ try
+ {
+ $pdfcode = $this->pdf_order($workorder_id,
$show_cost);
+ }
+ catch (Exception $e)
+ {
+ phpgwapi_cache::message_set($e->getMessage(),
'error');
+ }
+
+ $criteria = array
+ (
+ 'appname' => 'property',
+ 'location' => '.project.workorder.transfer',
+ 'allrows' => true
+ );
+
+ $custom_functions =
$GLOBALS['phpgw']->custom_functions->find($criteria);
+
+ foreach ($custom_functions as $entry)
+ {
+ // prevent path traversal
+ if (preg_match('/\.\./', $entry['file_name']))
+ {
+ continue;
+ }
+
+ $file = PHPGW_SERVER_ROOT .
"/property/inc/custom/{$GLOBALS['phpgw_info']['user']['domain']}/{$entry['file_name']}";
+ if ($entry['active'] && is_file($file) &&
!$entry['client_side'] && !$entry['pre_commit'])
+ {
+ require $file;
+ }
+ }
+
$dir =
"{$GLOBALS['phpgw_info']['server']['temp_dir']}/pdf_files";
$attachments = array();
Modified:
branches/Version-2_0-branch/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
===================================================================
---
branches/Version-2_0-branch/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
2017-01-04 13:41:49 UTC (rev 16140)
+++
branches/Version-2_0-branch/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
2017-01-04 13:47:01 UTC (rev 16141)
@@ -37,434 +37,440 @@
*
* @author Sigurd Nes
*/
- class BkBygg_exporter_data_til_Agresso
+ if (!class_exists("BkBygg_exporter_data_til_Agresso"))
{
+ class BkBygg_exporter_data_til_Agresso
+ {
- var $dim0; // Art
- var $dim1; // Ansvar
- var $dim2; // Tjeneste
- var $dim3; // Objekt
- var $dim4; // Kontrakt - frivillig
- var $dim5; // Prosjekt
- var $dim6; // Aktivitet - frivillig
- var $transfer_xml;
- var $connection;
- var $order_id;
- var $voucher_type;
- var $batchid;
+ var $dim0; // Art
+ var $dim1; // Ansvar
+ var $dim2; // Tjeneste
+ var $dim3; // Objekt
+ var $dim4; // Kontrakt - frivillig
+ var $dim5; // Prosjekt
+ var $dim6; // Aktivitet - frivillig
+ var $transfer_xml;
+ var $connection;
+ var $order_id;
+ var $voucher_type;
+ var $batchid;
- public function __construct( $param )
- {
- $this->db = & $GLOBALS['phpgw']->db;
- $this->soXport = CreateObject('property.soXport');
- $this->config = CreateObject('admin.soconfig',
$GLOBALS['phpgw']->locations->get_id('property', '.invoice'));
- $this->order_id = $param['order_id'];
- $this->voucher_type = $param['voucher_type'];
- }
+ public function __construct( $param )
+ {
+ $this->db = & $GLOBALS['phpgw']->db;
+ $this->soXport =
CreateObject('property.soXport');
+ $this->config = CreateObject('admin.soconfig',
$GLOBALS['phpgw']->locations->get_id('property', '.invoice'));
+ $this->order_id = $param['order_id'];
+ $this->voucher_type = $param['voucher_type'];
+ }
- public function create_transfer_xml( $param )
- {
- $Orders = array();
- /*
- UN-kodene i Agresso ligger med prefiks UN- foran
koden.
- Eks: UN-70111601: Plantetjenester
- */
+ public function create_transfer_xml( $param )
+ {
+ $Orders = array();
+ /*
+ UN-kodene i Agresso ligger med prefiks UN-
foran koden.
+ Eks: UN-70111601: Plantetjenester
+ */
- $Seller = array(
- 'Name' => $param['vendor_name'],
- 'AddressInfo' => array(
- array(
- 'Address' =>
$param['vendor_address']
- )
- ),
- 'SellerNo' => $param['vendor_id'],
-// 'SellerReferences' => array(
-// array(
-// 'SalesMan' => 12573,
-// )
-// )
- );
+ $Seller = array(
+ 'Name' => $param['vendor_name'],
+ 'AddressInfo' => array(
+ array(
+ 'Address' =>
$param['vendor_address']
+ )
+ ),
+ 'SellerNo' => $param['vendor_id'],
+ // 'SellerReferences' => array(
+ // array(
+ // 'SalesMan' => 12573,
+ // )
+ // )
+ );
- $DetailInfo = array();
-// $DetailInfo[] = array(
-// 'TaxCode' => $param['tax_code'] // Moms kode
-// );
- $DetailInfo[] = array(
- 'ReferenceCode' => array(
- 'Code' => 'A0',
- 'Value' => $param['dim0'] // Art
- )
- );
- $DetailInfo[] = array(
- 'ReferenceCode' => array(
- 'Code' => 'C1',
- 'Value' => sprintf("%06s",
$param['dim1']) // Ansvar
- )
- );
- $DetailInfo[] = array(
- 'ReferenceCode' => array(
- 'Code' => 'Q0',
- 'Value' => $param['dim2'] // Tjeneste
- )
- );
- $DetailInfo[] = array(
- 'ReferenceCode' => array(
- 'Code' => 'F0',
- 'Value' => $param['dim3'] // Objekt
- )
- );
- $DetailInfo[] = array(
- 'ReferenceCode' => array(
- 'Code' => 'A7',
- 'Value' => $param['dim4'] // Kontrakt
- )
- );
- $DetailInfo[] = array(
- 'ReferenceCode' => array(
- 'Code' => 'B0',
- 'Value' => $param['dim5'] ?
$param['dim5'] : 9 // Prosjekt
- )
- );
- $DetailInfo[] = array(
- 'ReferenceCode' => array(
- 'Code' => 'B1',
- 'Value' => $param['dim6'] // Aktivitet
- )
- );
+ $DetailInfo = array();
+ $DetailInfo[] = array(
+ 'TaxCode' => $param['tax_code'] // Moms
kode
+ );
+ $DetailInfo[] = array(
+ 'ReferenceCode' => array(
+ 'Code' => 'A0',
+ 'Value' => $param['dim0'] // Art
+ )
+ );
+ $DetailInfo[] = array(
+ 'ReferenceCode' => array(
+ 'Code' => 'C1',
+ 'Value' => sprintf("%06s",
$param['dim1']) // Ansvar
+ )
+ );
+ $DetailInfo[] = array(
+ 'ReferenceCode' => array(
+ 'Code' => 'Q0',
+ 'Value' => $param['dim2'] //
Tjeneste
+ )
+ );
+ $DetailInfo[] = array(
+ 'ReferenceCode' => array(
+ 'Code' => 'F0',
+ 'Value' => $param['dim3'] //
Objekt
+ )
+ );
+ $DetailInfo[] = array(
+ 'ReferenceCode' => array(
+ 'Code' => 'A7',
+ 'Value' => $param['dim4'] //
Kontrakt
+ )
+ );
+ $DetailInfo[] = array(
+ 'ReferenceCode' => array(
+ 'Code' => 'B0',
+ 'Value' => $param['dim5'] ?
$param['dim5'] : 9 // Prosjekt
+ )
+ );
+ $DetailInfo[] = array(
+ 'ReferenceCode' => array(
+ 'Code' => 'B1',
+ 'Value' => $param['dim6'] //
Aktivitet
+ )
+ );
- $DetailInfo[] = array(
- 'ReferenceCode' => array(
- 'Code' => 'A1',
- 'Value' => $param['tax_code'] // Moms
kode
- )
- );
+ $DetailInfo[] = array(
+ 'ReferenceCode' => array(
+ 'Code' => 'A1',
+ 'Value' => $param['tax_code']
// Moms kode
+ )
+ );
- $Header = array(
- 'AcceptFlag' => 1,
- 'OrderType]' => 'WB',
- 'Status' => 'N',
- 'OrderDate' => date('Y-m-d'),
- 'Currency' => 'NOK',
- 'Seller' => array($Seller),
- 'Buyer' => array($param['buyer']),
- $DetailInfo
- );
-
- $Detail = array();
- $i = 1;
- foreach ($param['lines'] as $line)
- {
-
- $Detail[] = array(
- 'LineNo' => $i,
+ $Header = array(
+ 'AcceptFlag' => 1,
+ 'OrderType]' => 'WB',
'Status' => 'N',
- 'BuyerProductCode' =>
$line['unspsc_code'], //74000176, //UN-kode
- 'BuyerProductDescr' => $line['descr'],
//'Kopipapir',
- 'UnitCode' => 'STK',
- 'Quantity' => 1,
- 'Price' =>
number_format($line['price'], 2, '.', ''),
- 'LineTotal'=>
number_format($line['price'], 2, '.', ''),
- 'DetailInfo' => $DetailInfo
+ 'OrderDate' => date('Y-m-d'),
+ 'Currency' => 'NOK',
+ 'Seller' => array($Seller),
+ 'Buyer' => array($param['buyer']),
+ $DetailInfo
);
- $i++;
- }
+ $Detail = array();
+ $i = 1;
+ foreach ($param['lines'] as $line)
+ {
+ $Detail[] = array(
+ 'LineNo' => $i,
+ 'Status' => 'N',
+ 'BuyerProductCode' =>
$line['unspsc_code'], //74000176, //UN-kode
+ 'BuyerProductDescr' =>
$line['descr'], //'Kopipapir',
+ 'UnitCode' => 'STK',
+ 'Quantity' => 1,
+ 'Price' =>
number_format($line['price'], 2, '.', ''),
+ 'LineTotal'=>
number_format($line['price'], 2, '.', ''),
+ 'DetailInfo' => $DetailInfo
+ );
- $Orders['Order'][] = array(
- 'OrderNo' => $param['order_id'],
- 'VoucherType' => $this->voucher_type,
- 'TransType' => 41,
- 'Header' => array($Header),
- 'Details' => array('Detail' => $Detail)
- );
+ $i++;
+ }
-// _debug_array($Orders);
-// die();
- $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;
- // $xml_creator->output();
- // die();
- }
+ $Orders['Order'][] = array(
+ 'OrderNo' => $param['order_id'],
+ 'VoucherType' => $this->voucher_type,
+ 'TransType' => 41,
+ 'Header' => array($Header),
+ 'Details' => array('Detail' => $Detail)
+ );
- /**
- * Output the content of a current xml document.
- * @access public
- * @param null
- */
- public function output()
- {
- header('Content-type: text/xml');
- echo $this->transfer_xml;
- }
+ // _debug_array($Orders);
+ // die();
-
- protected function create_file_name( $ref = '' )
- {
- if (!$ref)
- {
- 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;
+ // $xml_creator->output();
+ // die();
}
- $voucher_type = $this->voucher_type;
- if (!$voucher_type)
- {
- throw new
Exception('BkBygg_exporter_data_til_Agresso::create_file_name() Mangler
bilagstype');
- }
- $fil_katalog =
$this->config->config_data['export']['path'];
- $filename =
"{$fil_katalog}/{$voucher_type}_ordre_{$ref}.xml";
-
- //Sjekk om filen eksisterer
- if (file_exists($filename))
+ /**
+ * Output the content of a current xml document.
+ * @access public
+ * @param null
+ */
+ public function output()
{
- unlink($filename);
+ header('Content-type: text/xml');
+ echo $this->transfer_xml;
}
- return $filename;
- }
- public function transfer( )
- {
- $batchid = $this->soXport->increment_batchid();
- $this->batchid = $batchid;
- $filename = $this->create_file_name($this->order_id);
- $content = $this->transfer_xml;
- $debug =
empty($this->config->config_data['export']['activate_transfer']) ? true : false;
-
- if(!empty($this->config->config_data['export']['path'])
&& is_dir($this->config->config_data['export']['path'])) // keep a copy
+ protected function create_file_name( $ref = '' )
{
- $file_written = false;
- $fp = fopen($filename, "wb");
- fwrite($fp, $content);
-
- if (fclose($fp))
+ if (!$ref)
{
- $file_written = true;
+ throw new
Exception('BkBygg_exporter_data_til_Agresso::create_file_name() Mangler
referanse');
}
- else
+ $voucher_type = $this->voucher_type;
+ if (!$voucher_type)
{
- phpgwapi_cache::message_set("$filename
feilet", 'error');
+ throw new
Exception('BkBygg_exporter_data_til_Agresso::create_file_name() Mangler
bilagstype');
}
+ $fil_katalog =
$this->config->config_data['export']['path'];
+
+ $filename =
"{$fil_katalog}/{$voucher_type}_ordre_{$ref}.xml";
+
+ //Sjekk om filen eksisterer
+ if (file_exists($filename))
+ {
+ unlink($filename);
+ }
+
+ return $filename;
}
- $transfer_ok = false;
- if (!$debug &&
($this->config->config_data['common']['method'] == 'ftp' ||
$this->config->config_data['common']['method'] == 'ssh'))
+ public function transfer( )
{
- $this->db->transaction_begin();
+ $batchid = $this->soXport->increment_batchid();
+ $this->batchid = $batchid;
+ $filename =
$this->create_file_name($this->order_id);
+ $content = $this->transfer_xml;
+ $debug =
empty($this->config->config_data['export']['activate_transfer']) ? true : false;
- if (!$connection = $this->connection)
+
if(!empty($this->config->config_data['export']['path']) &&
is_dir($this->config->config_data['export']['path'])) // keep a copy
{
- $connection = $this->phpftp_connect();
- }
+ $file_written = false;
+ $fp = fopen($filename, "wb");
+ fwrite($fp, $content);
- $basedir =
$this->config->config_data['export']['remote_basedir'];
- if ($basedir)
- {
- $remote_file = $basedir . '/' .
basename($filename);
+ if (fclose($fp))
+ {
+ $file_written = true;
+ }
+ else
+ {
+
phpgwapi_cache::message_set("$filename feilet", 'error');
+ }
}
- else
- {
- $remote_file = basename($filename);
- }
- switch
($this->config->config_data['common']['method'])
+ $transfer_ok = false;
+ if (!$debug &&
($this->config->config_data['common']['method'] == 'ftp' ||
$this->config->config_data['common']['method'] == 'ssh'))
{
- case 'ftp';
- $tmp = tmpfile();
- fwrite($tmp, $content);
- rewind($tmp);
- $transfer_ok =
ftp_fput($connection, $remote_file, $tmp, FTP_BINARY);
- fclose($tmp);
- // $transfer_ok =
ftp_put($connection, $remote_file, $filename, FTP_BINARY);
- break;
- case 'ssh';
- $sftp = ssh2_sftp($connection);
- $stream =
@fopen("ssh2.sftp://$sftp$remote_file", 'w');
- fwrite($stream, $content);
- $transfer_ok = @fclose($stream);
- break;
- default:
- $transfer_ok = false;
- }
- if ($transfer_ok)
- {
-
$this->soXport->log_transaction($batchid, $this->order_id, lang('transferred
Order %1 to Agresso', basename($filename)));
- $this->db->transaction_commit(); //
Reverse the batch_id - increment
- }
- else
- {
- $this->db->transaction_abort();
-
$this->soXport->log_transaction($batchid, $this->order_id, lang('Failed to
transfere Order %1 to Agresso', basename($filename)));
- // @unlink($filename);
- }
- }
- else
- {
- $transfer_ok = true;
+ $this->db->transaction_begin();
-// $GLOBALS['phpgw_info']['flags']['noheader'] =
true;
-// $GLOBALS['phpgw_info']['flags']['nofooter'] =
true;
-// $GLOBALS['phpgw_info']['flags']['xslt_app'] =
false;
-// $size = strlen($content);
-// $browser = CreateObject('phpgwapi.browser');
-// $browser->content_header(basename($filename),
'', $size);
-// echo $content;
- }
- return $transfer_ok;
- }
+ if (!$connection = $this->connection)
+ {
+ $connection =
$this->phpftp_connect();
+ }
- function phpftp_connect()
- {
- $server = $this->config->config_data['common']['host'];
- $user = $this->config->config_data['common']['user'];
- $password =
$this->config->config_data['common']['password'];
- $port = 22;
-
- switch ($this->config->config_data['common']['method'])
- {
- case 'ftp';
- if ($connection = ftp_connect($server))
+ $basedir =
$this->config->config_data['export']['remote_basedir'];
+ if ($basedir)
{
- ftp_login($connection, $user,
$password);
+ $remote_file = $basedir . '/' .
basename($filename);
}
- break;
- case 'ssh';
- if (!function_exists("ssh2_connect"))
+ else
{
- die("function ssh2_connect
doesn't exist");
+ $remote_file =
basename($filename);
}
- if (!($connection =
ssh2_connect("$server", $port)))
+
+ switch
($this->config->config_data['common']['method'])
{
- $message = "fail: unable to
establish connection";
- _debug_array($message);
- //$receipt['error'][]=
array('msg' => $message);
+ case 'ftp';
+ $tmp = tmpfile();
+ fwrite($tmp, $content);
+ rewind($tmp);
+ $transfer_ok =
ftp_fput($connection, $remote_file, $tmp, FTP_BINARY);
+ fclose($tmp);
+ // $transfer_ok =
ftp_put($connection, $remote_file, $filename, FTP_BINARY);
+ break;
+ case 'ssh';
+ $sftp =
ssh2_sftp($connection);
+ $stream =
@fopen("ssh2.sftp://$sftp$remote_file", 'w');
+ fwrite($stream,
$content);
+ $transfer_ok =
@fclose($stream);
+ break;
+ default:
+ $transfer_ok = false;
}
+ if ($transfer_ok)
+ {
+
$this->soXport->log_transaction($batchid, $this->order_id, lang('transferred
Order %1 to Agresso', basename($filename)));
+
$this->db->transaction_commit(); // Reverse the batch_id - increment
+ }
else
{
- // try to authenticate with
username root, password secretpassword
- if
(!ssh2_auth_password($connection, $user, $password))
+ $this->db->transaction_abort();
+
$this->soXport->log_transaction($batchid, $this->order_id, lang('Failed to
transfere Order %1 to Agresso', basename($filename)));
+ // @unlink($filename);
+ }
+ }
+ else
+ {
+ $transfer_ok = true;
+
+ //
$GLOBALS['phpgw_info']['flags']['noheader'] = true;
+ //
$GLOBALS['phpgw_info']['flags']['nofooter'] = true;
+ //
$GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
+ // $size = strlen($content);
+ // $browser =
CreateObject('phpgwapi.browser');
+ //
$browser->content_header(basename($filename), '', $size);
+ // echo $content;
+ }
+ return $transfer_ok;
+ }
+
+ function phpftp_connect()
+ {
+ $server =
$this->config->config_data['common']['host'];
+ $user =
$this->config->config_data['common']['user'];
+ $password =
$this->config->config_data['common']['password'];
+ $port = 22;
+
+ switch
($this->config->config_data['common']['method'])
+ {
+ case 'ftp';
+ if ($connection =
ftp_connect($server))
{
- $message = "fail:
unable to authenticate";
+ ftp_login($connection,
$user, $password);
+ }
+ break;
+ case 'ssh';
+ if
(!function_exists("ssh2_connect"))
+ {
+ die("function
ssh2_connect doesn't exist");
+ }
+ if (!($connection =
ssh2_connect("$server", $port)))
+ {
+ $message = "fail:
unable to establish connection";
_debug_array($message);
//$receipt['error'][]=
array('msg' => $message);
}
- }
- break;
+ else
+ {
+ // try to authenticate
with username root, password secretpassword
+ if
(!ssh2_auth_password($connection, $user, $password))
+ {
+ $message =
"fail: unable to authenticate";
+
_debug_array($message);
+
//$receipt['error'][]= array('msg' => $message);
+ }
+ }
+ break;
+ }
+ $this->connection = $connection;
+ return $connection;
}
- $this->connection = $connection;
- return $connection;
}
}
- class xml_creator extends XMLWriter
+ if (!class_exists("xml_creator"))
{
-
- /**
- * Constructor.
- * @param string $prm_rootElementName A root element's name of
a current xml document
- * @param ARRAY $root_attributtes array of root attributes.
- * @param string $prm_xsltFilePath Path of a XSLT file.
- * @access public
- * @param null
- */
- public function __construct( $prm_rootElementName,
$root_attributes = array(), $prm_xsltFilePath = '' )
+ class xml_creator extends XMLWriter
{
- $this->openMemory();
- $this->setIndent(true);
- $this->setIndentString(' ');
- $this->startDocument('1.0', 'UTF-8');
- if ($prm_xsltFilePath)
+ /**
+ * Constructor.
+ * @param string $prm_rootElementName A root element's
name of a current xml document
+ * @param ARRAY $root_attributtes array of root
attributes.
+ * @param string $prm_xsltFilePath Path of a XSLT file.
+ * @access public
+ * @param null
+ */
+ public function __construct( $prm_rootElementName,
$root_attributes = array(), $prm_xsltFilePath = '' )
{
- $this->writePi('xml-stylesheet',
'type="text/xsl" href="' . $prm_xsltFilePath . '"');
+ $this->openMemory();
+ $this->setIndent(true);
+ $this->setIndentString(' ');
+ $this->startDocument('1.0', 'UTF-8');
+
+ if ($prm_xsltFilePath)
+ {
+ $this->writePi('xml-stylesheet',
'type="text/xsl" href="' . $prm_xsltFilePath . '"');
+ }
+
+ $this->startElement($prm_rootElementName);
+
+ foreach ($root_attributes as $key => $value)
+ {
+ $this->writeAttribute($key, $value);
+ }
}
- $this->startElement($prm_rootElementName);
-
- foreach ($root_attributes as $key => $value)
+ /**
+ * Set an element with a text to a current xml document.
+ * @access public
+ * @param string $prm_elementName An element's name
+ * @param string $prm_ElementText An element's text
+ * @return null
+ */
+ public function setElement( $prm_elementName,
$prm_ElementText )
{
- $this->writeAttribute($key, $value);
+ $this->startElement($prm_elementName);
+ $this->text($prm_ElementText);
+ $this->endElement();
}
- }
- /**
- * Set an element with a text to a current xml document.
- * @access public
- * @param string $prm_elementName An element's name
- * @param string $prm_ElementText An element's text
- * @return null
- */
- public function setElement( $prm_elementName, $prm_ElementText )
- {
- $this->startElement($prm_elementName);
- $this->text($prm_ElementText);
- $this->endElement();
- }
-
- /**
- * Construct elements and texts from an array.
- * The array should contain an attribute's name in index part
- * and a attribute's text in value part.
- * @access public
- * @param array $prm_array Contains attributes and texts
- * @return null
- */
- public function fromArray( array $array )
- {
- foreach ($array as $key => $val)
+ /**
+ * Construct elements and texts from an array.
+ * The array should contain an attribute's name in
index part
+ * and a attribute's text in value part.
+ * @access public
+ * @param array $prm_array Contains attributes and texts
+ * @return null
+ */
+ public function fromArray( array $array )
{
- if (is_array($val))
+ foreach ($array as $key => $val)
{
- if (is_numeric($key))
+ if (is_array($val))
{
- // numeric keys aren't allowed
so we'll skip the key
- $this->fromArray($val);
+ if (is_numeric($key))
+ {
+ // numeric keys aren't
allowed so we'll skip the key
+ $this->fromArray($val);
+ }
+ else
+ {
+
$this->startElement($key);
+ $this->fromArray($val);
+ $this->endElement();
+ }
}
else
{
- $this->startElement($key);
- $this->fromArray($val);
- $this->endElement();
+ $this->writeElement($key, $val);
}
}
- else
- {
- $this->writeElement($key, $val);
- }
}
- }
- /**
- * Return the content of a current xml document.
- * @access public
- * @param null
- * @return string Xml document
- */
- public function getDocument()
- {
- $this->endElement();
- $this->endDocument();
- return $this->outputMemory();
- }
+ /**
+ * Return the content of a current xml document.
+ * @access public
+ * @param null
+ * @return string Xml document
+ */
+ public function getDocument()
+ {
+ $this->endElement();
+ $this->endDocument();
+ return $this->outputMemory();
+ }
- /**
- * Output the content of a current xml document.
- * @access public
- * @param null
- */
- public function output()
- {
- header('Content-type: text/xml');
- echo $this->getDocument();
+ /**
+ * Output the content of a current xml document.
+ * @access public
+ * @param null
+ */
+ public function output()
+ {
+ header('Content-type: text/xml');
+ echo $this->getDocument();
+ }
}
}
\ No newline at end of file
Modified:
branches/Version-2_0-branch/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php
===================================================================
---
branches/Version-2_0-branch/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php
2017-01-04 13:41:49 UTC (rev 16140)
+++
branches/Version-2_0-branch/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php
2017-01-04 13:47:01 UTC (rev 16141)
@@ -31,301 +31,312 @@
* @package property
*/
-// if (!$workorder['order_sent'])
+ if (!class_exists("lag_agresso_ordre_fra_workorder"))
{
- $exporter_ordre = new lag_agresso_ordre_fra_workorder();
- $exporter_ordre->transfer($project, $workorder);
- }
-
- class lag_agresso_ordre_fra_workorder
- {
- var $debug = false;
-
- public function __construct()
+ class lag_agresso_ordre_fra_workorder
{
- $this->cats = CreateObject('phpgwapi.categories', -1,
'property', '.project');
- $this->cats->supress_info = true;
- $config = CreateObject('admin.soconfig',
$GLOBALS['phpgw']->locations->get_id('property', '.invoice'));
- $this->debug =
empty($config->config_data['export']['activate_transfer']) ? true : false;
- }
+ var $debug = false;
- public function transfer( $project, $workorder )
- {
-// _debug_array($workorder);die();
- if (!$this->debug && $workorder['order_sent'])
+ public function __construct()
{
- $transfer_time =
$GLOBALS['phpgw']->common->show_date($workorder['order_sent']);
- phpgwapi_cache::message_set("Info: Ordre
#{$workorder['id']} er allerede overført til Agresso {$transfer_time}");
- return 2;
+ $this->cats =
CreateObject('phpgwapi.categories', -1, 'property', '.project');
+ $this->cats->supress_info = true;
+ $config = CreateObject('admin.soconfig',
$GLOBALS['phpgw']->locations->get_id('property', '.invoice'));
+ $this->debug =
empty($config->config_data['export']['activate_transfer']) ? true : false;
}
- $config = CreateObject('phpgwapi.config', 'property');
- $config->read();
- $approval_level =
!empty($config->config_data['approval_level']) ?
$config->config_data['approval_level'] : 'order';
-
- $approval_amount = 0;
- $price = 0;
- if($approval_level == 'project')
+ public function transfer( $workorder )
{
- $approval_amount =
ExecMethod('property.boworkorder.get_accumulated_budget_amount',
$workorder['project_id']);
- $price = (float)
ExecMethod('property.boworkorder.get_budget_amount', $workorder['id']);
- }
- else
- {
- $approval_amount =
ExecMethod('property.boworkorder.get_budget_amount', $workorder['id']);
- $price = (float) $approval_amount;
+ $project =
createObject('property.boproject')->read_single($workorder['project_id'],
array(), true);
- }
+ if (!$this->debug && $workorder['order_sent'])
+ {
+ $transfer_time =
$GLOBALS['phpgw']->common->show_date($workorder['order_sent']);
+ phpgwapi_cache::message_set("Info:
Ordre #{$workorder['id']} er allerede overført til Agresso {$transfer_time}");
+ return 2;
+ }
- try
- {
- $purchase_grant_ok =
CreateObject('property.botts')->validate_purchase_grant( $workorder['ecodimb'],
$approval_amount, $workorder['id']);
- }
- catch (Exception $ex)
- {
- throw $ex;
- }
+ $config = CreateObject('phpgwapi.config',
'property');
+ $config->read();
+ $approval_level =
!empty($config->config_data['approval_level']) ?
$config->config_data['approval_level'] : 'order';
- if (!$this->debug && !$purchase_grant_ok)
- {
- return 3;
- }
+ $approval_amount = 0;
+ $price = 0;
+ if($approval_level == 'project')
+ {
+ $approval_amount =
ExecMethod('property.boworkorder.get_accumulated_budget_amount',
$workorder['project_id']);
+ $price = (float)
ExecMethod('property.boworkorder.get_budget_amount', $workorder['id']);
+ }
+ else
+ {
+ $approval_amount =
ExecMethod('property.boworkorder.get_budget_amount', $workorder['id']);
+ $price = (float) $approval_amount;
- $contacts = CreateObject('property.sogeneric');
- $contacts->get_location_info('vendor', false);
+ }
- $custom = createObject('property.custom_fields');
- $vendor_data['attributes'] = $custom->find('property',
'.vendor', 0, '', 'ASC', 'attrib_sort', true, true);
+ try
+ {
+ $purchase_grant_ok =
CreateObject('property.botts')->validate_purchase_grant( $workorder['ecodimb'],
$approval_amount, $workorder['id']);
+ }
+ catch (Exception $ex)
+ {
+ throw $ex;
+ }
- $vendor_data = $contacts->read_single(array('id' =>
$workorder['vendor_id']), $vendor_data);
- if (is_array($vendor_data))
- {
- foreach ($vendor_data['attributes'] as
$attribute)
+ if (!$this->debug && !$purchase_grant_ok)
{
- if ($attribute['name'] == 'adresse')
+ return 3;
+ }
+
+ $contacts = CreateObject('property.sogeneric');
+ $contacts->get_location_info('vendor', false);
+
+ $custom =
createObject('property.custom_fields');
+ $vendor_data['attributes'] =
$custom->find('property', '.vendor', 0, '', 'ASC', 'attrib_sort', true, true);
+
+ $vendor_data =
$contacts->read_single(array('id' => $workorder['vendor_id']), $vendor_data);
+ if (is_array($vendor_data))
+ {
+ foreach ($vendor_data['attributes'] as
$attribute)
{
- $vendor['address'] =
$attribute['value'];
+ if ($attribute['name'] ==
'adresse')
+ {
+ $vendor['address'] =
$attribute['value'];
+ }
+ if ($attribute['name'] ==
'org_name')
+ {
+ $vendor['name'] =
$attribute['value'];
+ }
}
- if ($attribute['name'] == 'org_name')
- {
- $vendor['name'] =
$attribute['value'];
- }
}
- }
- unset($contacts);
+ unset($contacts);
-
$GLOBALS['phpgw']->preferences->set_account_id($workorder['user_id'], true);
+
$GLOBALS['phpgw']->preferences->set_account_id($workorder['user_id'], true);
- $user_name =
$GLOBALS['phpgw']->accounts->get($workorder['user_id'])->__toString();
- $account_lid =
$GLOBALS['phpgw']->accounts->id2lid($workorder['user_id']);
+ $user_name =
$GLOBALS['phpgw']->accounts->get($workorder['user_id'])->__toString();
+ $account_lid =
$GLOBALS['phpgw']->accounts->id2lid($workorder['user_id']);
- if ($workorder['ecodimb'])
- {
- $dim1 = $workorder['ecodimb'];
- }
- else if ($project['ecodimb'])
- {
- $dim1 = $project['ecodimb'];
- }
- else
- {
- throw new Exception('Dimensjonen "Ansvar"
mangler');
- }
+ if ($workorder['ecodimb'])
+ {
+ $dim1 = $workorder['ecodimb'];
+ }
+ else if ($project['ecodimb'])
+ {
+ $dim1 = $project['ecodimb'];
+ }
+ else
+ {
+ throw new Exception('Dimensjonen
"Ansvar" mangler');
+ }
- if ($workorder['location_code'])
- {
- $location_code = $workorder['location_code'];
- $location = explode('-', $location_code);
-// $dim3 = isset($location[1]) && $location[1] ?
"{$location[0]}{$location[1]}" : "{$location[0]}01";
- $dim3 = $location[0];
+ if ($workorder['location_code'])
+ {
+ $location_code =
$workorder['location_code'];
+ $location = explode('-',
$location_code);
+ // $dim3 = isset($location[1]) &&
$location[1] ? "{$location[0]}{$location[1]}" : "{$location[0]}01";
+ $dim3 = $location[0];
- }
- else if ($project['location_code'])
- {
- $location_code = $project['location_code'];
- $location = explode('-', $location_code);
-// $dim3 = isset($location[1]) && $location[1] ?
"{$location[0]}{$location[1]}" : "{$location[0]}01";
- $dim3 = $location[0];
- }
- else
- {
- $dim3 = 9;
- }
+ }
+ else if ($project['location_code'])
+ {
+ $location_code =
$project['location_code'];
+ $location = explode('-',
$location_code);
+ // $dim3 = isset($location[1]) &&
$location[1] ? "{$location[0]}{$location[1]}" : "{$location[0]}01";
+ $dim3 = $location[0];
+ }
+ else
+ {
+ $dim3 = 9;
+ }
- $address_element =
execMethod('property.botts.get_address_element', $location_code);
- $_address = array();
- foreach ($address_element as $entry)
- {
- $_address[] = "{$entry['text']}:
{$entry['value']}";
- }
+ $address_element =
execMethod('property.botts.get_address_element', $location_code);
+ $_address = array();
+ foreach ($address_element as $entry)
+ {
+ $_address[] = "{$entry['text']}:
{$entry['value']}";
+ }
- $address = '';
- if ($_address)
- {
- $address = implode(', ', $_address);
- }
+ $address = '';
+ if ($_address)
+ {
+ $address = implode(', ', $_address);
+ }
- $buyer = array(
- 'Name' => $user_name,
- 'AddressInfo' => array(
- array(
- 'Address' => $address
+ $buyer = array(
+ 'Name' => $user_name,
+ 'AddressInfo' => array(
+ array(
+ 'Address' => $address
+ )
+ ),
+ 'BuyerReferences' => array(
+ array(
+ 'Responsible' =>
strtoupper($account_lid),
+ 'RequestedBy' =>
strtoupper($account_lid),
+ 'Accountable' =>
strtoupper($account_lid),
+ )
)
- ),
- 'BuyerReferences' => array(
- array(
- 'Responsible' =>
strtoupper($account_lid),
- 'RequestedBy' =>
strtoupper($account_lid),
- 'Accountable' =>
strtoupper($account_lid),
- )
- )
- );
+ );
- //EBF...
+ //EBF...
- $location_info =
execMethod('property.bolocation.read_single', $location[0]);
+ $location_info =
execMethod('property.bolocation.read_single', $location[0]);
- $tax_code = 0;
- $tjeneste = 9;
- if ($location_info['attributes'])
- {
- $_found = 0;
- foreach ($location_info['attributes'] as $key
=> $attribute)
+ $tax_code = 0;
+ $tjeneste = 9;
+ if ($location_info['attributes'])
{
- if ($attribute['name'] == 'mva')
+ $_found = 0;
+ foreach ($location_info['attributes']
as $key => $attribute)
{
- $tax_code = $attribute['value'];
- $_found ++;
+ if ($attribute['name'] == 'mva')
+ {
+ $tax_code =
$attribute['value'];
+ $_found ++;
+ }
+ if ($attribute['name'] ==
'kostra_id')
+ {
+ $tjeneste =
$attribute['value'];
+ $_found ++;
+ }
+ if ($_found == 2)
+ {
+ break;
+ }
}
- if ($attribute['name'] == 'kostra_id')
- {
- $tjeneste = $attribute['value'];
- $_found ++;
- }
- if ($_found == 2)
- {
+ }
+
+ //Override from workorder
+ $tax_code = $workorder['tax_code'] ?
$workorder['tax_code'] : $tax_code;
+ switch ($tax_code)
+ {
+ case '0':
+ $tax_code = '6A';
break;
- }
+ case '75':
+ $tax_code = '60';
+ break;
+ default:
+ $tax_code = '6A';
+ break;
}
- }
- //Override from workorder
- $tax_code = $workorder['tax_code'] ?
$workorder['tax_code'] : $tax_code;
- switch ($tax_code)
- {
- case '0':
- $tax_code = '6A';
- break;
- case '75':
- $tax_code = '60';
- break;
- default:
- $tax_code = '6A';
- break;
- }
+ $tjeneste = $workorder['service_id'] ?
$workorder['service_id'] : $tjeneste;
- $tjeneste = $workorder['service_id'] ?
$workorder['service_id'] : $tjeneste;
+ // _debug_array($location_info);die();
-// _debug_array($location_info);die();
-
- $collect_building_part = false;
- if
(isset($config->config_data['workorder_require_building_part']))
- {
- if
($config->config_data['workorder_require_building_part'] == 1)
+ $collect_building_part = false;
+ if
(isset($config->config_data['workorder_require_building_part']))
{
- $collect_building_part = true;
+ if
($config->config_data['workorder_require_building_part'] == 1)
+ {
+ $collect_building_part = true;
+ }
}
- }
- if ($collect_building_part)
- {
- if ($workorder['order_dim1'])
+ if ($collect_building_part)
{
- $sogeneric =
CreateObject('property.sogeneric', 'order_dim1');
- $sogeneric_data =
$sogeneric->read_single(array('id' => $workorder['order_dim1']));
- if ($sogeneric_data)
+ if ($workorder['order_dim1'])
{
- $dim6 =
"{$workorder['building_part']}{$sogeneric_data['num']}";
+ $sogeneric =
CreateObject('property.sogeneric', 'order_dim1');
+ $sogeneric_data =
$sogeneric->read_single(array('id' => $workorder['order_dim1']));
+ if ($sogeneric_data)
+ {
+ $dim6 =
"{$workorder['building_part']}{$sogeneric_data['num']}";
+ }
}
}
- }
- else
- {
- $category =
$this->cats->return_single($workorder['cat_id']);
- $category_arr = explode('-',
$category[0]['name']);
- $dim6 = (int)trim($category_arr[0]);
- }
+ else
+ {
+ $category =
$this->cats->return_single($workorder['cat_id']);
+ $category_arr = explode('-',
$category[0]['name']);
+ $dim6 = (int)trim($category_arr[0]);
+ }
- /*
- 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($workorder['id'] >= 45000000 && $workorder['id'] <=
45249999)
- {
- $voucher_type = 'P3';
- }
- else if ($workorder['id'] >= 45250000 &&
$workorder['id'] <= 45499999)
- {
- $voucher_type = 'P4';
- }
- else
- {
- throw new Exception("Ordrenummer
'{$workorder['id']}' er utenfor serien:<br/>" . __FILE__ . '<br/>linje:' .
__LINE__);
- }
+ if($workorder['id'] >= 45000000 &&
$workorder['id'] <= 45249999)
+ {
+ $voucher_type = 'P3';
+ }
+ else if ($workorder['id'] >= 45250000 &&
$workorder['id'] <= 45499999)
+ {
+ $voucher_type = 'P4';
+ }
+ else
+ {
+ throw new Exception("Ordrenummer
'{$workorder['id']}' er utenfor serien:<br/>" . __FILE__ . '<br/>linje:' .
__LINE__);
+ }
- $param = array(
- 'dim0' => $workorder['b_account_id'], // Art
- 'dim1' => $dim1, // Ansvar
- 'dim2' => $tjeneste, // Tjeneste liste 30 stk,
default 9
- 'dim3' => $dim3, // Objekt: eiendom + bygg: 6
siffer
- 'dim4' => $workorder['contract_id'], //
Kontrakt - frivillig / 9, 7 tegn - alfanumerisk
- 'dim5' => $project['external_project_id'], //
Prosjekt
- 'dim6' => $dim6, // Aktivitet - frivillig:
bygningsdel, 3 siffer + bokstavkode
- 'vendor_id' => $workorder['vendor_id'],
- 'vendor_name' => $vendor['name'],
- 'vendor_address' => $vendor['address'],
- 'order_id' => $workorder['id'],
- 'tax_code' => $tax_code,
- 'buyer' => $buyer,
- 'lines' => array(
- array(
- 'unspsc_code' =>
$workorder['unspsc_code'] ? $workorder['unspsc_code'] : 'UN-72000000',
-// 'descr' =>
strip_tags($workorder['descr'])
- 'descr' => '',
- 'price' => $price,
+ $param = array(
+ 'dim0' => $workorder['b_account_id'],
// Art
+ 'dim1' => $dim1, // Ansvar
+ 'dim2' => $tjeneste, // Tjeneste liste
30 stk, default 9
+ 'dim3' => $dim3, // Objekt: eiendom +
bygg: 6 siffer
+ 'dim4' => $workorder['contract_id'], //
Kontrakt - frivillig / 9, 7 tegn - alfanumerisk
+ 'dim5' =>
$project['external_project_id'], // Prosjekt
+ 'dim6' => $dim6, // Aktivitet -
frivillig: bygningsdel, 3 siffer + bokstavkode
+ 'vendor_id' => $workorder['vendor_id'],
+ 'vendor_name' => $vendor['name'],
+ 'vendor_address' => $vendor['address'],
+ 'order_id' => $workorder['id'],
+ 'tax_code' => $tax_code,
+ 'buyer' => $buyer,
+ 'lines' => array(
+ array(
+ 'unspsc_code' =>
$workorder['unspsc_code'] ? $workorder['unspsc_code'] : 'UN-72000000',
+ // 'descr' =>
strip_tags($workorder['descr'])
+ 'descr' => '',
+ 'price' => $price,
+ )
)
- )
- );
+ );
- $exporter_ordre = new
BkBygg_exporter_data_til_Agresso(array(
- 'order_id' => $workorder['id'],
- 'voucher_type' => $voucher_type
- )
- );
- $exporter_ordre->create_transfer_xml($param);
+ $exporter_ordre = new
BkBygg_exporter_data_til_Agresso(array(
+ 'order_id' => $workorder['id'],
+ 'voucher_type' => $voucher_type
+ )
+ );
+ $exporter_ordre->create_transfer_xml($param);
- $export_ok = $exporter_ordre->transfer($this->debug);
+ $export_ok =
$exporter_ordre->transfer($this->debug);
- if ($export_ok)
+ if ($export_ok)
+ {
+ phpgwapi_cache::message_set("Ordre
#{$workorder['id']} er overført");
+ $this->log_transfer( $workorder['id'] );
+ }
+ }
+
+ private function log_transfer( $id )
{
- phpgwapi_cache::message_set("Ordre
#{$workorder['id']} er overført");
- $this->log_transfer( $workorder['id'] );
+ $historylog =
CreateObject('property.historylog', 'workorder');
+ $historylog->add('RM', $id, "Ordre overført til
agresso");
+ $now = time();
+ $GLOBALS['phpgw']->db->query("UPDATE
fm_workorder SET order_sent = {$now} WHERE id = {$id}");
}
}
-
- private function log_transfer( $id )
+ }
+// if (!$workorder['order_sent'])
+ {
+ $exporter_ordre = new lag_agresso_ordre_fra_workorder();
+ try
{
- $historylog = CreateObject('property.historylog',
'workorder');
- $historylog->add('RM', $id, "Ordre overført til
agresso");
- $now = time();
- $GLOBALS['phpgw']->db->query("UPDATE fm_workorder SET
order_sent = {$now} WHERE id = {$id}");
+ $exporter_ordre->transfer($workorder);
}
- }
\ No newline at end of file
+ catch (Exception $exc)
+ {
+ phpgwapi_cache::message_set($exc->getMessage(),
'error');
+ }
+
+ }
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [16141] Stable: Merge 16131:16140 from trunk,
sigurdne <=