fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [7542] catch: fix and rename custom function


From: Sigurd Nes
Subject: [Fmsystem-commits] [7542] catch: fix and rename custom function
Date: Wed, 31 Aug 2011 18:20:23 +0000

Revision: 7542
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7542
Author:   sigurdne
Date:     2011-08-31 18:20:22 +0000 (Wed, 31 Aug 2011)
Log Message:
-----------
catch: fix and rename custom function

Modified Paths:
--------------
    trunk/catch/inc/custom/default/update_location_at_record.php

Removed Paths:
-------------
    trunk/catch/inc/custom/default/update_location_at_record_nlsh.php

Modified: trunk/catch/inc/custom/default/update_location_at_record.php
===================================================================
--- trunk/catch/inc/custom/default/update_location_at_record.php        
2011-08-31 18:16:53 UTC (rev 7541)
+++ trunk/catch/inc/custom/default/update_location_at_record.php        
2011-08-31 18:20:22 UTC (rev 7542)
@@ -1,56 +1,116 @@
 <?php
                if(!isset($this->db) || !is_object($this->db))
                {
-                       $this->db           = & $GLOBALS['phpgw']->db;
+                       $this->db               = & $GLOBALS['phpgw']->db;
+                       $this->like             = & $this->db->like;            
                }
-               
+
+               $this->db2              = clone($this->db);
+
                if(!isset($target_table) || !$target_table)
                {
                        $target_table = 
"fm_{$this->type_app[$this->type]}_{$entity_id}_{$cat_id}";
                }
-               
+
                $ids = array();
