[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: property/inc class.boworkorder.inc.php,NONE,1.1
From: |
Sigurd Nes <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: property/inc class.boworkorder.inc.php,NONE,1.1 class.soworkorder.inc.php,NONE,1.1class.uiworkorder.inc.php,NONE,1.1 |
Date: |
Wed, 12 Mar 2003 16:40:00 -0500 |
Update of /cvsroot/phpgroupware/property/inc
In directory subversions:/tmp/cvs-serv10872/inc
Added Files:
class.boworkorder.inc.php class.soworkorder.inc.php
class.uiworkorder.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 boworkorder
{
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 boworkorder($session=False)
{
$this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
$this->so =
CreateObject($this->currentapp.'.soworkorder');
$this->socommon =
CreateObject($this->currentapp.'.socommon');
$this->bocommon =
CreateObject($this->currentapp.'.bocommon');
$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'));
$status_id =
get_var('status_id',array('POST','GET'));
if ($start)
{
$this->start=$start;
}
else
{
$this->start=0;
}
if(isset($query))
{
$this->query = $query;
}
if(!empty($filter))
{
$this->filter = $filter;
}
if(isset($sort))
{
$this->sort = $sort;
}
if(isset($order))
{
$this->order = $order;
}
if(isset($cat_id))
{
$this->cat_id = $cat_id;
}
if(isset($status_id))
{
$this->status_id = $status_id;
}
}
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();
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 select_branch_list($selected='')
{
$branch_entries= $this->so->select_branch_list();
while (is_array($branch_entries) && list(,$branch) =
each($branch_entries))
{
$sel_branch = '';
if ($branch['id']==$selected)
{
$sel_branch = 'selected';
}
$branch_list[] = array
(
'id' => $branch['id'],
'name' => $branch['name'],
'selected' => $sel_branch
);
}
for ($i=0;$i<count($branch_list);$i++)
{
if ($branch_list[$i]['selected'] != 'selected')
{
unset($branch_list[$i]['selected']);
}
}
return $branch_list;
}
function select_branch_p_list($project_id='')
{
$selected =
$this->so->branch_p_list($project_id);
$branch_entries = $this->so->select_branch_list();
$j=0;
while (is_array($branch_entries) && list(,$branch) =
each($branch_entries))
{
$branch_list[$j]['id'] = $branch['id'];
$branch_list[$j]['name'] = $branch['name'];
for ($i=0;$i<count($selected);$i++)
{
if($selected[$i]['branch_id'] ==
$branch['id'])
{
$branch_list[$j]['selected'] =
'selected';
}
}
$j++;
}
for ($i=0;$i<count($branch_list);$i++)
{
if ($branch_list[$i]['selected'] != 'selected')
{
unset($branch_list[$i]['selected']);
}
}
return $branch_list;
}
function select_key_location_list($selected='')
{
$key_location_entries=
$this->so->select_key_location_list();
while (is_array($key_location_entries) &&
list(,$key_location) = each($key_location_entries))
{
$sel_key_location = '';
if ($key_location['id']==$selected)
{
$sel_key_location = 'selected';
}
$key_location_list[] = array
(
'id' => $key_location['id'],
'name' =>
$key_location['name'],
'selected' => $sel_key_location
);
}
for ($i=0;$i<count($key_location_list);$i++)
{
if ($key_location_list[$i]['selected'] !=
'selected')
{
unset($key_location_list[$i]['selected']);
}
}
return $key_location_list;
}
function select_category_project_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->so->select_category_workorder_list();
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 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_project()
{
$project = $this->so->read_project(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
'filter' => $this->filter,'cat_id' => $this->cat_id,'status_id' =>
$this->status_id));
$this->total_records = $this->so->total_records;
$dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
for ($i=0; $i<count($project); $i++)
{
$project[$i]['coordinator'] =
$GLOBALS['phpgw']->accounts->id2name($project[$i]['coordinator']);
$project[$i]['start_date'] =
$GLOBALS['phpgw']->common->show_date($project[$i]['start_date'],$dateformat);
}
return $project;
}
function read_single_p($project_id)
{
$project
= $this->so->read_single_p($project_id);
$dateformat
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
$project['start_date'] =
$GLOBALS['phpgw']->common->show_date($project['start_date'],$dateformat);
$project['end_date'] =
$GLOBALS['phpgw']->common->show_date($project['end_date'],$dateformat);
$workorder_budget =
$this->so->project_budget_from_workorder($project_id);
for ($i=0;$i<count($workorder_budget);$i++)
{
$sum_workorder_budget=
$sum_workorder_budget+$workorder_budget[$i]['budget'];
$project['workorder_budget'][$i]['workorder_id']=$workorder_budget[$i]['workorder_id'];
$project['workorder_budget'][$i]['budget']=number_format($workorder_budget[$i]['budget'],
2, ',', ' ');
}
$project['sum_workorder_budget']=
number_format($sum_workorder_budget, 2, ',', ' ');
//_debug_array($project);
return $project;
}
function select_part_of_town($part_of_town_id)
{
return
$this->socommon->select_part_of_town($part_of_town_id);
}
function p_save($project,$action='')
{
$date = $this->bocommon->date_array($project['date']);
$project['date'] = mktime
(2,0,0,$date['month'],$date['day'],$date['year']);
if ($action=='edit')
{
$receipt = $this->so->p_edit($project);
}
else
{
$project['location_code']=$this->bocommon->location_code($project['property_id'],$project['building_id'],$project['entrance_id'],$project['apartment_id']);
$receipt = $this->so->p_add($project);
}
return $receipt;
}
function read_single_equipment_type($equipment_type_id)
{
return
$this->so->read_single_equipment_type($equipment_type_id);
}
function delete($equipment_id)
{
$this->so->delete($equipment_id);
}
}
?>
--- 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 soworkorder
{
var $grants;
function soworkorder()
{
$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'];
$this->bocommon =
CreateObject($this->currentapp.'.bocommon',True);
if
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
{
$this->join = " JOIN ";
}
else
{
$this->join = " LEFT JOIN ";
}
}
function select_category_workorder_list()
{
$this->db->query("SELECT id, descr FROM
fm_wo_workorder_category 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 select_status_list()
{
$this->db->query("SELECT id, descr FROM
fm_wo_wrkorders_status ORDER BY id ");
$i = 0;
while ($this->db->next_record())
{
$status_entries[$i]['id']
= $this->db->f('id');
$status_entries[$i]['name']
= stripslashes($this->db->f('descr'));
$i++;
}
return $status_entries;
}
function select_branch_list()
{
$this->db->query("SELECT id, descr FROM fm_wo_branch
ORDER BY id ");
$i = 0;
while ($this->db->next_record())
{
$branch_entries[$i]['id']
= $this->db->f('id');
$branch_entries[$i]['name']
= stripslashes($this->db->f('descr'));
$i++;
}
return $branch_entries;
}
function select_key_location_list()
{
$this->db->query("SELECT id, descr FROM fm_wo_key_loc
ORDER BY descr ");
$i = 0;
while ($this->db->next_record())
{
$key_location_entries[$i]['id']
= $this->db->f('id');
$key_location_entries[$i]['name']
= stripslashes($this->db->f('descr'));
$i++;
}
return $key_location_entries;
}
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())
{
$ngrants =
(int)$this->grants[$this->db->f('fm_equipment.owner')];
$filter_list[] = array
(
'id' => $this->db->f('id'),
'name' => $this->db->f('name'),
);
}
return $filter_list;
}
function read_project($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);
$status_id =
(isset($data['status_id'])?$data['status_id']:0);
}
if ($order)
{
$ordermethod = " order by $order $sort";
}
else
{
$ordermethod = ' order by fm_wo_project.id ASC';
}
$filtermethod = ' ( fm_wo_project.owner=' .
$this->account;
if (is_array($this->grants))
{
$grants = $this->grants;
while (list($user) = each($grants))
{
$public_user_list[] = $user;
}
reset($public_user_list);
$filtermethod .= " OR
(fm_wo_project.access='public' OR fm_wo_project.owner IN(" .
implode(',',$public_user_list) . ")))";
}
else
{
$filtermethod .= ' )';
}
if ($cat_id > 0)
{
$filtermethod .= " AND
fm_wo_project.category='$cat_id' ";
}
if ($status_id)
{
$filtermethod .= " AND
fm_wo_project.status='$status_id' ";
}
if ($filter)
{
$filtermethod .= " AND
fm_wo_project.coordinator='$filter' ";
}
if($query)
{
$query = ereg_replace("'",'',$query);
$query = ereg_replace('"','',$query);
$querymethod = " AND fm_wo_project.title LIKE
'%$query%' or fm_wo_project.descr LIKE '%$query%'";
}
$sql = "SELECT * FROM fm_wo_project $this->join
phpgw_accounts ON fm_wo_project.owner = phpgw_accounts.account_id WHERE
$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('fm_wo_project.owner')];
$project_list[] = array
(
'project_id' =>
$this->db->f('id'),
'name' =>
stripslashes($this->db->f('name')),
'start_date' =>
$this->db->f('start_date'),
'coordinator' =>
$this->db->f('coordinator'),
'equipment_id' =>
$this->db->f('equipment_id'),
'location_code' =>
$this->db->f('location_code'),
'property_id' =>
$this->db->f('property_id'),
'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' =>
$this->db->f('street_name') .' ' . $this->db->f('street_number'),
'street_name' =>
$this->db->f('street_name'),
'street_number' =>
$this->db->f('street_number'),
'category' =>
$this->db->f('category'),
'title' =>
$this->db->f('title'),
'grants' => $ngrants
);
}
return $project_list;
}
function read_single_p($project_id)
{
$sql = "SELECT * from fm_wo_project where
id='$project_id'";
$this->db->query($sql,__LINE__,__FILE__);
if ($this->db->next_record())
{
$project['project_id']
= $this->db->f('id');
$project['title']
= $this->db->f('title');
$project['name']
= $this->db->f('name');
$project['equipment_id'] =
$this->db->f('equipment_id');
$project['location_code'] =
$this->db->f('location_code');
$project['property_id'] =
$this->db->f('property_id');
$project['property_name'] =
$this->db->f('property_name');
$project['building_id'] =
$this->db->f('building_id');
$project['entrance_id'] =
$this->db->f('entrance_id');
$project['apartment_id'] =
$this->db->f('apartment_id');
$project['floor']
= $this->db->f('floor');
$project['contact_phone'] =
$this->db->f('contact_phone');
$project['key_fetch'] =
$this->db->f('key_fetch');
$project['key_deliver'] =
$this->db->f('key_deliver');
$project['other_branch'] =
$this->db->f('other_branch');
$project['key_responsible'] =
$this->db->f('key_responsible');
$project['charge_tenant'] =
$this->db->f('charge_tenant');
$project['descr']
= $this->db->f('descr');
$project['status']
= $this->db->f('status');
$project['budget']
= $this->db->f('budget');
$project['actual_cost'] =
$this->db->f('actual_cost');
$project['vendor_id'] =
$this->db->f('vendor_id');
$project['lifetime'] =
$this->db->f('lifetime');
$project['street_name'] =
$this->db->f('street_name');
$project['street_number'] =
$this->db->f('street_number');
$project['owner']
= $this->db->f('owner');
$project['coordinator'] =
$this->db->f('coordinator');
$project['access']
= $this->db->f('access');
$project['start_date'] =
$this->db->f('start_date');
$project['end_date'] =
$this->db->f('end_date');
$project['cat_id']
= $this->db->f('category');
//_debug_array($project);
return $project;
}
}
function project_budget_from_workorder($project_id = '')
{
$this->db->query("select budget, id as workorder_id
from fm_wo_wrkorders where project_id='$project_id'");
while ($this->db->next_record())
{
$budget[] = array(
'workorder_id' =>
$this->db->f('workorder_id'),
'budget' =>
sprintf("%01.2f",$this->db->f('budget'))
);
}
return $budget;
}
function branch_p_list($project_id = '')
{
$this->db2->query("SELECT branch_id from
fm_wo_projectbranch WHERE project_id='$project_id' ",__LINE__,__FILE__);
while ($this->db2->next_record())
{
$selected[] = array('branch_id' =>
$this->db2->f('branch_id'));
}
return $selected;
}
function check_equipment($equipment_id='')
{
$this->db->query("SELECT count(*) FROM fm_equipment
where equipment_id='$equipment_id'");
$this->db->next_record();
if ( $this->db->f(0))
{
return True;
}
}
function read_single_equipment_type($equipment_type_id)
{
$this->db->query("SELECT name FROM fm_equipment_type
where id='$equipment_type_id'");
$this->db->next_record();
return $this->db->f('name');
}
function generate_id($equipment_type)
{
$year =
$GLOBALS['phpgw']->common->show_date(time(),'Y');
$this->db->query("select prefix from fm_equipment_type
where id='$equipment_type' ");
$this->db->next_record();
$prefix = $this->db->f('prefix');
//echo 'prefix ' .$prefix .'<br>' ;
// $prefix = $prefix . $year . '-';
$pos = strlen($prefix);
$this->db->query("select max(equipment_id) from
fm_equipment where equipment_id like ('$prefix%')");
$this->db->next_record();
$max =
$this->bocommon->add_leading_zero(substr($this->db->f(0),$pos));
return $prefix . $max;
}
function p_add($project)
{
$project['descr'] =
$this->db->db_addslashes($project['descr']);
//_debug_array($project);
$this->db->query("INSERT INTO fm_wo_project
(id,equipment_id,lifetime,status,equipment_type_id,cost,date,descr,location_code,
property_id,property_name,building_id,entrance_id,floor,apartment_id,street_name,street_number,vendor_id,owner)
"
. "VALUES ('"
. $project['project_id']. "','"
. $project['equipment_id']. "','"
. $project['lifetime']. "','"
. $project['status']. "','"
. $project['cat_id']. "','"
. $project['cost']. "','"
. $project['date']. "','"
. $project['descr']. "','"
. $project['location_code']. "','"
. $project['property_id']. "','"
. $project['property_name']. "','"
. $project['building_id']. "','"
. $project['entrance_id']. "','"
. $project['floor']. "','"
. $project['apartment_id'] . "','"
. $project['street_name'] . "','"
. $project['street_number'] . "','"
. $project['vendor_id'] . "','"
. $this->account. "')",__LINE__,__FILE__);
$receipt['message'][] = array('msg'=>lang('project has
been saved'));
return $receipt;
}
function edit($equipment)
{
$equipment['descr'] =
$this->db->db_addslashes($equipment['descr']);
$this->db->query("UPDATE fm_equipment set
lifetime='" . $equipment['lifetime'] . "',
status='" . $equipment['status'] . "',
equipment_type_id='" . $equipment['cat_id']
. "',
cost='" . $equipment['cost'] . "',
date='" . $equipment['date'] . "',
descr='" . $equipment['descr'] . "',
location_code='" . $equipment['location_code']
. "',
property_id='" . $equipment['property_id'] . "',
property_name='" . $equipment['property_name']
. "',
building_id='" . $equipment['building_id'] . "',
entrance_id='" . $equipment['entrance_id'] . "',
floor='" . $equipment['floor'] . "',
apartment_id='" . $equipment['apartment_id'] .
"',
street_name='" . $equipment['street_name'] . "',
street_number='" . $equipment['street_number']
. "',
vendor_id='" . $equipment['vendor_id']
. "' WHERE equipment_id= '" .
$equipment['equipment_id'] ."'",__LINE__,__FILE__);
$receipt['message'][] = array('msg'=>lang('equipment
has been edited'));
return $receipt;
}
function delete($equipment_id )
{
$this->db->query("DELETE FROM fm_equipment WHERE
equipment_id='" . $equipment_id . "'",__LINE__,__FILE__);
$this->db->query("DELETE FROM fm_equipment_attrib WHERE
entity_id='" . $equipment_id . "'",__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 uiworkorder
{
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
(
'project_list' => True,
'view' => True,
'p_edit' => True,
'delete' => True
);
function uiworkorder()
{
$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.'.boworkorder',True);
$this->so =
CreateObject($this->currentapp.'.soworkorder',True);
$this->bocommon =
CreateObject($this->currentapp.'.bocommon',True);
$this->socommon =
CreateObject($this->currentapp.'.socommon',True);
$this->config =
CreateObject('phpgwapi.config');
$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->status_id =
$this->bo->status_id;
$GLOBALS['phpgw']->session->appsession('sub',$this->currentapp,'workorder');
}
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->bocommon->save_sessiondata($data);
}
function project_list()
{
$GLOBALS['phpgw']->xslttpl->add_file(array('workorder',
'menu',
'nextmatchs',
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP .
'app_header',
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP .
'search_field'));
$sub = get_var('sub',array('POST','GET'));
$links = $this->bocommon->menu($sub);
$project_list = $this->bo->read_project();
//_debug_array($project_list);
while (is_array($project_list) && list(,$project) =
each($project_list))
{
$content[] = array
(
'title'
=> $project['title'],
'project_id'
=> $project['project_id'],
'descr'
=> $project['descr'],
'property_id'
=> $project['property_id'],
'building_id'
=> $project['building_id'],
'entrance_id'
=> $project['entrance_id'],
'floor'
=> $project['floor'],
'apartment_id'
=> $project['apartment_id'],
'street'
=> $project['street'],
'start_date'
=> $project['start_date'],
'coordinator'
=> $project['coordinator'],
'link_view'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.view&id='
. $project['project_id']),
'link_edit'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.p_edit&id='
. $project['project_id']),
'link_delete'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.delete&project_id='
. $project['project_id']),
'lang_view_statustext' =>
lang('view the project'),
'lang_edit_statustext' =>
lang('edit the project'),
'lang_delete_statustext' =>
lang('delete this project'),
'text_view'
=> lang('view'),
'text_edit'
=> lang('edit'),
'text_delete'
=> lang('delete')
);
}
$table_header[] = array
(
'sort_project' =>
$this->nextmatchs->show_sort_order(array
(
'sort' => $this->sort,
'var' => 'id',
'order' => $this->order,
'extra' => array('menuaction' =>
$this->currentapp.'.uiworkorder.project_list',
'cat_id'
=>$this->cat_id,
'district_id' =>
$this->district_id,
'filter'
=>$this->filter,
'query'
=>$this->query)
)),
'lang_project' => lang('project'),
'lang_title' => lang('Title'),
'sort_property' =>
$this->nextmatchs->show_sort_order(array
(
'sort' => $this->sort,
'var' => 'property_id',
'order' => $this->order,
'extra' => array('menuaction' =>
$this->currentapp.'.uiworkorder.project_list',
'cat_id'
=>$this->cat_id,
'district_id' =>
$this->district_id,
'filter'
=>$this->filter,
'query'
=>$this->query)
)),
'lang_property' => lang('Property'),
'lang_building' => lang('Building'),
'lang_entrance' => lang('Entrance'),
'lang_floor' => lang('Floor'),
'lang_apartment' => lang('Apartment'),
'sort_street_name' =>
$this->nextmatchs->show_sort_order(array
(
'sort' => $this->sort,
'var' => 'street_name',
'order' => $this->order,
'extra' => array('menuaction' =>
$this->currentapp.'.uiworkorder.project_list',
'cat_id'
=>$this->cat_id,
'district_id' =>
$this->district_id,
'filter'
=>$this->filter,
'query'
=>$this->query)
)),
'lang_street_name' => lang('Street Name'),
'lang_street_num' => lang('Num'),
'lang_start_date' => lang('Start date'),
'lang_coordinator' => lang('Coordinator'),
'lang_view' => lang('view'),
'lang_edit' => lang('edit'),
'lang_delete' => lang('delete')
);
$table_add[] = array
(
'lang_add' =>
lang('add'),
'lang_add_statustext' => lang('add a
project'),
'add_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.p_edit')
);
$link_data = array
(
'menuaction' =>
$this->currentapp.'.uiworkorder.project_list',
'sort'
=>$this->sort,
'order'
=>$this->order,
'cat_id'
=>$this->cat_id,
'district_id'
=>$this->district_id,
'filter'
=>$this->filter,
'query'
=>$this->query
);
$data = array
(
'links'
=> $links,
'allow_allrows'
=> false,
'start_record'
=> $this->start,
'record_limit'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
'num_records'
=> count($project_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'),
'appname'
=> lang($this->currentapp),
'function_msg'
=> lang('list project'),
'lang_no_cat'
=> lang('no category'),
'lang_cat_statustext' =>
lang('Select the category the project belongs to. To do not use a category
select NO CATEGORY'),
'select_name'
=> 'cat_id',
'cat_list'
=> $this->bo->select_category_project_list('filter',$this->cat_id),
'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 the agreement belongs to. To do not use a category
select NO STATUS'),
'status_name'
=> 'status_id',
'lang_no_status'
=> lang('No status'),
'status_list'
=> $this->bo->select_status_list('filter',$this->status_id),
'lang_user_statustext' =>
lang('Select the user the project belongs to. 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('filter',$this->filter),
'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_submit'
=> lang('submit'),
'table_header_project' =>
$table_header,
'values_project'
=> $content,
'table_add'
=> $table_add
);
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_project' => $data));
$this->save_sessiondata();
}
function p_edit()
{
$id =
get_var('id',array('POST','GET'));
$values =
get_var('values',array('POST'));
$GLOBALS['phpgw']->xslttpl->add_file(array('workorder',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
. SEP . 'app_header'));
$values['equipment_id'] =
get_var('equipment_idd',array('POST'));
$values['property_id'] =
get_var('property_id',array('POST'));
$values['property_name'] =
get_var('property_name',array('POST'));
$values['building_id'] =
get_var('building_id',array('POST'));
$values['entrance_id'] =
get_var('entrance_id',array('POST'));
$values['floor'] =
get_var('floor',array('POST'));
$values['apartment_id'] =
get_var('apartment_id',array('POST'));
$values['street_name'] =
get_var('street_name',array('POST'));
$values['street_number'] =
get_var('street_number',array('POST'));
// $values['vendor_id'] =
get_var('vendor_id',array('POST'));
// $values['vendor_name'] =
get_var('vendor_name',array('POST'));
$values['start_date'] =
get_var('start_date',array('POST'));
$values['end_date'] =
get_var('end_date',array('POST'));
$this->config->read_repository();
if ($values['save'])
{
if(!$values['name'])
{
$receipt['error'][]=array('msg'=>lang('Please enter a project NAME !'));
$error_id=true;
}
if(!$values['cat_id'])
{
$receipt['error'][]=array('msg'=>lang('Please select a category !'));
$error_id=true;
}
if(!$values['status'])
{
$receipt['error'][]=array('msg'=>lang('Please select a status !'));
}
if($id)
{
$values['project_id']=$id;
$action='edit';
}
else
{
$values['project_id']=$this->socommon->next_id('fm_wo_project');
}
if(!$receipt['error'])
{
$receipt =
$this->bo->p_save($values,$action);
$id = $values['project_id'];
$function_msg = lang('Edit Project');
if ($values['approval'])
{
$coordinator_name=$GLOBALS['phpgw_info']['user']['fullname'];
$coordinator_email=$GLOBALS['phpgw_info']['user']['preferences']['email']['address'];
$headers = "Return-Path: <".
$coordinator_email .">\r\n";
$headers .= "From: " .
$coordinator_name . "<" . $coordinator_email .">\r\n";
$headers .= "Bcc: " .
$coordinator_name . "<" . $coordinator_email .">\r\n";
$headers .= "Content-type:
text/plain; charset=iso-8859-1\r\n";
$subject = lang(Approval).": ".
$values['project_id'];
$message = lang(Project) . " "
. $values['project_id'] ." ". lang(needs_approval);
$mail_method=
$this->config->config_data['fmwrkorder_mail'];
if ($mail_method=='smtp'):
{
$bcc =
$coordinator_email;
$send =
CreateObject('phpgwapi.send');
$rcpt =
$send->msg('email', $to_approval_from_email, $subject, stripslashes($message),
'', $cc, $bcc, $coordinator_email, $coordinator_name, 'plain');
}
elseif
($mail_method=='sendmail'):
{
$rcpt=mail($to_approval_from_email,$subject,$message, $headers);
}
else:
{
$receipt['error'][]=array('msg'=>lang('Mailing method is not chosen! ("admin"
section)'));
}
endif;
}
}
}
else
{
if ($id)
{
$values = $this->bo->read_single_p($id);
}
}
if ($id)
{
$function_msg = lang('Edit Project');
}
else
{
$function_msg = lang('Add Project');
}
if ($values['cat_id'])
{
$this->cat_id = $values['cat_id'];
}
$location_data=$this->bocommon->initiate_ui_location(array(
'location_type' => 'form',
'equipment' => true,
'tenant' => true,
'address' => true,
'equipment_id' =>
$values['equipment_id'],
'property_id' =>
$values['property_id'],
'property_name' =>
$values['property_name'],
'building_id' =>
$values['building_id'],
'entrance_id' =>
$values['entrance_id'],
'floor' =>
$values['floor'],
'street_name' =>
$values['street_name'],
'street_number' =>
$values['street_number'],
'tenant_phone' =>
$values['contact_phone'],
'apartment_id' =>
$values['apartment_id']));
/*
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
'vendor_id' =>
$values['vendor_id'],
'vendor_name' =>
$values['vendor_name']));
if($values['equipment_id'])
{
$cat_text =
$this->bo->read_single_equipment_type($values['cat_id']);
$attributes_values =
$this->bocommon->read_attibutes(array('form'=>true,'type'=>equipment,'type_id'=>$values['cat_id'],'id'=>$values['equipment_id']));
$attributes_header[] = array
(
'lang_name' => lang('Name'),
'lang_descr' => lang('Description'),
'lang_datatype' => lang('Datatype'),
'lang_value' => lang('Value')
);
}
*/
$link_data = array
(
'menuaction' =>
$this->currentapp.'.uiworkorder.p_edit',
'id' => $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));
$supervisor_id=$GLOBALS['phpgw_info']['user']['preferences']['property']['workorder_approval_from'];
$need_approval =
$this->config->config_data['workorder_approval'];
if ($supervisor_id && ($need_approval=='yes'))
{
$prefs =
$GLOBALS['phpgw']->preferences->create_email_preferences($supervisor_id);
$supervisor_email = $prefs['email']['address'];
}
$data = array
(
'copy_project'
=> $values['copy_project'],
'calendar_gif'
=> './'.$this->currentapp.'/templates/default/images/calendar.gif',
'calendar_source'
=> './'.$this->currentapp.'/inc/calendar.js',
'dateformat'
=> $dateformat,
'lang_popup_calendar' =>
lang('Popup Calendar'),
'link_calendar_start_date' =>
'setDateField(document.form.start_date);top.newWin=window.open('."'.".'/'.$this->currentapp.'/inc/calendar.html'."'".','."'".'cal'."'".','."'dependent=yes,width=210,height=230,screenX=200,screenY=300,titlebar=yes'".')',
'lang_start_date_statustext' => lang('Select
the estimated end date for the Project'),
'lang_start_date'
=> lang('Project start date'),
'value_start_date'
=> $values['start_date'],
'link_calendar_end_date' =>
'setDateField(document.form.end_date);top.newWin=window.open('."'.".'/'.$this->currentapp.'/inc/calendar.html'."'".','."'".'cal'."'".','."'dependent=yes,width=210,height=230,screenX=200,screenY=300,titlebar=yes'".')',
'lang_end_date_statustext' =>
lang('Select the estimated end date for the Project'),
'lang_end_date'
=> lang('Project end date'),
'value_end_date'
=> $values['end_date'],
'lang_copy_project'
=> lang('Copy project ?'),
'lang_copy_project_statustext' => lang('Choose
Copy Project to copy this project to a new project'),
'lang_charge_tenant' =>
lang('Charge tenant'),
'lang_charge_tenant_statustext' => lang('Choose
charge tenant if the tenant i to pay for this project'),
'charge_tenant'
=> $values['charge_tenant'],
'lang_power_meter'
=> lang('Power meter'),
'lang_power_meter_statustext' => lang('Enter
the power_meter'),
'value_power_meter'
=> $values['power_meter'],
'lang_budget'
=> lang('Budget'),
'value_budget'
=> $values['budget'],
'lang_budget_statustext' =>
lang('Enter the budget'),
'vendor_data'
=> $vendor_data,
'location_data'
=> $location_data,
'location_type'
=> 'form',
'appname'
=> lang('equipment'),
'function_msg'
=> $function_msg,
'form_action'
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
'done_action'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.project_list'),
'lang_year'
=> lang('Year'),
'lang_category'
=> lang('category'),
'lang_save'
=> lang('save'),
'lang_done'
=> lang('done'),
'lang_name'
=> lang('Name'),
'lang_project_id'
=> lang('Project ID'),
'value_project_id'
=> $values['project_id'],
'value_name'
=> $values['name'],
'lang_name_statustext' =>
lang('Enter Project Name'),
'lang_other_branch'
=> lang('Other branch'),
'lang_other_branch_statustext' =>
lang('Enter other branch if not found in the list'),
'value_other_branch'
=> $values['other_branch'],
'cat_text'
=> $cat_text,
'error'
=> $receipt['error'],
'error_flag'
=> $error_id,
'message'
=> $receipt['message'],
'lang_descr_statustext' =>
lang('Enter a description of the equipment'),
'lang_descr'
=> lang('Description'),
'value_descr'
=> $values['descr'],
'lang_done_statustext' =>
lang('Back to the list'),
'lang_save_statustext' =>
lang('Save the equipment'),
'lang_no_cat'
=> lang('Select category'),
'lang_cat_statustext' =>
lang('Select the category the equipment 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->bo->select_category_project_list('select',$values['cat_id']),
'lang_workorder_id'
=> lang('Workorder ID'),
'sum_workorder_budget' =>
$values['sum_workorder_budget'],
'workorder_budget'
=> $values['workorder_budget'],
'lang_coordinator'
=> lang('Coordinator'),
'lang_sum'
=> lang('Sum'),
'lang_user_statustext' =>
lang('Select the coordinator the project belongs to. To do not use a category
select NO USER'),
'select_user_name'
=> 'values[coordinator]',
'lang_no_user'
=> lang('Select coordinator'),
'user_list'
=> $this->bocommon->get_user_list('select',$this->filter),
'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 equipment ?'),
'branch_list'
=> $this->bo->select_branch_p_list($values['project_id']),
'lang_branch'
=> lang('branch'),
'lang_branch_statustext' =>
lang('Select the branches for this project'),
'key_responsible_list'
=> $this->bo->select_branch_list($values['key_responsible']),
'lang_no_key_responsible'
=> lang('Select key responsible'),
'lang_key_responsible'
=> lang('key responsible'),
'lang_key_responsible_statustext'
=> lang('Select the key responsible for this project'),
'key_fetch_list'
=> $this->bo->select_key_location_list($values['key_fetch']),
'lang_no_key_fetch'
=> lang('Where to fetch the key'),
'lang_key_fetch'
=> lang('key fetch location'),
'lang_key_fetch_statustext'
=> lang('Select where to fetch the key'),
'key_deliver_list'
=> $this->bo->select_key_location_list($values['key_deliver']),
'lang_no_key_deliver'
=> lang('Where to deliver the key'),
'lang_key_deliver'
=> lang('key deliver location'),
'lang_key_deliver_statustext' =>
lang('Select where to deliver the key'),
'need_approval'
=> $need_approval,
'lang_ask_approval'
=> lang('Ask for approval'),
'lang_ask_approval_statustext' =>
lang('Check this to send a mail to your supervisor for approval'),
'value_approval_mail_address' =>
$supervisor_email,
'currency'
=> $GLOBALS['phpgw_info']['user']['preferences']['common']['currency']
);
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('p_edit' => $data));
}
function delete()
{
$equipment_id =
get_var('equipment_id',array('POST','GET'));
$confirm = get_var('confirm',array('POST'));
$link_data = array
(
'menuaction' =>
$this->currentapp.'.uiworkorder.project_list'
);
if (get_var('confirm',array('POST')))
{
$this->bo->delete($equipment_id);
Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',$link_data));
}
$GLOBALS['phpgw']->xslttpl->add_file(array($GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
. SEP . 'app_delete',
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP .
'app_header'));
$data = array
(
'appname' =>
lang('equipment'),
'function_msg' => lang('delete
equipment'),
'done_action' =>
$GLOBALS['phpgw']->link('/index.php',$link_data),
'delete_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.delete&equipment_id='
. $equipment_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')
);
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('delete' => $data));
}
function view()
{
$id = get_var('id',array('POST','GET'));
$values = $this->bo->read_single($id);
$GLOBALS['phpgw']->xslttpl->add_file(array('equipment',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
. SEP . 'app_header'));
$location_data=$this->bocommon->initiate_ui_location(array(
'location_type' => 'view',
'apartment' => true,
'address' => true,
'property_id' =>
$values['property_id'],
'property_name' =>
$values['property_name'],
'building_id' =>
$values['building_id'],
'entrance_id' =>
$values['entrance_id'],
'floor' =>
$values['floor'],
'street_name' =>
$values['street_name'],
'street_number' =>
$values['street_number'],
'apartment_id' =>
$values['apartment_id']));
$cat_text =
$this->bo->read_single_equipment_type($values['cat_id']);
$attributes_values =
$this->bocommon->read_attibutes(array('form'=>false,'type'=>equipment,'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_equipment_id' =>
lang('equipment ID'),
'value_equipment_id' =>
$values['equipment_id'],
'lang_lifetime' =>
lang('Longevity'),
'value_lifetime' =>
$values['lifetime'],
'cat_text'
=> $cat_text,
'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'],
'appname'
=> lang('equipment'),
'function_msg' =>
lang('view equipment'),
'done_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.project_list'),
'edit_action' =>
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.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 equipment'),
'lang_done'
=> lang('done'),
'lang_edit'
=> lang('Edit')
);
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
}
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: property/inc class.boworkorder.inc.php,NONE,1.1 class.soworkorder.inc.php,NONE,1.1class.uiworkorder.inc.php,NONE,1.1,
Sigurd Nes <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] CVS: property/inc class.bocommon.inc.php,1.25,1.26 class.sostandard_2.inc.php,1.7,1.8 hook_admin.inc.php,1.21,1.22
- Next by Date:
[Phpgroupware-cvs] CVS: property/setup setup.inc.php,1.24,1.25 tables_current.inc.php,1.42,1.43
- Previous by thread:
[Phpgroupware-cvs] CVS: property/inc class.bocommon.inc.php,1.25,1.26 class.sostandard_2.inc.php,1.7,1.8 hook_admin.inc.php,1.21,1.22
- Next by thread:
[Phpgroupware-cvs] CVS: property/setup setup.inc.php,1.24,1.25 tables_current.inc.php,1.42,1.43
- Index(es):