phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: property/inc class.bolocation.inc.php,1.6,1.7 cl


From: Sigurd Nes <address@hidden>
Subject: [Phpgroupware-cvs] CVS: property/inc class.bolocation.inc.php,1.6,1.7 class.solocation.inc.php,1.4,1.5 class.uilocation.inc.php,1.8,1.9
Date: Sat, 14 Jun 2003 17:41:32 -0400

Update of /cvsroot/phpgroupware/property/inc
In directory subversions:/tmp/cvs-serv11511/inc

Modified Files:
        class.bolocation.inc.php class.solocation.inc.php 
        class.uilocation.inc.php 
Log Message:
no message

Index: class.bolocation.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.bolocation.inc.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** class.bolocation.inc.php    13 Jun 2003 11:05:29 -0000      1.6
--- class.bolocation.inc.php    14 Jun 2003 21:41:30 -0000      1.7
***************
*** 48,53 ****
                        $this->currentapp                       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->so                                       = 
CreateObject($this->currentapp.'.solocation');
!                       $this->socommon                         = 
CreateObject($this->currentapp.'.socommon');
!                       $this->bocommon                         = 
CreateObject($this->currentapp.'.bocommon');
                        $this->soadmin_location         = 
CreateObject($this->currentapp.'.soadmin_location');
  
--- 48,52 ----
                        $this->currentapp                       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->so                                       = 
CreateObject($this->currentapp.'.solocation');
! //                    $this->bocommon                         = 
CreateObject($this->currentapp.'.bocommon');
                        $this->soadmin_location         = 
CreateObject($this->currentapp.'.soadmin_location');
  
***************
*** 178,183 ****
                        $this->location_types   = $location_types;
  //_debug_array($location_types);
!                       $fm_location_colst = 
$this->soadmin_location->read_attrib(array('type_id'=>$data['type_id']));
! //_debug_array($fm_location_colst);
  
                        for ($i=0;$i<$data['type_id'];$i++)
--- 177,182 ----
                        $this->location_types   = $location_types;
  //_debug_array($location_types);
!                       $fm_location_cols = 
$this->soadmin_location->read_attrib(array('type_id'=>$data['type_id']));
! //_debug_array($fm_location_cols);
  
                        for ($i=0;$i<$data['type_id'];$i++)
***************
*** 186,189 ****
--- 185,189 ----
                                $location['location'][$i]['input_name']         
                = 'loc' . ($i+1);
                                $input_name[]                                   
                                        = 
$location['location'][$i]['input_name'];
+                               $insert_record[]                                
                                        = 
$location['location'][$i]['input_name'];
                                $location['location'][$i]['size']               
                        = 5;
                                $location['location'][$i]['name']               
                        = $location_types[($i)]['name'];
