phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] property/inc class.solocation.inc.php, 1.12 class.sot


From: sigurdne
Subject: [Phpgroupware-cvs] property/inc class.solocation.inc.php, 1.12 class.sotenant_claim.inc.php, 1.7 class.soadmin_location.inc.php, 1.13 class.uiadmin_location.inc.php, 1.9 class.boadmin_location.inc.php, 1.6 class.bolocation.inc.php, 1.7 class.uilocation.inc.php, 1.11
Date: Wed, 18 May 2005 18:05:00 +0200

Update of property/inc

Modified Files:
     Branch: MAIN
            class.solocation.inc.php lines: +161 -4
            class.sotenant_claim.inc.php lines: +3 -2
            class.soadmin_location.inc.php lines: +77 -37
            class.uiadmin_location.inc.php lines: +2 -2
            class.boadmin_location.inc.php lines: +3 -3
            class.bolocation.inc.php lines: +49 -2
            class.uilocation.inc.php lines: +115 -2

Log Message:
History for locations

====================================================
Index: property/inc/class.solocation.inc.php
diff -u property/inc/class.solocation.inc.php:1.11 
property/inc/class.solocation.inc.php:1.12
--- property/inc/class.solocation.inc.php:1.11  Thu May 12 21:26:28 2005
+++ property/inc/class.solocation.inc.php       Wed May 18 16:05:55 2005
@@ -562,7 +562,6 @@
                                                        
$location_list[$j][$cols_return[$i]]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($value));
                                                }
                                                endif;
-
                                        }
                                        unset($value);
                                }
@@ -913,13 +912,34 @@
                                }
                        }

+                       $value_set['entry_date'] = time();
+
                        $value_set      = 
$this->bocommon->validate_db_update($value_set);

-                       $sql    = "UPDATE fm_location$type_id SET $value_set 
WHERE location_code='" . $location['location_code'] . "'";
+                       $sql = "SELECT * from fm_location$type_id where 
location_code ='" . $location['location_code'] . "'";
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->next_record();
+
+                       $metadata = $this->db->metadata('fm_location'.$type_id);
+
+                       for ($i=0; $i<count($metadata); $i++)
+                       {
+                               $cols[] = $metadata[$i]['name'];
+                               $vals[] = $this->db->f($metadata[$i]['name']);
+                       }
+
+                       $cols[] = 'exp_date';
+                       $vals[] = date($this->bocommon->datetimeformat,time());
+
+                       $cols   =implode(",", $cols);
+                       $vals   ="'" . implode("','", $vals) . "'";

+                       $sql = "INSERT INTO fm_location" . $type_id ."_history 
($cols) VALUES ($vals)";
                        $this->db->query($sql,__LINE__,__FILE__);

