fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11519] property: new import


From: Sigurd Nes
Subject: [Fmsystem-commits] [11519] property: new import
Date: Mon, 09 Dec 2013 13:30:26 +0000

Revision: 11519
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11519
Author:   sigurdne
Date:     2013-12-09 13:30:24 +0000 (Mon, 09 Dec 2013)
Log Message:
-----------
property: new import

Modified Paths:
--------------
    trunk/property/inc/class.sotts.inc.php
    trunk/property/inc/class.uiimport.inc.php

Added Paths:
-----------
    
trunk/property/inc/import/default/cvs_import_oppdatering_av_bestilling_fra_agresso_bkb

Modified: trunk/property/inc/class.sotts.inc.php
===================================================================
--- trunk/property/inc/class.sotts.inc.php      2013-12-09 11:42:24 UTC (rev 
11518)
+++ trunk/property/inc/class.sotts.inc.php      2013-12-09 13:30:24 UTC (rev 
11519)
@@ -42,6 +42,7 @@
                public $sum_budget                      = 0;
                public $sum_actual_cost         = 0;
                public $sum_difference          = 0;
+               protected $global_lock = false;
 
                public $soap_functions = array
                        (
@@ -904,8 +905,16 @@
                        $this->db->next_record();
                        $old_status             = $this->db->f('status');
 
-                       $this->db->transaction_begin();
+                       if ( $this->db->get_transaction() )
+                       {
+                               $this->global_lock = true;
+                       }
+                       else
+                       {
+                               $this->db->transaction_begin();
+                       }
 
+
                        /*
                         ** phpgw_fm_tts_append.append_type - Defs
                         ** R - Reopen ticket
@@ -976,7 +985,10 @@
                                $receipt['message'][]= array('msg' => 
lang('Ticket %1 has been updated',$id));
                        }
 
-                       $this->db->transaction_commit();
+                       if ( !$this->global_lock )
+                       {
+                               $this->db->transaction_commit();
+                       }
 
                        return $receipt;
 

Modified: trunk/property/inc/class.uiimport.inc.php
===================================================================
--- trunk/property/inc/class.uiimport.inc.php   2013-12-09 11:42:24 UTC (rev 
11518)
+++ trunk/property/inc/class.uiimport.inc.php   2013-12-09 13:30:24 UTC (rev 
11519)
@@ -182,6 +182,7 @@
                                        switch ($file['type'])
                                        {
                                                case 
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
+                                               case 
'application/vnd.oasis.opendocument.spreadsheet':
                                                case 'application/vnd.ms-excel':
                                                        $this->csvdata = 
$this->getexceldata($file['name']);
                                                        $valid_type = true;
@@ -191,6 +192,8 @@
                                                        $this->csvdata = 
$this->getcsvdata($file['name']);
                                                        $valid_type = true;
                                                        break;
+                                               default:
+                                                       throw new 
Exception("Not a valid filetype: {$file['type']}");
                                        }
 
                                        if($valid_type)

Added: 
trunk/property/inc/import/default/cvs_import_oppdatering_av_bestilling_fra_agresso_bkb
===================================================================
--- 
trunk/property/inc/import/default/cvs_import_oppdatering_av_bestilling_fra_agresso_bkb
                              (rev 0)
+++ 
trunk/property/inc/import/default/cvs_import_oppdatering_av_bestilling_fra_agresso_bkb
      2013-12-09 13:30:24 UTC (rev 11519)
@@ -0,0 +1,93 @@
+<?php
+       class import_conversion
+       {
+               protected $db;
+               public $messages = array();
+               public $warnings = array();
+               public $errors = array();
+               public $fields = array();
+               public $debug = true;
+
+               public function __construct()
+               {
+                       set_time_limit(10000); //Set the time limit for this 
request
+                       $this->account          = 
(int)$GLOBALS['phpgw_info']['user']['account_id'];
+                       $this->db           = & $GLOBALS['phpgw']->db;
+                       
phpgwapi_cache::session_clear('property','tts_listing_metadata');
+               }
+
+               public function add($data)
+               {
+                       $fields =  $this->fields;
+
+               $agresso_prosjekt = $this->decode($data[0]);
+                       $prosjektstatus = $this->decode($data[1]);
+                       $order_id = $this->decode($data[2]);
+                       $actual_cost = (float)$this->decode($data[3]);
+
+                       $this->db->query("SELECT id, actual_cost FROM 
fm_tts_tickets WHERE order_id= '{$order_id}'",__LINE__,__FILE__);
+                       $this->db->next_record();
+                       $id = $this->db->f('id');
+                       $old_actual_cost = $this->db->f('actual_cost');
+
+                       if(!$id)
+                       {
+                               $this->errors[] = "Fant ikke bestillingen, 
hopper over: {$order_id}";
+                               return false;
+                       }
+
+                       $this->messages[] = "Oppdaterer melding #{$id}, gammelt 
beløp: {$old_actual_cost}, nytt beløp: {$actual_cost}";
+
+                       $value_set = array
+                       (
+                       'agresso_prosjekt' => $agresso_prosjekt,
+                               'actual_cost' => $actual_cost
+                       );
+
+                       $value_set      = 
$this->db->validate_update($value_set);
+                       $ok = $this->db->query("UPDATE fm_tts_tickets SET 
$value_set WHERE id={$id}",__LINE__,__FILE__);
+
+
+//                     $prosjektstatus;
+
+/*
+                       $ticket = array
+                       (
+                               'status' => '';
+                       );
+
+                       $sotts  = CreateObject('property.sotts');
+                       $sotts->update_status($ticket,$id)
+*/
+                       return $ok;
+               }
+
+
+               /**
+                * Convert from the locale encoding to UTF-8 encoding and 
escape single quotes
+                * 
+                * @param string $value The value to convert
+                * @return string
+                */
+               protected function decode($value)
+               {
+                       $converted = trim($value);// 
mb_convert_encoding($value, 'UTF-8');
+                       if ($this->is_null($converted))
+                       {
+                               return null;
+                       }
+                       return stripslashes($converted);
+               }
+
+               /**
+                * Test a value for null according to several formats that can 
exist in the export.
+                * Returns true if the value is null according to these rules, 
false otherwise.
+                * 
+                * @param string $value The value to test
+                * @return bool
+                */
+               protected function is_null($value)
+               {
+                       return ((trim($value) == "") || ($data == "<NULL>") || 
($data == "''"));
+               }
+       }




reply via email to

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