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,1.1,1.2 cla


From: Sigurd Nes <address@hidden>
Subject: [Phpgroupware-cvs] CVS: property/inc class.bowo_hour.inc.php,1.1,1.2 class.sowo_hour.inc.php,1.1,1.2 class.soworkorder.inc.php,1.10,1.11 class.uiwo_hour.inc.php,1.1,1.2
Date: Mon, 24 Mar 2003 12:37:26 -0500

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

Modified Files:
        class.bowo_hour.inc.php class.sowo_hour.inc.php 
        class.soworkorder.inc.php class.uiwo_hour.inc.php 
Log Message:
no message

Index: class.bowo_hour.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.bowo_hour.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.bowo_hour.inc.php     21 Mar 2003 22:35:48 -0000      1.1
--- class.bowo_hour.inc.php     24 Mar 2003 17:37:24 -0000      1.2
***************
*** 77,258 ****
                }
  
!               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;
                }
  
--- 77,213 ----
                }
  
! 
!               function get_chapter_list($selected='')
                {
!                       
$GLOBALS['phpgw']->xslttpl->add_file(array('chapter_select'));
  
!                       $chapters= $this->so->get_chapter_list();
  
!                       while (is_array($chapters) && list(,$chapter_entry) = 
each($chapters))
                        {
!                               $sel_chapter_entry = '';
!                               if ($chapter_entry['id']==$selected)
                                {
!                                       $sel_chapter_entry = 'selected';
                                }
  
!                               $chapter_list[] = array
                                (
!                                       'id'            => $chapter_entry['id'],
!                                       'name'          => 
$chapter_entry['name'],
!                                       'selected'      => $sel_chapter_entry
                                );
                        }
  
!                       for ($i=0;$i<count($chapter_list);$i++)
                        {
!                               if ($chapter_list[$i]['selected'] != 'selected')
                                {
!                                       unset($chapter_list[$i]['selected']);
                                }
                        }
  
!                       return $chapter_list;
                }
  
!               function get_tolerance_list($selected='')
                {
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('tolerance_select'));
  
!                       $tolerances[0]['id']= 1;
!                       $tolerances[1]['id']= 2;
!                       $tolerances[2]['id']= 3;
  
!                       while (is_array($tolerances) && list(,$tolerance_entry) 
= each($tolerances))
                        {
!                               $sel_tolerance_entry = '';
!                               if ($tolerance_entry['id']==$selected)
                                {
!                                       $sel_tolerance_entry = 'selected';
                                }
  
!                               $tolerance_list[] = array
                                (
!                                       'id'            => 
$tolerance_entry['id'],
!                                       'name'          => 
$tolerance_entry['id'],
!                                       'selected'      => $sel_tolerance_entry
                                );
                        }
  
!                       for ($i=0;$i<count($tolerance_list);$i++)
                        {
!                               if ($tolerance_list[$i]['selected'] != 
'selected')
                                {
!                                       unset($tolerance_list[$i]['selected']);
                                }
                        }
  
!                       return $tolerance_list;
                }
  
!               function get_grouping_list($selected='',$workorder_id)
                {
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('grouping_select'));
  
!                       $groupings= $this->so->get_grouping_list($workorder_id);
  
!                       while (is_array($groupings) && list(,$grouping_entry) = 
each($groupings))
                        {
!                               $sel_grouping_entry = '';
!                               if ($grouping_entry['id']==$selected)
                                {
!                                       $sel_grouping_entry = 'selected';
                                }
  
!                               $grouping_list[] = array
                                (
!                                       'id'            => 
$grouping_entry['id'],
!                                       'name'          => 
$grouping_entry['name'],
!                                       'selected'      => $sel_grouping_entry
                                );
                        }
  
!                       for ($i=0;$i<count($grouping_list);$i++)
                        {
!                               if ($grouping_list[$i]['selected'] != 
'selected')
                                {
!                                       unset($grouping_list[$i]['selected']);
                                }
                        }
  
!                       return $grouping_list;
                }
  
