fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [8560] bkbooking: fixes for agresso export


From: Kjell Arne Espedal
Subject: [Fmsystem-commits] [8560] bkbooking: fixes for agresso export
Date: Thu, 12 Jan 2012 11:53:03 +0000

Revision: 8560
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8560
Author:   kjell
Date:     2012-01-12 11:52:18 +0000 (Thu, 12 Jan 2012)
Log Message:
-----------
bkbooking: fixes for agresso export

Modified Paths:
--------------
    trunk/booking/inc/class.customer_identifier.inc.php
    trunk/booking/inc/class.socompleted_reservation.inc.php
    trunk/booking/inc/class.socompleted_reservation_export.inc.php

Modified: trunk/booking/inc/class.customer_identifier.inc.php
===================================================================
--- trunk/booking/inc/class.customer_identifier.inc.php 2012-01-11 20:25:26 UTC 
(rev 8559)
+++ trunk/booking/inc/class.customer_identifier.inc.php 2012-01-12 11:52:18 UTC 
(rev 8560)
@@ -31,9 +31,13 @@
                     {
                        
$to_entity[$this->field_prefix.$from_entity_customer_identifier] = 
$from_entity['customer_number'];
                     }
+                    elseif 
(strlen($from_entity['customer_organization_number']) == 5) 
+                                       {
+                       
$to_entity[$this->field_prefix.$from_entity_customer_identifier] = 
$from_entity['customer_organization_number'];
+                                       }                       
                     else
                     {
-                               
$to_entity[$this->field_prefix.$from_entity_customer_identifier] = '';
+                               
$to_entity[$this->field_prefix.$from_entity_customer_identifier] = lang('None');
                     }
                 } 
                 else 

Modified: trunk/booking/inc/class.socompleted_reservation.inc.php
===================================================================
--- trunk/booking/inc/class.socompleted_reservation.inc.php     2012-01-11 
20:25:26 UTC (rev 8559)
+++ trunk/booking/inc/class.socompleted_reservation.inc.php     2012-01-12 
11:52:18 UTC (rev 8560)
@@ -150,9 +150,6 @@
                                'season_id'                             => 
isset($reservation['season_id']) ? $reservation['season_id'] : null,
                        );
                        
-                       //echo "$type\n";
-                       //print_r($reservation);
-                       
                        $method = "initialize_completed_{$type}";
                        $this->$method($reservation, $entity);
                        $this->set_description($type, $reservation, $entity);
