[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: property/inc class.bolocation.inc.php,NONE,1.1 c
From: |
Sigurd Nes <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: property/inc class.bolocation.inc.php,NONE,1.1 class.solocation.inc.php,NONE,1.1 class.uilocation.inc.php,NONE,1.1 |
Date: |
Sun, 01 Jun 2003 17:38:49 -0400 |
Update of /cvsroot/phpgroupware/property/inc
In directory subversions:/tmp/cvs-serv19790/inc
Added Files:
class.bolocation.inc.php class.solocation.inc.php
class.uilocation.inc.php
Log Message:
no message
--- NEW FILE ---
<?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 bolocation
{
var $start;
var $query;
var $filter;
var $sort;
var $order;
var $cat_id;
var $public_functions = array
(
'read' => True,
'read_single' => True,
'save' => True,
'delete' => True,
'check_perms' => True
);
var $soap_functions = array(
'list' => array(
'in' =>
array('int','int','struct','string','int'),
'out' => array('array')
),
'read' => array(
'in' => array('int','struct'),
'out' => array('array')
),
'save' => array(
'in' => array('int','struct'),
'out' => array()
),
'delete' => array(
'in' => array('int','struct'),
'out' => array()
)
);
function bolocation($session=False)
{
$this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
$this->so =
CreateObject($this->currentapp.'.solocation');
$this->socommon =
CreateObject($this->currentapp.'.socommon');
$this->bocommon =
CreateObject($this->currentapp.'.bocommon');
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'));
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;
}
}
function read_sessiondata()
{
$data =
$GLOBALS['phpgw']->session->appsession('session_data','location');
$this->start = $data['start'];
$this->query = $data['query'];
$this->filter = $data['filter'];
$this->sort = $data['sort'];
$this->order = $data['order'];
$this->cat_id = $data['cat_id'];
}
function save_sessiondata($data)
{
if ($this->use_session)
{
$GLOBALS['phpgw']->session->appsession('session_data','location',$data);
}
}
function
select_category_location_list($format='',$selected='',$type_id='')
{
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->so->select_category_location_list($type_id);
while (is_array($categories) && list(,$category) =
each($categories))
{
$sel_category = '';
if ($category['id']==$selected)
{
$sel_category = 'selected';
}
$category_list[] = array
(
'cat_id' => $category['id'],
'name' => $category['name'],
'selected' => $sel_category
);
}
for ($i=0;$i<count($category_list);$i++)
{
if ($category_list[$i]['selected'] !=
'selected')
{
unset($category_list[$i]['selected']);
}
}
return $category_list;
}
function read($type_id='')
{
$location = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
'filter' => $this->filter,'cat_id' => $this->cat_id,'type_id' =>
$type_id));
$this->total_records = $this->so->total_records;
for ($i=0; $i<count($location); $i++)
{
$location[$i]['date'] =
$GLOBALS['phpgw']->common->show_date($location[$i]['date']);
$location[$i]['owner'] =
$GLOBALS['phpgw']->accounts->id2name($location[$i]['owner']);
}
return $location;
}
function read_single($location_code)
{
return $this->so->read_single($location_code);
}
function read_category_name($cat_id)
{
return $this->so->read_category_name($cat_id);
}
function save($location,$action='')
{
if ($location['access'])
{
$location['access'] = 'private';
}
else
{
$location['access'] = 'public';
}
if ($action=='edit')
{
if
($this->socommon->check_location($location['property_id'],$location['building_id'],$location['entrance_id'],$location['apartment_id']))
{
$receipt = $this->so->edit($location);
}
else
{
$receipt['error'][]=array('msg'=>lang('This location ID does not exist!'));
}
}
else
{
if(!$this->socommon->check_entrance($location['property_id'],$location['building_id'],$location['entrance_id']))
{
$receipt['error'][]=array('msg'=>lang('This Entrance ID does not exist!'));
}
if(!$receipt['error'])
{
$receipt = $this->so->add($location);
}
}
return $receipt;
}
function delete($location_code)
{
$this->so->delete($location_code);
}
}
?>
--- NEW FILE ---
<?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 solocation
{
var $grants;
function solocation()
{
$this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
$this->db = $GLOBALS['phpgw']->db;
$this->db2 = $this->db;
$this->grants =
$GLOBALS['phpgw']->acl->get_grants($this->currentapp);
$this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
if
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
{
$this->join = " JOIN ";
}
else
{
$this->join = " LEFT JOIN ";
}
}
function read_category_name($cat_id)
{
$this->db->query("SELECT descr FROM
fm_apartment_category where id='$cat_id'");
$this->db->next_record();
return $this->db->f('descr');
}
function select_category_location_list($type_id='')
{
if (!$type_id)
{
return;
}
$table= 'fm_location'. $type_id . '_category';
$this->db->query("SELECT id, descr FROM $table where id
>'0' ORDER BY descr ");
$i = 0;
while ($this->db->next_record())
{
$categories[$i]['id']
= $this->db->f('id');
$categories[$i]['name']
= stripslashes($this->db->f('descr'));
$i++;
}
return $categories;
}
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);
$type_id =
(isset($data['type_id'])?$data['type_id']:'');
}
if (!$type_id)
{
return;
}
else
{
/* $from .= "FROM '" .fm_location . "'. $type_id;
if($type_id>1);
{
$from = $this->join fm_location1 ON
fm_location$type_id.loc1 = fm_location1.loc1":
}
$from .= " $this->join fm_part_of_town ON
fm_location1.part_of_town_id = fm_part_of_town.id
if($stree_id)
{
$from .= " $this->join fm_streetaddress
ON fm_location1.street_id = fm_streetaddress.street_id
}
SELECT fm_location4.loc1, fm_location4.loc2, fm_location4.loc3,
fm_location4.loc4
FROM ((fm_location1 LEFT JOIN fm_location2 ON fm_location1.loc1 =
fm_location2.loc1) LEFT JOIN fm_location3 ON (fm_location2.loc2 =
fm_location3.loc2) AND (fm_location2.loc1 = fm_location3.loc1)) LEFT JOIN
fm_location4 ON (fm_location3.loc3 = fm_location4.loc3) AND (fm_location3.loc2
= fm_location4.loc2) AND (fm_location3.loc1 = fm_location4.loc1);
SELECT fm_location4.location_code
FROM (fm_location4 LEFT JOIN fm_location3 ON (fm_location4.loc3 =
fm_location3.loc3) AND (fm_location4.loc2 = fm_location3.loc2) AND
(fm_location4.loc1 = fm_location3.loc1)) LEFT JOIN (fm_location1 RIGHT JOIN
fm_location2 ON fm_location1.loc1 = fm_location2.loc1) ON (fm_location3.loc2 =
fm_location2.loc2) AND (fm_location3.loc1 = fm_location2.loc1);
*/
$from .= " FROM fm_location$type_id ";
for ($j=($type_id-1); $j>0; $j--)
{
$from .= " $this->join fm_location".
($j);
$on = 'ON';
for ($i=$j; $i>0; $i--)
{
$from .= " $on (fm_location" .
($j+1) .".loc" . ($i). " = fm_location" . ($j) . ".loc" . ($i) . ") ";
$on = 'AND';
}
}
echo $from;
$from = "FROM (fm_apartment $this->join"
. " fm_property ON fm_apartment.property_id =
fm_property.property_id $this->join"
. " fm_part_of_town ON
fm_property.part_of_town_id = fm_part_of_town.id $this->join"
. " fm_streetaddress ON fm_apartment.street_id
= fm_streetaddress.street_id $this->join"
. " fm_apartment_category ON
fm_apartment.cat_id = fm_apartment_category.id) $this->join fm_owner on
fm_property.owner_id = fm_owner.owner_id ";
$from .= " $this->join fm_owner on
fm_location1.owner_id = fm_owner.owner_id ";
}
if ($order)
{
$ordermethod = " order by $order $sort";
}
else
{
$ordermethod = ' order by
fm_apartment.property_id DESC';
}
if ($cat_id > 0)
{
$filtermethod .= " WHERE
fm_apartment.cat_id='$cat_id' ";
}
else
{
$filtermethod .= " WHERE
fm_apartment.cat_id!='99' ";
}
if ($filter)
{
$filtermethod .= " AND
fm_owner.category='$filter' ";
}
if($query)
{
$query = ereg_replace("'",'',$query);
$query = ereg_replace('"','',$query);
$querymethod = " AND fm_apartment.property_id
LIKE '%$query%' or street_name LIKE '%$query%' or fm_apartment.location_code
LIKE '%$query%'";
}
$sql = "SELECT
fm_apartment.location_code,fm_apartment.property_id,fm_property.name,building_id,entrance_id,floor,apartment_id,street_number,street_name"
. " FROM (fm_apartment $this->join"
. " fm_property ON fm_apartment.property_id =
fm_property.property_id $this->join"
. " fm_part_of_town ON
fm_property.part_of_town_id = fm_part_of_town.id $this->join"
. " fm_streetaddress ON fm_apartment.street_id
= fm_streetaddress.street_id $this->join"
. " fm_apartment_category ON
fm_apartment.cat_id = fm_apartment_category.id) $this->join fm_owner on
fm_property.owner_id = fm_owner.owner_id "
. " $filtermethod $querymethod ";
$this->db2->query($sql,__LINE__,__FILE__);
$this->total_records = $this->db2->num_rows();
$this->db->limit_query($sql .
$ordermethod,$start,__LINE__,__FILE__);
while ($this->db->next_record())
{
$ngrants =
(int)$this->grants[$this->db->f('apartment_owner')];
$apartment[] = array
(
'location_code' =>
$this->db->f('location_code'),
'property_id' =>
$this->db->f('property_id'),
'property_name' => $this->db->f('name'),
'building_id' =>
$this->db->f('building_id'),
'entrance_id' =>
$this->db->f('entrance_id'),
'floor' =>
$this->db->f('floor'),
'apartment_id' =>
$this->db->f('apartment_id'),
'street_name' =>
$this->db->f('street_name'),
'street_number' =>
$this->db->f('street_number'),
'owner' =>
$this->db->f('owner'),
'access' =>
$this->db->f('access'),
'date' =>
$this->db->f('entry_date'),
'cat_id' =>
(int)$this->db->f('cat_id'),
'descr' =>
stripslashes($this->db->f('descr')),
'grants' => $ngrants
);
}
return $apartment;
}
function read_single($location_code)
{
$sql = "SELECT
fm_apartment.property_id,fm_property.name,building_id,entrance_id,floor,apartment_id,fm_apartment.street_id,street_name,street_number,descr,fm_apartment.cat_id,fm_apartment.remark"
. " FROM fm_apartment $this->join"
. " fm_property ON fm_apartment.property_id =
fm_property.property_id $this->join"
. " fm_part_of_town ON
fm_property.part_of_town_id = fm_part_of_town.id $this->join"
. " fm_streetaddress ON fm_apartment.street_id
= fm_streetaddress.street_id"
. " where
fm_apartment.location_code='$location_code'";
$this->db->query($sql,__LINE__,__FILE__);
if ($this->db->next_record())
{
$apartment['location_code'] =
$this->db->f('location_code');
$apartment['property_id'] =
$this->db->f('property_id');
$apartment['property_name'] =
$this->db->f('name');
$apartment['building_id'] =
$this->db->f('building_id');
$apartment['entrance_id'] =
$this->db->f('entrance_id');
$apartment['floor']
= $this->db->f('floor');
$apartment['apartment_id'] =
$this->db->f('apartment_id');
$apartment['street_id'] =
$this->db->f('street_id');
$apartment['street_name'] =
$this->db->f('street_name');
$apartment['street_number'] =
$this->db->f('street_number');
$apartment['owner']
= $this->db->f('owner');
$apartment['descr']
= stripslashes($this->db->f('descr'));
$apartment['access'] =
$this->db->f('access');
$apartment['date']
= $this->db->f('entry_date');
$apartment['cat_id'] =
(int)$this->db->f('cat_id');
$apartment['remark'] =
$this->db->f('remark');
return $apartment;
}
}
function add($apartment)
{
$apartment['remark'] =
$this->db->db_addslashes($apartment['remark']);
$this->db->query("INSERT INTO fm_apartment
(location_code,
property_id,building_id,entrance_id,apartment_id,floor,street_id,street_number,owner,access,descr,cat_id,remark)
"
. "VALUES ('" .
$apartment['location_code']. "','" .
$apartment['property_id'] . "','" .
$apartment['building_id'] . "','" .
$apartment['entrance_id'] . "','" .
$apartment['apartment_id'] . "','" .
$apartment['floor'] . "','" .
$apartment['street_idd'] . "','" .
$apartment['street_number'] . "','" .
$this->account . "','" .
$apartment['access'] . "','" .
$apartment['descr'] ."','" .
$apartment['cat_id'] ."','" .
$apartment['remark']. "')",__LINE__,__FILE__);
$this->db->query("INSERT INTO fm_location
(location_code,type) "
. "VALUES ('". $apartment['location_code'].
"','apartment')",__LINE__,__FILE__);
$receipt['message'][] = array('msg'=>lang('Apartment
has been saved'));
return $receipt;
}
function edit($apartment)
{
$apartment['remark'] =
$this->db->db_addslashes($apartment['remark']);
$this->db->query("UPDATE fm_apartment set
cat_id='" . $apartment['cat_id']
. "',
floor='" . $apartment['floor'] . "',
street_id='" . $apartment['street_idd']
. "',
street_number='" .
$apartment['street_number'] . "',
descr='" . $apartment['descr'] . "',
access='" . $apartment['access'] . "',
remark='" . $apartment['remark']
. "' WHERE location_code= '" .
$apartment['location_code'] ."'",__LINE__,__FILE__);
$receipt['message'][] = array('msg'=>lang('Apartment
has been edited'));
return $receipt;
}
function delete($location_code )
{
$this->db->query("DELETE FROM fm_apartment WHERE
location_code='" . $location_code ."'",__LINE__,__FILE__);
$this->db->query("DELETE FROM fm_location WHERE
location_code='" . $location_code ."'",__LINE__,__FILE__);
}
}
?>
--- NEW FILE ---
<?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 uilocation
{
var $grants;
var $cat_id;
var $start;
var $query;
var $sort;
var $order;
var $filter;
var $currentapp;
var $public_functions = array
(
'index' => True,
'view' => True,
'edit' => True,
'delete' => True
);
function uilocation()
{
$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->grants =
$GLOBALS['phpgw']->acl->get_grants($this->currentapp);
$this->grants[$this->account] = PHPGW_ACL_READ +
PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE;
$this->bo =
CreateObject($this->currentapp.'.bolocation',True);
$this->boproperty =
CreateObject($this->currentapp.'.boproperty');
$this->bocommon =
CreateObject($this->currentapp.'.bocommon');
$this->socommon =
CreateObject($this->currentapp.'.socommon');
$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;
$GLOBALS['phpgw']->session->appsession('sub',$this->currentapp,'property');
}
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
);
$this->bo->save_sessiondata($data);
}
function index()
{
$GLOBALS['phpgw']->xslttpl->add_file(array('location',
'menu',
'nextmatchs',
'search_field'));
$type_id =
get_var('type_id',array('GET'));
$links = $this->bocommon->menu();
$location_list = $this->bo->read($type_id);
while (is_array($location_list) && list(,$location) =
each($location_list))
{
$content[] = array
(
'property_id'
=> $location['property_id'],
'building_id'
=> $location['building_id'],
'entrance_id'
=> $location['entrance_id'],
'floor'
=> $location['floor'],
'apartment_id'
=> $location['apartment_id'],
'street_name'
=> $location['street_name'],
'street_number'
=> $location['street_number'],
'descr'
=> $location['descr'],
'property_name'
=> $location['property_name'],
'link_view'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.view&location_code='
. $location['location_code']),
'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.edit&location_code='
. $location['location_code']),
'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.delete&location_code='
. $location['location_code']),
'lang_view_statustext' =>
lang('view the location'),
'lang_edit_statustext' =>
lang('edit the location'),
'lang_delete_statustext' =>
lang('delete the location'),
'text_view'
=> lang('view'),
'text_edit'
=> lang('edit'),
'text_delete'
=> lang('delete')
);
}
$table_header[] = array
(
'sort_street_name' =>
$this->nextmatchs->show_sort_order(array
(
'sort' => $this->sort,
'var' => 'street_name',
'order' => $this->order,
'extra' => array('menuaction' =>
$this->currentapp.'.uilocation.index',
'cat_id'
=>$this->cat_id)
)),
'lang_floor' => lang('Floor'),
'lang_street_name' => lang('Street name'),
'lang_street_number'=> lang('Street number'),
'lang_view' => lang('view'),
'lang_edit' => lang('edit'),
'lang_delete' => lang('delete'),
'sort_property_id' =>
$this->nextmatchs->show_sort_order(array
(
'sort' => $this->sort,
'var' => 'property_id',
'order' => $this->order,
'extra' => array('menuaction' =>
$this->currentapp.'.uilocation.index',
'cat_id'
=>$this->cat_id)
)),
'lang_property_id' => lang('property id'),
'lang_property_id' =>
lang('property id'),
'lang_building_id' =>
lang('building id'),
'lang_entrance_id' =>
lang('entrance id'),
'lang_apartment_id' =>
lang('apartment id'),
'lang_owner' => lang('owner')
);
$table_add[] = array
(
'lang_add' =>
lang('add'),
'lang_add_statustext' => lang('add a
location'),
'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.edit')
);
$link_data = array
(
'menuaction' =>
$this->currentapp.'.uilocation.index',
'sort'
=>$this->sort,
'order'
=>$this->order,
'cat_id'
=>$this->cat_id,
'district_id'
=>$this->district_id,
'filter'
=>$this->filter,
'query'
=>$this->query
);
$data = array
(
'overlib_source'
=> './'.$this->currentapp.'/inc/overlib.js',
'lang_property_name' =>
lang('Property name'),
'links'
=> $links,
'allow_allrows'
=> false,
'start_record'
=> $this->start,
'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
'num_records'
=> count($location_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_no_cat'
=> lang('no category'),
'lang_cat_statustext' =>
lang('Select the category the location belongs to. To do not use a category
select NO CATEGORY'),
'select_name'
=> 'cat_id',
'cat_list'
=>
$this->bo->select_category_location_list('filter',$this->cat_id,$type_id),
'select_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
'filter_name'
=> 'filter',
'filter_list'
=> $this->boproperty->get_filter_list('filter', $this->filter),
'lang_show_all'
=> lang('Show all'),
'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
);
$appname
= lang('location');
$function_msg =
lang('list location');
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list' => $data));
$this->save_sessiondata();
}
function edit()
{
$location_code =
get_var('location_code',array('POST','GET'));
$location = split('-',$location_code);
$property_id = $location[0];
$building_id = $location[1];
$entrance_id = $location[2];
$apartment_id = $location[3];
$values =
get_var('values',array('POST','GET'));
if($values)
{
$values = $values +
$this->bocommon->get_location();
}
$values['street_idd'] =
get_var('street_idd',array('POST'));
//echo 'location_code :' .$location_code. '<br>';
//_debug_array($values);
//_debug_array($location);
$values_attribute =
get_var('values_attribute',array('POST','GET'));
$GLOBALS['phpgw']->xslttpl->add_file(array('location'));
if ($values['save'])
{
if(!$values['property_id'] && !$property_id)
{
$receipt['error'][]=array('msg'=>lang('Please select a Property ID !'));
$error_property_id=true;
$error_id=true;
}
if(!$values['building_id'] && !$building_id)
{
$receipt['error'][]=array('msg'=>lang('Please select a Building ID !'));
$error_building_id=true;
$error_id=true;
}
if(!$values['entrance_id'] && !$entrance_id)
{
$receipt['error'][]=array('msg'=>lang('Please select a Entrance ID !'));
$error_entrance_id=true;
$error_id=true;
}
if(!$values['apartment_id'] && !$apartment_id)
{
$receipt['error'][]=array('msg'=>lang('Please enter a Apartment ID !'));
$error_apartment_id=true;
$error_id=true;
}
if($values['property_id'] &&
$values['building_id'] && $values['entrance_id'] && $values['apartment_id'])
{
if($this->socommon->check_location($values['property_id'],$values['building_id'],$values['entrance_id'],$values['apartment_id']))
{
$receipt['error'][]=array('msg'=>lang('This location is already registered!') .
'[
'.$values['property_id'].'-'.$values['building_id'].'-'.$values['entrance_id'].'-'.$values['apartment_id'].'
]');
$error_location_id=true;
$error_id=true;
}
}
if($location_id)
{
$values['property_id']=$property_id;
$values['building_id']=$building_id;
$values['entrance_id']=$entrance_id;
$values['apartment_id']=$apartment_id;
$values['location_code']=$location_code;
$action='edit';
}
else
{
$values['location_code'] =
$this->bocommon->location_code($values['property_id'],$values['building_id'],$values['entrance_id'],$values['apartment_id']);
$location_code=$values['location_code'];
}
if(!$receipt['error'])
{
$receipt =
$this->bo->save($values,$action);
if($values_attribute)
{
$this->bocommon->save_attributes($values_attribute,'location');
}
}
}
if(!$error_id)
{
$values =
$this->bo->read_single($location_code);
}
if ($location_id)
{
$function_msg = lang('edit location');
}
else
{
$function_msg = lang('add location');
}
if ($values['cat_id'] > 0)
{
$this->cat_id = $values['cat_id'];
}
if($error_property_id)
{
unset($values['property_id']);
}
if($error_location_id)
{
unset($values['location_id']);
}
$link_data = array
(
'menuaction' =>
$this->currentapp.'.uilocation.edit',
'location_code' => $location_code
);
if($values['location_id'])
{
$attributes_values =
$this->bocommon->read_attibutes(array('form'=>true,'type'=>location,'type_id'=>4,'id'=>$property_id
. '-' . $building_id . '-' . $entrance_id . '-' . $apartment_id));
$attributes_header[] = array
(
'lang_name' => lang('Name'),
'lang_descr' => lang('Description'),
'lang_datatype' => lang('Datatype'),
'lang_value' => lang('Value')
);
$location_type='view';
}
else
{
$location_type='form';
}
$location_data=$this->bocommon->initiate_ui_location(array(
'location_type' =>
$location_type,
'entrance' => True,
'property_id' =>
$values['property_id'],
'property_name' =>
$values['property_name'],
'building_id' =>
$values['building_id'],
'entrance_id' =>
$values['entrance_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
(
'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',
'street_link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.street'),
'location_type'
=> $location_type,
'location_data'
=> $location_data,
'lang_attributes'
=> lang('Attributes'),
'attributes_header'
=> $attributes_header,
'attributes_values'
=> $attributes_values,
'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.index'),
'lang_location_id'
=> lang('location ID'),
'lang_floor'
=> lang('floor'),
'lang_street'
=> lang('Street'),
'lang_name'
=> lang('name'),
'lang_descr'
=> lang('Description'),
'lang_category'
=> lang('category'),
'lang_access'
=> lang('private'),
'lang_save'
=> lang('save'),
'lang_done'
=> lang('done'),
'lang_remark'
=> lang('remark'),
'value_location_id' =>
$values['location_id'],
'value_floor'
=> $values['floor'],
'value_street'
=> $values['street_name'],
'value_street_idd'
=> $values['street_id'],
'value_street_number' =>
$values['street_number'],
'value_name'
=> $values['name'],
'value_descr'
=> $values['descr'],
'value_access'
=> $values['access'],
'value_street_name'
=> $values['street_name'],
'value_remark'
=> $values['remark'],
'error_flag'
=> $error_id,
'lang_name_statustext' =>
lang('Enter the name of the location'),
'lang_select_street_help' =>
lang('Select the street name'),
'lang_street_num_statustext' => lang('Enter
the street number'),
'lang_location_id_statustext' => lang('Enter
location ID'),
'lang_floor_statustext' =>
lang('Enter the floor'),
'lang_descr_statustext' =>
lang('Enter the description'),
'lang_done_statustext' =>
lang('Back to the list'),
'lang_save_statustext' =>
lang('Save the location'),
'lang_access_off_statustext' => lang('The
location is public. If the location should be private, check this box'),
'lang_access_on_statustext' =>
lang('The location is private. If the location should be public, uncheck this
box'),
'lang_no_cat'
=> lang('no category'),
'lang_cat_statustext' =>
lang('Select the category the location belongs to. To do not use a category
select NO CATEGORY'),
'select_name'
=> 'values[cat_id]',
'lang_remark_statustext' =>
lang('Enter any remarks regarding this location'),
'cat_list'
=> $this->bo->select_category_location_list('select',$values['cat_id'])
);
$appname
= lang('location');
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
}
function delete()
{
$location_code =
get_var('location_code',array('GET'));
$confirm = get_var('confirm',array('POST'));
$link_data = array
(
'menuaction' =>
$this->currentapp.'.uilocation.index'
);
if (get_var('confirm',array('POST')))
{
$this->bo->delete($location_code);
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.'.uilocation.delete&location_code='
. $location_code),
'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('location');
$function_msg =
lang('delete location');
$GLOBALS['phpgw_info']['flags']['app_header'] =
lang($this->currentapp) . ' - ' . $appname . ': ' . $function_msg;
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
}
function view()
{
$location_code =
get_var('location_code',array('GET'));
$location =
split('-',$location_code);
$property_id = $location[0];
$building_id = $location[1];
$entrance_id = $location[2];
$apartment_id = $location[3];
$GLOBALS['phpgw']->xslttpl->add_file(array('location'));
$values = $this->bo->read_single($location_code);
$attributes_values =
$this->bocommon->read_attibutes(array('form'=>false,'type'=>location,'type_id'=>4,'id'=>$location_code));
$attributes_header[] = array
(
'lang_name' => lang('Name'),
'lang_descr' => lang('Description'),
'lang_datatype' => lang('Datatype'),
'lang_value' => lang('Value')
);
$location_type='view';
$location_data=$this->bocommon->initiate_ui_location(array(
'location_type' =>
$location_type,
'apartment' => True,
'property_id' =>
$values['property_id'],
'property_name' =>
$values['property_name'],
'building_id' =>
$values['building_id'],
'entrance_id' =>
$values['entrance_id'],
'floor' =>
$values['floor'],
'apartment_id' =>
$values['apartment_id'],
'street_name' =>
$values['street_name'],
'street_number' =>
$values['street_number']));
$data = array
(
'location_type'
=> $location_type,
'location_data'
=> $location_data,
'lang_attributes'
=> lang('Attributes'),
'attributes_header'
=> $attributes_header,
'attributes_values'
=> $attributes_values,
'value_name'
=> $values['name'],
'value_descr'
=> $values['descr'],
'value_access'
=> $values['access'],
'value_remark'
=> $values['remark'],
'lang_remark'
=> lang('remark'),
'value_category'
=> $this->bo->read_category_name($values['cat_id']),
'lang_name'
=> lang('name'),
'lang_descr'
=> lang('Description'),
'lang_category'
=> lang('category'),
'lang_done'
=> lang('done'),
'lang_edit'
=> lang('Edit'),
'edit_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.edit&location_code='
. $location_code),
'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilocation.index'),
'lang_done_statustext' => lang('Back
to the list'),
'lang_edit_statustext' => lang('Edit
this entry equipment'),
);
$appname
= lang('location');
$function_msg =
lang('view location');
$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] CVS: property/inc class.bolocation.inc.php,NONE,1.1 class.solocation.inc.php,NONE,1.1 class.uilocation.inc.php,NONE,1.1,
Sigurd Nes <address@hidden> <=