!               function get_building_part_list($selected='')
                {
!                       
$GLOBALS['phpgw']->xslttpl->add_file(array('building_part_select'));
  
!                       $building_parts= $this->so->get_building_part_list();
  
!                       while (is_array($building_parts) && 
list(,$building_part_entry) = each($building_parts))
                        {
!                               $sel_building_part_entry = '';
!                               if ($building_part_entry['id']==$selected)
                                {
!                                       $sel_building_part_entry = 'selected';
                                }
  
!                               $building_part_list[] = array
                                (
!                                       'id'            => 
$building_part_entry['id'],
!                                       'name'          => '[ ' . 
$building_part_entry['id'] . ' ] ' . $building_part_entry['name'],
!                                       'selected'      => 
$sel_building_part_entry
                                );
                        }
  
!                       for ($i=0;$i<count($building_part_list);$i++)
                        {
!                               if ($building_part_list[$i]['selected'] != 
'selected')
                                {
!                                       
unset($building_part_list[$i]['selected']);
                                }
                        }
  
!                       return $building_part_list;
                }
  
***************
*** 265,269 ****
                }
  
!               function add($values,$workorder_id)
                {
  
--- 220,224 ----
                }
  
!               function add_hour($values,$workorder_id)
                {
  
***************
*** 305,429 ****
                }
  
! 
! 
! 
!               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);
                }
        }
--- 260,336 ----
                }
  
!               function add_single_hour($values,$workorder_id)
                {
  
! _debug_array($values);
  
  
!                       $cost=($values['total_cost'][$n]*$values['quantity']);
  
+                       $hour[]=array(
+                               'activity_id'           => 
$values['activity_id'],
+                               'activity_num'          => 
$values['activity_num'],
+                               'hours_descr'           => $values['descr'],
+                               'unit'                          => 
$values['unit'],
+                               'cost'                          => $cost,
+                               'quantity'                      => 
$values['quantity'],
+                               'billperae'                     => 
$values['total_cost'],
+                               'ns3420_id'                     => 
$values['ns3420_id'],
+                               'dim_d'                         => 
$values['dim_d'],
+                               '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_hour($hour_id)
                {
!                       $hour   = $this->so->read_single_hour($hour_id);
!                       return $hour;
                }
  
  
!               function save_hour($values,$workorder_id)
!               {
!                       $values['billperae']    = 
str_replace(",",".",$values['billperae']);
!                       $values['quantity']             = 
str_replace(",",".",$values['quantity']);
!                       $values['cost']                 = 
$values['billperae']*$values['quantity'];
!                       if($values['ns3420_descr'])
!                       {
!                               $values['descr']=$values['ns3420_descr'];
!                       }
  
!                       if ($values['hour_id'])
                        {
!                               if ($values['hour_id'] != 0)
!                               {
!                                       $receipt['hour_id'] = 
$values['hour_id'];
! 
!                                       $this->so->edit($values);
!                               }
                        }
                        else
                        {
! //_debug_array($values);
!                               $receipt = 
$this->so->add_custom_hour($values,$workorder_id);
                        }
                        return $receipt;
                }
  
!               function delete($hour_id)
                {
!                       return $this->so->delete($hour_id);
                }
        }

Index: class.sowo_hour.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.sowo_hour.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.sowo_hour.inc.php     21 Mar 2003 22:35:48 -0000      1.1
--- class.sowo_hour.inc.php     24 Mar 2003 17:37:24 -0000      1.2
***************
*** 18,23 ****
                        $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')
--- 18,21 ----
***************
*** 31,78 ****
                }
  
! 
!               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()
                {
--- 29,75 ----
                }
  
