phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] property/class.bolocation.php, 1.1.1.3


From: nomail
Subject: [Phpgroupware-cvs] property/class.bolocation.php, 1.1.1.3
Date: Fri, 21 May 2004 19:31:30 -0000

Update of /property
Modified Files:
        Branch: 
          class.bolocation.php

date: 2004/04/23 21:26:33;  author: sigurdne;  state: Exp;  lines: +765 -765

Log Message:
no message
=====================================================================
Index: property/class.bolocation.php
diff -u property/class.bolocation.php:1.1.1.2 
property/class.bolocation.php:1.1.1.3
--- property/class.bolocation.php:1.1.1.2       Fri Apr 23 20:25:23 2004
+++ property/class.bolocation.php       Fri Apr 23 21:26:33 2004
@@ -1,765 +1,765 @@
-<?php
-       
/**************************************************************************\
-       * phpGroupWare - property                                               
   *
-       * http://www.phpgroupware.org                                           
   *
-       *                                                                       
   *
-       * Facilities Management                                                 
   *
-       * Written by Sigurd Nes [sigurdne at online.no]                         
   *
-       * 
------------------------------------------------------------------------ *
-       * Copyright 2000 - 2003 Free Software Foundation, Inc                   
   *
-       * This program is part of the GNU project, see http://www.gnu.org/      
   *
-       * 
------------------------------------------------------------------------ *
-       * This program is free software; you can redistribute it and/or modify 
it  *
-       * under the terms of the GNU General Public License as published by the 
   *
-       * Free Software Foundation; either version 2 of the License, or (at 
your   *
-       * option) any later version.                                            
   *
-       
\**************************************************************************/
-
-       class property_bolocation
-       {
-               var $start;
-               var $query;
-               var $filter;
-               var $sort;
-               var $order;
-               var $cat_id;
-
-               var $public_functions = array
-               (
-                       'read'                          => True,
-                       'read_single'           => True,
-                       'save'                          => True,
-                       'delete'                        => True,
-                       'check_perms'           => True
-               );
-
-               var $soap_functions = array(
-                       'list' => array(
-                               'in'  => 
array('int','int','struct','string','int'),
-                               'out' => array('array')
-                       ),
-                       'read' => array(
-                               'in'  => array('int','struct'),
-                               'out' => array('array')
-                       ),
-                       'save' => array(
-                               'in'  => array('int','struct'),
-                               'out' => array()
-                       ),
-                       'delete' => array(
-                               'in'  => array('int','struct'),
-                               'out' => array()
-                       )
-               );
-
-               function property_bolocation($session=False)
-               {
-                       $this->currentapp                       = 'property'; 
//$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');
-                       $this->fm_session       = 
CreateObject($this->currentapp.'_session');
-
-                       if ($session)
-                       {
-                               $this->read_sessiondata();
-                               $this->use_session = True;
-                       }
-
-                       $start  = get_var('start',array('POST','GET'));
-                       $query  = get_var('query',array('POST','GET'));
-                       $sort   = get_var('sort',array('POST','GET'));
-                       $order  = get_var('order',array('POST','GET'));
-                       $filter = get_var('filter',array('POST','GET'));
-                       $cat_id = get_var('cat_id',array('POST','GET'));
-                       $lookup_tenant  = 
get_var('lookup_tenant',array('POST','GET'));
-                       $district_id    = 
get_var('district_id',array('POST','GET'));
-                       $part_of_town_id        = 
get_var('part_of_town_id',array('POST','GET'));
-                       $status_eco_id  = 
get_var('status_eco_id',array('POST','GET'));
-                       $status_drift_id        = 
get_var('status_drift_id',array('POST','GET'));
-                       $status = get_var('status',array('POST','GET'));
-                       $type_id        = 
get_var('type_id',array('POST','GET'));
-
-
-                       if ($start)
-                       {
-                               $this->start=$start;
-                       }
-                       else
-                       {
-                               $this->start=0;
-                       }
-
-                       if(isset($query))
-                       {
-                               $this->query = $query;
-                       }
-                       if(isset($filter))
-                       {
-                               $this->filter = $filter;
-                       }
-                       if(isset($sort))
-                       {
-                               $this->sort = $sort;
-                       }
-                       if(isset($order))
-                       {
-                               $this->order = $order;
-                       }
-                       if(isset($cat_id))
-                       {
-                               $this->cat_id = $cat_id;
-                       }
-                       if(isset($part_of_town_id))
-                       {
-                               $this->part_of_town_id = $part_of_town_id;
-                       }
-                       if(isset($district_id))
-                       {
-                               $this->district_id = $district_id;
-                       }
-                       if(isset($status_eco_id))
-                       {
-                               $this->status_eco_id = $status_eco_id;
-                       }
-                       if(isset($status_drift_id))
-                       {
-                               $this->status_drift_id = $status_drift_id;
-                       }
-                       if(isset($status))
-                       {
-                               $this->status = $status;
-                       }
-                       if(isset($type_id))
-                       {
-                               $this->type_id = $type_id;
-                       }
-
-               }
-
-               function read_sessiondata()
-               {
-                       $data = 
$this->fm_session->appsession('session_data','location');
-
-                       $this->start                    = $data['start'];
-                       $this->query                    = $data['query'];
-                       $this->filter                   = $data['filter'];
-                       $this->sort                             = $data['sort'];
-                       $this->order                    = $data['order'];
-                       $this->cat_id                   = $data['cat_id'];
-                       $this->part_of_town_id  = $data['part_of_town_id'];
-                       $this->district_id              = $data['district_id'];
-                       $this->status_eco_id    = $data['status_eco_id'];
-                       $this->status_drift_id  = $data['status_drift_id'];
-                       $this->status                   = $data['status'];
-                       $this->type_id                  = $data['type_id'];
-
-               }
-
-               function save_sessiondata($data)
-               {
-                       if ($this->use_session)
-                       {
-                               
$this->fm_session->appsession('session_data','location',$data);
-                       }
-               }
-
-
-               function select_status_list($format='',$selected='')
-               {
-                       switch($format)
-                       {
-                               case 'select':
-
-                                       
$GLOBALS['phpgw']->add_xsl('property.status_select');
-                                       break;
-                               case 'filter':
-                                       
$GLOBALS['phpgw']->add_xsl('property.status_filter');
-                                       break;
-                       }
-
-                       $list= $this->so->select_status_list($this->type_id);
-                       return $this->bocommon->select_list($selected,$list);
-               }
-
-               function read_entity_to_link()
-               {
-                               return $this->so->read_entity_to_link();
-               }
-
-               function get_tenant_status($selected='',$lookup_tenant,$type='')
-               {
-                       if($lookup_tenant)
-                       {
-                               $list= $this->so->get_tenant_status($type);
-                               return 
$this->bocommon->select_list($selected,$list);
-                       }
-               }
-
-
-               function get_owner_list($format='',$selected='')
-               {
-
-                       switch($format)
-                       {
-                               case 'select':
-                                       
$GLOBALS['phpgw']->add_xsl('property.filter_select');
-                                       break;
-                               case 'filter':
-                                       
$GLOBALS['phpgw']->add_xsl('property.filter_filter');
-                                       break;
-                       }
-
-                       $owners = $this->so->get_owner_list();
-
-                       while (is_array($owners) && list(,$owner) = 
each($owners))
-                       {
-                               $sel_owner = '';
-                               if ($owner['id']==$selected)
-                               {
-                                       $sel_owner = 'selected';
-                               }
-
-                               $owner_list[] = array
-                               (
-                                       'id'    => $owner['id'],
-                                       'name'          => $owner['name'],
-                                       'selected'      => $sel_owner
-                               );
-                       }
-
-                       $owner_count=count($owner_list);
-                       for ($i=0;$i<$owner_count;$i++)
-                       {
-                               if ($owner_list[$i]['selected'] != 'selected')
-                               {
-                                       unset($owner_list[$i]['selected']);
-                               }
-                       }
-
-                       return $owner_list;
-               }
-
-               function get_owner_type_list($format='',$selected='')
-               {
-
-                       switch($format)
-                       {
-                               case 'select':
-                                       
$GLOBALS['phpgw']->add_xsl('property.owner_select');
-                                       break;
-                               case 'filter':
-                                       
$GLOBALS['phpgw']->add_xsl('property.owner_filter');
-                                       break;
-                       }
-
-                       $owners = $this->so->get_owner_type_list();
-
-                       while (is_array($owners) && list(,$owner) = 
each($owners))
-                       {
-                               $sel_owner = '';
-                               if ($owner['id']==$selected)
-                               {
-                                       $sel_owner = 'selected';
-                               }
-
-                               $owner_list[] = array
-                               (
-                                       'id'    => $owner['id'],
-                                       'name'          => $owner['name'],
-                                       'selected'      => $sel_owner
-                               );
-                       }
-
-                       $owner_count=count($owner_list);
-
-                       for ($i=0;$i<$owner_count;$i++)
-                       {
-                               if ($owner_list[$i]['selected'] != 'selected')
-                               {
-                                       unset($owner_list[$i]['selected']);
-                               }
-                       }
-
-                       return $owner_list;
-               }
-
-
-               function initiate_ui_location($data)
-               {
-
-                       switch($data['lookup_type'])
-                       {
-                               case 'form':
-                                       
$GLOBALS['phpgw']->add_xsl('property.location_form');
-                                       break;
-                               case 'view':
-                                       
$GLOBALS['phpgw']->add_xsl('property.location_view');
-                                       break;
-                       }
-
-                       $location_link          = 
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uilocation.index&lookup=1');
-
-                       $config = $this->soadmin_location->read_config(array());
-
-                       $this->config   = $config;
-//html_print_r($config);
-                       $location_types = 
$this->soadmin_location->select_location_type();
-                       $this->location_types   = $location_types;
-
-                       if($data['type_id']<0)
-                       {
-                               $data['type_id'] = count($location_types);
-                       }
-//html_print_r($data);
-//html_print_r($location_types);
-                       $fm_location_cols = 
$this->soadmin_location->read_attrib(array('type_id'=>$data['type_id'],'lookup_type'=>$data['type_id']));
-//html_print_r($fm_location_cols);
-
-                       for ($i=0;$i<$data['type_id'];$i++)
-                       {
-                               $location['location'][$i]['input_type']         
                = 'text';
-                               $location['location'][$i]['input_name']         
                = 'loc' . ($i+1);
-                               $input_name[]                                   
                                        = 
$location['location'][$i]['input_name'];
-                               $insert_record['location'][]                    
                        = $location['location'][$i]['input_name'];
-                               $location['location'][$i]['size']               
                        = 5;
-                               $location['location'][$i]['name']               
                        = $location_types[($i)]['name'];
-                               $location['location'][$i]['value']              
                        = $data['values']['loc' . ($i+1)];
-                               $location['location'][$i]['statustext']         
                = lang('Klick this link to select') . ' ' . 
$location_types[($i)]['name'];
-
-                               if($i==0)
-                               {
-                                       
$location['location'][$i]['extra'][0]['input_name']             = 'loc' . 
($i+1).'_name';
-                                       $input_name[]                           
                                                        = 
$location['location'][$i]['extra'][0]['input_name'];
-                                       
$location['location'][$i]['extra'][0]['input_type']                             
= 'text';
-                                       
$location['location'][$i]['extra'][0]['size']                           = 30;
-                                       
$location['location'][$i]['extra'][0]['lookup_function_call']   = 'lookup_loc' 
. ($i+1) . '()';
-                                       
$location['location'][$i]['extra'][0]['value']                          = 
$data['values']['loc' . ($i+1).'_name'];
-                               }
-                               else
-                               {
-                                       
$location['location'][$i]['extra'][0]['input_name']             = 'loc' . 
($i+1).'_name';
-                                       $input_name[]                           
                                                        = 
$location['location'][$i]['extra'][0]['input_name'];
-                                       
$location['location'][$i]['extra'][0]['input_type']                             
= 'text';
-                                       
$location['location'][$i]['extra'][0]['size']                           = 30;
-                                       
$location['location'][$i]['extra'][0]['lookup_function_call']   = 'lookup_loc' 
. ($i+1) . '()';
-                                       
$location['location'][$i]['extra'][0]['value']                          = 
$data['values']['loc' . ($i+1).'_name'];
-                               }
-
-                               
$location['location'][$i]['lookup_function_call']       = 'lookup_loc' . ($i+1) 
. '()';
-                               $location['location'][$i]['lookup_link']        
                = True;
-                               $location['location'][$i]['readonly']           
                = True;
-                               $lookup_functions[$i]['name']                   
                        = 'lookup_loc' . ($i+1) . '()';
-                               $lookup_functions[$i]['action']                 
                        = 'Window1=window.open('."'" . $location_link 
.'&type_id=' . ($i+1) . '&lookup_name=' . $i . "'" 
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
-
-                               if($data['no_link']>=($i+3))
-                               {
-                                       
$location['location'][$i]['lookup_link']                = False;
-                                       $lookup_functions[$i]['action']         
                        = 'Window1=window.open('."'" . $location_link 
.'&type_id=' . ($data['no_link']-1) . '&lookup_name=' . ($data[no_link]-2) . 
"'" 
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
-                                       $location['location'][$i]['statustext'] 
                = lang('Klick this link to select') . ' ' . 
$location_types[($data[no_link]-2)]['name'];
-                               }
-
-                               $m=$i;
-                       }
-
-//html_print_r($fm_location_cols);
-//html_print_r($data);
-
-                       $location_cols_count =count($fm_location_cols);
-                       for ($j=0;$j<$location_cols_count;$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]['readonly']   
                        = 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++;
-
-                               }
-                       }
-
-
-                       $config_count =count($config);
-                       for ($j=0;$j<$config_count;$j++)
-                       {
-                               if($config[$j]['location_type'] <= 
$data['type_id'] && $config[$j]['lookup_form'] )
-                               {
-                                       
if($config[$j]['column_name']=='street_id'):
-                                       {
-                                               
$location['location'][$i]['input_name']                         = 
$config[$j]['column_name'];
-                                               $input_name[]                   
                                                        = 'street_id';
-                                               
$location['location'][$i]['lookup_link']                        = True;
-                                               
$location['location'][$i]['lookup_function_call']       = 'lookup_loc' . 
$config[$j]['location_type'] . '()';
-                                               
$location['location'][$i]['name']                                       = 
lang('address');
-                                               
$location['location'][$i]['input_type']                         = 'hidden';
-                                               
$location['location'][$i]['value']                                      = 
$data['values'][$config[$j]['column_name']];
-
-                                               
$location['location'][$i]['extra'][0]['input_type']                             
= 'text';
-                                               
$location['location'][$i]['extra'][0]['input_name']                             
= 'street_name';
-                                               
$location['location'][$i]['extra'][0]['readonly']                               
= True;
-                                               $input_name[]                   
                                                                                
= $location['location'][$i]['extra'][0]['input_name'];
-                                               
$location['location'][$i]['extra'][0]['size']                                   
= 30;
-                                               
$location['location'][$i]['extra'][0]['lookup_function_call']   = 'lookup_loc' 
. $config[$j]['location_type'] . '()';
-                                               
$location['location'][$i]['extra'][0]['value']                                  
= $data['values']['street_name'];
-
-                                               
$location['location'][$i]['extra'][1]['input_type']                             
= 'text';
-                                               
$location['location'][$i]['extra'][1]['input_name']                             
= 'street_number';
-                                               
$location['location'][$i]['extra'][1]['readonly']                               
= True;
-                                               $input_name[]                   
                                                                                
= $location['location'][$i]['extra'][1]['input_name'];
-                                               
$location['location'][$i]['extra'][1]['size']                                   
= 6;
-                                               
$location['location'][$i]['extra'][1]['lookup_function_call']   = 'lookup_loc' 
. $config[$j]['location_type'] . '()';
-                                               
$location['location'][$i]['extra'][1]['value']                                  
= $data['values']['street_number'];
-                                       }
-                                       
elseif($config[$j]['column_name']=='tenant_id' && $data['tenant']):
-                                       {
-                                               $m++;
-                                               $lookup_functions[$m]['name'] = 
'lookup_loc' . ($m+1) . '()';
-                                               $lookup_functions[$m]['action'] 
= 'Window1=window.open('."'" . $location_link .'&lookup_tenant=1&type_id=' . 
$config[$j]['location_type'] . '&lookup_name=' . $i ."'" 
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
-
-                                               
$location['location'][$i]['lookup_link']                                        
        = True;
-                                               
$location['location'][$i]['name']                                               
                = lang('Tenant');
-                                               
$location['location'][$i]['input_type']                                         
        = 'hidden';
-                                               
$location['location'][$i]['input_name']                                         
        = 'tenant_id';
-                                               $input_name[]                   
                                                                                
= $location['location'][$i]['input_name'];
-                                               
$location['location'][$i]['value']                                              
                = $data['values'][$config[$j]['column_name']];
-                                               
$location['location'][$i]['lookup_function_call']                               
= $lookup_functions[$m]['name'];
-                                               
$location['location'][$i]['statustext']                                         
        = lang('tenant');
-                                               
$insert_record['extra']['tenant_id']                                            
        = 'tenant_id';
-
-                                               
$location['location'][$i]['extra'][0]['input_type']                             
= 'text';
-                                               
$location['location'][$i]['extra'][0]['input_name']                             
= 'last_name';
-                                               
$location['location'][$i]['extra'][0]['readonly']                               
= True;
-                                               $input_name[]                   
                                                                                
= $location['location'][$i]['extra'][0]['input_name'];
-                                               
$location['location'][$i]['extra'][0]['size']                                   
= 15;
-                                               
$location['location'][$i]['extra'][0]['lookup_function_call']   = 
$lookup_functions[$m]['name'];
-                                               
$location['location'][$i]['extra'][0]['value']                                  
= $data['values']['last_name'];
-                                               
$location['location'][$i]['extra'][0]['statustext']                             
= lang('last name');
-
-                                               
$location['location'][$i]['extra'][1]['input_type']                             
= 'text';
-                                               
$location['location'][$i]['extra'][1]['input_name']                             
= 'first_name';
-                                               
$location['location'][$i]['extra'][1]['readonly']                               
= True;
-                                               $input_name[]                   
                                                                                
= $location['location'][$i]['extra'][1]['input_name'];
-                                               
$location['location'][$i]['extra'][1]['size']                                   
= 15;
-                                               
$location['location'][$i]['extra'][1]['lookup_function_call']   = 
$lookup_functions[$m]['name'];
-                                               
$location['location'][$i]['extra'][1]['value']                                  
= $data['values']['first_name'];
-                                               
$location['location'][$i]['extra'][1]['statustext']                             
= lang('first name');
-                                               $i++;
-                                               
$location['location'][$i]['input_type']                         = 'text';
-                                               
$location['location'][$i]['name']                                       = 
lang('Contact phone');
-                                               
$location['location'][$i]['input_name']                         = 
'contact_phone';
-                                               $input_name[]                   
                                                        = 
$location['location'][$i]['input_name'];
-                                               
$location['location'][$i]['size']                                       = 12;
-                                               
$location['location'][$i]['lookup_function_call']       = 
'';//$lookup_functions[$m]['name'];
-                                               
$insert_record['extra']['contact_phone']                        = 
'contact_phone';
-                                               
$location['location'][$i]['value']                                      = 
$data['values']['contact_phone'];
-                                               
$location['location'][$i]['statustext']                         = lang('contact 
phone');
-                                       }
-                                       
elseif($config[$j]['column_name']!='tenant_id' && 
$config[$j]['column_name']!='street_id'):
-                                       {
-                                               
$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';
-                                       }
-                                       endif;
-                                       $i++;
-                               }
-                       }
-
-                       if (isset($data['lookup_entity']) && 
is_array($data['lookup_entity']))
-                       {
-                               foreach($data['lookup_entity'] as $entity)
-                               {
-                                       $m++;
-                                       $entity_link            = 
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uilookup.entity&location_type='
 . $data['type_id'] . '&entity_id=' .$entity['id']);
-
-                                       $lookup_functions[$m]['name'] = 
'lookup_entity_' . $entity['id'] .'()';
-                                       $lookup_functions[$m]['action'] = 
'Window1=window.open('."'" . $entity_link ."'" 
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
-
-                                       $location['location'][$i]['input_type'] 
                                                = 'text';
-                                       $location['location'][$i]['input_name'] 
                                                = 'entity_num_' . $entity['id'];
-                                       $input_name[]                           
                                                                        = 
'entity_num_' . $entity['id'];
-                                       $insert_record['extra']['entity_num_' . 
$entity['id']]                  = 'p_num';
-
-                                       $location['location'][$i]['size']       
                                                        = 8;
-                                       
$location['location'][$i]['lookup_function_call']                               
= 'lookup_entity_' . $entity['id'] .'()';
-                                       
$location['location'][$i]['lookup_link']                                        
        = True;
-                                       $location['location'][$i]['name']       
                                                        = $entity['name'];
-                                       $location['location'][$i]['value']      
                                                        = 
$data['entity_data'][$entity['id']]['p_num'];
-                                       $location['location'][$i]['statustext'] 
                                                = lang('Klick this link to 
select') .' ' . $entity['name'];
-
-                                       
$location['location'][$i]['extra'][0]['input_name']                             
= 'entity_cat_name_' . $entity['id'];
-                                       $input_name[]                           
                                                                        = 
$location['location'][$i]['extra'][0]['input_name'];
-                                       
$location['location'][$i]['extra'][0]['input_type']                             
= 'text';
-                                       
$location['location'][$i]['extra'][0]['size']                                   
= 30;
-                                       
$location['location'][$i]['extra'][0]['lookup_function_call']   = 
'lookup_entity_' . $entity['id'] .'()';
-                                       
$location['location'][$i]['extra'][0]['value']                                  
= $data['entity_data'][$entity['id']]['p_cat_name'];
-
-                                       
$location['location'][$i]['extra'][1]['input_type']                             
= 'hidden';
-                                       
$location['location'][$i]['extra'][1]['input_name']                             
= 'entity_id_' . $entity['id'];
-                                       $input_name[]                           
                                                                        = 
'entity_id_' . $entity['id'];
-                                       $insert_record['extra']['entity_id_' . 
$entity['id']]                   = 'p_entity_id';
-                                       
$location['location'][$i]['extra'][1]['value']                                  
= $data['entity_data'][$entity['id']]['p_entity_id'];
-
-                                       
$location['location'][$i]['extra'][2]['input_type']                             
= 'hidden';
-                                       
$location['location'][$i]['extra'][2]['input_name']                             
= 'cat_id_' . $entity['id'];
-                                       $input_name[]                           
                                                                        = 
'cat_id_' . $entity['id'];
-                                       $insert_record['extra']['cat_id_' . 
$entity['id']]                              = 'p_cat_id';
-                                       
$location['location'][$i]['extra'][2]['value']                                  
= $data['entity_data'][$entity['id']]['p_cat_id'];
-
-                                       $i++;
-                               }
-                       }
-
-//html_print_r($location['location']);
-
-                       
$this->fm_session->appsession('lookup_fields',$this->currentapp,$input_name);
-                       
$this->fm_session->appsession('insert_record',$this->currentapp,$insert_record);
-//                     
$this->fm_session->appsession('input_name',$this->currentapp,$input_name);
-
-                       for ($i=0;$i<count($location['location']);$i++)
-                       {
-                               $lookup_name[] = 
$location['location'][$i]['name'];
-
-                       }
-
-                       
$this->fm_session->appsession('lookup_name',$this->currentapp,$lookup_name);
-
-                       for ($j=0;$j<count($lookup_functions);$j++)
-                       {
-                               $location['lookup_functions'] .= 'function ' . 
$lookup_functions[$j]['name'] ."\r\n";
-                               $location['lookup_functions'] .= '{'."\r\n";
-                               $location['lookup_functions'] .= 
$lookup_functions[$j]['action'] ."\r\n";
-                               $location['lookup_functions'] .= '}'."\r\n";
-                       }
-
-
-//html_print_r($location);
-
-                       return $location;
-
-               }
-
-               function 
select_category_list($format='',$selected='',$type_id='')
-               {
-                       switch($format)
-                       {
-                               case 'select':
-                                       
$GLOBALS['phpgw']->add_xsl('property.cat_select');
-                                       break;
-                               case 'filter':
-                                       
$GLOBALS['phpgw']->add_xsl('property.cat_filter');
-                                       break;
-                       }
-
-                       $categories= $this->so->select_category_list($type_id);
-
-                       while (is_array($categories) && list(,$category) = 
each($categories))
-                       {
-                               $sel_category = '';
-                               if ($category['id']==$selected)
-                               {
-                                       $sel_category = 'selected';
-                               }
-
-                               $category_list[] = array
-                               (
-                                       'cat_id'        => $category['id'],
-                                       'name'          => $category['name'],
-                                       'selected'      => $sel_category
-                               );
-                       }
-
-                       $category_count=count($category_list);
-                       for ($i=0;$i<$category_count;$i++)
-                       {
-                               if ($category_list[$i]['selected'] != 
'selected')
-                               {
-                                       unset($category_list[$i]['selected']);
-                               }
-                       }
-
-                       return $category_list;
-               }
-
-
-               function read($data='')
-               {
-                       $location = $this->so->read(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
-                                                                               
        'filter' => $this->filter,'cat_id' => $this->cat_id,'type_id' => 
$data['type_id'],'lookup_tenant'=>$data['lookup_tenant'],'lookup'=>$data['lookup'],
-                                                                               
        
'district_id'=>$this->district_id,'allrows'=>$data['allrows'],'status_eco_id'=>$this->status_eco_id,'status_drift_id'=>$this->status_drift_id,
-                                                                               
        'status'=>$this->status));
