[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11301] property: convert p_num to integer
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11301] property: convert p_num to integer |
Date: |
Wed, 18 Sep 2013 11:45:08 +0000 |
Revision: 11301
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11301
Author: sigurdne
Date: 2013-09-18 11:45:08 +0000 (Wed, 18 Sep 2013)
Log Message:
-----------
property: convert p_num to integer
Modified Paths:
--------------
trunk/property/inc/class.bocommon.inc.php
trunk/property/inc/class.soentity.inc.php
trunk/property/inc/class.uientity.inc.php
trunk/property/inc/class.uiworkorder.inc.php
trunk/property/setup/setup.inc.php
trunk/property/setup/tables_update.inc.php
Modified: trunk/property/inc/class.bocommon.inc.php
===================================================================
--- trunk/property/inc/class.bocommon.inc.php 2013-09-18 10:43:56 UTC (rev
11300)
+++ trunk/property/inc/class.bocommon.inc.php 2013-09-18 11:45:08 UTC (rev
11301)
@@ -1979,6 +1979,28 @@
$values['extra'][$column] = phpgw::get_var($key, 'string', 'POST');
}
}
+
+
if(isset($values['extra']['p_entity_id']) && $values['extra']['p_entity_id'] &&
isset($values['extra']['p_cat_id']) && $values['extra']['p_cat_id'] &&
isset($values['extra']['p_num']) && $values['extra']['p_num'] )
+ {
+ //strip prefix and leading zeros
+ $values['extra']['p_num'] =
execMethod('property.soentity.convert_num_to_id', array
+ (
+ 'type'
=> $values['extra']['type'],
+ 'entity_id'
=> $values['extra']['p_entity_id'],
+ 'cat_id'
=> $values['extra']['p_cat_id'],
+ 'num'
=> $values['extra']['p_num']
+ )
+ );
+
+ $p_entity_id =
$values['extra']['p_entity_id'];
+ $p_cat_id =
$values['extra']['p_cat_id'];
+ $p_num =
$values['extra']['p_num'];
+
$values['p'][$p_entity_id]['p_entity_id'] = $p_entity_id;
+
$values['p'][$p_entity_id]['p_cat_id'] = $p_cat_id;
+
$values['p'][$p_entity_id]['p_num'] = $p_num;
+
$values['p'][$p_entity_id]['p_cat_name'] =
phpgw::get_var("entity_cat_name_{$p_entity_id}");
+
+ }
}
if(isset($insert_record['additional_info']) &&
is_array($insert_record['additional_info']))
{
Modified: trunk/property/inc/class.soentity.inc.php
===================================================================
--- trunk/property/inc/class.soentity.inc.php 2013-09-18 10:43:56 UTC (rev
11300)
+++ trunk/property/inc/class.soentity.inc.php 2013-09-18 11:45:08 UTC (rev
11301)
@@ -561,7 +561,7 @@
if ($p_num)
{
- $filtermethod .= " $where
$entity_table.p_num='$p_num'";
+ $filtermethod .= " $where
$entity_table.p_id='$p_num'";
$where= 'AND';
}
@@ -1855,13 +1855,21 @@
$this->db->transaction_begin();
+ if(isset($values_insert['p_num']) &&
$values_insert['p_num'])
+ {
+ // $p_category =
$admin_entity->read_single_category($values_insert['p_entity_id'],
$values_insert['p_cat_id']);
+ // $p_id = (int)
ltrim($values_insert['p_num'], $p_category['prefix']);
+ $p_id =
$values_insert['p_num'];
+ $p_location_id =
$GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type],
".{$this->type}.{$values_insert['p_entity_id']}.{$values_insert['p_cat_id']}");
+ }
+
+
if($category['is_eav'])
{
if(isset($values_insert['p_num']) &&
$values_insert['p_num'])
{
- $p_category =
$admin_entity->read_single_category($values_insert['p_entity_id'],
$values_insert['p_cat_id']);
- $values_insert['p_id']
= (int) ltrim($values_insert['p_num'], $p_category['prefix']);
- $values_insert['p_location_id'] =
$GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type],
".{$this->type}.{$values_insert['p_entity_id']}.{$values_insert['p_cat_id']}");
+ $values_insert['p_id']
= $p_id;
+ $values_insert['p_location_id'] =
$p_location_id;
}
$location_id =
$GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type],
".{$this->type}.{$entity_id}.{$cat_id}");
@@ -1877,6 +1885,11 @@
$values_insert['entry_date'] = time();
$values_insert['user_id'] = $this->account;
+ if(isset($values_insert['p_num']) &&
$values_insert['p_num'])
+ {
+ $values_insert['p_num'] = $p_id;
+ }
+
$this->db->query("INSERT INTO {$table} (" .
implode(',',array_keys($values_insert)) . ') VALUES ('
.
$this->db->validate_insert(array_values($values_insert)) .
')',__LINE__,__FILE__);
@@ -2157,19 +2170,33 @@
$this->db->transaction_begin();
+
+ if(isset($value_set['p_num']) && $value_set['p_num'])
+ {
+ // $p_category =
$admin_entity->read_single_category($value_set['p_entity_id'],
$value_set['p_cat_id']);
+ // $p_id = (int)
ltrim($value_set['p_num'], $p_category['prefix']);
+ $p_id = $value_set['p_num'];
+ $p_location_id =
$GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type],
".{$this->type}.{$value_set['p_entity_id']}.{$value_set['p_cat_id']}");
+ }
+
+
if($category['is_eav'])
{
if(isset($value_set['p_num']) &&
$value_set['p_num'])
{
- $p_category =
$admin_entity->read_single_category($value_set['p_entity_id'],
$value_set['p_cat_id']);
- $value_set['p_id']
= (int) ltrim($value_set['p_num'], $p_category['prefix']);
- $value_set['p_location_id'] =
$GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type],
".{$this->type}.{$value_set['p_entity_id']}.{$value_set['p_cat_id']}");
+ $value_set['p_id']
= $p_id;
+ $value_set['p_location_id'] =
$p_location_id;
}
$this->_edit_eav($value_set, $location_id,
".{$this->type}.{$entity_id}.{$cat_id}", $values['id']);
}
else
{
+ if(isset($value_set['p_num']) &&
$value_set['p_num'])
+ {
+ $value_set['p_num'] = $p_id;
+ }
+
$value_set =
$this->db->validate_update($value_set);
$this->db->query("UPDATE $table set $value_set
WHERE id=" . $values['id'],__LINE__,__FILE__);
}
@@ -2562,4 +2589,22 @@
return $this->db->transaction_commit();
}
+
+ public function convert_num_to_id($data = array())
+ {
+ $entity_id = (int) $data['entity_id'];
+ $cat_id = (int) $data['cat_id'];
+ $num = $data['num'];
+
+ $id = '';
+ if($num)
+ {
+ $admin_entity =
CreateObject('property.soadmin_entity');
+ $admin_entity->type = isset($data['type']) &&
$data['type'] ? $data['type'] : 'entity';
+ $category =
$admin_entity->read_single_category($entity_id, $cat_id);
+
+ $id = (int) ltrim($num,
$category['prefix']);
+ }
+ return $id;
+ }
}
Modified: trunk/property/inc/class.uientity.inc.php
===================================================================
--- trunk/property/inc/class.uientity.inc.php 2013-09-18 10:43:56 UTC (rev
11300)
+++ trunk/property/inc/class.uientity.inc.php 2013-09-18 11:45:08 UTC (rev
11301)
@@ -2211,7 +2211,7 @@
}
}
- $related =
$this->bo->read_entity_to_link(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'id'=>$values['num']));
+ $related =
$this->bo->read_entity_to_link(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'id'=>$id));
$_related = array();
if(isset($related['related']))
Modified: trunk/property/inc/class.uiworkorder.inc.php
===================================================================
--- trunk/property/inc/class.uiworkorder.inc.php 2013-09-18 10:43:56 UTC
(rev 11300)
+++ trunk/property/inc/class.uiworkorder.inc.php 2013-09-18 11:45:08 UTC
(rev 11301)
@@ -992,7 +992,6 @@
$project =
(isset($values['project_id'])?$boproject->read_single_mini($values['project_id']):'');
-
if (isset($values['save']))
{
if($GLOBALS['phpgw']->session->is_repost())
@@ -1021,6 +1020,8 @@
}
$insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record','property');
+
+/*
if(isset($insert_record_entity) &&
is_array($insert_record_entity))
{
for
($j=0;$j<count($insert_record_entity);$j++)
@@ -1028,7 +1029,7 @@
$insert_record['extra'][$insert_record_entity[$j]] =
$insert_record_entity[$j];
}
}
-
+*/
if(is_array($insert_record))
{
$values =
$this->bocommon->collect_locationdata($values,$insert_record);
Modified: trunk/property/setup/setup.inc.php
===================================================================
--- trunk/property/setup/setup.inc.php 2013-09-18 10:43:56 UTC (rev 11300)
+++ trunk/property/setup/setup.inc.php 2013-09-18 11:45:08 UTC (rev 11301)
@@ -12,7 +12,7 @@
*/
$setup_info['property']['name'] = 'property';
- $setup_info['property']['version'] = '0.9.17.670';
+ $setup_info['property']['version'] = '0.9.17.671';
$setup_info['property']['app_order'] = 8;
$setup_info['property']['enable'] = 1;
$setup_info['property']['app_group'] = 'office';
Modified: trunk/property/setup/tables_update.inc.php
===================================================================
--- trunk/property/setup/tables_update.inc.php 2013-09-18 10:43:56 UTC (rev
11300)
+++ trunk/property/setup/tables_update.inc.php 2013-09-18 11:45:08 UTC (rev
11301)
@@ -7627,3 +7627,36 @@
}
}
+ /**
+ * Update property version from 0.9.17.670 to 0.9.17.671
+ * Convert p_num values to integer
+ */
+ $test[] = '0.9.17.670';
+ function property_upgrade0_9_17_670()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+ $GLOBALS['phpgw_setup']->oProc->query("DELETE FROM fm_cache");
+
+ $tables = $GLOBALS['phpgw_setup']->oProc->m_odb->table_names();
+
+ foreach ($tables as $table)
+ {
+ if(preg_match('/^fm_/', $table))
+ {
+ $metadata =
$GLOBALS['phpgw_setup']->oProc->m_odb->metadata($table);
+
+ if(isset($metadata['p_num']))
+ {
+ $sql = "UPDATE {$table} SET p_num =
p_num::integer WHERE p_num IS NOT NULL";
+
$GLOBALS['phpgw_setup']->oProc->query($sql);
+ }
+ }
+ }
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['property']['currentver'] =
'0.9.17.671';
+ return $GLOBALS['setup_info']['property']['currentver'];
+ }
+ }
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11301] property: convert p_num to integer,
Sigurd Nes <=