!               function get_chapter_list()
                {
!                       $this->db->query("SELECT id, descr FROM fm_wo_chapter 
ORDER BY id ");
  
                        $i = 0;
                        while ($this->db->next_record())
                        {
!                               $chapter_entries[$i]['id']                      
        = $this->db->f('id');
!                               $chapter_entries[$i]['name']                    
        = stripslashes($this->db->f('descr'));
                                $i++;
                        }
!                       return $chapter_entries;
                }
  
!               function get_grouping_list($workorder_id='')
                {
!                       $this->db->query("SELECT grouping_id, grouping_descr 
FROM fm_wo_hours where workorder_id='$workorder_id' and grouping_id is not null 
group by grouping_id, grouping_descr");
  
!                       $i = 0;
!                       while ($this->db->next_record())
!                       {
!                               $grouping_entries[$i]['id']                     
        = $this->db->f('grouping_id');
!                               $grouping_entries[$i]['name']                   
        = stripslashes($this->db->f('grouping_descr'));
!                               $i++;
!                       }
!                       return $grouping_entries;
                }
  
!               function get_building_part_list()
                {
!                       $this->db->query("SELECT id, descr FROM 
fm_building_part ORDER BY id ");
  
                        $i = 0;
                        while ($this->db->next_record())
                        {
!                               $building_part_entries[$i]['id']                
                = $this->db->f('id');
!                               $building_part_entries[$i]['name']              
                = stripslashes($this->db->f('descr'));
                                $i++;
                        }
!                       return $building_part_entries;
                }
  
+ 
                function select_branch_list()
                {
***************
*** 89,105 ****
                }
  
-               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)
--- 86,89 ----
***************
*** 181,380 ****
                        $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__);
  
                }
