[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property/inc class.boentity.inc.php, 1.7 class.boadmi
From: |
sigurdne |
Subject: |
[Phpgroupware-cvs] property/inc class.boentity.inc.php, 1.7 class.boadmin_entity.inc.php, 1.8 class.soadmin_entity.inc.php, 1.8 class.uiadmin_entity.inc.php, 1.10 |
Date: |
Mon, 24 Oct 2005 12:43:00 +0200 |
Update of property/inc
Modified Files:
Branch: MAIN
class.boentity.inc.php lines: +635 -622
class.boadmin_entity.inc.php lines: +475 -375
class.soadmin_entity.inc.php lines: +1354 -1095
class.uiadmin_entity.inc.php lines: +1495 -1211
Log Message:
Enable custom functions to be performed within an acl_location
====================================================
Index: property/inc/class.boentity.inc.php
diff -u property/inc/class.boentity.inc.php:1.6
property/inc/class.boentity.inc.php:1.7
--- property/inc/class.boentity.inc.php:1.6 Thu May 12 21:26:28 2005
+++ property/inc/class.boentity.inc.php Mon Oct 24 10:43:29 2005
@@ -1,622 +1,635 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
- * @package property
- * @subpackage entity
- * @version $Id$
- */
-
- /**
- * Description
- * @package property
- */
-
- class boentity
- {
- 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 boentity($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.soentity');
-
- $this->solocation =
CreateObject($this->currentapp.'.solocation');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->vfs =
CreateObject('phpgwapi.vfs');
- $this->rootdir = $this->vfs->basedir;
- $this->fakebase = $this->vfs->fakebase;
-
- 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'));
- $district_id =
get_var('district_id',array('POST','GET'));
- $entity_id =
get_var('entity_id',array('POST','GET'));
- $status = get_var('status',array('POST','GET'));
-
- $this->soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity',$entity_id,$cat_id);
- $this->category_name =
$this->soadmin_entity->category_name;
-
- 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($district_id))
- {
- $this->district_id = $district_id;
- }
- if(isset($entity_id))
- {
- $this->entity_id = $entity_id;
- }
- if(isset($status))
- {
- $this->status = $status;
- }
- }
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','entity',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','entity');
-
- //_debug_array($data);
-
- $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->district_id = $data['district_id'];
- $this->entity_id = $data['entity_id'];
- $this->status = $data['status'];
- }
-
- function
column_list($selected='',$entity_id='',$cat_id,$allrows='')
- {
- $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
-
- if(!$selected)
- {
-
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]["entity_columns_"
. $this->entity_id . '_' . $this->cat_id];
- }
-
- $columns =
$soadmin_entity->read_attrib(array('entity_id'=>$entity_id,'cat_id'=>$cat_id,'allrows'=>$allrows));
-
-
$column_list=$this->bocommon->select_multi_list($selected,$columns);
-
- return $column_list;
- }
-
- function select_category_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
- break;
- }
-
- $categories=
$this->soadmin_entity->read_category(array('allrows'=>True,'entity_id'=>$this->entity_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
- );
- }
-
- for ($i=0;$i<count($category_list);$i++)
- {
- if ($category_list[$i]['selected'] !=
'selected')
- {
- unset($category_list[$i]['selected']);
- }
- }
-
- return $category_list;
- }
-
-
- function select_status_list($format='',$selected='')
- {
- switch($format)
- {
- case 'select':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('status_select'));
- break;
- case 'filter':
-
$GLOBALS['phpgw']->xslttpl->add_file(array('status_filter'));
- break;
- }
-
- $status_entries=
$this->so->select_status_list($this->entity_id,$this->cat_id);
-
- while (is_array($status_entries) && list(,$status) =
each($status_entries))
- {
- $sel_status = '';
- if ($status['id']==$selected)
- {
- $sel_status = 'selected';
- }
-
- $status_list[] = array
- (
- 'id' => $status['id'],
- 'name' => $status['name'],
- 'selected' => $sel_status
- );
- }
-
- for ($i=0;$i<count($status_list);$i++)
- {
- if ($status_list[$i]['selected'] != 'selected')
- {
- unset($status_list[$i]['selected']);
- }
- }
-
- return $status_list;
- }
-
-
- function read($data='')
- {
- $entity = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'filter' => $this->filter,'cat_id' => $this->cat_id,'district_id' =>
$this->district_id,
-
'lookup'=>$data['lookup'],'allrows'=>$data['allrows'],'entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'status'=>$this->status,
-
'start_date'=>$this->bocommon->date_to_timestamp($data['start_date']),'end_date'=>$this->bocommon->date_to_timestamp($data['end_date']),
-
'allrows'=>$data['allrows']));
-
- $this->total_records = $this->so->total_records;
-
- $this->uicols = $this->so->uicols;
- $cols_extra = $this->so->cols_extra;
- $cols_return_lookup =
$this->so->cols_return_lookup;
-//_debug_array($entity);
-//_debug_array($cols_extra);
-//_debug_array($cols_return_lookup);
-
- if($data['lookup'])
- {
- for ($i=0;$i<count($entity);$i++)
- {
-
$location_data=$this->solocation->read_single($entity[$i]['location_code']);
- for ($j=0;$j<count($cols_extra);$j++)
- {
- $entity[$i][$cols_extra[$j]] =
$location_data[$cols_extra[$j]];
- }
-
- if($cols_return_lookup)
- {
- for
($k=0;$k<count($cols_return_lookup);$k++)
- {
-
$entity[$i][$cols_return_lookup[$k]] = $location_data[$cols_return_lookup[$k]];
- }
- }
- }
- }
-
- return $entity;
- }
-
- function read_single($data)
- {
- $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
- $contacts =
CreateObject('phpgwapi.contacts');
-
- $vendor = CreateObject($this->currentapp.'.soactor');
- $vendor->role = 'vendor';
-
- $entity = $this->so->read_single($data);
- $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
- $entity['date'] =
$GLOBALS['phpgw']->common->show_date($entity['date'],$dateformat);
-
- if($entity['location_code'])
- {
-
$entity['location_data']=$this->solocation->read_single($entity['location_code']);
- if($entity['tenant_id'])
- {
-
$tenant_data=$this->bocommon->read_single_tenant($entity['tenant_id']);
- $entity['location_data']['tenant_id']
= $entity['tenant_id'];
-
$entity['location_data']['contact_phone']= $entity['contact_phone'];
- $entity['location_data']['last_name']
= $tenant_data['last_name'];
- $entity['location_data']['first_name']
= $tenant_data['first_name'];
- }
- }
-
- if($entity['p_num'])
- {
- $category =
$soadmin_entity->read_single_category($entity['p_entity_id'],$entity['p_cat_id']);
-
-
$entity['p'][$entity['p_entity_id']]['p_num']=$entity['p_num'];
-
$entity['p'][$entity['p_entity_id']]['p_entity_id']=$entity['p_entity_id'];
-
$entity['p'][$entity['p_entity_id']]['p_cat_id']=$entity['p_cat_id'];
-
$entity['p'][$entity['p_entity_id']]['p_cat_name'] = $category['name'];
- }
-
-
- $input_type_array = array(
- 'R' => 'radio',
- 'CH' => 'checkbox',
- 'LB' => 'listbox'
- );
-
- $sep = '/';
- $dlarr[strpos($dateformat,'Y')] = 'Y';
- $dlarr[strpos($dateformat,'m')] = 'm';
- $dlarr[strpos($dateformat,'d')] = 'd';
- ksort($dlarr);
-
- $dateformat= (implode($sep,$dlarr));
-
- $m=0;
- for ($i=0;$i<count($entity['attributes']);$i++)
- {
- if($entity['attributes'][$i]['datatype']=='D'
&& $entity['attributes'][$i]['value'])
- {
- $timestamp_date=
mktime(0,0,0,date(m,strtotime($entity['attributes'][$i]['value'])),date(d,strtotime($entity['attributes'][$i]['value'])),date(y,strtotime($entity['attributes'][$i]['value'])));
- $entity['attributes'][$i]['value']
= $GLOBALS['phpgw']->common->show_date($timestamp_date,$dateformat);
- }
- if($entity['attributes'][$i]['datatype']=='AB')
- {
- if($entity['attributes'][$i]['value'])
- {
- $contact_data
=
$contacts->read_single_entry($entity['attributes'][$i]['value'],array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
-
$entity['attributes'][$i]['contact_name'] = $contact_data[0]['n_family']
. ', ' . $contact_data[0]['n_given'];
- }
-
- $insert_record_entity[] =
$entity['attributes'][$i]['name'];
- $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.addressbook&column='
. $entity['attributes'][$i]['name']);
-
- $lookup_functions[$m]['name'] =
'lookup_'. $entity['attributes'][$i]['name'] .'()';
- $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
- $m++;
- }
-
if($entity['attributes'][$i]['datatype']=='VENDOR')
- {
- if($entity['attributes'][$i]['value'])
- {
- $vendor_data =
$vendor->read_single(array('actor_id'=>$entity['attributes'][$i]['value']));
-
- for
($n=0;$n<count($vendor_data['attributes']);$n++)
- {
-
if($vendor_data['attributes'][$n]['name'] == 'org_name')
- {
-
$entity['attributes'][$i]['vendor_name']=
$vendor_data['attributes'][$n]['value'];
- $n
=count($vendor_data['attributes']);
- }
- }
- }
-
- $insert_record_entity[] =
$entity['attributes'][$i]['name'];
- $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor&column='
. $entity['attributes'][$i]['name']);
-
- $lookup_functions[$m]['name'] =
'lookup_'. $entity['attributes'][$i]['name'] .'()';
- $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
- $m++;
- }
- if($entity['attributes'][$i]['datatype']=='R'
|| $entity['attributes'][$i]['datatype']=='CH' ||
$entity['attributes'][$i]['datatype']=='LB')
- {
- $entity['attributes'][$i]['choice']
=
$soadmin_entity->read_attrib_choice($data['entity_id'],$data['cat_id'],$entity['attributes'][$i]['attrib_id']);
-
$input_type=$input_type_array[$entity['attributes'][$i]['datatype']];
-
-
if($entity['attributes'][$i]['datatype']=='CH')
- {
-
$entity['attributes'][$i]['value']=unserialize($entity['attributes'][$i]['value']);
-
$entity['attributes'][$i]['choice'] =
$this->bocommon->select_multi_list_2($entity['attributes'][$i]['value'],$entity['attributes'][$i]['choice'],$input_type);
-
- }
- else
- {
- for
($j=0;$j<count($entity['attributes'][$i]['choice']);$j++)
- {
-
$entity['attributes'][$i]['choice'][$j]['input_type']=$input_type;
-
if($entity['attributes'][$i]['choice'][$j]['id']==$entity['attributes'][$i]['value'])
- {
-
$entity['attributes'][$i]['choice'][$j]['checked']='checked';
- }
- }
- }
- }
-
- $entity['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($entity['attributes'][$i]['datatype']);
- $entity['attributes'][$i]['counter'] = $i;
- $entity['attributes'][$i]['type_id'] =
$data['type_id'];
- }
-
- for ($j=0;$j<count($lookup_functions);$j++)
- {
- $entity['lookup_functions'] .= 'function ' .
$lookup_functions[$j]['name'] ."\r\n";
- $entity['lookup_functions'] .= '{'."\r\n";
- $entity['lookup_functions'] .=
$lookup_functions[$j]['action'] ."\r\n";
- $entity['lookup_functions'] .= '}'."\r\n";
- }
-
- $this->vfs->override_acl = 1;
-
- $entity['files'] = $this->vfs->ls (array(
- 'string' => $this->fakebase. '/' .
$this->category_name . '/' . $entity['location_data']['loc1'] . '/' .
$data['id'],
- 'relatives' => array(RELATIVE_NONE)));
-
- $this->vfs->override_acl = 0;
-
- if(!$entity['files'][0]['file_id'])
- {
- unset($entity['files']);
- }
-
-
-
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp,$insert_record_entity);
-
-//_debug_array($insert_record_entity);
- return $entity;
- }
-
-
- function create_home_dir($receipt='')
- {
- if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase. SEP .
$this->category_name,
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $this->vfs->override_acl = 1;
-
- if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase. SEP .
$this->category_name,
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . $this->category_name);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . $this->category_name);
- }
- $this->vfs->override_acl = 0;
- }
-
- return $receipt;
- }
-
- function create_document_dir($loc1='',$id='')
- {
- if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase. SEP .
$this->category_name . SEP . $loc1,
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $this->vfs->override_acl = 1;
- if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase. SEP .
$this->category_name . SEP . $loc1,
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $loc1);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $loc1);
- }
- $this->vfs->override_acl = 0;
- }
-
-
- if(!$this->vfs->file_exists(array(
- 'string' => $this->fakebase. SEP .
$this->category_name . SEP . $loc1 . SEP . $id,
- 'relatives' => Array(RELATIVE_NONE)
- )))
- {
- $this->vfs->override_acl = 1;
- if(!$this->vfs->mkdir (array(
- 'string' => $this->fakebase. SEP .
$this->category_name . SEP . $loc1 . SEP . $id,
- 'relatives' => array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $loc1 . SEP . $id);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $loc1 . SEP . $id);
- }
- $this->vfs->override_acl = 0;
- }
-
-//_debug_array($receipt);
- return $receipt;
- }
-
- function
save($values,$values_attribute,$action='',$entity_id,$cat_id)
- {
- while (is_array($values['location']) && list(,$value) =
each($values['location']))
- {
- if($value)
- {
- $location[] = $value;
- }
- }
-
- $values['location_code']=implode("-", $location);
-
- $values['date'] =
$this->bocommon->date_to_timestamp($values['date']);
-
- for ($i=0;$i<count($values_attribute);$i++)
- {
- 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']));
- }
- }
-
- if ($action=='edit')
- {
- $receipt =
$this->so->edit($values,$values_attribute,$entity_id,$cat_id);
-
- if($values['delete_file'])
- {
- for
($i=0;$i<count($values['delete_file']);$i++)
- {
- $file = $this->fakebase. SEP .
$this->category_name . SEP . $location[0] . SEP . $values['id'] . SEP .
$values['delete_file'][$i];
-
-
if($this->vfs->file_exists(array(
- 'string' =>
$file,
- 'relatives' =>
Array(RELATIVE_NONE)
- )))
- {
-
$this->vfs->override_acl = 1;
-
- if(!$this->vfs->rm
(array(
- 'string' =>
$file,
- 'relatives' =>
array(
- RELATIVE_NONE
- )
- )))
- {
-
$receipt['error'][]=array('msg'=>lang('failed to delete file') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $location[0]. SEP .
$values['id'] . SEP .$values['delete_file'][$i]);
- }
- else
- {
-
$receipt['message'][]=array('msg'=>lang('file deleted') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $location[0]. SEP .
$values['id'] . SEP . $values['delete_file'][$i]);
- }
-
$this->vfs->override_acl = 0;
- }
- }
- }
-
- }
- else
- {
- $receipt =
$this->so->add($values,$values_attribute,$entity_id,$cat_id);
- }
- return $receipt;
- }
-
-
- function delete($id )
- {
- $this->so->delete($this->entity_id,$this->cat_id,$id);
- }
-
- function generate_id($data )
- {
- if($data['cat_id'])
- {
- return $this->so->generate_id($data);
- }
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
+ * @package property
+ * @subpackage entity
+ * @version $Id$
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class boentity
+ {
+ 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 boentity($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.soentity');
+
+ $this->solocation =
CreateObject($this->currentapp.'.solocation');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->vfs =
CreateObject('phpgwapi.vfs');
+ $this->rootdir = $this->vfs->basedir;
+ $this->fakebase = $this->vfs->fakebase;
+
+ 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'));
+ $district_id =
get_var('district_id',array('POST','GET'));
+ $entity_id =
get_var('entity_id',array('POST','GET'));
+ $status = get_var('status',array('POST','GET'));
+
+ $this->soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity',$entity_id,$cat_id);
+ $this->category_name =
$this->soadmin_entity->category_name;
+
+ 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($district_id))
+ {
+ $this->district_id = $district_id;
+ }
+ if(isset($entity_id))
+ {
+ $this->entity_id = $entity_id;
+ }
+ if(isset($status))
+ {
+ $this->status = $status;
+ }
+ }
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','entity',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','entity');
+
+ //_debug_array($data);
+
+ $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->district_id = $data['district_id'];
+ $this->entity_id = $data['entity_id'];
+ $this->status = $data['status'];
+ }
+
+ function
column_list($selected='',$entity_id='',$cat_id,$allrows='')
+ {
+ $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
+
+ if(!$selected)
+ {
+
$selected=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]["entity_columns_"
. $this->entity_id . '_' . $this->cat_id];
+ }
+
+ $columns =
$soadmin_entity->read_attrib(array('entity_id'=>$entity_id,'cat_id'=>$cat_id,'allrows'=>$allrows));
+
+
$column_list=$this->bocommon->select_multi_list($selected,$columns);
+
+ return $column_list;
+ }
+
+ function select_category_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('cat_filter'));
+ break;
+ }
+
+ $categories=
$this->soadmin_entity->read_category(array('allrows'=>True,'entity_id'=>$this->entity_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
+ );
+ }
+
+ for ($i=0;$i<count($category_list);$i++)
+ {
+ if ($category_list[$i]['selected'] !=
'selected')
+ {
+ unset($category_list[$i]['selected']);
+ }
+ }
+
+ return $category_list;
+ }
+
+
+ function select_status_list($format='',$selected='')
+ {
+ switch($format)
+ {
+ case 'select':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('status_select'));
+ break;
+ case 'filter':
+
$GLOBALS['phpgw']->xslttpl->add_file(array('status_filter'));
+ break;
+ }
+
+ $status_entries=
$this->so->select_status_list($this->entity_id,$this->cat_id);
+
+ while (is_array($status_entries) && list(,$status) =
each($status_entries))
+ {
+ $sel_status = '';
+ if ($status['id']==$selected)
+ {
+ $sel_status = 'selected';
+ }
+
+ $status_list[] = array
+ (
+ 'id' => $status['id'],
+ 'name' => $status['name'],
+ 'selected' => $sel_status
+ );
+ }
+
+ for ($i=0;$i<count($status_list);$i++)
+ {
+ if ($status_list[$i]['selected'] != 'selected')
+ {
+ unset($status_list[$i]['selected']);
+ }
+ }
+
+ return $status_list;
+ }
+
+
+ function read($data='')
+ {
+ $entity = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'filter' => $this->filter,'cat_id' => $this->cat_id,'district_id' =>
$this->district_id,
+
'lookup'=>$data['lookup'],'allrows'=>$data['allrows'],'entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'status'=>$this->status,
+
'start_date'=>$this->bocommon->date_to_timestamp($data['start_date']),'end_date'=>$this->bocommon->date_to_timestamp($data['end_date']),
+
'allrows'=>$data['allrows']));
+
+ $this->total_records = $this->so->total_records;
+
+ $this->uicols = $this->so->uicols;
+ $cols_extra = $this->so->cols_extra;
+ $cols_return_lookup =
$this->so->cols_return_lookup;
+//_debug_array($entity);
+//_debug_array($cols_extra);
+//_debug_array($cols_return_lookup);
+
+ if($data['lookup'])
+ {
+ for ($i=0;$i<count($entity);$i++)
+ {
+
$location_data=$this->solocation->read_single($entity[$i]['location_code']);
+ for ($j=0;$j<count($cols_extra);$j++)
+ {
+ $entity[$i][$cols_extra[$j]] =
$location_data[$cols_extra[$j]];
+ }
+
+ if($cols_return_lookup)
+ {
+ for
($k=0;$k<count($cols_return_lookup);$k++)
+ {
+
$entity[$i][$cols_return_lookup[$k]] = $location_data[$cols_return_lookup[$k]];
+ }
+ }
+ }
+ }
+
+ return $entity;
+ }
+
+ function read_single($data)
+ {
+ $soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
+ $contacts =
CreateObject('phpgwapi.contacts');
+
+ $vendor = CreateObject($this->currentapp.'.soactor');
+ $vendor->role = 'vendor';
+
+ $entity = $this->so->read_single($data);
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $entity['date'] =
$GLOBALS['phpgw']->common->show_date($entity['date'],$dateformat);
+
+ if($entity['location_code'])
+ {
+
$entity['location_data']=$this->solocation->read_single($entity['location_code']);
+ if($entity['tenant_id'])
+ {
+
$tenant_data=$this->bocommon->read_single_tenant($entity['tenant_id']);
+ $entity['location_data']['tenant_id']
= $entity['tenant_id'];
+
$entity['location_data']['contact_phone']= $entity['contact_phone'];
+ $entity['location_data']['last_name']
= $tenant_data['last_name'];
+ $entity['location_data']['first_name']
= $tenant_data['first_name'];
+ }
+ }
+
+ if($entity['p_num'])
+ {
+ $category =
$soadmin_entity->read_single_category($entity['p_entity_id'],$entity['p_cat_id']);
+
+
$entity['p'][$entity['p_entity_id']]['p_num']=$entity['p_num'];
+
$entity['p'][$entity['p_entity_id']]['p_entity_id']=$entity['p_entity_id'];
+
$entity['p'][$entity['p_entity_id']]['p_cat_id']=$entity['p_cat_id'];
+
$entity['p'][$entity['p_entity_id']]['p_cat_name'] = $category['name'];
+ }
+
+
+ $input_type_array = array(
+ 'R' => 'radio',
+ 'CH' => 'checkbox',
+ 'LB' => 'listbox'
+ );
+
+ $sep = '/';
+ $dlarr[strpos($dateformat,'Y')] = 'Y';
+ $dlarr[strpos($dateformat,'m')] = 'm';
+ $dlarr[strpos($dateformat,'d')] = 'd';
+ ksort($dlarr);
+
+ $dateformat= (implode($sep,$dlarr));
+
+ $m=0;
+ for ($i=0;$i<count($entity['attributes']);$i++)
+ {
+ if($entity['attributes'][$i]['datatype']=='D'
&& $entity['attributes'][$i]['value'])
+ {
+ $timestamp_date=
mktime(0,0,0,date(m,strtotime($entity['attributes'][$i]['value'])),date(d,strtotime($entity['attributes'][$i]['value'])),date(y,strtotime($entity['attributes'][$i]['value'])));
+ $entity['attributes'][$i]['value']
= $GLOBALS['phpgw']->common->show_date($timestamp_date,$dateformat);
+ }
+ if($entity['attributes'][$i]['datatype']=='AB')
+ {
+ if($entity['attributes'][$i]['value'])
+ {
+ $contact_data
=
$contacts->read_single_entry($entity['attributes'][$i]['value'],array('n_given'=>'n_given','n_family'=>'n_family','email'=>'email'));
+
$entity['attributes'][$i]['contact_name'] = $contact_data[0]['n_family']
. ', ' . $contact_data[0]['n_given'];
+ }
+
+ $insert_record_entity[] =
$entity['attributes'][$i]['name'];
+ $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.addressbook&column='
. $entity['attributes'][$i]['name']);
+
+ $lookup_functions[$m]['name'] =
'lookup_'. $entity['attributes'][$i]['name'] .'()';
+ $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+ $m++;
+ }
+
if($entity['attributes'][$i]['datatype']=='VENDOR')
+ {
+ if($entity['attributes'][$i]['value'])
+ {
+ $vendor_data =
$vendor->read_single(array('actor_id'=>$entity['attributes'][$i]['value']));
+
+ for
($n=0;$n<count($vendor_data['attributes']);$n++)
+ {
+
if($vendor_data['attributes'][$n]['name'] == 'org_name')
+ {
+
$entity['attributes'][$i]['vendor_name']=
$vendor_data['attributes'][$n]['value'];
+ $n
=count($vendor_data['attributes']);
+ }
+ }
+ }
+
+ $insert_record_entity[] =
$entity['attributes'][$i]['name'];
+ $lookup_link =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.vendor&column='
. $entity['attributes'][$i]['name']);
+
+ $lookup_functions[$m]['name'] =
'lookup_'. $entity['attributes'][$i]['name'] .'()';
+ $lookup_functions[$m]['action'] =
'Window1=window.open('."'" . $lookup_link ."'"
.',"Search","width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+ $m++;
+ }
+ if($entity['attributes'][$i]['datatype']=='R'
|| $entity['attributes'][$i]['datatype']=='CH' ||
$entity['attributes'][$i]['datatype']=='LB')
+ {
+ $entity['attributes'][$i]['choice']
=
$soadmin_entity->read_attrib_choice($data['entity_id'],$data['cat_id'],$entity['attributes'][$i]['attrib_id']);
+
$input_type=$input_type_array[$entity['attributes'][$i]['datatype']];
+
+
if($entity['attributes'][$i]['datatype']=='CH')
+ {
+
$entity['attributes'][$i]['value']=unserialize($entity['attributes'][$i]['value']);
+
$entity['attributes'][$i]['choice'] =
$this->bocommon->select_multi_list_2($entity['attributes'][$i]['value'],$entity['attributes'][$i]['choice'],$input_type);
+
+ }
+ else
+ {
+ for
($j=0;$j<count($entity['attributes'][$i]['choice']);$j++)
+ {
+
$entity['attributes'][$i]['choice'][$j]['input_type']=$input_type;
+
if($entity['attributes'][$i]['choice'][$j]['id']==$entity['attributes'][$i]['value'])
+ {
+
$entity['attributes'][$i]['choice'][$j]['checked']='checked';
+ }
+ }
+ }
+ }
+
+ $entity['attributes'][$i]['datatype_text'] =
$this->bocommon->translate_datatype($entity['attributes'][$i]['datatype']);
+ $entity['attributes'][$i]['counter'] = $i;
+ $entity['attributes'][$i]['type_id'] =
$data['type_id'];
+ }
+
+ for ($j=0;$j<count($lookup_functions);$j++)
+ {
+ $entity['lookup_functions'] .= 'function ' .
$lookup_functions[$j]['name'] ."\r\n";
+ $entity['lookup_functions'] .= '{'."\r\n";
+ $entity['lookup_functions'] .=
$lookup_functions[$j]['action'] ."\r\n";
+ $entity['lookup_functions'] .= '}'."\r\n";
+ }
+
+ $this->vfs->override_acl = 1;
+
+ $entity['files'] = $this->vfs->ls (array(
+ 'string' => $this->fakebase. '/' .
$this->category_name . '/' . $entity['location_data']['loc1'] . '/' .
$data['id'],
+ 'relatives' => array(RELATIVE_NONE)));
+
+ $this->vfs->override_acl = 0;
+
+ if(!$entity['files'][0]['file_id'])
+ {
+ unset($entity['files']);
+ }
+
+
+
$GLOBALS['phpgw']->session->appsession('insert_record_entity',$this->currentapp,$insert_record_entity);
+
+//_debug_array($insert_record_entity);
+ return $entity;
+ }
+
+
+ function create_home_dir($receipt='')
+ {
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase. SEP .
$this->category_name,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase. SEP .
$this->category_name,
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . $this->category_name);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . $this->category_name);
+ }
+ $this->vfs->override_acl = 0;
+ }
+
+ return $receipt;
+ }
+
+ function create_document_dir($loc1='',$id='')
+ {
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase. SEP .
$this->category_name . SEP . $loc1,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase. SEP .
$this->category_name . SEP . $loc1,
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $loc1);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $loc1);
+ }
+ $this->vfs->override_acl = 0;
+ }
+
+
+ if(!$this->vfs->file_exists(array(
+ 'string' => $this->fakebase. SEP .
$this->category_name . SEP . $loc1 . SEP . $id,
+ 'relatives' => Array(RELATIVE_NONE)
+ )))
+ {
+ $this->vfs->override_acl = 1;
+ if(!$this->vfs->mkdir (array(
+ 'string' => $this->fakebase. SEP .
$this->category_name . SEP . $loc1 . SEP . $id,
+ 'relatives' => array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to create directory') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $loc1 . SEP . $id);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('directory created') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $loc1 . SEP . $id);
+ }
+ $this->vfs->override_acl = 0;
+ }
+
+//_debug_array($receipt);
+ return $receipt;
+ }
+
+ function
save($values,$values_attribute,$action='',$entity_id,$cat_id)
+ {
+ while (is_array($values['location']) && list(,$value) =
each($values['location']))
+ {
+ if($value)
+ {
+ $location[] = $value;
+ }
+ }
+
+ $values['location_code']=implode("-", $location);
+
+ $values['date'] =
$this->bocommon->date_to_timestamp($values['date']);
+
+ for ($i=0;$i<count($values_attribute);$i++)
+ {
+ 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']));
+ }
+ }
+
+ if ($action=='edit')
+ {
+ $receipt =
$this->so->edit($values,$values_attribute,$entity_id,$cat_id);
+
+ if($values['delete_file'])
+ {
+ for
($i=0;$i<count($values['delete_file']);$i++)
+ {
+ $file = $this->fakebase. SEP .
$this->category_name . SEP . $location[0] . SEP . $values['id'] . SEP .
$values['delete_file'][$i];
+
+
if($this->vfs->file_exists(array(
+ 'string' =>
$file,
+ 'relatives' =>
Array(RELATIVE_NONE)
+ )))
+ {
+
$this->vfs->override_acl = 1;
+
+ if(!$this->vfs->rm
(array(
+ 'string' =>
$file,
+ 'relatives' =>
array(
+ RELATIVE_NONE
+ )
+ )))
+ {
+
$receipt['error'][]=array('msg'=>lang('failed to delete file') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $location[0]. SEP .
$values['id'] . SEP .$values['delete_file'][$i]);
+ }
+ else
+ {
+
$receipt['message'][]=array('msg'=>lang('file deleted') . ' :'.
$this->fakebase. SEP . $this->category_name . SEP . $location[0]. SEP .
$values['id'] . SEP . $values['delete_file'][$i]);
+ }
+
$this->vfs->override_acl = 0;
+ }
+ }
+ }
+
+ }
+ else
+ {
+ $receipt =
$this->so->add($values,$values_attribute,$entity_id,$cat_id);
+ }
+
+ $acl_location = '.entity.' . $entity_id . '.' . $cat_id;
+ $custom_functions =
$this->soadmin_entity->read_custom_function(array('acl_location' =>
$acl_location,'allrows'=>True));
+
+ if (isSet($custom_functions) AND
is_array($custom_functions))
+ {
+ foreach($custom_functions as $entry)
+ {
+ if (is_file(PHPGW_APP_INC . SEP .
'custom' . SEP . $entry['file_name']) && $entry['active'])
+ include (PHPGW_APP_INC . SEP . 'custom'
. SEP . $entry['file_name']);
+ }
+
+ }
+ return receipt;
+ }
+
+
+ function delete($id )
+ {
+ $this->so->delete($this->entity_id,$this->cat_id,$id);
+ }
+
+ function generate_id($data )
+ {
+ if($data['cat_id'])
+ {
+ return $this->so->generate_id($data);
+ }
+ }
+
+ }
+?>
====================================================
Index: property/inc/class.boadmin_entity.inc.php
diff -u property/inc/class.boadmin_entity.inc.php:1.7
property/inc/class.boadmin_entity.inc.php:1.8
--- property/inc/class.boadmin_entity.inc.php:1.7 Fri May 13 12:17:24 2005
+++ property/inc/class.boadmin_entity.inc.php Mon Oct 24 10:43:29 2005
@@ -1,375 +1,475 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id$
- */
-
- /**
- * Description
- * @package property
- */
-
- class boadmin_entity
- {
- var $start;
- var $query;
- var $filter;
- var $sort;
- var $order;
- var $cat_id;
- var $entity_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 boadmin_entity($session=False)
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->so =
CreateObject($this->currentapp.'.soadmin_entity');
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- 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'));
- $allrows =
get_var('allrows',array('POST','GET'));
- $entity_id =
get_var('entity_id',array('POST','GET'));
-
- if ($start)
- {
- $this->start=$start;
- }
- else
- {
- $this->start=0;
- }
-
- if(isset($query))
- {
- $this->query = $query;
- }
- if(!empty($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($entity_id))
- {
- $this->entity_id = $entity_id;
- }
- if(isset($allrows))
- {
- $this->allrows = $allrows;
- }
- }
-
-
- function save_sessiondata($data)
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data','standard_e',$data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','standard_e');
-
-
- $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->entity_id = $data['entity_id'];
- $this->allrows = $data['allrows'];
- }
-
- function reset_fm_cache()
- {
- $this->so->reset_fm_cache();
- }
-
-
- function get_location_level_list($selected='')
- {
-
- $soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
- $location_types =
$soadmin_location->select_location_type();
- $max_location_type=count($location_types);
-
- for ($i=1; $i<=$max_location_type; $i++)
- {
- $location[$i][id] = $i;
- $location[$i][name] = $i . '-' .
$location_types[($i-1)]['name'];
- }
-
- return
$this->bocommon->select_list($selected,$location);
-
- }
-
- function get_entity_list($selected='')
- {
- $list = $this->so->read(array('allrows'=>True));
- return
$this->bocommon->select_multi_list($selected,$list);
- }
-
- function get_entity_list_2($selected='')
- {
- $list[0]['id']='project';
- $list[0]['name']='project';
- $list[1]['id']='ticket';
- $list[1]['name']='ticket';
- $list[2]['id']='document';
- $list[2]['name']='document';
- $list[3]['id']='request';
- $list[3]['name']='request';
- $list[4]['id']='investment';
- $list[4]['name']='investment';
- $list[5]['id']='s_agreement';
- $list[5]['name']='service agreement';
- return
$this->bocommon->select_multi_list($selected,$list);
- }
-
- function get_entity_list_3($selected='')
- {
- $list[0]['id']='ticket';
- $list[0]['name']='ticket';
- $list[1]['id']='request';
- $list[1]['name']='request';
- return
$this->bocommon->select_multi_list($selected,$list);
- }
-
- function read()
- {
- $entity = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,'allrows'=>$this->allrows));
-
- $this->total_records = $this->so->total_records;
- return $entity;
- }
-
- function read_category($entity_id)
- {
- $category = $this->so->read_category(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,
- 'order' =>
$this->order,'allrows'=>$this->allrows,'entity_id'=>$entity_id));
-
- $this->total_records = $this->so->total_records;
-
- return $category;
- }
-
- function read_status()
- {
- $status = $this->so->read_status(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,
- 'order' =>
$this->order,'allrows'=>$this->allrows,'entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id));
-
- $this->total_records = $this->so->total_records;
-
- return $status;
- }
-
- function read_config()
- {
- $standard = $this->so->read_config(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order));
-
- $this->total_records = $this->so->total_records;
-
-
- return $standard;
- }
-
- function read_config_single($column_name)
- {
- return $this->so->read_config_single($column_name);
- }
-
- function read_single($id)
- {
- return $this->so->read_single($id);
- }
-
- function read_single_category($entity_id,$cat_id)
- {
- return
$this->so->read_single_category($entity_id,$cat_id);
- }
-
- function read_single_status($id)
- {
- return
$this->so->read_single_status($this->entity_id,$this->cat_id,$id);
- }
-
- function save($values,$action='')
- {
- if ($action=='edit')
- {
- if ($values['id'] != '')
- {
- $receipt =
$this->so->edit_entity($values);
- }
- }
- else
- {
- $receipt = $this->so->add_entity($values);
- }
- return $receipt;
- }
-
- function save_category($values,$action='')
- {
- if ($action=='edit')
- {
- if ($values['id'] != '')
- {
- $receipt =
$this->so->edit_category($values);
- }
- }
- else
- {
- $receipt = $this->so->add_category($values);
- }
- return $receipt;
- }
-
- function save_status($values,$action='')
- {
- if ($action=='edit')
- {
- if ($values['id'] != '')
- {
- $receipt =
$this->so->edit_status($values,$this->entity_id,$this->cat_id);
- }
- }
- else
- {
- $receipt =
$this->so->add_status($values,$this->entity_id,$this->cat_id);
- }
- return $receipt;
- }
-
- function
delete($cat_id='',$entity_id='',$attrib_id='',$status_id='')
- {
- if(!$status_id && !$attrib_id && !$cat_id &&
$entity_id):
- {
- $this->so->delete_entity($entity_id);
- }
- elseif(!$status_id && !$attrib_id && $cat_id &&
$entity_id):
- {
- $this->so->delete_category($cat_id,$entity_id);
- }
- elseif(!$status_id && $attrib_id && $cat_id &&
$entity_id):
- {
-
$this->so->delete_attrib($cat_id,$entity_id,$attrib_id);
- }
- elseif($status_id && !$attrib_id && $cat_id &&
$entity_id):
- {
-
$this->so->delete_status($cat_id,$entity_id,$status_id);
- }
- endif;
- }
-
- function read_attrib($entity_id='',$cat_id='',$allrows='')
- {
- if($allrows)
- {
- $this->allrows = $allrows;
- }
-
- $attrib = $this->so->read_attrib(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'cat_id' => $cat_id,'entity_id' =>
$entity_id,'allrows'=>$this->allrows));
-
- for ($i=0; $i<count($attrib); $i++)
- {
- $attrib[$i]['datatype'] =
$this->bocommon->translate_datatype($attrib[$i]['datatype']);
- }
-
- $this->total_records = $this->so->total_records;
-
- return $attrib;
- }
-
- function read_single_attrib($entity_id,$cat_id,$id)
- {
- return
$this->so->read_single_attrib($entity_id,$cat_id,$id);
- }
-
- function resort_attrib($id,$resort)
- {
-
$this->so->resort_attrib(array('resort'=>$resort,'entity_id' =>
$this->entity_id,'cat_id' => $this->cat_id,'id'=>$id));
- }
-
- function save_attrib($attrib,$action='')
- {
- if ($action=='edit')
- {
- if ($attrib['id'] != '')
- {
-
- $receipt =
$this->so->edit_attrib($attrib);
- }
- }
- else
- {
- $receipt = $this->so->add_attrib($attrib);
- }
- return $receipt;
- }
-
- function save_config($values='',$column_name='')
- {
- return
$this->so->save_config($values,$column_name);
- }
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id$
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class boadmin_entity
+ {
+ var $start;
+ var $query;
+ var $filter;
+ var $sort;
+ var $order;
+ var $cat_id;
+ var $entity_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 boadmin_entity($session=False)
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->so =
CreateObject($this->currentapp.'.soadmin_entity');
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+
+ 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'));
+ $allrows =
get_var('allrows',array('POST','GET'));
+ $entity_id =
get_var('entity_id',array('POST','GET'));
+
+ if ($start)
+ {
+ $this->start=$start;
+ }
+ else
+ {
+ $this->start=0;
+ }
+
+ if(isset($query))
+ {
+ $this->query = $query;
+ }
+ if(!empty($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($entity_id))
+ {
+ $this->entity_id = $entity_id;
+ }
+ if(isset($allrows))
+ {
+ $this->allrows = $allrows;
+ }
+ }
+
+
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+
$GLOBALS['phpgw']->session->appsession('session_data','standard_e',$data);
+ }
+ }
+
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','standard_e');
+
+
+ $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->entity_id = $data['entity_id'];
+ $this->allrows = $data['allrows'];
+ }
+
+ function reset_fm_cache()
+ {
+ $this->so->reset_fm_cache();
+ }
+
+
+ function get_location_level_list($selected='')
+ {
+
+ $soadmin_location =
CreateObject($this->currentapp.'.soadmin_location');
+ $location_types =
$soadmin_location->select_location_type();
+ $max_location_type=count($location_types);
+
+ for ($i=1; $i<=$max_location_type; $i++)
+ {
+ $location[$i][id] = $i;
+ $location[$i][name] = $i . '-' .
$location_types[($i-1)]['name'];
+ }
+
+ return
$this->bocommon->select_list($selected,$location);
+
+ }
+
+ function get_entity_list($selected='')
+ {
+ $list = $this->so->read(array('allrows'=>True));
+ return
$this->bocommon->select_multi_list($selected,$list);
+ }
+
+ function get_entity_list_2($selected='')
+ {
+ $list[0]['id']='project';
+ $list[0]['name']='project';
+ $list[1]['id']='ticket';
+ $list[1]['name']='ticket';
+ $list[2]['id']='document';
+ $list[2]['name']='document';
+ $list[3]['id']='request';
+ $list[3]['name']='request';
+ $list[4]['id']='investment';
+ $list[4]['name']='investment';
+ $list[5]['id']='s_agreement';
+ $list[5]['name']='service agreement';
+ return
$this->bocommon->select_multi_list($selected,$list);
+ }
+
+ function get_entity_list_3($selected='')
+ {
+ $list[0]['id']='ticket';
+ $list[0]['name']='ticket';
+ $list[1]['id']='request';
+ $list[1]['name']='request';
+ return
$this->bocommon->select_multi_list($selected,$list);
+ }
+
+ function read()
+ {
+ $entity = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,'allrows'=>$this->allrows));
+
+ $this->total_records = $this->so->total_records;
+ return $entity;
+ }
+
+ function read_category($entity_id)
+ {
+ $category = $this->so->read_category(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,
+ 'order' =>
$this->order,'allrows'=>$this->allrows,'entity_id'=>$entity_id));
+
+ $this->total_records = $this->so->total_records;
+
+ return $category;
+ }
+
+ function read_status()
+ {
+ $status = $this->so->read_status(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,
+ 'order' =>
$this->order,'allrows'=>$this->allrows,'entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id));
+
+ $this->total_records = $this->so->total_records;
+
+ return $status;
+ }
+
+ function read_config()
+ {
+ $standard = $this->so->read_config(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order));
+
+ $this->total_records = $this->so->total_records;
+
+
+ return $standard;
+ }
+
+ function read_config_single($column_name)
+ {
+ return $this->so->read_config_single($column_name);
+ }
+
+ function read_single($id)
+ {
+ return $this->so->read_single($id);
+ }
+
+ function read_single_category($entity_id,$cat_id)
+ {
+ return
$this->so->read_single_category($entity_id,$cat_id);
+ }
+
+ function read_single_status($id)
+ {
+ return
$this->so->read_single_status($this->entity_id,$this->cat_id,$id);
+ }
+
+ function save($values,$action='')
+ {
+ if ($action=='edit')
+ {
+ if ($values['id'] != '')
+ {
+ $receipt =
$this->so->edit_entity($values);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add_entity($values);
+ }
+ return $receipt;
+ }
+
+ function save_category($values,$action='')
+ {
+ if ($action=='edit')
+ {
+ if ($values['id'] != '')
+ {
+ $receipt =
$this->so->edit_category($values);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add_category($values);
+ }
+ return $receipt;
+ }
+
+ function save_status($values,$action='')
+ {
+ if ($action=='edit')
+ {
+ if ($values['id'] != '')
+ {
+ $receipt =
$this->so->edit_status($values,$this->entity_id,$this->cat_id);
+ }
+ }
+ else
+ {
+ $receipt =
$this->so->add_status($values,$this->entity_id,$this->cat_id);
+ }
+ return $receipt;
+ }
+
+ function
delete($cat_id='',$entity_id='',$attrib_id='',$status_id='',$acl_location='',$custom_function_id='')
+ {
+ if(!$status_id && !$attrib_id && !$cat_id && $entity_id
&& !$custom_function_id):
+ {
+ $this->so->delete_entity($entity_id);
+ }
+ elseif(!$status_id && !$attrib_id && $cat_id &&
$entity_id && !$custom_function_id):
+ {
+ $this->so->delete_category($cat_id,$entity_id);
+ }
+ elseif(!$status_id && $attrib_id && $cat_id &&
$entity_id && !$custom_function_id):
+ {
+
$this->so->delete_attrib($cat_id,$entity_id,$attrib_id);
+ }
+ elseif($status_id && !$attrib_id && $cat_id &&
$entity_id && !$custom_function_id):
+ {
+
$this->so->delete_status($cat_id,$entity_id,$status_id);
+ }
+ elseif(!$status_id && $custom_function_id &&
$acl_location):
+ {
+
$this->so->delete_custom_function($acl_location,$custom_function_id);
+ }
+ endif;
+
+
+ }
+
+ function read_attrib($entity_id='',$cat_id='',$allrows='')
+ {
+ if($allrows)
+ {
+ $this->allrows = $allrows;
+ }
+
+ $attrib = $this->so->read_attrib(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
+
'cat_id' => $cat_id,'entity_id' =>
$entity_id,'allrows'=>$this->allrows));
+
+ for ($i=0; $i<count($attrib); $i++)
+ {
+ $attrib[$i]['datatype'] =
$this->bocommon->translate_datatype($attrib[$i]['datatype']);
+ }
+
+ $this->total_records = $this->so->total_records;
+
+ return $attrib;
+ }
+
+ function read_single_attrib($entity_id,$cat_id,$id)
+ {
+ return
$this->so->read_single_attrib($entity_id,$cat_id,$id);
+ }
+
+ function resort_attrib($id,$resort)
+ {
+
$this->so->resort_attrib(array('resort'=>$resort,'entity_id' =>
$this->entity_id,'cat_id' => $this->cat_id,'id'=>$id));
+ }
+
+ function save_attrib($attrib,$action='')
+ {
+ if ($action=='edit')
+ {
+ if ($attrib['id'] != '')
+ {
+
+ $receipt =
$this->so->edit_attrib($attrib);
+ }
+ }
+ else
+ {
+ $receipt = $this->so->add_attrib($attrib);
+ }
+ return $receipt;
+ }
+
+ function save_config($values='',$column_name='')
+ {
+ return
$this->so->save_config($values,$column_name);
+ }
+
+ function
read_custom_function($entity_id='',$cat_id='',$allrows='', $acl_location='')
+ {
+ if($allrows)
+ {
+ $this->allrows = $allrows;
+ }
+
+ if (!$acl_location && $entity_id && $cat_id)
+ {
+ $acl_location = '.entity.' . $entity_id . '.' .
$cat_id;
+ }
+
+ $custom_function =
$this->so->read_custom_function(array('start' => $this->start,'query' =>
$this->query,'sort' => $this->sort,'order' => $this->order,
+
'acl_location' => $acl_location,'allrows'=>$this->allrows));
+
+ $this->total_records = $this->so->total_records;
+
+ return $custom_function;
+ }
+
+ function resort_custom_function($id,$resort)
+ {
+
$this->so->resort_custom_function(array('resort'=>$resort,'entity_id' =>
$this->entity_id,'cat_id' => $this->cat_id,'id'=>$id));
+ }
+
+ function save_custom_function($custom_function,$action='')
+ {
+ if ($action=='edit')
+ {
+ if ($custom_function['id'] != '')
+ {
+
+ $receipt =
$this->so->edit_custom_function($custom_function);
+ }
+ }
+ else
+ {
+ $receipt =
$this->so->add_custom_function($custom_function);
+ }
+ return $receipt;
+ }
+
+ function select_custom_function($selected='')
+ {
+
+ $dir_handle = @opendir(PHPGW_APP_INC . SEP . 'custom');
+ $i=0; $myfilearray = '';
+ while ($file = readdir($dir_handle))
+ {
+ if ((substr($file, 0, 1) != '.') &&
is_file(PHPGW_APP_INC . SEP . 'custom' . SEP . $file) )
+ {
+ $myfilearray[$i] = $file;
+ $i++;
+ }
+ }
+ closedir($dir_handle);
+ sort($myfilearray);
+
+ for ($i=0;$i<count($myfilearray);$i++)
+ {
+ $fname = ereg_replace('_',' ',$myfilearray[$i]);
+ $sel_file = '';
+ if ($myfilearray[$i]==$selected)
+ {
+ $sel_file = 'selected';
+ }
+
+ $file_list[] = array
+ (
+ 'id' => $myfilearray[$i],
+ 'name' => $fname,
+ 'selected' => $sel_file
+ );
+ }
+
+ for ($i=0;$i<count($file_list);$i++)
+ {
+ if ($file_list[$i]['selected'] != 'selected')
+ {
+ unset($conv_list[$i]['selected']);
+ }
+ }
+
+ return $file_list;
+ }
+ function
read_single_custom_function($entity_id='',$cat_id='',$id,$acl_location='')
+ {
+ if (!$acl_location && $entity_id && $cat_id)
+ {
+ $acl_location = '.entity.' . $entity_id . '.' .
$cat_id;
+ }
+ return
$this->so->read_single_custom_function($acl_location,$id);
+ }
+ }
+?>
====================================================
Index: property/inc/class.soadmin_entity.inc.php
diff -u property/inc/class.soadmin_entity.inc.php:1.7
property/inc/class.soadmin_entity.inc.php:1.8
--- property/inc/class.soadmin_entity.inc.php:1.7 Thu May 12 21:26:28 2005
+++ property/inc/class.soadmin_entity.inc.php Mon Oct 24 10:43:29 2005
@@ -1,1095 +1,1354 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id$
- */
-
- /**
- * Description
- * @package property
- */
-
- class soadmin_entity
- {
- var $grants;
-
- function soadmin_entity($entity_id='',$cat_id='')
- {
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
-
- $this->join = $this->bocommon->join;
- $this->like = $this->bocommon->like;
-
- if($entity_id && $cat_id)
- {
- $this->category_name =
$this->read_category_name($entity_id,$cat_id);
- }
- }
-
- function reset_fm_cache()
- {
- $this->db->query("DELETE FROM fm_cache
",__LINE__,__FILE__);
- }
-
- function read($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by id asc';
- }
-
- $table = 'fm_entity';
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " where name $this->like
'%$query%' or descr $this->like '%$query%'";
- }
-
- $sql = "SELECT * FROM $table $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $entity[] = array
- (
- 'id' => $this->db->f('id'),
- 'name' => $this->db->f('name'),
- 'descr' => $this->db->f('descr'),
- 'documentation' =>
$this->db->f('documentation')
- );
- }
- return $entity;
- }
-
- function read_category($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $entity_id =
(isset($data['entity_id'])?$data['entity_id']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by id asc';
- }
-
- $table = 'fm_entity_category';
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " AND name $this->like
'%$query%' or descr $this->like '%$query%'";
- }
-
- $sql = "SELECT * FROM $table WHERE entity_id=$entity_id
$querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $standard[] = array
- (
- 'id' => $this->db->f('id'),
- 'name' => $this->db->f('name'),
- 'prefix'=> $this->db->f('prefix'),
- 'descr' => $this->db->f('descr')
- );
- }
- return $standard;
- }
-
- function read_status($data)
- {
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $entity_id =
(isset($data['entity_id'])?$data['entity_id']:'');
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by id asc';
- }
-
- $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " AND name $this->like
'%$query%' or descr $this->like '%$query%'";
- }
-
- $sql = "SELECT * FROM $table $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
-
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
- while ($this->db->next_record())
- {
- $status[] = array
- (
- 'id' => $this->db->f('id'),
- 'descr' => $this->db->f('descr')
- );
- }
- return $status;
- }
-
-
- function read_single($id)
- {
-
- $sql = "SELECT * FROM fm_entity where id='$id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $entity['id'] =
$this->db->f('id');
- $entity['name'] =
$this->db->f('name');
- $entity['descr'] =
$this->db->f('descr');
- $entity['location_form'] =
$this->db->f('location_form');
- $entity['lookup_entity'] =
unserialize($this->db->f('lookup_entity'));
- $entity['documentation'] =
$this->db->f('documentation');
- }
-
- $sql = "SELECT location FROM fm_entity_lookup where
entity_id=$id AND type='lookup'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $entity['include_entity_for'][] =
$this->db->f('location');
- }
-
- $sql = "SELECT location FROM fm_entity_lookup where
entity_id=$id AND type='start'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $entity['start_entity_from'][] =
$this->db->f('location');
- }
-
- return $entity;
- }
-
- function read_single_category($entity_id,$cat_id)
- {
- $sql = "SELECT * FROM fm_entity_category where
entity_id=$entity_id AND id=$cat_id";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $category['id'] =
$this->db->f('id');
- $category['name'] =
$this->db->f('name');
- $category['descr'] =
$this->db->f('descr');
- $category['prefix'] =
$this->db->f('prefix');
- $category['lookup_tenant'] =
$this->db->f('lookup_tenant');
- $category['tracking'] =
$this->db->f('tracking');
- $category['location_level'] =
$this->db->f('location_level');
- $category['fileupload'] =
$this->db->f('fileupload');
- $category['loc_link'] =
$this->db->f('loc_link');
- $category['start_project'] =
$this->db->f('start_project');
- return $category;
- }
- }
-
- function read_category_name($entity_id,$cat_id)
- {
- $sql = "SELECT * FROM fm_entity_category where
entity_id=$entity_id AND id=$cat_id";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- return $this->db->f('name');
- }
-
- function read_single_status($entity_id,$cat_id,$id)
- {
-
- $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
- $sql = "SELECT * FROM $table where id='$id'";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $status['id'] =
$this->db->f('id');
- $status['descr'] =
$this->db->f('descr');
-
- return $status;
- }
- }
-
- function add_entity($entity)
- {
- $entity['name'] =
$this->db->db_addslashes($entity['name']);
- $entity['descr'] =
$this->db->db_addslashes($entity['descr']);
-
- $entity['id'] = $this->bocommon->next_id('fm_entity');
-
- $values= array(
- $entity['id'],
- $entity['name'],
- $entity['descr'],
- $entity['location_form'],
- $entity['documentation']
- );
-
- $values = $this->bocommon->validate_db_insert($values);
-
- $this->db->query("INSERT INTO fm_entity (id,name,
descr,location_form,documentation) "
- . "VALUES ($values)",__LINE__,__FILE__);
-
-
- $values_acl_location= array(
- '.entity.' . $entity['id'],
- $entity['name'],
- 1
- );
-
- $values_acl_location =
$this->bocommon->validate_db_insert($values_acl_location);
-
- $this->db->query("INSERT INTO fm_acl_location
(id,descr,allow_grant) "
- . "VALUES
($values_acl_location)",__LINE__,__FILE__);
-
- $receipt['id']= $entity['id'];
-
- $receipt['message'][] = array('msg'=> lang('entity has
been added'));
- return $receipt;
- }
-
-
- function add_status($values,$entity_id,$cat_id)
- {
- $values['id'] = $this->db->db_addslashes($values['id']);
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
-
- $values_insert= array(
- $values['id'],
- $values['descr'],
- );
-
- $values_insert =
$this->bocommon->validate_db_insert($values_insert);
-
- $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
-
- $this->db->query("INSERT INTO $table (id,descr) VALUES
($values_insert)",__LINE__,__FILE__);
-
- $receipt['id']= $values['id'];
-
- $receipt['message'][] = array('msg'=> lang('status has
been added'));
- return $receipt;
- }
-
-
- function add_category($values)
- {
- $values['name'] =
$this->db->db_addslashes($values['name']);
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
-
- $values['id'] =
$this->bocommon->next_id('fm_entity_category',array('entity_id'=>$values['entity_id']));
-
- $location_type =
$this->bocommon->next_id('fm_location_type');
-
- $values_insert= array(
- $values['entity_id'],
- $values['id'],
- $values['name'],
- $values['descr'],
- $values['prefix'],
- $values['lookup_tenant'],
- $values['tracking'],
- $values['location_level'],
- $values['fileupload'],
- $values['loc_link'],
- $values['start_project']
- );
-
- $values_insert =
$this->bocommon->validate_db_insert($values_insert);
-
-
- $this->db->transaction_begin();
-
- $this->db->query("INSERT INTO fm_entity_category
(entity_id,id,name,
descr,prefix,lookup_tenant,tracking,location_level,fileupload,loc_link,start_project)
"
- . "VALUES ($values_insert)",__LINE__,__FILE__);
-
- $values_acl_location= array(
- '.entity.' . $values['entity_id'] . '.' .
$values['id'],
- $values['name'],
- 1
- );
-
- $values_acl_location =
$this->bocommon->validate_db_insert($values_acl_location);
-
- $this->db->query("INSERT INTO fm_acl_location
(id,descr,allow_grant) "
- . "VALUES
($values_acl_location)",__LINE__,__FILE__);
-
- $receipt['id']= $values['id'];
-
- $this->init_process();
-
- $fd=array();
- $fd['id'] = array('type' => 'int', 'precision' => 4,
'nullable' => False);
- $fd['num'] = array('type' => 'varchar', 'precision' =>
16, 'nullable' => False);
- $fd['p_num'] = array('type' => 'varchar', 'precision'
=> 16, 'nullable' => True);
- $fd['p_entity_id'] = array('type' => 'int', 'precision'
=> 4, 'nullable' => True);
- $fd['p_cat_id'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
- $fd['location_code'] = array('type' => 'varchar',
'precision' => 25, 'nullable' => True);
-
- for ($i=1; $i<$location_type; $i++)
- {
- $fd['loc' . $i] = array('type' => 'varchar',
'precision' => 4, 'nullable' => True);
- }
-
- $fd['address'] = array('type' => 'varchar', 'precision'
=> 150, 'nullable' => True);
- $fd['tenant_id'] = array('type' => 'int', 'precision'
=> 4, 'nullable' => True);
- $fd['contact_phone'] = array('type' => 'varchar',
'precision' => 30, 'nullable' => True);
- $fd['status'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
- $fd['entry_date'] = array('type' => 'int', 'precision'
=> 4, 'nullable' => True);
- $fd['user_id'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
-
- $pk[]= 'id';
- $table = 'fm_entity_'.
$values['entity_id'] .'_'.$values['id'];
-/*
- $fd_status['id'] = array('type' => 'varchar',
'precision' => 20, 'nullable' => False);
- $fd_status['descr'] = array('type' => 'varchar',
'precision' => 255, 'nullable' => False);
- $pk_status[]= 'id';
-
- $statustable = $table . '_' .'status';
-*/
- if(($this->oProc->CreateTable($table,array('fd' =>
$fd,'pk' => $pk,'fk' => $fk,'ix' => array('location_code'),'uc' => array()))))
-// &&
($this->oProc->CreateTable($statustable,array('fd' => $fd_status,'pk' =>
$pk_status,'fk' => $fk_status,'ix' => False,'uc' => array()))))
- {
-
- $values_insert= array(
- $values['entity_id'],
- $values['id'],
- 1,
- 'status',
- 'Status',
- 'Status',
- 'LB',
- 1,
- 'True'
- );
-
- $values_insert =
$this->bocommon->validate_db_insert($values_insert);
-
- $this->db->query("INSERT INTO
fm_entity_attribute
(entity_id,cat_id,id,column_name,input_text,statustext,datatype,attrib_sort,nullable)
"
- . "VALUES
($values_insert)",__LINE__,__FILE__);
-
- $receipt['message'][] = array('msg' =>
lang('table %1 has been saved',$table));
- $this->db->transaction_commit();
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('table could not be added') );
- if($this->db->Transaction)
- {
- $this->db->transaction_abort();
- }
- else
- {
- $this->db->query("DELETE FROM
fm_entity_category WHERE id=" . $values['id'] . " AND entity_id=" .
$values['entity_id'],__LINE__,__FILE__);
- unset($receipt['id']);
-
- }
- }
-
- return $receipt;
- }
-
- function edit_status($values,$entity_id,$cat_id)
- {
- $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
-
- $values['descr'] =
$this->db->db_addslashes($values['descr']);
-
- $value_set=array(
- 'descr' => $values['descr'],
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE $table set $value_set WHERE
id='" . $values['id'] . "'",__LINE__,__FILE__);
-
- $receipt['message'][] = array('msg'=> lang('Status has
been edited'));
-
- return $receipt;
- }
-
- function edit_entity($entity)
- {
- if (!$entity['name'])
- {
- $receipt['error'][] = array('msg'=>lang('Name
not entered!'));
- }
-
- if (!$receipt['error'])
- {
- $table = 'fm_entity';
-
- $entity['name'] =
$this->db->db_addslashes($entity['name']);
- $entity['descr'] =
$this->db->db_addslashes($entity['descr']);
-
- if(!$entity['location_form'])
- {
- unset($entity['lookup_entity']);
- }
-
- $value_set=array(
- 'descr' => $entity['descr'],
- 'name' => $entity['name'],
- 'location_form' => $entity['location_form'],
- 'lookup_entity' =>
serialize($entity['lookup_entity']),
- 'documentation' => $entity['documentation']
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->transaction_begin();
-
- $this->db->query("UPDATE $table set $value_set
WHERE id=" . $entity['id'],__LINE__,__FILE__);
-
- $value_set_acl=array(
- 'descr' =>
$entity['name']
- );
-
- $value_set_acl =
$this->bocommon->validate_db_update($value_set_acl);
-
- $this->db->query("UPDATE fm_acl_location set
$value_set_acl WHERE id='.entity." . $entity['id']. "'",__LINE__,__FILE__);
-
- $this->db->query("DELETE FROM fm_entity_lookup
WHERE type='lookup' AND entity_id=" . $entity['id'],__LINE__,__FILE__);
- if (isset($entity['include_entity_for']) AND
is_array($entity['include_entity_for']))
- {
- foreach($entity['include_entity_for']
as $location)
- {
- $this->db->query("INSERT INTO
fm_entity_lookup (entity_id,location,type)"
- . "VALUES (" .$entity['id'] .
",'$location','lookup' )",__LINE__,__FILE__);
- }
- }
-
- $this->db->query("DELETE FROM fm_entity_lookup
WHERE type='start' AND entity_id=" . $entity['id'],__LINE__,__FILE__);
-
- if (isset($entity['start_entity_from']) AND
is_array($entity['start_entity_from']))
- {
- foreach($entity['start_entity_from'] as
$location)
- {
- $this->db->query("INSERT INTO
fm_entity_lookup (entity_id,location,type)"
- . "VALUES (" .$entity['id'] .
",'$location','start' )",__LINE__,__FILE__);
- }
- }
-
- $this->db->transaction_commit();
-
- $receipt['message'][] = array('msg'=>
lang('entity has been edited'));
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('entity has NOT been edited'));
- }
-
- return $receipt;
- }
-
- function edit_category($entity)
- {
-
- if (!$entity['name'])
- {
- $receipt['error'][] = array('msg'=>lang('Name
not entered!'));
- }
-
- if (!$receipt['error'])
- {
- $table = 'fm_entity_category';
-
- $entity['name'] =
$this->db->db_addslashes($entity['name']);
- $entity['descr'] =
$this->db->db_addslashes($entity['descr']);
-
- $value_set=array(
- 'descr' =>
$entity['descr'],
- 'name' =>
$entity['name'],
- 'prefix' =>
$entity['prefix'],
- 'lookup_tenant' =>
$entity['lookup_tenant'],
- 'tracking' =>
$entity['tracking'],
- 'location_level'=>
$entity['location_level'],
- 'fileupload' =>
$entity['fileupload'],
- 'loc_link' =>
$entity['loc_link'],
- 'start_project' =>
$entity['start_project']
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE $table set $value_set
WHERE entity_id=" . $entity['entity_id']. " AND id=" .
$entity['id'],__LINE__,__FILE__);
-
- $value_set_acl=array(
- 'descr' =>
$entity['name']
- );
-
- $value_set_acl =
$this->bocommon->validate_db_update($value_set_acl);
-
- $this->db->query("UPDATE fm_acl_location set
$value_set_acl WHERE id='.entity." . $entity['entity_id']. "." . $entity['id'].
"'",__LINE__,__FILE__);
-
-
- $receipt['message'][] = array('msg'=>
lang('entity has been edited'));
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('entity has NOT been edited'));
- }
-
- return $receipt;
- }
-
- function delete_entity($id)
- {
-
$category_list=$this->read_category(array('entity_id'=>$id));
- $this->db->query("DELETE FROM fm_entity WHERE
id=$id",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_entity_category WHERE
entity_id=$id",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_entity_attribute WHERE
entity_id=$id",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_acl_location WHERE id
$this->like '.entity." . $id ."%'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_acl2 WHERE
acl_location $this->like '.entity." . $id ."%'",__LINE__,__FILE__);
- if (isset($category_list) AND is_array($category_list))
- {
- $this->init_process();
-
- foreach($category_list as $entry)
- {
- $this->oProc->DropTable('fm_entity_' .
$id . '_' . $entry['id']);
- }
- }
-
- }
-
- function delete_category($id,$entity_id)
- {
- $this->init_process();
- $this->oProc->DropTable('fm_entity_' . $entity_id . '_'
. $id);
-// $this->oProc->DropTable('fm_entity_' . $entity_id . '_'
. $id . '_' . 'status');
- $this->db->query("DELETE FROM fm_entity_category WHERE
entity_id= $entity_id AND id= $id",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_entity_attribute WHERE
entity_id= $entity_id AND cat_id= $id",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_acl_location WHERE
id='.entity." . $entity_id . "." . $id ."'",__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_acl2 WHERE
acl_location='.entity." . $entity_id . "." . $id ."'",__LINE__,__FILE__);
- }
-
- function delete_attrib($cat_id,$entity_id,$attrib_id)
- {
- $this->init_process();
-
- $sql = "SELECT * FROM fm_entity_attribute WHERE
entity_id=$entity_id AND cat_id=$cat_id AND id=$attrib_id";
-
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $ColumnName = $this->db->f('column_name');
-
- $this->oProc->DropColumn('fm_entity_' .$entity_id.'_'.
$cat_id,'', $ColumnName);
-
- $sql = "SELECT attrib_sort FROM fm_entity_attribute
where entity_id=$entity_id AND cat_id=$cat_id AND id=$attrib_id";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $attrib_sort = $this->db->f('attrib_sort');
- $sql2 = "SELECT max(attrib_sort) as max_sort FROM
fm_entity_attribute where entity_id=$entity_id AND cat_id=$cat_id";
- $this->db->query($sql2,__LINE__,__FILE__);
- $this->db->next_record();
- $max_sort = $this->db->f('max_sort');
- if($max_sort>$attrib_sort)
- {
- $sql = "UPDATE fm_entity_attribute set
attrib_sort=attrib_sort-1 WHERE entity_id=$entity_id AND cat_id=$cat_id AND
attrib_sort > $attrib_sort";
- $this->db->query($sql,__LINE__,__FILE__);
- }
-
- $this->db->query("DELETE FROM fm_entity_attribute WHERE
entity_id=$entity_id AND cat_id=$cat_id AND id=$attrib_id",__LINE__,__FILE__);
- }
-
- function delete_status($cat_id,$entity_id,$status_id)
- {
- $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
-
- $this->db->query("DELETE FROM $table WHERE
id='$status_id'",__LINE__,__FILE__);
- }
-
- function read_attrib($data)
- {
-
-//_debug_array($data);
- if(is_array($data))
- {
- if ($data['start'])
- {
- $start=$data['start'];
- }
- else
- {
- $start=0;
- }
- $query =
(isset($data['query'])?$data['query']:'');
- $sort =
(isset($data['sort'])?$data['sort']:'DESC');
- $order =
(isset($data['order'])?$data['order']:'');
- $allrows =
(isset($data['allrows'])?$data['allrows']:'');
- $entity_id =
(isset($data['entity_id'])?$data['entity_id']:0);
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- }
-
- if ($order)
- {
- $ordermethod = " order by $order $sort";
-
- }
- else
- {
- $ordermethod = ' order by attrib_sort asc';
- }
-
- if($query)
- {
- $query = ereg_replace("'",'',$query);
- $query = ereg_replace('"','',$query);
-
- $querymethod = " AND (fm_entity_attribute.name
$this->like '%$query%' or fm_entity_attribute.descr $this->like '%$query%')";
- }
-
- $sql = "SELECT * FROM fm_entity_attribute WHERE
entity_id=$entity_id AND cat_id = $cat_id $filtermethod $querymethod";
-
- $this->db2->query($sql,__LINE__,__FILE__);
- $this->total_records = $this->db2->num_rows();
- if(!$allrows)
- {
- $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
- }
- else
- {
- $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
- }
-
-
- while ($this->db->next_record())
- {
- $attrib[] = array
- (
- 'id' =>
$this->db->f('id'),
- 'entity_type' =>
$this->db->f('type_id'),
- 'attrib_sort' =>
$this->db->f('attrib_sort'),
- 'list' =>
$this->db->f('list'),
- 'lookup_form' =>
$this->db->f('lookup_form'),
- 'entity_form' =>
$this->db->f('entity_form'),
- 'column_name' =>
$this->db->f('column_name'),
- 'name' =>
$this->db->f('input_text'),
- 'size' =>
$this->db->f('size'),
- 'statustext' =>
$this->db->f('statustext'),
- 'input_text' =>
$this->db->f('input_text'),
- 'type_name' =>
$this->db->f('type'),
- 'datatype' =>
$this->db->f('datatype'),
- 'search' =>
$this->db->f('search')
- );
- }
- return $attrib;
- }
-
- function read_single_attrib($entity_id,$cat_id,$id)
- {
-
- $sql = "SELECT * FROM fm_entity_attribute where
entity_id=$entity_id AND cat_id=$cat_id AND id=$id";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- if ($this->db->next_record())
- {
- $attrib['id']
= $this->db->f('id');
- $attrib['column_name']
= $this->db->f('column_name');
- $attrib['input_text']
= $this->db->f('input_text');
- $attrib['statustext']
= $this->db->f('statustext');
- $attrib['column_info']['precision'] =
$this->db->f('precision_');
- $attrib['column_info']['scale'] =
$this->db->f('scale');
- $attrib['column_info']['default'] =
$this->db->f('default_value');
- $attrib['column_info']['nullable'] =
$this->db->f('nullable');
- $attrib['column_info']['type'] =
$this->db->f('datatype');
- $attrib['type_id']
= $this->db->f('type_id');
- $attrib['type_name']
= $this->db->f('type_name');
- $attrib['lookup_form']
= $this->db->f('lookup_form');
- $attrib['list']
= $this->db->f('list');
- $attrib['search']
= $this->db->f('search');
- if($this->db->f('datatype')=='R' ||
$this->db->f('datatype')=='CH' || $this->db->f('datatype')=='LB')
- {
- $attrib['choice'] =
$this->read_attrib_choice($entity_id,$cat_id,$id);
- }
-
- return $attrib;
- }
- }
-
- function read_attrib_choice($entity_id,$cat_id,$attrib_id)
- {
- $choice_table = 'fm_entity_choice';
- $sql = "SELECT * FROM $choice_table WHERE
entity_id=$entity_id AND cat_id=$cat_id AND attrib_id=$attrib_id";
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $choice[] = array
- (
- 'id' => $this->db->f('id'),
- 'value' => $this->db->f('value')
- );
- }
- return $choice;
- }
-
- function add_attrib($attrib)
- {
-
- $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
- $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
- $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
- $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
- $attrib['id'] =
$this->bocommon->next_id('fm_entity_attribute',array('entity_id'=>$attrib['entity_id'],'cat_id'=>$attrib['cat_id']));
-
- $sql = "SELECT max(attrib_sort) as max_sort FROM
fm_entity_attribute where entity_id=" . $attrib['entity_id'] . " AND cat_id=" .
$attrib['cat_id'];
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $attrib_sort = $this->db->f('max_sort')+1;
-
- $values= array(
- $attrib['entity_id'],
- $attrib['cat_id'],
- $attrib['id'],
- $attrib['column_name'],
- $attrib['input_text'],
- $attrib['statustext'],
- $attrib['search'],
- $attrib['list'],
- $attrib_sort,
- $attrib['column_info']['type'],
- $attrib['column_info']['precision'],
- $attrib['column_info']['scale'],
- $attrib['column_info']['default'],
- $attrib['column_info']['nullable']
- );
-
- $values = $this->bocommon->validate_db_insert($values);
-
- $this->db->transaction_begin();
-
- $this->db->query("INSERT INTO fm_entity_attribute
(entity_id,cat_id,id,column_name, input_text,
statustext,search,list,attrib_sort,
datatype,precision_,scale,default_value,nullable) "
- . "VALUES ($values)",__LINE__,__FILE__);
-
- $receipt['id']= $attrib['id'];
-
- if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
- {
- $attrib['column_info']['precision']=64;
- }
-
- $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
-
- if($attrib['column_info']['type']=='int' &&
!$attrib['column_info']['precision'])
- {
- $attrib['column_info']['precision']=4;
- }
-
- if(!$attrib['column_info']['default'])
- {
- unset($attrib['column_info']['default']);
- }
-
- $this->init_process();
-
-
if($this->oProc->AddColumn('fm_entity_'.$attrib['entity_id'] . '_' .
$attrib['cat_id'],$attrib['column_name'], $attrib['column_info']))
- {
- $receipt['message'][] = array('msg' =>
lang('Attribute has been saved') );
- $this->db->transaction_commit();
-
- }
- else
- {
- $receipt['error'][] = array('msg' =>
lang('column could not be added') );
- if($this->db->Transaction)
- {
- $this->db->transaction_abort();
- }
- else
- {
- $this->db->query("DELETE FROM
fm_entity_attribute WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['id']. " AND id='" . $receipt['id'] . "'",__LINE__,__FILE__);
- unset($receipt['id']);
-
- }
- }
-
- return $receipt;
- }
-
- function init_process()
- {
- $this->oProc
=
CreateObject('phpgwapi.schema_proc',$GLOBALS['phpgw_info']['server']['db_type']);
- $this->oProc->m_odb
= $this->db;
- $this->oProc->m_odb->Halt_On_Error = 'report';
- }
-
- function edit_attrib($attrib)
- {
-
- $choice_table = 'fm_entity_choice';
-
- $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
- $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
- $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
- $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
-
- $this->db->query("SELECT column_name FROM
fm_entity_attribute WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND id='" . $attrib['id']. "'",__LINE__,__FILE__);
- $this->db->next_record();
- $OldColumnName = $this->db->f('column_name');
-
- $this->db->transaction_begin();
-
- $value_set=array(
- 'input_text' =>
$attrib['input_text'],
- 'statustext' =>
$attrib['statustext'],
- 'search' =>
$attrib['search'],
- 'list' =>
$attrib['list'],
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE fm_entity_attribute
set $value_set WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND id=" . $attrib['id'],__LINE__,__FILE__);
-
-// if($OldColumnName !=$attrib['column_name'])
- {
-
- if($attrib['column_info']['type']!='R' &&
$attrib['column_info']['type']!='CH' && $attrib['column_info']['type']!='LB')
- {
- $this->db->query("DELETE FROM
$choice_table WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND attrib_id=" . $attrib['id'],__LINE__,__FILE__);
- }
-
- if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
- {
- $attrib['column_info']['precision']=64;
- }
-
- if($precision =
$this->bocommon->translate_datatype_precision($attrib['column_info']['type']))
- {
-
$attrib['column_info']['precision']=$precision;
- }
-
- if(!$attrib['column_info']['default'])
- {
-
unset($attrib['column_info']['default']);
- }
-
- $value_set=array(
- 'column_name' =>
$attrib['column_name'],
- 'datatype' =>
$attrib['column_info']['type'],
- 'precision_' =>
$attrib['column_info']['precision'],
- 'scale' =>
$attrib['column_info']['scale'],
- 'default_value' =>
$attrib['column_info']['default'],
- 'nullable' =>
$attrib['column_info']['nullable']
- );
-
- $value_set =
$this->bocommon->validate_db_update($value_set);
-
- $this->db->query("UPDATE fm_entity_attribute
set $value_set WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND id=" . $attrib['id'],__LINE__,__FILE__);
-
- $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
-
- $this->init_process();
-
- $mini_table_def = array(
- 'fm_entity_'.$attrib['entity_id'] . '_'
. $attrib['cat_id'] => array(
- 'fd' => array(
- $OldColumnName
=>$attrib['column_info']),
- 'pk' => array(),
- 'fk' => array(),
- 'ix' => array(),
- 'uc' => array()
- )
- );
-
- $this->oProc->GenerateScripts($mini_table_def);
-
$this->oProc->RenameColumn('fm_entity_'.$attrib['entity_id'] . '_' .
$attrib['cat_id'], $OldColumnName, $attrib['column_name']);
-
$this->oProc->AlterColumn('fm_entity_'.$attrib['entity_id'] . '_' .
$attrib['cat_id'],$attrib['column_name'],$attrib['column_info']);
- }
-
- $choice_table ='fm_entity_choice';
-
- if($attrib['new_choice'])
- {
- $choice_id =
$this->bocommon->next_id($choice_table
,array('entity_id'=>$attrib['entity_id'],'cat_id'=>$attrib['cat_id'],'attrib_id'=>$attrib['id']));
-
- $values= array(
- $attrib['entity_id'],
- $attrib['cat_id'],
- $attrib['id'],
- $choice_id,
- $attrib['new_choice']
- );
-
- $values =
$this->bocommon->validate_db_insert($values);
-
- $this->db->query("INSERT INTO $choice_table
(entity_id,cat_id,attrib_id,id,value) "
- . "VALUES ($values)",__LINE__,__FILE__);
- }
-
- if($attrib['delete_choice'])
- {
- for
($i=0;$i<count($attrib['delete_choice']);$i++)
- {
- $this->db->query("DELETE FROM
$choice_table WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND attrib_id=" . $attrib['id'] ." AND id=" .
$attrib['delete_choice'][$i],__LINE__,__FILE__);
- }
- }
-
- $this->db->transaction_commit();
-
- $receipt['message'][] = array('msg' =>
lang('Attribute has been edited'));
-
- return $receipt;
- }
- function resort_attrib($data)
- {
- if(is_array($data))
- {
- $resort =
(isset($data['resort'])?$data['resort']:'up');
- $entity_id =
(isset($data['entity_id'])?$data['entity_id']:0);
- $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
- $id = (isset($data['id'])?$data['id']:'');
- }
-
- $sql = "SELECT attrib_sort FROM fm_entity_attribute
where entity_id=$entity_id AND cat_id=$cat_id AND id=$id";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $attrib_sort = $this->db->f('attrib_sort');
- $sql2 = "SELECT max(attrib_sort) as max_sort FROM
fm_entity_attribute where entity_id=$entity_id AND cat_id=$cat_id";
- $this->db->query($sql2,__LINE__,__FILE__);
- $this->db->next_record();
- $max_sort = $this->db->f('max_sort');
-
- switch($resort)
- {
- case 'up':
- if($attrib_sort>1)
- {
- $sql = "UPDATE
fm_entity_attribute set attrib_sort=$attrib_sort WHERE entity_id=$entity_id AND
cat_id=$cat_id AND attrib_sort =" . ($attrib_sort-1);
-
$this->db->query($sql,__LINE__,__FILE__);
- $sql = "UPDATE
fm_entity_attribute set attrib_sort=" . ($attrib_sort-1) ." WHERE
entity_id=$entity_id AND cat_id=$cat_id AND id=$id";
-
$this->db->query($sql,__LINE__,__FILE__);
- }
- break;
- case 'down':
- if($max_sort > $attrib_sort)
- {
- $sql = "UPDATE
fm_entity_attribute set attrib_sort=$attrib_sort WHERE entity_id=$entity_id AND
cat_id=$cat_id AND attrib_sort =" . ($attrib_sort+1);
-
$this->db->query($sql,__LINE__,__FILE__);
- $sql = "UPDATE
fm_entity_attribute set attrib_sort=" . ($attrib_sort+1) ." WHERE
entity_id=$entity_id AND cat_id=$cat_id AND id=$id";
-
$this->db->query($sql,__LINE__,__FILE__);
- }
- break;
- default:
- return;
- break;
- }
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id$
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class soadmin_entity
+ {
+ var $grants;
+
+ function soadmin_entity($entity_id='',$cat_id='')
+ {
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->db = $GLOBALS['phpgw']->db;
+ $this->db2 = $this->db;
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+
+ $this->join = $this->bocommon->join;
+ $this->like = $this->bocommon->like;
+
+ if($entity_id && $cat_id)
+ {
+ $this->category_name =
$this->read_category_name($entity_id,$cat_id);
+ }
+ }
+
+ function reset_fm_cache()
+ {
+ $this->db->query("DELETE FROM fm_cache
",__LINE__,__FILE__);
+ }
+
+ function read($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by id asc';
+ }
+
+ $table = 'fm_entity';
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " where name $this->like
'%$query%' or descr $this->like '%$query%'";
+ }
+
+ $sql = "SELECT * FROM $table $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $entity[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'name' => $this->db->f('name'),
+ 'descr' => $this->db->f('descr'),
+ 'documentation' =>
$this->db->f('documentation')
+ );
+ }
+ return $entity;
+ }
+
+ function read_category($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $entity_id =
(isset($data['entity_id'])?$data['entity_id']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by id asc';
+ }
+
+ $table = 'fm_entity_category';
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " AND name $this->like
'%$query%' or descr $this->like '%$query%'";
+ }
+
+ $sql = "SELECT * FROM $table WHERE entity_id=$entity_id
$querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $standard[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'name' => $this->db->f('name'),
+ 'prefix'=> $this->db->f('prefix'),
+ 'descr' => $this->db->f('descr')
+ );
+ }
+ return $standard;
+ }
+
+ function read_status($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $entity_id =
(isset($data['entity_id'])?$data['entity_id']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by id asc';
+ }
+
+ $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " AND name $this->like
'%$query%' or descr $this->like '%$query%'";
+ }
+
+ $sql = "SELECT * FROM $table $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $status[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'descr' => $this->db->f('descr')
+ );
+ }
+ return $status;
+ }
+
+
+ function read_single($id)
+ {
+
+ $sql = "SELECT * FROM fm_entity where id='$id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $entity['id'] =
$this->db->f('id');
+ $entity['name'] =
$this->db->f('name');
+ $entity['descr'] =
$this->db->f('descr');
+ $entity['location_form'] =
$this->db->f('location_form');
+ $entity['lookup_entity'] =
unserialize($this->db->f('lookup_entity'));
+ $entity['documentation'] =
$this->db->f('documentation');
+ }
+
+ $sql = "SELECT location FROM fm_entity_lookup where
entity_id=$id AND type='lookup'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $entity['include_entity_for'][] =
$this->db->f('location');
+ }
+
+ $sql = "SELECT location FROM fm_entity_lookup where
entity_id=$id AND type='start'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $entity['start_entity_from'][] =
$this->db->f('location');
+ }
+
+ return $entity;
+ }
+
+ function read_single_category($entity_id,$cat_id)
+ {
+ $sql = "SELECT * FROM fm_entity_category where
entity_id=$entity_id AND id=$cat_id";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $category['id'] =
$this->db->f('id');
+ $category['name'] =
$this->db->f('name');
+ $category['descr'] =
$this->db->f('descr');
+ $category['prefix'] =
$this->db->f('prefix');
+ $category['lookup_tenant'] =
$this->db->f('lookup_tenant');
+ $category['tracking'] =
$this->db->f('tracking');
+ $category['location_level'] =
$this->db->f('location_level');
+ $category['fileupload'] =
$this->db->f('fileupload');
+ $category['loc_link'] =
$this->db->f('loc_link');
+ $category['start_project'] =
$this->db->f('start_project');
+ return $category;
+ }
+ }
+
+ function read_category_name($entity_id,$cat_id)
+ {
+ $sql = "SELECT * FROM fm_entity_category where
entity_id=$entity_id AND id=$cat_id";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ return $this->db->f('name');
+ }
+
+ function read_single_status($entity_id,$cat_id,$id)
+ {
+
+ $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
+ $sql = "SELECT * FROM $table where id='$id'";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $status['id'] =
$this->db->f('id');
+ $status['descr'] =
$this->db->f('descr');
+
+ return $status;
+ }
+ }
+
+ function add_entity($entity)
+ {
+ $entity['name'] =
$this->db->db_addslashes($entity['name']);
+ $entity['descr'] =
$this->db->db_addslashes($entity['descr']);
+
+ $entity['id'] = $this->bocommon->next_id('fm_entity');
+
+ $values= array(
+ $entity['id'],
+ $entity['name'],
+ $entity['descr'],
+ $entity['location_form'],
+ $entity['documentation']
+ );
+
+ $values = $this->bocommon->validate_db_insert($values);
+
+ $this->db->query("INSERT INTO fm_entity (id,name,
descr,location_form,documentation) "
+ . "VALUES ($values)",__LINE__,__FILE__);
+
+
+ $values_acl_location= array(
+ '.entity.' . $entity['id'],
+ $entity['name'],
+ 1
+ );
+
+ $values_acl_location =
$this->bocommon->validate_db_insert($values_acl_location);
+
+ $this->db->query("INSERT INTO fm_acl_location
(id,descr,allow_grant) "
+ . "VALUES
($values_acl_location)",__LINE__,__FILE__);
+
+ $receipt['id']= $entity['id'];
+
+ $receipt['message'][] = array('msg'=> lang('entity has
been added'));
+ return $receipt;
+ }
+
+
+ function add_status($values,$entity_id,$cat_id)
+ {
+ $values['id'] = $this->db->db_addslashes($values['id']);
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+
+ $values_insert= array(
+ $values['id'],
+ $values['descr'],
+ );
+
+ $values_insert =
$this->bocommon->validate_db_insert($values_insert);
+
+ $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
+
+ $this->db->query("INSERT INTO $table (id,descr) VALUES
($values_insert)",__LINE__,__FILE__);
+
+ $receipt['id']= $values['id'];
+
+ $receipt['message'][] = array('msg'=> lang('status has
been added'));
+ return $receipt;
+ }
+
+
+ function add_category($values)
+ {
+ $values['name'] =
$this->db->db_addslashes($values['name']);
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+
+ $values['id'] =
$this->bocommon->next_id('fm_entity_category',array('entity_id'=>$values['entity_id']));
+
+ $location_type =
$this->bocommon->next_id('fm_location_type');
+
+ $values_insert= array(
+ $values['entity_id'],
+ $values['id'],
+ $values['name'],
+ $values['descr'],
+ $values['prefix'],
+ $values['lookup_tenant'],
+ $values['tracking'],
+ $values['location_level'],
+ $values['fileupload'],
+ $values['loc_link'],
+ $values['start_project']
+ );
+
+ $values_insert =
$this->bocommon->validate_db_insert($values_insert);
+
+
+ $this->db->transaction_begin();
+
+ $this->db->query("INSERT INTO fm_entity_category
(entity_id,id,name,
descr,prefix,lookup_tenant,tracking,location_level,fileupload,loc_link,start_project)
"
+ . "VALUES ($values_insert)",__LINE__,__FILE__);
+
+ $values_acl_location= array(
+ '.entity.' . $values['entity_id'] . '.' .
$values['id'],
+ $values['name'],
+ 1
+ );
+
+ $values_acl_location =
$this->bocommon->validate_db_insert($values_acl_location);
+
+ $this->db->query("INSERT INTO fm_acl_location
(id,descr,allow_grant) "
+ . "VALUES
($values_acl_location)",__LINE__,__FILE__);
+
+ $receipt['id']= $values['id'];
+
+ $this->init_process();
+
+ $fd=array();
+ $fd['id'] = array('type' => 'int', 'precision' => 4,
'nullable' => False);
+ $fd['num'] = array('type' => 'varchar', 'precision' =>
16, 'nullable' => False);
+ $fd['p_num'] = array('type' => 'varchar', 'precision'
=> 16, 'nullable' => True);
+ $fd['p_entity_id'] = array('type' => 'int', 'precision'
=> 4, 'nullable' => True);
+ $fd['p_cat_id'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
+ $fd['location_code'] = array('type' => 'varchar',
'precision' => 25, 'nullable' => True);
+
+ for ($i=1; $i<$location_type; $i++)
+ {
+ $fd['loc' . $i] = array('type' => 'varchar',
'precision' => 4, 'nullable' => True);
+ }
+
+ $fd['address'] = array('type' => 'varchar', 'precision'
=> 150, 'nullable' => True);
+ $fd['tenant_id'] = array('type' => 'int', 'precision'
=> 4, 'nullable' => True);
+ $fd['contact_phone'] = array('type' => 'varchar',
'precision' => 30, 'nullable' => True);
+ $fd['status'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
+ $fd['entry_date'] = array('type' => 'int', 'precision'
=> 4, 'nullable' => True);
+ $fd['user_id'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
+
+ $pk[]= 'id';
+ $table = 'fm_entity_'.
$values['entity_id'] .'_'.$values['id'];
+/*
+ $fd_status['id'] = array('type' => 'varchar',
'precision' => 20, 'nullable' => False);
+ $fd_status['descr'] = array('type' => 'varchar',
'precision' => 255, 'nullable' => False);
+ $pk_status[]= 'id';
+
+ $statustable = $table . '_' .'status';
+*/
+ if(($this->oProc->CreateTable($table,array('fd' =>
$fd,'pk' => $pk,'fk' => $fk,'ix' => array('location_code'),'uc' => array()))))
+// &&
($this->oProc->CreateTable($statustable,array('fd' => $fd_status,'pk' =>
$pk_status,'fk' => $fk_status,'ix' => False,'uc' => array()))))
+ {
+
+ $values_insert= array(
+ $values['entity_id'],
+ $values['id'],
+ 1,
+ 'status',
+ 'Status',
+ 'Status',
+ 'LB',
+ 1,
+ 'True'
+ );
+
+ $values_insert =
$this->bocommon->validate_db_insert($values_insert);
+
+ $this->db->query("INSERT INTO
fm_entity_attribute
(entity_id,cat_id,id,column_name,input_text,statustext,datatype,attrib_sort,nullable)
"
+ . "VALUES
($values_insert)",__LINE__,__FILE__);
+
+ $receipt['message'][] = array('msg' =>
lang('table %1 has been saved',$table));
+ $this->db->transaction_commit();
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('table could not be added') );
+ if($this->db->Transaction)
+ {
+ $this->db->transaction_abort();
+ }
+ else
+ {
+ $this->db->query("DELETE FROM
fm_entity_category WHERE id=" . $values['id'] . " AND entity_id=" .
$values['entity_id'],__LINE__,__FILE__);
+ unset($receipt['id']);
+
+ }
+ }
+
+ return $receipt;
+ }
+
+ function edit_status($values,$entity_id,$cat_id)
+ {
+ $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
+
+ $values['descr'] =
$this->db->db_addslashes($values['descr']);
+
+ $value_set=array(
+ 'descr' => $values['descr'],
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE $table set $value_set WHERE
id='" . $values['id'] . "'",__LINE__,__FILE__);
+
+ $receipt['message'][] = array('msg'=> lang('Status has
been edited'));
+
+ return $receipt;
+ }
+
+ function edit_entity($entity)
+ {
+ if (!$entity['name'])
+ {
+ $receipt['error'][] = array('msg'=>lang('Name
not entered!'));
+ }
+
+ if (!$receipt['error'])
+ {
+ $table = 'fm_entity';
+
+ $entity['name'] =
$this->db->db_addslashes($entity['name']);
+ $entity['descr'] =
$this->db->db_addslashes($entity['descr']);
+
+ if(!$entity['location_form'])
+ {
+ unset($entity['lookup_entity']);
+ }
+
+ $value_set=array(
+ 'descr' => $entity['descr'],
+ 'name' => $entity['name'],
+ 'location_form' => $entity['location_form'],
+ 'lookup_entity' =>
serialize($entity['lookup_entity']),
+ 'documentation' => $entity['documentation']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->transaction_begin();
+
+ $this->db->query("UPDATE $table set $value_set
WHERE id=" . $entity['id'],__LINE__,__FILE__);
+
+ $value_set_acl=array(
+ 'descr' =>
$entity['name']
+ );
+
+ $value_set_acl =
$this->bocommon->validate_db_update($value_set_acl);
+
+ $this->db->query("UPDATE fm_acl_location set
$value_set_acl WHERE id='.entity." . $entity['id']. "'",__LINE__,__FILE__);
+
+ $this->db->query("DELETE FROM fm_entity_lookup
WHERE type='lookup' AND entity_id=" . $entity['id'],__LINE__,__FILE__);
+ if (isset($entity['include_entity_for']) AND
is_array($entity['include_entity_for']))
+ {
+ foreach($entity['include_entity_for']
as $location)
+ {
+ $this->db->query("INSERT INTO
fm_entity_lookup (entity_id,location,type)"
+ . "VALUES (" .$entity['id'] .
",'$location','lookup' )",__LINE__,__FILE__);
+ }
+ }
+
+ $this->db->query("DELETE FROM fm_entity_lookup
WHERE type='start' AND entity_id=" . $entity['id'],__LINE__,__FILE__);
+
+ if (isset($entity['start_entity_from']) AND
is_array($entity['start_entity_from']))
+ {
+ foreach($entity['start_entity_from'] as
$location)
+ {
+ $this->db->query("INSERT INTO
fm_entity_lookup (entity_id,location,type)"
+ . "VALUES (" .$entity['id'] .
",'$location','start' )",__LINE__,__FILE__);
+ }
+ }
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg'=>
lang('entity has been edited'));
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('entity has NOT been edited'));
+ }
+
+ return $receipt;
+ }
+
+ function edit_category($entity)
+ {
+
+ if (!$entity['name'])
+ {
+ $receipt['error'][] = array('msg'=>lang('Name
not entered!'));
+ }
+
+ if (!$receipt['error'])
+ {
+ $table = 'fm_entity_category';
+
+ $entity['name'] =
$this->db->db_addslashes($entity['name']);
+ $entity['descr'] =
$this->db->db_addslashes($entity['descr']);
+
+ $value_set=array(
+ 'descr' =>
$entity['descr'],
+ 'name' =>
$entity['name'],
+ 'prefix' =>
$entity['prefix'],
+ 'lookup_tenant' =>
$entity['lookup_tenant'],
+ 'tracking' =>
$entity['tracking'],
+ 'location_level'=>
$entity['location_level'],
+ 'fileupload' =>
$entity['fileupload'],
+ 'loc_link' =>
$entity['loc_link'],
+ 'start_project' =>
$entity['start_project']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE $table set $value_set
WHERE entity_id=" . $entity['entity_id']. " AND id=" .
$entity['id'],__LINE__,__FILE__);
+
+ $value_set_acl=array(
+ 'descr' =>
$entity['name']
+ );
+
+ $value_set_acl =
$this->bocommon->validate_db_update($value_set_acl);
+
+ $this->db->query("UPDATE fm_acl_location set
$value_set_acl WHERE id='.entity." . $entity['entity_id']. "." . $entity['id'].
"'",__LINE__,__FILE__);
+
+
+ $receipt['message'][] = array('msg'=>
lang('entity has been edited'));
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('entity has NOT been edited'));
+ }
+
+ return $receipt;
+ }
+
+ function delete_entity($id)
+ {
+
$category_list=$this->read_category(array('entity_id'=>$id));
+ $this->db->query("DELETE FROM fm_entity WHERE
id=$id",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_entity_category WHERE
entity_id=$id",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_entity_attribute WHERE
entity_id=$id",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_acl_location WHERE id
$this->like '.entity." . $id ."%'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_acl2 WHERE
acl_location $this->like '.entity." . $id ."%'",__LINE__,__FILE__);
+ if (isset($category_list) AND is_array($category_list))
+ {
+ $this->init_process();
+
+ foreach($category_list as $entry)
+ {
+ $this->oProc->DropTable('fm_entity_' .
$id . '_' . $entry['id']);
+ }
+ }
+
+ }
+
+ function delete_category($id,$entity_id)
+ {
+ $this->init_process();
+ $this->oProc->DropTable('fm_entity_' . $entity_id . '_'
. $id);
+// $this->oProc->DropTable('fm_entity_' . $entity_id . '_'
. $id . '_' . 'status');
+ $this->db->query("DELETE FROM fm_entity_category WHERE
entity_id= $entity_id AND id= $id",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_entity_attribute WHERE
entity_id= $entity_id AND cat_id= $id",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_acl_location WHERE
id='.entity." . $entity_id . "." . $id ."'",__LINE__,__FILE__);
+ $this->db->query("DELETE FROM fm_acl2 WHERE
acl_location='.entity." . $entity_id . "." . $id ."'",__LINE__,__FILE__);
+ }
+
+ function delete_attrib($cat_id,$entity_id,$attrib_id)
+ {
+ $this->init_process();
+
+ $sql = "SELECT * FROM fm_entity_attribute WHERE
entity_id=$entity_id AND cat_id=$cat_id AND id=$attrib_id";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $ColumnName = $this->db->f('column_name');
+
+ $this->oProc->DropColumn('fm_entity_' .$entity_id.'_'.
$cat_id,'', $ColumnName);
+
+ $sql = "SELECT attrib_sort FROM fm_entity_attribute
where entity_id=$entity_id AND cat_id=$cat_id AND id=$attrib_id";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('attrib_sort');
+ $sql2 = "SELECT max(attrib_sort) as max_sort FROM
fm_entity_attribute where entity_id=$entity_id AND cat_id=$cat_id";
+ $this->db->query($sql2,__LINE__,__FILE__);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+ if($max_sort>$attrib_sort)
+ {
+ $sql = "UPDATE fm_entity_attribute set
attrib_sort=attrib_sort-1 WHERE entity_id=$entity_id AND cat_id=$cat_id AND
attrib_sort > $attrib_sort";
+ $this->db->query($sql,__LINE__,__FILE__);
+ }
+
+ $this->db->query("DELETE FROM fm_entity_attribute WHERE
entity_id=$entity_id AND cat_id=$cat_id AND id=$attrib_id",__LINE__,__FILE__);
+ }
+
+ function delete_status($cat_id,$entity_id,$status_id)
+ {
+ $table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
+
+ $this->db->query("DELETE FROM $table WHERE
id='$status_id'",__LINE__,__FILE__);
+ }
+
+ function read_attrib($data)
+ {
+
+//_debug_array($data);
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $entity_id =
(isset($data['entity_id'])?$data['entity_id']:0);
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by attrib_sort asc';
+ }
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " AND (fm_entity_attribute.name
$this->like '%$query%' or fm_entity_attribute.descr $this->like '%$query%')";
+ }
+
+ $sql = "SELECT * FROM fm_entity_attribute WHERE
entity_id=$entity_id AND cat_id = $cat_id $filtermethod $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+
+ while ($this->db->next_record())
+ {
+ $attrib[] = array
+ (
+ 'id' =>
$this->db->f('id'),
+ 'entity_type' =>
$this->db->f('type_id'),
+ 'attrib_sort' =>
$this->db->f('attrib_sort'),
+ 'list' =>
$this->db->f('list'),
+ 'lookup_form' =>
$this->db->f('lookup_form'),
+ 'entity_form' =>
$this->db->f('entity_form'),
+ 'column_name' =>
$this->db->f('column_name'),
+ 'name' =>
$this->db->f('input_text'),
+ 'size' =>
$this->db->f('size'),
+ 'statustext' =>
$this->db->f('statustext'),
+ 'input_text' =>
$this->db->f('input_text'),
+ 'type_name' =>
$this->db->f('type'),
+ 'datatype' =>
$this->db->f('datatype'),
+ 'search' =>
$this->db->f('search')
+ );
+ }
+ return $attrib;
+ }
+
+ function read_single_attrib($entity_id,$cat_id,$id)
+ {
+
+ $sql = "SELECT * FROM fm_entity_attribute where
entity_id=$entity_id AND cat_id=$cat_id AND id=$id";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $attrib['id']
= $this->db->f('id');
+ $attrib['column_name']
= $this->db->f('column_name');
+ $attrib['input_text']
= $this->db->f('input_text');
+ $attrib['statustext']
= $this->db->f('statustext');
+ $attrib['column_info']['precision'] =
$this->db->f('precision_');
+ $attrib['column_info']['scale'] =
$this->db->f('scale');
+ $attrib['column_info']['default'] =
$this->db->f('default_value');
+ $attrib['column_info']['nullable'] =
$this->db->f('nullable');
+ $attrib['column_info']['type'] =
$this->db->f('datatype');
+ $attrib['type_id']
= $this->db->f('type_id');
+ $attrib['type_name']
= $this->db->f('type_name');
+ $attrib['lookup_form']
= $this->db->f('lookup_form');
+ $attrib['list']
= $this->db->f('list');
+ $attrib['search']
= $this->db->f('search');
+ if($this->db->f('datatype')=='R' ||
$this->db->f('datatype')=='CH' || $this->db->f('datatype')=='LB')
+ {
+ $attrib['choice'] =
$this->read_attrib_choice($entity_id,$cat_id,$id);
+ }
+
+ return $attrib;
+ }
+ }
+
+ function read_attrib_choice($entity_id,$cat_id,$attrib_id)
+ {
+ $choice_table = 'fm_entity_choice';
+ $sql = "SELECT * FROM $choice_table WHERE
entity_id=$entity_id AND cat_id=$cat_id AND attrib_id=$attrib_id";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $choice[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'value' => $this->db->f('value')
+ );
+ }
+ return $choice;
+ }
+
+ function add_attrib($attrib)
+ {
+
+ $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
+ $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
+ $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
+ $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
+ $attrib['id'] =
$this->bocommon->next_id('fm_entity_attribute',array('entity_id'=>$attrib['entity_id'],'cat_id'=>$attrib['cat_id']));
+
+ $sql = "SELECT max(attrib_sort) as max_sort FROM
fm_entity_attribute where entity_id=" . $attrib['entity_id'] . " AND cat_id=" .
$attrib['cat_id'];
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('max_sort')+1;
+
+ $values= array(
+ $attrib['entity_id'],
+ $attrib['cat_id'],
+ $attrib['id'],
+ $attrib['column_name'],
+ $attrib['input_text'],
+ $attrib['statustext'],
+ $attrib['search'],
+ $attrib['list'],
+ $attrib_sort,
+ $attrib['column_info']['type'],
+ $attrib['column_info']['precision'],
+ $attrib['column_info']['scale'],
+ $attrib['column_info']['default'],
+ $attrib['column_info']['nullable']
+ );
+
+ $values = $this->bocommon->validate_db_insert($values);
+
+ $this->db->transaction_begin();
+
+ $this->db->query("INSERT INTO fm_entity_attribute
(entity_id,cat_id,id,column_name, input_text,
statustext,search,list,attrib_sort,
datatype,precision_,scale,default_value,nullable) "
+ . "VALUES ($values)",__LINE__,__FILE__);
+
+ $receipt['id']= $attrib['id'];
+
+ if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
+ {
+ $attrib['column_info']['precision']=64;
+ }
+
+ $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
+
+ if($attrib['column_info']['type']=='int' &&
!$attrib['column_info']['precision'])
+ {
+ $attrib['column_info']['precision']=4;
+ }
+
+ if(!$attrib['column_info']['default'])
+ {
+ unset($attrib['column_info']['default']);
+ }
+
+ $this->init_process();
+
+
if($this->oProc->AddColumn('fm_entity_'.$attrib['entity_id'] . '_' .
$attrib['cat_id'],$attrib['column_name'], $attrib['column_info']))
+ {
+ $receipt['message'][] = array('msg' =>
lang('Attribute has been saved') );
+ $this->db->transaction_commit();
+
+ }
+ else
+ {
+ $receipt['error'][] = array('msg' =>
lang('column could not be added') );
+ if($this->db->Transaction)
+ {
+ $this->db->transaction_abort();
+ }
+ else
+ {
+ $this->db->query("DELETE FROM
fm_entity_attribute WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['id']. " AND id='" . $receipt['id'] . "'",__LINE__,__FILE__);
+ unset($receipt['id']);
+
+ }
+ }
+
+ return $receipt;
+ }
+
+ function init_process()
+ {
+ $this->oProc
=
CreateObject('phpgwapi.schema_proc',$GLOBALS['phpgw_info']['server']['db_type']);
+ $this->oProc->m_odb
= $this->db;
+ $this->oProc->m_odb->Halt_On_Error = 'report';
+ }
+
+ function edit_attrib($attrib)
+ {
+
+ $choice_table = 'fm_entity_choice';
+
+ $attrib['column_name'] =
$this->db->db_addslashes($attrib['column_name']);
+ $attrib['input_text'] =
$this->db->db_addslashes($attrib['input_text']);
+ $attrib['statustext'] =
$this->db->db_addslashes($attrib['statustext']);
+ $attrib['default'] =
$this->db->db_addslashes($attrib['default']);
+
+ $this->db->query("SELECT column_name FROM
fm_entity_attribute WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND id='" . $attrib['id']. "'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $OldColumnName = $this->db->f('column_name');
+
+ $this->db->transaction_begin();
+
+ $value_set=array(
+ 'input_text' =>
$attrib['input_text'],
+ 'statustext' =>
$attrib['statustext'],
+ 'search' =>
$attrib['search'],
+ 'list' =>
$attrib['list'],
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE fm_entity_attribute
set $value_set WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND id=" . $attrib['id'],__LINE__,__FILE__);
+
+// if($OldColumnName !=$attrib['column_name'])
+ {
+
+ if($attrib['column_info']['type']!='R' &&
$attrib['column_info']['type']!='CH' && $attrib['column_info']['type']!='LB')
+ {
+ $this->db->query("DELETE FROM
$choice_table WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND attrib_id=" . $attrib['id'],__LINE__,__FILE__);
+ }
+
+ if($attrib['column_info']['type']=='email' &&
!$attrib['column_info']['precision'])
+ {
+ $attrib['column_info']['precision']=64;
+ }
+
+ if($precision =
$this->bocommon->translate_datatype_precision($attrib['column_info']['type']))
+ {
+
$attrib['column_info']['precision']=$precision;
+ }
+
+ if(!$attrib['column_info']['default'])
+ {
+
unset($attrib['column_info']['default']);
+ }
+
+ $value_set=array(
+ 'column_name' =>
$attrib['column_name'],
+ 'datatype' =>
$attrib['column_info']['type'],
+ 'precision_' =>
$attrib['column_info']['precision'],
+ 'scale' =>
$attrib['column_info']['scale'],
+ 'default_value' =>
$attrib['column_info']['default'],
+ 'nullable' =>
$attrib['column_info']['nullable']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE fm_entity_attribute
set $value_set WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND id=" . $attrib['id'],__LINE__,__FILE__);
+
+ $attrib['column_info']['type'] =
$this->bocommon->translate_datatype_insert($attrib['column_info']['type']);
+
+ $this->init_process();
+
+ $mini_table_def = array(
+ 'fm_entity_'.$attrib['entity_id'] . '_'
. $attrib['cat_id'] => array(
+ 'fd' => array(
+ $OldColumnName
=>$attrib['column_info']),
+ 'pk' => array(),
+ 'fk' => array(),
+ 'ix' => array(),
+ 'uc' => array()
+ )
+ );
+
+ $this->oProc->GenerateScripts($mini_table_def);
+
$this->oProc->RenameColumn('fm_entity_'.$attrib['entity_id'] . '_' .
$attrib['cat_id'], $OldColumnName, $attrib['column_name']);
+
$this->oProc->AlterColumn('fm_entity_'.$attrib['entity_id'] . '_' .
$attrib['cat_id'],$attrib['column_name'],$attrib['column_info']);
+ }
+
+ $choice_table ='fm_entity_choice';
+
+ if($attrib['new_choice'])
+ {
+ $choice_id =
$this->bocommon->next_id($choice_table
,array('entity_id'=>$attrib['entity_id'],'cat_id'=>$attrib['cat_id'],'attrib_id'=>$attrib['id']));
+
+ $values= array(
+ $attrib['entity_id'],
+ $attrib['cat_id'],
+ $attrib['id'],
+ $choice_id,
+ $attrib['new_choice']
+ );
+
+ $values =
$this->bocommon->validate_db_insert($values);
+
+ $this->db->query("INSERT INTO $choice_table
(entity_id,cat_id,attrib_id,id,value) "
+ . "VALUES ($values)",__LINE__,__FILE__);
+ }
+
+ if($attrib['delete_choice'])
+ {
+ for
($i=0;$i<count($attrib['delete_choice']);$i++)
+ {
+ $this->db->query("DELETE FROM
$choice_table WHERE entity_id=" . $attrib['entity_id']. " AND cat_id=" .
$attrib['cat_id']. " AND attrib_id=" . $attrib['id'] ." AND id=" .
$attrib['delete_choice'][$i],__LINE__,__FILE__);
+ }
+ }
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg' =>
lang('Attribute has been edited'));
+
+ return $receipt;
+ }
+
+ function resort_attrib($data)
+ {
+ if(is_array($data))
+ {
+ $resort =
(isset($data['resort'])?$data['resort']:'up');
+ $entity_id =
(isset($data['entity_id'])?$data['entity_id']:0);
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
+ $id = (isset($data['id'])?$data['id']:'');
+ }
+
+ $sql = "SELECT attrib_sort FROM fm_entity_attribute
where entity_id=$entity_id AND cat_id=$cat_id AND id=$id";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $attrib_sort = $this->db->f('attrib_sort');
+ $sql2 = "SELECT max(attrib_sort) as max_sort FROM
fm_entity_attribute where entity_id=$entity_id AND cat_id=$cat_id";
+ $this->db->query($sql2,__LINE__,__FILE__);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+
+ switch($resort)
+ {
+ case 'up':
+ if($attrib_sort>1)
+ {
+ $sql = "UPDATE
fm_entity_attribute set attrib_sort=$attrib_sort WHERE entity_id=$entity_id AND
cat_id=$cat_id AND attrib_sort =" . ($attrib_sort-1);
+
$this->db->query($sql,__LINE__,__FILE__);
+ $sql = "UPDATE
fm_entity_attribute set attrib_sort=" . ($attrib_sort-1) ." WHERE
entity_id=$entity_id AND cat_id=$cat_id AND id=$id";
+
$this->db->query($sql,__LINE__,__FILE__);
+ }
+ break;
+ case 'down':
+ if($max_sort > $attrib_sort)
+ {
+ $sql = "UPDATE
fm_entity_attribute set attrib_sort=$attrib_sort WHERE entity_id=$entity_id AND
cat_id=$cat_id AND attrib_sort =" . ($attrib_sort+1);
+
$this->db->query($sql,__LINE__,__FILE__);
+ $sql = "UPDATE
fm_entity_attribute set attrib_sort=" . ($attrib_sort+1) ." WHERE
entity_id=$entity_id AND cat_id=$cat_id AND id=$id";
+
$this->db->query($sql,__LINE__,__FILE__);
+ }
+ break;
+ default:
+ return;
+ break;
+ }
+ }
+
+ function read_custom_function($data)
+ {
+ if(is_array($data))
+ {
+ if ($data['start'])
+ {
+ $start=$data['start'];
+ }
+ else
+ {
+ $start=0;
+ }
+ $query =
(isset($data['query'])?$data['query']:'');
+ $sort =
(isset($data['sort'])?$data['sort']:'DESC');
+ $order =
(isset($data['order'])?$data['order']:'');
+ $allrows =
(isset($data['allrows'])?$data['allrows']:'');
+ $acl_location =
(isset($data['acl_location'])?$data['acl_location']:'');
+ }
+
+ if(!$acl_location)
+ {
+ return;
+ }
+
+ if ($order)
+ {
+ $ordermethod = " order by $order $sort";
+
+ }
+ else
+ {
+ $ordermethod = ' order by custom_sort asc';
+ }
+
+ $table = 'fm_custom_function';
+
+ if($query)
+ {
+ $query = ereg_replace("'",'',$query);
+ $query = ereg_replace('"','',$query);
+
+ $querymethod = " AND name $this->like
'%$query%' or descr $this->like '%$query%'";
+ }
+
+ $sql = "SELECT * FROM $table WHERE
acl_location='$acl_location' $querymethod";
+
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $this->total_records = $this->db2->num_rows();
+
+ if(!$allrows)
+ {
+ $this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
+ }
+ else
+ {
+ $this->db->query($sql .
$ordermethod,__LINE__,__FILE__);
+ }
+
+ while ($this->db->next_record())
+ {
+ $custom_function[] = array
+ (
+ 'id' => $this->db->f('id'),
+ 'file_name' =>
$this->db->f('file_name'),
+ 'sorting' =>
$this->db->f('custom_sort'),
+ 'descr' =>
$this->db->f('descr'),
+ 'active' =>
$this->db->f('active')
+ );
+ }
+ return $custom_function;
+ }
+
+
+ function read_single_custom_function($acl_location,$id)
+ {
+
+ $sql = "SELECT * FROM fm_custom_function where
acl_location='$acl_location' AND id=$id";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $custom_function['id'] =
$this->db->f('id');
+ $custom_function['descr'] =
$this->db->f('descr');
+ $custom_function['custom_function_file']=
$this->db->f('file_name');
+ $custom_function['active'] =
$this->db->f('active');
+
+ return $custom_function;
+ }
+
+ }
+
+ function add_custom_function($custom_function)
+ {
+ if(!$custom_function['acl_location'] &&
$custom_function['entity_id'] && $custom_function['cat_id'])
+ {
+ $acl_location = '.entity.' .
$custom_function['entity_id'] . '.' . $custom_function['cat_id'];
+ }
+ else
+ {
+ $acl_location =
$custom_function['acl_location'];
+ }
+
+ if(!$acl_location)
+ {
+ return $receipt['error'][] = array('msg' =>
lang('acl_locastion is missing'));
+ }
+
+ $custom_function['descr'] =
$this->db->db_addslashes($custom_function['descr']);
+
+
+ $this->db->query("SELECT max(id) as maximum FROM
fm_custom_function WHERE acl_location='$acl_location'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $custom_function['id'] = $this->db->f('maximum')+1;
+
+ $sql = "SELECT max(custom_sort) as max_sort FROM
fm_custom_function where acl_location='$acl_location'";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $custom_sort = $this->db->f('max_sort')+1;
+
+ $values= array(
+ $acl_location,
+ $custom_function['id'],
+ $custom_function['custom_function_file'],
+ $custom_function['descr'],
+ $custom_function['active'],
+ $custom_sort
+ );
+
+ $values = $this->bocommon->validate_db_insert($values);
+
+//_debug_array($custom_function);
+ $this->db->transaction_begin();
+
+ $this->db->query("INSERT INTO fm_custom_function
(acl_location, id, file_name, descr, active, custom_sort) "
+ . "VALUES ($values)",__LINE__,__FILE__);
+
+ $receipt['id']= $custom_function['id'];
+
+ $this->db->transaction_commit();
+
+ return $receipt;
+ }
+
+ function edit_custom_function($custom_function)
+ {
+ if(!$custom_function['acl_location'] &&
$custom_function['entity_id'] && $custom_function['cat_id'])
+ {
+ $acl_location = '.entity.' .
$custom_function['entity_id'] . '.' . $custom_function['cat_id'];
+ }
+ else
+ {
+ $acl_location =
$custom_function['acl_location'];
+ }
+
+ if(!$acl_location)
+ {
+ return $receipt['error'][] = array('msg' =>
lang('acl_locastion is missing'));
+ }
+
+ $custom_function['descr'] =
$this->db->db_addslashes($custom_function['descr']);
+
+ $this->db->transaction_begin();
+
+ $value_set=array(
+ 'descr' =>
$custom_function['descr'],
+ 'file_name' =>
$custom_function['custom_function_file'],
+ 'active' =>
$custom_function['active']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->query("UPDATE fm_custom_function set
$value_set WHERE acl_location='" . $acl_location . "' AND id=" .
$custom_function['id'],__LINE__,__FILE__);
+
+ $this->db->transaction_commit();
+
+ $receipt['message'][] = array('msg' => lang('Custom
function has been edited'));
+
+ return $receipt;
+ }
+
+ function resort_custom_function($data)
+ {
+ if(is_array($data))
+ {
+ $resort =
(isset($data['resort'])?$data['resort']:'up');
+ $entity_id =
(isset($data['entity_id'])?$data['entity_id']:'');
+ $cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
+ $acl_location =
(isset($data['acl_location'])?$data['acl_location']:'');
+ $id = (isset($data['id'])?$data['id']:'');
+ }
+
+ if(!$acl_location && $entity_id && $cat_id)
+ {
+ $acl_location = '.entity.' . $entity_id . '.' .
$cat_id;
+ }
+ else
+ {
+ $acl_location = $acl_location;
+ }
+
+ if(!$acl_location)
+ {
+ return $receipt['error'][] = array('msg' =>
lang('acl_locastion is missing'));
+ }
+
+ $sql = "SELECT custom_sort FROM fm_custom_function
where acl_location='$acl_location' AND id=$id";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $custom_sort = $this->db->f('custom_sort');
+ $sql2 = "SELECT max(custom_sort) as max_sort FROM
fm_custom_function where acl_location='$acl_location'";
+ $this->db->query($sql2,__LINE__,__FILE__);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+
+ switch($resort)
+ {
+ case 'up':
+ if($custom_sort>1)
+ {
+ $sql = "UPDATE
fm_custom_function set custom_sort=$custom_sort WHERE
acl_location='$acl_location' AND custom_sort =" . ($custom_sort-1);
+
$this->db->query($sql,__LINE__,__FILE__);
+ $sql = "UPDATE
fm_custom_function set custom_sort=" . ($custom_sort-1) ." WHERE
acl_location='$acl_location' AND id=$id";
+
$this->db->query($sql,__LINE__,__FILE__);
+ }
+ break;
+ case 'down':
+ if($max_sort > $custom_sort)
+ {
+ $sql = "UPDATE
fm_custom_function set custom_sort=$custom_sort WHERE
acl_location='$acl_location' AND custom_sort =" . ($custom_sort+1);
+
$this->db->query($sql,__LINE__,__FILE__);
+ $sql = "UPDATE
fm_custom_function set custom_sort=" . ($custom_sort+1) ." WHERE
acl_location='$acl_location' AND id=$id";
+
$this->db->query($sql,__LINE__,__FILE__);
+ }
+ break;
+ default:
+ return;
+ break;
+ }
+ }
+
+ function
delete_custom_function($acl_location,$custom_function_id)
+ {
+ $sql = "SELECT custom_sort FROM fm_custom_function
where acl_location='$acl_location' AND id=$custom_function_id";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $custom_sort = $this->db->f('custom_sort');
+ $sql2 = "SELECT max(custom_sort) as max_sort FROM
fm_custom_function where acl_location='$acl_location'";
+ $this->db->query($sql2,__LINE__,__FILE__);
+ $this->db->next_record();
+ $max_sort = $this->db->f('max_sort');
+ if($max_sort>$custom_sort)
+ {
+ $sql = "UPDATE fm_custom_function set
custom_sort=custom_sort-1 WHERE acl_location='$acl_location' AND custom_sort >
$custom_sort";
+ $this->db->query($sql,__LINE__,__FILE__);
+ }
+ $this->db->query("DELETE FROM fm_custom_function WHERE
acl_location='$acl_location' AND id=$custom_function_id",__LINE__,__FILE__);
+ }
+ }
+?>
====================================================
Index: property/inc/class.uiadmin_entity.inc.php
diff -u property/inc/class.uiadmin_entity.inc.php:1.9
property/inc/class.uiadmin_entity.inc.php:1.10
--- property/inc/class.uiadmin_entity.inc.php:1.9 Thu May 12 21:26:28 2005
+++ property/inc/class.uiadmin_entity.inc.php Mon Oct 24 10:43:29 2005
@@ -1,1211 +1,1495 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
- * @package property
- * @subpackage admin
- * @version $Id$
- */
-
- /**
- * Description
- * @package property
- */
-
- class uiadmin_entity
- {
- var $grants;
- var $start;
- var $query;
- var $sort;
- var $order;
- var $sub;
- var $currentapp;
-
- var $public_functions = array
- (
- 'index' => True,
- 'list_status' => True,
- 'category' => True,
- 'edit' => True,
- 'edit_status' => True,
- 'edit_category' => True,
- 'view' => True,
- 'delete' => True,
- 'list_attribute' => True,
- 'edit_attrib' => True,
- );
-
- function uiadmin_entity()
- {
- $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bo =
CreateObject($this->currentapp.'.boadmin_entity',True);
- $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
- $this->menu =
CreateObject($this->currentapp.'.menu');
-
- $this->start =
$this->bo->start;
- $this->query =
$this->bo->query;
- $this->sort =
$this->bo->sort;
- $this->order =
$this->bo->order;
- $this->entity_id =
$this->bo->entity_id;
- $this->cat_id =
$this->bo->cat_id;
- $this->allrows =
$this->bo->allrows;
-
- $this->menu->sub ='admin_entity';
- }
-
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'allrows' => $this->allrows,
- 'entity_id' => $this->entity_id,
- 'cat_id' => $this->cat_id
- );
- $this->bo->save_sessiondata($data);
- }
-
- function index()
- {
- $this->bo->reset_fm_cache();
- $GLOBALS['phpgw']->xslttpl->add_file(array(
-
'admin_entity',
-
'nextmatchs',
-
'menu',
-
'search_field'));
- $links = $this->menu->links();
-
- $entity_list = $this->bo->read();
-
- if (isSet($entity_list) AND is_array($entity_list))
- {
- foreach($entity_list as $entry)
- {
- $content[] = array
- (
- 'id'
=> $entry['id'],
- 'name'
=> $entry['name'],
- 'descr'
=> $entry['descr'],
- 'link_categories'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='
. $entry['id']),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit&id='
. $entry['id']),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&entity_id='
. $entry['id']),
- 'lang_view_standardtext'
=> lang('view the standard'),
- 'lang_category_text'
=> lang('categories for the entity type'),
- 'lang_edit_standardtext'
=> lang('edit the entity'),
- 'lang_delete_standardtext'
=> lang('delete the entity'),
- 'text_categories'
=> lang('Categories'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
- }
-
-//_debug_array($content);
-
- $table_header[] = array
- (
-
- 'lang_descr' => lang('Descr'),
- 'lang_categories' => lang('Categories'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.index',
-
'allrows'=>$this->allrows)
-
)),
- 'lang_id' => lang('entity id'),
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.index',
-
'allrows'=>$this->allrows)
-
)),
- 'lang_name' => lang('Name'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_standardtext' => lang('add a
standard'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit'),
- 'lang_done' =>
lang('done'),
- 'lang_done_standardtext' => lang('back
to admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.index',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'query'
=>$this->query
- );
-
- $data = array
- (
- 'links'
=> $links,
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($entity_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header'
=> $table_header,
- 'values'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('entity');
- $function_msg =
lang('list entity type');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function list_status()
- {
- $this->bo->reset_fm_cache();
- $GLOBALS['phpgw']->xslttpl->add_file(array(
-
'admin_entity',
-
'nextmatchs',
-
'menu',
-
'search_field'));
- $links = $this->menu->links();
-
- $list = $this->bo->read_status();
-
- if (isSet($list) AND is_array($list))
- {
- foreach($list as $entry)
- {
- $content[] = array
- (
- 'id'
=> $entry['id'],
- 'descr'
=> $entry['descr'],
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_status&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id . '&id=' . $entry['id']),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id . '&status_id=' .
$entry['id']),
- 'lang_edit_standardtext'
=> lang('edit the entity'),
- 'lang_delete_standardtext'
=> lang('delete the entity'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
- }
-
-//_debug_array($content);
-
- $table_header[] = array
- (
-
- 'lang_descr' => lang('Descr'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.list_status',
-
'entity_id' =>
$this->entity_id,
-
'cat_id' =>
$this->cat_id
-
)
-
)),
- 'lang_id' => lang('status'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_text' => lang('add a standard'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_status&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id),
- 'lang_done' =>
lang('done'),
- 'lang_done_text' => lang('back to
admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id),
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.list_status',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'query'
=>$this->query,
- 'entity_id'
=>$this->entity_id,
- 'cat_id'
=>$this->cat_id
- );
-
- $entity =
$this->bo->read_single($this->entity_id,false);
- $category =
$this->bo->read_single_category($this->entity_id,$this->cat_id);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'lang_entity'
=> lang('entity'),
- 'entity_name'
=> $entity['name'],
- 'lang_category'
=> lang('category'),
- 'category_name'
=> $category['name'],
- 'links'
=> $links,
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($entity_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_status' =>
$table_header,
- 'values_status'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('entity');
- $function_msg =
lang('list status');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_status' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function category()
- {
-
- $entity_id =
get_var('entity_id',array('POST','GET'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array(
-
'admin_entity',
-
'nextmatchs',
-
'menu',
-
'search_field'));
- $links = $this->menu->links();
-
- $category_list = $this->bo->read_category($entity_id);
-
- if (isSet($category_list) AND is_array($category_list))
- {
- foreach($category_list as $entry)
- {
- $content[] = array
- (
- 'id'
=> $entry['id'],
- 'name'
=> $entry['name'],
- 'prefix'
=> $entry['prefix'],
- 'descr'
=> $entry['descr'],
-// 'link_status'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_status&cat_id='
. $entry['id'] . '&entity_id=' . $entity_id),
- 'link_attribute'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_attribute&cat_id='
. $entry['id'] . '&entity_id=' . $entity_id),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_category&id='
. $entry['id'] . '&entity_id=' . $entity_id),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&cat_id='
. $entry['id'] . '&entity_id=' . $entity_id),
- 'lang_view_standardtext'
=> lang('view the category'),
- 'lang_status_standardtext'
=> lang('Status for the entity category'),
- 'lang_attribute_standardtext'
=> lang('attributes for the entity category'),
- 'lang_edit_standardtext'
=> lang('edit the standard'),
- 'lang_delete_standardtext'
=> lang('delete the standard'),
- 'text_status'
=> lang('Status'),
- 'text_attribute'
=> lang('Attributes'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
- }
-
-//_debug_array($content);
-
- $table_header[] = array
- (
-
- 'lang_descr' => lang('Descr'),
- 'lang_prefix' => lang('prefix'),
-// 'lang_status' => lang('Status'),
- 'lang_attribute' => lang('Attributes'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_id' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'id',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.category',
-
'entity_id' =>$entity_id,
-
'allrows'=>$this->allrows)
-
)),
- 'lang_id' => lang('category id'),
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.category',
-
'entity_id' =>$entity_id,
-
'allrows'=>$this->allrows)
-
)),
- 'lang_name' => lang('Name'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_standardtext' => lang('add a
category'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_category&entity_id='
. $entity_id),
- 'lang_done' =>
lang('done'),
- 'lang_done_standardtext' => lang('back
to entity'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.index')
- );
-
- $entity = $this->bo->read_single($entity_id,false);
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.category',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'query'
=>$this->query,
- 'entity_id'
=>$entity_id
- );
-
- $data = array
- (
- 'lang_entity'
=> lang('entity'),
- 'entity_name'
=> $entity['name'],
- 'links'
=> $links,
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'num_records'
=> count($category_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_category' =>
$table_header,
- 'values_category'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('entity');
- $function_msg =
lang('list entity type');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_category' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit()
- {
- $id = get_var('id',array('POST','GET'));
- $values =
get_var('values',array('POST'));
- $config =
CreateObject('phpgwapi.config',$this->currentapp);
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
-
- if ($values['save'])
- {
- if (!$values['name'])
- {
- $receipt['error'][] =
array('msg'=>lang('Name not entered!'));
- }
-
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
-
- if (!$receipt['error'])
- {
-
- $receipt =
$this->bo->save($values,$action);
- if(!$id)
- {
- $id=$receipt['id'];
- }
- $config->read_repository();
-
-
if(!is_array($config->config_data['location_form']))
- {
-
$config->config_data['location_form'] = array();
- }
-
- if($values['location_form'])
- {
-
-
$config->config_data['location_form']['entity_' . $id] = 'entity_' . $id;
-
- }
- else
- {
-
unset($config->config_data['location_form']['entity_' . $id]);
- }
-
- $config->save_repository();
- }
- else
- {
- $receipt['error'][] = array('msg'=>
lang('Entity has NOT been saved'));
- }
-
- }
-
-
- if ($id)
- {
- $values = $this->bo->read_single($id);
- $function_msg = lang('edit standard');
- $action='edit';
- }
- else
- {
- $function_msg = lang('add entity');
- $action='add';
- }
-
- $include_list =
$this->bo->get_entity_list($values['lookup_entity']);
- $include_list_2 =
$this->bo->get_entity_list_2($values['include_entity_for']);
- $include_list_3 =
$this->bo->get_entity_list_3($values['start_entity_from']);
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit',
- 'id' => $id
- );
-//_debug_array($include_list);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'lang_name_standardtext' =>
lang('Enter a name of the standard'),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.index'),
- 'lang_id'
=> lang('standard ID'),
- 'lang_name'
=> lang('Name'),
- 'lang_descr'
=> lang('Descr'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
- 'value_name'
=> $values['name'],
- 'lang_id_standardtext' =>
lang('Enter the standard ID'),
- 'lang_descr_standardtext' =>
lang('Enter a description of the standard'),
- 'lang_done_standardtext' =>
lang('Back to the list'),
- 'lang_save_standardtext' =>
lang('Save the standard'),
- 'type_id'
=> $values['type_id'],
- 'value_descr'
=> $values['descr'],
- 'lang_location_form' =>
lang('location form'),
- 'value_location_form' =>
$values['location_form'],
- 'lang_location_form_statustext' => lang('If
this entity type is to be linked to a location'),
- 'lang_include_in_location_form' =>
lang('include in location form'),
- 'include_list'
=> $include_list,
- 'lang_include_statustext' =>
lang('Which entity type is to show up in location forms'),
- 'lang_include_this_entity' =>
lang('include this entity'),
- 'include_list_2'
=> $include_list_2,
- 'lang_include_2_statustext' =>
lang('Let this entity show up in location form'),
- 'lang_start_this_entity' =>
lang('start this entity'),
- 'include_list_3'
=> $include_list_3,
- 'lang_include_3_statustext' =>
lang('Start this entity from'),
- 'lang_select'
=> lang('select'),
- 'lang_documentation' =>
lang('documentation'),
- 'value_documentation' =>
$values['documentation'],
- 'lang_documentation_statustext' => lang('If
this entity type is to be linked to documents'),
- );
-
- $appname
= lang('entity');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function edit_status()
- {
- $id = get_var('id',array('POST','GET'));
- $values =
get_var('values',array('POST'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
-
- if ($values['save'])
- {
- if (!$values['id'])
- {
- $receipt['error'][] =
array('msg'=>lang('ID not entered!'));
- }
-
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
-
- if (!$receipt['error'])
- {
- $receipt =
$this->bo->save_status($values,$action);
- if(!$id)
- {
- $id=$receipt['id'];
- }
- }
- else
- {
- $receipt['error'][] = array('msg'=>
lang('Status has NOT been saved'));
- }
-
- }
-
- if ($id)
- {
- $values = $this->bo->read_single_status($id);
- $function_msg = lang('edit status');
- $action='edit';
- }
- else
- {
- $function_msg = lang('add status');
- $action='add';
- }
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit_status',
- 'entity_id' => $this->entity_id,
- 'cat_id' => $this->cat_id,
- 'id' => $id
- );
-//_debug_array($link_data);
-
- $entity =
$this->bo->read_single($this->entity_id,false);
- $category =
$this->bo->read_single_category($this->entity_id,$this->cat_id);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'lang_entity'
=> lang('entity'),
- 'entity_name'
=> $entity['name'],
- 'lang_category'
=> lang('category'),
- 'category_name'
=> $category['name'],
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'lang_name_standardtext' =>
lang('Enter a name of the standard'),
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_status&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id),
- 'lang_id'
=> lang('status ID'),
- 'lang_descr'
=> lang('Descr'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
- 'lang_id_standardtext' =>
lang('Enter the status ID'),
- 'lang_descr_standardtext' =>
lang('Enter a description of the status'),
- 'lang_done_standardtext' =>
lang('Back to the list'),
- 'lang_save_standardtext' =>
lang('Save the status'),
- 'value_descr'
=> $values['descr']
- );
-
- $appname
= lang('entity');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_status' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function edit_category()
- {
- $entity_id =
get_var('entity_id',array('POST','GET'));
- $id = get_var('id',array('POST','GET'));
- $values =
get_var('values',array('POST'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
-
- if ($values['save'])
- {
- $values['entity_id'] = $entity_id;
-
- if (!$values['name'])
- {
- $receipt['error'][] =
array('msg'=>lang('Name not entered!'));
- }
- if (!$values['entity_id'])
- {
- $receipt['error'][] =
array('msg'=>lang('Entity not choosen'));
- }
-
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
-
- if (!$receipt['error'])
- {
- $receipt =
$this->bo->save_category($values,$action);
- if(!$id)
- {
- $id=$receipt['id'];
- }
- }
- else
- {
- $receipt['error'][] = array('msg'=>
lang('Category has NOT been saved'));
- }
-
- }
-
- if ($id)
- {
- $values =
$this->bo->read_single_category($entity_id,$id);
- $function_msg = lang('edit category');
- $action='edit';
- }
- else
- {
- $function_msg = lang('add category');
- $action='add';
- }
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit_category',
- 'entity_id' =>$entity_id,
- 'id' => $id
- );
-//_debug_array($link_data);
-
- $entity = $this->bo->read_single($entity_id,false);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'lang_entity'
=> lang('entity'),
- 'entity_name'
=> $entity['name'],
- 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'lang_prefix_standardtext' =>
lang('Enter a standard prefix for the id'),
- 'lang_name_standardtext' =>
lang('Enter a name of the standard'),
-
- 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='
. $entity_id),
- 'lang_id'
=> lang('Category'),
- 'lang_name'
=> lang('Name'),
- 'lang_descr'
=> lang('Descr'),
- 'lang_prefix'
=> lang('Prefix'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
- 'value_name'
=> $values['name'],
- 'value_prefix'
=> $values['prefix'],
- 'lang_id_standardtext' =>
lang('Enter the standard ID'),
- 'lang_descr_standardtext' =>
lang('Enter a description of the standard'),
- 'lang_done_standardtext' =>
lang('Back to the list'),
- 'lang_save_standardtext' =>
lang('Save the standard'),
- 'type_id'
=> $values['type_id'],
- 'value_descr'
=> $values['descr'],
- 'lang_lookup_tenant' =>
lang('lookup tenant'),
- 'value_lookup_tenant' =>
$values['lookup_tenant'],
- 'lang_lookup_tenant_statustext' => lang('If
this entity type is to look up tenants'),
- 'lang_location_level' =>
lang('location level'),
- 'location_level_list' =>
$this->bo->get_location_level_list($values['location_level']),
- 'lang_location_level_statustext' =>
lang('select location level'),
- 'lang_no_location_level' =>
lang('None'),
- 'lang_tracking'
=> lang('tracking'),
- 'value_tracking'
=> $values['tracking'],
- 'lang_tracking_statustext' =>
lang('If this entity type is to be tracket in ticket list'),
- 'lang_fileupload'
=> lang('Enable file upload'),
- 'value_fileupload'
=> $values['fileupload'],
- 'lang_fileupload_statustext' => lang('If
files can be uploaded for this category'),
- 'lang_loc_link'
=> lang('Link from location'),
- 'value_loc_link'
=> $values['loc_link'],
- 'lang_loc_link_statustext' =>
lang('Enable link from location detail'),
- 'lang_start_project' =>
lang('Start project'),
- 'value_start_project' =>
$values['start_project'],
- 'lang_start_project_statustext' => lang('Enable
start project from this category')
- );
-
- $appname
= lang('entity');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- function delete()
- {
- $entity_id =
get_var('entity_id',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $attrib_id =
get_var('attrib_id',array('POST','GET'));
- $status_id =
get_var('status_id',array('POST','GET'));
- $confirm = get_var('confirm',array('POST'));
-
- if($attrib_id)
- {
- $function='list_attribute';
- }
- else
- {
- if($cat_id)
- {
- if($status_id)
- {
- $function='list_status';
- }
- else
- {
- $function='category';
- }
- }
- else
- {
- $function='index';
- }
- }
-
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.'.$function,
- 'cat_id' => $cat_id,
- 'entity_id' => $entity_id,
- 'attrib_id' => $attrib_id,
- 'status_id' => $status_id
- );
-
- $delete_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.delete',
- 'cat_id' => $cat_id,
- 'entity_id' => $entity_id,
- 'attrib_id' => $attrib_id,
- 'status_id' => $status_id
- );
-
- if (get_var('confirm',array('POST')))
- {
-
$this->bo->delete($cat_id,$entity_id,$attrib_id,$status_id);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
- }
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
-
- $data = array
- (
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php',$delete_data),
- 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
- 'lang_yes' =>
lang('yes'),
- 'lang_yes_standardtext' => lang('Delete the
entry'),
- 'lang_no_standardtext' => lang('Back to the
list'),
- 'lang_no' =>
lang('no')
- );
-
- $appname
= lang('entity');
- $function_msg =
lang('delete entity type');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
-
- function list_attribute()
- {
- $entity_id = $this->entity_id;
- $cat_id = $this->cat_id;
- $id = get_var('id',array('POST','GET'));
- $resort = get_var('resort',array('POST','GET'));
-
- $GLOBALS['phpgw']->xslttpl->add_file(array(
-
'admin_entity',
-
'nextmatchs',
-
'search_field'));
-
- if($resort)
- {
- $this->bo->resort_attrib($id,$resort);
- }
- $attrib_list =
$this->bo->read_attrib($entity_id,$cat_id);
-
- if (isset($attrib_list) AND is_array($attrib_list))
- {
- foreach($attrib_list as $entry)
- {
-
- $content[] = array
- (
- 'name'
=> $entry['name'],
- 'datatype'
=> $entry['datatype'],
- 'column_name'
=> $entry['column_name'],
- 'input_text'
=> $entry['input_text'],
- 'sorting'
=> $entry['attrib_sort'],
- 'search'
=> $entry['search'],
- 'link_up'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_attribute&resort=up&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id'] . '&allrows=' .
$this->allrows),
- 'link_down'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_attribute&resort=down&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id'] . '&allrows=' .
$this->allrows),
- 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_attrib&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id']),
- 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&attrib_id=' . $entry['id']),
- 'lang_up_text'
=> lang('shift up'),
- 'lang_down_text'
=> lang('shift down'),
- 'lang_edit_text'
=> lang('edit the attrib'),
- 'lang_delete_text'
=> lang('delete the attrib'),
- 'text_attribute'
=> lang('Attributes'),
- 'text_up'
=> lang('up'),
- 'text_down'
=> lang('down'),
- 'text_edit'
=> lang('edit'),
- 'text_delete'
=> lang('delete')
- );
- }
- }
-
-//_debug_array($content);
-
- $table_header[] = array
- (
- 'lang_descr' => lang('Descr'),
- 'lang_datatype' => lang('Datatype'),
- 'lang_sorting' => lang('sorting'),
- 'lang_search' => lang('search'),
- 'lang_edit' => lang('edit'),
- 'lang_delete' => lang('delete'),
- 'sort_name' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'column_name',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.list_attribute',
-
'entity_id'
=>$entity_id,
-
'cat_id'
=>$cat_id,
-
'allrows'=>$this->allrows)
-
)),
- 'sort_sorting' =>
$this->nextmatchs->show_sort_order(array
-
(
-
'sort' => $this->sort,
-
'var' => 'attrib_sort',
-
'order' => $this->order,
-
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.list_attribute',
-
'entity_id'
=>$entity_id,
-
'cat_id'
=>$cat_id,
-
'allrows'=>$this->allrows)
-
)),
- 'lang_name' => lang('Name'),
- );
-
- $table_add[] = array
- (
- 'lang_add' =>
lang('add'),
- 'lang_add_attribtext' => lang('add a attrib'),
- 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_attrib&entity_id='.$entity_id
. '&cat_id=' . $cat_id),
- 'lang_done' =>
lang('done'),
- 'lang_done_attribtext' => lang('back to
admin'),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='.$entity_id),
- );
-
- if(!$this->allrows)
- {
- $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
- }
- else
- {
- $record_limit = $this->bo->total_records;
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.list_attribute',
- 'sort'
=>$this->sort,
- 'order'
=>$this->order,
- 'query'
=>$this->query,
- 'entity_id'
=>$entity_id,
- 'cat_id'
=>$cat_id
- );
-
- $entity = $this->bo->read_single($entity_id,false);
- $category =
$this->bo->read_single_category($entity_id,$cat_id);
-
- $data = array
- (
- 'lang_entity'
=> lang('entity'),
- 'entity_name'
=> $entity['name'],
- 'lang_category'
=> lang('category'),
- 'category_name'
=> $category['name'],
- 'allow_allrows'
=> True,
- 'allrows'
=> $this->allrows,
- 'start_record'
=> $this->start,
- 'record_limit'
=> $record_limit,
- 'start_record'
=> $this->start,
- 'num_records'
=> count($attrib_list),
- 'all_records'
=> $this->bo->total_records,
- 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
- 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
- 'lang_searchfield_attribtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
- 'lang_searchbutton_attribtext' => lang('Submit
the search string'),
- 'query'
=> $this->query,
- 'lang_search'
=> lang('search'),
- 'table_header_attrib' =>
$table_header,
- 'values_attrib'
=> $content,
- 'table_add'
=> $table_add
- );
-
- $appname
= lang('attribute');
- $function_msg =
lang('list entity attribute');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_attribute' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- $this->save_sessiondata();
- }
-
- function edit_attrib()
- {
- $entity_id =
get_var('entity_id',array('POST','GET'));
- $cat_id = get_var('cat_id',array('POST','GET'));
- $id =
get_var('id',array('POST','GET'));
- $values = get_var('values',array('POST'));
-
-
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
-
- if ($values['save'])
- {
- if($id)
- {
- $values['id']=$id;
- $action='edit';
- }
-
- $values['entity_id']=$entity_id;
- $values['cat_id']=$cat_id;
-
- if (!$values['column_name'])
- {
- $receipt['error'][] =
array('msg'=>lang('Column name not entered!'));
- }
-
- if (!$values['input_text'])
- {
- $receipt['error'][] =
array('msg'=>lang('Input text not entered!'));
- }
- if (!$values['statustext'])
- {
- $receipt['error'][] =
array('msg'=>lang('Statustext not entered!'));
- }
-
- if (!$values['entity_id'])
- {
- $receipt['error'][] =
array('msg'=>lang('entity type not choosen!'));
- }
-
- if (!$values['column_info']['type'])
- {
- $receipt['error'][] =
array('msg'=>lang('Datatype type not choosen!'));
- }
-
-
if(!ctype_digit($values['column_info']['precision']))
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter precision as integer !'));
-
unset($values['column_info']['precision']);
- }
-
-
if(!ctype_digit($values['column_info']['scale']))
- {
-
$receipt['error'][]=array('msg'=>lang('Please enter scale as integer !'));
- unset($values['column_info']['scale']);
- }
-
- if (!$values['column_info']['nullable'])
- {
- $receipt['error'][] =
array('msg'=>lang('Nullable not choosen!'));
- }
-
-
- if (!$receipt['error'])
- {
-
- $receipt =
$this->bo->save_attrib($values,$action);
-
- if(!$id)
- {
- $id=$receipt['id'];
- }
- }
- else
- {
- $receipt['error'][] = array('msg'
=> lang('Attribute has NOT been saved'));
- }
-
- }
-
- if ($id)
- {
- $values =
$this->bo->read_single_attrib($entity_id,$cat_id,$id);
- $type_name=$values['type_name'];
- $function_msg = lang('edit attribute'). ' ' .
lang($type_name);
- $action='edit';
- }
- else
- {
- $function_msg = lang('add attribute');
- $action='add';
- }
-
- $link_data = array
- (
- 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit_attrib',
- 'entity_id' => $entity_id,
- 'cat_id' => $cat_id,
- 'id' => $id
- );
-
- if($values['column_info']['type']=='R' ||
$values['column_info']['type']=='CH' || $values['column_info']['type']=='LB')
- {
- $multiple_choice= True;
- }
-
-//_debug_array($values);
-
- $entity = $this->bo->read_single($entity_id,false);
- $category =
$this->bo->read_single_category($entity_id,$cat_id);
-
- $msgbox_data = $this->bocommon->msgbox_data($receipt);
-
- $data = array
- (
- 'lang_entity'
=> lang('entity'),
- 'entity_name'
=> $entity['name'],
- 'lang_category'
=> lang('category'),
- 'category_name'
=> $category['name'],
-
- 'lang_choice' =>
lang('Choice'),
- 'lang_new_value' =>
lang('New value'),
- 'lang_new_value_statustext' => lang('New
value for mulitple choice'),
- 'multiple_choice' =>
$multiple_choice,
- 'value_choice' =>
$values['choice'],
- 'lang_delete_value' =>
lang('Delete value'),
- 'lang_value' =>
lang('value'),
- 'lang_delete_choice_statustext'=> lang('Delete
this value from the list of multiple choice'),
-
- 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
- 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
- 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_attribute&entity_id='.$entity_id
. '&cat_id='.$cat_id),
- 'lang_id'
=> lang('Attribute ID'),
- 'lang_entity_type' =>
lang('Entity type'),
- 'lang_no_entity_type' => lang('No
entity type'),
- 'lang_save'
=> lang('save'),
- 'lang_done'
=> lang('done'),
- 'value_id'
=> $id,
-
- 'lang_column_name'
=> lang('Column name'),
- 'value_column_name'
=> $values['column_name'],
- 'lang_column_name_statustext' => lang('enter
the name for the column'),
-
- 'lang_input_text'
=> lang('input text'),
- 'value_input_text'
=> $values['input_text'],
- 'lang_input_name_statustext' => lang('enter
the input text for records'),
-
- 'lang_id_attribtext' => lang('Enter
the attribute ID'),
- 'lang_entity_statustext' => lang('Select
a entity type'),
-
- 'lang_statustext' =>
lang('Statustext'),
- 'lang_statustext_attribtext'=> lang('Enter a
statustext for the inputfield in forms'),
- 'value_statustext' =>
$values['statustext'],
-
- 'lang_done_attribtext' => lang('Back
to the list'),
- 'lang_save_attribtext' => lang('Save
the attribute'),
-
- 'lang_datatype' =>
lang('Datatype'),
- 'lang_datatype_statustext' => lang('Select
a datatype'),
- 'lang_no_datatype' =>
lang('No datatype'),
- 'datatype_list' =>
$this->bocommon->select_datatype($values['column_info']['type']),
-
- 'lang_precision' =>
lang('Precision'),
- 'lang_precision_statustext' => lang('enter
the record length'),
- 'value_precision' =>
$values['column_info']['precision'],
-
- 'lang_scale' =>
lang('scale'),
- 'lang_scale_statustext' => lang('enter
the scale if type is decimal'),
- 'value_scale' =>
$values['column_info']['scale'],
-
- 'lang_default' =>
lang('default'),
- 'lang_default_statustext' => lang('enter
the default value'),
- 'value_default' =>
$values['column_info']['default'],
-
- 'lang_nullable' =>
lang('Nullable'),
- 'lang_nullable_statustext' => lang('Chose
if this column is nullable'),
- 'lang_select_nullable' => lang('Select
nullable'),
- 'nullable_list' =>
$this->bocommon->select_nullable($values['column_info']['nullable']),
- 'value_lookup_form' =>
$values['lookup_form'],
- 'lang_lookup_form'
=> lang('show in lookup forms'),
- 'lang_lookup_form_statustext'
=> lang('check to show this attribue in lookup forms'),
- 'value_list' =>
$values['list'],
- 'lang_list' =>
lang('show in list'),
- 'lang_list_statustext' =>
lang('check to show this attribute in entity list'),
- 'value_search' =>
$values['search'],
- 'lang_include_search' =>
lang('Include in search'),
- 'lang_include_search_statustext'=> lang('check
to show this attribute in location list'),
-
- );
-//_debug_array($values);
-
- $appname
= lang('entity');
-
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
-
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_attrib' => $data));
- // $GLOBALS['phpgw']->xslttpl->pp();
- }
-
- }
-?>
+<?php
+ /**
+ * phpGroupWare - property: a Facilities Management System.
+ *
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
+ * @package property
+ * @subpackage admin
+ * @version $Id$
+ */
+
+ /**
+ * Description
+ * @package property
+ */
+
+ class uiadmin_entity
+ {
+ var $grants;
+ var $start;
+ var $query;
+ var $sort;
+ var $order;
+ var $sub;
+ var $currentapp;
+
+ var $public_functions = array
+ (
+ 'index' => True,
+ 'list_status' => True,
+ 'category' => True,
+ 'edit' => True,
+ 'edit_status' => True,
+ 'edit_category' => True,
+ 'view' => True,
+ 'delete' => True,
+ 'list_attribute' => True,
+ 'edit_attrib' => True,
+ 'list_custom_function'=>True,
+ 'edit_custom_function' => True
+ );
+
+ function uiadmin_entity()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
+ $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->bo =
CreateObject($this->currentapp.'.boadmin_entity',True);
+ $this->bocommon =
CreateObject($this->currentapp.'.bocommon');
+ $this->menu =
CreateObject($this->currentapp.'.menu');
+
+ $this->start =
$this->bo->start;
+ $this->query =
$this->bo->query;
+ $this->sort =
$this->bo->sort;
+ $this->order =
$this->bo->order;
+ $this->entity_id =
$this->bo->entity_id;
+ $this->cat_id =
$this->bo->cat_id;
+ $this->allrows =
$this->bo->allrows;
+
+ $this->menu->sub ='admin_entity';
+ }
+
+ function save_sessiondata()
+ {
+ $data = array
+ (
+ 'start' => $this->start,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'allrows' => $this->allrows,
+ 'entity_id' => $this->entity_id,
+ 'cat_id' => $this->cat_id
+ );
+ $this->bo->save_sessiondata($data);
+ }
+
+ function index()
+ {
+ $this->bo->reset_fm_cache();
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+
'admin_entity',
+
'nextmatchs',
+
'menu',
+
'search_field'));
+ $links = $this->menu->links();
+
+ $entity_list = $this->bo->read();
+
+ if (isSet($entity_list) AND is_array($entity_list))
+ {
+ foreach($entity_list as $entry)
+ {
+ $content[] = array
+ (
+ 'id'
=> $entry['id'],
+ 'name'
=> $entry['name'],
+ 'descr'
=> $entry['descr'],
+ 'link_categories'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='
. $entry['id']),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit&id='
. $entry['id']),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&entity_id='
. $entry['id']),
+ 'lang_view_standardtext'
=> lang('view the standard'),
+ 'lang_category_text'
=> lang('categories for the entity type'),
+ 'lang_edit_standardtext'
=> lang('edit the entity'),
+ 'lang_delete_standardtext'
=> lang('delete the entity'),
+ 'text_categories'
=> lang('Categories'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+ }
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+
+ 'lang_descr' => lang('Descr'),
+ 'lang_categories' => lang('Categories'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.index',
+
'allrows'=>$this->allrows)
+
)),
+ 'lang_id' => lang('entity id'),
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.index',
+
'allrows'=>$this->allrows)
+
)),
+ 'lang_name' => lang('Name'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_standardtext' => lang('add a
standard'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit'),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_standardtext' => lang('back
to admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/admin/index.php')
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.index',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'query'
=>$this->query
+ );
+
+ $data = array
+ (
+ 'links'
=> $links,
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($entity_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header'
=> $table_header,
+ 'values'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('entity');
+ $function_msg =
lang('list entity type');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function list_status()
+ {
+ $this->bo->reset_fm_cache();
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+
'admin_entity',
+
'nextmatchs',
+
'menu',
+
'search_field'));
+ $links = $this->menu->links();
+
+ $list = $this->bo->read_status();
+
+ if (isSet($list) AND is_array($list))
+ {
+ foreach($list as $entry)
+ {
+ $content[] = array
+ (
+ 'id'
=> $entry['id'],
+ 'descr'
=> $entry['descr'],
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_status&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id . '&id=' . $entry['id']),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id . '&status_id=' .
$entry['id']),
+ 'lang_edit_standardtext'
=> lang('edit the entity'),
+ 'lang_delete_standardtext'
=> lang('delete the entity'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+ }
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+
+ 'lang_descr' => lang('Descr'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.list_status',
+
'entity_id' =>
$this->entity_id,
+
'cat_id' =>
$this->cat_id
+
)
+
)),
+ 'lang_id' => lang('status'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_text' => lang('add a standard'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_status&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_text' => lang('back to
admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id),
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.list_status',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'query'
=>$this->query,
+ 'entity_id'
=>$this->entity_id,
+ 'cat_id'
=>$this->cat_id
+ );
+
+ $entity =
$this->bo->read_single($this->entity_id,false);
+ $category =
$this->bo->read_single_category($this->entity_id,$this->cat_id);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'lang_entity'
=> lang('entity'),
+ 'entity_name'
=> $entity['name'],
+ 'lang_category'
=> lang('category'),
+ 'category_name'
=> $category['name'],
+ 'links'
=> $links,
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($entity_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_status' =>
$table_header,
+ 'values_status'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('entity');
+ $function_msg =
lang('list status');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_status' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function category()
+ {
+
+ $entity_id =
get_var('entity_id',array('POST','GET'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+
'admin_entity',
+
'nextmatchs',
+
'menu',
+
'search_field'));
+ $links = $this->menu->links();
+
+ $category_list = $this->bo->read_category($entity_id);
+
+ if (isSet($category_list) AND is_array($category_list))
+ {
+ foreach($category_list as $entry)
+ {
+ $content[] = array
+ (
+ 'id'
=> $entry['id'],
+ 'name'
=> $entry['name'],
+ 'prefix'
=> $entry['prefix'],
+ 'descr'
=> $entry['descr'],
+// 'link_status'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_status&cat_id='
. $entry['id'] . '&entity_id=' . $entity_id),
+ 'link_custom_function'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_custom_function&cat_id='
. $entry['id'] . '&entity_id=' . $entity_id),
+ 'link_attribute'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_attribute&cat_id='
. $entry['id'] . '&entity_id=' . $entity_id),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_category&id='
. $entry['id'] . '&entity_id=' . $entity_id),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&cat_id='
. $entry['id'] . '&entity_id=' . $entity_id),
+ 'lang_view_standardtext'
=> lang('view the category'),
+ 'lang_status_standardtext'
=> lang('Status for the entity category'),
+ 'lang_attribute_standardtext'
=> lang('attributes for the entity category'),
+
'lang_custom_function_standardtext' => lang('custom functions for the
entity category'),
+ 'lang_edit_standardtext'
=> lang('edit the standard'),
+ 'lang_delete_standardtext'
=> lang('delete the standard'),
+ 'text_status'
=> lang('Status'),
+ 'text_attribute'
=> lang('Attributes'),
+ 'text_custom_function'
=> lang('Custom functions'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+ }
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+
+ 'lang_descr' => lang('Descr'),
+ 'lang_prefix' => lang('prefix'),
+// 'lang_status' => lang('Status'),
+ 'lang_attribute' => lang('Attributes'),
+ 'lang_custom_function' => lang('custom
functions'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_id' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'id',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.category',
+
'entity_id' =>$entity_id,
+
'allrows'=>$this->allrows)
+
)),
+ 'lang_id' => lang('category id'),
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.category',
+
'entity_id' =>$entity_id,
+
'allrows'=>$this->allrows)
+
)),
+ 'lang_name' => lang('Name'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_standardtext' => lang('add a
category'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_category&entity_id='
. $entity_id),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_standardtext' => lang('back
to entity'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.index')
+ );
+
+ $entity = $this->bo->read_single($entity_id,false);
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.category',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'query'
=>$this->query,
+ 'entity_id'
=>$entity_id
+ );
+
+ $data = array
+ (
+ 'lang_entity'
=> lang('entity'),
+ 'entity_name'
=> $entity['name'],
+ 'links'
=> $links,
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'num_records'
=> count($category_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_standardtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_standardtext' =>
lang('Submit the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_category' =>
$table_header,
+ 'values_category'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('entity');
+ $function_msg =
lang('list entity type');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_category' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit()
+ {
+ $id = get_var('id',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+ $config =
CreateObject('phpgwapi.config',$this->currentapp);
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
+
+ if ($values['save'])
+ {
+ if (!$values['name'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Name not entered!'));
+ }
+
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+
+ if (!$receipt['error'])
+ {
+
+ $receipt =
$this->bo->save($values,$action);
+ if(!$id)
+ {
+ $id=$receipt['id'];
+ }
+ $config->read_repository();
+
+
if(!is_array($config->config_data['location_form']))
+ {
+
$config->config_data['location_form'] = array();
+ }
+
+ if($values['location_form'])
+ {
+
+
$config->config_data['location_form']['entity_' . $id] = 'entity_' . $id;
+
+ }
+ else
+ {
+
unset($config->config_data['location_form']['entity_' . $id]);
+ }
+
+ $config->save_repository();
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'=>
lang('Entity has NOT been saved'));
+ }
+
+ }
+
+
+ if ($id)
+ {
+ $values = $this->bo->read_single($id);
+ $function_msg = lang('edit standard');
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add entity');
+ $action='add';
+ }
+
+ $include_list =
$this->bo->get_entity_list($values['lookup_entity']);
+ $include_list_2 =
$this->bo->get_entity_list_2($values['include_entity_for']);
+ $include_list_3 =
$this->bo->get_entity_list_3($values['start_entity_from']);
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit',
+ 'id' => $id
+ );
+//_debug_array($include_list);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'lang_name_standardtext' =>
lang('Enter a name of the standard'),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.index'),
+ 'lang_id'
=> lang('standard ID'),
+ 'lang_name'
=> lang('Name'),
+ 'lang_descr'
=> lang('Descr'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+ 'value_name'
=> $values['name'],
+ 'lang_id_standardtext' =>
lang('Enter the standard ID'),
+ 'lang_descr_standardtext' =>
lang('Enter a description of the standard'),
+ 'lang_done_standardtext' =>
lang('Back to the list'),
+ 'lang_save_standardtext' =>
lang('Save the standard'),
+ 'type_id'
=> $values['type_id'],
+ 'value_descr'
=> $values['descr'],
+ 'lang_location_form' =>
lang('location form'),
+ 'value_location_form' =>
$values['location_form'],
+ 'lang_location_form_statustext' => lang('If
this entity type is to be linked to a location'),
+ 'lang_include_in_location_form' =>
lang('include in location form'),
+ 'include_list'
=> $include_list,
+ 'lang_include_statustext' =>
lang('Which entity type is to show up in location forms'),
+ 'lang_include_this_entity' =>
lang('include this entity'),
+ 'include_list_2'
=> $include_list_2,
+ 'lang_include_2_statustext' =>
lang('Let this entity show up in location form'),
+ 'lang_start_this_entity' =>
lang('start this entity'),
+ 'include_list_3'
=> $include_list_3,
+ 'lang_include_3_statustext' =>
lang('Start this entity from'),
+ 'lang_select'
=> lang('select'),
+ 'lang_documentation' =>
lang('documentation'),
+ 'value_documentation' =>
$values['documentation'],
+ 'lang_documentation_statustext' => lang('If
this entity type is to be linked to documents'),
+ );
+
+ $appname
= lang('entity');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function edit_status()
+ {
+ $id = get_var('id',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
+
+ if ($values['save'])
+ {
+ if (!$values['id'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('ID not entered!'));
+ }
+
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+
+ if (!$receipt['error'])
+ {
+ $receipt =
$this->bo->save_status($values,$action);
+ if(!$id)
+ {
+ $id=$receipt['id'];
+ }
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'=>
lang('Status has NOT been saved'));
+ }
+
+ }
+
+ if ($id)
+ {
+ $values = $this->bo->read_single_status($id);
+ $function_msg = lang('edit status');
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add status');
+ $action='add';
+ }
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit_status',
+ 'entity_id' => $this->entity_id,
+ 'cat_id' => $this->cat_id,
+ 'id' => $id
+ );
+//_debug_array($link_data);
+
+ $entity =
$this->bo->read_single($this->entity_id,false);
+ $category =
$this->bo->read_single_category($this->entity_id,$this->cat_id);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'lang_entity'
=> lang('entity'),
+ 'entity_name'
=> $entity['name'],
+ 'lang_category'
=> lang('category'),
+ 'category_name'
=> $category['name'],
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'lang_name_standardtext' =>
lang('Enter a name of the standard'),
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_status&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id),
+ 'lang_id'
=> lang('status ID'),
+ 'lang_descr'
=> lang('Descr'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+ 'lang_id_standardtext' =>
lang('Enter the status ID'),
+ 'lang_descr_standardtext' =>
lang('Enter a description of the status'),
+ 'lang_done_standardtext' =>
lang('Back to the list'),
+ 'lang_save_standardtext' =>
lang('Save the status'),
+ 'value_descr'
=> $values['descr']
+ );
+
+ $appname
= lang('entity');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_status' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function edit_category()
+ {
+ $entity_id =
get_var('entity_id',array('POST','GET'));
+ $id = get_var('id',array('POST','GET'));
+ $values =
get_var('values',array('POST'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
+
+ if ($values['save'])
+ {
+ $values['entity_id'] = $entity_id;
+
+ if (!$values['name'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Name not entered!'));
+ }
+ if (!$values['entity_id'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Entity not choosen'));
+ }
+
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+
+ if (!$receipt['error'])
+ {
+ $receipt =
$this->bo->save_category($values,$action);
+ if(!$id)
+ {
+ $id=$receipt['id'];
+ }
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'=>
lang('Category has NOT been saved'));
+ }
+
+ }
+
+ if ($id)
+ {
+ $values =
$this->bo->read_single_category($entity_id,$id);
+ $function_msg = lang('edit category');
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add category');
+ $action='add';
+ }
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit_category',
+ 'entity_id' =>$entity_id,
+ 'id' => $id
+ );
+//_debug_array($link_data);
+
+ $entity = $this->bo->read_single($entity_id,false);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'lang_entity'
=> lang('entity'),
+ 'entity_name'
=> $entity['name'],
+ 'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'lang_prefix_standardtext' =>
lang('Enter a standard prefix for the id'),
+ 'lang_name_standardtext' =>
lang('Enter a name of the standard'),
+
+ 'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='
. $entity_id),
+ 'lang_id'
=> lang('Category'),
+ 'lang_name'
=> lang('Name'),
+ 'lang_descr'
=> lang('Descr'),
+ 'lang_prefix'
=> lang('Prefix'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+ 'value_name'
=> $values['name'],
+ 'value_prefix'
=> $values['prefix'],
+ 'lang_id_standardtext' =>
lang('Enter the standard ID'),
+ 'lang_descr_standardtext' =>
lang('Enter a description of the standard'),
+ 'lang_done_standardtext' =>
lang('Back to the list'),
+ 'lang_save_standardtext' =>
lang('Save the standard'),
+ 'type_id'
=> $values['type_id'],
+ 'value_descr'
=> $values['descr'],
+ 'lang_lookup_tenant' =>
lang('lookup tenant'),
+ 'value_lookup_tenant' =>
$values['lookup_tenant'],
+ 'lang_lookup_tenant_statustext' => lang('If
this entity type is to look up tenants'),
+ 'lang_location_level' =>
lang('location level'),
+ 'location_level_list' =>
$this->bo->get_location_level_list($values['location_level']),
+ 'lang_location_level_statustext' =>
lang('select location level'),
+ 'lang_no_location_level' =>
lang('None'),
+ 'lang_tracking'
=> lang('tracking'),
+ 'value_tracking'
=> $values['tracking'],
+ 'lang_tracking_statustext' =>
lang('If this entity type is to be tracket in ticket list'),
+ 'lang_fileupload'
=> lang('Enable file upload'),
+ 'value_fileupload'
=> $values['fileupload'],
+ 'lang_fileupload_statustext' => lang('If
files can be uploaded for this category'),
+ 'lang_loc_link'
=> lang('Link from location'),
+ 'value_loc_link'
=> $values['loc_link'],
+ 'lang_loc_link_statustext' =>
lang('Enable link from location detail'),
+ 'lang_start_project' =>
lang('Start project'),
+ 'value_start_project' =>
$values['start_project'],
+ 'lang_start_project_statustext' => lang('Enable
start project from this category')
+ );
+
+ $appname
= lang('entity');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function delete()
+ {
+ $entity_id =
get_var('entity_id',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $attrib_id =
get_var('attrib_id',array('POST','GET'));
+ $status_id =
get_var('status_id',array('POST','GET'));
+ $acl_location =
get_var('acl_location',array('POST','GET'));
+ $custom_function_id =
get_var('custom_function_id',array('POST','GET'));
+ $confirm = get_var('confirm',array('POST'));
+
+ if($attrib_id):
+ {
+ $function='list_attribute';
+ }
+ elseif($custom_function_id):
+ {
+ $function='list_custom_function';
+ }
+ endif;
+
+ if (!$acl_location && $entity_id && $cat_id)
+ {
+ $acl_location = '.entity.' . $entity_id . '.' .
$cat_id;
+ }
+
+ if(!$function)
+ {
+ if($cat_id)
+ {
+ if($status_id)
+ {
+ $function='list_status';
+ }
+ else
+ {
+ $function='category';
+ }
+ }
+ else
+ {
+ $function='index';
+ }
+ }
+
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.'.$function,
+ 'cat_id' => $cat_id,
+ 'entity_id' => $entity_id,
+ 'attrib_id' => $attrib_id,
+ 'status_id' => $status_id
+ );
+
+ $delete_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.delete',
+ 'cat_id' => $cat_id,
+ 'entity_id' => $entity_id,
+ 'attrib_id' => $attrib_id,
+ 'status_id' => $status_id,
+ 'acl_location' => $acl_location,
+ 'custom_function_id' => $custom_function_id
+ );
+
+ if (get_var('confirm',array('POST')))
+ {
+
$this->bo->delete($cat_id,$entity_id,$attrib_id,$status_id,$acl_location,$custom_function_id);
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
+ }
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('app_delete'));
+
+ $data = array
+ (
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'delete_action' =>
$GLOBALS['phpgw']->link('/index.php',$delete_data),
+ 'lang_confirm_msg' => lang('do you
really want to delete this entry'),
+ 'lang_yes' =>
lang('yes'),
+ 'lang_yes_standardtext' => lang('Delete the
entry'),
+ 'lang_no_standardtext' => lang('Back to the
list'),
+ 'lang_no' =>
lang('no')
+ );
+
+ $appname
= lang('entity');
+ $function_msg =
lang('delete entity type');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+
+ function list_attribute()
+ {
+ $entity_id = $this->entity_id;
+ $cat_id = $this->cat_id;
+ $id = get_var('id',array('POST','GET'));
+ $resort = get_var('resort',array('POST','GET'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+
'admin_entity',
+
'nextmatchs',
+
'search_field'));
+
+ if($resort)
+ {
+ $this->bo->resort_attrib($id,$resort);
+ }
+ $attrib_list =
$this->bo->read_attrib($entity_id,$cat_id);
+
+ if (isset($attrib_list) AND is_array($attrib_list))
+ {
+ foreach($attrib_list as $entry)
+ {
+
+ $content[] = array
+ (
+ 'name'
=> $entry['name'],
+ 'datatype'
=> $entry['datatype'],
+ 'column_name'
=> $entry['column_name'],
+ 'input_text'
=> $entry['input_text'],
+ 'sorting'
=> $entry['attrib_sort'],
+ 'search'
=> $entry['search'],
+ 'link_up'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_attribute&resort=up&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id'] . '&allrows=' .
$this->allrows),
+ 'link_down'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_attribute&resort=down&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id'] . '&allrows=' .
$this->allrows),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_attrib&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id']),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&attrib_id=' . $entry['id']),
+ 'lang_up_text'
=> lang('shift up'),
+ 'lang_down_text'
=> lang('shift down'),
+ 'lang_edit_text'
=> lang('edit the attrib'),
+ 'lang_delete_text'
=> lang('delete the attrib'),
+ 'text_attribute'
=> lang('Attributes'),
+ 'text_up'
=> lang('up'),
+ 'text_down'
=> lang('down'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+ }
+
+//_debug_array($content);
+
+ $table_header[] = array
+ (
+ 'lang_descr' => lang('Descr'),
+ 'lang_datatype' => lang('Datatype'),
+ 'lang_sorting' => lang('sorting'),
+ 'lang_search' => lang('search'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'column_name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.list_attribute',
+
'entity_id'
=>$entity_id,
+
'cat_id'
=>$cat_id,
+
'allrows'=>$this->allrows)
+
)),
+ 'sort_sorting' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'attrib_sort',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.list_attribute',
+
'entity_id'
=>$entity_id,
+
'cat_id'
=>$cat_id,
+
'allrows'=>$this->allrows)
+
)),
+ 'lang_name' => lang('Name'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_attribtext' => lang('add a attrib'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_attrib&entity_id='.$entity_id
. '&cat_id=' . $cat_id),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_attribtext' => lang('back to
admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='.$entity_id),
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.list_attribute',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'query'
=>$this->query,
+ 'entity_id'
=>$entity_id,
+ 'cat_id'
=>$cat_id
+ );
+
+ $entity = $this->bo->read_single($entity_id,false);
+ $category =
$this->bo->read_single_category($entity_id,$cat_id);
+
+ $data = array
+ (
+ 'lang_entity'
=> lang('entity'),
+ 'entity_name'
=> $entity['name'],
+ 'lang_category'
=> lang('category'),
+ 'category_name'
=> $category['name'],
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'start_record'
=> $this->start,
+ 'num_records'
=> count($attrib_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_attribtext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
+ 'lang_searchbutton_attribtext' => lang('Submit
the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_attrib' =>
$table_header,
+ 'values_attrib'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('attribute');
+ $function_msg =
lang('list entity attribute');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_attribute' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit_attrib()
+ {
+ $entity_id =
get_var('entity_id',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $id =
get_var('id',array('POST','GET'));
+ $values = get_var('values',array('POST'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
+
+ if ($values['save'])
+ {
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+
+ $values['entity_id']=$entity_id;
+ $values['cat_id']=$cat_id;
+
+ if (!$values['column_name'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Column name not entered!'));
+ }
+
+ if (!$values['input_text'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Input text not entered!'));
+ }
+ if (!$values['statustext'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Statustext not entered!'));
+ }
+
+ if (!$values['entity_id'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('entity type not choosen!'));
+ }
+
+ if (!$values['column_info']['type'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Datatype type not choosen!'));
+ }
+
+
if(!ctype_digit($values['column_info']['precision']))
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter precision as integer !'));
+
unset($values['column_info']['precision']);
+ }
+
+
if(!ctype_digit($values['column_info']['scale']))
+ {
+
$receipt['error'][]=array('msg'=>lang('Please enter scale as integer !'));
+ unset($values['column_info']['scale']);
+ }
+
+ if (!$values['column_info']['nullable'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('Nullable not choosen!'));
+ }
+
+
+ if (!$receipt['error'])
+ {
+
+ $receipt =
$this->bo->save_attrib($values,$action);
+
+ if(!$id)
+ {
+ $id=$receipt['id'];
+ }
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'
=> lang('Attribute has NOT been saved'));
+ }
+
+ }
+
+ if ($id)
+ {
+ $values =
$this->bo->read_single_attrib($entity_id,$cat_id,$id);
+ $type_name=$values['type_name'];
+ $function_msg = lang('edit attribute'). ' ' .
lang($type_name);
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add attribute');
+ $action='add';
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit_attrib',
+ 'entity_id' => $entity_id,
+ 'cat_id' => $cat_id,
+ 'id' => $id
+ );
+
+ if($values['column_info']['type']=='R' ||
$values['column_info']['type']=='CH' || $values['column_info']['type']=='LB')
+ {
+ $multiple_choice= True;
+ }
+
+//_debug_array($values);
+
+ $entity = $this->bo->read_single($entity_id,false);
+ $category =
$this->bo->read_single_category($entity_id,$cat_id);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'lang_entity'
=> lang('entity'),
+ 'entity_name'
=> $entity['name'],
+ 'lang_category'
=> lang('category'),
+ 'category_name'
=> $category['name'],
+
+ 'lang_choice' =>
lang('Choice'),
+ 'lang_new_value' =>
lang('New value'),
+ 'lang_new_value_statustext' => lang('New
value for mulitple choice'),
+ 'multiple_choice' =>
$multiple_choice,
+ 'value_choice' =>
$values['choice'],
+ 'lang_delete_value' =>
lang('Delete value'),
+ 'lang_value' =>
lang('value'),
+ 'lang_delete_choice_statustext'=> lang('Delete
this value from the list of multiple choice'),
+
+ 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_attribute&entity_id='.$entity_id
. '&cat_id='.$cat_id),
+ 'lang_id'
=> lang('Attribute ID'),
+ 'lang_entity_type' =>
lang('Entity type'),
+ 'lang_no_entity_type' => lang('No
entity type'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+
+ 'lang_column_name'
=> lang('Column name'),
+ 'value_column_name'
=> $values['column_name'],
+ 'lang_column_name_statustext' => lang('enter
the name for the column'),
+
+ 'lang_input_text'
=> lang('input text'),
+ 'value_input_text'
=> $values['input_text'],
+ 'lang_input_name_statustext' => lang('enter
the input text for records'),
+
+ 'lang_id_attribtext' => lang('Enter
the attribute ID'),
+ 'lang_entity_statustext' => lang('Select
a entity type'),
+
+ 'lang_statustext' =>
lang('Statustext'),
+ 'lang_statustext_attribtext'=> lang('Enter a
statustext for the inputfield in forms'),
+ 'value_statustext' =>
$values['statustext'],
+
+ 'lang_done_attribtext' => lang('Back
to the list'),
+ 'lang_save_attribtext' => lang('Save
the attribute'),
+
+ 'lang_datatype' =>
lang('Datatype'),
+ 'lang_datatype_statustext' => lang('Select
a datatype'),
+ 'lang_no_datatype' =>
lang('No datatype'),
+ 'datatype_list' =>
$this->bocommon->select_datatype($values['column_info']['type']),
+
+ 'lang_precision' =>
lang('Precision'),
+ 'lang_precision_statustext' => lang('enter
the record length'),
+ 'value_precision' =>
$values['column_info']['precision'],
+
+ 'lang_scale' =>
lang('scale'),
+ 'lang_scale_statustext' => lang('enter
the scale if type is decimal'),
+ 'value_scale' =>
$values['column_info']['scale'],
+
+ 'lang_default' =>
lang('default'),
+ 'lang_default_statustext' => lang('enter
the default value'),
+ 'value_default' =>
$values['column_info']['default'],
+
+ 'lang_nullable' =>
lang('Nullable'),
+ 'lang_nullable_statustext' => lang('Chose
if this column is nullable'),
+ 'lang_select_nullable' => lang('Select
nullable'),
+ 'nullable_list' =>
$this->bocommon->select_nullable($values['column_info']['nullable']),
+ 'value_lookup_form' =>
$values['lookup_form'],
+ 'lang_lookup_form'
=> lang('show in lookup forms'),
+ 'lang_lookup_form_statustext'
=> lang('check to show this attribue in lookup forms'),
+ 'value_list' =>
$values['list'],
+ 'lang_list' =>
lang('show in list'),
+ 'lang_list_statustext' =>
lang('check to show this attribute in entity list'),
+ 'value_search' =>
$values['search'],
+ 'lang_include_search' =>
lang('Include in search'),
+ 'lang_include_search_statustext'=> lang('check
to show this attribute in location list'),
+
+ );
+//_debug_array($values);
+
+ $appname
= lang('entity');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_attrib' => $data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ }
+
+ function list_custom_function()
+ {
+ $entity_id = $this->entity_id;
+ $cat_id = $this->cat_id;
+ $id = get_var('id',array('POST','GET'));
+ $resort = get_var('resort',array('POST','GET'));
+
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+
'admin_entity',
+
'nextmatchs',
+
'search_field'));
+
+ if($resort)
+ {
+ $this->bo->resort_custom_function($id,$resort);
+ }
+ $custom_function_list =
$this->bo->read_custom_function($entity_id,$cat_id);
+
+ if (isset($custom_function_list) AND
is_array($custom_function_list))
+ {
+ foreach($custom_function_list as $entry)
+ {
+
+ $content[] = array
+ (
+ 'file_name'
=> $entry['file_name'],
+ 'descr'
=> $entry['descr'],
+ 'sorting'
=> $entry['sorting'],
+ 'active'
=> $entry['active']?'X':'',
+ 'link_up'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_custom_function&resort=up&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id'] . '&allrows=' .
$this->allrows),
+ 'link_down'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_custom_function&resort=down&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id'] . '&allrows=' .
$this->allrows),
+ 'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_custom_function&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&id=' . $entry['id']),
+ 'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.delete&entity_id='
. $entity_id . '&cat_id=' . $cat_id . '&custom_function_id=' . $entry['id']),
+ 'lang_up_text'
=> lang('shift up'),
+ 'lang_down_text'
=> lang('shift down'),
+ 'lang_edit_text'
=> lang('edit the custom_function'),
+ 'lang_delete_text'
=> lang('delete the custom_function'),
+ 'text_custom_function'
=> lang('custom_functions'),
+ 'text_up'
=> lang('up'),
+ 'text_down'
=> lang('down'),
+ 'text_edit'
=> lang('edit'),
+ 'text_delete'
=> lang('delete')
+ );
+ }
+ }
+
+ $table_header[] = array
+ (
+ 'lang_descr' => lang('Descr'),
+ 'lang_active' => lang('Active'),
+ 'lang_sorting' => lang('sorting'),
+ 'lang_search' => lang('search'),
+ 'lang_edit' => lang('edit'),
+ 'lang_delete' => lang('delete'),
+ 'sort_name' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'column_name',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.list_custom_function',
+
'entity_id'
=>$entity_id,
+
'cat_id'
=>$cat_id,
+
'allrows'=>$this->allrows)
+
)),
+ 'sort_sorting' =>
$this->nextmatchs->show_sort_order(array
+
(
+
'sort' => $this->sort,
+
'var' => 'custom_function_sort',
+
'order' => $this->order,
+
'extra' => array('menuaction' =>
$this->currentapp.'.uiadmin_entity.list_custom_function',
+
'entity_id'
=>$entity_id,
+
'cat_id'
=>$cat_id,
+
'allrows'=>$this->allrows)
+
)),
+ 'lang_name' => lang('Name'),
+ );
+
+ $table_add[] = array
+ (
+ 'lang_add' =>
lang('add'),
+ 'lang_add_custom_functiontext' => lang('add a
custom_function'),
+ 'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.edit_custom_function&entity_id='.$entity_id
. '&cat_id=' . $cat_id),
+ 'lang_done' =>
lang('done'),
+ 'lang_done_custom_functiontext' => lang('back
to admin'),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.category&entity_id='.$entity_id),
+ );
+
+ if(!$this->allrows)
+ {
+ $record_limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ }
+ else
+ {
+ $record_limit = $this->bo->total_records;
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.list_custom_function',
+ 'sort'
=>$this->sort,
+ 'order'
=>$this->order,
+ 'query'
=>$this->query,
+ 'entity_id'
=>$entity_id,
+ 'cat_id'
=>$cat_id
+ );
+
+ $entity = $this->bo->read_single($entity_id,false);
+ $category =
$this->bo->read_single_category($entity_id,$cat_id);
+
+ $data = array
+ (
+ 'lang_entity'
=> lang('entity'),
+ 'entity_name'
=> $entity['name'],
+ 'lang_category'
=> lang('category'),
+ 'category_name'
=> $category['name'],
+ 'allow_allrows'
=> True,
+ 'allrows'
=> $this->allrows,
+ 'start_record'
=> $this->start,
+ 'record_limit'
=> $record_limit,
+ 'start_record'
=> $this->start,
+ 'num_records'
=> count($custom_function_list),
+ 'all_records'
=> $this->bo->total_records,
+ 'link_url'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'img_path'
=> $GLOBALS['phpgw']->common->get_image_path('phpgwapi','default'),
+ 'lang_searchfield_custom_functiontext' =>
lang('Enter the search string. To show all entries, empty this field and press
the SUBMIT button again'),
+ 'lang_searchbutton_custom_functiontext' =>
lang('Submit the search string'),
+ 'query'
=> $this->query,
+ 'lang_search'
=> lang('search'),
+ 'table_header_custom_function'
=> $table_header,
+ 'values_custom_function'
=> $content,
+ 'table_add'
=> $table_add
+ );
+
+ $appname
= lang('custom function');
+ $function_msg =
lang('list entity custom function');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_custom_function' =>
$data));
+ // $GLOBALS['phpgw']->xslttpl->pp();
+ $this->save_sessiondata();
+ }
+
+ function edit_custom_function()
+ {
+ $entity_id =
get_var('entity_id',array('POST','GET'));
+ $cat_id = get_var('cat_id',array('POST','GET'));
+ $id =
get_var('id',array('POST','GET'));
+ $values = get_var('values',array('POST'));
+
+
$GLOBALS['phpgw']->xslttpl->add_file(array('admin_entity'));
+
+ if ($values['save'])
+ {
+ if($id)
+ {
+ $values['id']=$id;
+ $action='edit';
+ }
+
+ $values['entity_id']=$entity_id;
+ $values['cat_id']=$cat_id;
+
+
+ if (!$values['entity_id'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('entity type not choosen!'));
+ }
+
+ if (!$values['custom_function_file'])
+ {
+ $receipt['error'][] =
array('msg'=>lang('custom function file not choosen!'));
+ }
+
+
+ if (!$receipt['error'])
+ {
+
+ $receipt =
$this->bo->save_custom_function($values,$action);
+
+ if(!$id)
+ {
+ $id=$receipt['id'];
+ }
+ }
+ else
+ {
+ $receipt['error'][] = array('msg'
=> lang('Custom function has NOT been saved'));
+ }
+
+ }
+
+ if ($id)
+ {
+ $values =
$this->bo->read_single_custom_function($entity_id,$cat_id,$id);
+ $type_name=$values['type_name'];
+ $function_msg = lang('edit custom function'). '
' . lang($type_name);
+ $action='edit';
+ }
+ else
+ {
+ $function_msg = lang('add custom function');
+ $action='add';
+ }
+
+ $link_data = array
+ (
+ 'menuaction' =>
$this->currentapp.'.uiadmin_entity.edit_custom_function',
+ 'entity_id' => $entity_id,
+ 'cat_id' => $cat_id,
+ 'id' => $id
+ );
+
+
+//_debug_array($values);
+
+ $entity = $this->bo->read_single($entity_id,false);
+ $category =
$this->bo->read_single_category($entity_id,$cat_id);
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $data = array
+ (
+ 'lang_entity'
=> lang('entity'),
+ 'entity_name'
=> $entity['name'],
+ 'lang_category'
=> lang('category'),
+ 'category_name'
=> $category['name'],
+
+ 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
+ 'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiadmin_entity.list_custom_function&entity_id='.$entity_id
. '&cat_id='.$cat_id),
+ 'lang_id'
=> lang('Custom function ID'),
+ 'lang_entity_type' =>
lang('Entity type'),
+ 'lang_no_entity_type' => lang('No
entity type'),
+ 'lang_save'
=> lang('save'),
+ 'lang_done'
=> lang('done'),
+ 'value_id'
=> $id,
+
+ 'lang_descr' =>
lang('descr'),
+ 'lang_descr_custom_functiontext'=> lang('Enter
a descr for the custom function'),
+ 'value_descr' =>
$values['descr'],
+
+ 'lang_done_custom_functiontext' =>
lang('Back to the list'),
+ 'lang_save_custom_functiontext' =>
lang('Save the custom function'),
+
+ 'lang_custom_function'
=> lang('custom function'),
+ 'lang_custom_function_statustext' =>
lang('Select a custom_function'),
+ 'lang_no_custom_function'
=> lang('No custom function'),
+ 'custom_function_list'
=> $this->bo->select_custom_function($values['custom_function_file']),
+
+ 'value_active' =>
$values['active'],
+ 'lang_active' =>
lang('Active'),
+ 'lang_active_statustext' => lang('check
acivate custom function'),
+ 'value_search' =>
$values['search'],
+ 'lang_include_search' =>
lang('Include in search'),
+ 'lang_include_search_statustext'=> lang('check
to show this custom function in location list')
+ );
+
+ $appname
= lang('entity');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_custom_function' =>
$data));
+ }
+
+ }
+?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] property/inc class.boentity.inc.php, 1.7 class.boadmin_entity.inc.php, 1.8 class.soadmin_entity.inc.php, 1.8 class.uiadmin_entity.inc.php, 1.10,
sigurdne <=