[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [7183] catch: postprocessing
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [7183] catch: postprocessing |
Date: |
Tue, 05 Apr 2011 19:08:05 +0000 |
Revision: 7183
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7183
Author: sigurdne
Date: 2011-04-05 19:08:04 +0000 (Tue, 05 Apr 2011)
Log Message:
-----------
catch: postprocessing
Modified Paths:
--------------
trunk/catch/inc/custom/default/update_location_at_record_nlsh.php
trunk/property/inc/cron/default/catch_ppc.php
Modified: trunk/catch/inc/custom/default/update_location_at_record_nlsh.php
===================================================================
--- trunk/catch/inc/custom/default/update_location_at_record_nlsh.php
2011-04-05 12:19:54 UTC (rev 7182)
+++ trunk/catch/inc/custom/default/update_location_at_record_nlsh.php
2011-04-05 19:08:04 UTC (rev 7183)
@@ -1,7 +1,7 @@
<?php
if(!isset($this->db) || !is_object($this->db))
{
- $this->db = & $GLOBALS['phpgw']->db;
+ $this->db = clone($GLOBALS['phpgw']->db);
$this->like = & $this->db->like;
}
@@ -22,52 +22,83 @@
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'
- );
+ if($location_id = $this->db->f('location_id') &&
$target_id = (int)$this->db->f('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];
- $location = array();
- $value_set = array();
- $j = 1;
- foreach ($loc_fields as $loc)
+ if($origin_table)
+ {
+ $this->db2->query("SELECT location_code
FROM {$origin_table} WHERE id = $target_id",__LINE__,__FILE__);
+ $this->db2->next_record();
+ $origin_location_code =
$this->db2->f('location_code');
+ $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(isset($origin_location_code_arr[4]))
+ {
+ $value_set['loc5']
= $origin_location_code_arr[4];
+ }
+ }
+
+ }
+ else
{
- if($this->db->f($loc))
+ $loc_fields = array
+ (
+ 'eiendomid',
+ 'byggid',
+ 'etasjeid',
+ 'bruksenhetid',
+ 'romid'
+ );
+
+ $location = array();
+ $j = 1;
+ foreach ($loc_fields as $loc)
{
- if($loc == 'romid')
+ if($this->db->f($loc))
{
- $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'))
+ if($loc == 'romid')
{
- $location[] =
$this->db2->f('loc5');
- $value_set["loc{$j}"] =
$this->db2->f('loc5');
+
$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
{
- $location[] =
$this->db->f($loc);
- $value_set["loc{$j}"] =
$this->db->f($loc);
+ break;
}
+ $j++;
}
- else
+ if($location)
{
- break;
+ $value_set['location_code'] =
implode('-', $location);
}
- $j++;
}
-
- 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__);
}
Modified: trunk/property/inc/cron/default/catch_ppc.php
===================================================================
--- trunk/property/inc/cron/default/catch_ppc.php 2011-04-05 12:19:54 UTC
(rev 7182)
+++ trunk/property/inc/cron/default/catch_ppc.php 2011-04-05 19:08:04 UTC
(rev 7183)
@@ -38,7 +38,7 @@
public function __construct()
{
- $this->db = & $GLOBALS['phpgw']->db;
+ $this->db = clone($GLOBALS['phpgw']->db);
$this->join = & $this->db->join;
$this->like = & $this->db->like;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [7183] catch: postprocessing,
Sigurd Nes <=