--- 165,300 ----
                        $receipt['message'][] = array('msg'=>lang('%1 entries 
is added!',count($hour)));
  
+                       $receipt['hour_id'] = 
$this->db->get_last_insert_id('fm_wo_hours','id');
+ 
                        return $receipt;
  
                }
!               function add_custom_hour($hour,$workorder_id)
                {
  
  
+                       $this->db->query("UPDATE fm_wo_wrkorders set
+                               chapter_id      ='" . $hour['chapter_id'] . "' 
WHERE id= '$workorder_id'",__LINE__,__FILE__);
  
!                       if($hour['grouping_id'])
                        {
!                               $this->db->query("SELECT grouping_descr , max 
(record) as record FROM fm_wo_hours where grouping_id='" .$hour['grouping_id'] 
. "' and workorder_id= '$workorder_id'",__LINE__,__FILE__);
!                               $this->db->next_record();
!                               $hour['grouping_descr'] = 
$this->db->f('grouping_descr');
!                               $hour['record'] = $this->db->f('record')+1;
                        }
  
!                       if($hour['new_grouping'] && !$hour['grouping_id'])
                        {
!                               $this->db->query("SELECT grouping_id FROM 
fm_wo_hours where grouping_descr ='" .$hour['new_grouping'] . "' and 
workorder_id= '$workorder_id'",__LINE__,__FILE__);
!                               $this->db->next_record();
!                               if ( $this->db->f('grouping_id'))
!                               {
!                                       $hour['grouping_id']    = 
$this->db->f('grouping_id');
!                               }
!                               else
!                               {
!                                       $this->db->query("SELECT 
max(grouping_id) as grouping_id FROM fm_wo_hours where workorder_id= 
'$workorder_id'",__LINE__,__FILE__);
!                                       $this->db->next_record();
!                                       $hour['grouping_id']    = 
$this->db->f('grouping_id')+1;
!                                       $hour['record'] = 1;
!                               }
  
!                               $hour['grouping_descr'] = $hour['new_grouping'];
                        }
  
!                       $this->db->query("insert into fm_wo_hours 
(hours_descr,unit,cost,quantity,billperae,ns3420_id,dim_d,"
!                               . " 
grouping_id,grouping_descr,record,building_part,tolerance,remark,workorder_id) "
!                               . " values ('" .
!                                       $hour['descr'] . "','" .
!                                       $hour['unit'] . "','" .
!                                       $hour['cost'] . "','" .
!                                       $hour['quantity'] . "','" .
!                                       $hour['billperae'] . "','" .
!                                       $hour['ns3420_id'] . "','" .
!                                       $hour['dim_d'] . "','" .
!                                       $hour['grouping_id'] . "','" .
!                                       $hour['grouping_descr'] . "','" .
!                                       $hour['record'] . "','" .
!                                       $hour['building_part_id'] . "','" .
!                                       $hour['tolerance_id'] . "','" .
!                                       $hour['remark'] . "','" .
!                                       $workorder_id . "')",__LINE__,__FILE__);
  
  
!                       $receipt['hour_id'] = 
$this->db->get_last_insert_id('fm_wo_hours','id');
  
!                       $receipt['message'][] = array('msg'=>lang('hour %1 is 
added!',$receipt['hour_id']));
  
!                       return $receipt;
  
                }
  
  
!               function read_single_hour($hour_id)
                {
+                       $sql = "SELECT * from fm_wo_hours where id='$hour_id'";
  
!                       $this->db->query($sql,__LINE__,__FILE__);
  
!                       if ($this->db->next_record())
                        {
!                               $hour['hour_id']                                
= $this->db->f('id');
!                               $hour['record']                                 
= $this->db->f('record');
!                               $hour['activity_id']                    = 
$this->db->f('activity_id');
!                               $hour['activity_num']                   = 
$this->db->f('activity_num');
!                               $hour['grouping_id']                    = 
$this->db->f('grouping_id');
!                               $hour['hours_descr']                    = 
$this->db->f('hours_descr');
!                               $hour['remark']                                 
= $this->db->f('remark');
!                               $hour['descr']                                  
= $this->db->f('descr');
!                               $hour['billperae']                              
= $this->db->f('billperae');
!                               $hour['unit']                                   
= $this->db->f('unit');
!                               $hour['ns3420_id']                              
= $this->db->f('ns3420_id');
!                               $hour['tolerance_id']                   = 
(int)$this->db->f('tolerance');
!                               $hour['building_part_id']               = 
(int)$this->db->f('building_part');
!                               $hour['quantity']                               
= $this->db->f('quantity');
!                               $hour['cost']                                   
= $this->db->f('cost');
!                               $hour['dim_d']                                  
= $this->db->f('dim_d');
!                       }
! 
! _debug_array($hour);
!                               return $hour;
!               }
  
  
!               function edit($hour)
!               {
! 
!                       $hour['descr'] = 
$this->db->db_addslashes($hour['descr']);
!                       $hour['remark'] = 
$this->db->db_addslashes($hour['remark']);
! //_debug_array($hour);
! 
!                       $this->db->query("UPDATE fm_wo_hours set
!                               record                          ='" . 
$hour['record'] . "',
!                               hours_descr                     ='" . 
$hour['descr'] . "',
!                               remark                          ='" . 
$hour['remark'] . "',
!                               billperae                       ='" . 
$hour['billperae'] . "',
!                               unit                            ='" . 
$hour['unit'] . "',
!                               quantity                        ='" . 
$hour['quantity'] . "',
!                               cost                            ='" . 
$hour['cost'] . "',
!                               ns3420_id                       ='" . 
$hour['ns3420_id'] . "',
!                               tolerance               ='" . 
$hour['tolerance_id'] . "',
!                               building_part   ='" . $hour['building_part_id'] 
. "',
!                               dim_d                           ='" . 
$hour['dim_d'] . "',
!                               grouping_descr          ='" . 
$hour['grouping_descr']
!                               . "' WHERE id= '" . $hour['hour_id'] 
."'",__LINE__,__FILE__);
  
  
!                       $receipt['message'][] = array('msg'=>lang('hour %1 has 
been edited',$hour['hour_id']));
                        return $receipt;
  
                }
  
!               function delete($hour_id )
                {
!                       $this->db->query("DELETE FROM fm_wo_hours WHERE id='" . 
$hour_id . "'",__LINE__,__FILE__);
! 
!                       $receipt['message'][] = array('msg'=>lang('hour %1 has 
been deleted',$hour_id));
!                       return $receipt;
  
                }

Index: class.soworkorder.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.soworkorder.inc.php,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** class.soworkorder.inc.php   21 Mar 2003 22:35:48 -0000      1.10
--- class.soworkorder.inc.php   24 Mar 2003 17:37:24 -0000      1.11
***************
*** 238,241 ****
--- 238,242 ----
                                $workorder['end_date']                  = 
$this->db->f('end_date');
                                $workorder['cat_id']                    = 
$this->db->f('category');
+                               $workorder['chapter_id']                = 
$this->db->f('chapter_id');
                        }
  

Index: class.uiwo_hour.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.uiwo_hour.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.uiwo_hour.inc.php     21 Mar 2003 22:35:48 -0000      1.1
--- class.uiwo_hour.inc.php     24 Mar 2003 17:37:24 -0000      1.2
***************
*** 86,89 ****
--- 86,90 ----
                                $content[] = array
                                (
+                                       'hour_id'                               
        => $hour['hour_id'],
                                        'activity_num'                          
=> $hour['activity_num'],
                                        'hours_descr'                           
=> $hour['hours_descr'],
***************
*** 100,109 ****
                                        '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'),
--- 101,109 ----
                                        'unit'                                  
        => $hour['unit'],
                                        'billperae'                             
        => $hour['billperae'],
!                                       'link_view'                             
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.view&workorder_id='
 . $workorder_id . '&hour_id=' . $hour['hour_id']),
!                                       'link_edit'                             
        => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.edit&workorder_id='
 . $workorder_id . '&hour_id=' . $hour['hour_id']),
!                                       'lang_view_statustext'          => 
lang('view this hour'),
!                                       'lang_edit_statustext'          => 
lang('edit/customise this hour'),
!                                       'lang_delete_statustext'        => 
lang('delete this hour'),
                                        'text_view'                             
        => lang('view'),
                                        'text_edit'                             
        => lang('edit'),
***************
*** 114,118 ****
  
                        $workorder      = 
$this->boworkorder->read_single($workorder_id);
- //_debug_array($workorder);
  
                        $table_header[] = array
--- 114,117 ----
***************
*** 132,148 ****
                        $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 )
                        );
  
--- 131,148 ----
                        $addition_percentage = $sum_hour * 
$workorder['addition_percentage']/100;
                        $sum_tax        = ($sum_hour + $addition_percentage + 
$workorder['addition_rs'])*0.24;
+                       $total_sum      = $sum_hour + $addition_percentage + 
$workorder['addition_rs'] + $sum_tax;
  
                        $table_sum[] = array
                        (
                                'lang_sum_calculation'                  => 
lang('Sum calculation'),
!                               'value_sum_calculation'                 => 
number_format($sum_hour, 2, ',', ' '),
                                'lang_addition_rs'                              
=> lang('Rig adition'),
!                               'value_addition_rs'                             
=> number_format($workorder['addition_rs'], 2, ',', ' '),
                                'lang_addition_percentage'              => 
lang('Percentage adition'),
!                               'value_addition_percentage'             => 
number_format($addition_percentage, 2, ',', ' '),
                                'lang_sum_tax'                                  
=> lang('Sum tax'),
!                               'value_sum_tax'                                 
=> number_format($sum_tax, 2, ',', ' '),
                                'lang_total_sum'                                
=> lang('Total sum'),
!                               'value_total_sum'                               
=> number_format($total_sum, 2, ',', ' ')
                        );
  
***************
*** 181,187 ****
--- 181,194 ----
  
  
+                       $delete = get_var('delete',array('POST','GET'));
+                       $hour_id = get_var('hour_id',array('POST','GET'));
                        $workorder_id = 
get_var('workorder_id',array('POST','GET'));
                        $links = $this->bocommon->menu();
  
+                       if($delete && $hour_id)
+                       {
+                               $receipt = $this->bo->delete($hour_id);
+                       }
+ 
                        $common_data=$this->common_data($workorder_id);
  
***************
*** 203,206 ****
--- 210,216 ----
                        $data = array
                        (
+                               'error'                                         
        => $receipt['error'],
+                               'message'                                       
        => $receipt['message'],
+                               'link_delete'                                   
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index&delete=true&workorder_id='
 . $workorder_id),
                                'links'                                         
        => $links,
                                'num_records'                                   
=> count($hours_list),
***************
*** 214,217 ****
--- 224,229 ----
                        );
  
+ //_debug_array($data);
+ 
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_hour' => $data));
                        $this->save_sessiondata();
***************
*** 226,236 ****
                                                                                
$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);
                        }
  
--- 238,257 ----
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'search_field'));
  
