[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [17485] thirdparty: refactoring
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [17485] thirdparty: refactoring |
Date: |
Wed, 3 Jan 2018 05:13:57 -0500 (EST) |
Revision: 17485
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=17485
Author: sigurdne
Date: 2018-01-03 05:13:57 -0500 (Wed, 03 Jan 2018)
Log Message:
-----------
thirdparty: refactoring
Modified Paths:
--------------
thirdparty/PE_custom/BK_EBE/svn_full_checkout.php
thirdparty/PE_custom/BK_EBF/svn_full_checkout.php
Added Paths:
-----------
thirdparty/PE_custom/BK_COMMON/
thirdparty/PE_custom/BK_COMMON/property/
thirdparty/PE_custom/BK_COMMON/property/inc/
thirdparty/PE_custom/BK_COMMON/property/inc/cron/
thirdparty/PE_custom/BK_COMMON/property/inc/cron/default/
thirdparty/PE_custom/BK_COMMON/property/inc/cron/default/oppdater_betalte_faktura_BK.php
thirdparty/PE_custom/BK_COMMON/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
thirdparty/PE_custom/BK_COMMON/property/inc/custom/
thirdparty/PE_custom/BK_COMMON/property/inc/custom/default/
thirdparty/PE_custom/BK_COMMON/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
thirdparty/PE_custom/BK_COMMON/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php
thirdparty/PE_custom/BK_COMMON/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_melding.php
thirdparty/PE_custom/BK_COMMON/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php
Removed Paths:
-------------
thirdparty/PE_custom/BK_EBF/property/inc/cron/default/oppdater_betalte_faktura_BK.php
thirdparty/PE_custom/BK_EBF/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_melding.php
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php
Copied:
thirdparty/PE_custom/BK_COMMON/property/inc/cron/default/oppdater_betalte_faktura_BK.php
(from rev 17484,
thirdparty/PE_custom/BK_EBF/property/inc/cron/default/oppdater_betalte_faktura_BK.php)
===================================================================
---
thirdparty/PE_custom/BK_COMMON/property/inc/cron/default/oppdater_betalte_faktura_BK.php
(rev 0)
+++
thirdparty/PE_custom/BK_COMMON/property/inc/cron/default/oppdater_betalte_faktura_BK.php
2018-01-03 10:13:57 UTC (rev 17485)
@@ -0,0 +1,243 @@
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software
Foundation, Inc. http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
+ * @package property
+ * @subpackage cron
+ * @version $Id: oppdater_betalte_faktura_BK.php 16075 2016-12-12
15:26:41Z sigurdne $
+ */
+ /**
+ * Description
+ * example cron : /usr/local/bin/php -q
/var/www/html/phpgroupware/property/inc/cron/cron.php default
oppdater_betalte_faktura_BK
+ * @package property
+ */
+ include_class('property', 'cron_parent', 'inc/cron/');
+ phpgw::import_class('phpgwapi.datetime');
+
+ class oppdater_betalte_faktura_BK extends property_cron_parent
+ {
+
+ public function __construct()
+ {
+ parent::__construct();
+
+ $this->function_name = get_class($this);
+ $this->sub_location = lang('property');
+ $this->function_msg = 'oppdater bestillinger med
grunnlag i betalte faktura';
+ /**
+ * Bruker konffigurasjon fra '.ticket' - fordi denne
definerer oppslaget mot fullmaktsregisteret ved bestilling.
+ */
+ $config =
CreateObject('admin.soconfig', $GLOBALS['phpgw']->locations->get_id('property',
'.ticket'));
+ $this->soap_url =
$config->config_data['external_register']['url'];
+ $this->soap_username =
$config->config_data['external_register']['username'];
+ $this->soap_password =
$config->config_data['external_register']['password'];
+ }
+
+ function execute()
+ {
+ $start = time();
+
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/art
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/ansvar?id=013000
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/objekt?id=5001
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/prosjekt?id=5001
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/tjeneste?id=88010
+
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/leverandorer?leverandorNr=722920
+ if ($this->debug)
+ {
+ }
+ set_time_limit(2000);
+
+ try
+ {
+ $this->update_order();
+ }
+ catch (Exception $e)
+ {
+ $this->receipt['error'][] = array('msg' =>
$e->getMessage());
+ }
+
+ $msg = 'Tidsbruk: ' . (time() - $start) . ' sekunder';
+ $this->cron_log($msg, $cron);
+ echo "$msg\n";
+ $this->receipt['message'][] = array('msg' => $msg);
+
+ }
+
+ function cron_log( $receipt = '' )
+ {
+
+ $insert_values = array(
+ $this->cron,
+ date($this->db->datetime_format()),
+ $this->function_name,
+ $receipt
+ );
+
+ $insert_values =
$this->db->validate_insert($insert_values);
+
+ $sql = "INSERT INTO fm_cron_log
(cron,cron_date,process,message) "
+ . "VALUES ($insert_values)";
+ $this->db->query($sql, __LINE__, __FILE__);
+ }
+
+ private function update_order()
+ {
+ $config = CreateObject('phpgwapi.config',
'property')->read();
+ $sql = "SELECT DISTINCT pmwrkord_code,
external_voucher_id FROM fm_ecobilag";
+ $this->db->query($sql, __LINE__, __FILE__);
+ $vouchers = array();
+ while ($this->db->next_record())
+ {
+ $vouchers[] = array
+ (
+ 'order_id' =>
$this->db->f('pmwrkord_code'),
+ 'voucher_id' =>
$this->db->f('external_voucher_id')
+ );
+ }
+
+ $socommon = CreateObject('property.socommon');
+ $soworkorder = CreateObject('property.soworkorder');
+ $sotts = CreateObject('property.sotts');
+ $workorder_closed_status =
!empty($config['workorder_closed_status']) ? $config['workorder_closed_status']
: false;
+
+ if(!$workorder_closed_status)
+ {
+ throw new Exception('Order closed status not
defined');
+ }
+
+ $vouchers_ok = array();
+ foreach ($vouchers as $voucher)
+ {
+
if(!$this->check_payment($voucher['voucher_id']))
+ {
+ $this->receipt['error'][] = array('msg'
=> "{$voucher['voucher_id']} er ikke betalt");
+ continue;
+ }
+
+ $this->receipt['message'][] = array('msg' =>
"{$voucher['voucher_id']} er betalt");
+
+ $ok = false;
+ $order_type =
$socommon->get_order_type($voucher['order_id']);
+ switch ($order_type)
+ {
+ case 's_agreement':
+ break;
+ case 'workorder':
+ $workorder =
$soworkorder->read_single($voucher['order_id']);
+ if($workorder['continuous'])
+ {
+ $ok = true;
+ }
+ else
+ {
+ $ok =
$soworkorder->update_status(array('order_id' => $voucher['order_id'],'status'
=> $workorder_closed_status));
+ }
+ break;
+ case 'ticket':
+ $this->db->query("SELECT id,
continuous FROM fm_tts_tickets WHERE order_id= '{$voucher['order_id']}'",
__LINE__, __FILE__);
+ $this->db->next_record();
+ $ticket_id = $this->db->f('id');
+
+ if($this->db->f('continuous'))
+ {
+ $ok = true;
+ }
+ else
+ {
+ $ticket = array(
+
'status' => 'C8' //Avsluttet og fakturert (C)
+ );
+ $ok =
$sotts->update_status($ticket, $ticket_id);
+ }
+ break;
+ default:
+ throw new Exception('Order type
not supported');
+ }
+
+ if($ok)
+ {
+ $vouchers_ok[] = $voucher;
+ // $i = 60;
+ }
+
+ }
+ unset($voucher);
+
+ $metadata = $this->db->metadata('fm_ecobilag');
+ $cols = array_keys($metadata);
+ foreach ($vouchers_ok as $voucher)
+ {
+ $this->db->transaction_begin();
+ $value_set = array();
+ $this->db->query("SELECT * FROM fm_ecobilag
WHERE external_voucher_id= '{$voucher['voucher_id']}'", __LINE__, __FILE__);
+ $this->db->next_record();
+ foreach ($cols as $col)
+ {
+ $value_set[$col] = $this->db->f($col);
+ }
+ $value_set['filnavn'] = date('d.m.Y-H:i:s',
phpgwapi_datetime::user_localtime());
+ $value_set['ordrebelop'] = $value_set['belop'];
+ unset($value_set['pre_transfer']);
+
+ $_cols = implode(',', array_keys($value_set));
+ $values =
$this->db->validate_insert(array_values($value_set));
+ $this->db->query("INSERT INTO fm_ecobilagoverf
({$_cols}) VALUES ({$values})", __LINE__, __FILE__);
+ $this->db->query("DELETE FROM fm_ecobilag WHERE
external_voucher_id= '{$voucher['voucher_id']}'", __LINE__, __FILE__);
+ $this->db->transaction_commit();
+ $this->receipt['message'][] = array('msg' =>
"{$voucher['voucher_id']} er overført til historikk");
+ }
+ }
+
+ function check_payment( $voucher_id )
+ {
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/utlignetfaktura?bilagsNr=917039148
+ $url =
"{$this->soap_url}/utlignetfaktura?bilagsNr={$voucher_id}";
+ $username = $this->soap_username; //'portico';
+ $password = $this->soap_password;
//'BgPor790gfol';
+
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_USERPWD,
"{$username}:{$password}");
+ curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json'));
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+
+ $result = curl_exec($ch);
+
+ $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ if(!$httpCode)
+ {
+ throw new Exception("No connection: {$url}");
+ }
+ curl_close($ch);
+
+ $result = json_decode($result, true);
+
+ return $result;
+
+ }
+
+ }
Copied:
thirdparty/PE_custom/BK_COMMON/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
(from rev 17484,
thirdparty/PE_custom/BK_EBF/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php)
===================================================================
---
thirdparty/PE_custom/BK_COMMON/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
(rev 0)
+++
thirdparty/PE_custom/BK_COMMON/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
2018-01-03 10:13:57 UTC (rev 17485)
@@ -0,0 +1,891 @@
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software
Foundation, Inc. http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
+ * @package property
+ * @subpackage cron
+ * @version $Id$
+ */
+ /**
+ * Description
+ * example cron : /usr/local/bin/php -q
/var/www/html/phpgroupware/property/inc/cron/cron.php default
synkroniser_avdelinger_med_fellesdata
+ * @package property
+ */
+ include_class('property', 'cron_parent', 'inc/cron/');
+
+ class synkroniser_avdelinger_med_fellesdata extends property_cron_parent
+ {
+
+ public function __construct()
+ {
+ parent::__construct();
+
+ $this->function_name = get_class($this);
+ $this->sub_location = lang('property');
+ $this->function_msg = 'Synkroniser avdelinger med
Fellesdata';
+ }
+
+ function execute()
+ {
+ $fellesdata = new property_fellesdata();
+
+ $fellesdata->set_debug($this->debug);
+
+ /*
+ * ansvar
+ * art
+ * objekt
+ * prosjekt
+ * tjeneste
+ */
+ if
(isset($GLOBALS['phpgw_info']['user']['apps']['rental']))
+ {
+ $fellesdata->update_customer_id();
+ }
+ $fellesdata->update_vendor();
+ // $fellesdata->update_agresso_prosjekt(); //for mange
treff
+ // $fellesdata->update_art();
//for mange treff
+ // $fellesdata->update_tjeneste();
+ // $fellesdata->update_dimb(); // ansvar, or mange treff
+ $fellesdata->get_org_unit_ids_from_top();
+
+
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/art
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/ansvar?id=013000
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/objekt?id=5001
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/prosjekt?id=5001
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/tjeneste?id=88010
+
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/leverandorer?leverandorNr=722920
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/kundeinfo?organisasjonsnummer="998391407"
+
+
+ if ($this->debug)
+ {
+ _debug_array($fellesdata->unit_ids);
+ }
+
+ try
+ {
+ $fellesdata->insert_values();
+
+ if
(isset($GLOBALS['phpgw_info']['user']['apps']['rental']))
+ {
+ $this->update_rental_party();
+ }
+ }
+ catch (Exception $e)
+ {
+ $this->receipt['error'][] = array('msg' =>
$e->getMessage());
+ }
+
+ $messages = $fellesdata->messages;
+ foreach ($messages as $message)
+ {
+ $this->receipt['message'][] = array('msg' =>
$message);
+ }
+ }
+
+ private function update_rental_party()
+ {
+ $sogeneric = CreateObject('property.sogeneric');
+ $sql = "SELECT DISTINCT org_enhet_id FROM rental_party
WHERE org_enhet_id IS NOT NULL";
+ $this->db->query($sql, __LINE__, __FILE__);
+ $parties = array();
+ while ($this->db->next_record())
+ {
+ $parties[] = $this->db->f('org_enhet_id');
+ }
+
+ foreach ($parties as $party)
+ {
+ $sql = "SELECT name, parent_id FROM fm_org_unit
WHERE id = {$party}";
+ $this->db->query($sql, __LINE__, __FILE__);
+ if ($this->db->next_record())
+ {
+ $name = $this->db->f('name');
+ $parent_id = $this->db->f('parent_id');
+ $path =
$sogeneric->get_path(array('type' => 'org_unit', 'id' => $parent_id));
+ $parent_name = implode(' > ', $path);
+
+ $value_set = array
+ (
+ 'company_name' => $name,
+ 'department' =>
$this->db->db_addslashes($parent_name)
+ );
+
+ $value_set =
$this->db->validate_update($value_set);
+ $sql = "UPDATE rental_party SET
{$value_set} WHERE org_enhet_id ={$party}";
+
+ $this->db->query($sql, __LINE__,
__FILE__);
+ if ($this->debug)
+ {
+ $this->receipt['message'][] =
array('msg' => $sql);
+ }
+ }
+ }
+ }
+ }
+
+ class property_fellesdata
+ {
+
+ // Instance variable
+ protected static $bo;
+ protected $connected = false;
+ protected $status;
+ protected $db = null;
+ protected $unit_ids = array();
+ protected $names = array();
+ protected $messages = array();
+ protected $debug = false;
+
+ private $soap_url,
+ $soap_username,
+ $soap_password;
+
+ function __construct()
+ {
+ /**
+ * Bruker konffigurasjon fra '.ticket' - fordi denne
definerer oppslaget mot fullmaktsregisteret ved bestilling.
+ */
+ $config =
CreateObject('admin.soconfig', $GLOBALS['phpgw']->locations->get_id('property',
'.ticket'));
+ $this->soap_url =
$config->config_data['external_register']['url'];
+ $this->soap_username =
$config->config_data['external_register']['username'];
+ $this->soap_password =
$config->config_data['external_register']['password'];
+
+ $this->config = CreateObject('admin.soconfig',
$GLOBALS['phpgw']->locations->get_id('property', '.admin'));
+
+ if (!isset($this->config->config_data['fellesdata']) ||
!$this->config->config_data['fellesdata'])
+ {
+ $this->initiate_config();
+ }
+ }
+
+ public function set_debug( $debug )
+ {
+ $this->debug = $debug;
+ }
+
+ private function initiate_config()
+ {
+ $receipt_section = $this->config->add_section(array
+ (
+ 'name' => 'fellesdata',
+ 'descr' => 'Fellesdata'
+ )
+ );
+
+ $receipt = $this->config->add_attrib(array
+ (
+ 'section_id' => $receipt_section['section_id'],
+ 'input_type' => 'text',
+ 'name' => 'host',
+ 'descr' => 'Host'
+ )
+ );
+ $receipt = $this->config->add_attrib(array
+ (
+ 'section_id' => $receipt_section['section_id'],
+ 'input_type' => 'text',
+ 'name' => 'port',
+ 'descr' => 'Port'
+ )
+ );
+ $receipt = $this->config->add_attrib(array
+ (
+ 'section_id' => $receipt_section['section_id'],
+ 'input_type' => 'text',
+ 'name' => 'db_name',
+ 'descr' => 'Database'
+ )
+ );
+ $receipt = $this->config->add_attrib(array
+ (
+ 'section_id' => $receipt_section['section_id'],
+ 'input_type' => 'text',
+ 'name' => 'user',
+ 'descr' => 'User'
+ )
+ );
+ $receipt = $this->config->add_attrib(array
+ (
+ 'section_id' => $receipt_section['section_id'],
+ 'input_type' => 'password',
+ 'name' => 'password',
+ 'descr' => 'Password'
+ )
+ );
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'admin.uiconfig2.list_attrib',
+ 'section_id' => $receipt_section['section_id'],
'location_id' => $GLOBALS['phpgw']->locations->get_id('property', '.admin')));
+ }
+
+ /**
+ * Magic get method
+ *
+ * @param string $varname the variable to fetch
+ *
+ * @return mixed the value of the variable sought - null if not
found
+ */
+ public function __get( $varname )
+ {
+ switch ($varname)
+ {
+ case 'unit_ids':
+ return $this->unit_ids;
+ break;
+ case 'names':
+ return $this->names;
+ break;
+ case 'messages':
+ return $this->messages;
+ break;
+ default:
+ return null;
+ }
+ }
+ /* our simple php ping function */
+
+ function ping( $host )
+ {
+ exec(sprintf('ping -c 1 -W 5 %s',
escapeshellarg($host)), $res, $rval);
+ return $rval === 0;
+ }
+
+ public function get_db()
+ {
+ if ($this->db && is_object($this->db))
+ {
+ return $this->db;
+ }
+
+ if (!$this->config->config_data['fellesdata']['host']
|| !$this->ping($this->config->config_data['fellesdata']['host']))
+ {
+ $message = "Database server
{$this->config->config_data['fellesdata']['host']} is not accessible";
+ phpgwapi_cache::message_set($message, 'error');
+ return false;
+ }
+
+ $db = createObject('phpgwapi.db_adodb', null, null,
true);
+ $db->debug = false;
+ $db->Host =
$this->config->config_data['fellesdata']['host'];
+ $db->Port =
$this->config->config_data['fellesdata']['port'];
+ $db->Type = 'oracle';
+ $db->Database =
$this->config->config_data['fellesdata']['db_name'];
+ $db->User =
$this->config->config_data['fellesdata']['user'];
+ $db->Password =
$this->config->config_data['fellesdata']['password'];
+
+ try
+ {
+ $db->connect();
+ $this->connected = true;
+ }
+ catch (Exception $e)
+ {
+ $status = lang('unable_to_connect_to_database');
+ }
+
+ $this->db = $db;
+ return $db;
+ }
+
+ public function insert_values()
+ {
+ $table = 'fm_org_unit';
+
+ $db = & $GLOBALS['phpgw']->db;
+ $db->transaction_begin();
+ $db->query("UPDATE {$table} SET active = 0", __LINE__,
__FILE__);
+ $units = $this->unit_ids;
+// _debug_array($units);
+ foreach ($units as $unit)
+ {
+ $value_set = array(
+ 'id' => $unit['id'],
+ 'parent_id' => $unit['parent'],
+ 'name' =>
$db->db_addslashes($unit['name']),
+ 'arbeidssted' => $unit['arbeidssted'],
+ 'created_on' => time(),
+ 'created_by' =>
$GLOBALS['phpgw_info']['user']['account_id'],
+ 'modified_by' =>
$GLOBALS['phpgw_info']['user']['account_id'],
+ 'modified_on' => time()
+ );
+
+ $db->query("SELECT count(*) as cnt FROM
{$table} WHERE id =" . (int)$unit['id'], __LINE__, __FILE__);
+ $db->next_record();
+
+ if ($db->f('cnt'))
+ {
+ unset($value_set['id']);
+ unset($value_set['created_on']);
+
+ $value_set['active'] = 1;
+ $value_set =
$db->validate_update($value_set);
+ $sql = "UPDATE {$table} SET
{$value_set} WHERE id =" . (int)$unit['id'];
+ if ($this->debug)
+ {
+ $this->messages[] = "ID finnes
fra før: {$unit['id']}, oppdaterer: {$unit['name']}";
+ $this->messages[] = $sql;
+ }
+ }
+ else
+ {
+ $cols = implode(',',
array_keys($value_set));
+ $values =
$db->validate_insert(array_values($value_set));
+ $sql = "INSERT INTO {$table} ({$cols})
VALUES ({$values})";
+ if ($this->debug)
+ {
+ $this->messages[] = "ID fantes
ikke fra før: {$unit['id']}, legger til: {$unit['name']}";
+ $this->messages[] = $sql;
+ }
+ }
+
+ $db->query($sql, __LINE__, __FILE__);
+ }
+
+ $db->transaction_commit();
+ }
+
+ function update_customer_id( )
+ {
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/kundeinfo?organisasjonsnummer="998391407"
+ $sql = "SELECT id, identifier FROM rental_party"
+ . " WHERE (customer_id = 0 OR customer_id IS
NULL)"
+ . " AND (length(identifier) = 9 OR
length(identifier) = 11)";
+
+ $GLOBALS['phpgw']->db->query($sql, __LINE__, __FILE__);
+
+ $parties = array();
+ while ($GLOBALS['phpgw']->db->next_record())
+ {
+ $parties[] = array(
+ 'id' =>
$GLOBALS['phpgw']->db->f('id'),
+ 'identifier' =>
$GLOBALS['phpgw']->db->f('identifier')
+ );
+ }
+
+ foreach ($parties as $party)
+ {
+ // $this->soap_url=
'http://tjenester.usrv.ubergenkom.no/api/agresso'; //test url
+ $url =
"{$this->soap_url}/kundeinfo?organisasjonsnummer='{$party['identifier']}'";
+ $values = array();
+ try
+ {
+ $values =
$this->check_external_register($url);
+ }
+ catch (Exception $exc)
+ {
+ echo $exc->getTraceAsString();
+ }
+
+ if(!empty($values[0]['kundenr']))
+ {
+ $customer_id =
(int)$values[0]['kundenr'];
+ $sql = "UPDATE rental_party"
+ . " SET customer_id =
{$customer_id}"
+ . " WHERE id = " .
(int)$party['id'];
+ // _debug_array($sql);
+ $GLOBALS['phpgw']->db->query($sql,
__LINE__, __FILE__);
+ }
+ }
+ }
+
+ /*
+ * ansvar
+ * art
+ * objekt
+ * prosjekt
+ * tjeneste
+ */
+ function update_agresso_prosjekt()
+ {
+ //det er for mange...16396 stk...
+ //return;
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/prosjekt
+
+// $url =
'http://tjenester.usrv.ubergenkom.no/api/agresso/prosjekt';
+ $url = "{$this->soap_url}/prosjekt";
+ $values = array();
+ try
+ {
+ $values = $this->check_external_register($url);
+
+ }
+ catch (Exception $exc)
+ {
+ echo $exc->getTraceAsString();
+ }
+/**
+ [tab] => A
+ [dimValue] => A00001
+ [description] => ADM.BYGG VEDTATT BUDSJETT 2001
+ [periodFrom] => 200612
+ [periodTo] => 209912
+ [status] => N
+
+ */
+ if($values)
+ {
+ $GLOBALS['phpgw']->db->query("UPDATE
fm_external_project SET active = 0" , __LINE__, __FILE__);
+ }
+
+ foreach ($values as $entry)
+ {
+ $active = $entry['status'] == 'C' ? 0 : 1;
+ $GLOBALS['phpgw']->db->query("SELECT id FROM
fm_external_project WHERE id ='{$entry['dimValue']}'", __LINE__, __FILE__);
+ if($GLOBALS['phpgw']->db->next_record())
+ {
+ $sql = "UPDATE fm_external_project SET
name = '{$entry['dimValue']} {$entry['description']}', active = {$active} WHERE
id = '{$entry['dimValue']}'";
+ }
+ else
+ {
+ $name =
$GLOBALS['phpgw']->db->db_addslashes("{$entry['dimValue']}
{$entry['description']}");
+ $sql = "INSERT INTO fm_external_project
(id, name, active)"
+ . " VALUES
('{$entry['dimValue']}', '{$name}', {$active})";
+ }
+ $GLOBALS['phpgw']->db->query($sql, __LINE__,
__FILE__);
+ }
+
+ }
+ function update_art()
+ {
+ //det er for mange...
+ return;
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/art
+
+// $url =
'http://tjenester.usrv.ubergenkom.no/api/agresso/art';
+ $url = "{$this->soap_url}/art";
+ $values = array();
+ try
+ {
+ $values = $this->check_external_register($url);
+
+ }
+ catch (Exception $exc)
+ {
+ echo $exc->getTraceAsString();
+ }
+
+ }
+
+ function update_tjeneste()
+ {
+ //det er for mange...
+ return;
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/tjeneste?id=88010
+ //fm_eco_service
+
+// $url =
'http://tjenester.usrv.ubergenkom.no/api/agresso/tjeneste';
+ $url = "{$this->soap_url}/tjeneste";
+ $values = array();
+ try
+ {
+ $values = $this->check_external_register($url);
+
+ }
+ catch (Exception $exc)
+ {
+ echo $exc->getTraceAsString();
+ }
+// [tab] => A
+// [dimValue] => 19050
+// [description] => Renholdstjenester
+// [periodFrom] => 200200
+// [periodTo] => 209912
+// [status] => N
+
+ if($values)
+ {
+ $GLOBALS['phpgw']->db->query("UPDATE
fm_eco_service SET active = 0" , __LINE__, __FILE__);
+ }
+
+ foreach ($values as $entry)
+ {
+ $active = $entry['status'] == 'C' ? 0 : 1;
+ $GLOBALS['phpgw']->db->query("SELECT id FROM
fm_eco_service WHERE id =" . (int) $entry['dimValue'], __LINE__, __FILE__);
+ if($GLOBALS['phpgw']->db->next_record())
+ {
+ $sql = "UPDATE fm_eco_service SET name
= '{$entry['dimValue']} {$entry['description']}', active = {$active} WHERE id =
" . (int) $entry['dimValue'];
+ }
+ else
+ {
+ $sql = "INSERT INTO fm_eco_service (id,
name, active)"
+ . " VALUES
({$entry['dimValue']}, '{$entry['dimValue']} {$entry['description']}',
{$active})";
+ }
+ $GLOBALS['phpgw']->db->query($sql, __LINE__,
__FILE__);
+ }
+ }
+
+ function update_vendor()
+ {
+ if(empty($this->soap_password))
+ {
+ return;
+ }
+
+ $metadata =
$GLOBALS['phpgw']->db->metadata('fm_vendor_temp');
+//_debug_array($metadata);
+ if (!$metadata)
+ {
+ $sql_table = <<<SQL
+ CREATE TABLE fm_vendor_temp
+ (
+ id integer NOT NULL,
+ status character varying(1),
+ navn character varying(255),
+ adresse character varying(255),
+ postnummer character varying(50),
+ sted character varying(50),
+ organisasjonsnr character varying(50),
+ bankkontonr character varying(50),
+ aktiv integer,
+ CONSTRAINT fm_vendor_temp_pkey PRIMARY KEY
(id)
+ );
+SQL;
+ $GLOBALS['phpgw']->db->query($sql_table,
__LINE__, __FILE__);
+ }
+ $GLOBALS['phpgw']->db->query('DELETE FROM
fm_vendor_temp', __LINE__, __FILE__);
+
+ //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/leverandorer?leverandorNr=**
+ //fm_vendor
+
+// $url =
'http://tjenester.usrv.ubergenkom.no/api/agresso/leverandorer?leverandorNr=**';
+// $url =
'http://tjenester.usrv.ubergenkom.no/api/agresso/leverandorer?leverandorNr=100304';
+ $url = "{$this->soap_url}/leverandorer?leverandorNr=**";
+
+ $error = false;
+
+ $values = array();
+ try
+ {
+ $values = $this->check_external_register($url);
+ }
+ catch (Exception $exc)
+ {
+ $error = true;
+ echo $exc->getTraceAsString();
+ }
+
+ $GLOBALS['phpgw']->db->transaction_begin();
+
+ $sql = 'INSERT INTO fm_vendor_temp (id, status, navn,
adresse, postnummer, sted, organisasjonsnr, bankkontonr, aktiv)'
+ . ' VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)';
+
+ //remove duplicates
+
+ if(empty($values[0]['leverandornummer']))
+ {
+ _debug_array($values);
+ $error = true;
+ }
+ $vendors = array();
+ foreach ($values as $entry)
+ {
+ $vendors[$entry['leverandornummer']] = $entry;
+ }
+
+ unset($entry);
+// _debug_array($vendors);die();
+
+ $valueset = array();
+
+ foreach ($vendors as $key => $entry)
+ {
+ $valueset[] = array
+ (
+ 1 => array
+ (
+ 'value' =>
(int)$entry['leverandornummer'],
+ 'type' => PDO::PARAM_INT
+ ),
+ 2 => array
+ (
+ 'value' => $entry['status'],
+ 'type' => PDO::PARAM_STR
+ ),
+ 3 => array
+ (
+ 'value' => $entry['navn'],
+ 'type' => PDO::PARAM_STR
+ ),
+ 4 => array
+ (
+ 'value' => $entry['adresse'],
+ 'type' => PDO::PARAM_STR
+ ),
+ 5 => array
+ (
+ 'value' => $entry['postnummer'],
+ 'type' => PDO::PARAM_STR
+ ),
+ 6 => array
+ (
+ 'value' => $entry['sted'],
+ 'type' => PDO::PARAM_STR
+ ),
+ 7 => array
+ (
+ 'value' =>
$entry['organisasjonsNr'],
+ 'type' => PDO::PARAM_STR
+ ),
+ 8 => array
+ (
+ 'value' =>
$entry['bankkontoNr'],
+ 'type' => PDO::PARAM_STR
+ ),
+ 9 => array
+ (
+ 'value' => (int)$entry['aktiv'],
+ 'type' => PDO::PARAM_INT
+ )
+ );
+ }
+
+ if($valueset && !$error)
+ {
+ $GLOBALS['phpgw']->db->insert($sql, $valueset,
__LINE__, __FILE__);
+ }
+
+/*
+ [leverandornummer] => 9906
+ [status] => N
+ [navn] => Bergen Vann KF (BV)
+ [adresse] => Postboks 7700
+ [postnummer] => 5020
+ [sted] => BERGEN
+ [organisasjonsNr] => 987328096
+ [bankkontoNr] => 52020801786
+ [aktiv] => 1
+*/
+// _debug_array($valueset);die();
+
+
+ $sql = "SELECT fm_vendor_temp.*"
+ . " FROM fm_vendor RIGHT OUTER JOIN
fm_vendor_temp ON (fm_vendor.id = fm_vendor_temp.id)"
+ . " WHERE fm_vendor.id IS NULL";
+
+ $GLOBALS['phpgw']->db->query($sql, __LINE__, __FILE__);
+ $vendors = array();
+ while ($GLOBALS['phpgw']->db->next_record())
+ {
+ $vendors[] = array(
+ 1 => array(
+ 'value' =>
(int)$GLOBALS['phpgw']->db->f('id'),
+ 'type' => PDO::PARAM_INT
+ ),
+ 2 => array(
+ 'value' =>
$GLOBALS['phpgw']->db->f('navn'),
+ 'type' => PDO::PARAM_STR
+ ),
+ 3 => array(
+ 'value' => 1,
+ 'type' => PDO::PARAM_INT
+ ),
+ 4 => array(
+ 'value' => 6,
+ 'type' => PDO::PARAM_INT
+ ),
+ 5 => array(
+ 'value' =>
(int)$GLOBALS['phpgw']->db->f('aktiv'),
+ 'type' => PDO::PARAM_INT
+ ),
+ 6 => array(
+ 'value' =>
$GLOBALS['phpgw']->db->f('adresse'),
+ 'type' => PDO::PARAM_STR
+ ),
+ 7 => array(
+ 'value' =>
$GLOBALS['phpgw']->db->f('postnummer'),
+ 'type' => PDO::PARAM_STR
+ ),
+ 8 => array(
+ 'value' =>
$GLOBALS['phpgw']->db->f('sted'),
+ 'type' => PDO::PARAM_STR
+ ),
+ 9 => array(
+ 'value' =>
$GLOBALS['phpgw']->db->f('organisasjonsnr'),
+ 'type' => PDO::PARAM_STR
+ ),
+ 10 => array(
+ 'value' =>
$GLOBALS['phpgw']->db->f('bankkontonr'),
+ 'type' => PDO::PARAM_STR
+ )
+ );
+ }
+ $sql = 'INSERT INTO fm_vendor (id, org_name,category,
owner_id, active, adresse, postnr, poststed, org_nr, konto_nr)'
+ . ' VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
+ if($vendors)
+ {
+ $GLOBALS['phpgw']->db->insert($sql, $vendors,
__LINE__, __FILE__);
+ }
+
+ $GLOBALS['phpgw']->db->query("UPDATE fm_vendor SET
active = 0", __LINE__, __FILE__);
+
+ $GLOBALS['phpgw']->db->query("UPDATE fm_vendor SET"
+ . " active = 1,"
+ . " org_name = fm_vendor_temp.navn,"
+ . " adresse = fm_vendor_temp.adresse,"
+ . " postnr = fm_vendor_temp.postnummer,"
+ . " poststed = fm_vendor_temp.sted,"
+ . " org_nr = fm_vendor_temp.organisasjonsnr"
+ . " FROM fm_vendor_temp WHERE fm_vendor.id =
fm_vendor_temp.id", __LINE__, __FILE__);
+
+ $GLOBALS['phpgw']->db->transaction_commit();
+ }
+
+ public function check_external_register($url)
+ {
+ $username = $this->soap_username;
+ $password = $this->soap_password;
+
+ /*Test server*/
+// $username = 'portico';
+// $password = 'BgPor790gfol';
+
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_USERPWD,
"{$username}:{$password}");
+ curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json'));
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+
+ $result = curl_exec($ch);
+
+ $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ curl_close($ch);
+
+ return json_decode($result, true);
+ }
+
+
+ /**
+ * ansvar
+ */
+ function update_dimb()
+ {
+ if (!$db = $this->get_db())
+ {
+ return;
+ }
+
+ $sql = "SELECT V_ANSVAR.ANSVAR,
V_ANSVAR.BESKRIVELSE,V_ANSVAR.STATUS, V_ORG_ENHET.ORG_ENHET_ID"
+ . " FROM V_ANSVAR JOIN V_ORG_ENHET ON
(V_ANSVAR.RESULTATENHET = V_ORG_ENHET.RESULTATENHET)";
+
+ $db->query($sql, __LINE__, __FILE__);
+ $values = array();
+ while ($db->next_record())
+ {
+ $values[] = array(
+ 'id' => (int)$db->f('ANSVAR'),
+ 'descr' =>
$GLOBALS['phpgw']->db->db_addslashes($db->f('BESKRIVELSE', true)),
+ 'active' => $db->f('STATUS') == 'C' ? 0
: 1,
+ 'org_unit_id' =>
(int)$db->f('ORG_ENHET_ID')
+ );
+ }
+
+ foreach ($values as $entry)
+ {
+ $GLOBALS['phpgw']->db->query("SELECT id FROM
fm_ecodimb WHERE id = {$entry['id']}", __LINE__, __FILE__);
+ if($GLOBALS['phpgw']->db->next_record())
+ {
+ $sql = "UPDATE fm_ecodimb SET descr =
'{$entry['descr']}', active = {$entry['active']}, org_unit_id =
{$entry['org_unit_id']} WHERE id = {$entry['id']}";
+ }
+ else
+ {
+ $sql = "INSERT INTO fm_ecodimb (id,
descr, active, org_unit_id)"
+ . " VALUES ({$entry['id']},
'{$entry['descr']}', {$entry['active']}, {$entry['org_unit_id']})";
+ }
+ $GLOBALS['phpgw']->db->query($sql, __LINE__,
__FILE__);
+ }
+ }
+
+ function get_org_unit_ids_from_top()
+ {
+ if (!$db = $this->get_db())
+ {
+ return;
+ }
+
+ $sql = "SELECT ORG_ENHET_ID, V_ORG_ENHET.ORG_NAVN FROM
V_ORG_ENHET";
+ $db->query($sql, __LINE__, __FILE__);
+ while ($db->next_record())
+ {
+ $org_unit_id = $db->f('ORG_ENHET_ID');
+ $name = $db->f('ORG_NAVN', true);
+ $this->names[$org_unit_id] = $name;
+ }
+// _debug_array($db);
+// _debug_array($this->names);die();
+ $sql = "SELECT V_ORG_ENHET.ORG_ENHET_ID,
V_ORG_ENHET.ORG_NAVN, V_ORG_ENHET.TJENESTESTED, V_ORG_ENHET.ORG_NIVAA FROM
V_ORG_ENHET"
+ . " WHERE V_ORG_ENHET.ORG_NIVAA = 1 ORDER BY
V_ORG_ENHET.ORG_NAVN ASC";
+
+ $db->query($sql);
+
+ while ($db->next_record())
+ {
+ $org_unit_id = $db->f('ORG_ENHET_ID');
+ $arbeidssted = $db->f('TJENESTESTED');
+ $this->unit_ids[] = array
+ (
+ 'id' => $org_unit_id,
+ 'name' => $this->names[$org_unit_id],
+ 'parent' => '',
+ 'arbeidssted' => $arbeidssted
+ );
+
+ $this->get_org_unit_ids_children($org_unit_id);
+ }
+ return $this->unit_ids;
+ }
+
+ function get_org_unit_ids_children( $org_unit_id )
+ {
+ $org_unit_id = (int)$org_unit_id;
+ $db = clone($this->db);
+
+ $sql = "SELECT V_ORG_KNYTNING.*,
ANT_ENHETER_UNDER,V_ORG_ENHET.ORG_NAVN, V_ORG_ENHET.TJENESTESTED, ORG_NIVAA
FROM V_ORG_KNYTNING"
+ . " JOIN V_ORG_ENHET ON
(V_ORG_ENHET.ORG_ENHET_ID = V_ORG_KNYTNING.ORG_ENHET_ID ) WHERE
V_ORG_KNYTNING.ORG_ENHET_ID_KNYTNING={$org_unit_id}";
+
+ $db->query($sql);
+
+ while ($db->next_record())
+ {
+ $child_org_unit_id = $db->f('ORG_ENHET_ID');
+ $arbeidssted = $db->f('TJENESTESTED');
+ $this->unit_ids[] = array(
+ 'id' => $child_org_unit_id,
+ 'name' =>
$this->names[$child_org_unit_id],
+ 'parent' => $org_unit_id,
+ 'level' => $db->f('ORG_NIVAA'),
+ 'arbeidssted' => $arbeidssted,
+ 'ant_enheter_under' =>
$db->f('ANT_ENHETER_UNDER')
+ );
+
+ if ($db->f('ANT_ENHETER_UNDER'))
+ {
+
$this->get_org_unit_ids_children($child_org_unit_id);
+ }
+ }
+// unset($db);
+ }
+ }
\ No newline at end of file
Copied:
thirdparty/PE_custom/BK_COMMON/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
(from rev 17484,
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php)
===================================================================
---
thirdparty/PE_custom/BK_COMMON/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
(rev 0)
+++
thirdparty/PE_custom/BK_COMMON/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
2018-01-03 10:13:57 UTC (rev 17485)
@@ -0,0 +1,490 @@
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2016 Free Software Foundation, Inc.
http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
+ * @package property
+ * @subpackage helpdesk
+ * @version $Id$
+ */
+ /**
+ * Description
+ * @package property
+ */
+
+
+ /**
+ * Description of BkBygg_exporter_data_til_Agresso
+ *
+ * @author Sigurd Nes
+ */
+ 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 $voucher_id;
+ var $batchid;
+ protected $global_lock = false;
+
+
+ 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
+ */
+
+ $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(
+ '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
+ )
+ );
+
+ $Header = array(
+ 'AcceptFlag' => 1,
+ 'OrderType]' => 'WB',
+ 'Status' => 'N',
+ 'OrderDate' => date('Y-m-d'),
+ 'Currency' => 'NOK',
+ 'Seller' => array($Seller),
+ 'Buyer' => array($param['buyer']),
+ $DetailInfo
+ );
+
+ array_unshift($DetailInfo, array('TaxCode' =>
$param['tax_code']));
+
+ $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
+ );
+
+ $i++;
+ }
+
+
+ $Orders['Order'][] = array(
+ 'OrderNo' => $param['order_id'],
+ 'VoucherType' => $this->voucher_type,
+ 'TransType' => 41,
+ 'Header' => array($Header),
+ 'Details' => array('Detail' => $Detail)
+ );
+
+ // _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();
+ }
+
+ /**
+ * Output the content of a current xml document.
+ * @access public
+ * @param null
+ */
+ public function output()
+ {
+ header('Content-type: text/xml');
+ echo $this->transfer_xml;
+ }
+
+
+ protected function create_file_name( $ref = '' )
+ {
+ if (!$ref)
+ {
+ throw new
Exception('BkBygg_exporter_data_til_Agresso::create_file_name() Mangler
referanse');
+ }
+ $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))
+ {
+ unlink($filename);
+ }
+
+ 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
+ {
+ $file_written = false;
+ $fp = fopen($filename, "wb");
+ fwrite($fp, $content);
+
+ if (fclose($fp))
+ {
+ $file_written = true;
+ }
+ else
+ {
+
phpgwapi_cache::message_set("$filename feilet", 'error');
+ }
+ }
+
+ $transfer_ok = false;
+ if (!$debug &&
($this->config->config_data['common']['method'] == 'ftp' ||
$this->config->config_data['common']['method'] == 'ssh'))
+ {
+ if ($this->db->get_transaction())
+ {
+ $this->global_lock = true;
+ }
+ else
+ {
+ $this->db->transaction_begin();
+ }
+
+ if (!$connection = $this->connection)
+ {
+ $connection =
$this->phpftp_connect();
+ }
+
+ $basedir =
$this->config->config_data['export']['remote_basedir'];
+ if ($basedir)
+ {
+ $remote_file = $basedir . '/' .
basename($filename);
+ }
+ else
+ {
+ $remote_file =
basename($filename);
+ }
+
+ switch
($this->config->config_data['common']['method'])
+ {
+ 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)));
+ if (!$this->global_lock)
+ {
+
$this->db->transaction_commit();
+ }
+ }
+ else
+ {
+ if (!$this->global_lock)
+ {
+
$this->db->transaction_abort(); // Reverse the batch_id - increment
+ }
+
$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))
+ {
+ 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);
+ }
+ 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;
+ }
+ }
+ }
+
+ if (!class_exists("xml_creator"))
+ {
+ class xml_creator extends XMLWriter
+ {
+
+ /**
+ * 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->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);
+ }
+ }
+
+ /**
+ * 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)
+ {
+ if (is_array($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->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();
+ }
+
+ /**
+ * 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
Copied:
thirdparty/PE_custom/BK_COMMON/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php
(from rev 17484,
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php)
===================================================================
---
thirdparty/PE_custom/BK_COMMON/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php
(rev 0)
+++
thirdparty/PE_custom/BK_COMMON/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php
2018-01-03 10:13:57 UTC (rev 17485)
@@ -0,0 +1,256 @@
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2016 Free Software Foundation, Inc.
http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
+ * @package property
+ * @subpackage helpdesk
+ * @version $Id$
+ */
+ /**
+ * Description
+ * @package property
+ */
+ /**
+ * Description of lag_agresso_varemottak
+ *
+ * @author Sigurd Nes
+ */
+
+ if (!class_exists("lag_agresso_varemottak"))
+ {
+ class lag_agresso_varemottak
+ {
+
+ private $acl_location;
+ private $values;
+ private $ordered_amount = 1;
+ var $debug = true;
+
+ function __construct( $acl_location, $id )
+ {
+ 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)
+ {
+
+ $amount += $budget['amount'];
+ }
+ return $amount ? $amount : 1;
+ }
+
+ 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();
+
+ /*
+ 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';
+
+ 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(empty($this->values['continuous']))
+ {
+ $quantity = 1; // closing the order
+ }
+ else if($this->ordered_amount)
+ {
+ $quantity =
$received_amount/$this->ordered_amount;
+ }
+ else //should not happen, but just in case...
+ {
+ $quantity = 0.8;
+ }
+
+ $param = array(
+ 'voucher_type' => $voucher_type,
+ 'order_id' => $values['order_id'],
+ 'lines' => array(
+ array(
+ 'UnitCode' => 'STK',
+ 'Quantity' => $quantity,
+ )
+ )
+ );
+
+ $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 );
+ }
+ return $export_ok;
+ }
+
+ private function log_transfer( $id, $received_amount )
+ {
+ $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 = order_received_amount +
{$received_amount} WHERE id = {$id}");
+ }
+ }
+ }
+
+ 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;
+
+ public function __construct( $param )
+ {
+ parent::__construct($param);
+ }
+
+ 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++;
+ }
+
+ $Orders['Order'][] = array(
+ 'OrderNo' => $param['order_id'],
+ 'VoucherType' => $param['voucher_type'],
+ 'TransType' => 51,
+ 'Details' => array('Detail' => $Detail)
+ );
+
+ // _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;
+ }
+
+ protected function create_file_name( $ref = '' )
+ {
+ 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'];
+
+ $filename =
"{$fil_katalog}/{$voucher_type}_varemottak_{$order_id}_{$this->batchid}.xml";
+
+ //Sjekk om filen eksisterer
+ if (file_exists($filename))
+ {
+ unlink($filename);
+ }
+
+ return $filename;
+ }
+ }
+ }
+
+ if (!empty($id) && !empty($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);
+ }
Copied:
thirdparty/PE_custom/BK_COMMON/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_melding.php
(from rev 17484,
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_melding.php)
===================================================================
---
thirdparty/PE_custom/BK_COMMON/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_melding.php
(rev 0)
+++
thirdparty/PE_custom/BK_COMMON/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_melding.php
2018-01-03 10:13:57 UTC (rev 17485)
@@ -0,0 +1,253 @@
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2016 Free Software Foundation, Inc.
http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
+ * @package property
+ * @subpackage helpdesk
+ * @version $Id$
+ */
+ /**
+ * Description
+ * @package property
+ */
+ //if (false)
+ if (!empty($data['order_id']) && !empty($data['send_order']) &&
!empty($data['vendor_email'][0]))
+ {
+ $exporter_ordre = new lag_agresso_ordre_fra_melding();
+ $data['purchase_grant_error'] = $exporter_ordre->transfer($id)
== 3 ? true : false;
+ $data['purchase_grant_checked'] = true;
+ }
+
+ class lag_agresso_ordre_fra_melding
+ {
+
+ var $debug = true;
+ function __construct()
+ {
+
+ }
+
+ public function transfer( $id )
+ {
+ $_ticket = ExecMethod('property.sotts.read_single',
$id);
+ if (!$this->debug && $_ticket['order_sent'])
+ {
+ return 2;
+ }
+
+ $price = 0;
+ $budgets = ExecMethod('property.botts.get_budgets',$id);
+ foreach ($budgets as $budget)
+ {
+
+ $price += $budget['amount'];
+ }
+
+ try
+ {
+ $purchase_grant_ok =
CreateObject('property.botts')->validate_purchase_grant( $_ticket['ecodimb'],
$price, $_ticket['order_id'] );
+ }
+ catch (Exception $ex)
+ {
+ throw $ex;
+ }
+
+ if (!$this->debug && !$purchase_grant_ok)
+ {
+ return 3;
+ }
+ // _debug_array($_ticket);die();
+
+ $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' =>
$_ticket['vendor_id']), $vendor_data);
+ if (is_array($vendor_data))
+ {
+ foreach ($vendor_data['attributes'] as
$attribute)
+ {
+ if ($attribute['name'] == 'adresse')
+ {
+ $vendor['address'] =
$attribute['value'];
+ }
+ if ($attribute['name'] == 'org_name')
+ {
+ $vendor['name'] =
$attribute['value'];
+ }
+ }
+ }
+ unset($contacts);
+
+
+ if (phpgw::get_var('on_behalf_of_assigned', 'bool') &&
isset($_ticket['assignedto_name']))
+ {
+ $user_name = $_ticket['assignedto_name'];
+
$GLOBALS['phpgw']->preferences->set_account_id($_ticket['assignedto'], true);
+ $GLOBALS['phpgw_info']['user']['preferences'] =
$GLOBALS['phpgw']->preferences->data;
+ $account_lid =
$GLOBALS['phpgw']->accounts->id2lid($_ticket['assignedto']);
+ }
+ else
+ {
+ $user_name =
$GLOBALS['phpgw_info']['user']['fullname'];
+ $account_lid =
$GLOBALS['phpgw_info']['user']['account_lid'];
+ }
+ // $ressursnr =
$GLOBALS['phpgw_info']['user']['preferences']['property']['ressursnr'];
+
+ $address =
mb_substr(htmlspecialchars($_ticket['address'], ENT_QUOTES, 'UTF-8', true), 0,
50);
+
+
+ $buyer = array(
+ 'Name' => $user_name,
+ 'AddressInfo' => array(
+ array(
+ 'Address' =>
htmlspecialchars_decode($address, ENT_QUOTES)
+ )
+ ),
+ 'BuyerReferences' => array(
+ array(
+ 'Responsible' =>
strtoupper($account_lid),
+ 'RequestedBy' =>
strtoupper($account_lid),
+ 'Accountable' =>
strtoupper($account_lid),
+ )
+ )
+ );
+ if ($_ticket['location_data'])
+ {
+ $dim3 =
isset($_ticket['location_data']['loc2']) && $_ticket['location_data']['loc2'] ?
"{$_ticket['location_data']['loc1']}{$_ticket['location_data']['loc2']}" :
"{$_ticket['location_data']['loc1']}01";
+ }
+ else
+ {
+ $dim3 = 9;
+ }
+
+ if($dim3 == 9999)
+ {
+ $dim3 = 9;
+ }
+
+ $dim6 = 9;
+
+ //Override from order
+ $tax_code = $_ticket['tax_code'] ? $_ticket['tax_code']
: 0;
+ switch ($tax_code)
+ {
+ case '0':
+ $tax_code = '6A';
+ break;
+ case '75':
+ $tax_code = '60';
+ break;
+ default:
+ $tax_code = '6A';
+ break;
+ }
+
+ if ($_ticket['order_dim1'])
+ {
+ $sogeneric = CreateObject('property.sogeneric',
'order_dim1');
+ $sogeneric_data =
$sogeneric->read_single(array('id' => $_ticket['order_dim1']));
+ if ($sogeneric_data)
+ {
+ $dim6 =
"{$_ticket['building_part']}{$sogeneric_data['num']}";
+ }
+ }
+ /*
+ 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
+ */
+
+
+ if($_ticket['order_id'] >= 45000000 &&
$_ticket['order_id'] <= 45249999)
+ {
+ $voucher_type = 'P3';
+ }
+ else if ($_ticket['order_id'] >= 45250000 &&
$_ticket['order_id'] <= 45499999)
+ {
+ $voucher_type = 'P4';
+ }
+ else
+ {
+ throw new Exception("Ordrenummer
'{$_ticket['order_id']}' er utenfor serien:<br/>" . __FILE__ . '<br/>linje:' .
__LINE__);
+ }
+
+
+ $param = array(
+ 'voucher_type' => $voucher_type,
+ 'dim0' => $_ticket['b_account_id'],
// Art
+ 'dim1' => $_ticket['ecodimb'],
// Ansvar
+ 'dim2' => $_ticket['service_id'] ?
$_ticket['service_id'] : 9, // Tjeneste liste 30 stk, default 9
+ 'dim3' => $dim3,
// Objekt: eiendom + bygg: 6 siffer
+ 'dim4' => $_ticket['contract_id'] == '-1' ? ''
: $_ticket['contract_id'], // Kontrakt - frivillig / 9, 7 tegn - alfanumerisk
+ 'dim5' => $_ticket['external_project_id'],
// Prosjekt
+ 'dim6' => $dim6,
// Aktivitet - frivillig: bygningsdel, 3 siffer +
bokstavkode
+ 'vendor_id' => $_ticket['vendor_id'],
+ 'vendor_name' => $vendor['name'],
+ 'vendor_address' =>
mb_substr($vendor['address'], 0, 50),
+ 'order_id' => $_ticket['order_id'],
+ 'tax_code' => $tax_code,
+ 'buyer' => $buyer,
+ 'lines' => array(
+ array(
+ 'unspsc_code' =>
$_ticket['unspsc_code'] ? $_ticket['unspsc_code'] : 'UN-72000000',
+ 'descr' => '',
+ 'price' => $price,
+ )
+ )
+ );
+
+ $exporter_ordre = new
BkBygg_exporter_data_til_Agresso(array(
+ 'order_id' => $_ticket['order_id'],
+ 'voucher_type' => $voucher_type
+ )
+ );
+ $exporter_ordre->create_transfer_xml($param);
+
+ $export_ok = $exporter_ordre->transfer($this->debug);
+
+ if ($export_ok)
+ {
+ phpgwapi_cache::message_set("Ordre
#{$_ticket['order_id']} er overført");
+ $this->log_transfer( $id );
+ }
+ }
+
+ private function log_transfer( $id )
+ {
+ $historylog = CreateObject('property.historylog',
'tts');
+ $historylog->add('RM', $id, "Ordre overført til
agresso");
+ $now = time();
+ $GLOBALS['phpgw']->db->query("UPDATE fm_tts_tickets SET
order_sent = {$now} WHERE id = {$id}");
+ }
+
+ private function get_unspsc_code_descr( $unspsc_code )
+ {
+ $GLOBALS['phpgw']->db->query("SELECT name FROM
fm_unspsc_code WHERE id = '{$unspsc_code}'");
+ $GLOBALS['phpgw']->db->next_record();
+ return $GLOBALS['phpgw']->db->f('name');
+ }
+ }
\ No newline at end of file
Copied:
thirdparty/PE_custom/BK_COMMON/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php
(from rev 17484,
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php)
===================================================================
---
thirdparty/PE_custom/BK_COMMON/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php
(rev 0)
+++
thirdparty/PE_custom/BK_COMMON/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php
2018-01-03 10:13:57 UTC (rev 17485)
@@ -0,0 +1,351 @@
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2016 Free Software Foundation, Inc.
http://www.fsf.org/
+ * This file is part of phpGroupWare.
+ *
+ * phpGroupWare is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
+ * @package property
+ * @subpackage helpdesk
+ * @version $Id$
+ */
+ /**
+ * Description
+ * @package property
+ */
+
+ if (!class_exists("lag_agresso_ordre_fra_workorder"))
+ {
+ class lag_agresso_ordre_fra_workorder
+ {
+ var $debug = false;
+
+ public function __construct()
+ {
+ $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;
+ }
+
+ public function transfer( $workorder )
+ {
+ $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;
+ }
+
+ $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')
+ {
+ $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;
+
+ }
+
+ try
+ {
+ $purchase_grant_ok =
CreateObject('property.botts')->validate_purchase_grant( $workorder['ecodimb'],
$approval_amount, $workorder['id']);
+ }
+ catch (Exception $ex)
+ {
+ throw $ex;
+ }
+
+ if (!$this->debug && !$purchase_grant_ok)
+ {
+ 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)
+ {
+ if ($attribute['name'] ==
'adresse')
+ {
+ $vendor['address'] =
$attribute['value'];
+ }
+ if ($attribute['name'] ==
'org_name')
+ {
+ $vendor['name'] =
$attribute['value'];
+ }
+ }
+ }
+ unset($contacts);
+
+
$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']);
+
+
+ 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];
+
+ }
+ 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;
+ }
+
+ if($dim3 == 9999)
+ {
+ $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 = '';
+ if ($_address)
+ {
+ $address = implode(', ', $_address);
+ }
+
+ $address = mb_substr(htmlspecialchars($address,
ENT_QUOTES, 'UTF-8', true), 0, 50);
+
+ $buyer = array(
+ 'Name' => $user_name,
+ 'AddressInfo' => array(
+ array(
+ 'Address' =>
htmlspecialchars_decode($address, ENT_QUOTES)
+ )
+ ),
+ 'BuyerReferences' => array(
+ array(
+ 'Responsible' =>
strtoupper($account_lid),
+ 'RequestedBy' =>
strtoupper($account_lid),
+ 'Accountable' =>
strtoupper($account_lid),
+ )
+ )
+ );
+
+
+ //EBF...
+
+ $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)
+ {
+ if ($attribute['name'] == 'mva')
+ {
+ $tax_code =
$attribute['value'];
+ $_found ++;
+ }
+ if ($attribute['name'] ==
'kostra_id')
+ {
+ $tjeneste =
$attribute['value'];
+ $_found ++;
+ }
+ if ($_found == 2)
+ {
+ 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'] ?
(int)$workorder['service_id'] : (int)$tjeneste;
+
+ $GLOBALS['phpgw']->db->query("UPDATE
fm_workorder SET service_id = {$tjeneste} WHERE id = {$workorder['id']}");
+
+ // _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 = true;
+ }
+ }
+
+ if ($collect_building_part)
+ {
+ if ($workorder['order_dim1'])
+ {
+ $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]);
+ }
+
+ /*
+ 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';
+
+ 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'] ==
'-1' ? '' : $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' =>
mb_substr($vendor['address'], 0, 50),
+ '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);
+
+ $export_ok =
$exporter_ordre->transfer($this->debug);
+
+ if ($export_ok)
+ {
+ phpgwapi_cache::message_set("Ordre
#{$workorder['id']} er overført");
+ $this->log_transfer( $workorder['id'] );
+ }
+ }
+
+ private function log_transfer( $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}");
+ }
+ }
+ }
+
+ if (!empty($transfer_action) && $transfer_action == 'workorder')
+ {
+ $exporter_ordre = new lag_agresso_ordre_fra_workorder();
+ try
+ {
+ $exporter_ordre->transfer($workorder);
+ }
+ catch (Exception $exc)
+ {
+ phpgwapi_cache::message_set($exc->getMessage(),
'error');
+ }
+ }
Modified: thirdparty/PE_custom/BK_EBE/svn_full_checkout.php
===================================================================
--- thirdparty/PE_custom/BK_EBE/svn_full_checkout.php 2018-01-03 09:35:11 UTC
(rev 17484)
+++ thirdparty/PE_custom/BK_EBE/svn_full_checkout.php 2018-01-03 10:13:57 UTC
(rev 17485)
@@ -113,6 +113,10 @@
$pe_custom = array();
+ $pe_custom['BK_COMMON'] = array
+ (
+ array('property', '')
+ );
$pe_custom['BK_EBE'] = array
(
array('property', '')
Deleted:
thirdparty/PE_custom/BK_EBF/property/inc/cron/default/oppdater_betalte_faktura_BK.php
===================================================================
---
thirdparty/PE_custom/BK_EBF/property/inc/cron/default/oppdater_betalte_faktura_BK.php
2018-01-03 09:35:11 UTC (rev 17484)
+++
thirdparty/PE_custom/BK_EBF/property/inc/cron/default/oppdater_betalte_faktura_BK.php
2018-01-03 10:13:57 UTC (rev 17485)
@@ -1,243 +0,0 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software
Foundation, Inc. http://www.fsf.org/
- * This file is part of phpGroupWare.
- *
- * phpGroupWare is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * phpGroupWare is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpGroupWare; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
- *
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
- * @package property
- * @subpackage cron
- * @version $Id: oppdater_betalte_faktura_BK.php 16075 2016-12-12
15:26:41Z sigurdne $
- */
- /**
- * Description
- * example cron : /usr/local/bin/php -q
/var/www/html/phpgroupware/property/inc/cron/cron.php default
oppdater_betalte_faktura_BK
- * @package property
- */
- include_class('property', 'cron_parent', 'inc/cron/');
- phpgw::import_class('phpgwapi.datetime');
-
- class oppdater_betalte_faktura_BK extends property_cron_parent
- {
-
- public function __construct()
- {
- parent::__construct();
-
- $this->function_name = get_class($this);
- $this->sub_location = lang('property');
- $this->function_msg = 'oppdater bestillinger med
grunnlag i betalte faktura';
- /**
- * Bruker konffigurasjon fra '.ticket' - fordi denne
definerer oppslaget mot fullmaktsregisteret ved bestilling.
- */
- $config =
CreateObject('admin.soconfig', $GLOBALS['phpgw']->locations->get_id('property',
'.ticket'));
- $this->soap_url =
$config->config_data['external_register']['url'];
- $this->soap_username =
$config->config_data['external_register']['username'];
- $this->soap_password =
$config->config_data['external_register']['password'];
- }
-
- function execute()
- {
- $start = time();
-
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/art
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/ansvar?id=013000
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/objekt?id=5001
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/prosjekt?id=5001
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/tjeneste?id=88010
-
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/leverandorer?leverandorNr=722920
- if ($this->debug)
- {
- }
- set_time_limit(2000);
-
- try
- {
- $this->update_order();
- }
- catch (Exception $e)
- {
- $this->receipt['error'][] = array('msg' =>
$e->getMessage());
- }
-
- $msg = 'Tidsbruk: ' . (time() - $start) . ' sekunder';
- $this->cron_log($msg, $cron);
- echo "$msg\n";
- $this->receipt['message'][] = array('msg' => $msg);
-
- }
-
- function cron_log( $receipt = '' )
- {
-
- $insert_values = array(
- $this->cron,
- date($this->db->datetime_format()),
- $this->function_name,
- $receipt
- );
-
- $insert_values =
$this->db->validate_insert($insert_values);
-
- $sql = "INSERT INTO fm_cron_log
(cron,cron_date,process,message) "
- . "VALUES ($insert_values)";
- $this->db->query($sql, __LINE__, __FILE__);
- }
-
- private function update_order()
- {
- $config = CreateObject('phpgwapi.config',
'property')->read();
- $sql = "SELECT DISTINCT pmwrkord_code,
external_voucher_id FROM fm_ecobilag";
- $this->db->query($sql, __LINE__, __FILE__);
- $vouchers = array();
- while ($this->db->next_record())
- {
- $vouchers[] = array
- (
- 'order_id' =>
$this->db->f('pmwrkord_code'),
- 'voucher_id' =>
$this->db->f('external_voucher_id')
- );
- }
-
- $socommon = CreateObject('property.socommon');
- $soworkorder = CreateObject('property.soworkorder');
- $sotts = CreateObject('property.sotts');
- $workorder_closed_status =
!empty($config['workorder_closed_status']) ? $config['workorder_closed_status']
: false;
-
- if(!$workorder_closed_status)
- {
- throw new Exception('Order closed status not
defined');
- }
-
- $vouchers_ok = array();
- foreach ($vouchers as $voucher)
- {
-
if(!$this->check_payment($voucher['voucher_id']))
- {
- $this->receipt['error'][] = array('msg'
=> "{$voucher['voucher_id']} er ikke betalt");
- continue;
- }
-
- $this->receipt['message'][] = array('msg' =>
"{$voucher['voucher_id']} er betalt");
-
- $ok = false;
- $order_type =
$socommon->get_order_type($voucher['order_id']);
- switch ($order_type)
- {
- case 's_agreement':
- break;
- case 'workorder':
- $workorder =
$soworkorder->read_single($voucher['order_id']);
- if($workorder['continuous'])
- {
- $ok = true;
- }
- else
- {
- $ok =
$soworkorder->update_status(array('order_id' => $voucher['order_id'],'status'
=> $workorder_closed_status));
- }
- break;
- case 'ticket':
- $this->db->query("SELECT id,
continuous FROM fm_tts_tickets WHERE order_id= '{$voucher['order_id']}'",
__LINE__, __FILE__);
- $this->db->next_record();
- $ticket_id = $this->db->f('id');
-
- if($this->db->f('continuous'))
- {
- $ok = true;
- }
- else
- {
- $ticket = array(
-
'status' => 'C8' //Avsluttet og fakturert (C)
- );
- $ok =
$sotts->update_status($ticket, $ticket_id);
- }
- break;
- default:
- throw new Exception('Order type
not supported');
- }
-
- if($ok)
- {
- $vouchers_ok[] = $voucher;
- // $i = 60;
- }
-
- }
- unset($voucher);
-
- $metadata = $this->db->metadata('fm_ecobilag');
- $cols = array_keys($metadata);
- foreach ($vouchers_ok as $voucher)
- {
- $this->db->transaction_begin();
- $value_set = array();
- $this->db->query("SELECT * FROM fm_ecobilag
WHERE external_voucher_id= '{$voucher['voucher_id']}'", __LINE__, __FILE__);
- $this->db->next_record();
- foreach ($cols as $col)
- {
- $value_set[$col] = $this->db->f($col);
- }
- $value_set['filnavn'] = date('d.m.Y-H:i:s',
phpgwapi_datetime::user_localtime());
- $value_set['ordrebelop'] = $value_set['belop'];
- unset($value_set['pre_transfer']);
-
- $_cols = implode(',', array_keys($value_set));
- $values =
$this->db->validate_insert(array_values($value_set));
- $this->db->query("INSERT INTO fm_ecobilagoverf
({$_cols}) VALUES ({$values})", __LINE__, __FILE__);
- $this->db->query("DELETE FROM fm_ecobilag WHERE
external_voucher_id= '{$voucher['voucher_id']}'", __LINE__, __FILE__);
- $this->db->transaction_commit();
- $this->receipt['message'][] = array('msg' =>
"{$voucher['voucher_id']} er overført til historikk");
- }
- }
-
- function check_payment( $voucher_id )
- {
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/utlignetfaktura?bilagsNr=917039148
- $url =
"{$this->soap_url}/utlignetfaktura?bilagsNr={$voucher_id}";
- $username = $this->soap_username; //'portico';
- $password = $this->soap_password;
//'BgPor790gfol';
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_USERPWD,
"{$username}:{$password}");
- curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json'));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
-
- $result = curl_exec($ch);
-
- $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- if(!$httpCode)
- {
- throw new Exception("No connection: {$url}");
- }
- curl_close($ch);
-
- $result = json_decode($result, true);
-
- return $result;
-
- }
-
- }
Deleted:
thirdparty/PE_custom/BK_EBF/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
===================================================================
---
thirdparty/PE_custom/BK_EBF/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
2018-01-03 09:35:11 UTC (rev 17484)
+++
thirdparty/PE_custom/BK_EBF/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
2018-01-03 10:13:57 UTC (rev 17485)
@@ -1,891 +0,0 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software
Foundation, Inc. http://www.fsf.org/
- * This file is part of phpGroupWare.
- *
- * phpGroupWare is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * phpGroupWare is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpGroupWare; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
- *
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
- * @package property
- * @subpackage cron
- * @version $Id$
- */
- /**
- * Description
- * example cron : /usr/local/bin/php -q
/var/www/html/phpgroupware/property/inc/cron/cron.php default
synkroniser_avdelinger_med_fellesdata
- * @package property
- */
- include_class('property', 'cron_parent', 'inc/cron/');
-
- class synkroniser_avdelinger_med_fellesdata extends property_cron_parent
- {
-
- public function __construct()
- {
- parent::__construct();
-
- $this->function_name = get_class($this);
- $this->sub_location = lang('property');
- $this->function_msg = 'Synkroniser avdelinger med
Fellesdata';
- }
-
- function execute()
- {
- $fellesdata = new property_fellesdata();
-
- $fellesdata->set_debug($this->debug);
-
- /*
- * ansvar
- * art
- * objekt
- * prosjekt
- * tjeneste
- */
- if
(isset($GLOBALS['phpgw_info']['user']['apps']['rental']))
- {
- $fellesdata->update_customer_id();
- }
- $fellesdata->update_vendor();
- // $fellesdata->update_agresso_prosjekt(); //for mange
treff
- // $fellesdata->update_art();
//for mange treff
- // $fellesdata->update_tjeneste();
- // $fellesdata->update_dimb(); // ansvar, or mange treff
- $fellesdata->get_org_unit_ids_from_top();
-
-
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/art
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/ansvar?id=013000
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/objekt?id=5001
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/prosjekt?id=5001
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/tjeneste?id=88010
-
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/leverandorer?leverandorNr=722920
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/kundeinfo?organisasjonsnummer="998391407"
-
-
- if ($this->debug)
- {
- _debug_array($fellesdata->unit_ids);
- }
-
- try
- {
- $fellesdata->insert_values();
-
- if
(isset($GLOBALS['phpgw_info']['user']['apps']['rental']))
- {
- $this->update_rental_party();
- }
- }
- catch (Exception $e)
- {
- $this->receipt['error'][] = array('msg' =>
$e->getMessage());
- }
-
- $messages = $fellesdata->messages;
- foreach ($messages as $message)
- {
- $this->receipt['message'][] = array('msg' =>
$message);
- }
- }
-
- private function update_rental_party()
- {
- $sogeneric = CreateObject('property.sogeneric');
- $sql = "SELECT DISTINCT org_enhet_id FROM rental_party
WHERE org_enhet_id IS NOT NULL";
- $this->db->query($sql, __LINE__, __FILE__);
- $parties = array();
- while ($this->db->next_record())
- {
- $parties[] = $this->db->f('org_enhet_id');
- }
-
- foreach ($parties as $party)
- {
- $sql = "SELECT name, parent_id FROM fm_org_unit
WHERE id = {$party}";
- $this->db->query($sql, __LINE__, __FILE__);
- if ($this->db->next_record())
- {
- $name = $this->db->f('name');
- $parent_id = $this->db->f('parent_id');
- $path =
$sogeneric->get_path(array('type' => 'org_unit', 'id' => $parent_id));
- $parent_name = implode(' > ', $path);
-
- $value_set = array
- (
- 'company_name' => $name,
- 'department' =>
$this->db->db_addslashes($parent_name)
- );
-
- $value_set =
$this->db->validate_update($value_set);
- $sql = "UPDATE rental_party SET
{$value_set} WHERE org_enhet_id ={$party}";
-
- $this->db->query($sql, __LINE__,
__FILE__);
- if ($this->debug)
- {
- $this->receipt['message'][] =
array('msg' => $sql);
- }
- }
- }
- }
- }
-
- class property_fellesdata
- {
-
- // Instance variable
- protected static $bo;
- protected $connected = false;
- protected $status;
- protected $db = null;
- protected $unit_ids = array();
- protected $names = array();
- protected $messages = array();
- protected $debug = false;
-
- private $soap_url,
- $soap_username,
- $soap_password;
-
- function __construct()
- {
- /**
- * Bruker konffigurasjon fra '.ticket' - fordi denne
definerer oppslaget mot fullmaktsregisteret ved bestilling.
- */
- $config =
CreateObject('admin.soconfig', $GLOBALS['phpgw']->locations->get_id('property',
'.ticket'));
- $this->soap_url =
$config->config_data['external_register']['url'];
- $this->soap_username =
$config->config_data['external_register']['username'];
- $this->soap_password =
$config->config_data['external_register']['password'];
-
- $this->config = CreateObject('admin.soconfig',
$GLOBALS['phpgw']->locations->get_id('property', '.admin'));
-
- if (!isset($this->config->config_data['fellesdata']) ||
!$this->config->config_data['fellesdata'])
- {
- $this->initiate_config();
- }
- }
-
- public function set_debug( $debug )
- {
- $this->debug = $debug;
- }
-
- private function initiate_config()
- {
- $receipt_section = $this->config->add_section(array
- (
- 'name' => 'fellesdata',
- 'descr' => 'Fellesdata'
- )
- );
-
- $receipt = $this->config->add_attrib(array
- (
- 'section_id' => $receipt_section['section_id'],
- 'input_type' => 'text',
- 'name' => 'host',
- 'descr' => 'Host'
- )
- );
- $receipt = $this->config->add_attrib(array
- (
- 'section_id' => $receipt_section['section_id'],
- 'input_type' => 'text',
- 'name' => 'port',
- 'descr' => 'Port'
- )
- );
- $receipt = $this->config->add_attrib(array
- (
- 'section_id' => $receipt_section['section_id'],
- 'input_type' => 'text',
- 'name' => 'db_name',
- 'descr' => 'Database'
- )
- );
- $receipt = $this->config->add_attrib(array
- (
- 'section_id' => $receipt_section['section_id'],
- 'input_type' => 'text',
- 'name' => 'user',
- 'descr' => 'User'
- )
- );
- $receipt = $this->config->add_attrib(array
- (
- 'section_id' => $receipt_section['section_id'],
- 'input_type' => 'password',
- 'name' => 'password',
- 'descr' => 'Password'
- )
- );
- $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'admin.uiconfig2.list_attrib',
- 'section_id' => $receipt_section['section_id'],
'location_id' => $GLOBALS['phpgw']->locations->get_id('property', '.admin')));
- }
-
- /**
- * Magic get method
- *
- * @param string $varname the variable to fetch
- *
- * @return mixed the value of the variable sought - null if not
found
- */
- public function __get( $varname )
- {
- switch ($varname)
- {
- case 'unit_ids':
- return $this->unit_ids;
- break;
- case 'names':
- return $this->names;
- break;
- case 'messages':
- return $this->messages;
- break;
- default:
- return null;
- }
- }
- /* our simple php ping function */
-
- function ping( $host )
- {
- exec(sprintf('ping -c 1 -W 5 %s',
escapeshellarg($host)), $res, $rval);
- return $rval === 0;
- }
-
- public function get_db()
- {
- if ($this->db && is_object($this->db))
- {
- return $this->db;
- }
-
- if (!$this->config->config_data['fellesdata']['host']
|| !$this->ping($this->config->config_data['fellesdata']['host']))
- {
- $message = "Database server
{$this->config->config_data['fellesdata']['host']} is not accessible";
- phpgwapi_cache::message_set($message, 'error');
- return false;
- }
-
- $db = createObject('phpgwapi.db_adodb', null, null,
true);
- $db->debug = false;
- $db->Host =
$this->config->config_data['fellesdata']['host'];
- $db->Port =
$this->config->config_data['fellesdata']['port'];
- $db->Type = 'oracle';
- $db->Database =
$this->config->config_data['fellesdata']['db_name'];
- $db->User =
$this->config->config_data['fellesdata']['user'];
- $db->Password =
$this->config->config_data['fellesdata']['password'];
-
- try
- {
- $db->connect();
- $this->connected = true;
- }
- catch (Exception $e)
- {
- $status = lang('unable_to_connect_to_database');
- }
-
- $this->db = $db;
- return $db;
- }
-
- public function insert_values()
- {
- $table = 'fm_org_unit';
-
- $db = & $GLOBALS['phpgw']->db;
- $db->transaction_begin();
- $db->query("UPDATE {$table} SET active = 0", __LINE__,
__FILE__);
- $units = $this->unit_ids;
-// _debug_array($units);
- foreach ($units as $unit)
- {
- $value_set = array(
- 'id' => $unit['id'],
- 'parent_id' => $unit['parent'],
- 'name' =>
$db->db_addslashes($unit['name']),
- 'arbeidssted' => $unit['arbeidssted'],
- 'created_on' => time(),
- 'created_by' =>
$GLOBALS['phpgw_info']['user']['account_id'],
- 'modified_by' =>
$GLOBALS['phpgw_info']['user']['account_id'],
- 'modified_on' => time()
- );
-
- $db->query("SELECT count(*) as cnt FROM
{$table} WHERE id =" . (int)$unit['id'], __LINE__, __FILE__);
- $db->next_record();
-
- if ($db->f('cnt'))
- {
- unset($value_set['id']);
- unset($value_set['created_on']);
-
- $value_set['active'] = 1;
- $value_set =
$db->validate_update($value_set);
- $sql = "UPDATE {$table} SET
{$value_set} WHERE id =" . (int)$unit['id'];
- if ($this->debug)
- {
- $this->messages[] = "ID finnes
fra før: {$unit['id']}, oppdaterer: {$unit['name']}";
- $this->messages[] = $sql;
- }
- }
- else
- {
- $cols = implode(',',
array_keys($value_set));
- $values =
$db->validate_insert(array_values($value_set));
- $sql = "INSERT INTO {$table} ({$cols})
VALUES ({$values})";
- if ($this->debug)
- {
- $this->messages[] = "ID fantes
ikke fra før: {$unit['id']}, legger til: {$unit['name']}";
- $this->messages[] = $sql;
- }
- }
-
- $db->query($sql, __LINE__, __FILE__);
- }
-
- $db->transaction_commit();
- }
-
- function update_customer_id( )
- {
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/kundeinfo?organisasjonsnummer="998391407"
- $sql = "SELECT id, identifier FROM rental_party"
- . " WHERE (customer_id = 0 OR customer_id IS
NULL)"
- . " AND (length(identifier) = 9 OR
length(identifier) = 11)";
-
- $GLOBALS['phpgw']->db->query($sql, __LINE__, __FILE__);
-
- $parties = array();
- while ($GLOBALS['phpgw']->db->next_record())
- {
- $parties[] = array(
- 'id' =>
$GLOBALS['phpgw']->db->f('id'),
- 'identifier' =>
$GLOBALS['phpgw']->db->f('identifier')
- );
- }
-
- foreach ($parties as $party)
- {
- // $this->soap_url=
'http://tjenester.usrv.ubergenkom.no/api/agresso'; //test url
- $url =
"{$this->soap_url}/kundeinfo?organisasjonsnummer='{$party['identifier']}'";
- $values = array();
- try
- {
- $values =
$this->check_external_register($url);
- }
- catch (Exception $exc)
- {
- echo $exc->getTraceAsString();
- }
-
- if(!empty($values[0]['kundenr']))
- {
- $customer_id =
(int)$values[0]['kundenr'];
- $sql = "UPDATE rental_party"
- . " SET customer_id =
{$customer_id}"
- . " WHERE id = " .
(int)$party['id'];
- // _debug_array($sql);
- $GLOBALS['phpgw']->db->query($sql,
__LINE__, __FILE__);
- }
- }
- }
-
- /*
- * ansvar
- * art
- * objekt
- * prosjekt
- * tjeneste
- */
- function update_agresso_prosjekt()
- {
- //det er for mange...16396 stk...
- //return;
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/prosjekt
-
-// $url =
'http://tjenester.usrv.ubergenkom.no/api/agresso/prosjekt';
- $url = "{$this->soap_url}/prosjekt";
- $values = array();
- try
- {
- $values = $this->check_external_register($url);
-
- }
- catch (Exception $exc)
- {
- echo $exc->getTraceAsString();
- }
-/**
- [tab] => A
- [dimValue] => A00001
- [description] => ADM.BYGG VEDTATT BUDSJETT 2001
- [periodFrom] => 200612
- [periodTo] => 209912
- [status] => N
-
- */
- if($values)
- {
- $GLOBALS['phpgw']->db->query("UPDATE
fm_external_project SET active = 0" , __LINE__, __FILE__);
- }
-
- foreach ($values as $entry)
- {
- $active = $entry['status'] == 'C' ? 0 : 1;
- $GLOBALS['phpgw']->db->query("SELECT id FROM
fm_external_project WHERE id ='{$entry['dimValue']}'", __LINE__, __FILE__);
- if($GLOBALS['phpgw']->db->next_record())
- {
- $sql = "UPDATE fm_external_project SET
name = '{$entry['dimValue']} {$entry['description']}', active = {$active} WHERE
id = '{$entry['dimValue']}'";
- }
- else
- {
- $name =
$GLOBALS['phpgw']->db->db_addslashes("{$entry['dimValue']}
{$entry['description']}");
- $sql = "INSERT INTO fm_external_project
(id, name, active)"
- . " VALUES
('{$entry['dimValue']}', '{$name}', {$active})";
- }
- $GLOBALS['phpgw']->db->query($sql, __LINE__,
__FILE__);
- }
-
- }
- function update_art()
- {
- //det er for mange...
- return;
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/art
-
-// $url =
'http://tjenester.usrv.ubergenkom.no/api/agresso/art';
- $url = "{$this->soap_url}/art";
- $values = array();
- try
- {
- $values = $this->check_external_register($url);
-
- }
- catch (Exception $exc)
- {
- echo $exc->getTraceAsString();
- }
-
- }
-
- function update_tjeneste()
- {
- //det er for mange...
- return;
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/tjeneste?id=88010
- //fm_eco_service
-
-// $url =
'http://tjenester.usrv.ubergenkom.no/api/agresso/tjeneste';
- $url = "{$this->soap_url}/tjeneste";
- $values = array();
- try
- {
- $values = $this->check_external_register($url);
-
- }
- catch (Exception $exc)
- {
- echo $exc->getTraceAsString();
- }
-// [tab] => A
-// [dimValue] => 19050
-// [description] => Renholdstjenester
-// [periodFrom] => 200200
-// [periodTo] => 209912
-// [status] => N
-
- if($values)
- {
- $GLOBALS['phpgw']->db->query("UPDATE
fm_eco_service SET active = 0" , __LINE__, __FILE__);
- }
-
- foreach ($values as $entry)
- {
- $active = $entry['status'] == 'C' ? 0 : 1;
- $GLOBALS['phpgw']->db->query("SELECT id FROM
fm_eco_service WHERE id =" . (int) $entry['dimValue'], __LINE__, __FILE__);
- if($GLOBALS['phpgw']->db->next_record())
- {
- $sql = "UPDATE fm_eco_service SET name
= '{$entry['dimValue']} {$entry['description']}', active = {$active} WHERE id =
" . (int) $entry['dimValue'];
- }
- else
- {
- $sql = "INSERT INTO fm_eco_service (id,
name, active)"
- . " VALUES
({$entry['dimValue']}, '{$entry['dimValue']} {$entry['description']}',
{$active})";
- }
- $GLOBALS['phpgw']->db->query($sql, __LINE__,
__FILE__);
- }
- }
-
- function update_vendor()
- {
- if(empty($this->soap_password))
- {
- return;
- }
-
- $metadata =
$GLOBALS['phpgw']->db->metadata('fm_vendor_temp');
-//_debug_array($metadata);
- if (!$metadata)
- {
- $sql_table = <<<SQL
- CREATE TABLE fm_vendor_temp
- (
- id integer NOT NULL,
- status character varying(1),
- navn character varying(255),
- adresse character varying(255),
- postnummer character varying(50),
- sted character varying(50),
- organisasjonsnr character varying(50),
- bankkontonr character varying(50),
- aktiv integer,
- CONSTRAINT fm_vendor_temp_pkey PRIMARY KEY
(id)
- );
-SQL;
- $GLOBALS['phpgw']->db->query($sql_table,
__LINE__, __FILE__);
- }
- $GLOBALS['phpgw']->db->query('DELETE FROM
fm_vendor_temp', __LINE__, __FILE__);
-
- //curl -s -u portico:BgPor790gfol
http://tjenester.usrv.ubergenkom.no/api/agresso/leverandorer?leverandorNr=**
- //fm_vendor
-
-// $url =
'http://tjenester.usrv.ubergenkom.no/api/agresso/leverandorer?leverandorNr=**';
-// $url =
'http://tjenester.usrv.ubergenkom.no/api/agresso/leverandorer?leverandorNr=100304';
- $url = "{$this->soap_url}/leverandorer?leverandorNr=**";
-
- $error = false;
-
- $values = array();
- try
- {
- $values = $this->check_external_register($url);
- }
- catch (Exception $exc)
- {
- $error = true;
- echo $exc->getTraceAsString();
- }
-
- $GLOBALS['phpgw']->db->transaction_begin();
-
- $sql = 'INSERT INTO fm_vendor_temp (id, status, navn,
adresse, postnummer, sted, organisasjonsnr, bankkontonr, aktiv)'
- . ' VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)';
-
- //remove duplicates
-
- if(empty($values[0]['leverandornummer']))
- {
- _debug_array($values);
- $error = true;
- }
- $vendors = array();
- foreach ($values as $entry)
- {
- $vendors[$entry['leverandornummer']] = $entry;
- }
-
- unset($entry);
-// _debug_array($vendors);die();
-
- $valueset = array();
-
- foreach ($vendors as $key => $entry)
- {
- $valueset[] = array
- (
- 1 => array
- (
- 'value' =>
(int)$entry['leverandornummer'],
- 'type' => PDO::PARAM_INT
- ),
- 2 => array
- (
- 'value' => $entry['status'],
- 'type' => PDO::PARAM_STR
- ),
- 3 => array
- (
- 'value' => $entry['navn'],
- 'type' => PDO::PARAM_STR
- ),
- 4 => array
- (
- 'value' => $entry['adresse'],
- 'type' => PDO::PARAM_STR
- ),
- 5 => array
- (
- 'value' => $entry['postnummer'],
- 'type' => PDO::PARAM_STR
- ),
- 6 => array
- (
- 'value' => $entry['sted'],
- 'type' => PDO::PARAM_STR
- ),
- 7 => array
- (
- 'value' =>
$entry['organisasjonsNr'],
- 'type' => PDO::PARAM_STR
- ),
- 8 => array
- (
- 'value' =>
$entry['bankkontoNr'],
- 'type' => PDO::PARAM_STR
- ),
- 9 => array
- (
- 'value' => (int)$entry['aktiv'],
- 'type' => PDO::PARAM_INT
- )
- );
- }
-
- if($valueset && !$error)
- {
- $GLOBALS['phpgw']->db->insert($sql, $valueset,
__LINE__, __FILE__);
- }
-
-/*
- [leverandornummer] => 9906
- [status] => N
- [navn] => Bergen Vann KF (BV)
- [adresse] => Postboks 7700
- [postnummer] => 5020
- [sted] => BERGEN
- [organisasjonsNr] => 987328096
- [bankkontoNr] => 52020801786
- [aktiv] => 1
-*/
-// _debug_array($valueset);die();
-
-
- $sql = "SELECT fm_vendor_temp.*"
- . " FROM fm_vendor RIGHT OUTER JOIN
fm_vendor_temp ON (fm_vendor.id = fm_vendor_temp.id)"
- . " WHERE fm_vendor.id IS NULL";
-
- $GLOBALS['phpgw']->db->query($sql, __LINE__, __FILE__);
- $vendors = array();
- while ($GLOBALS['phpgw']->db->next_record())
- {
- $vendors[] = array(
- 1 => array(
- 'value' =>
(int)$GLOBALS['phpgw']->db->f('id'),
- 'type' => PDO::PARAM_INT
- ),
- 2 => array(
- 'value' =>
$GLOBALS['phpgw']->db->f('navn'),
- 'type' => PDO::PARAM_STR
- ),
- 3 => array(
- 'value' => 1,
- 'type' => PDO::PARAM_INT
- ),
- 4 => array(
- 'value' => 6,
- 'type' => PDO::PARAM_INT
- ),
- 5 => array(
- 'value' =>
(int)$GLOBALS['phpgw']->db->f('aktiv'),
- 'type' => PDO::PARAM_INT
- ),
- 6 => array(
- 'value' =>
$GLOBALS['phpgw']->db->f('adresse'),
- 'type' => PDO::PARAM_STR
- ),
- 7 => array(
- 'value' =>
$GLOBALS['phpgw']->db->f('postnummer'),
- 'type' => PDO::PARAM_STR
- ),
- 8 => array(
- 'value' =>
$GLOBALS['phpgw']->db->f('sted'),
- 'type' => PDO::PARAM_STR
- ),
- 9 => array(
- 'value' =>
$GLOBALS['phpgw']->db->f('organisasjonsnr'),
- 'type' => PDO::PARAM_STR
- ),
- 10 => array(
- 'value' =>
$GLOBALS['phpgw']->db->f('bankkontonr'),
- 'type' => PDO::PARAM_STR
- )
- );
- }
- $sql = 'INSERT INTO fm_vendor (id, org_name,category,
owner_id, active, adresse, postnr, poststed, org_nr, konto_nr)'
- . ' VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
- if($vendors)
- {
- $GLOBALS['phpgw']->db->insert($sql, $vendors,
__LINE__, __FILE__);
- }
-
- $GLOBALS['phpgw']->db->query("UPDATE fm_vendor SET
active = 0", __LINE__, __FILE__);
-
- $GLOBALS['phpgw']->db->query("UPDATE fm_vendor SET"
- . " active = 1,"
- . " org_name = fm_vendor_temp.navn,"
- . " adresse = fm_vendor_temp.adresse,"
- . " postnr = fm_vendor_temp.postnummer,"
- . " poststed = fm_vendor_temp.sted,"
- . " org_nr = fm_vendor_temp.organisasjonsnr"
- . " FROM fm_vendor_temp WHERE fm_vendor.id =
fm_vendor_temp.id", __LINE__, __FILE__);
-
- $GLOBALS['phpgw']->db->transaction_commit();
- }
-
- public function check_external_register($url)
- {
- $username = $this->soap_username;
- $password = $this->soap_password;
-
- /*Test server*/
-// $username = 'portico';
-// $password = 'BgPor790gfol';
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_USERPWD,
"{$username}:{$password}");
- curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json'));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
-
- $result = curl_exec($ch);
-
- $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- curl_close($ch);
-
- return json_decode($result, true);
- }
-
-
- /**
- * ansvar
- */
- function update_dimb()
- {
- if (!$db = $this->get_db())
- {
- return;
- }
-
- $sql = "SELECT V_ANSVAR.ANSVAR,
V_ANSVAR.BESKRIVELSE,V_ANSVAR.STATUS, V_ORG_ENHET.ORG_ENHET_ID"
- . " FROM V_ANSVAR JOIN V_ORG_ENHET ON
(V_ANSVAR.RESULTATENHET = V_ORG_ENHET.RESULTATENHET)";
-
- $db->query($sql, __LINE__, __FILE__);
- $values = array();
- while ($db->next_record())
- {
- $values[] = array(
- 'id' => (int)$db->f('ANSVAR'),
- 'descr' =>
$GLOBALS['phpgw']->db->db_addslashes($db->f('BESKRIVELSE', true)),
- 'active' => $db->f('STATUS') == 'C' ? 0
: 1,
- 'org_unit_id' =>
(int)$db->f('ORG_ENHET_ID')
- );
- }
-
- foreach ($values as $entry)
- {
- $GLOBALS['phpgw']->db->query("SELECT id FROM
fm_ecodimb WHERE id = {$entry['id']}", __LINE__, __FILE__);
- if($GLOBALS['phpgw']->db->next_record())
- {
- $sql = "UPDATE fm_ecodimb SET descr =
'{$entry['descr']}', active = {$entry['active']}, org_unit_id =
{$entry['org_unit_id']} WHERE id = {$entry['id']}";
- }
- else
- {
- $sql = "INSERT INTO fm_ecodimb (id,
descr, active, org_unit_id)"
- . " VALUES ({$entry['id']},
'{$entry['descr']}', {$entry['active']}, {$entry['org_unit_id']})";
- }
- $GLOBALS['phpgw']->db->query($sql, __LINE__,
__FILE__);
- }
- }
-
- function get_org_unit_ids_from_top()
- {
- if (!$db = $this->get_db())
- {
- return;
- }
-
- $sql = "SELECT ORG_ENHET_ID, V_ORG_ENHET.ORG_NAVN FROM
V_ORG_ENHET";
- $db->query($sql, __LINE__, __FILE__);
- while ($db->next_record())
- {
- $org_unit_id = $db->f('ORG_ENHET_ID');
- $name = $db->f('ORG_NAVN', true);
- $this->names[$org_unit_id] = $name;
- }
-// _debug_array($db);
-// _debug_array($this->names);die();
- $sql = "SELECT V_ORG_ENHET.ORG_ENHET_ID,
V_ORG_ENHET.ORG_NAVN, V_ORG_ENHET.TJENESTESTED, V_ORG_ENHET.ORG_NIVAA FROM
V_ORG_ENHET"
- . " WHERE V_ORG_ENHET.ORG_NIVAA = 1 ORDER BY
V_ORG_ENHET.ORG_NAVN ASC";
-
- $db->query($sql);
-
- while ($db->next_record())
- {
- $org_unit_id = $db->f('ORG_ENHET_ID');
- $arbeidssted = $db->f('TJENESTESTED');
- $this->unit_ids[] = array
- (
- 'id' => $org_unit_id,
- 'name' => $this->names[$org_unit_id],
- 'parent' => '',
- 'arbeidssted' => $arbeidssted
- );
-
- $this->get_org_unit_ids_children($org_unit_id);
- }
- return $this->unit_ids;
- }
-
- function get_org_unit_ids_children( $org_unit_id )
- {
- $org_unit_id = (int)$org_unit_id;
- $db = clone($this->db);
-
- $sql = "SELECT V_ORG_KNYTNING.*,
ANT_ENHETER_UNDER,V_ORG_ENHET.ORG_NAVN, V_ORG_ENHET.TJENESTESTED, ORG_NIVAA
FROM V_ORG_KNYTNING"
- . " JOIN V_ORG_ENHET ON
(V_ORG_ENHET.ORG_ENHET_ID = V_ORG_KNYTNING.ORG_ENHET_ID ) WHERE
V_ORG_KNYTNING.ORG_ENHET_ID_KNYTNING={$org_unit_id}";
-
- $db->query($sql);
-
- while ($db->next_record())
- {
- $child_org_unit_id = $db->f('ORG_ENHET_ID');
- $arbeidssted = $db->f('TJENESTESTED');
- $this->unit_ids[] = array(
- 'id' => $child_org_unit_id,
- 'name' =>
$this->names[$child_org_unit_id],
- 'parent' => $org_unit_id,
- 'level' => $db->f('ORG_NIVAA'),
- 'arbeidssted' => $arbeidssted,
- 'ant_enheter_under' =>
$db->f('ANT_ENHETER_UNDER')
- );
-
- if ($db->f('ANT_ENHETER_UNDER'))
- {
-
$this->get_org_unit_ids_children($child_org_unit_id);
- }
- }
-// unset($db);
- }
- }
\ No newline at end of file
Deleted:
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
===================================================================
---
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
2018-01-03 09:35:11 UTC (rev 17484)
+++
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_exporter_data_til_Agresso.php
2018-01-03 10:13:57 UTC (rev 17485)
@@ -1,490 +0,0 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2016 Free Software Foundation, Inc.
http://www.fsf.org/
- * This file is part of phpGroupWare.
- *
- * phpGroupWare is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * phpGroupWare is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpGroupWare; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
- *
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
- * @package property
- * @subpackage helpdesk
- * @version $Id$
- */
- /**
- * Description
- * @package property
- */
-
-
- /**
- * Description of BkBygg_exporter_data_til_Agresso
- *
- * @author Sigurd Nes
- */
- 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 $voucher_id;
- var $batchid;
- protected $global_lock = false;
-
-
- 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
- */
-
- $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(
- '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
- )
- );
-
- $Header = array(
- 'AcceptFlag' => 1,
- 'OrderType]' => 'WB',
- 'Status' => 'N',
- 'OrderDate' => date('Y-m-d'),
- 'Currency' => 'NOK',
- 'Seller' => array($Seller),
- 'Buyer' => array($param['buyer']),
- $DetailInfo
- );
-
- array_unshift($DetailInfo, array('TaxCode' =>
$param['tax_code']));
-
- $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
- );
-
- $i++;
- }
-
-
- $Orders['Order'][] = array(
- 'OrderNo' => $param['order_id'],
- 'VoucherType' => $this->voucher_type,
- 'TransType' => 41,
- 'Header' => array($Header),
- 'Details' => array('Detail' => $Detail)
- );
-
- // _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();
- }
-
- /**
- * Output the content of a current xml document.
- * @access public
- * @param null
- */
- public function output()
- {
- header('Content-type: text/xml');
- echo $this->transfer_xml;
- }
-
-
- protected function create_file_name( $ref = '' )
- {
- if (!$ref)
- {
- throw new
Exception('BkBygg_exporter_data_til_Agresso::create_file_name() Mangler
referanse');
- }
- $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))
- {
- unlink($filename);
- }
-
- 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
- {
- $file_written = false;
- $fp = fopen($filename, "wb");
- fwrite($fp, $content);
-
- if (fclose($fp))
- {
- $file_written = true;
- }
- else
- {
-
phpgwapi_cache::message_set("$filename feilet", 'error');
- }
- }
-
- $transfer_ok = false;
- if (!$debug &&
($this->config->config_data['common']['method'] == 'ftp' ||
$this->config->config_data['common']['method'] == 'ssh'))
- {
- if ($this->db->get_transaction())
- {
- $this->global_lock = true;
- }
- else
- {
- $this->db->transaction_begin();
- }
-
- if (!$connection = $this->connection)
- {
- $connection =
$this->phpftp_connect();
- }
-
- $basedir =
$this->config->config_data['export']['remote_basedir'];
- if ($basedir)
- {
- $remote_file = $basedir . '/' .
basename($filename);
- }
- else
- {
- $remote_file =
basename($filename);
- }
-
- switch
($this->config->config_data['common']['method'])
- {
- 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)));
- if (!$this->global_lock)
- {
-
$this->db->transaction_commit();
- }
- }
- else
- {
- if (!$this->global_lock)
- {
-
$this->db->transaction_abort(); // Reverse the batch_id - increment
- }
-
$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))
- {
- 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);
- }
- 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;
- }
- }
- }
-
- if (!class_exists("xml_creator"))
- {
- class xml_creator extends XMLWriter
- {
-
- /**
- * 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->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);
- }
- }
-
- /**
- * 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)
- {
- if (is_array($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->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();
- }
-
- /**
- * 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
Deleted:
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php
===================================================================
---
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php
2018-01-03 09:35:11 UTC (rev 17484)
+++
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_exporter_varemottak_til_Agresso.php
2018-01-03 10:13:57 UTC (rev 17485)
@@ -1,256 +0,0 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2016 Free Software Foundation, Inc.
http://www.fsf.org/
- * This file is part of phpGroupWare.
- *
- * phpGroupWare is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * phpGroupWare is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpGroupWare; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
- *
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
- * @package property
- * @subpackage helpdesk
- * @version $Id$
- */
- /**
- * Description
- * @package property
- */
- /**
- * Description of lag_agresso_varemottak
- *
- * @author Sigurd Nes
- */
-
- if (!class_exists("lag_agresso_varemottak"))
- {
- class lag_agresso_varemottak
- {
-
- private $acl_location;
- private $values;
- private $ordered_amount = 1;
- var $debug = true;
-
- function __construct( $acl_location, $id )
- {
- 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)
- {
-
- $amount += $budget['amount'];
- }
- return $amount ? $amount : 1;
- }
-
- 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();
-
- /*
- 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';
-
- 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(empty($this->values['continuous']))
- {
- $quantity = 1; // closing the order
- }
- else if($this->ordered_amount)
- {
- $quantity =
$received_amount/$this->ordered_amount;
- }
- else //should not happen, but just in case...
- {
- $quantity = 0.8;
- }
-
- $param = array(
- 'voucher_type' => $voucher_type,
- 'order_id' => $values['order_id'],
- 'lines' => array(
- array(
- 'UnitCode' => 'STK',
- 'Quantity' => $quantity,
- )
- )
- );
-
- $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 );
- }
- return $export_ok;
- }
-
- private function log_transfer( $id, $received_amount )
- {
- $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 = order_received_amount +
{$received_amount} WHERE id = {$id}");
- }
- }
- }
-
- 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;
-
- public function __construct( $param )
- {
- parent::__construct($param);
- }
-
- 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++;
- }
-
- $Orders['Order'][] = array(
- 'OrderNo' => $param['order_id'],
- 'VoucherType' => $param['voucher_type'],
- 'TransType' => 51,
- 'Details' => array('Detail' => $Detail)
- );
-
- // _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;
- }
-
- protected function create_file_name( $ref = '' )
- {
- 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'];
-
- $filename =
"{$fil_katalog}/{$voucher_type}_varemottak_{$order_id}_{$this->batchid}.xml";
-
- //Sjekk om filen eksisterer
- if (file_exists($filename))
- {
- unlink($filename);
- }
-
- return $filename;
- }
- }
- }
-
- if (!empty($id) && !empty($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);
- }
Deleted:
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_melding.php
===================================================================
---
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_melding.php
2018-01-03 09:35:11 UTC (rev 17484)
+++
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_melding.php
2018-01-03 10:13:57 UTC (rev 17485)
@@ -1,253 +0,0 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2016 Free Software Foundation, Inc.
http://www.fsf.org/
- * This file is part of phpGroupWare.
- *
- * phpGroupWare is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * phpGroupWare is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpGroupWare; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
- *
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
- * @package property
- * @subpackage helpdesk
- * @version $Id$
- */
- /**
- * Description
- * @package property
- */
- //if (false)
- if (!empty($data['order_id']) && !empty($data['send_order']) &&
!empty($data['vendor_email'][0]))
- {
- $exporter_ordre = new lag_agresso_ordre_fra_melding();
- $data['purchase_grant_error'] = $exporter_ordre->transfer($id)
== 3 ? true : false;
- $data['purchase_grant_checked'] = true;
- }
-
- class lag_agresso_ordre_fra_melding
- {
-
- var $debug = true;
- function __construct()
- {
-
- }
-
- public function transfer( $id )
- {
- $_ticket = ExecMethod('property.sotts.read_single',
$id);
- if (!$this->debug && $_ticket['order_sent'])
- {
- return 2;
- }
-
- $price = 0;
- $budgets = ExecMethod('property.botts.get_budgets',$id);
- foreach ($budgets as $budget)
- {
-
- $price += $budget['amount'];
- }
-
- try
- {
- $purchase_grant_ok =
CreateObject('property.botts')->validate_purchase_grant( $_ticket['ecodimb'],
$price, $_ticket['order_id'] );
- }
- catch (Exception $ex)
- {
- throw $ex;
- }
-
- if (!$this->debug && !$purchase_grant_ok)
- {
- return 3;
- }
- // _debug_array($_ticket);die();
-
- $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' =>
$_ticket['vendor_id']), $vendor_data);
- if (is_array($vendor_data))
- {
- foreach ($vendor_data['attributes'] as
$attribute)
- {
- if ($attribute['name'] == 'adresse')
- {
- $vendor['address'] =
$attribute['value'];
- }
- if ($attribute['name'] == 'org_name')
- {
- $vendor['name'] =
$attribute['value'];
- }
- }
- }
- unset($contacts);
-
-
- if (phpgw::get_var('on_behalf_of_assigned', 'bool') &&
isset($_ticket['assignedto_name']))
- {
- $user_name = $_ticket['assignedto_name'];
-
$GLOBALS['phpgw']->preferences->set_account_id($_ticket['assignedto'], true);
- $GLOBALS['phpgw_info']['user']['preferences'] =
$GLOBALS['phpgw']->preferences->data;
- $account_lid =
$GLOBALS['phpgw']->accounts->id2lid($_ticket['assignedto']);
- }
- else
- {
- $user_name =
$GLOBALS['phpgw_info']['user']['fullname'];
- $account_lid =
$GLOBALS['phpgw_info']['user']['account_lid'];
- }
- // $ressursnr =
$GLOBALS['phpgw_info']['user']['preferences']['property']['ressursnr'];
-
- $address =
mb_substr(htmlspecialchars($_ticket['address'], ENT_QUOTES, 'UTF-8', true), 0,
50);
-
-
- $buyer = array(
- 'Name' => $user_name,
- 'AddressInfo' => array(
- array(
- 'Address' =>
htmlspecialchars_decode($address, ENT_QUOTES)
- )
- ),
- 'BuyerReferences' => array(
- array(
- 'Responsible' =>
strtoupper($account_lid),
- 'RequestedBy' =>
strtoupper($account_lid),
- 'Accountable' =>
strtoupper($account_lid),
- )
- )
- );
- if ($_ticket['location_data'])
- {
- $dim3 =
isset($_ticket['location_data']['loc2']) && $_ticket['location_data']['loc2'] ?
"{$_ticket['location_data']['loc1']}{$_ticket['location_data']['loc2']}" :
"{$_ticket['location_data']['loc1']}01";
- }
- else
- {
- $dim3 = 9;
- }
-
- if($dim3 == 9999)
- {
- $dim3 = 9;
- }
-
- $dim6 = 9;
-
- //Override from order
- $tax_code = $_ticket['tax_code'] ? $_ticket['tax_code']
: 0;
- switch ($tax_code)
- {
- case '0':
- $tax_code = '6A';
- break;
- case '75':
- $tax_code = '60';
- break;
- default:
- $tax_code = '6A';
- break;
- }
-
- if ($_ticket['order_dim1'])
- {
- $sogeneric = CreateObject('property.sogeneric',
'order_dim1');
- $sogeneric_data =
$sogeneric->read_single(array('id' => $_ticket['order_dim1']));
- if ($sogeneric_data)
- {
- $dim6 =
"{$_ticket['building_part']}{$sogeneric_data['num']}";
- }
- }
- /*
- 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
- */
-
-
- if($_ticket['order_id'] >= 45000000 &&
$_ticket['order_id'] <= 45249999)
- {
- $voucher_type = 'P3';
- }
- else if ($_ticket['order_id'] >= 45250000 &&
$_ticket['order_id'] <= 45499999)
- {
- $voucher_type = 'P4';
- }
- else
- {
- throw new Exception("Ordrenummer
'{$_ticket['order_id']}' er utenfor serien:<br/>" . __FILE__ . '<br/>linje:' .
__LINE__);
- }
-
-
- $param = array(
- 'voucher_type' => $voucher_type,
- 'dim0' => $_ticket['b_account_id'],
// Art
- 'dim1' => $_ticket['ecodimb'],
// Ansvar
- 'dim2' => $_ticket['service_id'] ?
$_ticket['service_id'] : 9, // Tjeneste liste 30 stk, default 9
- 'dim3' => $dim3,
// Objekt: eiendom + bygg: 6 siffer
- 'dim4' => $_ticket['contract_id'] == '-1' ? ''
: $_ticket['contract_id'], // Kontrakt - frivillig / 9, 7 tegn - alfanumerisk
- 'dim5' => $_ticket['external_project_id'],
// Prosjekt
- 'dim6' => $dim6,
// Aktivitet - frivillig: bygningsdel, 3 siffer +
bokstavkode
- 'vendor_id' => $_ticket['vendor_id'],
- 'vendor_name' => $vendor['name'],
- 'vendor_address' =>
mb_substr($vendor['address'], 0, 50),
- 'order_id' => $_ticket['order_id'],
- 'tax_code' => $tax_code,
- 'buyer' => $buyer,
- 'lines' => array(
- array(
- 'unspsc_code' =>
$_ticket['unspsc_code'] ? $_ticket['unspsc_code'] : 'UN-72000000',
- 'descr' => '',
- 'price' => $price,
- )
- )
- );
-
- $exporter_ordre = new
BkBygg_exporter_data_til_Agresso(array(
- 'order_id' => $_ticket['order_id'],
- 'voucher_type' => $voucher_type
- )
- );
- $exporter_ordre->create_transfer_xml($param);
-
- $export_ok = $exporter_ordre->transfer($this->debug);
-
- if ($export_ok)
- {
- phpgwapi_cache::message_set("Ordre
#{$_ticket['order_id']} er overført");
- $this->log_transfer( $id );
- }
- }
-
- private function log_transfer( $id )
- {
- $historylog = CreateObject('property.historylog',
'tts');
- $historylog->add('RM', $id, "Ordre overført til
agresso");
- $now = time();
- $GLOBALS['phpgw']->db->query("UPDATE fm_tts_tickets SET
order_sent = {$now} WHERE id = {$id}");
- }
-
- private function get_unspsc_code_descr( $unspsc_code )
- {
- $GLOBALS['phpgw']->db->query("SELECT name FROM
fm_unspsc_code WHERE id = '{$unspsc_code}'");
- $GLOBALS['phpgw']->db->next_record();
- return $GLOBALS['phpgw']->db->f('name');
- }
- }
\ No newline at end of file
Deleted:
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php
===================================================================
---
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php
2018-01-03 09:35:11 UTC (rev 17484)
+++
thirdparty/PE_custom/BK_EBF/property/inc/custom/default/BkBygg_lag_Agresso_ordre_fra_workorder.php
2018-01-03 10:13:57 UTC (rev 17485)
@@ -1,351 +0,0 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2016 Free Software Foundation, Inc.
http://www.fsf.org/
- * This file is part of phpGroupWare.
- *
- * phpGroupWare is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * phpGroupWare is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpGroupWare; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
- *
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
- * @package property
- * @subpackage helpdesk
- * @version $Id$
- */
- /**
- * Description
- * @package property
- */
-
- if (!class_exists("lag_agresso_ordre_fra_workorder"))
- {
- class lag_agresso_ordre_fra_workorder
- {
- var $debug = false;
-
- public function __construct()
- {
- $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;
- }
-
- public function transfer( $workorder )
- {
- $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;
- }
-
- $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')
- {
- $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;
-
- }
-
- try
- {
- $purchase_grant_ok =
CreateObject('property.botts')->validate_purchase_grant( $workorder['ecodimb'],
$approval_amount, $workorder['id']);
- }
- catch (Exception $ex)
- {
- throw $ex;
- }
-
- if (!$this->debug && !$purchase_grant_ok)
- {
- 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)
- {
- if ($attribute['name'] ==
'adresse')
- {
- $vendor['address'] =
$attribute['value'];
- }
- if ($attribute['name'] ==
'org_name')
- {
- $vendor['name'] =
$attribute['value'];
- }
- }
- }
- unset($contacts);
-
-
$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']);
-
-
- 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];
-
- }
- 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;
- }
-
- if($dim3 == 9999)
- {
- $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 = '';
- if ($_address)
- {
- $address = implode(', ', $_address);
- }
-
- $address = mb_substr(htmlspecialchars($address,
ENT_QUOTES, 'UTF-8', true), 0, 50);
-
- $buyer = array(
- 'Name' => $user_name,
- 'AddressInfo' => array(
- array(
- 'Address' =>
htmlspecialchars_decode($address, ENT_QUOTES)
- )
- ),
- 'BuyerReferences' => array(
- array(
- 'Responsible' =>
strtoupper($account_lid),
- 'RequestedBy' =>
strtoupper($account_lid),
- 'Accountable' =>
strtoupper($account_lid),
- )
- )
- );
-
-
- //EBF...
-
- $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)
- {
- if ($attribute['name'] == 'mva')
- {
- $tax_code =
$attribute['value'];
- $_found ++;
- }
- if ($attribute['name'] ==
'kostra_id')
- {
- $tjeneste =
$attribute['value'];
- $_found ++;
- }
- if ($_found == 2)
- {
- 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'] ?
(int)$workorder['service_id'] : (int)$tjeneste;
-
- $GLOBALS['phpgw']->db->query("UPDATE
fm_workorder SET service_id = {$tjeneste} WHERE id = {$workorder['id']}");
-
- // _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 = true;
- }
- }
-
- if ($collect_building_part)
- {
- if ($workorder['order_dim1'])
- {
- $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]);
- }
-
- /*
- 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';
-
- 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'] ==
'-1' ? '' : $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' =>
mb_substr($vendor['address'], 0, 50),
- '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);
-
- $export_ok =
$exporter_ordre->transfer($this->debug);
-
- if ($export_ok)
- {
- phpgwapi_cache::message_set("Ordre
#{$workorder['id']} er overført");
- $this->log_transfer( $workorder['id'] );
- }
- }
-
- private function log_transfer( $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}");
- }
- }
- }
-
- if (!empty($transfer_action) && $transfer_action == 'workorder')
- {
- $exporter_ordre = new lag_agresso_ordre_fra_workorder();
- try
- {
- $exporter_ordre->transfer($workorder);
- }
- catch (Exception $exc)
- {
- phpgwapi_cache::message_set($exc->getMessage(),
'error');
- }
- }
Modified: thirdparty/PE_custom/BK_EBF/svn_full_checkout.php
===================================================================
--- thirdparty/PE_custom/BK_EBF/svn_full_checkout.php 2018-01-03 09:35:11 UTC
(rev 17484)
+++ thirdparty/PE_custom/BK_EBF/svn_full_checkout.php 2018-01-03 10:13:57 UTC
(rev 17485)
@@ -90,29 +90,36 @@
/*
* Booking
*/
- $co_modules[] = array('booking', $revision);
- $co_modules[] = array('bookingfrontend', $revision);
- $co_modules[] = array('activitycalendar', $revision);
- $co_modules[] = array('activitycalendarfrontend', $revision);
+// $co_modules[] = array('booking', $revision);
+// $co_modules[] = array('bookingfrontend', $revision);
+// $co_modules[] = array('activitycalendar', $revision);
+// $co_modules[] = array('activitycalendarfrontend', $revision);
/*
* rental
*/
- $co_modules[] = array('rental', $revision);
- $co_modules[] = array('frontend', $revision);
+// $co_modules[] = array('rental', $revision);
+// $co_modules[] = array('frontend', $revision);
/**
* Some other stuff
*/
+
+ $co_modules[] = array('felamimail', $revision);
+ $co_modules[] = array('emailadmin', $revision);
$co_modules[] = array('catch', $revision);
- $co_modules[] = array('logistic', $revision);
- $co_modules[] = array('helpdesk', $revision);
- $co_modules[] = array('eventplanner', $revision);
- $co_modules[] = array('eventplannerfrontend', $revision);
+// $co_modules[] = array('logistic', $revision);
+// $co_modules[] = array('helpdesk', $revision);
+// $co_modules[] = array('eventplanner', $revision);
+// $co_modules[] = array('eventplannerfrontend', $revision);
$pe_custom = array();
+ $pe_custom['BK_COMMON'] = array
+ (
+ array('property', '')
+ );
$pe_custom['BK_EBF'] = array
(
array('property', '')
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [17485] thirdparty: refactoring,
sigurdne <=