***************
*** 219,235 ****
  
  
!                       for ($j=0;$j<count($fm_location_colst);$j++)
                        {
!                               if($fm_location_colst[$j]['location_type'] <= 
$data['type_id'] && $fm_location_colst[$j]['lookup_form'])
                                {
                                        $location['location'][$i]['input_type'] 
                        = 'text';
!                                       $location['location'][$i]['input_name'] 
                        = $fm_location_colst[$j]['column_name'];
                                        $input_name[]                           
                                                = 
$location['location'][$i]['input_name'];
                                        $location['location'][$i]['size']       
                                = 5;
!                                       
$location['location'][$i]['lookup_function_call']       = 'lookup_loc' . 
$fm_location_colst[$j]['location_type'] . '()';
                                        
$location['location'][$i]['lookup_link']                        = True;
!                                       $location['location'][$i]['name']       
                                = $fm_location_colst[$j]['input_text'];
!                                       $location['location'][$i]['value']      
                                = 
$data['values'][$fm_location_colst[$j]['column_name']];
!                                       $location['location'][$i]['statustext'] 
                        = lang('Klick this link to select') . ' ' . 
$location_types[($fm_location_colst[$j]['location_type']-1)]['name'];
                                        $i++;
  //echo 'i :' . $i . '<br>';
--- 219,235 ----
  
  
!                       for ($j=0;$j<count($fm_location_cols);$j++)
                        {
!                               if($fm_location_cols[$j]['location_type'] <= 
$data['type_id'] && $fm_location_cols[$j]['lookup_form'])
                                {
                                        $location['location'][$i]['input_type'] 
                        = 'text';
!                                       $location['location'][$i]['input_name'] 
                        = $fm_location_cols[$j]['column_name'];
                                        $input_name[]                           
                                                = 
$location['location'][$i]['input_name'];
                                        $location['location'][$i]['size']       
                                = 5;
!                                       
$location['location'][$i]['lookup_function_call']       = 'lookup_loc' . 
$fm_location_cols[$j]['location_type'] . '()';
                                        
$location['location'][$i]['lookup_link']                        = True;
!                                       $location['location'][$i]['name']       
                                = $fm_location_cols[$j]['input_text'];
!                                       $location['location'][$i]['value']      
                                = 
$data['values'][$fm_location_cols[$j]['column_name']];
!                                       $location['location'][$i]['statustext'] 
                        = lang('Klick this link to select') . ' ' . 
$location_types[($fm_location_cols[$j]['location_type']-1)]['name'];
                                        $i++;
  //echo 'i :' . $i . '<br>';
***************
*** 244,254 ****
                                        $location['location'][$i]['input_name'] 
                        = $config[$j]['column_name'];
                                        $input_name[]                           
                                                = 
$location['location'][$i]['input_name'];
                                        $location['location'][$i]['size']       
                                = 5;
                                        $location['location'][$i]['value']      
                                = 
$data['location']['value'][$config[$j]['column_name']];
!                                       
$location['location'][$i]['lookup_function_call']       = 'lookup_loc' . 
$fm_location_colst[$j]['location_type'] . '()';
                                        
$location['location'][$i]['lookup_link']                        = True;
                                        $location['location'][$i]['name']       
                                = $config[$j]['descr'];
                                        $location['location'][$i]['value']      
                                = $data['values'][$config[$j]['column_name']];
!                                       $location['location'][$i]['statustext'] 
                        = lang('Klick this link to select') . ' ' 
.$location_types[($fm_location_colst[$j]['location_type']-1)]['name'];
                                        $location['location'][$i]['input_type'] 
                        = 'text';
  
--- 244,255 ----
                                        $location['location'][$i]['input_name'] 
                        = $config[$j]['column_name'];
                                        $input_name[]                           
                                                = 
$location['location'][$i]['input_name'];
+                                       $insert_record[]                        
                                                = 
$location['location'][$i]['input_name'];
                                        $location['location'][$i]['size']       
                                = 5;
                                        $location['location'][$i]['value']      
                                = 
$data['location']['value'][$config[$j]['column_name']];
!                                       
$location['location'][$i]['lookup_function_call']       = 'lookup_loc' . 
$fm_location_cols[$j]['location_type'] . '()';
                                        
$location['location'][$i]['lookup_link']                        = True;
                                        $location['location'][$i]['name']       
                                = $config[$j]['descr'];
                                        $location['location'][$i]['value']      
                                = $data['values'][$config[$j]['column_name']];
!                                       $location['location'][$i]['statustext'] 
                        = lang('Klick this link to select') . ' ' 
.$location_types[($fm_location_cols[$j]['location_type']-1)]['name'];
                                        $location['location'][$i]['input_type'] 
                        = 'text';
  
***************
*** 258,261 ****
--- 259,263 ----
                                                
$location['location'][$i]['name']                                       = 
lang('address');
                                                
$location['location'][$i]['input_type']                         = 'hidden';
+                                               $insert_record[]                
                                                        = 'street_id';
  
                                                
$location['location'][$i]['extra'][0]['input_type']                             
= 'text';
***************
*** 284,287 ****
--- 286,290 ----
                                                
$location['location'][$i]['lookup_function_call']                               
= $lookup_functions[$m]['name'];
                                                
$location['location'][$i]['statustext']                                         
        = lang('tenant');
+                                               $insert_record[]                
                                                                                
= 'tenant_id';
  
                                                
$location['location'][$i]['extra'][0]['input_type']                             
= 'text';
***************
*** 324,327 ****
--- 327,331 ----
                                $location['location'][$i]['input_name']         
                                        = 'equipment_id';
                                $input_name[]                                   
                                                                = 
'equipment_id';
+                               $insert_record[]                                
                                                                = 
'equipment_id';
                                $location['location'][$i]['size']               
                                                = 12;
                                
$location['location'][$i]['lookup_function_call']                               
= 'lookup_equipment()';
***************
*** 341,344 ****
--- 345,349 ----
  
                        
$GLOBALS['phpgw']->session->appsession('lookup_fields',$this->currentapp,$input_name);
+                       
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp,$insert_record);
  
                        for ($i=0;$i<count($location['location']);$i++)
***************
*** 423,427 ****
                }
  
!               function read_single($location_code)
                {
                        return $this->so->read_single($location_code);
--- 428,432 ----
                }
  
!               function read_single($location_code='')
                {
                        return $this->so->read_single($location_code);
***************
*** 433,453 ****
                }
  
  
!               function save($location,$action='')
                {
!                       if ($location['access'])
!                       {
!                               $location['access'] = 'private';
!                       }
!                       else
                        {
!                               $location['access'] = 'public';
                        }
  
                        if ($action=='edit')
                        {
!                               if 
($this->socommon->check_location($location['property_id'],$location['building_id'],$location['entrance_id'],$location['apartment_id']))
                                {
!                                       $receipt = $this->so->edit($location);
                                }
                                else
--- 438,489 ----
                }
  
+               function check_location($location_code='',$type_id='')
+               {
+                       return 
$this->so->check_location($location_code,$type_id);
+               }
+ 
  
!               function 
save($location,$action='',$type_id='',$location_code_parent='')
                {
! 
!                       $location_datatype = 
$GLOBALS['phpgw']->session->appsession('location_datatype',$this->currentapp);
! //    _debug_array($location_datatype);
! 
! 
!                       for ($i=0;$i<count($location_datatype);$i++)
                        {
!                               
if($location_datatype[$i]['datatype']=='decimal' && 
$location[$location_datatype[$i]['input_name']])
!                               {
!                                       
$location[$location_datatype[$i]['input_name']] = 
str_replace(",",".",$location[$location_datatype[$i]['input_name']]);
!                               }
! 
!                               if($location_datatype[$i]['datatype']=='date' 
&& $location[$location_datatype[$i]['input_name']])
!                               {
!                                       $dateformat= 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
!                                       $dateformat = 
str_replace(".","",$dateformat);
!                                       $dateformat = 
str_replace("-","",$dateformat);
!                                       $dateformat = 
str_replace("/","",$dateformat);
!                                       $y=strpos($dateformat,'Y');
!                                       $d=strpos($dateformat,'d');
!                                       $m=strpos($dateformat,'m');
! 
!                                       $dateparts = explode('/', 
$location[$location_datatype[$i]['input_name']]);
!                                       $day            = $dateparts[$d];
!                                       $month          = $dateparts[$m];
!                                       $year           = $dateparts[$y];
! 
! //                                    
$location[$location_datatype[$i]['input_name']] = 
date($this->bocommon->dateformat,mktime(2,0,0,$month,$day,$year));
!                                       
$location[$location_datatype[$i]['input_name']] = 
mktime(0,0,0,$month,$day,$year);
! 
!                               }
                        }
  
+       _debug_array($location);
+ 
                        if ($action=='edit')
                        {
!                               if 
($this->so->check_location($location['location_code'],$type_id))
                                {
!                                       $receipt = 
$this->so->edit($location,$type_id);
                                }
                                else
***************
*** 459,470 ****
                        {
  
!                               
if(!$this->socommon->check_entrance($location['property_id'],$location['building_id'],$location['entrance_id']))
                                {
!                                       
$receipt['error'][]=array('msg'=>lang('This Entrance ID does not exist!'));
                                }
  
                                if(!$receipt['error'])
                                {
!                                       $receipt = $this->so->add($location);
                                }
                        }
--- 495,510 ----
                        {
  
! /*                            if($type_id>1)
                                {
!                                       
if(!$this->so->check_location($location_code_parent,($type_id-1)))
!                                       {
!                                               
$receipt['error'][]=array('msg'=>lang('This location parent ID does not 
exist!'));
!                                       }
                                }
  
+ */
                                if(!$receipt['error'])
                                {
!                                       $receipt = 
$this->so->add($location,$type_id);
                                }
                        }

Index: class.solocation.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.solocation.inc.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** class.solocation.inc.php    13 Jun 2003 11:05:30 -0000      1.4
--- class.solocation.inc.php    14 Jun 2003 21:41:30 -0000      1.5
***************
*** 51,54 ****
--- 51,65 ----
                }
  
+               function check_location($location_code='',$type_id='')
+               {
+                       $this->db->query("SELECT count(*) FROM 
fm_location$type_id where location_code='$location_code'");
+ 
+                       $this->db->next_record();
+ 
+                       if ( $this->db->f(0))
+                       {
+                               return True;
+                       }
+               }
  
  
***************
*** 106,110 ****
                        for ($i=0; $i<($type_id); $i++)
                        {
- 
                                $uicols['input_type'][]         = 'text';
                                $uicols['name'][]                       = 'loc' 
. $location_types[$i]['id'];
--- 117,120 ----
***************
*** 298,304 ****
                }
  
!               function read_single($location_code)
                {
!                       $sql = "SELECT 
fm_apartment.property_id,fm_property.name,building_id,entrance_id,floor,apartment_id,fm_apartment.street_id,street_name,street_number,descr,fm_apartment.cat_id,fm_apartment.remark"
                                . "     FROM fm_apartment $this->join"
                                . " fm_property ON fm_apartment.property_id = 
fm_property.property_id $this->join"
--- 308,470 ----
                }
  
!               function read_single($location_code='')
                {
!                       $location_array = split('-',$location_code);
!                       $type_id= count($location_array);
! 
!                       if (!$type_id)
!                       {
!                               return;
!                       }
! 
!                       $location_types = 
$this->soadmin_location->select_location_type();
! 
!                       $cols = "fm_location" . ($type_id) .".location_code";
!                       $cols_return[] = 'location_code';
!                       for ($i=0; $i<($type_id); $i++)
!                       {
!                               $uicols['input_type'][]         = 'text';
!                               $uicols['name'][]                       = 'loc' 
. $location_types[$i]['id'];
!                               $uicols['descr'][]                      = 
$location_types[$i]['name'];
!                               $uicols['statustext'][]         = 
$location_types[$i]['descr'];
!                               $cols .= ",fm_location" . ($type_id) .".loc" . 
$location_types[$i]['id'];
!                               $cols_return[] = 'loc' . 
$location_types[$i]['id'];
!                       }
! 
!                       $fm_location_cols = 
$this->soadmin_location->read_attrib(array('type_id'=>$type_id));
! 
!                       for ($i=0;$i<count($fm_location_cols);$i++)
!                       {
!                               if($fm_location_cols[$i]['list']==1)
!                               {
!                                       $cols .= ",fm_location" . ($type_id) 
.".".$fm_location_cols[$i]['column_name'];
!                                       $cols_return[]                          
= $fm_location_cols[$i]['column_name'];
!                                       $uicols['input_type'][]         = 
'text';
!                                       $uicols['name'][]                       
= $fm_location_cols[$i]['column_name'];
!                                       $uicols['descr'][]                      
= $fm_location_cols[$i]['input_text'];
!                                       $uicols['statustext'][]         = 
$fm_location_cols[$i]['statustext'];
!                               }
!                       }
! 
! //_debug_array($fm_location_cols);
! 
!                       for ($j=($type_id-1); $j>0; $j--)
!                       {
!                               $joinmethod .= " $this->join fm_location". ($j);
! 
!                               $paranthesis .='(';
! 
! 
!                               $on = 'ON';
!                               for ($i=($j); $i>0; $i--)
!                               {
!                                       $joinmethod .= " $on (fm_location" . 
($j+1) .".loc" . ($i). " = fm_location" . ($j) . ".loc" . ($i) . ")";
!                                       $on = 'AND';
!                                       if($i==1)
!                                       {
!                                               $joinmethod .= ")";
!                                       }
!                               }
!                       }
! 
! 
!                       $config = $this->soadmin_location->read_config('');
! 
! //_debug_array($config);
! 
!                       $cols.= ',fm_location1.loc1_name as loc1_name';
!                       $cols_return[]                          = 'loc1_name';
!                       $uicols['input_type'][]         = 'text';
!                       $uicols['name'][]                       = 'loc1_name';
!                       $uicols['descr'][]                      = 
lang('Property Name');
!                       $uicols['statustext'][]         = lang('Property Name');
! 
! 
!                       if($lookup_tenant)
!                       {
!                               $cols.= ',fm_tenant.tenant_id';
!                               $cols_return[]                          = 
'tenant_id';
!                               $uicols['input_type'][]         = 'hidden';
!                               $uicols['name'][]                       = 
'tenant_id';
! 
!                               $cols.= ',fm_tenant.last_name';
!                               $cols_return[]                          = 
'last_name';
!                               $uicols['input_type'][]         = 'text';
!                               $uicols['name'][]                       = 
'last_name';
!                               $uicols['descr'][]                      = 
lang('last name');
!                               $uicols['statustext'][]         = lang('last 
name');
! 
!                               $cols.= ',fm_tenant.last_name';
!                               $cols_return[]                          = 
'first_name';
!                               $uicols['input_type'][]         = 'text';
!                               $uicols['name'][]                       = 
'first_name';
!                               $uicols['descr'][]                      = 
lang('first name');
!                               $uicols['statustext'][]         = lang('first 
name');
! 
!                               $cols.= ',fm_tenant.last_name';
!                               $cols_return[]                          = 
'contact_phone';
!                               $uicols['input_type'][]         = 'text';
!                               $uicols['name'][]                       = 
'contact_phone';
!                               $uicols['descr'][]                      = 
lang('contact phone');
!                               $uicols['statustext'][]         = lang('contact 
phone');
!                       }
! 
!                       for ($i=0;$i<count($config);$i++)
!                       {
!                               if (($config[$i]['location_type'] <= $type_id) 
&& ($config[$i]['f_key'] ==1))
!                               {
!                                       $joinmethod .= " $this->join  " . 
$config[$i]['reference_table'] . " ON ( fm_location" . 
$config[$i]['location_type'] . "." . $config[$i]['column_name'] . "=" . 
$config[$i]['reference_table'] . ".".$config[$i]['column_name']."))";
! 
!                                       $paranthesis .='(';
!                               }
! 
!                               if (($config[$i]['location_type'] <= $type_id) 
&& ($config[$i]['query_value'] ==1))
!                               {
! 
!                                       
if($config[$i]['column_name']=='street_number')
!                                       {
!                                               $sub_query= "or street_name 
LIKE '%$query%'";
! 
!                                               $cols.= 
',fm_streetaddress.street_name';
!                                               $cols_return[]                  
        = 'street_name';
!                                               $uicols['input_type'][]         
= 'text';
!                                               $uicols['name'][]               
        = 'street_name';
!                                               $uicols['descr'][]              
        = lang('street name');
!                                               $uicols['statustext'][]         
= lang('street name');
! 
!                                               $cols.= ',' . 
$config[$i]['column_name'];
!                                               $cols_return[]                  
        = $config[$i]['column_name'];
!                                               $uicols['input_type'][]         
= 'text';
!                                               $uicols['name'][]               
        = $config[$i]['column_name'];
!                                               $uicols['descr'][]              
        = lang($config[$i]['input_text']);
!                                               $uicols['statustext'][]         
= lang($config[$i]['input_text']);
! 
!                                       }
!                                       else
!                                       {
!                                               $cols.= ',' . 
$config[$i]['column_name'];
!                                               $cols_return[]                  
        = $config[$i]['column_name'];
!                                               $uicols['input_type'][]         
= 'text';
!                                               $uicols['name'][]               
        = $config[$i]['column_name'];
!                                               $uicols['descr'][]              
        = $config[$i]['input_text'];
!                                               $uicols['statustext'][]         
= $config[$i]['input_text'];
!                                       }
!                               }
!                       }
! 
!                       $this->uicols = $uicols;
! 
!                       $from .= " FROM $paranthesis fm_location$type_id ";
! 
! 
! //_debug_array($config);
! 
! 
! 
!                       $sql = "SELECT $cols $from $joinmethod WHERE 
fm_location$type_id.location_code='$location_code' ";
! 
! echo $sql;
! 
! /*                    $sql = "SELECT 
fm_apartment.property_id,fm_property.name,building_id,entrance_id,floor,apartment_id,fm_apartment.street_id,street_name,street_number,descr,fm_apartment.cat_id,fm_apartment.remark"
                                . "     FROM fm_apartment $this->join"
                                . " fm_property ON fm_apartment.property_id = 
fm_property.property_id $this->join"
***************
*** 307,311 ****
                                . " where 
fm_apartment.location_code='$location_code'";
  
!                       $this->db->query($sql,__LINE__,__FILE__);
  
                        if ($this->db->next_record())
--- 473,478 ----
                                . " where 
fm_apartment.location_code='$location_code'";
  
! */
! //                    $this->db->query($sql,__LINE__,__FILE__);
  
                        if ($this->db->next_record())
***************
*** 332,359 ****
                }
  
!               function add($apartment)
                {
!                       $apartment['remark'] = 
$this->db->db_addslashes($apartment['remark']);
  
!                       $this->db->query("INSERT INTO fm_apartment 
(location_code, 
property_id,building_id,entrance_id,apartment_id,floor,street_id,street_number,owner,access,descr,cat_id,remark)
 "
!                               . "VALUES ('" .
!                               $apartment['location_code']. "','" .
!                               $apartment['property_id'] . "','" .
!                               $apartment['building_id'] . "','" .
!                               $apartment['entrance_id'] . "','" .
!                               $apartment['apartment_id'] . "','" .
!                               $apartment['floor'] . "','" .
!                               $apartment['street_idd'] . "','" .
!                               $apartment['street_number'] . "','" .
!                               $this->account . "','" .
!                               $apartment['access'] . "','" .
!                               $apartment['descr'] ."','" .
!                               $apartment['cat_id'] ."','" .
!                               $apartment['remark']. "')",__LINE__,__FILE__);
  
!                       $this->db->query("INSERT INTO fm_location 
(location_code,type) "
!                               . "VALUES ('". $apartment['location_code']. 
"','apartment')",__LINE__,__FILE__);
  
!                       $receipt['message'][] = array('msg'=>lang('Apartment 
has been saved'));
                        return $receipt;
                }
--- 499,525 ----
                }
  
!               function add($location='',$type_id='')
                {
!                       $location['remark'] = 
$this->db->db_addslashes($location['remark']);
! 
!                       while (is_array($location) && list($input_name,$value) 
= each($location))
!                       {
!                               if($value)
!                               {
!                                       $cols[] = $input_name;
!                                       $vals[] = $value;
!                               }
!                       }
! 
!                       $cols   =implode(",", $cols) . ",entry_date,user_id";
!                       $vals   ="'" . implode("','", $vals) . "'," . "'" . 
time() . "','" . $this->account . "'";
! 
  
!                       $sql    = "INSERT INTO fm_location$type_id ($cols) 
VALUES ($vals)";
  
! //echo $sql;
!                       $this->db->query($sql,__LINE__,__FILE__);
  
!                       $receipt['message'][] = array('msg'=>lang('Location %1 
has been saved',$location['location_code']));
                        return $receipt;
                }

Index: class.uilocation.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.uilocation.inc.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** class.uilocation.inc.php    13 Jun 2003 13:15:47 -0000      1.8
--- class.uilocation.inc.php    14 Jun 2003 21:41:30 -0000      1.9
***************
*** 273,292 ****
                        $location = split('-',$location_code);
  
!       _debug_array($_POST);
  
- /*                    while (is_array($_POST) && list($input_name,$value) = 
each($_POST))
-                       {
-                               $values[] = array(
-                               'input_name'    => $input_name,
-                               'value'                 => $value
-                               );
-                       }
  
! */
!                       if(count($_POST)>0)
                        {
!                               $values = $_POST;
                        }
-       _debug_array($values);
  
                        $type_id                = 
get_var('type_id',array('GET'));
--- 273,288 ----
                        $location = split('-',$location_code);
  
!                       $insert_record = 
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
  
  
!       _debug_array($insert_record);
! 
!                       if($_POST['save'])
                        {
!                               for ($i=0; $i<count($insert_record); $i++)
!                               {
!                                       $values[$insert_record[$i]]= 
$_POST[$insert_record[$i]];
!                               }
                        }
  
                        $type_id                = 
get_var('type_id',array('GET'));
***************
*** 299,303 ****
                        $GLOBALS['phpgw']->xslttpl->add_file(array('location'));
  
!                       if (is_array($values))
                        {
  
--- 295,299 ----
                        $GLOBALS['phpgw']->xslttpl->add_file(array('location'));
  
!                       if (is_array($values) )
                        {
  
***************
*** 312,323 ****
  
                                        $values['location_code'][]= 
$values['loc' . $i];
                                }
  
                                $values['location_code']=implode("-", 
$values['location_code']);
  
-       _debug_array($values);
                                if($values['location_code'])
                                {
!                                       
if($this->bocommon->check_location($values['location_code'],$type_id))
                                        {
                                                
$receipt['error'][]=array('msg'=>lang('This location is already registered!') . 
'[ '.$values['location_code'].' ]');
--- 308,324 ----
  
                                        $values['location_code'][]= 
$values['loc' . $i];
+ 
+                                       if($i<$type_id)
+                                       {
+                                               $location_code_parent[]= 
$values['loc' . ($i)];
+                                       }
                                }
  
                                $values['location_code']=implode("-", 
$values['location_code']);
+ //                            $location_code_parent=implode("-", 
$location_code_parent);
  
                                if($values['location_code'])
                                {
!                                       
if($this->bo->check_location($values['location_code'],$type_id))
                                        {
                                                
$receipt['error'][]=array('msg'=>lang('This location is already registered!') . 
'[ '.$values['location_code'].' ]');
***************
*** 331,335 ****
                                        $action='edit';
                                }
!                               else
                                {
                                        $location_code=$values['location_code'];
--- 332,336 ----
                                        $action='edit';
                                }
!                               elseif(!$location_code && !$error_id )
                                {
                                        $location_code=$values['location_code'];
***************
*** 338,342 ****
                                if(!$receipt['error'])
                                {
!                                       $receipt = 
$this->bo->save($values,$action);
                                }
                        }
--- 339,343 ----
                                if(!$receipt['error'])
                                {
!                                       $receipt = 
$this->bo->save($values,$action,$type_id,$location_code_parent);
                                }
                        }
***************
*** 346,349 ****
--- 347,354 ----
                                $values = 
$this->bo->read_single($location_code);
                        }
+                       else
+                       {
+                               unset($values['location_code']);
+                       }
  
                        if ($values['cat_id'] > 0)
***************
*** 359,363 ****
                        );
  
!                       if($values['location_id'])
                        {
                                $location_type='view';
--- 364,368 ----
                        );
  
!                       if($values['location_code'])
                        {
                                $location_type='view';
***************
*** 380,384 ****
                        $config                 = $this->bo->config;
  
!                       if ($location_id)
                        {
                                $function_msg = lang('edit');
--- 385,389 ----
                        $config                 = $this->bo->config;
  
!                       if ($location_code)
                        {
                                $function_msg = lang('edit');
***************
*** 393,396 ****
--- 398,402 ----
  //    _debug_array($config);
                        $custom_fields  = 
$this->soadmin_location->read_attrib(array(type_id=>$type_id));
+                       $insert_record = 
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
  
                        $j=0;
***************
*** 400,403 ****
--- 406,411 ----
                        $additional_fields[$j]['input_name']    = 'loc' . 
$type_id;
                        $additional_fields[$j]['class']                 = 
'th_text';
+                       $insert_record[]                                        
        = $additional_fields[$j]['input_name'];
+ 
                        $j++;
                        $additional_fields[$j]['input_text']    = lang('name');
***************
*** 405,408 ****
--- 413,417 ----
                        $additional_fields[$j]['datatype']              = 
'varchar';
                        $additional_fields[$j]['input_name']    = 'loc' . 
$type_id . '_name';
+                       $insert_record[]                                        
        = $additional_fields[$j]['input_name'];
                        $j++;
  
***************
*** 413,424 ****
--- 422,441 ----
                                $additional_fields[$j]['datatype']              
= $custom['datatype'];
                                $additional_fields[$j]['input_name']    = 
$custom['column_name'];
+                               $insert_record[]                                
                = $additional_fields[$j]['input_name'];
  
+                               $location_datatype[]= array('input_name'        
        => $custom['column_name'],
+                                       'datatype'              => 
$custom['datatype']
+                                       );
                                $j++;
                        }
  
+                       
$GLOBALS['phpgw']->session->appsession('location_datatype',$this->currentapp,$location_datatype);
+ 
+ 
                        $additional_fields[$j]['input_text']    = 
lang('remark');
                        $additional_fields[$j]['statustext']    = lang('enter 
any remark for this location');
                        $additional_fields[$j]['datatype']              = 
'text';
                        $additional_fields[$j]['input_name']    = 'remark';
+                       $insert_record[]                                        
        = $additional_fields[$j]['input_name'];
  
  
***************
*** 433,436 ****
--- 450,454 ----
                                        {
                                                $edit_street=True;
+                                               $insert_record[]        = 
'street_id';
                                        }
  
***************
*** 438,441 ****
--- 456,460 ----
                                        {
                                                $edit_tenant=True;
+                                               $insert_record[]        = 
'tenant_id';
                                        }
  
***************
*** 446,449 ****
--- 465,469 ----
                                                $part_of_town_list              
                = 
$this->bocommon->select_part_of_town('select',$this->part_of_town_id);
                                                $lang_town_statustext           
        = lang('Select the part of town the property belongs to. To do not use 
a part of town -  select NO PART OF TOWN');
+                                               $insert_record[]        = 
'part_of_town_id';
                                        }
                                        
if($config[$j]['column_name']=='owner_id')
***************
*** 454,461 ****
--- 474,484 ----
                                                $lang_select_owner              
                = lang('Select owner');
                                                $lang_owner_statustext          
        = lang('Select the owner');
+                                               $insert_record[]        = 
'owner_id';
                                        }
                                }
                        }
  
+                       
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp,$insert_record);
+ 
  
                        $dateformat = 
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
***************
*** 512,515 ****
--- 535,541 ----
                                'dateformat_source'                             
=> './'.$this->currentapp.'/inc/dateformat.js',
                                'street_link'                                   
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.street'),
+                               'lang_street'                                   
=> lang('Street'),
+                               'lang_select_street_help'               => 
lang('Select the street name'),
+                               'lang_street_num_statustext'    => lang('Enter 
the street number'),
  
                                'tenant_link'                                   
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.tenant'),
***************
*** 522,565 ****
                                'location_type'                                 
=> $location_type,
                                'location_data'                                 
=> $location_data,
-                               'lang_attributes'                               
=> lang('Attributes'),
-                               'attributes_header'                             
=> $attributes_header,
-                               'attributes_values'                             
=> $attributes_values,
                                'form_action'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
                                'done_action'                                   
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.index&type_id='
 . $type_id),
-                               'lang_location_id'                              
=> lang('location ID'),
-                               'lang_floor'                                    
=> lang('floor'),
-                               'lang_street'                                   
=> lang('Street'),
-                               'lang_name'                                     
        => lang('name'),
-                               'lang_descr'                                    
=> lang('Description'),
-                               'lang_category'                                 
=> lang('category'),
-                               'lang_access'                                   
=> lang('private'),
                                'lang_save'                                     
        => lang('save'),
                                'lang_done'                                     
        => lang('done'),
-                               'lang_remark'                                   
=> lang('remark'),
-                               'value_location_id'                     => 
$values['location_id'],
-                               'value_floor'                                   
=> $values['floor'],
-                               'value_street'                                  
=> $values['street_name'],
-                               'value_street_id'                               
=> $values['street_id'],
-                               'value_street_number'                   => 
$values['street_number'],
-                               'value_name'                                    
=> $values['name'],
-                               'value_descr'                                   
=> $values['descr'],
-                               'value_access'                                  
=> $values['access'],
-                               'value_street_name'                             
=> $values['street_name'],
-                               'value_remark'                                  
=> $values['remark'],
-                               'error_flag'                                    
=> $error_id,
-                               'lang_name_statustext'                  => 
lang('Enter the name of the location'),
-                               'lang_select_street_help'               => 
lang('Select the street name'),
-                               'lang_street_num_statustext'    => lang('Enter 
the street number'),
-                               'lang_location_id_statustext'   => lang('Enter 
location ID'),
-                               'lang_floor_statustext'                 => 
lang('Enter the floor'),
-                               'lang_descr_statustext'                 => 
lang('Enter the description'),
                                'lang_done_statustext'                  => 
lang('Back to the list'),
                                'lang_save_statustext'                  => 
lang('Save the location'),
!                               'lang_access_off_statustext'    => lang('The 
location is public. If the location should be private, check this box'),
!                               'lang_access_on_statustext'             => 
lang('The location is private. If the location should be public, uncheck this 
box'),
                                'lang_no_cat'                                   
=> lang('no category'),
                                'lang_cat_statustext'                   => 
lang('Select the category the location belongs to. To do not use a category 
select NO CATEGORY'),
                                'select_name'                                   
=> 'cat_id',
-                               'lang_remark_statustext'                => 
lang('Enter any remarks regarding this location'),
                                'cat_list'                                      
        => $this->bo->select_category_list('select',$values['cat_id'],$type_id)
                        );
--- 548,561 ----
                                'location_type'                                 
=> $location_type,
                                'location_data'                                 
=> $location_data,
                                'form_action'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
                                'done_action'                                   
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.index&type_id='
 . $type_id),
                                'lang_save'                                     
        => lang('save'),
                                'lang_done'                                     
        => lang('done'),
                                'lang_done_statustext'                  => 
lang('Back to the list'),
                                'lang_save_statustext'                  => 
lang('Save the location'),
!                               'lang_category'                                 
=> lang('category'),
                                'lang_no_cat'                                   
=> lang('no category'),
                                'lang_cat_statustext'                   => 
lang('Select the category the location belongs to. To do not use a category 
select NO CATEGORY'),
                                'select_name'                                   
=> 'cat_id',
                                'cat_list'                                      
        => $this->bo->select_category_list('select',$values['cat_id'],$type_id)
                        );





reply via email to

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