[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property/inc class.boentity.inc.php, NONE, 1.1 class.
From: |
Sigurd Nes <address@hidden> |
Subject: |
[Phpgroupware-cvs] property/inc class.boentity.inc.php, NONE, 1.1 class.soentity.inc.php, NONE, 1.1 class.uientity.inc.php, NONE, 1.1 class.bocommon.inc.php, 1.85, 1.86 class.soadmin_entity.inc.php, 1.2, 1.3 class.uiadmin_entity.inc.php, 1.2, 1.3 class.boadmin_entity.inc.php, 1.1, 1.2 |
Date: |
Sat, 18 Oct 2003 22:15:54 +0000 |
Update of /cvsroot/phpgroupware/property/inc
In directory subversions:/tmp/cvs-serv30781/inc
Modified Files:
class.bocommon.inc.php class.soadmin_entity.inc.php
class.uiadmin_entity.inc.php class.boadmin_entity.inc.php
Added Files:
class.boentity.inc.php class.soentity.inc.php
class.uientity.inc.php
Log Message:
no message
Index: class.bocommon.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.bocommon.inc.php,v
retrieving revision 1.85
retrieving revision 1.86
diff -C2 -d -r1.85 -r1.86
*** class.bocommon.inc.php 15 Oct 2003 17:27:38 -0000 1.85
--- class.bocommon.inc.php 18 Oct 2003 22:15:51 -0000 1.86
***************
*** 952,958 ****
function add_leading_zero($num)
{
- //echo 'num ' .$num .'<br>' ;
- // $id_type = "hex";
- // global $id_type;
if ($id_type == "hex")
--- 952,955 ----
--- NEW FILE: class.boentity.inc.php ---
<?php
/***************************************************************************\
* This program is free software; you can redistribute it and/or modify
it *
* under the terms of the GNU General Public License as published by the
*
* Free Software Foundation; either version 2 of the License, or (at
your *
* option) any later version.
*
\***************************************************************************/
class 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->soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
$this->solocation =
CreateObject($this->currentapp.'.solocation');
$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'));
$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'));
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));
//_debug_array($columns);
$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 filter($selected='')
{
$GLOBALS['phpgw']->xslttpl->add_file(array('filter_filter'));
if($this->cat_id)
{
$filters=
$this->so->get_filter_list($this->cat_id);
}
while (is_array($filters) && list(,$filter) =
each($filters))
{
$sel_filter = '';
if ($filter['id']==$selected)
{
$sel_filter = 'selected';
}
$filter_list[] = array
(
'id' => $filter['id'],
'name' => $filter['name'],
'selected' => $sel_filter
);
}
for ($i=0;$i<count($filter_list);$i++)
{
if ($filter_list[$i]['selected'] != 'selected')
{
unset($filter_list[$i]['selected']);
}
}
return $filter_list;
}
function read()
{
$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));
$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;
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)
{
$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'])
{
$location_data=$this->solocation->read_single($entity['location_code']);
$entity['location_data'] = $location_data;
}
$soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
$input_type_array = array(
'R' => 'radio',
'CH' => 'checkbox',
);
$sep = '/';
$dlarr[strpos($dateformat,'Y')] = 'Y';
$dlarr[strpos($dateformat,'m')] = 'm';
$dlarr[strpos($dateformat,'d')] = 'd';
ksort($dlarr);
$dateformat= (implode($sep,$dlarr));
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']=='R'
|| $entity['attributes'][$i]['datatype']=='CH')
{
$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]['lang_attribute_statustext'] = lang('Enter the
attribute value for this entity');
$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'];
}
//_debug_array($entity);
return $entity;
}
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'])
{
//_debug_array($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);
}
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 )
{
return $this->so->generate_id($data);
}
function read_attibutes($data)
{
$soadmin_entity =
CreateObject($this->currentapp.'.soadmin_entity');
if($data['form'])
{
$GLOBALS['phpgw']->xslttpl->add_file(array('attributes_form'));
}
else
{
$GLOBALS['phpgw']->xslttpl->add_file(array('attributes_view'));
}
$input_type_array = array(
'R' => 'radio',
'CH' => 'checkbox',
);
$attributes_values =
$this->so->read_attibutes($data);
$dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
$sep = '/';
$dlarr[strpos($dateformat,'Y')] = 'Y';
$dlarr[strpos($dateformat,'m')] = 'm';
$dlarr[strpos($dateformat,'d')] = 'd';
ksort($dlarr);
$dateformat= (implode($sep,$dlarr));
for ($i=0;$i<count($attributes_values);$i++)
{
if($attributes_values[$i]['datatype']=='D' &&
$attributes_values[$i]['value'])
{
$timestamp_date=
mktime(0,0,0,date(m,strtotime($attributes_values[$i]['value'])),date(d,strtotime($attributes_values[$i]['value'])),date(y,strtotime($attributes_values[$i]['value'])));
$attributes_values[$i]['value'] =
$GLOBALS['phpgw']->common->show_date($timestamp_date,$dateformat);
}
if($attributes_values[$i]['datatype']=='R' ||
$attributes_values[$i]['datatype']=='CH')
{
$attributes_values[$i]['choice']
=
$soadmin_entity->read_attrib_choice($data['entity_id'],$data['cat_id'],$attributes_values[$i]['attrib_id']);
$input_type=$input_type_array[$attributes_values[$i]['datatype']];
if($attributes_values[$i]['datatype']=='CH')
{
$attributes_values[$i]['value']=unserialize($attributes_values[$i]['value']);
$attributes_values[$i]['choice'] =
$this->bocommon->select_multi_list_2($attributes_values[$i]['value'],$attributes_values[$i]['choice'],$input_type);
}
else
{
for
($j=0;$j<count($attributes_values[$i]['choice']);$j++)
{
$attributes_values[$i]['choice'][$j]['input_type']=$input_type;
if($attributes_values[$i]['choice'][$j]['id']==$attributes_values[$i]['value'])
{
$attributes_values[$i]['choice'][$j]['checked']='checked';
}
}
}
}
$attributes_values[$i]['lang_attribute_statustext'] = lang('Enter the attribute
value for this entity');
$attributes_values[$i]['datatype_text'] =
$this->bocommon->translate_datatype($attributes_values[$i]['datatype']);
$attributes_values[$i]['counter'] = $i;
$attributes_values[$i]['type_id'] =
$data['type_id'];
}
return $attributes_values;
}
}
?>
Index: class.boadmin_entity.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.boadmin_entity.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** class.boadmin_entity.inc.php 10 Oct 2003 21:57:15 -0000 1.1
--- class.boadmin_entity.inc.php 18 Oct 2003 22:15:51 -0000 1.2
***************
*** 61,64 ****
--- 61,65 ----
$order = get_var('order',array('POST','GET'));
$filter = get_var('filter',array('POST','GET'));
+ $entity_id =
get_var('entity_id',array('POST','GET'));
$cat_id = get_var('cat_id',array('POST','GET'));
$allrows =
get_var('allrows',array('POST','GET'));
***************
*** 93,96 ****
--- 94,101 ----
$this->cat_id = $cat_id;
}
+ if(isset($entity_id))
+ {
+ $this->entity_id = $entity_id;
+ }
if(isset($allrows))
{
***************
*** 120,123 ****
--- 125,129 ----
$this->order = $data['order'];
$this->cat_id = $data['cat_id'];
+ $this->entity_id = $data['entity_id'];
$this->allrows = $data['allrows'];
}
***************
*** 147,150 ****
--- 153,166 ----
}
+ 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()
{
***************
*** 167,173 ****
}
! function read_single_category($id,$entity_id)
{
! return $this->so->read_single_category($id,$entity_id);
}
--- 183,194 ----
}
! 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);
}
***************
*** 204,226 ****
}
! function delete($cat_id='',$entity_id='',$attrib_id='')
{
! if(!$attrib_id && !$cat_id && $entity_id):
{
$this->so->delete_entity($entity_id);
}
! elseif(!$attrib_id && $cat_id && $entity_id):
{
$this->so->delete_category($cat_id,$entity_id);
}
! elseif($attrib_id && $cat_id && $entity_id):
{
$this->so->delete_attrib($cat_id,$entity_id,$attrib_id);
}
endif;
}
! function read_attrib($entity_id='',$cat_id='')
{
$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));
--- 225,272 ----
}
! 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));
Index: class.soadmin_entity.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.soadmin_entity.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** class.soadmin_entity.inc.php 15 Oct 2003 17:27:38 -0000 1.2
--- class.soadmin_entity.inc.php 18 Oct 2003 22:15:51 -0000 1.3
***************
*** 158,161 ****
--- 158,226 ----
}
+ 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 LIKE '%$query%' or
descr 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)
***************
*** 168,175 ****
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');
return $entity;
--- 233,240 ----
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');
return $entity;
***************
*** 177,183 ****
}
! function read_single_category($id,$entity_id)
{
! $sql = "SELECT * FROM fm_entity_category where id=$id
AND entity_id=$entity_id";
$this->db->query($sql,__LINE__,__FILE__);
--- 242,248 ----
}
! 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__);
***************
*** 189,192 ****
--- 254,258 ----
$category['descr'] =
$this->db->f('descr');
$category['prefix'] =
$this->db->f('prefix');
+ $category['lookup_vendor'] =
$this->db->f('lookup_vendor');
return $category;
***************
*** 194,197 ****
--- 260,280 ----
}
+ 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 next_id($table='',$key='')
***************
*** 241,244 ****
--- 324,351 ----
}
+
+ 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)
{
***************
*** 250,257 ****
$location_type = $this->next_id('fm_location_type');
$this->db->transaction_begin();
! $this->db->query("INSERT INTO fm_entity_category
(entity_id,id,name, descr,prefix) "
! . "VALUES ('" . $values['entity_id'] . "','" .
$values['id'] . "','" . $values['name'] . "','" . $values['descr'] . "','" .
$values['prefix']. "')",__LINE__,__FILE__);
$receipt['id']= $values['id'];
--- 357,376 ----
$location_type = $this->next_id('fm_location_type');
+ $values_insert= array(
+ $values['entity_id'],
+ $values['id'],
+ $values['name'],
+ $values['descr'],
+ $values['prefix'],
+ $values['lookup_vendor']
+ );
+
+ $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_vendor) "
! . "VALUES ($values_insert)",__LINE__,__FILE__);
$receipt['id']= $values['id'];
***************
*** 263,266 ****
--- 382,386 ----
$fd['num'] = array('type' => 'varchar', 'precision' =>
16, 'nullable' => False);
$fd['location_code'] = array('type' => 'varchar',
'precision' => 25, 'nullable' => True);
+ $fd['vendor_id'] = array('type' => 'int', 'precision'
=> 4, 'nullable' => True);
for ($i=1; $i<$location_type; $i++)
***************
*** 270,282 ****
$fd['address'] = array('type' => 'varchar', 'precision'
=> 100, 'nullable' => True);
$fd['entry_date'] = array('type' => 'int', 'precision'
=> 4, 'nullable' => True);
$fd['user_id'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
! $fd['remark'] = array('type' => 'text', 'nullable' =>
True);
$pk[]= 'id';
! if($this->oProc->CreateTable('fm_entity_'.
$values['entity_id'] .'_'.$values['id'],array('fd' => $fd,'pk' => $pk,'fk' =>
$fk,'ix' => array('location_code'),'uc' => array())))
{
! $receipt['message'][] = array('msg' =>
lang('table %1 has been saved','fm_entity_'. $values['entity_id']
.'_'.$values['id']) );
$this->db->transaction_commit();
}
--- 390,411 ----
$fd['address'] = array('type' => 'varchar', 'precision'
=> 100, 'nullable' => True);
+ $fd['status'] = array('type' => 'varchar', 'precision'
=> 20, 'nullable' => True);
$fd['entry_date'] = array('type' => 'int', 'precision'
=> 4, 'nullable' => True);
$fd['user_id'] = array('type' => 'int', 'precision' =>
4, 'nullable' => True);
! // $fd['remark'] = array('type' => 'text', 'nullable' =>
True);
$pk[]= 'id';
! $fd_status['id'] = array('type' => 'varchar',
'precision' => 20, 'nullable' => False);
! $fd_status['descr'] = array('type' => 'varchar',
'precision' => 255, 'nullable' => False);
! $pk_status[]= 'id';
!
! $table = 'fm_entity_'.
$values['entity_id'] .'_'.$values['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()))))
{
! $receipt['message'][] = array('msg' =>
lang('table %1 has been saved',$table));
$this->db->transaction_commit();
}
***************
*** 299,305 ****
}
! function edit_entity($entity)
{
if (!$entity['name'])
{
--- 428,452 ----
}
! 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'])
{
***************
*** 315,326 ****
! $value_set=array(
'descr' => $entity['descr'],
'name' => $entity['name'],
! 'location_form' => $entity['location_form']
);
! $value_set =
$this->bocommon->validate_db_update($value_set);
!
$this->db->query("UPDATE $table set $value_set
WHERE id=" . $entity['id'],__LINE__,__FILE__);
--- 462,473 ----
! $value_set=array(
'descr' => $entity['descr'],
'name' => $entity['name'],
! 'location_form' => $entity['location_form'],
! 'lookup_vendor' => $entity['lookup_vendor']
);
! $value_set =
$this->bocommon->validate_db_update($value_set);
$this->db->query("UPDATE $table set $value_set
WHERE id=" . $entity['id'],__LINE__,__FILE__);
***************
*** 351,356 ****
$entity['descr'] =
$this->db->db_addslashes($entity['descr']);
! $this->db->query("UPDATE $table set descr='" .
$entity['descr'] . "', name='". $entity['name'] . "', prefix='".
$entity['prefix']
! . "' WHERE entity_id=" .
$entity['entity_id']. " AND id=" . $entity['id'],__LINE__,__FILE__);
$receipt['message'][] = array('msg'=>
lang('entity has been edited'));
--- 498,511 ----
$entity['descr'] =
$this->db->db_addslashes($entity['descr']);
! $value_set=array(
! 'descr' =>
$entity['descr'],
! 'name' =>
$entity['name'],
! 'prefix' =>
$entity['prefix'],
! 'lookup_vendor' =>
$entity['lookup_vendor']
! );
!
! $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__);
$receipt['message'][] = array('msg'=>
lang('entity has been edited'));
***************
*** 385,388 ****
--- 540,544 ----
$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__);
}
***************
*** 403,406 ****
--- 559,569 ----
}
+ 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)
{
***************
*** 463,470 ****
--- 626,635 ----
'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('column_name'),
'size' =>
$this->db->f('size'),
'statustext' =>
$this->db->f('statustext'),
--- NEW FILE: class.soentity.inc.php ---
<?php
/***************************************************************************\
* This program is free software; you can redistribute it and/or modify
it *
* under the terms of the GNU General Public License as published by the
*
* Free Software Foundation; either version 2 of the License, or (at
your *
* option) any later version.
*
\***************************************************************************/
class soentity
{
function soentity()
{
$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->acl2 =
CreateObject($this->currentapp.'.acl2','##DEFAULT##','##DEFAULT##');
$this->join = $this->bocommon->join;
$this->left_join = $this->bocommon->left_join;
}
function select_status_list($entity_id,$cat_id)
{
if(!$entity_id || !$cat_id)
{
return;
}
$table = 'fm_entity_'. $entity_id .'_'.$cat_id .
'_status';
$this->db->query("SELECT id, descr FROM $table ORDER BY
id ");
$i = 0;
while ($this->db->next_record())
{
$status[$i]['id']
= $this->db->f('id');
$status[$i]['name']
= stripslashes($this->db->f('descr'));
$i++;
}
return $status;
}
function get_filter_list($cat_id='')
{
$sql = "SELECT id ,name FROM fm_equipment_type_attrib
where type_id = '$cat_id' ORDER BY name DESC";
$this->db->query($sql .
$ordermethod,$start,__LINE__,__FILE__);
while ($this->db->next_record())
{
$filter_list[] = array
(
'id' => $this->db->f('id'),
'name' => $this->db->f('name'),
);
}
return $filter_list;
}
function read($data)
{
if(is_array($data))
{
if ($data['start'])
{
$start=$data['start'];
}
else
{
$start=0;
}
$filter =
(isset($data['filter'])?$data['filter']:'');
$query =
(isset($data['query'])?$data['query']:'');
$sort =
(isset($data['sort'])?$data['sort']:'DESC');
$order =
(isset($data['order'])?$data['order']:'');
$cat_id =
(isset($data['cat_id'])?$data['cat_id']:0);
$district_id =
(isset($data['district_id'])?$data['district_id']:0);
$lookup =
(isset($data['lookup'])?$data['lookup']:'');
$allrows =
(isset($data['allrows'])?$data['allrows']:'');
$entity_id =
(isset($data['entity_id'])?$data['entity_id']:'');
$cat_id =
(isset($data['cat_id'])?$data['cat_id']:'');
$status =
(isset($data['status'])?$data['status']:'');
}
if(!$entity_id || !$cat_id)
{
return;
}
$sql = $this->bocommon->fm_cache('sql_entity_' .
$entity_id . '_' . $cat_id);
$entity_table = 'fm_entity_' . $entity_id . '_' .
$cat_id;
if(!$sql)
{
$cols = $entity_table . '.*';
$cols_return[] = 'location_code';
$cols_return[] = 'num';
$uicols['input_type'][] = 'text';
$uicols['name'][] = 'num';
$uicols['descr'][] =
lang('ID');
$uicols['statustext'][] = lang('ID');
$cols_return[] = 'id';
$uicols['input_type'][] = 'hidden';
$uicols['name'][] = 'id';
$uicols['descr'][] = false;
$uicols['statustext'][] = false;
$sql =
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols_return'=>$cols_return,'cols'=>$cols,
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query,'lookup'=>$lookup));
$this->bocommon->fm_cache('sql_entity_' .
$entity_id . '_' . $cat_id,$sql);
$this->bocommon->fm_cache('uicols_entityt_' .
$entity_id . '_' . $cat_id,$this->bocommon->uicols);
$this->bocommon->fm_cache('cols_return_entityt_' . $entity_id . '_' .
$cat_id,$this->bocommon->cols_return);
$this->bocommon->fm_cache('cols_return_lookup_entityt_' . $entity_id . '_' .
$cat_id,$this->bocommon->cols_return_lookup);
$this->bocommon->fm_cache('cols_extra_entityt_'
. $entity_id . '_' . $cat_id,$this->bocommon->cols_extra);
$uicols
= $this->bocommon->uicols;
$cols_return =
$this->bocommon->cols_return;
$this->cols_return_lookup =
$this->bocommon->cols_return_lookup;
$this->cols_extra =
$this->bocommon->cols_extra;
}
else
{
$uicols
= $this->bocommon->fm_cache('uicols_entityt_' . $entity_id . '_' .
$cat_id);
$cols_return
= $this->bocommon->fm_cache('cols_return_entityt_' . $entity_id . '_' .
$cat_id);
$this->cols_return_lookup =
$this->bocommon->fm_cache('cols_return_lookup_entityt_' . $entity_id . '_' .
$cat_id);
$this->cols_extra
= $this->bocommon->fm_cache('cols_extra_entityt_' . $entity_id . '_' . $cat_id);
}
if ($cat_id > 0)
{
$user_columns=$GLOBALS['phpgw_info']['user']['preferences'][$this->currentapp]['entity_columns_'.$entity_id.'_'.$cat_id];
if (isset($user_columns) AND
is_array($user_columns))
{
foreach($user_columns as $column_id)
{
$this->db->query("SELECT * FROM
fm_entity_attribute WHERE entity_id= $entity_id AND cat_id= $cat_id AND id=
$column_id");
$this->db->next_record();
$uicols['input_type'][]
= 'text';
$uicols['name'][]
= $this->db->f('column_name');
$uicols['descr'][]
= $this->db->f('input_text');
$uicols['statustext'][]
= $this->db->f('statustext');
$cols_return_extra[]= array(
'name' =>
$this->db->f('column_name'),
'datatype' =>
$this->db->f('datatype'),
'attrib_id' =>
$this->db->f('id')
);
}
}
}
else
{
return;
}
$this->uicols = $uicols;
//_debug_array($cols_return_extra);
if ($order)
{
$ordermethod = " order by $order $sort";
}
else
{
$ordermethod = ' order by id DESC';
}
$where= 'WHERE';
$filtermethod = "$where ( $entity_table.user_id=" .
$this->account;
if (is_array($this->grants))
{
$grants = $this->grants;
while (list($user) = each($grants))
{
$public_user_list[] = $user;
}
reset($public_user_list);
$filtermethod = " $where
($entity_table.access='public' AND $entity_table.user_id IN(" .
implode(',',$public_user_list) . "))";
}
else
{
$filtermethod .= ')';
}
$where= 'AND';
if ($filter > 0)
{
$filtermethod .= " $where
$entity_table.user_id=$filter ";
$where= 'AND';
}
if ($status)
{
$filtermethod .= " $where
$entity_table.status='$status' ";
$where= 'AND';
}
if ($district_id > 0)
{
$filtermethod .= " $where
district_id='$district_id' ";
$where = 'AND';
}
if($query)
{
$query = ereg_replace("'",'',$query);
$query = ereg_replace('"','',$query);
$querymethod = " $where (
$entity_table.location_code LIKE '%$query%' OR $entity_table.num LIKE
'%$query%' OR loc1_name LIKE '%$query%' OR address LIKE '%$query%')";
$where = 'AND';
}
$sql .= " $filtermethod $querymethod";
//echo $sql;
$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__);
}
$j=0;
while ($this->db->next_record())
{
for ($i=0;$i<count($cols_return);$i++)
{
$entity_list[$j][$cols_return[$i]] =
$this->db->f($cols_return[$i]);
}
for ($i=0;$i<count($cols_return_extra);$i++)
{
$value=$this->db->f($cols_return_extra[$i]['name']);
if($cols_return_extra[$i]['datatype']=='R' && $value):
{
$sql="SELECT value FROM
fm_entity_choice where entity_id=$entity_id AND cat_id=$cat_id AND attrib_id="
.$cols_return_extra[$i]['attrib_id']. " AND id=" . $value;
$this->db2->query($sql);
$this->db2->next_record();
$entity_list[$j][$cols_return_extra[$i]['name']] = $this->db2->f('value');
}
elseif($cols_return_extra[$i]['datatype']=='CH' && $value):
{
$ch= unserialize($value);
for ($k=0;$k<count($ch);$k++)
{
$sql="SELECT value FROM
fm_entity_choice where entity_id=$entity_id AND cat_id=$cat_id AND attrib_id="
.$cols_return_extra[$i]['attrib_id']. " AND id=" . $ch[$k];
$this->db2->query($sql);
while
($this->db2->next_record())
{
$ch_value[]=$this->db2->f('value');
}
}
$entity_list[$j][$cols_return_extra[$i]['name']] = @implode(",", $ch_value);
}
elseif($cols_return_extra[$i]['datatype']=='D' && $value):
{
//_debug_array($value);
$entity_list[$j][$cols_return_extra[$i]['name']]=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($value));
}
else:
{
$entity_list[$j][$cols_return_extra[$i]['name']]=$value;
}
endif;
}
$location_code= $this->db->f('location_code');
$location = split('-',$location_code);
for ($m=0;$m<count($location);$m++)
{
$entity_list[$j]['loc' . ($m+1)] =
$location[$m];
$entity_list[$j]['query_location']['loc' . ($m+1)]=implode("-",
array_slice($location, 0, ($m+1)));
}
$j++;
}
//_debug_array($entity_list);
return $entity_list;
}
function read_single($data)
{
$entity_id =$data['entity_id'];
$cat_id =$data['cat_id'];
$id =$data['id'];
$this->db->query("SELECT * FROM fm_entity_attribute
WHERE entity_id =$entity_id AND cat_id =$cat_id ");
while ($this->db->next_record())
{
$entity['attributes'][] = array
(
'attrib_id' =>
$this->db->f('id'),
'name' =>
$this->db->f('column_name'),
'descr' =>
$this->db->f('input_text'),
'datatype' =>
$this->db->f('datatype')
);
}
if($id)
{
$table='fm_entity_' . $entity_id .'_' . $cat_id;
$this->db->query("SELECT * FROM $table WHERE id
=$id");
if($this->db->next_record())
{
$entity['id']
= $id;
$entity['num']
= $this->db->f('num');
$entity['location_code'] =
$this->db->f('location_code');
$entity['vendor_id'] =
$this->db->f('vendor_id');
$entity['status']
= $this->db->f('status');
for
($i=0;$i<count($entity['attributes']);$i++)
{
$entity['attributes'][$i]['value'] =
$this->db->f($entity['attributes'][$i]['name']);
}
}
}
return $entity;
}
function check_entity($entity_id,$cat_id,$num)
{
$table='fm_entity_' . $entity_id .'_' . $cat_id;
$this->db->query("SELECT count(*) FROM $table where
num='$num'");
$this->db->next_record();
if ( $this->db->f(0))
{
return True;
}
}
function generate_id($data)
{
$table='fm_entity_' . $data['entity_id'] .'_' .
$data['cat_id'];
$this->db->query("select max(id) as id from $table");
$this->db->next_record();
$id = $this->db->f('id')+1;
return $id;
}
function generate_num($entity_id,$cat_id,$id)
{
$this->db->query("select prefix from fm_entity_category
WHERE entity_id=$entity_id AND id=$cat_id ");
$this->db->next_record();
$prefix = $this->db->f('prefix');
if (strlen($id) == 4)
$return = $id;
if (strlen($id) == 3)
$return = "0$id";
if (strlen($id) == 2)
$return = "00$id";
if (strlen($id) == 1)
$return = "000$id";
if (strlen($id) == 0)
$return = "0001";
return $prefix . strtoupper($return);
}
function add($values,$values_attribute,$entity_id,$cat_id)
{
if($values['street_name'])
{
$address[]= $values['street_name'];
$address[]= $values['street_number'];
$address = implode(" ", $address);
}
if(!$address)
{
$address = $values['location_name'];
}
$values['descr'] =
$this->db->db_addslashes($values['descr']);
while (is_array($values['location']) &&
list($input_name,$value) = each($values['location']))
{
if($value)
{
$cols[] = $input_name;
$vals[] = $value;
}
}
while (is_array($values['extra']) &&
list($input_name,$value) = each($values['extra']))
{
if($value)
{
$cols[] = $input_name;
$vals[] = $value;
}
}
if (isset($values_attribute) AND
is_array($values_attribute))
{
foreach($values_attribute as $entry)
{
$cols[] = $entry['name'];
$vals[] = $entry['value'];
}
}
if($cols)
{
$cols = "," . implode(",", $cols);
$vals = "," .
$this->bocommon->validate_db_insert($vals);
}
$table='fm_entity_' . $entity_id .'_' . $cat_id;
$num=$this->generate_num($entity_id,$cat_id,$values['id']);
$this->db->query("INSERT INTO $table
(id,num,address,location_code,status,vendor_id,entry_date,user_id $cols) "
. "VALUES ("
. $values['id']. ",'"
. $num . "','"
. $address. "','"
. $values['location_code']. "','"
. $values['status']. "','"
. $values['vendor_id'] . "',"
. time() . ","
. $this->account. " $vals)",__LINE__,__FILE__);
$receipt['message'][] = array('msg'=>lang('Entity %1
has been saved',$values['id']));
return $receipt;
}
function edit($values,$values_attribute,$entity_id,$cat_id)
{
//_debug_array($values);
if($values['street_name'])
{
$address[]= $values['street_name'];
$address[]= $values['street_number'];
$address = implode(" ", $address);
}
if(!$address)
{
$address = $values['location_name'];
}
$values['descr'] =
$this->db->db_addslashes($values['descr']);
$value_set=array(
'location_code' => $values['location_code'],
'status' => $values['status'],
'address' => $address,
'vendor_id' => $values['vendor_id']
);
while (is_array($values['location']) &&
list($column,$value) = each($values['location']))
{
$value_set[$column] = $value;
}
while (is_array($values['extra']) &&
list($column,$value) = each($values['extra']))
{
$value_set[$column] = $value;
}
if (isset($values_attribute) AND
is_array($values_attribute))
{
foreach($values_attribute as $entry)
{
$value_set[$entry['name']] =
$entry['value'];
}
}
$value_set =
$this->bocommon->validate_db_update($value_set);
$table='fm_entity_' . $entity_id .'_' . $cat_id;
$this->db->query("UPDATE $table set $value_set WHERE
id=" . $values['id'],__LINE__,__FILE__);
$receipt['message'][] = array('msg'=>lang('entity %1
has been edited',$values['num']));
return $receipt;
}
function delete($entity_id,$cat_id,$id )
{
$table='fm_entity_' . $entity_id .'_' . $cat_id;
$this->db->query("DELETE FROM $table WHERE
id=$id",__LINE__,__FILE__);
}
}
?>
Index: class.uiadmin_entity.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.uiadmin_entity.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** class.uiadmin_entity.inc.php 15 Oct 2003 17:27:38 -0000 1.2
--- class.uiadmin_entity.inc.php 18 Oct 2003 22:15:51 -0000 1.3
***************
*** 20,25 ****
--- 20,27 ----
(
'index' => True,
+ 'list_status' => True,
'category' => True,
'edit' => True,
+ 'edit_status' => True,
'edit_category' => True,
'view' => True,
***************
*** 42,45 ****
--- 44,49 ----
$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;
***************
*** 55,58 ****
--- 59,65 ----
'sort' => $this->sort,
'order' => $this->order,
+ 'allrows' => $this->allrows,
+ 'entity_id' => $this->entity_id,
+ 'cat_id' => $this->cat_id
);
$this->bo->save_sessiondata($data);
***************
*** 61,65 ****
function index()
{
-
$this->bo->reset_fm_cache();
$GLOBALS['phpgw']->xslttpl->add_file(array(
--- 68,71 ----
***************
*** 177,180 ****
--- 183,303 ----
}
+ function list_status()
+ {
+ $this->bo->reset_fm_cache();
+ $GLOBALS['phpgw']->xslttpl->add_file(array(
+
'admin_entity',
+
'nextmatchs',
+
'menu',
+
'search_field'));
+ $links = $this->bocommon->menu();
+
+ $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'),
+ '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));
+ $this->save_sessiondata();
+ }
+
function category()
{
***************
*** 201,211 ****
'prefix'
=> $entry['prefix'],
'descr'
=> $entry['descr'],
'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_attribute_standardtext'
=> lang('attributes for the entity type'),
'lang_edit_standardtext'
=> lang('edit the standard'),
'lang_delete_standardtext'
=> lang('delete the standard'),
'text_attribute'
=> lang('Attributes'),
'text_edit'
=> lang('edit'),
--- 324,337 ----
'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'),
***************
*** 222,225 ****
--- 348,352 ----
'lang_descr' => lang('Descr'),
'lang_prefix' => lang('prefix'),
+ 'lang_status' => lang('Status'),
'lang_attribute' => lang('Attributes'),
'lang_edit' => lang('edit'),
***************
*** 392,395 ****
--- 519,612 ----
}
+ 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));
+ }
+
function edit_category()
{
***************
*** 437,441 ****
if ($id)
{
! $values =
$this->bo->read_single_category($id,$entity_id);
$function_msg = lang('edit category');
$action='edit';
--- 654,658 ----
if ($id)
{
! $values =
$this->bo->read_single_category($entity_id,$id);
$function_msg = lang('edit category');
$action='edit';
***************
*** 484,488 ****
'lang_save_standardtext' =>
lang('Save the standard'),
'type_id'
=> $values['type_id'],
! 'value_descr'
=> $values['descr']
);
--- 701,708 ----
'lang_save_standardtext' =>
lang('Save the standard'),
'type_id'
=> $values['type_id'],
! 'value_descr'
=> $values['descr'],
! 'lang_lookup_vendor' =>
lang('lookup vendor'),
! 'value_lookup_vendor' =>
$values['lookup_vendor'],
! 'lang_lookup_vendor_statustext' => lang('If
this entity type is to look up vendors')
);
***************
*** 498,501 ****
--- 718,722 ----
$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'));
***************
*** 508,512 ****
if($cat_id)
{
! $function='category';
}
else
--- 729,740 ----
if($cat_id)
{
! if($status_id)
! {
! $function='list_status';
! }
! else
! {
! $function='category';
! }
}
else
***************
*** 516,524 ****
}
$link_data = array
(
'menuaction' =>
$this->currentapp.'.uiadmin_entity.'.$function,
'cat_id' => $cat_id,
! 'entity_id' => $entity_id
);
--- 744,755 ----
}
+
$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
);
***************
*** 528,537 ****
'cat_id' => $cat_id,
'entity_id' => $entity_id,
! 'attrib_id' => $attrib_id
);
if (get_var('confirm',array('POST')))
{
!
$this->bo->delete($cat_id,$entity_id,$attrib_id);
Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
}
--- 759,769 ----
'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));
}
***************
*** 644,648 ****
$entity = $this->bo->read_single($entity_id,false);
! $category =
$this->bo->read_single_category($cat_id,$entity_id);
$data = array
--- 876,880 ----
$entity = $this->bo->read_single($entity_id,false);
! $category =
$this->bo->read_single_category($entity_id,$cat_id);
$data = array
***************
*** 786,790 ****
$entity = $this->bo->read_single($entity_id,false);
! $category =
$this->bo->read_single_category($cat_id,$entity_id);
$msgbox_data = $this->bocommon->msgbox_data($receipt);
--- 1018,1022 ----
$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);
--- NEW FILE: class.uientity.inc.php ---
<?php
/***************************************************************************\
* -------------------------------------------------
*
* This program is free software; you can redistribute it and/or modify
it *
* under the terms of the GNU General Public License as published by the
*
* Free Software Foundation; either version 2 of the License, or (at
your *
* option) any later version.
*
\***************************************************************************/
class uientity
{
var $grants;
var $cat_id;
var $start;
var $query;
var $sort;
var $order;
var $filter;
var $part_of_town_id;
var $sub;
var $currentapp;
var $public_functions = array
(
'columns'=> True,
'excel' => True,
'index' => True,
'view' => True,
'edit' => True,
'delete' => True
);
function uientity()
{
$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.'.boentity',True);
$this->bocommon =
CreateObject($this->currentapp.'.bocommon');
$this->bolocation =
CreateObject($this->currentapp.'.bolocation');
$this->boadmin_entity =
CreateObject($this->currentapp.'.boadmin_entity',True);
$this->acl2 =
CreateObject($this->currentapp.'.acl2');
$this->acl2_location = '.equipment';
$this->acl_read =
$this->acl2->check($this->acl2_location,1);
$this->acl_add =
$this->acl2->check($this->acl2_location,2);
$this->acl_edit =
$this->acl2->check($this->acl2_location,4);
$this->acl_delete =
$this->acl2->check($this->acl2_location,8);
$this->start =
$this->bo->start;
$this->query =
$this->bo->query;
$this->sort =
$this->bo->sort;
$this->order =
$this->bo->order;
$this->filter =
$this->bo->filter;
$this->cat_id =
$this->bo->cat_id;
$this->part_of_town_id =
$this->bo->part_of_town_id;
$this->district_id =
$this->bo->district_id;
$this->entity_id =
$this->bo->entity_id;
$this->status =
$this->bo->status;
$GLOBALS['phpgw']->session->appsession('sub',$this->currentapp,'entity_'.$this->entity_id);
$GLOBALS['phpgw']->session->appsession('entity_id',$this->currentapp,$this->entity_id);
}
function save_sessiondata()
{
$data = array
(
'start' => $this->start,
'query' => $this->query,
'sort' => $this->sort,
'order' => $this->order,
'filter' => $this->filter,
'cat_id' => $this->cat_id,
'part_of_town_id' =>
$this->part_of_town_id,
'district_id' => $this->district_id,
'entity_id' => $this->entity_id,
'status' => $this->status
);
$this->bo->save_sessiondata($data);
}
function excel()
{
$GLOBALS['phpgw_info']['flags']['noframework'] = True;
require('PEAR.php');
$xls =
CreateObject($this->currentapp.'.excel');
$list =
$this->bo->read(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'allrows'=>true));
$uicols = $this->bo->uicols;
$count_uicols_name=count($uicols['name']);
$j=0;
if (isset($list) AND is_array($list))
{
$str=$xls->Begin();
foreach($list as $entry)
{
$m=0;
for ($k=0;$k<$count_uicols_name;$k++)
{
if($uicols['input_type'][$k]=='text')
{
$content[$j][$m]
= $entry[$uicols['name'][$k]];
$xls->WriteLabel(0,$m,$uicols['descr'][$k]);
$str.=$xls->WriteLabel(0,$m,$uicols['descr'][$k]);
$m++;
}
}
$j++;
}
foreach($content as $row)
{
$line++;
for ($i=0; $i<count($row); $i++)
{
$str.=$xls->WriteLabel($line,$i,$row[$i]);
}
}
$filename=
$GLOBALS['phpgw_info']['user']['account_lid'].'.xls';
$str.=$xls->EOF();
$size=strlen($str);
$browser = CreateObject('phpgwapi.browser');
$browser->content_header($filename,'application/vnd.ms-excel',$size);
echo $str;
}
}
function columns()
{
$GLOBALS['phpgw']->xslttpl->add_file(array('columns'));
$GLOBALS['phpgw_info']['flags']['headonly']=true;
$values =
get_var('values',array('POST','GET'));
if ($values['save'] && $this->cat_id)
{
$GLOBALS['phpgw']->preferences->account_id=$this->account;
$GLOBALS['phpgw']->preferences->read_repository();
$GLOBALS['phpgw']->preferences->add($this->currentapp,"entity_columns_" .
$this->entity_id . '_' . $this->cat_id,$values['columns'],'user');
$GLOBALS['phpgw']->preferences->save_repository();
$receipt['message'][] = array('msg' =>
lang('columns is updated'));
}
if(!$this->cat_id)
{
$receipt['error'][] = array('msg' =>
lang('Choose a category'));
}
$function_msg = lang('Select Column');
$link_data = array
(
'menuaction' =>
$this->currentapp.'.uientity.columns',
'entity_id' =>
$this->entity_id,
'cat_id' => $this->cat_id
);
$msgbox_data = $this->bocommon->msgbox_data($receipt);
$data = array
(
'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
'column_list' =>
$this->bo->column_list($values['columns'],$entity_id=$this->entity_id,$cat_id=$this->cat_id,$allrows=True),
'function_msg' => $function_msg,
'form_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
'lang_columns' => lang('columns'),
'lang_save' => lang('save'),
'select_name' => 'period'
);
$GLOBALS['phpgw_info']['flags']['app_header'] =
$function_msg;
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('columns' => $data));
}
function index()
{
if(!$this->acl_read)
{
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
}
$GLOBALS['phpgw']->xslttpl->add_file(array('entity',
'menu',
'nextmatchs',
'search_field'));
$links = $this->bocommon->menu($sub);
$entity_list = $this->bo->read();
$uicols = $this->bo->uicols;
$j=0;
while (is_array($entity_list) && list(,$entity_entry) =
each($entity_list))
{
for ($i=0;$i<count($uicols['name']);$i++)
{
if($uicols['input_type'][$i]!='hidden')
{
if($entity_entry['query_location'][$uicols['name'][$i]])
{
$content[$j]['row'][$i]['statustext'] = lang('search');
$content[$j]['row'][$i]['text'] =
$entity_entry[$uicols['name'][$i]];
$content[$j]['row'][$i]['link'] =
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.index&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id .'&query=' .
$entity_entry['query_location'][$uicols['name'][$i]]);
}
else
{
$content[$j]['row'][$i]['value'] =
$entity_entry[$uicols['name'][$i]];
$content[$j]['row'][$i]['name'] = $uicols['name'][$i];
}
}
}
while
(is_array($entity_entry['query_location']) && list($key,$query_location) =
each($entity_entry['query_location']))
{
// _debug_array($key);
}
if($this->acl_read)
{
$content[$j]['row'][$i]['statustext']
= lang('view the entity');
$content[$j]['row'][$i]['text']
= lang('view');
$content[$j]['row'][$i++]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.view&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id .'&id=' . $entity_entry['id']);
}
if($this->acl_edit)
{
$content[$j]['row'][$i]['statustext']
= lang('edit the entity');
$content[$j]['row'][$i]['text']
= lang('edit');
$content[$j]['row'][$i++]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.edit&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id .'&id=' . $entity_entry['id']);
}
if($this->acl_delete)
{
$content[$j]['row'][$i]['statustext']
= lang('delete the entity');
$content[$j]['row'][$i]['text']
= lang('delete');
$content[$j]['row'][$i++]['link']
=
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.delete&entity_id='
. $this->entity_id . '&cat_id=' . $this->cat_id .'&id=' . $entity_entry['id']);
}
$j++;
}
//_debug_array($content);
for ($i=0;$i<count($uicols['descr']);$i++)
{
if($uicols['input_type'][$i]!='hidden')
{
$table_header[$i]['header'] =
$uicols['descr'][$i];
$table_header[$i]['width']
= '5%';
$table_header[$i]['align']
= 'center';
if($uicols['name'][$i]=='loc1')
{
$table_header[$i]['sort_link']
=true;
$table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
(
'sort' => $this->sort,
'var' => 'location_code',
'order' => $this->order,
'extra' => array('menuaction' =>
$this->currentapp.'.uientity.index',
'type_id'
=>$type_id,
'query'
=>$this->query,
'lookup'
=>$lookup,
'district_id' =>
$this->district_id,
'entity_id'
=>$this->entity_id,
'cat_id'
=>$this->cat_id)
));
}
if($uicols['name'][$i]=='entity_id')
{
$table_header[$i]['sort_link']
=true;
$table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
(
'sort' => $this->sort,
'var' => 'entity_id',
'order' => $this->order,
'extra' => array('menuaction' =>
$this->currentapp.'.uientity.index',
'type_id'
=>$type_id,
'query'
=>$this->query,
'lookup'
=>$lookup,
'district_id' =>
$this->district_id,
'entity_id'
=>$this->entity_id,
'cat_id'
=>$this->cat_id)
));
}
if($uicols['name'][$i]=='address')
{
$table_header[$i]['sort_link']
=true;
$table_header[$i]['sort']
= $this->nextmatchs->show_sort_order(array
(
'sort' => $this->sort,
'var' => 'address',
'order' => $this->order,
'extra' => array('menuaction' =>
$this->currentapp.'.uientity.index',
'type_id'
=>$type_id,
'query'
=>$this->query,
'lookup'
=>$lookup,
'district_id' =>
$this->district_id,
'entity_id'
=>$this->entity_id,
'cat_id'
=>$this->cat_id)
));
}
}
}
if($this->acl_read)
{
$table_header[$i]['width']
= '5%';
$table_header[$i]['align']
= 'center';
$table_header[$i]['header']
= lang('view');
$i++;
}
if($this->acl_edit)
{
$table_header[$i]['width']
= '5%';
$table_header[$i]['align']
= 'center';
$table_header[$i]['header']
= lang('edit');
$i++;
}
if($this->acl_delete)
{
$table_header[$i]['width']
= '5%';
$table_header[$i]['align']
= 'center';
$table_header[$i]['header']
= lang('delete');
$i++;
}
if($this->acl_add)
{
$table_add[] = array
(
'lang_add'
=> lang('add'),
'lang_add_statustext' => lang('add a
entity'),
'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.edit&entity_id='.
$this->entity_id .'&cat_id='. $this->cat_id)
);
}
$link_data = array
(
'menuaction' =>
$this->currentapp.'.uientity.index',
'sort'
=>$this->sort,
'order'
=>$this->order,
'cat_id'
=>$this->cat_id,
'entity_id'
=>$this->entity_id,
'district_id'
=>$this->district_id,
'filter'
=>$this->filter,
'query'
=>$this->query
);
$link_excel = array
(
'menuaction' =>
$this->currentapp.'.uientity.excel',
'sort'
=>$this->sort,
'order'
=>$this->order,
'entity_id'
=>$this->entity_id,
'cat_id'
=>$this->cat_id,
'district_id'
=>$this->district_id,
'status_id'
=>$this->status,
'filter'
=>$this->filter,
'query'
=>$this->query
);
$link_columns = array
(
'menuaction' =>
$this->currentapp.'.uientity.columns',
'entity_id'
=>$this->entity_id,
'cat_id'
=>$this->cat_id
);
$data = array
(
'lang_excel' =>
'excel',
'link_excel' =>
$GLOBALS['phpgw']->link('/index.php',$link_excel),
'lang_excel_help' =>
lang('Download table to MS Excel'),
'lang_columns' =>
lang('columns'),
'link_columns' =>
$GLOBALS['phpgw']->link('/index.php',$link_columns),
'lang_columns_help' =>
lang('Choose columns'),
'links'
=> $links,
'allow_allrows'
=> false,
'start_record'
=> $this->start,
'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
'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'),
'district_list'
=> $this->bocommon->select_district_list('filter',$this->district_id),
'lang_no_district'
=> lang('no district'),
'lang_district_statustext' =>
lang('Select the district the selection belongs to. To do not use a district
select NO DISTRICT'),
'select_district_name' =>
'district_id',
'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
'lang_status_statustext' =>
lang('Select the status. To do not use a category select NO STATUS'),
'status_name'
=> 'status',
'lang_no_status'
=> lang('No status'),
'status_list'
=> $this->bo->select_status_list('filter',$this->status),
'lang_user_statustext' =>
lang('Select the user. To do not use a category select NO USER'),
'select_user_name'
=> 'filter',
'lang_no_user'
=> lang('No user'),
'user_list'
=>
$this->bocommon->get_user_list_right2('filter',4,$this->filter,$this->acl2_location,array('all'),$default=$this->account),
'lang_filter_statustext' =>
lang('Select the filter. To show all entries select SHOW ALL'),
'lang_searchfield_statustext' => lang('Enter
the search string. To show all entries, empty this field and press the SUBMIT
button again'),
'lang_searchbutton_statustext' => lang('Submit
the search string'),
'query'
=> $this->query,
'lang_search'
=> lang('search'),
'table_header'
=> $table_header,
'values'
=> $content,
'table_add'
=> $table_add
);
if($this->entity_id)
{
$entity =
$this->boadmin_entity->read_single($this->entity_id,false);
$appname = $entity['name'];
}
if($this->cat_id)
{
$category =
$this->boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
$function_msg
= 'list ' . $category['name'];
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
}
if(!$this->entity_id || !$this->cat_id)
{
$receipt['error'][]=array('msg'=>lang('Please
select type'));
$msgbox_data =
$this->bocommon->msgbox_data($receipt);
$data = array
(
'msgbox_data'
=> $GLOBALS['phpgw']->common->msgbox($msgbox_data),
'links'
=> $links
);
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname;
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('empty' => $data));
}
else
{
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
$this->save_sessiondata();
}
}
function edit()
{
if(!$this->acl_add && !$this->acl_edit)
{
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=2&acl_location='
. $this->acl2_location);
}
$id =
get_var('id',array('POST','GET'));
$values =
get_var('values',array('POST','GET'));
$values_attribute =
get_var('values_attribute',array('POST','GET'));
$insert_record =
$GLOBALS['phpgw']->session->appsession('insert_record',$this->currentapp);
$GLOBALS['phpgw']->xslttpl->add_file(array('entity'));
$values['vendor_id'] =
get_var('vendor_id',array('POST'));
$values['vendor_name'] =
get_var('vendor_name',array('POST'));
$values['date'] =
get_var('date',array('POST'));
if ($values['save'])
{
for ($i=0;
$i<count($insert_record['location']); $i++)
{
if($_POST[$insert_record['location'][$i]])
{
$values['location'][$insert_record['location'][$i]]=
$_POST[$insert_record['location'][$i]];
}
}
while (is_array($insert_record['extra']) &&
list($key,) = each($insert_record['extra']))
{
if($_POST[$key])
{
$values['extra'][$key] =
$_POST[$key];
}
}
$values['street_name'] =
$_POST['street_name'];
$values['street_number'] =
$_POST['street_number'];
$values['location_name'] = $_POST['loc'
. (count($values['location'])).'_name']; // if not address - get the parent
name as address
if(!$values['location'])
{
$receipt['error'][]=array('msg'=>lang('Please select a location !'));
$error_id=true;
}
if(!$this->cat_id)
{
$receipt['error'][]=array('msg'=>lang('Please select entity type !'));
$error_id=true;
}
if(!$values['status'])
{
//
$receipt['error'][]=array('msg'=>lang('Please select a status !'));
}
if($id)
{
$values['id']=$id;
$action='edit';
}
else
{
if (!$receipt['error'])
{
$values['id']=$this->bo->generate_id(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id));
}
}
if(!$receipt['error'])
{
$receipt =
$this->bo->save($values,$values_attribute,$action,$this->entity_id,$this->cat_id);
$id = $values['id'];
$function_msg = lang('edit entity');
if($values_attribute)
{
//
$this->bo->save_attributes($values_attribute,'entity');
}
}
else
{
if($values['location'])
{
$location_code=implode("-",
$values['location']);
$values['location_data'] =
$this->bolocation->read_single($location_code);
}
}
}
if ($id)
{
$values =
$this->bo->read_single(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id,'id'=>$id));
}
else
{
$temp =
$this->bo->read_single(array('entity_id'=>$this->entity_id,'cat_id'=>$this->cat_id));
}
$lookup_type='form';
if ($id)
{
$function_msg = lang('edit entity');
}
else
{
$function_msg = lang('add entity');
}
if ($values['cat_id'])
{
$this->cat_id = $values['cat_id'];
}
$location_data=$this->bolocation->initiate_ui_location(array(
'values' =>
$values['location_data'],
'type_id' => -1,
// calculated from location_types
'no_link' =>
False, // disable lookup links for location type less than type_id
// 'tenant' => True,
// 'entity' => True,
'lookup_type' => $lookup_type
));
$entity =
$this->boadmin_entity->read_single($this->entity_id,false);
$category =
$this->boadmin_entity->read_single_category($this->entity_id,$this->cat_id);
if($category['lookup_vendor'])
{
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
'vendor_id' =>
$values['vendor_id'],
'vendor_name' =>
$values['vendor_name']));
}
if($values['attributes'])
{
$attributes_values=$values['attributes'];
}
else
{
$attributes_values=$temp['attributes'];
}
$attributes_header[] = array(
'lang_name' => lang('Name'),
'lang_descr' => lang('Description'),
'lang_datatype' => lang('Datatype'),
'lang_value' => lang('Value')
);
if($error_id)
{
unset($values['id']);
unset($id);
}
$link_data = array
(
'menuaction' =>
$this->currentapp.'.uientity.edit',
'id' => $id,
'entity_id' => $this->entity_id,
'cat_id' => $this->cat_id
);
$dateformat =
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
$sep = '/';
$dlarr[strpos($dateformat,'y')] = 'yyyy';
$dlarr[strpos($dateformat,'m')] = 'MM';
$dlarr[strpos($dateformat,'d')] = 'DD';
ksort($dlarr);
$dateformat= (implode($sep,$dlarr));
switch(substr($dateformat,0,1))
{
case 'M':
$dateformat_validate=
"javascript:vDateType='1'";
$onKeyUp =
"DateFormat(this,this.value,event,false,'1')";
$onBlur =
"DateFormat(this,this.value,event,true,'1')";
break;
case 'y':
$dateformat_validate="javascript:vDateType='2'";
$onKeyUp =
"DateFormat(this,this.value,event,false,'2')";
$onBlur =
"DateFormat(this,this.value,event,true,'2')";
break;
case 'D':
$dateformat_validate="javascript:vDateType='3'";
$onKeyUp =
"DateFormat(this,this.value,event,false,'3')";
$onBlur =
"DateFormat(this,this.value,event,true,'3')";
break;
}
$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_dateformat'
=> lang(strtolower($dateformat)),
'dateformat_validate' =>
$dateformat_validate,
'onKeyUp'
=> $onKeyUp,
'onBlur'
=> $onBlur,
'dateformat_source'
=> './'.$this->currentapp.'/inc/dateformat.js',
'lang_attributes'
=> lang('Attributes'),
'attributes_header'
=> $attributes_header,
'attributes_values'
=> $attributes_values,
'generate_id'
=> $values['generate_id'],
'link_calendar_date' =>
'setDateField(document.form.date);top.newWin=window.open('."'.".'/'.$this->currentapp.'/inc/calendar.html'."'".','."'".'cal'."'".','."'dependent=yes,width=210,height=230,screenX=200,screenY=300,titlebar=yes'".')',
'calendar_gif'
=> './'.$this->currentapp.'/templates/default/images/calendar.gif',
'calendar_source'
=> './'.$this->currentapp.'/inc/calendar.js',
'dateformat'
=> $dateformat,
'lang_popup_calendar' =>
lang('Popup Calendar'),
'lang_date_statustext' =>
lang('insert the date for the acquisition'),
'lang_date'
=> lang('Acquisition date'),
'value_date'
=> $values['date'],
'lang_generate_id'
=> lang('Generate ID ?'),
'lang_generate_id_statustext' => lang('Choose
Generate ID to automaticly assign new ID based on type-prefix'),
'vendor_data'
=> $vendor_data,
'location_data'
=> $location_data,
'lookup_type'
=> $lookup_type,
'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.index&entity_id='
. $this->entity_id . '&cat_id='. $this->cat_id),
'lang_year'
=> lang('Year'),
'lang_category'
=> lang('category'),
'lang_save'
=> lang('save'),
'lang_done'
=> lang('done'),
'lang_id'
=> lang('ID'),
'value_id' =>
$values['id'],
'value_num' =>
$values['num'],
'lang_id_statustext' => lang('Enter ID'),
'lang_lifetime'
=> lang('Longevity'),
'lang_lifetime_statustext' =>
lang('Enter the expected longevity in years'),
'value_lifetime'
=> $values['lifetime'],
'error_flag'
=> $error_id,
'lang_descr_statustext' =>
lang('Enter a description of the entity'),
'lang_descr'
=> lang('Description'),
'value_descr'
=> $values['descr'],
'lang_done_statustext' =>
lang('Back to the list'),
'lang_save_statustext' =>
lang('Save the entity'),
'lang_no_cat'
=> lang('no category'),
'lang_cat_statustext' =>
lang('Select the category the entity belongs to. To do not use a category
select NO CATEGORY'),
'select_name'
=> 'values[cat_id]',
'value_cat_id'
=> $values['cat_id'],
// 'cat_list'
=> $this->bocommon->select_category_entity_list('select',$this->cat_id),
'status_list'
=> $this->bo->select_status_list('select',$values['status']),
'select_status_name' =>
'values[status]',
'lang_no_status'
=> lang('Select status'),
'lang_status'
=> lang('Status'),
'lang_status_statustext' =>
lang('What is the current status of this entity ?'),
'lang_cost'
=> lang('Purchase cost'),
'value_cost'
=> $values['cost'],
'lang_cost_statustext' =>
lang('Enter the purchase cost'),
'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency']
);
$appname
= lang('entity');
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
}
function delete()
{
if(!$this->acl_delete)
{
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=8&acl_location='
. $this->acl2_location);
}
$id = get_var('id',array('POST','GET'));
$confirm = get_var('confirm',array('POST'));
$link_data = array
(
'menuaction' =>
$this->currentapp.'.uientity.index',
'entity_id' => $this->entity_id,
'cat_id' => $this->cat_id
);
if (get_var('confirm',array('POST')))
{
$this->bo->delete($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','menuaction='.$this->currentapp.'.uientity.delete&entity_id='
. $this->entity_id .'&cat_id=' . $this->cat_id . '&id=' . $id),
'lang_confirm_msg' => lang('do you
really want to delete this entry'),
'lang_yes' =>
lang('yes'),
'lang_yes_statustext' => lang('Delete the
entry'),
'lang_no_statustext' => lang('Back to the
list'),
'lang_no' =>
lang('no')
);
$appname
= lang('entity');
$function_msg =
lang('delete entity');
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
}
function view()
{
if(!$this->acl_read)
{
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uilocation.stop&perm=1&acl_location='
. $this->acl2_location);
}
$id = get_var('id',array('POST','GET'));
$values = $this->bo->read_single($id);
$GLOBALS['phpgw']->xslttpl->add_file(array('entity'));
$location_data=$this->bolocation->initiate_ui_location(array(
'values' =>
$values['location_data'],
'type_id' => -1,
// calculated from location_types
'no_link' =>
False, // disable lookup links for location type less than type_id
// 'tenant' => True,
// 'entity' => True,
'lookup_type' => 'view'
));
$attributes_values =
$this->bocommon->read_attibutes(array('form'=>false,'type'=>entity,'type_id'=>$values['cat_id'],'id'=>$id));
$attributes_header[] = array(
'lang_name' => lang('Name'),
'lang_descr' => lang('Description'),
'lang_datatype' => lang('Datatype'),
'lang_value' => lang('Value')
);
$data = array
(
'lang_attributes' =>
lang('Attributes'),
'attributes_header' =>
$attributes_header,
'attributes_values' =>
$attributes_values,
'lang_date'
=> lang('Acquisition date'),
'value_date' =>
$values['date'],
'location_data' =>
$location_data,
'lang_year'
=> lang('Year'),
'lang_category' =>
lang('category'),
'lang_entity_id' =>
lang('entity ID'),
'value_entity_id' =>
$values['entity_id'],
'lang_lifetime' =>
lang('Longevity'),
'value_lifetime' =>
$values['lifetime'],
'lang_descr' =>
lang('Description'),
'value_descr' =>
$values['descr'],
'lang_status' =>
lang('Status'),
'value_status' =>
$values['status'],
'lang_cost'
=> lang('Purchase cost'),
'value_cost' =>
$values['cost'],
'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.index'),
'edit_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uientity.edit&id='
. $id),
'lang_vendor' =>
lang('Vendor'),
'value_vendor_id' =>
$values['vendor_id'],
'value_vendor_name' =>
$values['vendor_name'],
'lang_done_statustext' => lang('Back
to the list'),
'lang_edit_statustext' => lang('Edit
this entry entity'),
'lang_done'
=> lang('done'),
'lang_edit'
=> lang('Edit')
);
$appname
= lang('entity');
$function_msg =
lang('view entity');
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
}
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] property/inc class.boentity.inc.php, NONE, 1.1 class.soentity.inc.php, NONE, 1.1 class.uientity.inc.php, NONE, 1.1 class.bocommon.inc.php, 1.85, 1.86 class.soadmin_entity.inc.php, 1.2, 1.3 class.uiadmin_entity.inc.php, 1.2, 1.3 class.boadmin_entity.inc.php, 1.1, 1.2,
Sigurd Nes <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] email/templates/default/images navbar.gif, 1.4.2.2, 1.4.2.3 navbar.png, 1.6.2.2, 1.6.2.3
- Next by Date:
[Phpgroupware-cvs] property/templates/default entity.xsl, NONE, 1.1 admin_entity.xsl, 1.2, 1.3 attributes_form.xsl, 1.7, 1.8
- Previous by thread:
[Phpgroupware-cvs] email/templates/default/images navbar.gif, 1.4.2.2, 1.4.2.3 navbar.png, 1.6.2.2, 1.6.2.3
- Next by thread:
[Phpgroupware-cvs] property/templates/default entity.xsl, NONE, 1.1 admin_entity.xsl, 1.2, 1.3 attributes_form.xsl, 1.7, 1.8
- Index(es):