phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] property/import/Import_fra_Service, 1.1.1.3


From: nomail
Subject: [Phpgroupware-cvs] property/import/Import_fra_Service, 1.1.1.3
Date: Fri, 21 May 2004 16:41:18 -0000

Update of /property/import
Modified Files:
        Branch: 
          Import_fra_Service

date: 2004/04/23 21:26:32;  author: sigurdne;  state: Exp;  lines: +194 -194

Log Message:
no message
=====================================================================
Index: property/import/Import_fra_Service
diff -u property/import/Import_fra_Service:1.1.1.2 
property/import/Import_fra_Service:1.1.1.3
--- property/import/Import_fra_Service:1.1.1.2  Fri Apr 23 20:27:22 2004
+++ property/import/Import_fra_Service  Fri Apr 23 21:26:32 2004
@@ -1,194 +1,194 @@
-<?php
-
-       class import_conv
-       {
-               var $currentrecord = array(); //used for buffering to allow uid 
lines to go first
-               var $id;
-               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',
-                       'Fag/Timer/Matr' => 'dimd',
-                       'MVA' => 'mvakode',
-                       'Beløp [kr]' => 'belop'
-                       );
-
-               var $header = array('Bestilling','Fakt. 
Nr','Konto','Objekt','Fag/Timer/Matr','MVA','Beløp [kr]');
-
-               function import_conv()
-               {
-                       $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $this->soXport          = 
CreateObject($this->currentapp.'.soXport');   
-                       $this->invoice          = 
CreateObject($this->currentapp.'.boinvoice');
-                       $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
-                       $this->dateformat       = $this->bocommon->dateformat;
-                       $this->datetimeformat   = 
$this->bocommon->datetimeformat;
-                       $this->next_bilagsnr    = 
$this->invoice->next_bilagsnr();
-               }
-
-               function import($invoice_common,$download)
-               {
-
-                       $tsvfile        = $invoice_common['tsvfile'];
-                       $conv_type      = $invoice_common['conv_type'];
-                       $row = 0;
-                       $valid_data= False;
-                       $buffer = array();
-                       $buffer = $this->import_start_file($buffer);
-                       $fp = fopen($tsvfile,'r');
-//print_r($header);
-//echo '<br>';
-                       for ($i = 1; $i < $this->header_count && 
fgetcsv($fp,8000,';'); ++$i);
-
-                       while ($data = fgetcsv($fp,8000,';'))
-                       {
-                               $num = count($data);
-                               $row++;
-                               $buffer = $this->import_start_record($buffer);
-                               for ($c=0; $c<$num; $c++ )
-                               {
-                                       //Send name/value pairs along with the 
buffer
-                                       if ($this->import[$this->header[$c]] != 
'' && $data[$c] != '')
-                                       {
-
-//echo 'data'.$data[$c].'<br>';
-//echo '<br>'.$c.': '.$this->import[$this->header[$c]].' => '.$data[$c];
-                                               $buffer = 
$this->import_new_attrib($buffer, 
$this->import[$this->header[$c]],$data[$c],$invoice_common);
-                                               $valid_data= True;
-                                       }
-                               }
-                               if ($valid_data)
-                               {
-                                       $buffer = 
$this->import_end_record($buffer,$invoice_common);
-                                       $valid_data= False;
-                               }
-                       }
-                       fclose($fp);
-
-
-//echo 'download'.$download.'<br>';
-
-                       if(!$download)
-                       {
-                               $buffer = 
$this->import_end_file($buffer,$invoice_common['bilagsnr']);
-                       }
-
-//print_r($buffer);
-                       return $buffer;
-               }
-               
-
-               function import_start_file($buffer)
-               {
-                       return $buffer;
-               }
-
-               function import_start_record($buffer)
-               {
-                       $top=array();
-                       ++$this->id;
-                       $this->currentrecord = $top;
-                       return $buffer;
-               }
-
-               function import_new_attrib($buffer,$name,$value,$invoice_common)
-               {
-
-                       $value = trim($value);
-                       $value = str_replace('\n','<BR>',$value);
-                       $value = str_replace('\r','',$value);
-
-                       $this->currentrecord += array($name => $value);
-
-                       return $buffer;
-               }
-
-               function import_end_record($buffer,$invoice_common)
-               {
-                       $buffer[$this->id]='';
-                       while ( list($name, $value) = 
each($this->currentrecord))
-                       {
-                               $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']));
-                               }
-                               else
-                               {
-                                       $payment_date = 
date($this->dateformat,mktime(2,0,0,$invoice_common['emonth'],$invoice_common['eday'],$invoice_common['eyear']));
                       
-                               }
-
-                               if($name=='belop')
-                               {
-                                       $value = str_replace('kr','',$value);
-                                       $value = str_replace(' ','',$value);
-                                       $value = str_replace(',','.',$value);
-                                       $godkjentbelop=$value;
-                               }
-                               if($name=='pmwrkord_code')
-                               {
-                                       
if(!$this->soXport->check_pmwrkord_code(intval($value)))
-                                       {
-                                               $value='';
-                                       }
-                               }
-                               if($name=='spbudact_code')
-                               {
-                                       
if(!$this->soXport->check_spbudact_code(intval($value)))
-                                       {
-                                               $value='';
-                                       }
-                               }
-
-                               if($name=='fakturanr')
-                               {
-                                       if($invoice_common['invoice_num'])
-                                       {
-                                               
$value=$invoice_common['invoice_num'];
-                                       }
-                               }
-
-                               if($name=='mvakode' && 
$invoice_common['auto_tax'])
-                               {
-                                       $value = 
$this->soXport->auto_tax($buffer[$this->id]['dima']);
-                               }
-
-                               $buffer[$this->id][$name] = $value;
-                               $buffer[$this->id]['bilagsnr'] = 
$this->next_bilagsnr;
-                               $buffer[$this->id]['splitt'] = $this->splitt;
-                               $buffer[$this->id]['kildeid'] = $this->kildeid;
-                               $buffer[$this->id]['kidnr'] = 
$invoice_common['kid_nr'];
-                               $buffer[$this->id]['typeid'] = 
$invoice_common['type'];
-                               $buffer[$this->id]['fakturadato'] = 
$invoice_date;
-                               $buffer[$this->id]['forfallsdato'] = 
$payment_date;
-                               $buffer[$this->id]['periode'] = 
$invoice_common['smonth'];
-                               $buffer[$this->id]['regtid'] = 
date($this->datetimeformat);
-                               $buffer[$this->id]['artid'] = 
$invoice_common['art'];
-                               $buffer[$this->id]['godkjentbelop'] = 
$godkjentbelop;
-                               $buffer[$this->id]['spvend_code'] = 
$invoice_common['vendor_id'];
-                               $buffer[$this->id]['dimb'] = 
$invoice_common['dim_b'];
-                               $buffer[$this->id]['oppsynsmannid'] = 
$invoice_common['janitor'];
-                               $buffer[$this->id]['saksbehandlerid'] = 
$invoice_common['supervisor'];
-                               $buffer[$this->id]['budsjettansvarligid'] = 
$invoice_common['budget_responsible'];
-
-                       }
-                       return $buffer;
-               }
-
-               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);
-                       return $receipt;
-               }
-       }
-?>
+<?php
+
+       class import_conv
+       {
+               var $currentrecord = array(); //used for buffering to allow uid 
lines to go first
+               var $id;
+               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',
+                       'Fag/Timer/Matr' => 'dimd',
+                       'MVA' => 'mvakode',
+                       'Beløp [kr]' => 'belop'
+                       );
+
+               var $header = array('Bestilling','Fakt. 
Nr','Konto','Objekt','Fag/Timer/Matr','MVA','Beløp [kr]');
+
+               function import_conv()
+               {
+                       $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $this->soXport          = 
CreateObject($this->currentapp.'.soXport');   
+                       $this->invoice          = 
CreateObject($this->currentapp.'.boinvoice');
+                       $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
+                       $this->dateformat       = $this->bocommon->dateformat;
+                       $this->datetimeformat   = 
$this->bocommon->datetimeformat;
+                       $this->next_bilagsnr    = 
$this->invoice->next_bilagsnr();
+               }
+
+               function import($invoice_common,$download)
+               {
+
+                       $tsvfile        = $invoice_common['tsvfile'];
+                       $conv_type      = $invoice_common['conv_type'];
+                       $row = 0;
+                       $valid_data= False;
+                       $buffer = array();
+                       $buffer = $this->import_start_file($buffer);
+                       $fp = fopen($tsvfile,'r');
+//print_r($header);
+//echo '<br>';
+                       for ($i = 1; $i < $this->header_count && 
fgetcsv($fp,8000,';'); ++$i);
+
+                       while ($data = fgetcsv($fp,8000,';'))
+                       {
+                               $num = count($data);
+                               $row++;
+                               $buffer = $this->import_start_record($buffer);
+                               for ($c=0; $c<$num; $c++ )
+                               {
+                                       //Send name/value pairs along with the 
buffer
+                                       if ($this->import[$this->header[$c]] != 
'' && $data[$c] != '')
+                                       {
+
+//echo 'data'.$data[$c].'<br>';
+//echo '<br>'.$c.': '.$this->import[$this->header[$c]].' => '.$data[$c];
+                                               $buffer = 
$this->import_new_attrib($buffer, 
$this->import[$this->header[$c]],$data[$c],$invoice_common);
+                                               $valid_data= True;
+                                       }
+                               }
+                               if ($valid_data)
+                               {
+                                       $buffer = 
$this->import_end_record($buffer,$invoice_common);
+                                       $valid_data= False;
+                               }
+                       }
+                       fclose($fp);
+
+
+//echo 'download'.$download.'<br>';
+
+                       if(!$download)
+                       {
+                               $buffer = 
$this->import_end_file($buffer,$invoice_common['bilagsnr']);
+                       }
+
+//print_r($buffer);
+                       return $buffer;
+               }
+               
+
+               function import_start_file($buffer)
+               {
+                       return $buffer;
+               }
+
+               function import_start_record($buffer)
+               {
+                       $top=array();
+                       ++$this->id;
+                       $this->currentrecord = $top;
+                       return $buffer;
+               }
+
+               function import_new_attrib($buffer,$name,$value,$invoice_common)
+               {
+
+                       $value = trim($value);
+                       $value = str_replace('\n','<BR>',$value);
+                       $value = str_replace('\r','',$value);
+
+                       $this->currentrecord += array($name => $value);
+
+                       return $buffer;
+               }
+
+               function import_end_record($buffer,$invoice_common)
+               {
+                       $buffer[$this->id]='';
+                       while ( list($name, $value) = 
each($this->currentrecord))
+                       {
+                               $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']));
+                               }
+                               else
+                               {
+                                       $payment_date = 
date($this->dateformat,mktime(2,0,0,$invoice_common['emonth'],$invoice_common['eday'],$invoice_common['eyear']));
                       
+                               }
+
+                               if($name=='belop')
+                               {
+                                       $value = str_replace('kr','',$value);
+                                       $value = str_replace(' ','',$value);
+                                       $value = str_replace(',','.',$value);
+                                       $godkjentbelop=$value;
+                               }
+                               if($name=='pmwrkord_code')
+                               {
+                                       
if(!$this->soXport->check_pmwrkord_code(intval($value)))
+                                       {
+                                               $value='';
+                                       }
+                               }
+                               if($name=='spbudact_code')
+                               {
+                                       
if(!$this->soXport->check_spbudact_code(intval($value)))
+                                       {
+                                               $value='';
+                                       }
+                               }
+
+                               if($name=='fakturanr')
+                               {
+                                       if($invoice_common['invoice_num'])
+                                       {
+                                               
$value=$invoice_common['invoice_num'];
+                                       }
+                               }
+
+                               if($name=='mvakode' && 
$invoice_common['auto_tax'])
+                               {
+                                       $value = 
$this->soXport->auto_tax($buffer[$this->id]['dima']);
+                               }
+
+                               $buffer[$this->id][$name] = $value;
+                               $buffer[$this->id]['bilagsnr'] = 
$this->next_bilagsnr;
+                               $buffer[$this->id]['splitt'] = $this->splitt;
+                               $buffer[$this->id]['kildeid'] = $this->kildeid;
+                               $buffer[$this->id]['kidnr'] = 
$invoice_common['kid_nr'];
+                               $buffer[$this->id]['typeid'] = 
$invoice_common['type'];
+                               $buffer[$this->id]['fakturadato'] = 
$invoice_date;
+                               $buffer[$this->id]['forfallsdato'] = 
$payment_date;
+                               $buffer[$this->id]['periode'] = 
$invoice_common['smonth'];
+                               $buffer[$this->id]['regtid'] = 
date($this->datetimeformat);
+                               $buffer[$this->id]['artid'] = 
$invoice_common['art'];
+                               $buffer[$this->id]['godkjentbelop'] = 
$godkjentbelop;
+                               $buffer[$this->id]['spvend_code'] = 
$invoice_common['vendor_id'];
+                               $buffer[$this->id]['dimb'] = 
$invoice_common['dim_b'];
+                               $buffer[$this->id]['oppsynsmannid'] = 
$invoice_common['janitor'];
+                               $buffer[$this->id]['saksbehandlerid'] = 
$invoice_common['supervisor'];
+                               $buffer[$this->id]['budsjettansvarligid'] = 
$invoice_common['budget_responsible'];
+
+                       }
+                       return $buffer;
+               }
+
+               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);
+                       return $receipt;
+               }
+       }
+?>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]