phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: property/inc class.boproject.inc.php,NONE,1.1 cl


From: Sigurd Nes <address@hidden>
Subject: [Phpgroupware-cvs] CVS: property/inc class.boproject.inc.php,NONE,1.1 class.historylog.inc.php,NONE,1.1 class.soproject.inc.php,NONE,1.1 class.uiproject.inc.php,NONE,1.1 class.bocommon.inc.php,1.26,1.27 class.botts.inc.php,1.5,1.6 class.boworkorder.inc.php,1.4,1.5 class.socommon.inc.php,1.13,1.14 class.sotts.inc.php,1.9,1.10 class.sotts2.inc.php,1.2,1.3 class.soworkorder.inc.php,1.5,1.6 class.uiworkorder.inc.php,1.4,1.5
Date: Sun, 16 Mar 2003 06:41:23 -0500

Update of /cvsroot/phpgroupware/property/inc
In directory subversions:/tmp/cvs-serv27234/inc

Modified Files:
        class.bocommon.inc.php class.botts.inc.php 
        class.boworkorder.inc.php class.socommon.inc.php 
        class.sotts.inc.php class.sotts2.inc.php 
        class.soworkorder.inc.php class.uiworkorder.inc.php 
Added Files:
        class.boproject.inc.php class.historylog.inc.php 
        class.soproject.inc.php class.uiproject.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 boproject
        {
                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
                );

                function boproject($session=False)
                {
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->so                       = 
CreateObject($this->currentapp.'.soproject');
                        $this->socommon         = 
CreateObject($this->currentapp.'.socommon');
                        $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
                        $this->historylog       = 
CreateObject($this->currentapp.'.historylog','project');

                        $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 read()
                {
                        $project = $this->so->read(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($project_id)
                {
                        $project                                                
= $this->so->read_single($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, ',', ' ');
                        }
                        if($sum_workorder_budget)
                        {
                                $project['sum_workorder_budget']= 
number_format($sum_workorder_budget, 2, ',', ' ');
                        }

                        if($project['tenant_id'])
                        {
                                
$tenant_data=$this->socommon->read_single_tenant($project['tenant_id']);
                                $project['tenant_phone']= 
$tenant_data['tenant_phone'];
                                $project['tenant_name']= 
$tenant_data['last_name'] . ', ' . $tenant_data['first_name'];
                        }

//                      
$location_data=$this->socommon->read_location_data($project['location_code']);
//                      
$project['power_meter']=$location_data['power_meter_id'];

//_debug_array($project);
                        return $project;
                }


                function read_record_history($id)
                {
                        $history_array = 
$this->historylog->return_array(array('O'),array(),'','',$id);
                        $i=0;
                        while (is_array($history_array) && list(,$value) = 
each($history_array))
                        {

                                $record_history[$i]['value_date']       = 
$GLOBALS['phpgw']->common->show_date($value['datetime']);
                                $record_history[$i]['value_user']       = 
$value['owner'];

                                switch ($value['status'])
                                {
                                        case 'R': $type = lang('Re-opened'); 
break;
                                        case 'X': $type = lang('Closed');    
break;
                                        case 'O': $type = lang('Opened');    
break;
                                        case 'A': $type = lang('Re-assigned'); 
break;
                                        case 'P': $type = lang('Priority 
changed'); break;
                                        case 'CO': $type = lang('Initial 
Coordinator'); break;
                                        case 'C': $type = lang('Coordinator 
changed'); break;
                                        case 'TO': $type = lang('Initial 
Category'); break;
                                        case 'T': $type = lang('Category 
changed'); break;
                                        case 'SO': $type = lang('Initial 
Status'); break;
                                        case 'S': $type = lang('Status 
changed'); break;
                                        default: break;
                                }

                                
if($value['new_value']=='O'){$value['new_value']=lang('Opened');}
                                
if($value['new_value']=='X'){$value['new_value']=lang('Closed');}


                                $record_history[$i]['value_action']     = 
$type?$type:'';
                                unset($type);

                                if ($value['status'] == 'A')
                                {
                                        if (! $value['new_value'])
                                        {
                                                
$record_history[$i]['value_new_value']  = lang('None');
                                        }
                                        else
                                        {
                                                
$record_history[$i]['value_new_value']  = 
$GLOBALS['phpgw']->accounts->id2name($value['new_value']);
                                        }
                                }
                                else if ($value['status'] == 'C' || 
$value['status'] == 'CO')
                                {
                                        $record_history[$i]['value_new_value']  
= $GLOBALS['phpgw']->accounts->id2name($value['new_value']);
                                }
                                else if ($value['status'] == 'T' || 
$value['status'] == 'TO')
                                {
                                        $record_history[$i]['value_new_value']  
= $this->so->read_single_project_category($value['new_value']);
                                }
                                else if ($value['status'] != 'O' && 
$value['new_value'])
                                {
                                        $record_history[$i]['value_new_value']  
= $value['new_value'];
                                }
                                else
                                {
                                        $record_history[$i]['value_new_value']  
= '';
                                }

                                $i++;
                        }

                        return $record_history;
                }


                function increment_project_id()
                {
                        return $this->so->increment_project_id();
                }

                function save($project,$action='')
                {
                        $start_date     = 
$this->bocommon->date_array($project['start_date']);
                        $end_date       = 
$this->bocommon->date_array($project['end_date']);

                        $project['start_date']  = mktime 
(2,0,0,$start_date['month'],$start_date['day'],$start_date['year']);
                        $project['end_date']    = mktime 
(2,0,0,$end_date['month'],$end_date['day'],$end_date['year']);
                        
$project['location_code']=$this->bocommon->location_code($project['property_id'],$project['building_id'],$project['entrance_id'],$project['apartment_id']);

                        if ($action=='edit')
                        {
                                        $receipt = $this->so->edit($project);
                        }
                        else
                        {
                                $receipt = $this->so->add($project);
                        }
                        return $receipt;
                }

                function read_single_equipment_type($equipment_type_id)
                {
                        return 
$this->so->read_single_equipment_type($equipment_type_id);
                }

                function delete($project_id)
                {
                        $this->so->delete($project_id);
                }
        }
?>

***** Error reading new file: [Errno 2] No such file or directory: 
'class.historylog.inc.php'
--- 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 soproject
        {
                var $grants;

                function soproject()
                {
                        $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);
                        $this->historylog       = 
CreateObject($this->currentapp.'.historylog','project');

                        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 read_single_project_category($id='')
                {
                        $this->db->query("SELECT descr FROM 
fm_wo_workorder_category where id='$id' ");
                        $this->db->next_record();
                        return $this->db->f('descr');
                }

                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 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);
                                $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($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']                              
= (int)$this->db->f('budget');
                                $project['actual_cost']                 = 
$this->db->f('actual_cost');
                                $project['tenant_id']                   = 
$this->db->f('tenant_id');
                                $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');

                                $this->db2->query("SELECT name as power_meter 
FROM fm_meter where location_code='" . $this->db->f('location_code'). "' and 
type='power_meter'",__LINE__,__FILE__);

                                $this->db2->next_record();
                                $project['power_meter']                         
= $this->db2->f('power_meter');
                        }

//_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 increment_project_id()
                {
                        $this->db->query("update fm_idgenerator set value = 
value + 1 where name = 'project'");
                        $this->db->query("select value from fm_idgenerator 
where name = 'project'");
                        $this->db->next_record();
                        $project_id = $this->db->f('value');
                        return $project_id;
                }



                function add($project)
                {

                        
$this->historylog->add('SO',$project['project_id'],$project['status']);
                        
$this->historylog->add('TO',$project['project_id'],$project['cat_id']);
                        
$this->historylog->add('CO',$project['project_id'],$project['coordinator']);

                        $project['descr'] = 
$this->db->db_addslashes($project['descr']);
                        $project['name'] = 
$this->db->db_addslashes($project['name']);
                        $project['title'] = 
$this->db->db_addslashes($project['title']);
//_debug_array($project);
                        $this->db->query("INSERT INTO fm_wo_project 
(id,name,equipment_id,access,category,entry_date,start_date,end_date,coordinator,status,"
                                . 
"descr,title,budget,location_code,property_id,property_name,building_id,entrance_id,floor,apartment_id,"
                                . 
"street_name,street_number,key_deliver,key_fetch,other_branch,key_responsible,tenant_id,charge_tenant,owner)
 "
                                . "VALUES ('"
                                . $project['project_id']. "','"
                                . $project['name']. "','"
                                . $project['equipment_id']. "','"
                                . "public','"
                                . $project['cat_id']. "','"
                                . time() . "','"
                                . $project['start_date']. "','"
                                . $project['end_date']. "','"
                                . $project['coordinator']. "','"
                                . $project['status']. "','"
                                . $project['descr']. "','"
                                . $project['title']. "','"
                                . $project['budget']. "','"
                                . $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['key_deliver']. "','"
                                . $project['key_fetch']. "','"
                                . $project['other_branch']. "','"
                                . $project['key_responsible']. "','"
                                . $project['tenant_id']. "','"
                                . $project['charge_tenant'] . "','"
                                . $this->account. "')",__LINE__,__FILE__);


                        if($project['tenant_phone'])
                        {
                                $this->db->query("update fm_tenant set 
contact_phone='". $project['tenant_phone']. "' where tenant_id='". 
$project['tenant_id']. "'",__LINE__,__FILE__);
                        }

                        if ($project['power_meter'] )
                        {
                                
$this->update_power_meter($project['power_meter'],$project['location_code']);
                        }

        // -----------------which branch is represented
                        if (count($project['branch']) != 0)
                        {
                                while($branch=each($project['branch']))
                                {
                                        $this->db->query("insert into 
fm_wo_projectbranch (project_id,branch_id) values ('" . $project['project_id']. 
"','$branch[1]')",__LINE__,__FILE__);
                                }
                        }

                        $receipt['message'][] = array('msg'=>lang('project %1 
has been saved',$project['project_id']));
                        return $receipt;
                }

                function update_power_meter($power_meter,$location_code)
                {

                        $this->db->query("SELECT count(*) FROM fm_meter where 
location_code='$location_code' and type='power_meter'",__LINE__,__FILE__);

                        $this->db->next_record();

                        if ( $this->db->f(0))
                        {
                                $this->db->query("update fm_meter set name='" . 
$power_meter. "' where location_code='" . $location_code. "' and 
type='power_meter'",__LINE__,__FILE__);
                        }
                        else
                        {
                                $meter_id       = $this->generate_meter_id();
                                $this->db->query("insert into fm_meter 
(id,name,type,location_code,entry_date,user_created) "
                                        . "VALUES ('"
                                        . $meter_id. "','"
                                        . $power_meter. "','"
                                        . "power_meter','"
                                        . $location_code. "','"
                                        . time() . "','"
                                        . $this->account. 
"')",__LINE__,__FILE__);
                        }
                }

                function generate_meter_id()
                {
                        $prefix = 'meter';
                        $pos    = strlen($prefix);
                        $this->db->query("select max(id) from fm_meter where id 
like ('$prefix%')");
                        $this->db->next_record();

                        $max = 
$this->bocommon->add_leading_zero(substr($this->db->f(0),$pos));

                        $meter_id= $prefix . $max;
                        return $meter_id;
                }

                function edit($project)
                {
                        $this->db->query("SELECT status,category,coordinator 
FROM fm_wo_project where id='" .$project['project_id']."'",__LINE__,__FILE__);

                        $this->db->next_record();

                        $old_status = $this->db->f('status');
                        $old_categroy = $this->db->f('category');
                        $old_coordinator = $this->db->f('coordinator');
                        if ($old_status != $project['status'])
                        {
                                
$this->historylog->add('S',$project['project_id'],$project['status']);
                        }
                        if ($old_categroy != $project['cat_id'])
                        {
                                
$this->historylog->add('T',$project['project_id'],$project['cat_id']);
                        }
                        if ($old_coordinator != $project['coordinator'])
                        {
                                
$this->historylog->add('C',$project['project_id'],$project['coordinator']);
                        }

                        $project['descr'] = 
$this->db->db_addslashes($project['descr']);
                        $project['name'] = 
$this->db->db_addslashes($project['name']);
                        $project['title'] = 
$this->db->db_addslashes($project['title']);
//_debug_array($project);

                        $this->db->query("UPDATE fm_wo_project set
                                name                    ='" . $project['name'] 
. "',
                                status                  ='" . 
$project['status'] . "',
                                category                ='" . 
$project['cat_id'] . "',
                                start_date              ='" . 
$project['start_date'] . "',
                                end_date                ='" . 
$project['end_date'] . "',
                                coordinator             ='" . 
$project['coordinator'] . "',
                                descr                   ='" . $project['descr'] 
. "',
                                title                   ='"     . 
$project['title'] . "',
                                budget                  ='" . 
(int)$project['budget'] . "',
                                key_deliver             ='" . 
$project['key_deliver'] . "',
                                key_fetch               ='" . 
$project['key_fetch'] . "',
                                other_branch    ='" . $project['other_branch'] 
. "',
                                key_responsible ='" . 
$project['key_responsible'] . "',
                                tenant_id               ='" . 
$project['tenant_id'] . "',
                                charge_tenant   ='" . $project['charge_tenant'] 
. "',
                                location_code   ='" . $project['location_code'] 
. "',
                                property_id             ='" . 
$project['property_id'] . "',
                                property_name   ='" . $project['property_name'] 
. "',
                                building_id             ='" . 
$project['building_id'] . "',
                                entrance_id             ='" . 
$project['entrance_id'] . "',
                                floor                   ='" . $project['floor'] 
. "',
                                apartment_id    ='" . $project['apartment_id'] 
. "',
                                street_name             ='" . 
$project['street_name'] . "',
                                street_number   ='" . $project['street_number']
                                . "' WHERE id= '" . $project['project_id'] 
."'",__LINE__,__FILE__);

                        if($project['tenant_phone'])
                        {
                                $this->db->query("update fm_tenant set 
contact_phone='". $project['tenant_phone']. "' where tenant_id='". 
$project['tenant_id']. "'",__LINE__,__FILE__);
                        }

                        if ($project['power_meter'] )
                        {
                                
$this->update_power_meter($project['power_meter'],$project['location_code']);
                        }
        // -----------------which branch is represented
                        $this->db->query("delete from fm_wo_projectbranch where 
project_id='" . $project['project_id'] ."'",__LINE__,__FILE__);

                        if (count($project['branch']) != 0)
                        {
                                while($branch=each($project['branch']))
                                {
                                        $this->db->query("insert into 
fm_wo_projectbranch (project_id,branch_id) values ('" . $project['project_id']. 
"','$branch[1]')",__LINE__,__FILE__);
                                }
                        }


                        $receipt['message'][] = array('msg'=>lang('project %1 
has been edited',$project['project_id']));
                        return $receipt;

                }

                function delete($project_id )
                {
                        $this->db->query("DELETE FROM fm_wo_project WHERE id='" 
. $project_id . "'",__LINE__,__FILE__);
                        $this->db->query("DELETE FROM fm_wo_project_history  
WHERE  history_record_id='" . $project_id   . "'",__LINE__,__FILE__);
                        $this->db->query("DELETE FROM fm_wo_projectbranch  
WHERE  project_id='" . $project_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 uiproject
        {
                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
                (
                        'index'  => True,
                        'view'   => True,
                        'edit'   => True,
                        'delete' => True
                );

                function uiproject()
                {
                        $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.'.boproject',True);
                        $this->so                                       = 
CreateObject($this->currentapp.'.soproject',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 index()
                {

                        $GLOBALS['phpgw']->xslttpl->add_file(array('project',
                                                                                
'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();

//_debug_array($project_list);

                        while (is_array($project_list) && list(,$project) = 
each($project_list))
                        {
                                $content[] = array
                                (
                                        'name'                                  
        => $project['name'],
                                        '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.'.uiproject.view&id='
 . $project['project_id']),
                                        'link_edit'                             
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit&id='
 . $project['project_id']),
                                        'link_delete'                           
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.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.'.uiproject.index',
                                                                                
                                                        'cat_id'                
=>$this->cat_id,
                                                                                
                                                        'district_id'   => 
$this->district_id,
                                                                                
                                                        'filter'                
=>$this->filter,
                                                                                
                                                        'query'                 
=>$this->query)
                                                                                
)),
                                'lang_project'  => lang('project'),
                                'lang_name'             => lang('Name'),
                                'sort_property' => 
$this->nextmatchs->show_sort_order(array
                                                                                
(
                                                                                
        'sort'  => $this->sort,
                                                                                
        'var'   =>      'property_id',
                                                                                
        'order' =>      $this->order,
                                                                                
        'extra'         => array('menuaction'           => 
$this->currentapp.'.uiproject.index',
                                                                                
                                                        '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.'.uiproject.index',
                                                                                
                                                        '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.'.uiproject.edit')
                        );

                        $link_data = array
                        (
                                'menuaction'    => 
$this->currentapp.'.uiproject.index',
                                                'sort'                  
=>$this->sort,
                                                'order'                 
=>$this->order,
                                                'cat_id'                
=>$this->cat_id,
                                                'district_id'   
=>$this->district_id,
                                                'filter'                
=>$this->filter,
                                                'status_id'             
=>$this->status_id,
                                                '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 edit()
                {
                        $id                             = 
get_var('id',array('POST','GET'));
                        $values                         = 
get_var('values',array('POST'));

                        
$GLOBALS['phpgw']->xslttpl->add_file(array('project',$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['tenant_id']            = 
get_var('tenant_id',array('POST'));
                        $values['tenant_name']          = 
get_var('tenant_name',array('POST'));
                        $values['tenant_phone']         = 
get_var('tenant_phone',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');
                                        $id     = $values['project_id'];
                                }

                                if(!$receipt['error'])
                                {
                                        if($values['copy_project'])
                                        {
                                                $action='add';
                                                $values['project_id']   = 
$this->bo->increment_project_id();
                                                $id     = $values['project_id'];
                                        }
                                        $receipt = 
$this->bo->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;
                                        }

                                }
                        }

                        if(!$receipt['error'])
                        {
                                $values = $this->bo->read_single($id);
                        }

                        $record_history = $this->bo->read_record_history($id);

                        $table_header_history[] = array
                        (
                                'lang_date'                     => lang('Date'),
                                'lang_user'                     => lang('User'),
                                'lang_action'           => lang('Action'),
                                'lang_new_value'        => lang('New value')
                        );

                        $table_header_workorder_budget[] = array
                        (
                                'lang_workorder_id'     => lang('Workorder'),
                                'lang_sum'      => lang('Sum')
                        );

                        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_id'             => 
$values['tenant_id'],
                                                'tenant_name'   => 
$values['tenant_name'],
                                                'tenant_phone'  => 
$values['tenant_phone'],
                                                'apartment_id'  => 
$values['apartment_id']));


                        $link_data = array
                        (
                                'menuaction'    => 
$this->currentapp.'.uiproject.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
                        (
                                'table_header_workorder_budget' => 
$table_header_workorder_budget,
                                'lang_no_workorders'                    => 
lang('No workorder bugdet'),
                                'workorder_link'                                
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit'),
                                'record_history'                                
=> $record_history,
                                'table_header_history'                  => 
$table_header_history,
                                'lang_history'                                  
=> lang('History'),
                                'lang_no_history'                               
=> lang('No history'),

                                '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.'.uiproject.index'),
                                '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'],

                                'error'                                         
        => $receipt['error'],
                                '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 project 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',$values['coordinator']),

                                '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('edit' => $data));
                }

                function delete()
                {
                        $project_id = get_var('project_id',array('POST','GET'));
                        $confirm        = get_var('confirm',array('POST'));

                        $link_data = array
                        (
                                'menuaction' => 
$this->currentapp.'.uiproject.index'
                        );

                        if (get_var('confirm',array('POST')))
                        {
                                $this->bo->delete($project_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.'.uiproject.delete&project_id='
 . $project_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'));

                        
$GLOBALS['phpgw']->xslttpl->add_file(array('project',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));

                        $this->config->read_repository();

                        $values = $this->bo->read_single($id);

                        $record_history = $this->bo->read_record_history($id);

                        $table_header_history[] = array
                        (
                                'lang_date'                     => lang('Date'),
                                'lang_user'                     => lang('User'),
                                'lang_action'           => lang('Action'),
                                'lang_new_value'        => lang('New value')
                        );

                        $table_header_workorder_budget[] = array
                        (
                                'lang_workorder_id'     => lang('Workorder'),
                                'lang_sum'      => lang('Sum')
                        );

                        $function_msg = lang('View Project');

                        if ($values['cat_id'])
                        {
                                $this->cat_id = $values['cat_id'];
                        }


                        
$location_data=$this->bocommon->initiate_ui_location(array(
                                                'location_type' => 'view',
                                                '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_id'             => 
$values['tenant_id'],
                                                'tenant_name'   => 
$values['tenant_name'],
                                                'tenant_phone'  => 
$values['tenant_phone'],
                                                'apartment_id'  => 
$values['apartment_id']));

                        $data = array
                        (
                                'table_header_workorder_budget' => 
$table_header_workorder_budget,
                                'lang_no_workorders'                    => 
lang('No workorder bugdet'),
                                'workorder_link'                                
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.view'),
                                'record_history'                                
=> $record_history,
                                'table_header_history'                  => 
$table_header_history,
                                'lang_history'                                  
=> lang('History'),
                                'lang_no_history'                               
=> lang('No history'),

                                'lang_start_date'                               
=> lang('Project start date'),
                                'value_start_date'                              
=> $values['start_date'],

                                'lang_end_date'                                 
=> lang('Project end date'),
                                'value_end_date'                                
=> $values['end_date'],

                                'lang_charge_tenant'                    => 
lang('Charge tenant'),
                                'charge_tenant'                                 
=> $values['charge_tenant'],

                                'lang_power_meter'                              
=> lang('Power meter'),
                                'value_power_meter'                             
=> $values['power_meter'],

                                'lang_budget'                                   
=> lang('Budget'),
                                'value_budget'                                  
=> $values['budget'],

                                'vendor_data'                                   
=> $vendor_data,
                                'location_data'                                 
=> $location_data,
                                'location_type'                                 
=> 'view',
                                'appname'                                       
        => lang('Project'),
                                'function_msg'                                  
=> $function_msg,
                                'done_action'                                   
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.index'),
                                '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_other_branch'                             
        => lang('Other branch'),
                                'value_other_branch'                            
=> $values['other_branch'],

                                'lang_descr'                                    
=> lang('Description'),
                                'value_descr'                                   
=> $values['descr'],
                                'lang_done_statustext'                  => 
lang('Back to the list'),
                                'lang_save_statustext'                  => 
lang('Save the equipment'),
                                'select_name'                                   
=> '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'),
                                'select_user_name'                              
=> 'values[coordinator]',
                                'lang_no_user'                                  
=> lang('Select coordinator'),
                                'user_list'                                     
        => $this->bocommon->get_user_list('select',$values['coordinator']),

                                'status_list'                                   
=> $this->bo->select_status_list('select',$values['status']),
                                'lang_no_status'                                
=> lang('Select status'),
                                'lang_status'                                   
=> lang('Status'),

                                'branch_list'                                   
=> $this->bo->select_branch_p_list($values['project_id']),
                                'lang_branch'                                   
=> lang('branch'),

                                'key_responsible_list'                          
        => $this->bo->select_branch_list($values['key_responsible']),
                                'lang_key_responsible'                          
        => lang('key responsible'),

                                'key_fetch_list'                                
        => $this->bo->select_key_location_list($values['key_fetch']),
                                'lang_key_fetch'                                
        => lang('key fetch location'),

                                'key_deliver_list'                              
        => $this->bo->select_key_location_list($values['key_deliver']),
                                'lang_key_deliver'                              
        => lang('key deliver location'),

                                'edit_action'                                   
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit&id='
 . $id),
                                'lang_edit_statustext'                          
=> lang('Edit this entry equipment'),
                                'lang_edit'                                     
                => lang('Edit'),
                                'currency'                                      
                => 
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency']
                        );

                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
                }
        }
?>

Index: class.bocommon.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.bocommon.inc.php,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -r1.26 -r1.27
*** class.bocommon.inc.php      12 Mar 2003 21:37:32 -0000      1.26
--- class.bocommon.inc.php      16 Mar 2003 11:41:16 -0000      1.27
***************
*** 459,463 ****
                                'link_helpdesk'         =>      
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uitts.index'),
                                'lang_helpdesk'         =>      
lang('Helpdesk'),
!                               'link_workorder'        =>      
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiworkorder.project_list'),
                                'lang_workorder'        =>      
lang('Workorder'),
                                'link_invoice'          =>      
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiinvoice.index'),
--- 459,463 ----
                                'link_helpdesk'         =>      
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uitts.index'),
                                'lang_helpdesk'         =>      
lang('Helpdesk'),
!                               'link_workorder'        =>      
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiproject.index'),
                                'lang_workorder'        =>      
lang('Workorder'),
                                'link_invoice'          =>      
$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiinvoice.index'),
***************
*** 594,598 ****
                                
$menu['sub_workorder_archive']=$GLOBALS['phpgw']->link('/property/list_workorder.php','sub=workorder&status=Avsluttet');
                                
$menu['sub_workorder_template']=$GLOBALS['phpgw']->link('/property/list_wo_template.php','sub=workorder');
!                               
$menu['sub_workorder_project']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiworkorder.project_list');
                                
$menu['sublang_workorder_project']=lang('Project');
                                
$menu['sublang_workorder_list']=lang('Workorder');
--- 594,598 ----
                                
$menu['sub_workorder_archive']=$GLOBALS['phpgw']->link('/property/list_workorder.php','sub=workorder&status=Avsluttet');
                                
$menu['sub_workorder_template']=$GLOBALS['phpgw']->link('/property/list_wo_template.php','sub=workorder');
!                               
$menu['sub_workorder_project']=$GLOBALS['phpgw']->link('/index.php','menuaction='.$currentapp.'.uiproject.index');
                                
$menu['sublang_workorder_project']=lang('Project');
                                
$menu['sublang_workorder_list']=lang('Workorder');

Index: class.botts.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.botts.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** class.botts.inc.php 11 Feb 2003 14:19:54 -0000      1.5
--- class.botts.inc.php 16 Mar 2003 11:41:17 -0000      1.6
***************
*** 50,54 ****
                        $this->socommon         = 
CreateObject($this->currentapp.'.socommon');
                        $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
!                       $this->historylog       = 
createobject('phpgwapi.historylog',$this->currentapp .'_tts');
                        $this->send                     = 
CreateObject('phpgwapi.send');
                        $this->config           = 
CreateObject('phpgwapi.config');
--- 50,54 ----
                        $this->socommon         = 
CreateObject($this->currentapp.'.socommon');
                        $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
!                       $this->historylog       = 
CreateObject($this->currentapp.'.historylog','tts');
                        $this->send                     = 
CreateObject('phpgwapi.send');
                        $this->config           = 
CreateObject('phpgwapi.config');

Index: class.boworkorder.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.boworkorder.inc.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** class.boworkorder.inc.php   14 Mar 2003 14:32:18 -0000      1.4
--- class.boworkorder.inc.php   16 Mar 2003 11:41:17 -0000      1.5
***************
*** 25,47 ****
                );
  
-               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)
                {
--- 25,28 ----
***************
*** 50,54 ****
                        $this->socommon         = 
CreateObject($this->currentapp.'.socommon');
                        $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
!                       $this->historylog       = 
createobject('phpgwapi.historylog',$this->currentapp .'_project');
  
                        $start  = get_var('start',array('POST','GET'));
--- 31,35 ----
                        $this->socommon         = 
CreateObject($this->currentapp.'.socommon');
                        $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
!                       $this->historylog       = 
CreateObject($this->currentapp.'.historylog','project');
  
                        $start  = get_var('start',array('POST','GET'));
***************
*** 275,318 ****
                }
  
-               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;
--- 256,263 ----
                }
  
  
!               function read()
                {
!                       $project = $this->so->read(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;
***************
*** 329,335 ****
                }
  
!               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);
--- 274,280 ----
                }
  
!               function read_single($project_id)
                {
!                       $project                                                
= $this->so->read_single($project_id);
                        $dateformat                                             
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
                        $project['start_date']                  = 
$GLOBALS['phpgw']->common->show_date($project['start_date'],$dateformat);
***************
*** 365,369 ****
                function read_record_history($id)
                {
!                       $history_array = 
$this->historylog->return_array(array('C','O'),array(),'','',$id);
                        $i=0;
                        while (is_array($history_array) && list(,$value) = 
each($history_array))
--- 310,314 ----
                function read_record_history($id)
                {
!                       $history_array = 
$this->historylog->return_array(array('O'),array(),'','',$id);
                        $i=0;
                        while (is_array($history_array) && list(,$value) = 
each($history_array))
***************
*** 380,383 ****
--- 325,330 ----
                                        case 'A': $type = lang('Re-assigned'); 
break;
                                        case 'P': $type = lang('Priority 
changed'); break;
+                                       case 'CO': $type = lang('Initial 
Coordinator'); break;
+                                       case 'C': $type = lang('Coordinator 
changed'); break;
                                        case 'TO': $type = lang('Initial 
Category'); break;
                                        case 'T': $type = lang('Category 
changed'); break;
***************
*** 405,408 ****
--- 352,359 ----
                                        }
                                }
+                               else if ($value['status'] == 'C' || 
$value['status'] == 'CO')
+                               {
+                                       $record_history[$i]['value_new_value']  
= $GLOBALS['phpgw']->accounts->id2name($value['new_value']);
+                               }
                                else if ($value['status'] == 'T' || 
$value['status'] == 'TO')
                                {
***************
*** 425,434 ****
  
  
!               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='')
                {
                        $start_date     = 
$this->bocommon->date_array($project['start_date']);
--- 376,385 ----
  
  
!               function increment_project_id()
                {
!                       return $this->so->increment_project_id();
                }
  
!               function save($project,$action='')
                {
                        $start_date     = 
$this->bocommon->date_array($project['start_date']);
***************
*** 441,449 ****
                        if ($action=='edit')
                        {
!                                       $receipt = $this->so->p_edit($project);
                        }
                        else
                        {
!                               $receipt = $this->so->p_add($project);
                        }
                        return $receipt;
--- 392,400 ----
                        if ($action=='edit')
                        {
!                                       $receipt = $this->so->edit($project);
                        }
                        else
                        {
!                               $receipt = $this->so->add($project);
                        }
                        return $receipt;
***************
*** 455,461 ****
                }
  
!               function delete($equipment_id)
                {
!                       $this->so->delete($equipment_id);
                }
        }
--- 406,412 ----
                }
  
!               function delete($project_id)
                {
!                       $this->so->delete($project_id);
                }
        }

Index: class.socommon.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.socommon.inc.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** class.socommon.inc.php      13 Mar 2003 10:25:03 -0000      1.13
--- class.socommon.inc.php      16 Mar 2003 11:41:17 -0000      1.14
***************
*** 30,35 ****
                }
  
- 
- 
                function read_single_tenant($tenant_id)
                {
--- 30,33 ----

Index: class.sotts.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.sotts.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** class.sotts.inc.php 14 Mar 2003 14:32:22 -0000      1.9
--- class.sotts.inc.php 16 Mar 2003 11:41:17 -0000      1.10
***************
*** 19,23 ****
                        $this->grants   = 
$GLOBALS['phpgw']->acl->get_grants($this->currentapp);
                        $this->account  = 
$GLOBALS['phpgw_info']['user']['account_id'];
!                       $this->historylog       = 
createobject('phpgwapi.historylog',$this->currentapp .'_tts');
                        $this->config           = 
CreateObject('phpgwapi.config');
  
--- 19,23 ----
                        $this->grants   = 
$GLOBALS['phpgw']->acl->get_grants($this->currentapp);
                        $this->account  = 
$GLOBALS['phpgw_info']['user']['account_id'];
!                       $this->historylog       = 
CreateObject($this->currentapp.'.historylog','tts');
                        $this->config           = 
CreateObject('phpgwapi.config');
  
***************
*** 223,228 ****
  
                        $id = 
$this->db->get_last_insert_id('fm_tts_tickets','id');
- 
-                       $this->historylog = 
createobject('phpgwapi.historylog',$this->currentapp .'_tts');
                        $this->historylog->add('O',$id,mktime(),'');
  
--- 223,226 ----

Index: class.sotts2.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.sotts2.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** class.sotts2.inc.php        11 Feb 2003 14:19:54 -0000      1.2
--- class.sotts2.inc.php        16 Mar 2003 11:41:17 -0000      1.3
***************
*** 15,19 ****
                        $this->db2              = $this->db;
                        $this->bo               = 
CreateObject($this->currentapp.'.botts');
!                       $this->historylog       = 
createobject('phpgwapi.historylog',$this->currentapp .'_tts');
                        $this->config           = 
CreateObject('phpgwapi.config');
                }
--- 15,19 ----
                        $this->db2              = $this->db;
                        $this->bo               = 
CreateObject($this->currentapp.'.botts');
!                       $this->historylog       = 
CreateObject($this->currentapp.'.historylog','tts');
                        $this->config           = 
CreateObject('phpgwapi.config');
                }

Index: class.soworkorder.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.soworkorder.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** class.soworkorder.inc.php   14 Mar 2003 14:32:35 -0000      1.5
--- class.soworkorder.inc.php   16 Mar 2003 11:41:17 -0000      1.6
***************
*** 19,23 ****
                        $this->account          = 
$GLOBALS['phpgw_info']['user']['account_id'];
                        $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon',True);
!                       $this->historylog       = 
createobject('phpgwapi.historylog',$this->currentapp .'_project');
  
                        if 
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
--- 19,23 ----
                        $this->account          = 
$GLOBALS['phpgw_info']['user']['account_id'];
                        $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon',True);
!                       $this->historylog       = 
CreateObject($this->currentapp.'.historylog','project');
  
                        if 
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
***************
*** 96,120 ****
                }
  
!               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))
--- 96,100 ----
                }
  
!               function read($data)
                {
                        if(is_array($data))
***************
*** 217,221 ****
                }
  
!               function read_single_p($project_id)
                {
                        $sql = "SELECT * from fm_wo_project where 
id='$project_id'";
--- 197,201 ----
                }
  
!               function read_single($project_id)
                {
                        $sql = "SELECT * from fm_wo_project where 
id='$project_id'";
***************
*** 330,338 ****
                }
  
!               function p_add($project)
                {
  
!                       
$this->historylog->add('SO',$project['project_id'],$project['status'],'');
!                       
$this->historylog->add('TO',$project['project_id'],$project['cat_id'],'');
  
                        $project['descr'] = 
$this->db->db_addslashes($project['descr']);
--- 310,331 ----
                }
  
! 
!               function increment_project_id()
                {
+                       $this->db->query("update fm_idgenerator set value = 
value + 1 where name = 'project'");
+                       $this->db->query("select value from fm_idgenerator 
where name = 'project'");
+                       $this->db->next_record();
+                       $project_id = $this->db->f('value');
+                       return $project_id;
+               }
+ 
  
! 
!               function add($project)
!               {
! 
!                       
$this->historylog->add('SO',$project['project_id'],$project['status']);
!                       
$this->historylog->add('TO',$project['project_id'],$project['cat_id']);
!                       
$this->historylog->add('CO',$project['project_id'],$project['coordinator']);
  
                        $project['descr'] = 
$this->db->db_addslashes($project['descr']);
***************
*** 436,442 ****
                }
  
!               function p_edit($project)
                {
!                       $this->db->query("SELECT status,category FROM 
fm_wo_project where id='" .$project['project_id']."'",__LINE__,__FILE__);
  
                        $this->db->next_record();
--- 429,435 ----
                }
  
!               function edit($project)
                {
!                       $this->db->query("SELECT status,category,coordinator 
FROM fm_wo_project where id='" .$project['project_id']."'",__LINE__,__FILE__);
  
                        $this->db->next_record();
***************
*** 444,454 ****
                        $old_status = $this->db->f('status');
                        $old_categroy = $this->db->f('category');
                        if ($old_status != $project['status'])
                        {
!                               
$this->historylog->add('S',$project['project_id'],$project['status'],$old_status);
                        }
                        if ($old_categroy != $project['cat_id'])
                        {
!                               
$this->historylog->add('T',$project['project_id'],$project['cat_id'],$old_categroy);
                        }
  
--- 437,452 ----
                        $old_status = $this->db->f('status');
                        $old_categroy = $this->db->f('category');
+                       $old_coordinator = $this->db->f('coordinator');
                        if ($old_status != $project['status'])
                        {
!                               
$this->historylog->add('S',$project['project_id'],$project['status']);
                        }
                        if ($old_categroy != $project['cat_id'])
                        {
!                               
$this->historylog->add('T',$project['project_id'],$project['cat_id']);
!                       }
!                       if ($old_coordinator != $project['coordinator'])
!                       {
!                               
$this->historylog->add('C',$project['project_id'],$project['coordinator']);
                        }
  
***************
*** 511,518 ****
                }
  
!               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__);
                }
        }
--- 509,518 ----
                }
  
!               function delete($project_id )
                {
!                       $this->db->query("DELETE FROM fm_wo_project WHERE id='" 
. $project_id . "'",__LINE__,__FILE__);
!                       $this->db->query("DELETE FROM fm_wo_project_history  
WHERE  history_record_id='" . $project_id   . "'",__LINE__,__FILE__);
!                       $this->db->query("DELETE FROM fm_wo_projectbranch  
WHERE  project_id='" . $project_id   . "'",__LINE__,__FILE__);
! 
                }
        }

Index: class.uiworkorder.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.uiworkorder.inc.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** class.uiworkorder.inc.php   14 Mar 2003 14:32:35 -0000      1.4
--- class.uiworkorder.inc.php   16 Mar 2003 11:41:17 -0000      1.5
***************
*** 22,28 ****
                var $public_functions = array
                (
!                       'project_list'  => True,
                        'view'   => True,
!                       'p_edit'   => True,
                        'delete' => True
                );
--- 22,28 ----
                var $public_functions = array
                (
!                       'index'  => True,
                        'view'   => True,
!                       'edit'   => True,
                        'delete' => True
                );
***************
*** 67,71 ****
                }
  
!               function project_list()
                {
  
--- 67,71 ----
                }
  
!               function index()
                {
  
***************
*** 79,83 ****
                        $links = $this->bocommon->menu($sub);
  
!                       $project_list = $this->bo->read_project();
  
  //_debug_array($project_list);
--- 79,83 ----
                        $links = $this->bocommon->menu($sub);
  
!                       $project_list = $this->bo->read();
  
  //_debug_array($project_list);
***************
*** 87,91 ****
                                $content[] = array
                                (
!                                       'title'                                 
        => $project['title'],
                                        'project_id'                            
=> $project['project_id'],
                                        'descr'                                 
        => $project['descr'],
--- 87,91 ----
                                $content[] = array
                                (
!                                       'name'                                  
        => $project['name'],
                                        'project_id'                            
=> $project['project_id'],
                                        'descr'                                 
        => $project['descr'],
***************
*** 99,103 ****
                                        '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'),
--- 99,103 ----
                                        '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.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'),
***************
*** 118,122 ****
                                                                                
        'var'   =>      'id',
                                                                                
        'order' =>      $this->order,
!                                                                               
        'extra' => array('menuaction'           => 
$this->currentapp.'.uiworkorder.project_list',
                                                                                
                                                        'cat_id'                
=>$this->cat_id,
                                                                                
                                                        'district_id'   => 
$this->district_id,
--- 118,122 ----
                                                                                
        'var'   =>      'id',
                                                                                
        'order' =>      $this->order,
!                                                                               
        'extra' => array('menuaction'           => 
$this->currentapp.'.uiworkorder.index',
                                                                                
                                                        'cat_id'                
=>$this->cat_id,
                                                                                
                                                        'district_id'   => 
$this->district_id,
***************
*** 125,129 ****
                                                                                
)),
                                'lang_project'  => lang('project'),
!                               'lang_title'            => lang('Title'),
                                'sort_property' => 
$this->nextmatchs->show_sort_order(array
                                                                                
(
--- 125,129 ----
                                                                                
)),
                                'lang_project'  => lang('project'),
!                               'lang_name'             => lang('Name'),
                                'sort_property' => 
$this->nextmatchs->show_sort_order(array
                                                                                
(
***************
*** 131,135 ****
                                                                                
        'var'   =>      'property_id',
                                                                                
        'order' =>      $this->order,
!                                                                               
        'extra'         => array('menuaction'           => 
$this->currentapp.'.uiworkorder.project_list',
                                                                                
                                                        'cat_id'                
=>$this->cat_id,
                                                                                
                                                        'district_id'   => 
$this->district_id,
--- 131,135 ----
                                                                                
        'var'   =>      'property_id',
                                                                                
        'order' =>      $this->order,
!                                                                               
        'extra'         => array('menuaction'           => 
$this->currentapp.'.uiworkorder.index',
                                                                                
                                                        'cat_id'                
=>$this->cat_id,
                                                                                
                                                        'district_id'   => 
$this->district_id,
***************
*** 147,151 ****
                                                                                
        'var'   =>      'street_name',
                                                                                
        'order' =>      $this->order,
!                                                                               
        'extra'         => array('menuaction'           => 
$this->currentapp.'.uiworkorder.project_list',
                                                                                
                                                        'cat_id'                
=>$this->cat_id,
                                                                                
                                                        'district_id'   => 
$this->district_id,
--- 147,151 ----
                                                                                
        'var'   =>      'street_name',
                                                                                
        'order' =>      $this->order,
!                                                                               
        'extra'         => array('menuaction'           => 
$this->currentapp.'.uiworkorder.index',
                                                                                
                                                        'cat_id'                
=>$this->cat_id,
                                                                                
                                                        'district_id'   => 
$this->district_id,
***************
*** 166,175 ****
                                '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,
--- 166,175 ----
                                'lang_add'                              => 
lang('add'),
                                'lang_add_statustext'   => lang('add a 
project'),
!                               'add_action'                    => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit')
                        );
  
                        $link_data = array
                        (
!                               'menuaction'    => 
$this->currentapp.'.uiworkorder.index',
                                                'sort'                  
=>$this->sort,
                                                'order'                 
=>$this->order,
***************
*** 225,229 ****
                }
  
!               function p_edit()
                {
                        $id                             = 
get_var('id',array('POST','GET'));
--- 225,229 ----
                }
  
!               function edit()
                {
                        $id                             = 
get_var('id',array('POST','GET'));
***************
*** 284,291 ****
                                        {
                                                $action='add';
!                                               $values['project_id']   = 
$this->socommon->next_id('fm_wo_project');
                                                $id     = $values['project_id'];
                                        }
!                                       $receipt = 
$this->bo->p_save($values,$action);
                                        $id = $values['project_id'];
                                        $function_msg = lang('Edit Project');
--- 284,291 ----
                                        {
                                                $action='add';
!                                               $values['project_id']   = 
$this->bo->increment_project_id();
                                                $id     = $values['project_id'];
                                        }
!                                       $receipt = 
$this->bo->save($values,$action);
                                        $id = $values['project_id'];
                                        $function_msg = lang('Edit Project');
***************
*** 324,328 ****
                        }
  
!                       $values = $this->bo->read_single_p($id);
  
                        $record_history = $this->bo->read_record_history($id);
--- 324,331 ----
                        }
  
!                       if(!$receipt['error'])
!                       {
!                               $values = $this->bo->read_single($id);
!                       }
  
                        $record_history = $this->bo->read_record_history($id);
***************
*** 399,403 ****
                        $link_data = array
                        (
!                               'menuaction'    => 
$this->currentapp.'.uiworkorder.p_edit',
                                'id'                    => $id
                        );
--- 402,406 ----
                        $link_data = array
                        (
!                               'menuaction'    => 
$this->currentapp.'.uiworkorder.edit',
                                'id'                    => $id
                        );
***************
*** 428,433 ****
--- 431,440 ----
                                'table_header_workorder_budget' => 
$table_header_workorder_budget,
                                'lang_no_workorders'                    => 
lang('No workorder bugdet'),
+                               'workorder_link'                                
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.w_edit'),
                                'record_history'                                
=> $record_history,
                                'table_header_history'                  => 
$table_header_history,
+                               'lang_history'                                  
=> lang('History'),
+                               'lang_no_history'                               
=> lang('No history'),
+ 
                                'calendar_gif'                                  
=> './'.$this->currentapp.'/templates/default/images/calendar.gif',
                                'calendar_source'                               
=> './'.$this->currentapp.'/inc/calendar.js',
***************
*** 466,470 ****
                                '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'),
--- 473,477 ----
                                'function_msg'                                  
=> $function_msg,
                                'form_action'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
!                               'done_action'                                   
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.index'),
                                'lang_year'                                     
        => lang('Year'),
                                'lang_category'                                 
=> lang('category'),
***************
*** 483,487 ****
  
                                'error'                                         
        => $receipt['error'],
-                               'error_flag'                                    
=> $error_id,
                                'message'                                       
        => $receipt['message'],
                                'lang_descr_statustext'                 => 
lang('Enter a description of the equipment'),
--- 490,493 ----
***************
*** 491,495 ****
                                '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'],
--- 497,501 ----
                                'lang_save_statustext'                  => 
lang('Save the equipment'),
                                'lang_no_cat'                                   
=> lang('Select category'),
!                               'lang_cat_statustext'                   => 
lang('Select the category the project belongs to. To do not use a category 
select NO CATEGORY'),
                                'select_name'                                   
=> 'values[cat_id]',
                                'value_cat_id'                                  
=> $values['cat_id'],
***************
*** 541,560 ****
                        );
  
!                       
$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));
                        }
--- 547,566 ----
                        );
  
!                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit' => $data));
                }
  
                function delete()
                {
!                       $project_id = get_var('project_id',array('POST','GET'));
                        $confirm        = get_var('confirm',array('POST'));
  
                        $link_data = array
                        (
!                               'menuaction' => 
$this->currentapp.'.uiworkorder.index'
                        );
  
                        if (get_var('confirm',array('POST')))
                        {
!                               $this->bo->delete($project_id);
                                Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php',$link_data));
                        }
***************
*** 568,572 ****
                                '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'),
--- 574,578 ----
                                '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&project_id='
 . $project_id),
                                'lang_confirm_msg'              => lang('do you 
really want to delete this entry'),
                                'lang_yes'                              => 
lang('yes'),
***************
*** 582,593 ****
                {
                        $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'],
--- 588,628 ----
                {
                        $id     = get_var('id',array('POST','GET'));
  
!                       
$GLOBALS['phpgw']->xslttpl->add_file(array('workorder',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));
! 
!                       $this->config->read_repository();
! 
!                       $values = $this->bo->read_single($id);
! 
!                       $record_history = $this->bo->read_record_history($id);
! 
!                       $table_header_history[] = array
!                       (
!                               'lang_date'                     => lang('Date'),
!                               'lang_user'                     => lang('User'),
!                               'lang_action'           => lang('Action'),
!                               'lang_new_value'        => lang('New value')
!                       );
! 
!                       $table_header_workorder_budget[] = array
!                       (
!                               'lang_workorder_id'     => lang('Workorder'),
!                               'lang_sum'      => lang('Sum')
!                       );
! 
!                       $function_msg = lang('View Project');
! 
!                       if ($values['cat_id'])
!                       {
!                               $this->cat_id = $values['cat_id'];
!                       }
! 
  
                        
$location_data=$this->bocommon->initiate_ui_location(array(
                                                'location_type' => 'view',
!                                               'equipment'             => true,
!                                               'tenant'                => true,
                                                'address'               => true,
+                                               'equipment_id'  => 
$values['equipment_id'],
                                                'property_id'   => 
$values['property_id'],
                                                'property_name' => 
$values['property_name'],
***************
*** 597,646 ****
                                                '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));
                }
--- 632,722 ----
                                                'street_name'   => 
$values['street_name'],
                                                'street_number' => 
$values['street_number'],
+                                               'tenant_id'             => 
$values['tenant_id'],
+                                               'tenant_name'   => 
$values['tenant_name'],
+                                               'tenant_phone'  => 
$values['tenant_phone'],
                                                'apartment_id'  => 
$values['apartment_id']));
  
                        $data = array
                        (
!                               'table_header_workorder_budget' => 
$table_header_workorder_budget,
!                               'lang_no_workorders'                    => 
lang('No workorder bugdet'),
!                               'workorder_link'                                
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.view'),
!                               'record_history'                                
=> $record_history,
!                               'table_header_history'                  => 
$table_header_history,
!                               'lang_history'                                  
=> lang('History'),
!                               'lang_no_history'                               
=> lang('No history'),
! 
!                               'lang_start_date'                               
=> lang('Project start date'),
!                               'value_start_date'                              
=> $values['start_date'],
! 
!                               'lang_end_date'                                 
=> lang('Project end date'),
!                               'value_end_date'                                
=> $values['end_date'],
! 
!                               'lang_charge_tenant'                    => 
lang('Charge tenant'),
!                               'charge_tenant'                                 
=> $values['charge_tenant'],
! 
!                               'lang_power_meter'                              
=> lang('Power meter'),
!                               'value_power_meter'                             
=> $values['power_meter'],
  
+                               'lang_budget'                                   
=> lang('Budget'),
+                               'value_budget'                                  
=> $values['budget'],
+ 
+                               'vendor_data'                                   
=> $vendor_data,
+                               'location_data'                                 
=> $location_data,
+                               'location_type'                                 
=> 'view',
+                               'appname'                                       
        => lang('Project'),
+                               'function_msg'                                  
=> $function_msg,
+                               'done_action'                                   
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.index'),
+                               '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_other_branch'                             
        => lang('Other branch'),
+                               'value_other_branch'                            
=> $values['other_branch'],
+ 
+                               'lang_descr'                                    
=> lang('Description'),
+                               'value_descr'                                   
=> $values['descr'],
+                               'lang_done_statustext'                  => 
lang('Back to the list'),
+                               'lang_save_statustext'                  => 
lang('Save the equipment'),
+                               'select_name'                                   
=> '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'),
+                               'select_user_name'                              
=> 'values[coordinator]',
+                               'lang_no_user'                                  
=> lang('Select coordinator'),
+                               'user_list'                                     
        => $this->bocommon->get_user_list('select',$values['coordinator']),
+ 
+                               'status_list'                                   
=> $this->bo->select_status_list('select',$values['status']),
+                               'lang_no_status'                                
=> lang('Select status'),
+                               'lang_status'                                   
=> lang('Status'),
+ 
+                               'branch_list'                                   
=> $this->bo->select_branch_p_list($values['project_id']),
+                               'lang_branch'                                   
=> lang('branch'),
+ 
+                               'key_responsible_list'                          
        => $this->bo->select_branch_list($values['key_responsible']),
+                               'lang_key_responsible'                          
        => lang('key responsible'),
+ 
+                               'key_fetch_list'                                
        => $this->bo->select_key_location_list($values['key_fetch']),
+                               'lang_key_fetch'                                
        => lang('key fetch location'),
+ 
+                               'key_deliver_list'                              
        => $this->bo->select_key_location_list($values['key_deliver']),
+                               'lang_key_deliver'                              
        => lang('key deliver location'),
+ 
+                               'edit_action'                                   
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit&id='
 . $id),
+                               'lang_edit_statustext'                          
=> lang('Edit this entry equipment'),
+                               'lang_edit'                                     
                => lang('Edit'),
+                               'currency'                                      
                => 
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency']
+                       );
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
                }





reply via email to

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