+                       $delete = get_var('delete',array('POST','GET'));
+                       $hour_id = get_var('hour_id',array('POST','GET'));
+ 
                        $workorder_id = 
get_var('workorder_id',array('POST','GET'));
                        $values = get_var('values',array('POST'));
  //_debug_array($values);
  
+                       if($delete && $hour_id)
+                       {
+                               $receipt = $this->bo->delete($hour_id);
+                       }
+ 
+ 
                        if($values['add'])
                        {
!                               
$receipt=$this->bo->add_hour($values,$workorder_id);
                        }
  
***************
*** 329,332 ****
--- 350,365 ----
                                                'order'                 
=>$this->order,
                                                'workorder_id'  =>$workorder_id,
+                                               'allrows'               
=>$this->bopricebook->allrows,
+                                               'query'                 
=>$this->query
+                       );
+ 
+                       $link_data_delete = array
+                       (
+                               'menuaction'    => 
$this->currentapp.'.uiwo_hour.prizebook',
+                                               'sort'                  
=>$this->sort,
+                                               'order'                 
=>$this->order,
+                                               'workorder_id'  =>$workorder_id,
+                                               'allrows'               
=>$this->bopricebook->allrows,
+                                               'delete'                =>true,
                                                'query'                 
=>$this->query
                        );
