phpgroupware-cvs
[Top][All Lists]
Advanced

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

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


From: nomail
Subject: [Phpgroupware-cvs] property/import/Import_fra_BKK, 1.1.1.3
Date: Fri, 21 May 2004 17:41:52 -0000

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

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

Log Message:
no message
=====================================================================
Index: property/import/Import_fra_BKK
diff -u property/import/Import_fra_BKK:1.1.1.2 
property/import/Import_fra_BKK:1.1.1.3
--- property/import/Import_fra_BKK:1.1.1.2      Fri Apr 23 20:27:19 2004
+++ property/import/Import_fra_BKK      Fri Apr 23 21:26:32 2004
@@ -1,271 +1,271 @@
-<?php
-       class import_conv
-       {
-               var $currentrecord = array(); //used for buffering to allow uid 
lines to go first
-               var $id;
-               var $spbudact_code=4321;
-               var $mvakode=0;
-               var $kildeid=1;
-               var $splitt=0;
-               var $type = 'fixed';
-               var $header_count = 1;
-               var $soXport;
-               var $invoice;
-
-               var $import = array(
-                       'Bestilling' => 'pmwrkord_code', 
-                       'Fakt. Nr' => 'fakturanr',
-                       'Måler nr' => 'maalernr',
-                       'Konto' => 'spbudact_code',
-                       'Objekt' => 'dima',
-                       'Omr' => 'omraade',
-                       'Adresse' => 'merknad',
-                       'MVA' => 'mvakode',
-                       'Beløp [kr]' => 'belop'
-                       );
-
-               var $header = array('Fakt. Nr','Måler 
nr','Konto','Objekt','MVA','Beløp [kr]','Omr','Adresse');
-
-               var $import_bkk = 
array('boligbyggelag','dato','kundenr','lopenr', 'maalernr' , 
'installasjonsnr', 
-                       
'anleggsid','stedsnavn','kunde_navn','navn','netto','mva');
-                       
-               var $import_bkk_offset = array(
-                       'boligbyggelag' => '0', 
-                       'dato' => '5', 
-                       'kundenr' => '16', 
-                       'lopenr' => '25', 
-                       'maalernr' => '30', 
-                       'installasjonsnr' => '43', 
-                       'anleggsid' => '54', 
-                       'stedsnavn' => '59',
-                       'kunde_navn' => '95',
-                       'navn' => '126',
-                       'netto' => '157',
-                       'mva' => '172'
-                       );
-
-               var $import_bkk_len = array(
-                       'boligbyggelag' => '5', 
-                       'dato' => '10', 
-                       'kundenr' => '8', 
-                       'lopenr' => '4', 
-                       'maalernr' => '8', 
-                       'installasjonsnr' => '9', 
-                       'anleggsid' => '4', 
-                       'stedsnavn' => '35',
-                       'kunde_navn' => '30',
-                       'navn' => '30',
-                       'netto' => '14',
-                       'mva' => '14'
-                       );
-
-               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'];
-
-                       if(!$buffer[$this->id]['kidnr'] = 
$invoice_common['kid_nr'])
-                       {
-                               echo '<b>KID-nummer mangler</b><br><br>';
-                               return;
-                       }
-                       $valid_data= False;
-                       $buffer = array();
-                       $buffer = $this->import_start_file($buffer);
-                       $fp = fopen($tsvfile,'rb');
-//print_r($buffer);
-
-//print_r($header);
-//echo '<br>';
-                       for ($i = 0; $i < $this->header_count && 
fgets($fp,8000); ++$i);
-
-                       while ($data = fgets($fp,8000))
-                       {
-//print_r($data);
-                               $num = count($this->import_bkk);
-//echo 'data :'.$data.'<br>';
-                               $buffer = $this->import_start_record($buffer);
-//print_r($buffer);
-                               for ($c=0; $c<$num; $c++ )
-                               {
-                                       //Send name/value pairs along with the 
buffer
-                                       if ($this->import_bkk[$c] != '' && 
substr($data,5,10) !='')
-                                       {
-//echo 'len :'.$this->import_bkk_len[$this->import_bkk[$c]].'<br>';
-//print_r(fread($data,$this->import_bkk_len[$this->import_bkk[$c]]));
-//print_r($this->import_bkk[$c]);
-                                               
$value=substr($data,$this->import_bkk_offset[$this->import_bkk[$c]],$this->import_bkk_len[$this->import_bkk[$c]]);
-                                               $name=$this->import_bkk[$c];
-                                               if ($name=='installasjonsnr')
-                                               {
-                                                       $name='anleggsnr';
-                                                       
$value=substr($data,43,9)." ".substr($data,54,4);
-                                               }
-                                               if ($name=='netto')
-                                               {
-                                                       $name='belop';
-                                                       
$value=(floatval(substr($data,157,14)) + floatval(substr($data,172,14)))/100;
-                                                       $valid_data= True;      
                        
-                                               }
-//echo 'name :'.$name;
-//echo '  value :'.$value.'<br>';
-//print_r($buffer);
-
-                                               $buffer = 
$this->import_new_attrib($buffer,$name,$value,$invoice_common);
-                                       }
-                               }
-                               if ($valid_data)
-                               {
-                                       $buffer = 
$this->import_end_record($buffer,$invoice_common);
-                                       $valid_data= False;
-                               }
-                       }
-                       fclose($fp);
-//print_r($buffer);
-
-
-//echo 'download'.$download.'<br>';
-
-                       if(!$download)
-                       {
-                               $buffer = 
$this->import_end_file($buffer,$invoice_common['bilagsnr']);
-                       }
-
-                       return $buffer;
-               }
-               
-
-               function import_start_file($buffer)
-               {
-                       return $buffer;
-               }
-
-               function import_start_record($buffer)
-               {
-//print_r($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);
-//print_r($buffer);
-                       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=='anleggsnr')
-                               {
-                                       $buffer[$this->id]['merknad'] = 
'anleggsnr:' . $value;
-                                       
-                                       
$maalerinfo=$this->soXport->anleggsnr_to_objekt($value);
-                                       $dima=$maalerinfo['dima'];
-                                       $loc1=$maalerinfo['loc1'];
-//                                     $maalernr=$maalerinfo['maalernr'];
-                                       $omraade=$maalerinfo['district'];
-                               }
-                               if($name=='stedsnavn')
-                               {
-                                       $buffer[$this->id]['merknad'] .= "\r\n" 
. $value;
-                               }
-
-                               if($name=='dima' && 
$invoice_common['auto_tax']):
-                               {
-                                       
$mvakode=$this->soXport->auto_tax($value);
-                                       
-                                       if($mvakode)
-                                       {
-                                               $buffer[$this->id]['mvakode'] = 
$mvakode;
-                                       }
-                                       else
-                                       {
-                                               $buffer[$this->id]['mvakode'] = 
$this->mvakode;
-                                       }
-                               }
-                               elseif($name=='dima' && 
!$invoice_common['auto_tax']):
-                               {
-                                       $buffer[$this->id]['mvakode'] = 
$this->mvakode;
-                               }
-                               endif;
-
-                               $buffer[$this->id][$name] = $value;
-                               $buffer[$this->id]['bilagsnr'] = 
$this->next_bilagsnr;
-                               $buffer[$this->id]['fakturanr'] = 
$invoice_common['invoice_num'];
-                               $buffer[$this->id]['dima'] = $dima;
-                               $buffer[$this->id]['loc1'] = $loc1;
-                               $buffer[$this->id]['omraade'] = $omraade;
-//                             $buffer[$this->id]['maalernr'] = $maalernr;
-                               $buffer[$this->id]['splitt'] = $this->splitt;
-                               $buffer[$this->id]['kildeid'] = $this->kildeid;
-//                             $buffer[$this->id]['mvakode'] = $this->mvakode;
-                               $buffer[$this->id]['spbudact_code'] = 
$this->spbudact_code;
-                               $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 $spbudact_code=4321;
+               var $mvakode=0;
+               var $kildeid=1;
+               var $splitt=0;
+               var $type = 'fixed';
+               var $header_count = 1;
+               var $soXport;
+               var $invoice;
+
+               var $import = array(
+                       'Bestilling' => 'pmwrkord_code', 
+                       'Fakt. Nr' => 'fakturanr',
+                       'Måler nr' => 'maalernr',
+                       'Konto' => 'spbudact_code',
+                       'Objekt' => 'dima',
+                       'Omr' => 'omraade',
+                       'Adresse' => 'merknad',
+                       'MVA' => 'mvakode',
+                       'Beløp [kr]' => 'belop'
+                       );
+
+               var $header = array('Fakt. Nr','Måler 
nr','Konto','Objekt','MVA','Beløp [kr]','Omr','Adresse');
+
+               var $import_bkk = 
array('boligbyggelag','dato','kundenr','lopenr', 'maalernr' , 
'installasjonsnr', 
+                       
'anleggsid','stedsnavn','kunde_navn','navn','netto','mva');
+                       
+               var $import_bkk_offset = array(
+                       'boligbyggelag' => '0', 
+                       'dato' => '5', 
+                       'kundenr' => '16', 
+                       'lopenr' => '25', 
+                       'maalernr' => '30', 
+                       'installasjonsnr' => '43', 
+                       'anleggsid' => '54', 
+                       'stedsnavn' => '59',
+                       'kunde_navn' => '95',
+                       'navn' => '126',
+                       'netto' => '157',
+                       'mva' => '172'
+                       );
+
+               var $import_bkk_len = array(
+                       'boligbyggelag' => '5', 
+                       'dato' => '10', 
+                       'kundenr' => '8', 
+                       'lopenr' => '4', 
+                       'maalernr' => '8', 
+                       'installasjonsnr' => '9', 
+                       'anleggsid' => '4', 
+                       'stedsnavn' => '35',
+                       'kunde_navn' => '30',
+                       'navn' => '30',
+                       'netto' => '14',
+                       'mva' => '14'
+                       );
+
+               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'];
+
+                       if(!$buffer[$this->id]['kidnr'] = 
$invoice_common['kid_nr'])
+                       {
+                               echo '<b>KID-nummer mangler</b><br><br>';
+                               return;
+                       }
+                       $valid_data= False;
+                       $buffer = array();
+                       $buffer = $this->import_start_file($buffer);
+                       $fp = fopen($tsvfile,'rb');
+//print_r($buffer);
+
+//print_r($header);
+//echo '<br>';
+                       for ($i = 0; $i < $this->header_count && 
fgets($fp,8000); ++$i);
+
+                       while ($data = fgets($fp,8000))
+                       {
+//print_r($data);
+                               $num = count($this->import_bkk);
+//echo 'data :'.$data.'<br>';
+                               $buffer = $this->import_start_record($buffer);
+//print_r($buffer);
+                               for ($c=0; $c<$num; $c++ )
+                               {
+                                       //Send name/value pairs along with the 
buffer
+                                       if ($this->import_bkk[$c] != '' && 
substr($data,5,10) !='')
+                                       {
+//echo 'len :'.$this->import_bkk_len[$this->import_bkk[$c]].'<br>';
+//print_r(fread($data,$this->import_bkk_len[$this->import_bkk[$c]]));
+//print_r($this->import_bkk[$c]);
+                                               
$value=substr($data,$this->import_bkk_offset[$this->import_bkk[$c]],$this->import_bkk_len[$this->import_bkk[$c]]);
+                                               $name=$this->import_bkk[$c];
+                                               if ($name=='installasjonsnr')
+                                               {
+                                                       $name='anleggsnr';
+                                                       
$value=substr($data,43,9)." ".substr($data,54,4);
+                                               }
+                                               if ($name=='netto')
+                                               {
+                                                       $name='belop';
+                                                       
$value=(floatval(substr($data,157,14)) + floatval(substr($data,172,14)))/100;
+                                                       $valid_data= True;      
                        
+                                               }
+//echo 'name :'.$name;
+//echo '  value :'.$value.'<br>';
+//print_r($buffer);
+
+                                               $buffer = 
$this->import_new_attrib($buffer,$name,$value,$invoice_common);
+                                       }
+                               }
+                               if ($valid_data)
+                               {
+                                       $buffer = 
$this->import_end_record($buffer,$invoice_common);
+                                       $valid_data= False;
+                               }
+                       }
+                       fclose($fp);
+//print_r($buffer);
+
+
+//echo 'download'.$download.'<br>';
+
+                       if(!$download)
+                       {
+                               $buffer = 
$this->import_end_file($buffer,$invoice_common['bilagsnr']);
+                       }
+
+                       return $buffer;
+               }
+               
+
+               function import_start_file($buffer)
+               {
+                       return $buffer;
+               }
+
+               function import_start_record($buffer)
+               {
+//print_r($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);
+//print_r($buffer);
+                       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=='anleggsnr')
+                               {
+                                       $buffer[$this->id]['merknad'] = 
'anleggsnr:' . $value;
+                                       
+                                       
$maalerinfo=$this->soXport->anleggsnr_to_objekt($value);
+                                       $dima=$maalerinfo['dima'];
+                                       $loc1=$maalerinfo['loc1'];
+//                                     $maalernr=$maalerinfo['maalernr'];
+                                       $omraade=$maalerinfo['district'];
+                               }
+                               if($name=='stedsnavn')
+                               {
+                                       $buffer[$this->id]['merknad'] .= "\r\n" 
. $value;
+                               }
+
+                               if($name=='dima' && 
$invoice_common['auto_tax']):
+                               {
+                                       
$mvakode=$this->soXport->auto_tax($value);
+                                       
+                                       if($mvakode)
+                                       {
+                                               $buffer[$this->id]['mvakode'] = 
$mvakode;
+                                       }
+                                       else
+                                       {
+                                               $buffer[$this->id]['mvakode'] = 
$this->mvakode;
+                                       }
+                               }
+                               elseif($name=='dima' && 
!$invoice_common['auto_tax']):
+                               {
+                                       $buffer[$this->id]['mvakode'] = 
$this->mvakode;
+                               }
+                               endif;
+
+                               $buffer[$this->id][$name] = $value;
+                               $buffer[$this->id]['bilagsnr'] = 
$this->next_bilagsnr;
+                               $buffer[$this->id]['fakturanr'] = 
$invoice_common['invoice_num'];
+                               $buffer[$this->id]['dima'] = $dima;
+                               $buffer[$this->id]['loc1'] = $loc1;
+                               $buffer[$this->id]['omraade'] = $omraade;
+//                             $buffer[$this->id]['maalernr'] = $maalernr;
+                               $buffer[$this->id]['splitt'] = $this->splitt;
+                               $buffer[$this->id]['kildeid'] = $this->kildeid;
+//                             $buffer[$this->id]['mvakode'] = $this->mvakode;
+                               $buffer[$this->id]['spbudact_code'] = 
$this->spbudact_code;
+                               $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]