@@ -265,12 +262,22 @@
             if (intval($organization['customer_internal']) == 1) {
                 if (strlen($organization['customer_number']) == 5) {
                     $entity['customer_organization_number'] = 
$organization['customer_number'];
+                       $entity['customer_identifier_type'] = 
'organization_number';
+                } elseif ($organization['customer_identifier_type'] == 'ssn') {
+                    $entity['customer_ssn'] = $organization['customer_ssn'];
+                       $entity['customer_identifier_type'] = 'ssn';
+                } elseif ($organization['customer_identifier_type'] == 
'organization_number') {
+                    $entity['customer_organization_number'] = 
$organization['customer_organization_number'];
+                       $entity['customer_identifier_type'] = 
'organization_number';
                 } else {
                     $entity['customer_organization_number'] = '';
+                       $entity['customer_identifier_type'] = '';
                 }
             } else {
                 $entity['customer_organization_number'] = 
$organization['organization_number'];
-            }
+                $entity['customer_identifier_type'] = 'organization_number';
+                       }
+                       
                }
                
                protected function initialize_completed_booking(&$booking, 
&$entity) {
@@ -311,8 +318,25 @@
                }
                
                protected function initialize_completed_event(&$event, 
&$entity) {
-                       $this->set_customer_type($entity, $event);
-                       $this->copy_customer_identifier($event, $entity);
+
+                       if($event['customer_organization_id'] > 0) {
+                               static $soorg;
+                               static $cache = array();
+
+                               !$soorg AND $soorg = 
CreateObject('booking.soorganization');
+                               if 
(isset($cache[$event['customer_organization_id']])) {
+                                       $org = 
$cache[$event['customer_organization_id']];
+                               } else {
+                                       $org = 
$soorg->read_single($event['customer_organization_id']);
+                                       
$cache[$event['customer_organization_id']] = $org;
+                               }
+                               $this->set_organization($entity, $org);         
                
+                               $this->set_customer_type($entity, $org);
+                               $this->copy_customer_identifier($event, 
$entity);
+                       } else {
+                               $this->set_customer_type($entity, $event);
+                               $this->copy_customer_identifier($event, 
$entity);
+                       }
                }
                
                public function update_exported_state_of(&$reservations, 
$with_export_id) {

Modified: trunk/booking/inc/class.socompleted_reservation_export.inc.php
===================================================================
--- trunk/booking/inc/class.socompleted_reservation_export.inc.php      
2012-01-11 20:25:26 UTC (rev 8559)
+++ trunk/booking/inc/class.socompleted_reservation_export.inc.php      
2012-01-12 11:52:18 UTC (rev 8560)
@@ -638,8 +638,6 @@
                        $trans_type = str_pad(substr(strtoupper('42'), 0, 2), 
2, ' ');
                        $voucher_type = str_pad(substr(strtoupper('FK'), 0, 2), 
2, ' ');
                        
-//                     echo "<pre>";print_r($reservations);exit;       
-                       
                        foreach($reservations as &$reservation) {
                                if ($this->get_cost_value($reservation['cost']) 
<= 0) {
                                        continue; //Don't export costless rows
@@ -648,8 +646,8 @@
                                $order_id = 
$sequential_number_generator->increment()->get_current();
                                $export_info[] = 
$this->create_export_item_info($reservation, $order_id);
                                
-                               $reservation = array_map('utf8_decode', 
$reservation);
-                               
+       //                      $reservation = array_map('utf8_decode', 
$reservation);
+
                                //header level
                                $header = $this->get_agresso_row_template();
                                $header['accept_flag'] = '1';
@@ -688,8 +686,8 @@
                                $header['line_no'] = '0000'; //Nothing here 
according to example file but spec. says so
                                
                                //Topptekst til faktura, knyttet mot fagavdeling
-                               $header['long_info1'] = 
str_pad(substr($account_codes['invoice_instruction'], 0, 120), 120, ' ');
-                               
+                               $header['long_info1'] = 
str_pad(substr(iconv("utf-8","windows-1252",$account_codes['invoice_instruction']),
 0, 120), 120, ' ');
+
                                //Ordrenr. UNIKT, løpenr. genereres i booking 
ut fra gitt serie, eks. 38000000
                                $header['order_id'] = str_pad($order_id, 9, 0, 
STR_PAD_LEFT);
                                
@@ -714,7 +712,7 @@
                                /* Data hentes fra booking, tidspunkt legges i 
eget felt som kommer på 
                                 * linjen under: 78_short_info. <navn på bygg>, 
 <navn på ressurs>
                                 */
-                               $item['art_descr'] = 
str_pad(substr($reservation['article_description'], 0, 35), 35, ' '); //35 
chars long
+                               $item['art_descr'] = 
str_pad(substr(iconv("utf-8","windows-1252",$reservation['article_description']),
 0, 35), 35, ' '); //35 chars long
                                
                                //Artikkel opprettes i Agresso (4 siffer), en 
for kultur og en for idrett, inneholder konteringsinfo.
                                $item['article'] = 
str_pad(substr(strtoupper($account_codes['article']), 0, 15), 15, ' ');
@@ -770,7 +768,7 @@
                                $text['batch_id'] = $header['batch_id'];
                                $text['client'] = $header['client'];
                                $text['line_no'] = $item['line_no']; 
-                               $text['short_info'] = 
str_pad(substr($reservation['description'], 0, 60), 60, ' ');
+                               $text['short_info'] = 
str_pad(substr(iconv("utf-8","windows-1252",$reservation['description']), 0, 
60), 60, ' ');
                                $text['trans_type'] = $header['trans_type'];
                                $text['voucher_type'] = $header['voucher_type'];
                                
@@ -781,6 +779,7 @@
                                $output[] = implode('', str_replace(array("\n", 
"\r"), '', $header));
                                $output[] = implode('', str_replace(array("\n", 
"\r"), '', $item));
                                $output[] = implode('', str_replace(array("\n", 
"\r"), '', $text));
+
                        }
                        
                        if (count($export_info) == 0) {




reply via email to

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