[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11678] property: more on integration
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11678] property: more on integration |
Date: |
Wed, 12 Feb 2014 15:04:40 +0000 |
Revision: 11678
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11678
Author: sigurdne
Date: 2014-02-12 15:04:40 +0000 (Wed, 12 Feb 2014)
Log Message:
-----------
property: more on integration
Modified Paths:
--------------
trunk/property/inc/import/default/Import_fra_Service_EBF
Modified: trunk/property/inc/import/default/Import_fra_Service_EBF
===================================================================
--- trunk/property/inc/import/default/Import_fra_Service_EBF 2014-02-12
11:18:26 UTC (rev 11677)
+++ trunk/property/inc/import/default/Import_fra_Service_EBF 2014-02-12
15:04:40 UTC (rev 11678)
@@ -1,77 +1,76 @@
<?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 import
- * @version $Id: Import_fra_Service,v 1.19 2007/03/18 16:33:16 sigurdne
Exp $
- */
+ * 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 import
+ * @version $Id: Import_fra_Service,v 1.19 2007/03/18 16:33:16 sigurdne
Exp $
+ */
/**
* Description
* @package property
*/
-
class import_conv
{
+
var $currentrecord = array(); //used for buffering to allow uid
lines to go first
var $id = -1;
- var $kildeid=1;
- var $splitt=0;
+ var $kildeid = 1;
+ var $splitt = 0;
var $type = 'csv';
var $header_count = 18;
var $soXport;
var $invoice;
-
var $import = array(
- 'Bestilling' => 'pmwrkord_code',
- 'Fakt. Nr' => 'fakturanr',
- 'Konto' => 'spbudact_code',
- 'Objekt' => 'dima',
- 'DIM 6' => 'dimd',//utgår fra import - kopieres fra
kategori
- 'MVA' => 'mvakode',
- 'Tjeneste'=> 'kostra_id',
+ 'Bestilling' => 'pmwrkord_code',
+ 'Fakt. Nr' => 'fakturanr',
+ 'Konto' => 'spbudact_code',
+ 'Objekt' => 'dima',
+ 'DIM 6' => 'dimd', //utgår fra import -
kopieres fra kategori
+ 'MVA' => 'mvakode',
+ 'Tjeneste' => 'kostra_id',
'Belop [kr]' => 'belop'
- );
+ );
+ var $header = array('Bestilling', 'Fakt. Nr', 'Konto',
'Objekt', 'DIM 6', 'MVA', 'Belop [kr]');
- var $header = array('Bestilling','Fakt.
Nr','Konto','Objekt','DIM 6','MVA','Belop [kr]');
-
function import_conv()
{
- $this->db =
clone($GLOBALS['phpgw']->db);
- $this->soXport =
CreateObject('property.soXport');
- $this->invoice =
CreateObject('property.boinvoice');
- $this->bocommon =
CreateObject('property.bocommon');
- $this->dateformat =
$GLOBALS['phpgw']->db->date_format();
- $this->datetimeformat =
$GLOBALS['phpgw']->db->datetime_format();
- $this->next_bilagsnr =
$this->invoice->next_bilagsnr();
+ $this->db = clone($GLOBALS['phpgw']->db);
+ $this->soXport = CreateObject('property.soXport');
+ $this->invoice = CreateObject('property.boinvoice');
+ $this->bocommon = CreateObject('property.bocommon');
+ $this->dateformat =
$GLOBALS['phpgw']->db->date_format();
+ $this->datetimeformat =
$GLOBALS['phpgw']->db->datetime_format();
+ $this->next_bilagsnr = $this->invoice->next_bilagsnr();
}
- function import($invoice_common,$download)
+ function import($invoice_common, $download)
{
- $tsvfile = $invoice_common['tsvfile'];
+ $tsvfile = $invoice_common['tsvfile'];
- $conv_type = $invoice_common['conv_type'];
+ $conv_type = $invoice_common['conv_type'];
$buffer = array();
//-----------
@@ -80,25 +79,25 @@
$objPHPExcel = PHPExcel_IOFactory::load($tsvfile);
- $data =
$objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
+ $data = $objPHPExcel->getActiveSheet()->toArray(null,
true, true, true);
$result = array();
- $rows = count($data)+1;
+ $rows = count($data) + 1;
- for ($row = $this->header_count; $row < $rows; $row++ )
+ for($row = $this->header_count; $row < $rows; $row++)
{
$this->currentrecord = array();
- $j=0;
+ $j = 0;
foreach($data[$row] as $key => $_dummy)
{
- $value =
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($j,$row)->getCalculatedValue();
+ $value =
$objPHPExcel->getActiveSheet()->getCellByColumnAndRow($j,
$row)->getCalculatedValue();
- if ($name =
$this->import[$this->header[$j]])
+ if($name =
$this->import[$this->header[$j]])
{
-
- $value =
str_replace(array('\n','\r'),array('<BR>',''),$value);
+
+ $value =
str_replace(array('\n', '\r'), array('<BR>', ''), $value);
$this->currentrecord +=
array($name => $value);
}
$j++;
@@ -107,7 +106,7 @@
if($this->currentrecord['fakturanr'] &&
$this->currentrecord['belop']) // fakturanr og beløp
{
++$this->id;
- $buffer =
$this->import_end_record($buffer,$invoice_common);
+ $buffer =
$this->import_end_record($buffer, $invoice_common);
}
}
@@ -115,81 +114,78 @@
if(!$download)
{
- $buffer =
$this->import_end_file($buffer,$invoice_common['bilagsnr']);
+ $buffer = $this->import_end_file($buffer,
$invoice_common['bilagsnr']);
}
return $buffer;
}
-
- function import_end_record($buffer,$invoice_common)
+ function import_end_record($buffer, $invoice_common)
{
static $workorders = array();
$buffer[$this->id] = array();
- foreach ($this->currentrecord as $name => $value)
+ foreach($this->currentrecord as $name => $value)
{
- if($name=='belop')
+ if($name == 'belop')
{
- $value = str_replace('kr','',$value);
- $value = str_replace(' ','',$value);
- $value = str_replace(',','.',$value);
-
- if( $invoice_common['art'] == 2 ) //
kreditnota
+ $value = str_replace('kr', '', $value);
+ $value = str_replace(' ', '', $value);
+ $value = str_replace(',', '.', $value);
+
+ if($invoice_common['art'] == 2) //
kreditnota
{
$value = -1 * abs($value);
}
-
+
$buffer[$this->id]['godkjentbelop'] =
$value;
}
- if($name=='pmwrkord_code')
+ if($name == 'pmwrkord_code')
{
- if(!$workorder =
$workorders[(int)$value]['order'])
+ if(!$workorder = $workorders[(int)
$value]['order'])
{
-
if(!$this->soXport->check_order((int)$value))
+
if(!$this->soXport->check_order((int) $value))
{
-
$workorders[(int)$value]['order']['cat_id'] = '';
-
$workorders[(int)$value]['order']['ecodimb'] = '';
-
$workorders[(int)$value]['project_id'] = '';
+ $workorders[(int)
$value]['order']['cat_id'] = '';
+ $workorders[(int)
$value]['order']['ecodimb'] = '';
+ $workorders[(int)
$value]['project_id'] = '';
}
else
{
-
$workorders[(int)$value]['order'] =
execMethod('property.soworkorder.read_single', (int)$value);
-
$workorders[(int)$value]['project_id'] =
$this->soXport->get_project((int)$value);//Agresso prosjekt
+ $workorder =
execMethod('property.soworkorder.read_single', (int) $value);
+ $workorders[(int)
$value]['order'] = $workorder;
+ $workorders[(int)
$value]['project_id'] = $this->soXport->get_project((int) $value);//Agresso
prosjekt
}
}
-
- $buffer[$this->id]['project_id'] =
$workorders[(int)$value]['project_id'];//Agresso prosjekt
- $buffer[$this->id]['dime'] =
$workorders[(int)$value]['order']['cat_id']; // Dim 6
- $buffer[$this->id]['dimb'] =
$workorders[(int)$value]['order']['ecodimb']; // Ansvarssted
-
+ $buffer[$this->id]['project_id'] =
$workorders[(int) $value]['project_id'];//Agresso prosjekt
+ $buffer[$this->id]['dimb'] =
$workorders[(int) $value]['order']['ecodimb']; // Ansvarssted
}
- if($name=='spbudact_code')
+ if($name == 'spbudact_code')
{
continue;
}
- if($name=='dima')
+ if($name == 'dima')
{
$value = $this->check_dima($value);
- $buffer[$this->id]['loc1'] =
$loc1=substr($value,0,4);
+ $buffer[$this->id]['loc1'] = $loc1 =
substr($value, 0, 4);
}
- if($name=='mvakode')
+ if($name == 'mvakode')
{
- if( $invoice_common['auto_tax'])
+ if($invoice_common['auto_tax'])
{
- $value =
(int)$this->soXport->auto_tax($buffer[$this->id]['loc1']);
+ $value = (int)
$this->soXport->auto_tax($buffer[$this->id]['loc1']);
}
else
{
$value = (int) $value;
}
}
-
+
$buffer[$this->id][$name] = $value;
}
@@ -198,25 +194,24 @@
$buffer[$this->id]['kildeid'] = $this->kildeid;
$buffer[$this->id]['kidnr'] = $invoice_common['kid_nr'];
$buffer[$this->id]['typeid'] = $invoice_common['type'];
- $buffer[$this->id]['periode'] =
$invoice_common['syear'] . sprintf("%02d",$invoice_common['smonth']);
+ $buffer[$this->id]['periode'] =
$invoice_common['syear'] . sprintf("%02d", $invoice_common['smonth']);
$buffer[$this->id]['regtid'] =
date($this->datetimeformat);
$buffer[$this->id]['artid'] = $invoice_common['art'];
$buffer[$this->id]['spvend_code'] =
$invoice_common['vendor_id'];
$buffer[$this->id]['oppsynsmannid'] =
$invoice_common['janitor'];
$buffer[$this->id]['saksbehandlerid'] =
$invoice_common['supervisor'];
$buffer[$this->id]['budsjettansvarligid'] =
$invoice_common['budget_responsible'];
-
- $buffer[$this->id]['dimd'] = $buffer[$this->id]['dime'];
- $invoice_date =
date($this->dateformat,mktime(2,0,0,$invoice_common['smonth'],$invoice_common['sday'],$invoice_common['syear']));
+ $invoice_date = date($this->dateformat, mktime(2, 0, 0,
$invoice_common['smonth'], $invoice_common['sday'], $invoice_common['syear']));
+
if($invoice_common['num_days'])
{
- $payment_date =
date($this->dateformat,mktime(2,0,0,$invoice_common['smonth'],$invoice_common['sday'],$invoice_common['syear'])+(86400*$invoice_common['num_days']));
+ $payment_date = date($this->dateformat,
mktime(2, 0, 0, $invoice_common['smonth'], $invoice_common['sday'],
$invoice_common['syear']) + (86400 * $invoice_common['num_days']));
}
else
{
- $payment_date =
date($this->dateformat,mktime(2,0,0,$invoice_common['emonth'],$invoice_common['eday'],$invoice_common['eyear']));
+ $payment_date = date($this->dateformat,
mktime(2, 0, 0, $invoice_common['emonth'], $invoice_common['eday'],
$invoice_common['eyear']));
}
$buffer[$this->id]['fakturadato'] = $invoice_date;
@@ -226,23 +221,97 @@
{
if($this->check_old_spbudact_code($workorder['b_account_id']))
{
- $buffer[$this->id]['spbudact_code'] =
'123014';
- $buffer[$this->id]['dime'] =
(int)substr($workorder['b_account_id'],-4); // Dim 6
+ $_accout_class =
substr(substr($workorder['b_account_id'], -4), 0, 2);
+ switch($_accout_class)
+ {
+ case '41':
+
$buffer[$this->id]['spbudact_code'] = '123013';
+ break;
+ case '42':
+
$buffer[$this->id]['spbudact_code'] = '123014';
+ break;
+ case '44':
+
$buffer[$this->id]['spbudact_code'] = '123015';
+ break;
+ case '45':
+
$buffer[$this->id]['spbudact_code'] = '123016';
+ break;
+ case '46':
+
$buffer[$this->id]['spbudact_code'] = '123016';
+ break;
+ case '47':
+
$buffer[$this->id]['spbudact_code'] = '123017';
+ break;
+ case '48':
+
$buffer[$this->id]['spbudact_code'] = '123018';
+ break;
+ case '49':
+
$buffer[$this->id]['spbudact_code'] = '123019';
+ break;
+ default:
+
$buffer[$this->id]['spbudact_code'] = '123014';
+ break;
+ }
+
+ $buffer[$this->id]['dime'] = (int)
substr($workorder['b_account_id'], -4); // Dim 6
}
else
{
+ $buffer[$this->id]['dime'] =
$workorder['cat_id']; // Dim 6
$buffer[$this->id]['spbudact_code'] =
$workorder['b_account_id'];
}
}
else
{
- $buffer[$this->id]['spbudact_code'] = '123014';
+ $_spbudact_code =
$this->currentrecord['spbudact_code'];
+
if($this->check_old_spbudact_code($_spbudact_code))
+ {
+ $_accout_class =
substr(substr($_spbudact_code, -4), 0, 2);
+ switch($_accout_class)
+ {
+ case '41':
+
$buffer[$this->id]['spbudact_code'] = '123013';
+ break;
+ case '42':
+
$buffer[$this->id]['spbudact_code'] = '123014';
+ break;
+ case '44':
+
$buffer[$this->id]['spbudact_code'] = '123015';
+ break;
+ case '45':
+
$buffer[$this->id]['spbudact_code'] = '123016';
+ break;
+ case '46':
+
$buffer[$this->id]['spbudact_code'] = '123016';
+ break;
+ case '47':
+
$buffer[$this->id]['spbudact_code'] = '123017';
+ break;
+ case '48':
+
$buffer[$this->id]['spbudact_code'] = '123018';
+ break;
+ case '49':
+
$buffer[$this->id]['spbudact_code'] = '123019';
+ break;
+ default:
+
$buffer[$this->id]['spbudact_code'] = '123014';
+ break;
+ }
+
+ $buffer[$this->id]['dime'] = (int)
substr($_spbudact_code, -4); // Dim 6
+ }
+ else
+ {
+ $buffer[$this->id]['spbudact_code'] =
$_spbudact_code ? $_spbudact_code : '123014';
+ }
}
+ $buffer[$this->id]['dimd'] = $buffer[$this->id]['dime'];
+
if($invoice_common['auto_tax'])
{
- $buffer[$this->id]['mvakode'] =
$this->soXport->tax_b_account_override($buffer[$this->id]['mvakode']
,$buffer[$this->id]['spbudact_code']);
- $buffer[$this->id]['mvakode'] =
$this->soXport->tax_vendor_override($buffer[$this->id]['mvakode']
,$buffer[$this->id]['spvend_code']);
+ $buffer[$this->id]['mvakode'] =
$this->soXport->tax_b_account_override($buffer[$this->id]['mvakode'],
$buffer[$this->id]['spbudact_code']);
+ $buffer[$this->id]['mvakode'] =
$this->soXport->tax_vendor_override($buffer[$this->id]['mvakode'],
$buffer[$this->id]['spvend_code']);
}
$buffer[$this->id]['kostra_id'] =
$this->soXport->get_kostra_id($buffer[$this->id]['loc1']);
@@ -256,48 +325,46 @@
{
$buffer[$this->id]['dimb'] =
$invoice_common['dim_b'];
}
-
return $buffer;
}
-
+
function check_old_spbudact_code($id)
{
- $b_account='';
- $this->db->query("select id from fm_b_account where
id='$id'");
+ $this->db->query("SELECT id FROM fm_b_account_convert
WHERE id='{$id}'");
$this->db->next_record();
- if ($this->db->f('id'))
- {
- $b_account = $this->db->f('id');
+ if($this->db->f('id'))
+ {
+ return true;
}
else
{
- $this->db->query("select id from
fm_b_account_convert where old_id='$id'");
+ $this->db->query("SELECT id FROM
fm_b_account_convert WHERE old_id='{$id}'");
$this->db->next_record();
- $b_account = $this->db->f('id');
+ return !!$this->db->f('id');
}
-
- return $b_account;
+
+ return false;
}
function check_dima($id)
{
- $loc1=substr($id,0,4);
- $loc2=substr($id,4,2);
-
+ $loc1 = substr($id, 0, 4);
+ $loc2 = substr($id, 4, 2);
+
$this->db->query("select loc1 from fm_location1 where
loc1='$loc1' AND ((fm_location1.category <> 99) OR (fm_location1.category IS
NULL))");
$this->db->next_record();
- if ($this->db->f('loc1'))
- {
+ if($this->db->f('loc1'))
+ {
$dima = $this->db->f('loc1');
-
- if ($loc2)
+
+ if($loc2)
{
$this->db->query("select location_code
from fm_location2 where loc1='$loc1' AND loc2='$loc2' AND
((fm_location2.category <> 99) OR (fm_location2.category IS NULL))");
$this->db->next_record();
- if ($this->db->f('location_code'))
- {
- $dima =
str_replace('-','',$this->db->f('location_code'));
+ if($this->db->f('location_code'))
+ {
+ $dima = str_replace('-', '',
$this->db->f('location_code'));
}
else
{
@@ -305,14 +372,16 @@
}
}
}
-
+
return $dima;
}
- function import_end_file($buffer,$bilagsnr)
+ function import_end_file($buffer, $bilagsnr)
{
- $num = $this->soXport->add($buffer);
- $receipt['message'][]= array('msg' =>
lang('Successfully imported %1 records into your invoice register.',$num).'
'.lang('ID').': '. $bilagsnr);
+ $receipt = array();
+ $num = $this->soXport->add($buffer);
+ $receipt['message'][] = array('msg' =>
lang('Successfully imported %1 records into your invoice register.', $num) . '
' . lang('ID') . ': ' . $bilagsnr);
return $receipt;
}
- }
+
+ }
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11678] property: more on integration,
Sigurd Nes <=