fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15426] Property: update integration with oracle data


From: sigurdne
Subject: [Fmsystem-commits] [15426] Property: update integration with oracle database
Date: Fri, 5 Aug 2016 16:12:38 +0000 (UTC)

Revision: 15426
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15426
Author:   sigurdne
Date:     2016-08-05 16:12:38 +0000 (Fri, 05 Aug 2016)
Log Message:
-----------
Property: update integration with oracle database

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   
2016-08-05 11:07:51 UTC (rev 15425)
+++ trunk/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php   
2016-08-05 16:12:38 UTC (rev 15426)
@@ -56,7 +56,7 @@
 
                        if ($this->debug)
                        {
-//                             _debug_array($fellesdata->unit_ids);
+                               _debug_array($fellesdata->unit_ids);
                        }
 
                        try
@@ -248,7 +248,8 @@
                                return false;
                        }
 
-                       $db = createObject('phpgwapi.db', null, null, true);
+//                     $db = createObject('phpgwapi.db', null, null, true);
+                       $db = createObject('property.db_oci8');
 
                        $db->debug = false;
                        $db->Host = 
$this->config->config_data['fellesdata']['host'];
@@ -279,7 +280,7 @@
                        $db->transaction_begin();
 
                        $units = $this->unit_ids;
-
+//                     _debug_array($units);
                        foreach ($units as $unit)
                        {
                                $value_set = array
@@ -333,17 +334,16 @@
                        }
 
                        $sql = "SELECT ORG_ENHET_ID, V_ORG_ENHET.ORG_NAVN FROM 
V_ORG_ENHET";
-//                     $sql = "SELECT * FROM V_ORG_ENHET";
                        $db->query($sql, __LINE__, __FILE__);
                        while ($db->next_record())
                        {
                                $org_unit_id = $db->f('ORG_ENHET_ID');
                                $name = $db->f('ORG_NAVN', true);
-
                                $this->names[$org_unit_id] = $name;
                        }
 
-                       $sql = "SELECT V_ORG_ENHET.ORG_ENHET_ID, 
V_ORG_ENHET.ORG_NAVN FROM V_ORG_ENHET"
+//                     _debug_array($this->names);
+                       $sql = "SELECT V_ORG_ENHET.ORG_ENHET_ID, 
V_ORG_ENHET.ORG_NAVN, V_ORG_ENHET.TJENESTESTED, V_ORG_ENHET.ORG_NIVAA FROM 
V_ORG_ENHET"
                                . " WHERE V_ORG_ENHET.ORG_NIVAA = 1 ORDER BY 
V_ORG_ENHET.ORG_NAVN ASC";
 
                        $db->query($sql);
@@ -351,38 +351,55 @@
                        while ($db->next_record())
                        {
                                $org_unit_id = $db->f('ORG_ENHET_ID');
+                               $arbeidssted = $db->f('TJENESTESTED');
                                $this->unit_ids[] = array
                                        (
                                        'id' => $org_unit_id,
                                        'name' => $this->names[$org_unit_id],
-                                       'parent' => ''
+                                       'parent' => '',
+                                       'arbeidssted'   => $arbeidssted
                                );
 
                                $this->get_org_unit_ids_children($org_unit_id);
                        }
-
                        return $this->unit_ids;
                }
 
                function get_org_unit_ids_children( $org_unit_id )
                {
                        $org_unit_id = (int)$org_unit_id;
-                       $db = clone($this->db);
+                       /*
+                        * FIXME: doe not work for db_oci8;
+                        */
+//                     $db = clone($this->db);
+                       $db = createObject('property.db_oci8');
 
-                       $q = "SELECT V_ORG_KNYTNING.*, 
ANT_ENHETER_UNDER,V_ORG_ENHET.ORG_NAVN,ORG_NIVAA FROM V_ORG_KNYTNING"
-                               . " JOIN V_ORG_ENHET ON 
(V_ORG_ENHET.ORG_ENHET_ID = V_ORG_KNYTNING.ORG_ENHET_ID_KNYTNING ) WHERE 
V_ORG_KNYTNING.ORG_ENHET_ID_KNYTNING=$org_unit_id";
+                       $db->debug = false;
+                       $db->Host = $this->db->Host;
+                       $db->Port = $this->db->Port;
+                       $db->Type = $this->db->Type;
+                       $db->Database = $this->db->Database;
+                       $db->User = $this->db->User;
+                       $db->Password = $this->db->Password;
+                       $db->connect();
 
-                       $db->query($q);
+                       $sql = "SELECT V_ORG_KNYTNING.*, 
ANT_ENHETER_UNDER,V_ORG_ENHET.ORG_NAVN, V_ORG_ENHET.TJENESTESTED, ORG_NIVAA 
FROM V_ORG_KNYTNING"
+                               . " JOIN V_ORG_ENHET ON 
(V_ORG_ENHET.ORG_ENHET_ID = V_ORG_KNYTNING.ORG_ENHET_ID_KNYTNING ) WHERE 
V_ORG_KNYTNING.ORG_ENHET_ID_KNYTNING={$org_unit_id}";
 
+                       $db->query($sql);
+
                        while ($db->next_record())
                        {
                                $child_org_unit_id = $db->f('ORG_ENHET_ID');
+                               $arbeidssted = $db->f('TJENESTESTED');
                                $this->unit_ids[] = array
                                        (
                                        'id' => $child_org_unit_id,
                                        'name' => 
$this->names[$child_org_unit_id],
                                        'parent' => $org_unit_id,
-                                       'level' => $db->f('ORG_NIVAA')
+                                       'level' => $db->f('ORG_NIVAA'),
+                                       'arbeidssted'   => $arbeidssted,
+                                       'ant_enheter_under'     => 
$db->f('ANT_ENHETER_UNDER')
                                );
 
                                if ($db->f('ANT_ENHETER_UNDER'))
@@ -390,5 +407,6 @@
                                        
$this->get_org_unit_ids_children($child_org_unit_id);
                                }
                        }
+                       unset($db);
                }
        }
\ No newline at end of file




reply via email to

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