***************
*** 350,353 ****
--- 383,387 ----
                                'lang_add_statustext'                   => 
lang('Add the selected items'),
                                'lang_add'                                      
        => lang('Add'),
+                               'link_delete'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data_delete),
  
                                'links'                                         
        => $links,
***************
*** 383,723 ****
                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));
                }
  
--- 417,572 ----
                function edit()
                {
!                       $workorder_id                   = 
get_var('workorder_id',array('POST','GET'));
!                       $activity_id                    = 
get_var('activity_id',array('POST','GET'));
!                       $hour_id                                = 
get_var('hour_id',array('POST','GET'));
!                       $values                                 = 
get_var('values',array('POST','GET'));
!                       $values['ns3420_id']    = 
get_var('ns3420_id',array('POST','GET'));
!                       $values['ns3420_descr'] = 
get_var('ns3420_descr',array('POST','GET'));
  
  
  
+                       $common_data=$this->common_data($workorder_id);
+ 
+                       $workorder      = $common_data['workorder'];
+ //_debug_array($workorder);
  
  
!                       
$GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));
  
                        if ($values['save'])
                        {
!                               $values['hour_id'] = $hour_id;
  
                                if(!$receipt['error'])
                                {
!                                       $receipt = 
$this->bo->save_hour($values,$workorder_id);
  
+                                       $hour_id=$receipt['hour_id'];
                                }
                        }
  
!                       if ($hour_id)
                        {
!                               $values = $this->bo->read_single_hour($hour_id);
!                               $function_msg = lang('Edit hour');
                        }
                        else
                        {
!                               $function_msg = lang('Add hour');
                        }
  
! //_debug_array($values);
! 
!                       if($error_id)
                        {
!                               unset($values['hour_id']);
                        }
  
                        $link_data = array
                        (
                                'menuaction'    => 
$this->currentapp.'.uiwo_hour.edit',
!                               'activity_id'   => $activity_id,
!                               'workorder_id'  => $workorder_id,
!                               'hour_id'               => $hour_id
                        );
  
                        $data = array
                        (
!                               '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&workorder_id='
 . $workorder_id),
!                               'lang_workorder'                                
=> lang('Workorder'),
!                               'value_workorder_id'                    => 
$workorder['workorder_id'],
!                               'value_workorder_title'                 => 
$workorder['title'],
! 
!                               'lang_hour_id'                                  
=> lang('Hour ID'),
!                               'value_hour_id'                                 
=> $hour_id,
! 
!                               'lang_activity_num'                             
=> lang('Activity code'),
!                               'value_activity_num'                    => 
$values['activity_num'],
!                               'value_activity_id'                             
=> $values['activity_id'],
! 
!                               'lang_unit'                                     
        => lang('Unit'),
                                'lang_save'                                     
        => lang('save'),
                                'lang_done'                                     
        => lang('done'),
!                               'lang_descr'                                    
=> lang('description'),
!                               'value_descr'                                   
=> $values['hours_descr'],
!                               'lang_descr_statustext'                 => 
lang('Enter the description for this activity'),
                                'error'                                         
        => $receipt['error'],
                                'message'                                       
        => $receipt['message'],
                                'lang_done_statustext'                  => 
lang('Back to the list'),
!                               'lang_save_statustext'                  => 
lang('Save the building'),
  
