phpgroupware-cvs
[Top][All Lists]
Advanced

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

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


From: Sigurd Nes <address@hidden>
Subject: [Phpgroupware-cvs] CVS: property/inc class.bowo_hour.inc.php,NONE,1.1 class.sowo_hour.inc.php,NONE,1.1 class.uiwo_hour.inc.php,NONE,1.1 class.sopricebook.inc.php,1.5,1.6 class.soproject.inc.php,1.4,1.5 class.soworkorder.inc.php,1.9,1.10class.uiworkorder.inc.php,1.8,1.9
Date: Fri, 21 Mar 2003 17:35:50 -0500

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

Modified Files:
        class.sopricebook.inc.php class.soproject.inc.php 
        class.soworkorder.inc.php class.uiworkorder.inc.php 
Added Files:
        class.bowo_hour.inc.php class.sowo_hour.inc.php 
        class.uiwo_hour.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 bowo_hour
        {
                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 bowo_hour($session=False)
                {
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->so                       = 
CreateObject($this->currentapp.'.sowo_hour');
                        $this->socommon         = 
CreateObject($this->currentapp.'.socommon');
                        $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
                        $this->historylog       = 
CreateObject($this->currentapp.'.historylog','workorder');
                        $this->contacts         = 
CreateObject('phpgwapi.contacts');

                        $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_workorder_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($workorder_id='')
                {
                        $hour = $this->so->read(array('workorder_id' => 
$workorder_id));
                        $this->total_records = $this->so->total_records;
                        return $hour;
                }

                function add($values,$workorder_id)
                {

//_debug_array($values);

                        while($entry=each($values['select']))
                        {
                                $n=$entry[0];

                                
$cost=($values['total_cost'][$n]*$values['quantity'][$n]);

                                $hour[]=array(
                                        'activity_id'           => 
$values['activity_id'][$n],
                                        'activity_num'          => 
$values['activity_num'][$n],
                                        'hours_descr'           => 
$values['descr'][$n],
                                        'unit'                          => 
$values['unit'][$n],
                                        'cost'                          => 
$cost,
                                        'quantity'                      => 
$values['quantity'][$n],
                                        'billperae'                     => 
$values['total_cost'][$n],
                                        'ns3420_id'                     => 
$values['ns3420_id'][$n],
                                        'dim_d'                         => 
$values['dim_d'][$n],
                                        'workorder_id'          => 
$workorder_id,
                                );

                        }
//_debug_array($hour);

                        if($hour)
                        {
                                $receipt =      $this->so->add_hour($hour);
                        }
                        else
                        {
                                        $receipt['message'][] = 
array('msg'=>lang('Nothing to do!'));
                        }

                        return $receipt;

                }




                function read_single($workorder_id)
                {
                        $workorder                                              
= $this->so->read_single($workorder_id);
                        $dateformat                                             
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
                        $workorder['start_date']                = 
$GLOBALS['phpgw']->common->show_date($workorder['start_date'],$dateformat);
                        $workorder['end_date']                  = 
$GLOBALS['phpgw']->common->show_date($workorder['end_date'],$dateformat);
                        $vendor                                                 
= 
$this->contacts->read_single_entry($workorder['vendor_id'],array('org_name'=>'org_name'));
                        $workorder['vendor_name']               = 
$vendor[0]['org_name'];
                        $workorder['b_account_name']    = 
$this->so->get_b_account_name($workorder['b_account_id']);

                        return $workorder;
                }

                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 'B': $type = lang('Budget 
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 if ($value['status'] != 'B' && 
$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_workorder_id()
                {
                        return $this->so->increment_workorder_id();
                }

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

                        $workorder['start_date']        = mktime 
(2,0,0,$start_date['month'],$start_date['day'],$start_date['year']);
                        $workorder['end_date']  = mktime 
(2,0,0,$end_date['month'],$end_date['day'],$end_date['year']);

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

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

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

--- NEW FILE ---
<?php
        
/***************************************************************************\
        * This program is free software; you can redistribute it and/or modify 
it   *
        * under the terms of the GNU General Public License as published by the 
    *
        * Free Software Foundation; either version 2 of the License, or (at 
your    *
        * option) any later version.                                            
    *
        
\***************************************************************************/

        class sowo_hour
        {
                var $grants;

                function sowo_hour()
                {
                        $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','workorder');

                        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 get_b_account_name($id='')
                {
                        $this->db->query("SELECT descr FROM fm_wo_accounts 
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))
                        {
                                $workorder_id = 
(isset($data['workorder_id'])?$data['workorder_id']:0);
                        }


                        $ordermethod = ' order by grouping_id, record , h.id 
asc ';


                        $sql = "SELECT h.tolerance,h.quantity as 
quantity,h.activity_id as activity_id, h.activity_num as activity_num,"
                                . " h.record as record, h.grouping_id as 
grouping_id,h.grouping_descr as grouping_descr,"
                                . " h.id as id,h.hours_descr,a.descr as 
activity_descr,h.ns3420_id as ns3420_id,h.unit as unit,h.status,"
                                . " h.start_date,h.end_date,h.owner, 
cost,h.remark as remark, h.building_part as building_part,h.billperae"
                                . " FROM (fm_wo_hours AS h $this->join"
                                . " fm_wo_activities AS a ON 
h.activity_id=a.id) $this->join"
                                . " fm_wo_wrkorders ON h.workorder_id = 
fm_wo_wrkorders.id WHERE h.workorder_id='$workorder_id' ";



                        $this->db->query($sql . $ordermethod,__LINE__,__FILE__);
                        $this->total_records = $this->db->num_rows();

                        while ($this->db->next_record())
                        {
                                $ngrants = 
(int)$this->grants[$this->db->f('fm_wo_wrkorders.owner')];
                                $hour_list[] = array
                                (
                                        'hour_id'                       => 
$this->db->f('id'),
                                        'activity_num'          => 
$this->db->f('activity_num'),
                                        'hours_descr'           => 
stripslashes($this->db->f('hours_descr')),
                                        'activity_descr'        => 
stripslashes($this->db->f('activity_descr')),
                                        'start_date'            => 
$this->db->f('start_date'),
                                        'end_date'                      => 
$this->db->f('end_date'),
                                        'status'                        => 
$this->db->f('status'),
                                        'owner'                         => 
$this->db->f('owner'),
                                        'quantity'                      => 
$this->db->f('quantity'),
                                        'grouping_id'           => 
$this->db->f('grouping_id'),
                                        'grouping_descr'        => 
$this->db->f('grouping_descr'),
                                        'ns3420_id'                     => 
$this->db->f('ns3420_id'),
                                        'tolerance'                     => 
$this->db->f('tolerance'),
                                        'activity_id'           => 
$this->db->f('activity_id'),
                                        'unit'                          => 
$this->db->f('unit'),
                                        'record'                        => 
$this->db->f('record'),
                                        'cost'                          => 
$this->db->f('cost'),
                                        'billperae'                     => 
$this->db->f('billperae'),
                                        'remark'                        => 
$this->db->f('remark'),
                                        'building_part'         => 
$this->db->f('building_part'),
                                        'grants'                => $ngrants
                                        );
                        }
//_debug_array($hour_list);
                        return $hour_list;
                }


                function add_hour($hour)
                {
                        for ($i=0; $i<count($hour); $i++)
                        {

                                $this->db->query("insert into fm_wo_hours 
(activity_id,activity_num,hours_descr,unit,cost,quantity,billperae,ns3420_id,dim_d,workorder_id)
 "
                                . " values ('" .
                                        $hour[$i]['activity_id'] . "','" .
                                        $hour[$i]['activity_num'] . "','" .
                                        $hour[$i]['hours_descr'] . "','" .
                                        $hour[$i]['unit'] . "','" .
                                        $hour[$i]['cost'] . "','" .
                                        $hour[$i]['quantity'] . "','" .
                                        $hour[$i]['billperae'] . "','" .
                                        $hour[$i]['ns3420_id'] . "','" .
                                        $hour[$i]['dim_d'] . "','" .
                                        $hour[$i]['workorder_id']. 
"')",__LINE__,__FILE__);
                        }

                        $receipt['message'][] = array('msg'=>lang('%1 entries 
is added!',count($hour)));

                        return $receipt;

                }

                function read_single($workorder_id)
                {
                        $sql = "SELECT * from fm_wo_wrkorders where 
id='$workorder_id'";

                        $this->db->query($sql,__LINE__,__FILE__);

                        if ($this->db->next_record())
                        {
                                $workorder['workorder_id']              = 
$this->db->f('id');
                                $workorder['project_id']                = 
$this->db->f('project_id');
                                $workorder['title']                             
= $this->db->f('title');
                                $workorder['name']                              
= $this->db->f('name');
                                $workorder['key_fetch']                 = 
$this->db->f('key_fetch');
                                $workorder['key_deliver']               = 
$this->db->f('key_deliver');
                                $workorder['key_responsible']   = 
$this->db->f('key_responsible');
                                $workorder['charge_tenant']             = 
$this->db->f('charge_tenant');
                                $workorder['descr']                             
= $this->db->f('descr');
                                $workorder['status']                    = 
$this->db->f('status');
                                $workorder['budget']                    = 
(int)$this->db->f('budget');
                                $workorder['b_account_id']                      
= (int)$this->db->f('account_id');
                                $workorder['addition_percentage']       = 
(int)$this->db->f('addition');
                                $workorder['addition_rs']                       
= (int)$this->db->f('rig_addition');
                                $workorder['actual_cost']               = 
$this->db->f('actual_cost');
                                $workorder['owner']                             
= $this->db->f('owner');
                                $workorder['vendor_id']                 = 
$this->db->f('vendor');
                                $workorder['coordinator']               = 
$this->db->f('coordinator');
                                $workorder['access']                    = 
$this->db->f('access');
                                $workorder['start_date']                = 
$this->db->f('start_date');
                                $workorder['end_date']                  = 
$this->db->f('end_date');
                                $workorder['cat_id']                    = 
$this->db->f('category');
                        }

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


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

                function add($workorder)
                {

                        
$this->historylog->add('SO',$workorder['workorder_id'],$workorder['status']);

                        $workorder['descr'] = 
$this->db->db_addslashes($workorder['descr']);
                        $workorder['title'] = 
$this->db->db_addslashes($workorder['title']);
//_debug_array($workorder);
                        $this->db->query("INSERT INTO fm_wo_wrkorders 
(id,project_id,title,access,entry_date,start_date,end_date,status,"
                                . 
"descr,budget,account_id,rig_addition,addition,key_deliver,key_fetch,vendor,charge_tenant,owner)
 "
                                . "VALUES ('"
                                . $workorder['workorder_id']. "','"
                                . $workorder['project_id']. "','"
                                . $workorder['title']. "','"
                                . "public','"
                                . time() . "','"
                                . $workorder['start_date']. "','"
                                . $workorder['end_date']. "','"
                                . $workorder['status']. "','"
                                . $workorder['descr']. "','"
                                . $workorder['budget']. "','"
                                . $workorder['b_account_id']. "','"
                                . $workorder['addition_rs']. "','"
                                . $workorder['addition_percentage']. "','"
                                . $workorder['key_deliver']. "','"
                                . $workorder['key_fetch']. "','"
                                . $workorder['vendor_id']. "','"
                                . $workorder['charge_tenant'] . "','"
                                . $this->account. "')",__LINE__,__FILE__);

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

                function edit($workorder)
                {
                        $this->db->query("SELECT status,budget FROM 
fm_wo_wrkorders where id='" .$workorder['workorder_id']."'",__LINE__,__FILE__);

                        $this->db->next_record();

                        $old_status = $this->db->f('status');
                        $old_budget = $this->db->f('budget');
                        if ($old_status != $workorder['status'])
                        {
                                
$this->historylog->add('S',$workorder['workorder_id'],$workorder['status']);
                        }
                        if ($old_budget != $workorder['budget'])
                        {
                                
$this->historylog->add('B',$workorder['workorder_id'],$workorder['budget']);
                        }

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

                        $this->db->query("UPDATE fm_wo_wrkorders set
                                title                   ='" . 
$workorder['title'] . "',
                                status                  ='" . 
$workorder['status'] . "',
                                start_date              ='" . 
$workorder['start_date'] . "',
                                end_date                ='" . 
$workorder['end_date'] . "',
                                descr                   ='" . 
$workorder['descr'] . "',
                                budget                  ='" . 
(int)$workorder['budget'] . "',
                                key_deliver             ='" . 
$workorder['key_deliver'] . "',
                                key_fetch               ='" . 
$workorder['key_fetch'] . "',
                                account_id              ='" . 
$workorder['b_account_id'] . "',
                                rig_addition    ='" . $workorder['addition_rs'] 
. "',
                                addition                ='" . 
$workorder['addition_percentage'] . "',
                                charge_tenant   ='" . 
$workorder['charge_tenant'] . "',
                                vendor                  ='" . 
$workorder['vendor_id']
                                . "' WHERE id= '" . $workorder['workorder_id'] 
."'",__LINE__,__FILE__);


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

                }

                function delete($workorder_id )
                {
                        $this->db->query("DELETE FROM fm_wo_wrkorders WHERE 
id='" . $workorder_id . "'",__LINE__,__FILE__);
                        $this->db->query("DELETE FROM fm_wo_workorder_history  
WHERE  history_record_id='" . $workorder_id   . "'",__LINE__,__FILE__);
                        $this->db->query("DELETE FROM fm_wo_hours WHERE 
workorder_id='" . $workorder_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 uiwo_hour
        {
                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,
                        'prizebook'     => True,
                        'view'          => True,
                        'add'           => True,
                        'edit'          => True,
                        'delete'        => True
                );

                function uiwo_hour()
                {
                        $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.'.bowo_hour',True);
                        $this->boworkorder                      = 
CreateObject($this->currentapp.'.boworkorder',True);
                        $this->bopricebook                      = 
CreateObject($this->currentapp.'.bopricebook',True);


//                      $this->boproject                        = 
CreateObject($this->currentapp.'.boproject',True);
                        $this->so                                       = 
CreateObject($this->currentapp.'.sowo_hour',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 common_data($workorder_id)
                {
                        $hour_list = $this->bo->read($workorder_id);

//_debug_array($hour_list);

                        while (is_array($hour_list) && list(,$hour) = 
each($hour_list))
                        {
                                $sum_hour       = $sum_hour + $hour['cost'];

                                $content[] = array
                                (
                                        'activity_num'                          
=> $hour['activity_num'],
                                        'hours_descr'                           
=> $hour['hours_descr'],
                                        'activity_descr'                        
=> $hour['activity_descr'],
                                        'quantity'                              
        => $hour['quantity'],
                                        'grouping_id'                           
=> $hour['grouping_id'],
                                        'grouping_descr'                        
=> $hour['grouping_descr'],
                                        'ns3420_id'                             
        => $hour['ns3420_id'],
                                        'tolerance'                             
        => $hour['tolerance'],
                                        'remark'                                
        => $hour['remark'],
                                        'building_part'                         
=> $hour['building_part'],
                                        'quantity'                              
        => $hour['quantity'],
                                        'cost'                                  
        => $hour['cost'],
                                        'unit'                                  
        => $hour['unit'],
                                        'billperae'                             
        => $hour['billperae'],
                                        'link_view'                             
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.view&id='
 . $hour['hour_id']),
                                        'link_edit'                             
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.edit&id='
 . $hour['hour_id']),
                                        'link_delete'                           
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.delete&id='
 . $hour['hour_id']),
                                        'lang_view_statustext'          => 
lang('view the workorder'),
                                        'lang_edit_statustext'          => 
lang('edit the workorder'),
                                        'lang_delete_statustext'        => 
lang('delete this workorder'),
                                        'text_view'                             
        => lang('view'),
                                        'text_edit'                             
        => lang('edit'),
                                        'text_delete'                           
=> lang('delete')
                                );
                        }


                        $workorder      = 
$this->boworkorder->read_single($workorder_id);
//_debug_array($workorder);

                        $table_header[] = array
                        (
                                'lang_activity_num'             => 
lang('Acitity code'),
                                'lang_descr'    => lang('descr'),
                                'lang_unit'             => lang('Unit'),
                                'lang_billperea'        => lang('Bill per 
unit'),
                                'lang_quantity'         => lang('Quantity'),
                                'lang_cost'                     => lang('cost'),
                                'lang_view'                     => lang('view'),
                                'lang_edit'                     => lang('edit'),
                                'lang_delete'           => lang('delete')
                                );


                        $addition_percentage = $sum_hour * 
$workorder['addition_percentage']/100;
                        $sum_tax        = ($sum_hour + $addition_percentage + 
$workorder['addition_rs'])*0.24;

                        $table_sum[] = array
                        (
                                'lang_sum_calculation'                  => 
lang('Sum calculation'),
                                'value_sum_calculation'                 => 
$sum_hour,
                                'lang_addition_rs'                              
=> lang('Rig adition'),
                                'value_addition_rs'                             
=> $workorder['addition_rs'],
                                'lang_addition_percentage'              => 
lang('Percentage adition'),
                                'value_addition_percentage'             => 
$addition_percentage,
                                'lang_sum_tax'                                  
=> lang('Sum tax'),
                                'value_sum_tax'                                 
=> $sum_tax,
                                'lang_total_sum'                                
=> lang('Total sum'),
                                'value_total_sum'                               
=> ($sum_hour + $addition_percentage + $workorder['addition_rs'] + $sum_tax )
                        );


                        $workorder_data = array(
                                'link_workorder'                                
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit&id='
 . $workorder_id),
                                'lang_vendor_name'                              
=> lang('Vendor'),
                                'vendor_name'                                   
=> $workorder['vendor_name'],

                                'lang_workorder_id'                             
=> lang('Workorder ID'),
                                'workorder_id'                                  
=> $workorder['workorder_id'],

                                'lang_workorder_title'                  => 
lang('Workorder title'),
                                'workorder_title'                               
=> $workorder['title']
                                );



                        $common_data = array(
                                'content'                       => $content,
                                'table_header'          => $table_header,
                                'table_sum'             => $table_sum,
                                'workorder'             => $workorder,
                                'workorder_data'        => $workorder_data,
                                );

                        return $common_data;
                }

                function index()
                {

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


                        $workorder_id = 
get_var('workorder_id',array('POST','GET'));
                        $links = $this->bocommon->menu();

                        $common_data=$this->common_data($workorder_id);

                        $table_add[] = array
                        (
                                'lang_add_prizebook'                            
=> lang('Add from prizebook'),
                                'lang_add_prizebook_statustext'         => 
lang('add items from this vendors prizebook'),
                                'add_prizebook_action'                          
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.prizebook&workorder_id='
 . $workorder_id),

                                'lang_add_template'                             
        => lang('Add from template'),
                                'lang_add_template_statustext'          => 
lang('add items from a predefined template'),
                                'add_template_action'                           
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.template&workorder_id='
 . $workorder_id),

                                'lang_add_custom'                               
        => lang('Add custom'),
                                'lang_add_custom_statustext'            => 
lang('Add single custom line'),
                                'add_custom_action'                             
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.edit&workorder_id='
 . $workorder_id)
                        );

                        $data = array
                        (
                                'links'                                         
        => $links,
                                'num_records'                                   
=> count($hours_list),
                                'appname'                                       
        => lang($this->currentapp),
                                'function_msg'                                  
=> lang('list hours'),
                                'table_header_hour'                             
=> $common_data['table_header'],
                                'values_hour'                                   
=> $common_data['content'],
                                'workorder_data'                                
=> $common_data['workorder_data'],
                                'table_add'                                     
        => $table_add,
                                'table_sum'                                     
        => $common_data['table_sum']
                        );

                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_hour' => $data));
                        $this->save_sessiondata();
                }

                function prizebook()
                {
                        $GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour',
                                                                                
'menu',
                                                                                
'nextmatchs',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'app_header',
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'search_field'));

                        $workorder_id = 
get_var('workorder_id',array('POST','GET'));
                        $values = get_var('values',array('POST'));
//_debug_array($values);

                        if($values['add'])
                        {
                                $receipt=$this->bo->add($values,$workorder_id);
                        }

                        $links = $this->bocommon->menu();

                        $common_data=$this->common_data($workorder_id);

                        $workorder      = $common_data['workorder'];

                        if($workorder['vendor_id'])
                        {
                                $this->bopricebook->cat_id = 
$workorder['vendor_id'];
                                $this->bopricebook->start = $this->start;
                                $this->bopricebook->query = $this->query;
                                $pricebook_list = $this->bopricebook->read();
                        }

//_debug_array($pricebook_list);
                        $i=0;
                        while (is_array($pricebook_list) && list(,$pricebook) = 
each($pricebook_list))
                        {
                                $content_prizebook[] = array
                                (
                                        'counter'                               
=> $i,
                                        'activity_id'                   => 
$pricebook['activity_id'],
                                        'num'                                   
=> $pricebook['num'],
                                        'branch'                                
=> $pricebook['branch'],
                                        'vendor_id'                             
=> $pricebook['vendor_id'],
                                        'm_cost'                                
=> $pricebook['m_cost'],
                                        'w_cost'                                
=> $pricebook['w_cost'],
                                        'total_cost'                    => 
$pricebook['total_cost'],
                                        'this_index'                    => 
$pricebook['this_index'],
                                        'unit'                                  
=> $pricebook['unit'],
                                        'descr'                                 
=> $pricebook['descr'],
                                        'base_descr'                    => 
$pricebook['base_descr'],
                                        'index_count'                   => 
$pricebook['index_count'],
                                        'link_edit'                             
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.edit_activity&activity_id='
 . $pricebook['activity_id']),
                                        'link_prizing'                          
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uipricebook.prizing&activity_id='
 . $pricebook['activity_id'].'&vendor_id=' . $pricebook['vendor_id'] 
.'&cat_id=' .$this->cat_id),
                                        'lang_edit_statustext'          => 
lang('edit the pricebook'),
                                        'lang_prizing_statustext'       => 
lang('view or edit prizing history of this element'),
                                        'text_edit'                             
        => lang('edit'),
                                        'text_prizing'                          
=> lang('prizing')
                                );

                                $i++;
                        }

                        $table_header_prizebook[] = array
                        (
                                'sort_num'      => 
$this->nextmatchs->show_sort_order(array
                                                                                
(
                                                                                
        'sort'  => $this->sort,
                                                                                
        'var'   =>      'num',
                                                                                
        'order' =>      $this->order,
                                                                                
        'extra'         => array('menuaction'   => 
$this->currentapp.'.uiwo_hour.prizebook',
                                                                                
                                                        'workorder_id'  
=>$workorder_id,
                                                                                
                                                        'allrows'       
=>$this->allrows)
                                                                                
)),
                                'lang_num'                      => 
lang('Activity Num'),
                                'lang_branch'           => lang('Branch'),
                                'lang_vendor'           => lang('Vendor'),
                                'lang_select'           => lang('Select'),
                                'lang_total_cost'       => lang('Total Cost'),
                                'lang_descr'            => lang('Description'),
                                'lang_base_descr'       => lang('Base'),
                                'lang_m_cost'           => lang('Material 
cost'),
                                'lang_w_cost'           => lang('Labour cost'),
                                'lang_unit'                     => lang('Unit'),
                                'lang_quantity'         => lang('Quantity'),

                                'lang_view'                     => lang('view'),
                                'lang_edit'                     => lang('edit'),
                                'sort_total_cost'       => 
$this->nextmatchs->show_sort_order(array
                                                                                
(
                                                                                
        'sort'  => $this->sort,
                                                                                
        'var'   =>      'total_cost',
                                                                                
        'order' =>      $this->order,
                                                                                
        'extra'         => array('menuaction'   => 
$this->currentapp.'.uiwo_hour.prizebook',
                                                                                
                                                        'workorder_id'  
=>$workorder_id,
                                                                                
                                                        'allrows'       
=>$this->allrows)
                                                                                
))
                        );


                        $table_done[] = array
                        (
                                'lang_done'                             => 
lang('Done'),
                                'lang_done_statustext'  => lang('Back to list'),
                                'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index&workorder_id='
 . $workorder_id)
                        );

                        $link_data = array
                        (
                                'menuaction'    => 
$this->currentapp.'.uiwo_hour.prizebook',
                                                'sort'                  
=>$this->sort,
                                                'order'                 
=>$this->order,
                                                'workorder_id'  =>$workorder_id,
                                                'query'                 
=>$this->query
                        );


                        if(!$this->bopricebook->allrows)
                        {
                                $record_limit   = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
                        }
                        else
                        {
                                $record_limit   = 
$this->bopricebook->total_records;
                        }


                        $data = array
                        (
                                'error'                                         
        => $receipt['error'],
                                'message'                                       
        => $receipt['message'],
                                'form_action'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
                                'lang_add_statustext'                   => 
lang('Add the selected items'),
                                'lang_add'                                      
        => lang('Add'),

                                'links'                                         
        => $links,
                                'allrows'                                       
        => $this->bopricebook->allrows,
                                'allow_allrows'                                 
=> true,
                                'start_record'                                  
=> $this->start,
                                'record_limit'                                  
=> $record_limit,
                                'num_records'                                   
=> count($pricebook_list),
                                'all_records'                                   
=> $this->bopricebook->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 prizebook'),
                                'select_action'                                 
=> $GLOBALS['phpgw']->link('/index.php',$link_data),

                                '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'),
                                'workorder_data'                                
=> $common_data['workorder_data'],
                                'table_header_prizebook'                => 
$table_header_prizebook,
                                'values_prizebook'                              
=> $content_prizebook,
                                'table_header_hour'                             
=> $common_data['table_header'],
                                'values_hour'                                   
=> $common_data['content'],
                                'table_sum'                                     
        => $common_data['table_sum'],
                                'table_done'                                    
=> $table_done
                        );

                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('prizebook' => $data));
                        $this->save_sessiondata();
                }

                function edit()
                {
                        $id                             = 
get_var('id',array('POST','GET'));
                        $project_id             = 
get_var('project_id',array('POST','GET'));
                        $values                         = 
get_var('values',array('POST'));

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

                        $values['vendor_id']            = 
get_var('vendor_id',array('POST'));
                        $values['vendor_name']          = 
get_var('vendor_name',array('POST'));
                        $values['b_account_id']         = 
get_var('b_account_id',array('POST'));
                        $values['b_account_name']       = 
get_var('b_account_name',array('POST'));


                        $values['start_date']           = 
get_var('start_date',array('POST'));
                        $values['end_date']                     = 
get_var('end_date',array('POST'));

                        $this->config->read_repository();

                        if ($values['save'])
                        {
                                if(!$values['title'])
                                {
                                        
$receipt['error'][]=array('msg'=>lang('Please enter a workorder title !'));
                                        $error_id=true;
                                }
                                if(!$values['project_id'])
                                {
                                        
$receipt['error'][]=array('msg'=>lang('Please select a valid project !'));
                                        $error_id=true;
                                }

                                if(!$values['status'])
                                {
                                        
$receipt['error'][]=array('msg'=>lang('Please select a status !'));
                                }

                                if($id)
                                {
                                        $values['workorder_id']=$id;
                                        $action='edit';
                                }
                                else
                                {
                                        
$values['workorder_id']=$this->bo->increment_workorder_id();
                                        $id     = $values['workorder_id'];
                                }

                                if(!$receipt['error'])
                                {
                                        if($values['copy_workorder'])
                                        {
                                                $action='add';
                                                $values['workorder_id'] = 
$this->bo->increment_workorder_id();
                                                $id     = 
$values['workorder_id'];
                                        }
                                        $receipt = 
$this->bo->save($values,$action);
                                        $id = $values['workorder_id'];
                                        $function_msg = lang('Edit Workorder');

                                        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['workorder_id'];
                                                $message = lang(Workorder) . " 
" . $values['workorder_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);
                                if($project_id && !$values['project_id'])
                                {
                                        $values['project_id']=$project_id;
                                }
                                $project        = 
$this->boproject->read_single($values['project_id']);

                                if( $project['key_fetch'] && 
!$values['key_fetch'])
                                {
                                        
$values['key_fetch']=$project['key_fetch'];
                                }

                                if( $project['key_deliver'] && 
!$values['key_deliver'])
                                {
                                        
$values['key_deliver']=$project['key_deliver'];
                                }

//_debug_array($project);
                        }

                        $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 Workorder');
                        }
                        else
                        {
                                $function_msg = lang('Add Workorder');
                        }

                        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'  => 
$project['equipment_id'],
                                                'property_id'   => 
$project['property_id'],
                                                'property_name' => 
$project['property_name'],
                                                'building_id'   => 
$project['building_id'],
                                                'entrance_id'   => 
$project['entrance_id'],
                                                'floor'                 => 
$project['floor'],
                                                'street_name'   => 
$project['street_name'],
                                                'street_number' => 
$project['street_number'],
                                                'tenant_id'             => 
$project['tenant_id'],
                                                'tenant_name'   => 
$project['tenant_name'],
                                                'tenant_phone'  => 
$project['tenant_phone'],
                                                'apartment_id'  => 
$project['apartment_id']));


                        
$vendor_data=$this->bocommon->initiate_ui_vendorlookup(array(
                                                'vendor_id'             => 
$values['vendor_id'],
                                                'vendor_name'   => 
$values['vendor_name']));

                        
$b_account_data=$this->bocommon->initiate_ui_budget_account_lookup(array(
                                                'b_account_id'          => 
$values['b_account_id'],
                                                'b_account_name'        => 
$values['b_account_name']));


                        $link_data = array
                        (
                                'menuaction'    => 
$this->currentapp.'.uiwo_hour.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
                        (
                                'calculate_action'                              
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.edit'),
                                'lang_calculate'                                
=> lang('Calculate Workorder'),
                                'lang_calculate_statustext'             => 
lang('Calculate workorder by adding items from vendors prizebook or adding 
general hours'),

                                'project_link'                                  
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit'),
                                'b_account_data'                                
=> $b_account_data,
                                'vendor_data'                                   
=> $vendor_data,
                                '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.'.uiwo_hour.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',
                                '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('Workorder 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('Workorder end date'),
                                'value_end_date'                                
=> $values['end_date'],

                                'lang_copy_workorder'                   => 
lang('Copy workorder ?'),
                                'lang_copy_workorder_statustext'        => 
lang('Choose Copy Workorder to copy this workorder to a new workorder'),

                                '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'                             
=> $project['power_meter'],

                                'lang_addition_rs'                              
=> lang('Rig adition'),
                                'lang_addition_rs_statustext'   => lang('Enter 
any round sum addition per order'),
                                'value_addition_rs'                             
=> $values['addition_rs'],

                                'lang_addition_percentage'                      
=> lang('Percentage adition'),
                                'lang_addition_percentage_statustext'   => 
lang('Enter any persentage addition per unit'),
                                'value_addition_percentage'                     
        => $values['addition_percentage'],

                                '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'                                 
=> 'view',
                                'appname'                                       
        => lang('workorder'),
                                'function_msg'                                  
=> $function_msg,
                                'form_action'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
                                'done_action'                                   
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index'),
                                'lang_year'                                     
        => lang('Year'),
                                'lang_category'                                 
=> lang('category'),
                                'lang_save'                                     
        => lang('save'),
                                'lang_done'                                     
        => lang('done'),
                                'lang_title'                                    
=> lang('Title'),
                                'value_title'                                   
=> $values['title'],
                                'lang_project_name'                             
=> lang('Project name'),
                                'value_project_name'                    => 
$project['name'],

                                'lang_project_id'                               
=> lang('Project ID'),
                                'value_project_id'                              
=> $values['project_id'],

                                'lang_workorder_id'                             
=> lang('Workorder ID'),
                                'value_workorder_id'                    => 
$values['workorder_id'],

                                'lang_title_statustext'                 => 
lang('Enter Workorder title'),

                                'lang_other_branch'                             
        => lang('Other branch'),
                                'lang_other_branch_statustext'          => 
lang('Enter other branch if not found in the list'),
                                'value_other_branch'                            
=> $project['other_branch'],

                                'error'                                         
        => $receipt['error'],
                                'message'                                       
        => $receipt['message'],
                                'lang_descr_statustext'                 => 
lang('Enter a short description of the workorder'),
                                'lang_descr'                                    
=> lang('Description'),
                                'value_descr'                                   
=> $values['descr'],
                                'lang_done_statustext'                  => 
lang('Back to the list'),
                                'lang_save_statustext'                  => 
lang('Save the workorder'),
                                '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_workorder_list('select',$project['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]',
                                'user_list'                                     
        => $this->bocommon->get_user_list('select',$project['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 workorder ?'),

                                'branch_list'                                   
=> $this->boproject->select_branch_p_list($project['project_id']),
                                'lang_branch'                                   
=> lang('branch'),
                                'lang_branch_statustext'                => 
lang('Select the branches for this project'),

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

                                '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 add()
                {

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

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

                        $data = array
                        (
                                'appname'                               => 
lang('Workorder'),
                                'function_msg'                  => lang('Add 
workorder'),
                                'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
                                'add_action'                    => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.edit'),
                                'search_action'                 => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.index&lookup=true'),

                                'lang_done_statustext'                  => 
lang('Back to the workorder list'),
                                'lang_add_statustext'                   => 
lang('Adds a new project - then a new workorder'),
                                'lang_search_statustext'                => 
lang('Adds a new workorder to an existing project'),

                                'lang_done'                             => 
lang('Done'),
                                'lang_add'                              => 
lang('Add'),
                                'lang_search'                   => 
lang('Search')
                        );

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

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

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

                        if (get_var('confirm',array('POST')))
                        {
                                $this->bo->delete($id);
                                Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php',$link_data));
                        }

                        
$GLOBALS['phpgw']->xslttpl->add_file(array($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('workorder'),
                                'function_msg'                  => lang('delete 
workorder'),
                                'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php',$link_data),
                                'delete_action'                 => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.delete&id='
 . $id),
                                'lang_confirm_msg'              => lang('do you 
really want to delete this entry'),
                                'lang_yes'                              => 
lang('yes'),
                                'lang_yes_statustext'   => lang('Delete the 
entry'),
                                'lang_no_statustext'    => lang('Back to the 
list'),
                                'lang_no'                               => 
lang('no')
                        );

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

                function view()
                {
                        $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);
                        $project        = 
$this->boproject->read_single($values['project_id']);

//_debug_array($values);
                        $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 Workorder');

                        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'  => 
$project['equipment_id'],
                                                'property_id'   => 
$project['property_id'],
                                                'property_name' => 
$project['property_name'],
                                                'building_id'   => 
$project['building_id'],
                                                'entrance_id'   => 
$project['entrance_id'],
                                                'floor'                 => 
$project['floor'],
                                                'street_name'   => 
$project['street_name'],
                                                'street_number' => 
$project['street_number'],
                                                'tenant_id'             => 
$project['tenant_id'],
                                                'tenant_name'   => 
$project['tenant_name'],
                                                'tenant_phone'  => 
$project['tenant_phone'],
                                                'apartment_id'  => 
$project['apartment_id']));

                        $data = array
                        (
                                'project_link'                                  
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiproject.view'),
                                '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.'.uiwo_hour.view'),
                                'record_history'                                
=> $record_history,
                                'table_header_history'                  => 
$table_header_history,
                                'lang_history'                                  
=> lang('History'),
                                'lang_no_history'                               
=> lang('No history'),

                                'lang_vendor'                                   
=> lang('Vendor'),
                                'value_vendor_id'                               
=> $values['vendor_id'],
                                'value_vendor_name'                             
=> $values['vendor_name'],

                                'lang_b_account'                                
=> lang('Budget account'),
                                'value_b_account_id'                    => 
$values['b_account_id'],
                                'value_b_account_name'                  => 
$values['b_account_name'],


                                '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'                             
=> $project['power_meter'],

                                'lang_addition_rs'                              
=> lang('Rig adition'),
                                'lang_addition_rs_statustext'   => lang('Enter 
any round sum addition per order'),
                                'value_addition_rs'                             
=> $values['addition_rs'],

                                'lang_addition_percentage'                      
=> lang('Percentage adition'),
                                'lang_addition_percentage_statustext'   => 
lang('Enter any persentage addition per unit'),
                                'value_addition_percentage'                     
        => $values['addition_percentage'],

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

                                'location_data'                                 
=> $location_data,
                                'location_type'                                 
=> 'view',
                                'appname'                                       
        => lang('Workorder'),
                                'function_msg'                                  
=> $function_msg,
                                'done_action'                                   
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index'),
                                'lang_year'                                     
        => lang('Year'),
                                'lang_category'                                 
=> lang('category'),
                                'lang_save'                                     
        => lang('save'),
                                'lang_done'                                     
        => lang('done'),
                                'lang_name'                                     
        => lang('Name'),

                                'lang_title'                                    
=> lang('Title'),
                                'value_title'                                   
=> $values['title'],

                                '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'                            
=> $project['other_branch'],

                                'lang_descr'                                    
=> lang('Description'),
                                'value_descr'                                   
=> $values['descr'],
                                'lang_done_statustext'                  => 
lang('Back to the list'),
                                'cat_list'                                      
        => 
$this->bo->select_category_workorder_list('select',$project['cat_id']),

                                'lang_workorder_id'                             
=> lang('Workorder ID'),

                                'lang_coordinator'                              
=> lang('Coordinator'),
                                'lang_sum'                                      
        => lang('Sum'),
                                'user_list'                                     
        => $this->bocommon->get_user_list('select',$project['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($project['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.'.uiwo_hour.edit&id='
 . $id),
                                'lang_edit_statustext'                  => 
lang('Edit this entry workorder'),
                                'lang_edit'                                     
        => lang('Edit'),
                                'currency'                                      
        => $GLOBALS['phpgw_info']['user']['preferences']['common']['currency']
                        );
//_debug_array($this->bo->select_key_location_list($values['key_fetch']));
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('view' => $data));
                }
        }
?>

Index: class.sopricebook.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.sopricebook.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** class.sopricebook.inc.php   5 Mar 2003 14:31:49 -0000       1.5
--- class.sopricebook.inc.php   21 Mar 2003 22:35:48 -0000      1.6
***************
*** 184,187 ****
--- 184,188 ----
                        }
  
+ //_debug_array($data);
                        if ($order)
                        {
***************
*** 206,214 ****
                        }
  
!                       $sql = "SELECT 
fm_wo_activities.num,fm_wo_activities.unit,fm_wo_activities.descr as 
descr,activity_id, phpgw_addressbook.org_name,fm_wo_branch.descr as branch 
,vendor_id,total_cost,m_cost,w_cost,index_count,fm_wo_activity_price_index.this_index
 "
                                . " FROM (fm_wo_activities  $this->join 
fm_wo_activity_price_index ON fm_wo_activities.id = 
fm_wo_activity_price_index.activity_id) $this->join phpgw_addressbook ON 
fm_wo_activity_price_index.vendor_id = phpgw_addressbook.id "
                                . " $this->join fm_wo_branch ON 
fm_wo_activities.branch_id = fm_wo_branch.id "
!                               . " WHERE vendor_id='$cat_id' and current_index 
is not null "
!                               . " OR (fm_wo_activity_price_index.vendor_id = 
'$cat_id') AND (fm_wo_activity_price_index.this_index IS NULL)";
  
                        $this->db2->query($sql,__LINE__,__FILE__);
--- 207,215 ----
                        }
  
!                       $sql = "SELECT 
fm_wo_activities.num,fm_wo_activities.unit,fm_wo_activities.dim_d,fm_wo_activities.ns3420,fm_wo_activities.descr
 as descr, fm_wo_activities.base_descr,activity_id, 
phpgw_addressbook.org_name,fm_wo_branch.descr as branch 
,vendor_id,total_cost,m_cost,w_cost,index_count,fm_wo_activity_price_index.this_index
 "
                                . " FROM (fm_wo_activities  $this->join 
fm_wo_activity_price_index ON fm_wo_activities.id = 
fm_wo_activity_price_index.activity_id) $this->join phpgw_addressbook ON 
fm_wo_activity_price_index.vendor_id = phpgw_addressbook.id "
                                . " $this->join fm_wo_branch ON 
fm_wo_activities.branch_id = fm_wo_branch.id "
!                               . " WHERE (vendor_id='$cat_id' and 
current_index is not null "
!                               . " OR (fm_wo_activity_price_index.vendor_id = 
'$cat_id') AND (fm_wo_activity_price_index.this_index IS NULL)) $querymethod";
  
                        $this->db2->query($sql,__LINE__,__FILE__);
***************
*** 238,242 ****
--- 239,246 ----
                                        'this_index'            => 
$this->db->f('this_index'),
                                        'unit'                          => 
$this->db->f('unit'),
+                                       'dim_d'                         => 
$this->db->f('dim_d'),
+                                       'ns3420_id'                     => 
$this->db->f('ns3420'),
                                        'descr'                         => 
stripslashes($this->db->f('descr')),
+                                       'base_descr'            => 
stripslashes($this->db->f('base_descr')),
                                        'index_count'           => 
$this->db->f('index_count'),
                                        'grants'                        => 
$ngrants

Index: class.soproject.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.soproject.inc.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** class.soproject.inc.php     18 Mar 2003 14:23:11 -0000      1.4
--- class.soproject.inc.php     21 Mar 2003 22:35:48 -0000      1.5
***************
*** 249,253 ****
                function project_workorder_data($project_id = '')
                {
!                       $this->db->query("select budget, id as workorder_id, 
vendor as vendor_id from fm_wo_wrkorders where project_id='$project_id'");
                        while ($this->db->next_record())
                        {
--- 249,253 ----
                function project_workorder_data($project_id = '')
                {
!                       $this->db->query("select budget, id as workorder_id, 
vendor_id from fm_wo_wrkorders where project_id='$project_id'");
                        while ($this->db->next_record())
                        {

Index: class.soworkorder.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.soworkorder.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** class.soworkorder.inc.php   18 Mar 2003 14:23:11 -0000      1.9
--- class.soworkorder.inc.php   21 Mar 2003 22:35:48 -0000      1.10
***************
*** 182,187 ****
                        while ($this->db->next_record())
                        {
!                               $ngrants = 
(int)$this->grants[$this->db->f('fm_wo_project.owner')];
!                               $project_list[] = array
                                (
                                        'workorder_id'  => $this->db->f('id'),
--- 182,187 ----
                        while ($this->db->next_record())
                        {
!                               $ngrants = 
(int)$this->grants[$this->db->f('fm_wo_wrkorders.owner')];
!                               $workorder_list[] = array
                                (
                                        'workorder_id'  => $this->db->f('id'),
***************
*** 205,209 ****
                                        );
                        }
!                       return $project_list;
                }
  
--- 205,209 ----
                                        );
                        }
!                       return $workorder_list;
                }
  
***************
*** 232,236 ****
                                $workorder['actual_cost']               = 
$this->db->f('actual_cost');
                                $workorder['owner']                             
= $this->db->f('owner');
!                               $workorder['vendor_id']                 = 
$this->db->f('vendor');
                                $workorder['coordinator']               = 
$this->db->f('coordinator');
                                $workorder['access']                    = 
$this->db->f('access');
--- 232,236 ----
                                $workorder['actual_cost']               = 
$this->db->f('actual_cost');
                                $workorder['owner']                             
= $this->db->f('owner');
!                               $workorder['vendor_id']                 = 
$this->db->f('vendor_id');
                                $workorder['coordinator']               = 
$this->db->f('coordinator');
                                $workorder['access']                    = 
$this->db->f('access');
***************
*** 327,331 ****
  //_debug_array($workorder);
                        $this->db->query("INSERT INTO fm_wo_wrkorders 
(id,project_id,title,access,entry_date,start_date,end_date,status,"
!                               . 
"descr,budget,account_id,rig_addition,addition,key_deliver,key_fetch,vendor,charge_tenant,owner)
 "
                                . "VALUES ('"
                                . $workorder['workorder_id']. "','"
--- 327,331 ----
  //_debug_array($workorder);
                        $this->db->query("INSERT INTO fm_wo_wrkorders 
(id,project_id,title,access,entry_date,start_date,end_date,status,"
!                               . 
"descr,budget,account_id,rig_addition,addition,key_deliver,key_fetch,vendor_id,charge_tenant,owner)
 "
                                . "VALUES ('"
                                . $workorder['workorder_id']. "','"
***************
*** 386,390 ****
                                addition                ='" . 
$workorder['addition_percentage'] . "',
                                charge_tenant   ='" . 
$workorder['charge_tenant'] . "',
!                               vendor                  ='" . 
$workorder['vendor_id']
                                . "' WHERE id= '" . $workorder['workorder_id'] 
."'",__LINE__,__FILE__);
  
--- 386,390 ----
                                addition                ='" . 
$workorder['addition_percentage'] . "',
                                charge_tenant   ='" . 
$workorder['charge_tenant'] . "',
!                               vendor_id                       ='" . 
$workorder['vendor_id']
                                . "' WHERE id= '" . $workorder['workorder_id'] 
."'",__LINE__,__FILE__);
  

Index: class.uiworkorder.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.uiworkorder.inc.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** class.uiworkorder.inc.php   18 Mar 2003 14:23:11 -0000      1.8
--- class.uiworkorder.inc.php   21 Mar 2003 22:35:48 -0000      1.9
***************
*** 445,449 ****
                        $data = array
                        (
!                               'calculate_action'                              
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.edit'),
                                'lang_calculate'                                
=> lang('Calculate Workorder'),
                                'lang_calculate_statustext'             => 
lang('Calculate workorder by adding items from vendors prizebook or adding 
general hours'),
--- 445,449 ----
                        $data = array
                        (
!                               'calculate_action'                              
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index'),
                                'lang_calculate'                                
=> lang('Calculate Workorder'),
                                'lang_calculate_statustext'             => 
lang('Calculate workorder by adding items from vendors prizebook or adding 
general hours'),





reply via email to

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