-                       $this->total_records = $this->so->total_records;
-                       $this->uicols = $this->so->uicols;
-
-                       return $location;
-               }
-
-               function read_single($location_code='',$extra='')
-               {
-                       $location_data = $this->so->read_single($location_code);
-
-                       if(!$extra['tenant_id']=='lookup')
-                       {
-                               if($extra['tenant_id']>0)
-                               {
-                                       
$tenant_data=$this->bocommon->read_single_tenant($extra['tenant_id']);
-                                       $location_data['tenant_id']     = 
$extra['tenant_id'];
-                                       $location_data['contact_phone']= 
$extra['contact_phone'];
-                                       $location_data['last_name']     = 
$tenant_data['last_name'];
-                                       $location_data['first_name']    = 
$tenant_data['first_name'];
-                               }
-                               else
-                               {
-                                       unset($location_data['tenant_id']);
-                                       unset($location_data['contact_phone']);
-                                       unset($location_data['last_name']);
-                                       unset($location_data['first_name']);
-                               }
-                       }
-
-                       if(is_array($extra))
-                       {
-                               $location_data = $location_data + $extra;
-                       }
-                       return $location_data;
-               }
-
-               function check_location($location_code='',$type_id='')
-               {
-                       return 
$this->so->check_location($location_code,$type_id);
-               }
-
-
-               function 
save($location,$values_attribute,$action='',$type_id='',$location_code_parent='')
-               {
-
-
-//html_print_r($values_attribute);
-/*                     $location_datatype = 
$this->fm_session->appsession('location_datatype',$this->currentapp);
-//     html_print_r($location_datatype);
-
-                       if(is_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);
-
-                                       }
-                               }
-                       }
-
-*/
-
-                       $m=count($values_attribute);
-                       for ($i=0;$i<$m;$i++)
-                       {
-                               if($values_attribute[$i]['datatype']=='AB')
-                               {
-                                       $values_attribute[$i]['value'] = 
$_POST[$values_attribute[$i]['name']];
-                               }
-                               if($values_attribute[$i]['datatype']=='CH' && 
$values_attribute[$i]['value'])
-                               {
-                                       $values_attribute[$i]['value'] = 
serialize($values_attribute[$i]['value']);
-                               }
-                               if($values_attribute[$i]['datatype']=='R' && 
$values_attribute[$i]['value'])
-                               {
-                                       $values_attribute[$i]['value'] = 
$values_attribute[$i]['value'][0];
-                               }
-
-                               if($values_attribute[$i]['datatype']=='N' && 
$values_attribute[$i]['value'])
-                               {
-                                       $values_attribute[$i]['value'] = 
str_replace(",",".",$values_attribute[$i]['value']);
-                               }
-
-                               if($values_attribute[$i]['datatype']=='D' && 
$values_attribute[$i]['value'])
-                               {
-
-                                       $values_attribute[$i]['value'] = 
date($this->bocommon->dateformat,$this->bocommon->date_to_timestamp($values_attribute[$i]['value']));
-                               }
-                       }
-
-
-//html_print_r($values_attribute);
-
-
-
-//     html_print_r($location);
-
-                       if ($action=='edit')
-                       {
-                               if 
($this->so->check_location($location['location_code'],$type_id))
-                               {
-                                       $receipt = 
$this->so->edit($location,$values_attribute,$type_id);
-                               }
-                               else
-                               {
-                                       
$receipt['error'][]=array('msg'=>lang('This location ID does not exist!'));
-                               }
-                       }
-                       else
-                       {
-
-/*                             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,$values_attribute,$type_id);
-                               }
-                       }
-                       return $receipt;
-               }
-
-               function delete($location_code)
-               {
-                       $this->so->delete($location_code);
-               }
-
-               function update_cat()
-               {
-                       return $this->so->update_cat();
-               }
-
-       }
+<?php
+       
/**************************************************************************\
+       * phpGroupWare - property                                               
   *
+       * http://www.phpgroupware.org                                           
   *
+       *                                                                       
   *
+       * Facilities Management                                                 
   *
+       * Written by Sigurd Nes [sigurdne at online.no]                         
   *
+       * 
------------------------------------------------------------------------ *
+       * Copyright 2000 - 2003 Free Software Foundation, Inc                   
   *
+       * This program is part of the GNU project, see http://www.gnu.org/      
   *
+       * 
------------------------------------------------------------------------ *
+       * This program is free software; you can redistribute it and/or modify 
it  *
+       * under the terms of the GNU General Public License as published by the 
   *
+       * Free Software Foundation; either version 2 of the License, or (at 
your   *
+       * option) any later version.                                            
   *
+       
\**************************************************************************/
+
+       class property_bolocation
+       {
+               var $start;
+               var $query;
+               var $filter;
+               var $sort;
+               var $order;
+               var $cat_id;
+
+               var $public_functions = array
+               (
+                       'read'                          => True,
+                       'read_single'           => True,
+                       'save'                          => True,
+                       'delete'                        => True,
+                       'check_perms'           => True
+               );
+
+               var $soap_functions = array(
+                       'list' => array(
+                               'in'  => 
array('int','int','struct','string','int'),
+                               'out' => array('array')
+                       ),
+                       'read' => array(
+                               'in'  => array('int','struct'),
+                               'out' => array('array')
+                       ),
+                       'save' => array(
+                               'in'  => array('int','struct'),
+                               'out' => array()
+                       ),
+                       'delete' => array(
+                               'in'  => array('int','struct'),
+                               'out' => array()
+                       )
+               );
+
+               function property_bolocation($session=False)
+               {
+                       $this->currentapp                       = 'property'; 
//$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');
+                       $this->fm_session       = 
CreateObject($this->currentapp.'_session');
+
+                       if ($session)
+                       {
+                               $this->read_sessiondata();
+                               $this->use_session = True;
+                       }
+
+                       $start  = get_var('start',array('POST','GET'));
+                       $query  = get_var('query',array('POST','GET'));
+                       $sort   = get_var('sort',array('POST','GET'));
+                       $order  = get_var('order',array('POST','GET'));
+                       $filter = get_var('filter',array('POST','GET'));
+                       $cat_id = get_var('cat_id',array('POST','GET'));
+                       $lookup_tenant  = 
get_var('lookup_tenant',array('POST','GET'));
+                       $district_id    = 
get_var('district_id',array('POST','GET'));
+                       $part_of_town_id        = 
get_var('part_of_town_id',array('POST','GET'));
+                       $status_eco_id  = 
get_var('status_eco_id',array('POST','GET'));
+                       $status_drift_id        = 
get_var('status_drift_id',array('POST','GET'));
+                       $status = get_var('status',array('POST','GET'));
+                       $type_id        = 
get_var('type_id',array('POST','GET'));
+
+
+                       if ($start)
+                       {
+                               $this->start=$start;
+                       }
+                       else
+                       {
+                               $this->start=0;
+                       }
+
+                       if(isset($query))
+                       {
+                               $this->query = $query;
+                       }
+                       if(isset($filter))
+                       {
+                               $this->filter = $filter;
+                       }
+                       if(isset($sort))
+                       {
+                               $this->sort = $sort;
+                       }
+                       if(isset($order))
+                       {
+                               $this->order = $order;
+                       }
+                       if(isset($cat_id))
+                       {
+                               $this->cat_id = $cat_id;
+                       }
+                       if(isset($part_of_town_id))
+                       {
+                               $this->part_of_town_id = $part_of_town_id;
+                       }
+                       if(isset($district_id))
+                       {
+                               $this->district_id = $district_id;
+                       }
+                       if(isset($status_eco_id))
+                       {
+                               $this->status_eco_id = $status_eco_id;
+                       }
+                       if(isset($status_drift_id))
+                       {
+                               $this->status_drift_id = $status_drift_id;
+                       }
+                       if(isset($status))
+                       {
+                               $this->status = $status;
+                       }
+                       if(isset($type_id))
+                       {
+                               $this->type_id = $type_id;
+                       }
+
+               }
+
+               function read_sessiondata()
+               {
+                       $data = 
$this->fm_session->appsession('session_data','location');
+
+                       $this->start                    = $data['start'];
+                       $this->query                    = $data['query'];
+                       $this->filter                   = $data['filter'];
+                       $this->sort                             = $data['sort'];
+                       $this->order                    = $data['order'];
+                       $this->cat_id                   = $data['cat_id'];
+                       $this->part_of_town_id  = $data['part_of_town_id'];
+                       $this->district_id              = $data['district_id'];
+                       $this->status_eco_id    = $data['status_eco_id'];
+                       $this->status_drift_id  = $data['status_drift_id'];
+                       $this->status                   = $data['status'];
+                       $this->type_id                  = $data['type_id'];
+
+               }
+
+               function save_sessiondata($data)
+               {
+                       if ($this->use_session)
+                       {
+                               
$this->fm_session->appsession('session_data','location',$data);
+                       }
+               }
+
+
+               function select_status_list($format='',$selected='')
+               {
+                       switch($format)
+                       {
+                               case 'select':
+
+                                       
$GLOBALS['phpgw']->add_xsl('property.status_select');
+                                       break;
+                               case 'filter':
+                                       
$GLOBALS['phpgw']->add_xsl('property.status_filter');
+                                       break;
+                       }
+
+                       $list= $this->so->select_status_list($this->type_id);
+                       return $this->bocommon->select_list($selected,$list);
+               }
+
+               function read_entity_to_link()
+               {
+                               return $this->so->read_entity_to_link();
+               }
+
+               function get_tenant_status($selected='',$lookup_tenant,$type='')
+               {
+                       if($lookup_tenant)
+                       {
+                               $list= $this->so->get_tenant_status($type);
+                               return 
$this->bocommon->select_list($selected,$list);
+                       }
+               }
+
+
+               function get_owner_list($format='',$selected='')
+               {
+
+                       switch($format)
+                       {
+                               case 'select':
+                                       
$GLOBALS['phpgw']->add_xsl('property.filter_select');
+                                       break;
+                               case 'filter':
+                                       
$GLOBALS['phpgw']->add_xsl('property.filter_filter');
+                                       break;
+                       }
+
+                       $owners = $this->so->get_owner_list();
+
+                       while (is_array($owners) && list(,$owner) = 
each($owners))
+                       {
+                               $sel_owner = '';
+                               if ($owner['id']==$selected)
+                               {
+                                       $sel_owner = 'selected';
+                               }
+
+                               $owner_list[] = array
+                               (
+                                       'id'    => $owner['id'],
+                                       'name'          => $owner['name'],
+                                       'selected'      => $sel_owner
+                               );
+                       }
+
+                       $owner_count=count($owner_list);
+                       for ($i=0;$i<$owner_count;$i++)
+                       {
+                               if ($owner_list[$i]['selected'] != 'selected')
+                               {
+                                       unset($owner_list[$i]['selected']);
+                               }
+                       }
+
+                       return $owner_list;
+               }
+
+               function get_owner_type_list($format='',$selected='')
+               {
+
+                       switch($format)
+                       {
+                               case 'select':
+                                       
$GLOBALS['phpgw']->add_xsl('property.owner_select');
+                                       break;
+                               case 'filter':
+                                       
$GLOBALS['phpgw']->add_xsl('property.owner_filter');
+                                       break;
+                       }
+
+                       $owners = $this->so->get_owner_type_list();
+
+                       while (is_array($owners) && list(,$owner) = 
each($owners))
+                       {
+                               $sel_owner = '';
+                               if ($owner['id']==$selected)
+                               {
+                                       $sel_owner = 'selected';
+                               }
+
+                               $owner_list[] = array
+                               (
+                                       'id'    => $owner['id'],
+                                       'name'          => $owner['name'],
+                                       'selected'      => $sel_owner
+                               );
+                       }
+
+                       $owner_count=count($owner_list);
+
+                       for ($i=0;$i<$owner_count;$i++)
+                       {
+                               if ($owner_list[$i]['selected'] != 'selected')
+                               {
+                                       unset($owner_list[$i]['selected']);
+                               }
+                       }
+
+                       return $owner_list;
+               }
+
+
+               function initiate_ui_location($data)
+               {
+
+                       switch($data['lookup_type'])
+                       {
+                               case 'form':
+                                       
$GLOBALS['phpgw']->add_xsl('property.location_form');
+                                       break;
+                               case 'view':
+                                       
$GLOBALS['phpgw']->add_xsl('property.location_view');
+                                       break;
+                       }
+
+                       $location_link          = 
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uilocation.index&lookup=1');
+
+                       $config = $this->soadmin_location->read_config(array());
+
+                       $this->config   = $config;
+//html_print_r($config);
+                       $location_types = 
$this->soadmin_location->select_location_type();
+                       $this->location_types   = $location_types;
+
+                       if($data['type_id']<0)
+                       {
+                               $data['type_id'] = count($location_types);
+                       }
+//html_print_r($data);
+//html_print_r($location_types);
+                       $fm_location_cols = 
$this->soadmin_location->read_attrib(array('type_id'=>$data['type_id'],'lookup_type'=>$data['type_id']));
+//html_print_r($fm_location_cols);
+
+                       for ($i=0;$i<$data['type_id'];$i++)
+                       {
+                               $location['location'][$i]['input_type']         
                = 'text';
+                               $location['location'][$i]['input_name']         
                = 'loc' . ($i+1);
+                               $input_name[]                                   
                                        = 
$location['location'][$i]['input_name'];
+                               $insert_record['location'][]                    
                        = $location['location'][$i]['input_name'];
+                               $location['location'][$i]['size']               
                        = 5;
+                               $location['location'][$i]['name']               
                        = $location_types[($i)]['name'];
+                               $location['location'][$i]['value']              
                        = $data['values']['loc' . ($i+1)];
+                               $location['location'][$i]['statustext']         
                = lang('Klick this link to select') . ' ' . 
$location_types[($i)]['name'];
+
+                               if($i==0)
+                               {
+                                       
$location['location'][$i]['extra'][0]['input_name']             = 'loc' . 
($i+1).'_name';
+                                       $input_name[]                           
                                                        = 
$location['location'][$i]['extra'][0]['input_name'];
+                                       
$location['location'][$i]['extra'][0]['input_type']                             
= 'text';
+                                       
$location['location'][$i]['extra'][0]['size']                           = 30;
+                                       
$location['location'][$i]['extra'][0]['lookup_function_call']   = 'lookup_loc' 
. ($i+1) . '()';
+                                       
$location['location'][$i]['extra'][0]['value']                          = 
$data['values']['loc' . ($i+1).'_name'];
+                               }
+                               else
+                               {
+                                       
$location['location'][$i]['extra'][0]['input_name']             = 'loc' . 
($i+1).'_name';
+                                       $input_name[]                           
                                                        = 
$location['location'][$i]['extra'][0]['input_name'];
+                                       
$location['location'][$i]['extra'][0]['input_type']                             
= 'text';
+                                       
$location['location'][$i]['extra'][0]['size']                           = 30;
+                                       
$location['location'][$i]['extra'][0]['lookup_function_call']   = 'lookup_loc' 
. ($i+1) . '()';
+                                       
$location['location'][$i]['extra'][0]['value']                          = 
$data['values']['loc' . ($i+1).'_name'];
+                               }
+
+                               
$location['location'][$i]['lookup_function_call']       = 'lookup_loc' . ($i+1) 
. '()';
+                               $location['location'][$i]['lookup_link']        
                = True;
+                               $location['location'][$i]['readonly']           
                = True;
+                               $lookup_functions[$i]['name']                   
                        = 'lookup_loc' . ($i+1) . '()';
+                               $lookup_functions[$i]['action']                 
                        = 'Window1=window.open('."'" . $location_link 
.'&type_id=' . ($i+1) . '&lookup_name=' . $i . "'" 
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+
+                               if($data['no_link']>=($i+3))
+                               {
+                                       
$location['location'][$i]['lookup_link']                = False;
+                                       $lookup_functions[$i]['action']         
                        = 'Window1=window.open('."'" . $location_link 
.'&type_id=' . ($data['no_link']-1) . '&lookup_name=' . ($data[no_link]-2) . 
"'" 
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+                                       $location['location'][$i]['statustext'] 
                = lang('Klick this link to select') . ' ' . 
$location_types[($data[no_link]-2)]['name'];
+                               }
+
+                               $m=$i;
+                       }
+
+//html_print_r($fm_location_cols);
+//html_print_r($data);
+
+                       $location_cols_count =count($fm_location_cols);
+                       for ($j=0;$j<$location_cols_count;$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]['readonly']   
                        = 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++;
+
+                               }
+                       }
+
+
+                       $config_count =count($config);
+                       for ($j=0;$j<$config_count;$j++)
+                       {
+                               if($config[$j]['location_type'] <= 
$data['type_id'] && $config[$j]['lookup_form'] )
+                               {
+                                       
if($config[$j]['column_name']=='street_id'):
+                                       {
+                                               
$location['location'][$i]['input_name']                         = 
$config[$j]['column_name'];
+                                               $input_name[]                   
                                                        = 'street_id';
+                                               
$location['location'][$i]['lookup_link']                        = True;
+                                               
$location['location'][$i]['lookup_function_call']       = 'lookup_loc' . 
$config[$j]['location_type'] . '()';
+                                               
$location['location'][$i]['name']                                       = 
lang('address');
+                                               
$location['location'][$i]['input_type']                         = 'hidden';
+                                               
$location['location'][$i]['value']                                      = 
$data['values'][$config[$j]['column_name']];
+
+                                               
$location['location'][$i]['extra'][0]['input_type']                             
= 'text';
+                                               
$location['location'][$i]['extra'][0]['input_name']                             
= 'street_name';
+                                               
$location['location'][$i]['extra'][0]['readonly']                               
= True;
+                                               $input_name[]                   
                                                                                
= $location['location'][$i]['extra'][0]['input_name'];
+                                               
$location['location'][$i]['extra'][0]['size']                                   
= 30;
+                                               
$location['location'][$i]['extra'][0]['lookup_function_call']   = 'lookup_loc' 
. $config[$j]['location_type'] . '()';
+                                               
$location['location'][$i]['extra'][0]['value']                                  
= $data['values']['street_name'];
+
+                                               
$location['location'][$i]['extra'][1]['input_type']                             
= 'text';
+                                               
$location['location'][$i]['extra'][1]['input_name']                             
= 'street_number';
+                                               
$location['location'][$i]['extra'][1]['readonly']                               
= True;
+                                               $input_name[]                   
                                                                                
= $location['location'][$i]['extra'][1]['input_name'];
+                                               
$location['location'][$i]['extra'][1]['size']                                   
= 6;
+                                               
$location['location'][$i]['extra'][1]['lookup_function_call']   = 'lookup_loc' 
. $config[$j]['location_type'] . '()';
+                                               
$location['location'][$i]['extra'][1]['value']                                  
= $data['values']['street_number'];
+                                       }
+                                       
elseif($config[$j]['column_name']=='tenant_id' && $data['tenant']):
+                                       {
+                                               $m++;
+                                               $lookup_functions[$m]['name'] = 
'lookup_loc' . ($m+1) . '()';
+                                               $lookup_functions[$m]['action'] 
= 'Window1=window.open('."'" . $location_link .'&lookup_tenant=1&type_id=' . 
$config[$j]['location_type'] . '&lookup_name=' . $i ."'" 
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+
+                                               
$location['location'][$i]['lookup_link']                                        
        = True;
+                                               
$location['location'][$i]['name']                                               
                = lang('Tenant');
+                                               
$location['location'][$i]['input_type']                                         
        = 'hidden';
+                                               
$location['location'][$i]['input_name']                                         
        = 'tenant_id';
+                                               $input_name[]                   
                                                                                
= $location['location'][$i]['input_name'];
+                                               
$location['location'][$i]['value']                                              
                = $data['values'][$config[$j]['column_name']];
+                                               
$location['location'][$i]['lookup_function_call']                               
= $lookup_functions[$m]['name'];
+                                               
$location['location'][$i]['statustext']                                         
        = lang('tenant');
+                                               
$insert_record['extra']['tenant_id']                                            
        = 'tenant_id';
+
+                                               
$location['location'][$i]['extra'][0]['input_type']                             
= 'text';
+                                               
$location['location'][$i]['extra'][0]['input_name']                             
= 'last_name';
+                                               
$location['location'][$i]['extra'][0]['readonly']                               
= True;
+                                               $input_name[]                   
                                                                                
= $location['location'][$i]['extra'][0]['input_name'];
+                                               
$location['location'][$i]['extra'][0]['size']                                   
= 15;
+                                               
$location['location'][$i]['extra'][0]['lookup_function_call']   = 
$lookup_functions[$m]['name'];
+                                               
$location['location'][$i]['extra'][0]['value']                                  
= $data['values']['last_name'];
+                                               
$location['location'][$i]['extra'][0]['statustext']                             
= lang('last name');
+
+                                               
$location['location'][$i]['extra'][1]['input_type']                             
= 'text';
+                                               
$location['location'][$i]['extra'][1]['input_name']                             
= 'first_name';
+                                               
$location['location'][$i]['extra'][1]['readonly']                               
= True;
+                                               $input_name[]                   
                                                                                
= $location['location'][$i]['extra'][1]['input_name'];
+                                               
$location['location'][$i]['extra'][1]['size']                                   
= 15;
+                                               
$location['location'][$i]['extra'][1]['lookup_function_call']   = 
$lookup_functions[$m]['name'];
+                                               
$location['location'][$i]['extra'][1]['value']                                  
= $data['values']['first_name'];
+                                               
$location['location'][$i]['extra'][1]['statustext']                             
= lang('first name');
+                                               $i++;
+                                               
$location['location'][$i]['input_type']                         = 'text';
+                                               
$location['location'][$i]['name']                                       = 
lang('Contact phone');
+                                               
$location['location'][$i]['input_name']                         = 
'contact_phone';
+                                               $input_name[]                   
                                                        = 
$location['location'][$i]['input_name'];
+                                               
$location['location'][$i]['size']                                       = 12;
+                                               
$location['location'][$i]['lookup_function_call']       = 
'';//$lookup_functions[$m]['name'];
+                                               
$insert_record['extra']['contact_phone']                        = 
'contact_phone';
+                                               
$location['location'][$i]['value']                                      = 
$data['values']['contact_phone'];
+                                               
$location['location'][$i]['statustext']                         = lang('contact 
phone');
+                                       }
+                                       
elseif($config[$j]['column_name']!='tenant_id' && 
$config[$j]['column_name']!='street_id'):
+                                       {
+                                               
$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';
+                                       }
+                                       endif;
+                                       $i++;
+                               }
+                       }
+
+                       if (isset($data['lookup_entity']) && 
is_array($data['lookup_entity']))
+                       {
+                               foreach($data['lookup_entity'] as $entity)
+                               {
+                                       $m++;
+                                       $entity_link            = 
$this->bocommon->link('/index.php','sid=cookie&op='.$this->currentapp.'.uilookup.entity&location_type='
 . $data['type_id'] . '&entity_id=' .$entity['id']);
+
+                                       $lookup_functions[$m]['name'] = 
'lookup_entity_' . $entity['id'] .'()';
+                                       $lookup_functions[$m]['action'] = 
'Window1=window.open('."'" . $entity_link ."'" 
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+
+                                       $location['location'][$i]['input_type'] 
                                                = 'text';
+                                       $location['location'][$i]['input_name'] 
                                                = 'entity_num_' . $entity['id'];
+                                       $input_name[]                           
                                                                        = 
'entity_num_' . $entity['id'];
+                                       $insert_record['extra']['entity_num_' . 
$entity['id']]                  = 'p_num';
+
+                                       $location['location'][$i]['size']       
                                                        = 8;
+                                       
$location['location'][$i]['lookup_function_call']                               
= 'lookup_entity_' . $entity['id'] .'()';
+                                       
$location['location'][$i]['lookup_link']                                        
        = True;
+                                       $location['location'][$i]['name']       
                                                        = $entity['name'];
+                                       $location['location'][$i]['value']      
                                                        = 
$data['entity_data'][$entity['id']]['p_num'];
+                                       $location['location'][$i]['statustext'] 
                                                = lang('Klick this link to 
select') .' ' . $entity['name'];
+
+                                       
$location['location'][$i]['extra'][0]['input_name']                             
= 'entity_cat_name_' . $entity['id'];
+                                       $input_name[]                           
                                                                        = 
$location['location'][$i]['extra'][0]['input_name'];
+                                       
$location['location'][$i]['extra'][0]['input_type']                             
= 'text';
+                                       
$location['location'][$i]['extra'][0]['size']                                   
= 30;
+                                       
$location['location'][$i]['extra'][0]['lookup_function_call']   = 
'lookup_entity_' . $entity['id'] .'()';
+                                       
$location['location'][$i]['extra'][0]['value']                                  
= $data['entity_data'][$entity['id']]['p_cat_name'];
+
+                                       
$location['location'][$i]['extra'][1]['input_type']                             
= 'hidden';
+                                       
$location['location'][$i]['extra'][1]['input_name']                             
= 'entity_id_' . $entity['id'];
+                                       $input_name[]                           
                                                                        = 
'entity_id_' . $entity['id'];
+                                       $insert_record['extra']['entity_id_' . 
$entity['id']]                   = 'p_entity_id';
+                                       
$location['location'][$i]['extra'][1]['value']                                  
= $data['entity_data'][$entity['id']]['p_entity_id'];
+
+                                       
$location['location'][$i]['extra'][2]['input_type']                             
= 'hidden';
+                                       
$location['location'][$i]['extra'][2]['input_name']                             
= 'cat_id_' . $entity['id'];
+                                       $input_name[]                           
                                                                        = 
'cat_id_' . $entity['id'];
+                                       $insert_record['extra']['cat_id_' . 
$entity['id']]                              = 'p_cat_id';
+                                       
$location['location'][$i]['extra'][2]['value']                                  
= $data['entity_data'][$entity['id']]['p_cat_id'];
+
+                                       $i++;
+                               }
+                       }
+
+//html_print_r($location['location']);
+
+                       
$this->fm_session->appsession('lookup_fields',$this->currentapp,$input_name);
+                       
$this->fm_session->appsession('insert_record',$this->currentapp,$insert_record);
+//                     
$this->fm_session->appsession('input_name',$this->currentapp,$input_name);
+
+                       for ($i=0;$i<count($location['location']);$i++)
+                       {
+                               $lookup_name[] = 
$location['location'][$i]['name'];
+
+                       }
+
+                       
$this->fm_session->appsession('lookup_name',$this->currentapp,$lookup_name);
+
+                       for ($j=0;$j<count($lookup_functions);$j++)
+                       {
+                               $location['lookup_functions'] .= 'function ' . 
$lookup_functions[$j]['name'] ."\r\n";
+                               $location['lookup_functions'] .= '{'."\r\n";
+                               $location['lookup_functions'] .= 
$lookup_functions[$j]['action'] ."\r\n";
+                               $location['lookup_functions'] .= '}'."\r\n";
+                       }
+
+
+//html_print_r($location);
+
+                       return $location;
+
+               }
+
+               function 
select_category_list($format='',$selected='',$type_id='')
+               {
+                       switch($format)
+                       {
+                               case 'select':
+                                       
$GLOBALS['phpgw']->add_xsl('property.cat_select');
+                                       break;
+                               case 'filter':
+                                       
$GLOBALS['phpgw']->add_xsl('property.cat_filter');
+                                       break;
+                       }
+
+                       $categories= $this->so->select_category_list($type_id);
+
+                       while (is_array($categories) && list(,$category) = 
each($categories))
+                       {
+                               $sel_category = '';
+                               if ($category['id']==$selected)
+                               {
+                                       $sel_category = 'selected';
+                               }
+
+                               $category_list[] = array
+                               (
+                                       'cat_id'        => $category['id'],
+                                       'name'          => $category['name'],
+                                       'selected'      => $sel_category
+                               );
+                       }
+
+                       $category_count=count($category_list);
+                       for ($i=0;$i<$category_count;$i++)
+                       {
+                               if ($category_list[$i]['selected'] != 
'selected')
+                               {
+                                       unset($category_list[$i]['selected']);
+                               }
+                       }
+
+                       return $category_list;
+               }
+
+
+               function read($data='')
+               {
+                       $location = $this->so->read(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
+                                                                               
        'filter' => $this->filter,'cat_id' => $this->cat_id,'type_id' => 
$data['type_id'],'lookup_tenant'=>$data['lookup_tenant'],'lookup'=>$data['lookup'],
+                                                                               
        
'district_id'=>$this->district_id,'allrows'=>$data['allrows'],'status_eco_id'=>$this->status_eco_id,'status_drift_id'=>$this->status_drift_id,
+                                                                               
        'status'=>$this->status));
+                       $this->total_records = $this->so->total_records;
+                       $this->uicols = $this->so->uicols;
+
+                       return $location;
+               }
+
+               function read_single($location_code='',$extra='')
+               {
+                       $location_data = $this->so->read_single($location_code);
+
+                       if(!$extra['tenant_id']=='lookup')
+                       {
+                               if($extra['tenant_id']>0)
+                               {
+                                       
$tenant_data=$this->bocommon->read_single_tenant($extra['tenant_id']);
+                                       $location_data['tenant_id']     = 
$extra['tenant_id'];
+                                       $location_data['contact_phone']= 
$extra['contact_phone'];
+                                       $location_data['last_name']     = 
$tenant_data['last_name'];
+                                       $location_data['first_name']    = 
$tenant_data['first_name'];
+                               }
+                               else
+                               {
+                                       unset($location_data['tenant_id']);
+                                       unset($location_data['contact_phone']);
+                                       unset($location_data['last_name']);
+                                       unset($location_data['first_name']);
+                               }
+                       }
+
+                       if(is_array($extra))
+                       {
+                               $location_data = $location_data + $extra;
+                       }
+                       return $location_data;
+               }
+
+               function check_location($location_code='',$type_id='')
+               {
+                       return 
$this->so->check_location($location_code,$type_id);
+               }
+
+
+               function 
save($location,$values_attribute,$action='',$type_id='',$location_code_parent='')
+               {
+
+
+//html_print_r($values_attribute);
+/*                     $location_datatype = 
$this->fm_session->appsession('location_datatype',$this->currentapp);
+//     html_print_r($location_datatype);
+
+                       if(is_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);
+
+                                       }
+                               }
+                       }
+
+*/
+
+                       $m=count($values_attribute);
+                       for ($i=0;$i<$m;$i++)
+                       {
+                               if($values_attribute[$i]['datatype']=='AB')
+                               {
+                                       $values_attribute[$i]['value'] = 
$_POST[$values_attribute[$i]['name']];
+                               }
+                               if($values_attribute[$i]['datatype']=='CH' && 
$values_attribute[$i]['value'])
+                               {
+                                       $values_attribute[$i]['value'] = 
serialize($values_attribute[$i]['value']);
+                               }
+                               if($values_attribute[$i]['datatype']=='R' && 
$values_attribute[$i]['value'])
+                               {
+                                       $values_attribute[$i]['value'] = 
$values_attribute[$i]['value'][0];
+                               }
+
+                               if($values_attribute[$i]['datatype']=='N' && 
$values_attribute[$i]['value'])
+                               {
+                                       $values_attribute[$i]['value'] = 
str_replace(",",".",$values_attribute[$i]['value']);
+                               }
+
+                               if($values_attribute[$i]['datatype']=='D' && 
$values_attribute[$i]['value'])
+                               {
+
+                                       $values_attribute[$i]['value'] = 
date($this->bocommon->dateformat,$this->bocommon->date_to_timestamp($values_attribute[$i]['value']));
+                               }
+                       }
+
+
+//html_print_r($values_attribute);
+
+
+
+//     html_print_r($location);
+
+                       if ($action=='edit')
+                       {
+                               if 
($this->so->check_location($location['location_code'],$type_id))
+                               {
+                                       $receipt = 
$this->so->edit($location,$values_attribute,$type_id);
+                               }
+                               else
+                               {
+                                       
$receipt['error'][]=array('msg'=>lang('This location ID does not exist!'));
+                               }
+                       }
+                       else
+                       {
+
+/*                             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,$values_attribute,$type_id);
+                               }
+                       }
+                       return $receipt;
+               }
+
+               function delete($location_code)
+               {
+                       $this->so->delete($location_code);
+               }
+
+               function update_cat()
+               {
+                       return $this->so->update_cat();
+               }
+
+       }




reply via email to

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