+                               'lang_remark'                                   
=> lang('Remark'),
+                               'value_remark'                                  
=> $values['remark'],
+                               'lang_remark_statustext'                => 
lang('Enter addtional remarks to the description - if any'),
+ 
+                               'lang_quantity'                                 
=> lang('quantity'),
+                               'value_quantity'                                
=> $values['quantity'],
+                               'lang_quantity_statustext'              => 
lang('Enter quantity of unit'),
+ 
+                               'lang_billperae'                                
=> lang('Cost per unit'),
+                               'value_billperae'                               
=> $values['billperae'],
+                               'lang_billperae_statustext'             => 
lang('Enter the cost per unit'),
+ 
+                               'lang_total_cost'                               
=> lang('Total cost'),
+                               'value_total_cost'                              
=> $values['cost'],
+                               'lang_total_cost_statustext'    => lang('Enter 
the total cost of this activity - if not to be calculated from unit-cost'),
+ 
+ 
+                               'lang_vendor'                                   
=> lang('Vendor'),
+                               'value_vendor_id'                               
=> $workorder['vendor_id'],
+                               'value_vendor_name'                             
=> $workorder['vendor_name'],
+ 
+                               'lang_dim_d'                                    
=> lang('Dim D'),
+                               'dim_d_list'                                    
=> $this->bopricebook->get_dim_d_list($values['dim_d']),
+                               'select_dim_d'                                  
=> 'values[dim_d]',
+                               'lang_no_dim_d'                                 
=> lang('No Dim D'),
+                               'lang_dim_d_statustext'                 => 
lang('Select the Dim D for this activity. To do not use Dim D -  select NO DIM 
D'),
+ 
+                               'lang_unit'                                     
        => lang('Unit'),
+                               'unit_list'                                     
        => $this->bopricebook->get_unit_list($values['unit']),
+                               'select_unit'                                   
=> 'values[unit]',
+                               'lang_no_unit'                                  
=> lang('Select Unit'),
+                               'lang_unit_statustext'                  => 
lang('Select the unit for this activity.'),
+ 
+                               'lang_chapter'                                  
=> lang('chapter'),
+                               'chapter_list'                                  
=> $this->bo->get_chapter_list($workorder['chapter_id']),
+                               'select_chapter'                                
=> 'values[chapter_id]',
+                               'lang_no_chapter'                               
=> lang('Select chapter'),
+                               'lang_chapter_statustext'               => 
lang('Select the chapter (for tender) for this activity.'),
+ 
+                               'lang_tolerance'                                
=> lang('tolerance'),
+                               'tolerance_list'                                
=> $this->bo->get_tolerance_list($values['tolerance_id']),
+                               'select_tolerance'                              
=> 'values[tolerance_id]',
+                               'lang_no_tolerance'                             
=> lang('Select tolerance'),
+                               'lang_tolerance_statustext'             => 
lang('Select the tolerance for this activity.'),
+ 
+                               'lang_grouping'                                 
=> lang('grouping'),
+                               'grouping_list'                                 
=> $this->bo->get_grouping_list($values['grouping_id'],$workorder_id),
+                               'select_grouping'                               
=> 'values[grouping_id]',
+                               'lang_no_grouping'                              
=> lang('Select grouping'),
+                               'lang_grouping_statustext'              => 
lang('Select the grouping for this activity.'),
+ 
+                               'lang_new_grouping'                             
        => lang('New grouping'),
+                               'lang_new_grouping_statustext'          => 
lang('Enter a new grouping for this activity if not found in the list'),
+ 
+                               'lang_building_part'                            
=> lang('building_part'),
+                               'building_part_list'                            
=> $this->bo->get_building_part_list($values['building_part_id']),
+                               'select_building_part'                          
=> 'values[building_part_id]',
+                               'lang_no_building_part'                         
=> lang('Select building part'),
+                               'lang_building_part_statustext'         => 
lang('Select the building part for this activity.'),
+ 
+ 
+                               'ns3420_link'                                   
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uilookup.ns3420'),
+                               'lang_ns3420'                                   
=> lang('NS3420'),
+                               'value_ns3420_id'                               
=> $values['ns3420_id'],
+                               'lang_ns3420_statustext'                => 
lang('Select a standard-code from the norwegian standard'),
                                'currency'                                      
        => $GLOBALS['phpgw_info']['user']['preferences']['common']['currency']
+ 
                        );
  
!                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_hour' => $data));
                }
  





reply via email to

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