-               $this->db->query("SELECT id FROM $target_table WHERE 
location_code is NULL",__LINE__,__FILE__);
+               $this->db->query("SELECT id FROM $target_table WHERE 
(location_code is NULL OR location_code = '') OR (target_id IS NOT NULL AND 
location_id IS NOT NULL AND p_num IS NULL)",__LINE__,__FILE__);
                while ($this->db->next_record())
                {
                        $ids[] = $this->db->f('id');
                }
-               
+
                foreach ($ids as $_id)
                {
+                       $value_set = array();
                        $this->db->query("SELECT * FROM $target_table WHERE id 
= {$_id}",__LINE__,__FILE__);
                        $this->db->next_record();
-               
-                       $loc_fields = array
-                       (
-                               'eiendomid',
-                               'byggid',
-                               'etasjeid',
-                               'bruksenhetid',
-                               'romid'
-                       );
 
-                       $location = array();
-                       $value_set = array();
-                       $j = 1;
-                       foreach ($loc_fields as $loc)
+                       $location_id = $this->db->f('location_id');
+                       $target_id = $this->db->f('target_id');
+
+                       if($location_id  && $target_id)
                        {
-                               if($this->db->f($loc))
+                               $origin = 
$GLOBALS['phpgw']->locations->get_name($location_id);
+                               $origin_table =  
$GLOBALS['phpgw']->locations->get_attrib_table($origin['appname'], 
$origin['location']);
+                               $origin_arr = explode('_', $origin_table);
+                               $p_entity_id = $origin_arr[2];
+                               $p_cat_id = $origin_arr[3];
+                               if($origin_table)
                                {
-                                       $location[] = $this->db->f($loc);
-                                       $value_set["loc{$j}"] = 
$this->db->f($loc);     
+                                       $this->db2->query("SELECT 
location_code, address FROM {$origin_table} WHERE num = 
'{$target_id}'",__LINE__,__FILE__);
+                                       $this->db2->next_record();
+                                       $origin_location_code           = 
$this->db2->f('location_code');
+                                       $origin_address                         
= $this->db2->f('address');
+                                       $value_set['location_code'] = 
$origin_location_code;
+                                       $value_set['p_num']             = 
$target_id;
+                                       $value_set['p_entity_id']       = 
$p_entity_id;
+                                       $value_set['p_cat_id']          = 
$p_cat_id;
+                                       $origin_location_code_arr       = 
explode('-',$origin_location_code);
+                                       if($origin_location_code_arr)
+                                       {
+                                               $j=1;
+                                               
foreach($origin_location_code_arr as $_loc)
+                                               {
+                                                       $value_set["loc{$j}"]   
= $_loc;
+                                                       $j++;
+                                               }
+                                       }
+                                       $value_set['address']   = 
$origin_address;
                                }
-                               else
+                       }
+                       else
+                       {
+                               $loc_fields = array
+                               (
+                                       'eiendomid',
+                                       'byggid',
+                                       'etasjeid',
+                                       'bruksenhetid',
+                                       'romid'
+                               );
+
+                               $location = array();
+                               $j = 1;
+                               foreach ($loc_fields as $loc)
                                {
-                                       break;
+                                       if($this->db->f($loc))
+                                       {
+
+// 8.April 11: 'romid' is now loc5
+/*
+                                               if($loc == 'romid')
+                                               {
+                                                       
$this->db2->query("SELECT loc5 FROM fm_location5 WHERE rom_nr_id = '" . 
$this->db->f($loc) . "' AND location_code {$this->like} '" . implode('-', 
$location) . "%'",__LINE__,__FILE__);
+       
+                                                       
$this->db2->next_record();
+                                                       
if($this->db2->f('loc5'))
+                                                       {
+                                                               $location[] = 
$this->db2->f('loc5');
+                                                               
$value_set["loc{$j}"] = $this->db2->f('loc5');
+                                                       }
+                                               }
+                                               else
+*/
+                                               {
+                                                       $location[] = 
$this->db->f($loc);
+                                                       $value_set["loc{$j}"] = 
$this->db->f($loc);
+                                               }
+                                       }
+                                       else
+                                       {
+                                               break;
+                                       }
+                                       $j++;
                                }
-                               $j++;
+                               if($location)
+                               {
+                                       $value_set['location_code'] = 
implode('-', $location);
+                               }
                        }
-               
-                       if($location)
+
+                       if($value_set)
                        {
-                               $value_set['location_code'] = implode('-', 
$location);
                                $value_set      = 
$this->db->validate_update($value_set);
-                               $this->db->query("UPDATE $target_table SET 
$value_set WHERE id= {$_id}",__LINE__,__FILE__);
+                               $this->db->query("UPDATE $target_table SET 
$value_set WHERE id={$_id}",__LINE__,__FILE__);
                        }
                }

Deleted: trunk/catch/inc/custom/default/update_location_at_record_nlsh.php
===================================================================
--- trunk/catch/inc/custom/default/update_location_at_record_nlsh.php   
2011-08-31 18:16:53 UTC (rev 7541)
+++ trunk/catch/inc/custom/default/update_location_at_record_nlsh.php   
2011-08-31 18:20:22 UTC (rev 7542)
@@ -1,116 +0,0 @@
-<?php
-               if(!isset($this->db) || !is_object($this->db))
-               {
-                       $this->db               = & $GLOBALS['phpgw']->db;
-                       $this->like             = & $this->db->like;            
-               }
-
-               $this->db2              = clone($this->db);
-
-               if(!isset($target_table) || !$target_table)
-               {
-                       $target_table = 
"fm_{$this->type_app[$this->type]}_{$entity_id}_{$cat_id}";
-               }
-
-               $ids = array();
-               $this->db->query("SELECT id FROM $target_table WHERE 
(location_code is NULL OR location_code = '') OR (target_id IS NOT NULL AND 
location_id IS NOT NULL AND p_num IS NULL)",__LINE__,__FILE__);
-               while ($this->db->next_record())
-               {
-                       $ids[] = $this->db->f('id');
-               }
-
-               foreach ($ids as $_id)
-               {
-                       $value_set = array();
-                       $this->db->query("SELECT * FROM $target_table WHERE id 
= {$_id}",__LINE__,__FILE__);
-                       $this->db->next_record();
-
-                       $location_id = $this->db->f('location_id');
-                       $target_id = $this->db->f('target_id');
-
-                       if($location_id  && $target_id)
-                       {
-                               $origin = 
$GLOBALS['phpgw']->locations->get_name($location_id);
-                               $origin_table =  
$GLOBALS['phpgw']->locations->get_attrib_table($origin['appname'], 
$origin['location']);
-                               $origin_arr = explode('_', $origin_table);
-                               $p_entity_id = $origin_arr[2];
-                               $p_cat_id = $origin_arr[3];
-                               if($origin_table)
-                               {
-                                       $this->db2->query("SELECT 
location_code, address FROM {$origin_table} WHERE num = 
'{$target_id}'",__LINE__,__FILE__);
-                                       $this->db2->next_record();
-                                       $origin_location_code           = 
$this->db2->f('location_code');
-                                       $origin_address                         
= $this->db2->f('address');
-                                       $value_set['location_code'] = 
$origin_location_code;
-                                       $value_set['p_num']             = 
$target_id;
-                                       $value_set['p_entity_id']       = 
$p_entity_id;
-                                       $value_set['p_cat_id']          = 
$p_cat_id;
-                                       $origin_location_code_arr       = 
explode('-',$origin_location_code);
-                                       if($origin_location_code_arr)
-                                       {
-                                               $j=1;
-                                               
foreach($origin_location_code_arr as $_loc)
-                                               {
-                                                       $value_set["loc{$j}"]   
= $_loc;
-                                                       $j++;
-                                               }
-                                       }
-                                       $value_set['address']   = 
$origin_address;
-                               }
-                       }
-                       else
-                       {
-                               $loc_fields = array
-                               (
-                                       'eiendomid',
-                                       'byggid',
-                                       'etasjeid',
-                                       'bruksenhetid',
-                                       'romid'
-                               );
-
-                               $location = array();
-                               $j = 1;
-                               foreach ($loc_fields as $loc)
-                               {
-                                       if($this->db->f($loc))
-                                       {
-
-// 8.April 11: 'romid' is now loc5
-/*
-                                               if($loc == 'romid')
-                                               {
-                                                       
$this->db2->query("SELECT loc5 FROM fm_location5 WHERE rom_nr_id = '" . 
$this->db->f($loc) . "' AND location_code {$this->like} '" . implode('-', 
$location) . "%'",__LINE__,__FILE__);
-       
-                                                       
$this->db2->next_record();
-                                                       
if($this->db2->f('loc5'))
-                                                       {
-                                                               $location[] = 
$this->db2->f('loc5');
-                                                               
$value_set["loc{$j}"] = $this->db2->f('loc5');
-                                                       }
-                                               }
-                                               else
-*/
-                                               {
-                                                       $location[] = 
$this->db->f($loc);
-                                                       $value_set["loc{$j}"] = 
$this->db->f($loc);
-                                               }
-                                       }
-                                       else
-                                       {
-                                               break;
-                                       }
-                                       $j++;
-                               }
-                               if($location)
-                               {
-                                       $value_set['location_code'] = 
implode('-', $location);
-                               }
-                       }
-
-                       if($value_set)
-                       {
-                               $value_set      = 
$this->db->validate_update($value_set);
-                               $this->db->query("UPDATE $target_table SET 
$value_set WHERE id={$_id}",__LINE__,__FILE__);
-                       }
-               }




reply via email to

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