-//echo $sql;
+                       $sql = "UPDATE fm_location$type_id SET $value_set WHERE 
location_code='" . $location['location_code'] . "'";
+
+                       $this->db->query($sql,__LINE__,__FILE__);

                        $receipt['message'][] = array('msg'=>lang('Location %1 
has been edited',$location['location_code']));
                        return $receipt;
@@ -1088,5 +1108,142 @@
                        return $summary;
                }

+               function check_history($location_code='')
+               {
+                       $location_array = split('-',$location_code);
+                       $type_id= count($location_array);
+
+                       if (!$type_id)
+                       {
+                               return false;
+                       }
+
+                       $table = 'fm_location' . $type_id . '_history';
+
+                       $sql = "SELECT count(*) FROM $table WHERE 
location_code='$location_code'";
+
+                       $this->db->query($sql,__LINE__,__FILE__);
+
+                       $this->db->next_record();
+
+                       if($this->db->f('0')>0)
+                       {
+                               return True;
+                       }
+                       else
+                       {
+                               return;
+                       }
+               }
+
+               function get_history($location_code='')
+               {
+                       $this->uicols = array();
+                       $location_array = split('-',$location_code);
+                       $type_id= count($location_array);
+
+                       if (!$type_id)
+                       {
+                               return;
+                       }
+
+                       $table = 'fm_location' . $type_id . '_history';
+
+                       $table_category = 'fm_location' . $type_id . 
'_category';
+
+                       $sql = "SELECT column_name,datatype,input_text,id as 
attrib_id FROM fm_location_attrib WHERE type_id = $type_id";
+
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       while ($this->db->next_record())
+                       {
+                               $attrib[] = array(
+                                       'column_name' => 
$this->db->f('column_name'),
+                                       'input_text' => 
$this->db->f('input_text'),
+                                       'datatype' => $this->db->f('datatype'),
+                                       'attrib_id' => $this->db->f('attrib_id')
+                               );
+
+                               $this->uicols['input_type'][] = 'text';
+                               $this->uicols['name'][] = 
$this->db->f('column_name');
+                               $this->uicols['descr'][] = 
$this->db->f('input_text');
+                       }
+
+                       $this->uicols['input_type'][] = 'text';
+                       $this->uicols['name'][] = 'exp_date';
+                       $this->uicols['descr'][] = lang('exp date');
+
+
+                       $attrib[] = array(
+                               'column_name' => 'exp_date',
+                               'input_text' => 'exp date',
+                               'datatype' => 'D'
+                       );
+
+                       $sql = "SELECT $table.*, $table_category.descr as 
category FROM $table $this->join $table_category on $table.category 
=$table_category.id WHERE location_code='$location_code' ORDER BY exp_date 
DESC";
+                       $this->db->query($sql,__LINE__,__FILE__);
+
+                       $j=0;
+                       while ($this->db->next_record())
+                       {
+                               for ($i=0; $i<count($attrib); $i++)
+                               {
+                                       
$location[$j][$attrib[$i]['column_name']]=$this->db->f($attrib[$i]['column_name']);
+
+                                       $value = 
$this->db->f($attrib[$i]['column_name']);
+                                       if(($attrib[$i]['datatype']=='R' || 
$attrib[$i]['datatype']=='LB') && $value):
+                                       {
+                                               $sql="SELECT value FROM 
fm_location_choice where type_id=$type_id AND attrib_id=" 
.$attrib[$i]['attrib_id']. "  AND id=" . $value;
+                                               $this->db2->query($sql);
+                                               $this->db2->next_record();
+                                               
$location[$j][$attrib[$i]['column_name']] = $this->db2->f('value');
+                                       }
+                                       elseif($attrib[$i]['datatype']=='AB' && 
$value):
+                                       {
+                                               $contact_data   = 
$contacts->read_single_entry($value,array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
+                                               
$location[$j][$attrib[$i]['column_name']]       = $contact_data[0]['n_family'] 
. ', ' . $contact_data[0]['n_given'];
+                                       }
+                                       
elseif($attrib[$i]['datatype']=='VENDOR' && $value):
+                                       {
+                                               $sql="SELECT org_name FROM 
fm_vendor where id=$value";
+                                               $this->db2->query($sql);
+                                               $this->db2->next_record();
+                                               
$location[$j][$attrib[$i]['column_name']] = $this->db2->f('org_name');
+                                       }
+                                       elseif($attrib[$i]['datatype']=='CH' && 
$value):
+                                       {
+                                               $ch= unserialize($value);
+                                               if (isset($ch) AND 
is_array($ch))
+                                               {
+                                                       for 
($k=0;$k<count($ch);$k++)
+                                                       {
+                                                               $sql="SELECT 
value FROM fm_location_choice where type_id=$type_id AND attrib_id=" 
.$attrib[$i]['attrib_id']. "  AND id=" . $ch[$k];
+                                                               
$this->db2->query($sql);
+                                                               while 
($this->db2->next_record())
+                                                               {
+                                                                       
$ch_value[]=$this->db2->f('value');
+                                                               }
+                                                       }
+                                                       
$location[$j][$attrib[$i]['column_name']] = @implode(",", $ch_value);
+                                                       unset($ch_value);
+                                               }
+                                       }
+                                       elseif($attrib[$i]['datatype']=='D' && 
$value):
+                                       {
+                                               
$location[$j][$attrib[$i]['column_name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($value));
+                                       }
+                                       
elseif($attrib[$i]['column_name']=='entry_date' && $value):
+                                       {
+                                               
$location[$j][$attrib[$i]['column_name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],$value);
+                                       }
+                                       endif;
+
+                                       unset($value);
+
+                               }
+                               $j++;
+                       }
+
+                       return $location;
+               }
        }
 ?>

====================================================
Index: property/inc/class.sotenant_claim.inc.php
diff -u property/inc/class.sotenant_claim.inc.php:1.6 
property/inc/class.sotenant_claim.inc.php:1.7
--- property/inc/class.sotenant_claim.inc.php:1.6       Thu May 12 21:26:28 2005
+++ property/inc/class.sotenant_claim.inc.php   Wed May 18 16:05:55 2005
@@ -202,10 +202,10 @@

                function add($claim)
                {
-//_debug_array($claim);
                        $this->db->transaction_begin();

                        $claim['name'] = 
$this->db->db_addslashes($claim['name']);
+                       $claim['amount'] =  
str_replace(",",".",$claim['amount']);

                        $values_insert= array(
                                $claim['project_id'],
@@ -252,6 +252,7 @@
                        $this->db->transaction_begin();

                        $claim['name'] = 
$this->db->db_addslashes($claim['name']);
+                       $claim['amount'] =  
str_replace(",",".",$claim['amount']);

                        $value_set=array(
                                'amount'                        => 
$claim['amount'],

====================================================
Index: property/inc/class.soadmin_location.inc.php
diff -u property/inc/class.soadmin_location.inc.php:1.12 
property/inc/class.soadmin_location.inc.php:1.13
--- property/inc/class.soadmin_location.inc.php:1.12    Thu May 12 21:26:28 2005
+++ property/inc/class.soadmin_location.inc.php Wed May 18 16:05:55 2005
@@ -203,36 +203,70 @@
                        $default_attrib['type'][]='V';
                        $default_attrib['precision'][] =4*$standard['id'];
                        $default_attrib['nullable'][] ='False';
+                       $default_attrib['input_text'][] ='dummy';
+                       $default_attrib['statustext'][] ='dummy';
+                       $default_attrib['attrib_sort'][] ='NULL';
+                       $default_attrib['custom'][] ='NULL';

                        $default_attrib['id'][]= 2;
                        $default_attrib['column_name'][]= 'loc' . 
$standard['id'] . '_name';
                        $default_attrib['type'][]='V';
                        $default_attrib['precision'][] =50;
                        $default_attrib['nullable'][] ='True';
+                       $default_attrib['input_text'][] ='dummy';
+                       $default_attrib['statustext'][] ='dummy';
+                       $default_attrib['attrib_sort'][] ='NULL';
+                       $default_attrib['custom'][] ='NULL';

                        $default_attrib['id'][]= 3;
                        $default_attrib['column_name'][]= 'entry_date';
                        $default_attrib['type'][]='I';
                        $default_attrib['precision'][] =4;
                        $default_attrib['nullable'][] ='True';
+                       $default_attrib['input_text'][] ='dummy';
+                       $default_attrib['statustext'][] ='dummy';
+                       $default_attrib['attrib_sort'][] ='NULL';
+                       $default_attrib['custom'][] ='NULL';

                        $default_attrib['id'][]= 4;
                        $default_attrib['column_name'][]= 'category';
                        $default_attrib['type'][]='I';
                        $default_attrib['precision'][] =4;
                        $default_attrib['nullable'][] ='False';
+                       $default_attrib['input_text'][] ='dummy';
+                       $default_attrib['statustext'][] ='dummy';
+                       $default_attrib['attrib_sort'][] ='NULL';
+                       $default_attrib['custom'][] ='NULL';

                        $default_attrib['id'][]= 5;
                        $default_attrib['column_name'][]= 'user_id';
                        $default_attrib['type'][]='I';
                        $default_attrib['precision'][] =4;
                        $default_attrib['nullable'][] ='False';
+                       $default_attrib['input_text'][] ='dummy';
+                       $default_attrib['statustext'][] ='dummy';
+                       $default_attrib['attrib_sort'][] ='NULL';
+                       $default_attrib['custom'][] ='NULL';

                        $default_attrib['id'][]= 6;
+                       $default_attrib['column_name'][]= 'status';
+                       $default_attrib['type'][]='LB';
+                       $default_attrib['precision'][] = False;
+                       $default_attrib['nullable'][] ='True';
+                       $default_attrib['input_text'][] ='Status';
+                       $default_attrib['statustext'][] ='Status';
+                       $default_attrib['attrib_sort'][] =1;
+                       $default_attrib['custom'][] =1;
+
+                       $default_attrib['id'][]= 7;
                        $default_attrib['column_name'][]= 'remark';
                        $default_attrib['type'][]='T';
                        $default_attrib['precision'][] = False;
                        $default_attrib['nullable'][] ='False';
+                       $default_attrib['input_text'][] ='Remark';
+                       $default_attrib['statustext'][] ='Remark';
+                       $default_attrib['attrib_sort'][] =2;
+                       $default_attrib['custom'][] =1;

                        $fd=array();
                        $fd['location_code'] = array('type' => 'varchar', 
'precision' => 25, 'nullable' => False);
@@ -242,11 +276,15 @@
                                $fd['loc' . $i] = array('type' => 'varchar', 
'precision' => 4, 'nullable' => False);
                                $pk[$i-1]= 'loc' . $i;

-                               $default_attrib['id'][]= $i+6;
+                               $default_attrib['id'][]= $i+7;
                                $default_attrib['column_name'][]= 'loc' . $i;
                                $default_attrib['type'][]='V';
                                $default_attrib['precision'][] =4;
                                $default_attrib['nullable'][] ='False';
+                               $default_attrib['input_text'][] ='dummy';
+                               $default_attrib['statustext'][] ='dummy';
+                               $default_attrib['attrib_sort'][] ='NULL';
+                               $default_attrib['custom'][] ='NULL';
                        }

                        $fk_table='fm_location'. ($standard['id']-1);
@@ -271,9 +309,14 @@
                        $ix = array('location_code');
                        $uc = array();

-//                     
$add_columns_in_tables=array('fm_project','fm_tts_tickets','fm_request','fm_document','fm_investment');
+                       $fd_history = $fd;
+                       $fd_history['exp_date'] = array('type' => 
'timestamp','nullable' => True,'default' => 'current_timestamp');
+//                     $fd_history['change_type'] = array('type' => 
'int','precision' => '4','nullable' => True);

-                       if($this->oProc->CreateTable('fm_location'. 
$standard['id'],array('fd' => $fd,'pk' => $pk,'fk' => $fk,'ix' => $ix,'uc' => 
$uc)))
+                       
$add_columns_in_tables=array('fm_project','fm_tts_tickets','fm_request','fm_document','fm_investment');
+
+                       if($this->oProc->CreateTable('fm_location'. 
$standard['id'],array('fd' => $fd,'pk' => $pk,'fk' => $fk,'ix' => $ix,'uc' => 
$uc))
+                               && $this->oProc->CreateTable('fm_location'. 
$standard['id'] . '_history',array('fd' => $fd_history)))
                        {

                                $this->oProc->CreateTable('fm_location'. 
$standard['id'] . '_category', array(
@@ -313,34 +356,20 @@
                                                
$default_attrib['column_name'][$i],
                                                $default_attrib['type'][$i],
                                                
$default_attrib['precision'][$i],
-                                               'dummy',
-                                               'dummy',
-                                               'False'
+                                               
$default_attrib['input_text'][$i],
+                                               
$default_attrib['statustext'][$i],
+                                               
$default_attrib['attrib_sort'][$i],
+                                               $default_attrib['custom'][$i],
+                                               $default_attrib['nullable'][$i]
                                                );

+
                                        $values_insert  = 
$this->bocommon->validate_db_insert($values_insert);

-                                       $this->db->query("INSERT INTO 
fm_location_attrib 
(type_id,id,column_name,datatype,precision_,input_text,statustext,nullable) "
+                                       $this->db->query("INSERT INTO 
fm_location_attrib 
(type_id,id,column_name,datatype,precision_,input_text,statustext,attrib_sort,custom,nullable)
 "
                                                . "VALUES 
($values_insert)",__LINE__,__FILE__);
                                }

-                               $values_insert= array(
-                                       $standard['id'],
-                                       count($default_attrib['id'])+1,
-                                       1,
-                                       'status',
-                                       'Status',
-                                       'Status',
-                                       'LB',
-                                       1,
-                                       'True'
-                                       );
-
-                               $values_insert  = 
$this->bocommon->validate_db_insert($values_insert);
-
-                               $this->db->query("INSERT INTO 
fm_location_attrib 
(type_id,id,custom,column_name,input_text,statustext,datatype,attrib_sort,nullable)
 "
-                                       . "VALUES 
($values_insert)",__LINE__,__FILE__);
-
                                $type_id=$standard['id'];

                                $this->db->query("INSERT INTO 
fm_location_choice (type_id,attrib_id,id,value) "
@@ -399,7 +428,7 @@
                        return $receipt;
                }

-               function delete($id,$attrib)
+               function delete($type_id,$id,$attrib)
                {
                        $this->init_process();

@@ -410,15 +439,15 @@
                                $this->db->query("SELECT column_name,type_id 
FROM fm_location_attrib WHERE id='" . $id . "'",__LINE__,__FILE__);
                                $this->db->next_record();
                                $ColumnName             = 
$this->db->f('column_name');
-                               $type_id                = 
$this->db->f('type_id');

                                $this->oProc->DropColumn('fm_location' 
.$type_id ,'', $ColumnName);
-
+                               $this->oProc->DropColumn('fm_location' 
.$type_id . '_history','', $ColumnName);
                        }
                        else
                        {
                                $this->oProc->DropTable('fm_location' . $id);
                                $this->oProc->DropTable('fm_location' . $id . 
'_category');
+                               $this->oProc->DropTable('fm_location' . $id . 
'_history');

                                $table                  = 'fm_location_type';
                                $attrib_table   = 'fm_location_attrib';
@@ -595,14 +624,15 @@
                                $attrib['column_info']['precision'],
                                $attrib['column_info']['scale'],
                                $attrib['column_info']['default'],
-                               $attrib['column_info']['nullable']
+                               $attrib['column_info']['nullable'],
+                               1
                                );

                        $values = $this->bocommon->validate_db_insert($values);

                        $this->db->transaction_begin();

-                       $this->db->query("INSERT INTO fm_location_attrib 
(id,column_name, input_text, statustext, 
type_id,lookup_form,list,attrib_sort,datatype,precision_,scale,default_value,nullable)
 "
+                       $this->db->query("INSERT INTO fm_location_attrib 
(id,column_name, input_text, statustext, 
type_id,lookup_form,list,attrib_sort,datatype,precision_,scale,default_value,nullable,custom)
 "
                                . "VALUES ($values)",__LINE__,__FILE__);

                        $receipt['id']= $attrib['id'];
@@ -616,7 +646,8 @@

                        $this->init_process();

-                       
if($this->oProc->AddColumn('fm_location'.$attrib['type_id'],$attrib['column_name'],
 $attrib['column_info']))
+                       
if($this->oProc->AddColumn('fm_location'.$attrib['type_id'],$attrib['column_name'],
 $attrib['column_info'])
+                               && 
$this->oProc->AddColumn('fm_location'.$attrib['type_id'] 
.'_history',$attrib['column_name'], $attrib['column_info']))
                        {
                                $receipt['message'][] = array('msg'     => 
lang('Attribute has been saved')     );
                                $this->db->transaction_commit();
@@ -674,6 +705,7 @@
                                        }

                                        $this->oProc->DropColumn('fm_location' 
.$location_type ,'', $column_name);
+                                       $this->oProc->DropColumn('fm_location' 
.$location_type . ' _history','', $column_name);


                                        $this->db->query("UPDATE 
fm_location_config set
@@ -689,7 +721,6 @@
                        }

                        return $receipt;
-
                }


@@ -707,7 +738,14 @@
                        $OldColumnPrecision     = $this->db->f('precision_');

                        $table_def = $this->get_table_def($attrib['type_id']);
-//_debug_array($table_def);
+                       $history_table_def['fm_location'.$attrib['type_id'] . 
'_history'] = $table_def['fm_location'.$attrib['type_id']];
+                       
$history_table_def['fm_location'.$attrib['type_id']]['fd']['exp_date']=array('type'
 => 'timestamp','nullable' => False,'default' => 'current_timestamp');
+//                     
$history_table_def['fm_location'.$attrib['type_id']]['fd']['change_type'] = 
array('type' => 'int','precision' => '4','nullable' => True);
+
+                       
unset($history_table_def['fm_location'.$attrib['type_id']]['pk']);
+                       
unset($history_table_def['fm_location'.$attrib['type_id']]['fk']);
+                       
unset($history_table_def['fm_location'.$attrib['type_id']]['ix']);
+                       
unset($history_table_def['fm_location'.$attrib['type_id']]['uc']);

                        if($this->receipt['error'])
                        {
@@ -729,12 +767,8 @@

                        $this->init_process();

-
-                       $this->oProc->m_aTables = $table_def;
-
                        if($OldColumnName !=$attrib['column_name'])
                        {
-
                                $value_set=array(
                                        'column_name'           => 
$attrib['column_name']
                                        );
@@ -743,7 +777,10 @@

                                $this->db->query("UPDATE fm_location_attrib set 
$value_set WHERE type_id = " . $attrib['type_id'] ." AND id=" . 
$attrib['id'],__LINE__,__FILE__);

+                               $this->oProc->m_aTables = $table_def;
                                
$this->oProc->RenameColumn('fm_location'.$attrib['type_id'], $OldColumnName, 
$attrib['column_name']);
+                               $this->oProc->m_aTables = $history_table_def;
+                               
$this->oProc->RenameColumn('fm_location'.$attrib['type_id'] . '_history', 
$OldColumnName, $attrib['column_name']);
                        }

                        if($OldColumnType !=$attrib['column_info']['type'])
@@ -774,7 +811,10 @@

                                $attrib['column_info']['type']  = 
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);

+                               $this->oProc->m_aTables = $table_def;
                                
$this->oProc->AlterColumn('fm_location'.$attrib['type_id'],$attrib['column_name'],$attrib['column_info']);
+                               $this->oProc->m_aTables = $history_table_def;
+                               
$this->oProc->AlterColumn('fm_location'.$attrib['type_id'] . 
'_history',$attrib['column_name'],$attrib['column_info']);
                        }

                        $choice_table ='fm_location_choice';

====================================================
Index: property/inc/class.uiadmin_location.inc.php
diff -u property/inc/class.uiadmin_location.inc.php:1.8 
property/inc/class.uiadmin_location.inc.php:1.9
--- property/inc/class.uiadmin_location.inc.php:1.8     Thu May 12 21:26:28 2005
+++ property/inc/class.uiadmin_location.inc.php Wed May 18 16:05:55 2005
@@ -290,7 +290,7 @@

                        if (get_var('confirm',array('POST')))
                        {
-                               $this->bo->delete($id,$attrib);
+                               $this->bo->delete($type_id,$id,$attrib);
                                Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php',$link_data));
                        }


====================================================
Index: property/inc/class.boadmin_location.inc.php
diff -u property/inc/class.boadmin_location.inc.php:1.5 
property/inc/class.boadmin_location.inc.php:1.6
--- property/inc/class.boadmin_location.inc.php:1.5     Thu May 12 21:26:28 2005
+++ property/inc/class.boadmin_location.inc.php Wed May 18 16:05:55 2005
@@ -184,9 +184,9 @@

                }

-               function delete($id,$attrib)
+               function delete($type_id,$id,$attrib)
                {
-                       $this->so->delete($id,$attrib);
+                       $this->so->delete($type_id,$id,$attrib);
                }

                function read_attrib($type_id='')

====================================================
Index: property/inc/class.bolocation.inc.php
diff -u property/inc/class.bolocation.inc.php:1.6 
property/inc/class.bolocation.inc.php:1.7
--- property/inc/class.bolocation.inc.php:1.6   Thu May 12 21:26:28 2005
+++ property/inc/class.bolocation.inc.php       Wed May 18 16:05:55 2005
@@ -758,11 +758,58 @@

                        $summary = $this->so->read_summary(array('filter' => 
$this->filter,'type_id' => $data['type_id'],
                                                                                
        
'district_id'=>$this->district_id,'part_of_town_id'=>$this->part_of_town_id));
+                       $this->uicols = $this->so->uicols;
+                       return $summary;
+
+               }

+               function select_change_type($selected='')
+               {
+                       $nullable[0]['id']= 1;
+                       $nullable[0]['name']= lang('Correct error');
+                       $nullable[1]['id']= 2;
+                       $nullable[1]['name']= lang('New values');

+                       while (is_array($nullable) && list(,$type) = 
each($nullable))
+                       {
+                               $sel_type = '';
+                               if ($type['id']==$selected)
+                               {
+                                       $sel_type = 'selected';
+                               }
+
+                               $change_type_list[] = array
+                               (
+                                       'id'    => $type['id'],
+                                       'name'          => $type['name'],
+                                       'selected'      => $sel_type
+                               );
+                       }
+
+                       for ($i=0;$i<count($change_type_list);$i++)
+                       {
+                               if ($change_type_list[$i]['selected'] != 
'selected')
+                               {
+                                       
unset($change_type_list[$i]['selected']);
+                               }
+                       }
+                       return $change_type_list;
+               }
+
+               function check_history($location_code)
+               {
+                       return $this->so->check_history($location_code);
+               }
+
+               function get_history($location_code)
+               {
+                       $history = $this->so->get_history($location_code);
+                       $this->total_records = $this->so->total_records;
                        $this->uicols = $this->so->uicols;
-                       return $summary;
+
+                       return $history;

                }
+
        }
 ?>

====================================================
Index: property/inc/class.uilocation.inc.php
diff -u property/inc/class.uilocation.inc.php:1.10 
property/inc/class.uilocation.inc.php:1.11
--- property/inc/class.uilocation.inc.php:1.10  Thu May 12 21:26:28 2005
+++ property/inc/class.uilocation.inc.php       Wed May 18 16:05:55 2005
@@ -479,6 +479,8 @@
                                
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
 . $this->acl2_location);
                        }

+                       $get_history            = 
get_var('get_history',array('POST'));
+                       $change_type            = 
get_var('change_type',array('POST'));
                        $lookup_tenant          = 
get_var('lookup_tenant',array('POST','GET'));
                        $location_code          = 
get_var('location_code',array('POST','GET'));
                        $values_attribute       = 
get_var('values_attribute',array('POST','GET'));
@@ -511,7 +513,6 @@

                        if (is_array($values) )
                        {
-
                                for ($i=1; $i<($type_id+1); $i++)
                                {
                                        if((!$values['loc' . $i]  && 
!$location[($i-1)]) || !$values['loc' . $i])
@@ -544,6 +545,13 @@
                                if($location_code)
                                {
                                        $action='edit';
+                                       $values['change_type'] = $change_type;
+
+
+                                       if(!$values['change_type'])
+                                       {
+                                               
$receipt['error'][]=array('msg'=>lang('Please select change type'));
+                                       }
                                }
                                elseif(!$location_code && !$error_id )
                                {
@@ -567,6 +575,46 @@
                        if(!$error_id && $location_code)
                        {
                                $values = 
$this->bo->read_single($location_code,array('tenant_id'=>'lookup'));
+                               $check_history = 
$this->bo->check_history($location_code);
+                               if($get_history)
+                               {
+                                       $history = 
$this->bo->get_history($location_code);
+                                       $uicols = $this->bo->uicols;
+
+                                       $j=0;
+                                       if (isSet($history) AND 
is_array($history))
+                                       {
+                                               foreach($history as $entry)
+                                               {
+                                                       $k=0;
+                                                       for 
($i=0;$i<count($uicols['name']);$i++)
+                                                       {
+                                                               
if($uicols['input_type'][$i]!='hidden')
+                                                               {
+                                                                       
$content[$j]['row'][$k]['value']                        = 
$entry[$uicols['name'][$i]];
+                                                                       
$content[$j]['row'][$k]['name']                         = $uicols['name'][$i];
+                                                                       
$content[$j]['row'][$k]['lookup']                       = $lookup;
+                                                               }
+
+                                                               
$content[$j]['hidden'][$k]['value']                     = 
$entry[$uicols['name'][$i]];
+                                                               
$content[$j]['hidden'][$k]['name']                              = 
$uicols['name'][$i];
+                                                               $k++;
+                                                       }
+                                                       $j++;
+                                               }
+                                       }
+
+                                       $uicols_count   = 
count($uicols['descr']);
+                                       for ($i=0;$i<$uicols_count;$i++)
+                                       {
+                                               
if($uicols['input_type'][$i]!='hidden')
+                                               {
+                                                       
$table_header[$i]['header']     = $uicols['descr'][$i];
+                                                       
$table_header[$i]['width']              = '5%';
+                                                       
$table_header[$i]['align']              = 'center';
+                                               }
+                                       }
+                               }
                        }
                        else
                        {
@@ -854,8 +902,24 @@
                                }
                        }

+
+                       if($location_code)
+                       {
+                               $change_type_list = 
$this->bo->select_change_type($change_type);
+                       }
+
                        $data = array
                        (
+                               'lang_change_type'                              
=> lang('Change type'),
+                               'lang_no_change_type'                   => 
lang('No Change type'),
+                               'lang_change_type_statustext'   => lang('Type 
of changes'),
+                               'change_type_list'                              
=> $change_type_list,
+                               'check_history'                                 
=> $check_history,
+                               'lang_history'                                  
=> lang('History'),
+                               'lang_history_statustext'               => 
lang('Fetch the history for this item'),
+                               'table_header'                                  
=> $table_header,
+                               'values'                                        
        => $content,
+
                                'lang_related_info'                             
=> lang('related info'),
                                'entities_link'                                 
=> $entities_link,
                                'edit_street'                                   
=> $edit_street,
@@ -920,6 +984,7 @@
                //      $GLOBALS['phpgw']->xslttpl->pp();
                }

+
                function delete()
                {
                        if(!$this->acl_delete)
@@ -974,6 +1039,7 @@
                                
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
 . $this->acl2_location);
                        }

+                       $get_history            = 
get_var('get_history',array('POST'));
                        $lookup_tenant  = 
get_var('lookup_tenant',array('POST','GET'));
                        $location_code                  = 
get_var('location_code',array('POST','GET'));
                        $location = split('-',$location_code);
@@ -989,6 +1055,47 @@

                        $values = 
$this->bo->read_single($location_code,array('tenant_id'=>'lookup'));

+                       $check_history = 
$this->bo->check_history($location_code);
+                       if($get_history)
+                       {
+                               $history = 
$this->bo->get_history($location_code);
+                               $uicols = $this->bo->uicols;
+
+                               $j=0;
+                               if (isSet($history) AND is_array($history))
+                               {
+                                       foreach($history as $entry)
+                                       {
+                                               $k=0;
+                                               for 
($i=0;$i<count($uicols['name']);$i++)
+                                               {
+                                                       
if($uicols['input_type'][$i]!='hidden')
+                                                       {
+                                                               
$content[$j]['row'][$k]['value']                        = 
$entry[$uicols['name'][$i]];
+                                                               
$content[$j]['row'][$k]['name']                         = $uicols['name'][$i];
+                                                               
$content[$j]['row'][$k]['lookup']                       = $lookup;
+                                                       }
+
+                                                       
$content[$j]['hidden'][$k]['value']                     = 
$entry[$uicols['name'][$i]];
+                                                       
$content[$j]['hidden'][$k]['name']                              = 
$uicols['name'][$i];
+                                                       $k++;
+                                               }
+                                               $j++;
+                                       }
+                               }
+
+                               $uicols_count   = count($uicols['descr']);
+                               for ($i=0;$i<$uicols_count;$i++)
+                               {
+                                       if($uicols['input_type'][$i]!='hidden')
+                                       {
+                                               $table_header[$i]['header']     
= $uicols['descr'][$i];
+                                               $table_header[$i]['width']      
        = '5%';
+                                               $table_header[$i]['align']      
        = 'center';
+                                       }
+                               }
+                       }
+
                        $lookup_type='view';

                        $location_data=$this->bo->initiate_ui_location(array(
@@ -1196,6 +1303,12 @@

                        $data = array
                        (
+                               'check_history'                                 
=> $check_history,
+                               'lang_history'                                  
=> lang('History'),
+                               'lang_history_statustext'               => 
lang('Fetch the history for this item'),
+                               'table_header'                                  
=> $table_header,
+                               'values'                                        
        => $content,
+
                                'lang_related_info'                             
=> lang('related info'),
                                'entities_link'                                 
=> $entities_link,
                                'edit_street'                                   
=> $edit_street,






reply via email to

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