fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [16992] rental: sync party customer id


From: sigurdne
Subject: [Fmsystem-commits] [16992] rental: sync party customer id
Date: Mon, 21 Aug 2017 09:02:31 -0400 (EDT)

Revision: 16992
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16992
Author:   sigurdne
Date:     2017-08-21 09:02:30 -0400 (Mon, 21 Aug 2017)
Log Message:
-----------
rental: sync party customer id

Modified Paths:
--------------
    trunk/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php

Modified: 
trunk/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
===================================================================
--- trunk/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php   
2017-08-21 12:52:56 UTC (rev 16991)
+++ trunk/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php   
2017-08-21 13:02:30 UTC (rev 16992)
@@ -58,6 +58,7 @@
                         * prosjekt
                         * tjeneste
                         */
+//                     $fellesdata->update_customer_id();
                        $fellesdata->update_vendor();
        //              $fellesdata->update_agresso_prosjekt(); //for mange 
treff
        //              $fellesdata->update_art();                              
//for mange treff
@@ -73,6 +74,9 @@
                        //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/agresso/tjeneste?id=88010
 
                        //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/agresso/leverandorer?leverandorNr=722920
+                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/agresso/kundeinfo?organisasjonsnummer="998391407";
+
+
                        if ($this->debug)
                        {
                                _debug_array($fellesdata->unit_ids);
@@ -359,6 +363,50 @@
                        $db->transaction_commit();
                }
 
+               function update_customer_id(  )
+               {
+                       //curl -s -u portico:BgPor790gfol 
http://tjenester.usrv.ubergenkom.no/api/agresso/kundeinfo?organisasjonsnummer="998391407";
+                       $sql = "SELECT id, identifier FROM rental_party"
+                               . " WHERE (customer_id = 0 OR customer_id IS 
NULL)"
+                               . " AND (length(identifier) = 9 OR 
length(identifier) = 11)";
+
+                       $GLOBALS['phpgw']->db->query($sql, __LINE__, __FILE__);
+
+                       $parties = array();
+                       while ($GLOBALS['phpgw']->db->next_record())
+                       {
+                               $parties[] = array(
+                                       'id'    => 
$GLOBALS['phpgw']->db->f('id'),
+                                       'identifier'    => 
$GLOBALS['phpgw']->db->f('identifier')
+                               );
+                       }
+
+                       foreach ($parties as $party)
+                       {
+               //              $this->soap_url= 
'http://tjenester.usrv.ubergenkom.no/api/agresso'; //test url
+                               $url = 
"{$this->soap_url}/kundeinfo?organisasjonsnummer='{$party['identifier']}'";
+                               $values = array();
+                               try
+                               {
+                                       $values = 
$this->check_external_register($url);
+                               }
+                               catch (Exception $exc)
+                               {
+                                       echo $exc->getTraceAsString();
+                               }
+
+                               if(!empty($values[0]['kundenr']))
+                               {
+                                       $customer_id = 
(int)$values[0]['kundenr'];
+                                       $sql = "UPDATE rental_party"
+                                               . " SET customer_id = 
{$customer_id}"
+                                               . " WHERE id = " . 
(int)$party['id'];
+                                       _debug_array($sql);
+                                       $GLOBALS['phpgw']->db->query($sql, 
__LINE__, __FILE__);
+                               }
+                       }
+               }
+
                /*
                 * ansvar
                 * art
@@ -700,9 +748,13 @@
 
                public function check_external_register($url)
                {
-                       $username = $this->soap_username; //'portico';
-                       $password = $this->soap_password; //'BgPor790gfol';
+                       $username = $this->soap_username;
+                       $password = $this->soap_password;
 
+                       /*Test server*/
+//                     $username = 'portico';
+//                     $password = 'BgPor790gfol';
+
                        $ch = curl_init();
                        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
                        curl_setopt($ch, CURLOPT_URL, $url);




reply via email to

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