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.3,1.4 cla


From: Sigurd Nes <address@hidden>
Subject: [Phpgroupware-cvs] CVS: property/inc class.bowo_hour.inc.php,1.3,1.4 class.sowo_hour.inc.php,1.3,1.4 class.uiwo_hour.inc.php,1.3,1.4
Date: Sat, 29 Mar 2003 13:03:05 -0500

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

Modified Files:
        class.bowo_hour.inc.php class.sowo_hour.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.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** class.bowo_hour.inc.php     26 Mar 2003 12:31:56 -0000      1.3
--- class.bowo_hour.inc.php     29 Mar 2003 18:03:03 -0000      1.4
***************
*** 29,44 ****
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->so                       = 
CreateObject($this->currentapp.'.sowo_hour');
!                       $this->socommon         = 
CreateObject($this->currentapp.'.socommon');
!                       $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
!                       $this->historylog       = 
CreateObject($this->currentapp.'.historylog','workorder');
!                       $this->contacts         = 
CreateObject('phpgwapi.contacts');
! 
!                       $start  = get_var('start',array('POST','GET'));
!                       $query  = get_var('query',array('POST','GET'));
!                       $sort   = get_var('sort',array('POST','GET'));
!                       $order  = get_var('order',array('POST','GET'));
!                       $filter = get_var('filter',array('POST','GET'));
!                       $cat_id = get_var('cat_id',array('POST','GET'));
!                       $status_id      = 
get_var('status_id',array('POST','GET'));
  
                        if ($start)
--- 29,41 ----
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->so                       = 
CreateObject($this->currentapp.'.sowo_hour');
! 
!                       $start          = get_var('start',array('POST','GET'));
!                       $query          = get_var('query',array('POST','GET'));
!                       $sort           = get_var('sort',array('POST','GET'));
!                       $order          = get_var('order',array('POST','GET'));
!                       $filter         = get_var('filter',array('POST','GET'));
!                       $cat_id         = get_var('cat_id',array('POST','GET'));
!                       $chapter_id     = 
get_var('chapter_id',array('POST','GET'));
!                       $allrows        = 
get_var('allrows',array('POST','GET'));
  
                        if ($start)
***************
*** 71,84 ****
                                $this->cat_id = $cat_id;
                        }
!                       if(isset($status_id))
                        {
!                               $this->status_id = $status_id;
                        }
                }
  
  
!               function get_chapter_list($selected='')
                {
!                       
$GLOBALS['phpgw']->xslttpl->add_file(array('chapter_select'));
  
                        $chapters= $this->so->get_chapter_list();
--- 68,93 ----
                                $this->cat_id = $cat_id;
                        }
!                       if(isset($allrows))
!                       {
!                               $this->allrows = $allrows;
!                       }
!                       if(isset($chapter_id))
                        {
!                               $this->chapter_id = $chapter_id;
                        }
                }
  
  
!               function get_chapter_list($format='',$selected='')
                {
!                       switch($format)
!                       {
!                               case 'select':
!                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('chapter_select'));
!                                       break;
!                               case 'filter':
!                                       
$GLOBALS['phpgw']->xslttpl->add_file(array('chapter_filter'));
!                                       break;
!                       }
  
                        $chapters= $this->so->get_chapter_list();
***************
*** 220,223 ****
--- 229,276 ----
                }
  
+               function read_template()
+               {
+                       $template = $this->so->read_template(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
+                                                                               
        'chapter_id' => $this->chapter_id,'allrows'=>$this->allrows, 
'template_id'=>$template_id));
+                       $this->total_records = $this->so->total_records;
+ 
+                       $dateformat                                     = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ 
+                       for ($i=0; $i<count($template); $i++)
+                       {
+                               $template[$i]['owner'] = 
$GLOBALS['phpgw']->accounts->id2name($template[$i]['owner']);
+                               $template[$i]['entry_date']             = 
$GLOBALS['phpgw']->common->show_date($template[$i]['entry_date'],$dateformat);
+                       }
+ //_debug_array($template);
+ 
+ 
+                       return $template;
+               }
+ 
+               function read_template_hour($template_id)
+               {
+                       $template = $this->so->read_template_hour(array('start' 
=> $this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
+                                                                               
        'chapter_id' => $this->chapter_id,'allrows'=>$this->allrows, 
'template_id'=>$template_id));
+                       $this->total_records = $this->so->total_records;
+ 
+                       $dateformat                                     = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ 
+                       for ($i=0; $i<count($template); $i++)
+                       {
+                               $template[$i]['owner'] = 
$GLOBALS['phpgw']->accounts->id2name($template[$i]['owner']);
+                               $template[$i]['entry_date']             = 
$GLOBALS['phpgw']->common->show_date($template[$i]['entry_date'],$dateformat);
+                       }
+ //_debug_array($template);
+ 
+ 
+                       return $template;
+               }
+ 
+               function add_template($values,$workorder_id)
+               {
+                       return $this->so->add_template($values,$workorder_id);
+               }
+ 
+ 
                function add_hour($values,$workorder_id)
                {
***************
*** 260,289 ****
                }
  
!               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
--- 313,357 ----
                }
  
!               function add_hour_from_template($values,$workorder_id)
                {
  
  //_debug_array($values);
  
+                       while($entry=each($values['select']))
+                       {
+                               $n=$entry[0];
  
!                               if(!$values['quantity'][$n])
!                               {
!                                       $values['quantity'][$n]=1;
!                               }
  
!                               $values['quantity'][$n]         = 
str_replace(",",".",$values['quantity'][$n]);
!                               
$cost=($values['billperae'][$n]*$values['quantity'][$n]);
  
+                               $hour[]=array(
+                                       'chapter_id'            => 
$values['chapter_id'][$n],
+                                       'activity_id'           => 
$values['activity_id'][$n],
+                                       'activity_num'          => 
$values['activity_num'][$n],
+                                       'hours_descr'           => 
$values['hours_descr'][$n],
+                                       'remark'                        => 
$values['remark'][$n],
+                                       'unit'                          => 
$values['unit'][$n],
+                                       'cost'                          => 
$cost,
+                                       'quantity'                      => 
$values['quantity'][$n],
+                                       'new_grouping'          => 
$values['grouping_descr'][$n],
+                                       'billperae'                     => 
$values['billperae'][$n],
+                                       'ns3420_id'                     => 
$values['ns3420_id'][$n],
+                                       'tolerance'                     => 
$values['tolerance'][$n],
+                                       'building_part'         => 
$values['building_part'][$n],
+                                       'dim_d'                         => 
$values['dim_d'][$n],
+                                       'workorder_id'          => 
$workorder_id,
+                               );
+ 
+                       }
  //_debug_array($hour);
  
                        if($hour)
                        {
!                               $receipt =      
$this->so->add_hour_from_template($hour,$workorder_id);
                        }
                        else

Index: class.sowo_hour.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.sowo_hour.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** class.sowo_hour.inc.php     26 Mar 2003 12:31:56 -0000      1.3
--- class.sowo_hour.inc.php     29 Mar 2003 18:03:03 -0000      1.4
***************
*** 13,21 ****
                function sowo_hour()
                {
!                       $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
!                       $this->db                       = $GLOBALS['phpgw']->db;
!                       $this->db2                      = $this->db;
!                       $this->grants           = 
$GLOBALS['phpgw']->acl->get_grants($this->currentapp);
!                       $this->account          = 
$GLOBALS['phpgw_info']['user']['account_id'];
  
                        if 
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
--- 13,22 ----
                function sowo_hour()
                {
!                       $this->currentapp               = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
!                       $this->db                               = 
$GLOBALS['phpgw']->db;
!                       $this->db2                              = $this->db;
!                       $this->grants                   = 
$GLOBALS['phpgw']->acl->get_grants($this->currentapp);
!                       $this->account                  = 
$GLOBALS['phpgw_info']['user']['account_id'];
!                       $this->soworkorder              = 
CreateObject($this->currentapp.'.soworkorder');
  
                        if 
($GLOBALS['phpgw_info']['server']['db_type']=='pgsql')
***************
*** 125,129 ****
                                        'remark'                        => 
$this->db->f('remark'),
                                        'building_part'         => 
$this->db->f('building_part'),
!                                       'grants'                => $ngrants
                                        );
                        }
--- 126,131 ----
                                        'remark'                        => 
$this->db->f('remark'),
                                        'building_part'         => 
$this->db->f('building_part'),
!                                       'dim_d'                         => 
$this->db->f('dim_d'),
!                                       'grants'                        => 
$ngrants
                                        );
                        }
***************
*** 132,136 ****
--- 134,296 ----
                }
  
+               function read_template($data)
+               {
+ 
+                       if(is_array($data))
+                       {
+                               if ($data['start'])
+                               {
+                                       $start=$data['start'];
+                               }
+                               else
+                               {
+                                       $start=0;
+                               }
+                               $query                  = 
(isset($data['query'])?$data['query']:'');
+                               $sort                   = 
(isset($data['sort'])?$data['sort']:'DESC');
+                               $order                  = 
(isset($data['order'])?$data['order']:'');
+                               $chapter_id     = 
(isset($data['chapter_id'])?$data['chapter_id']:0);
+                               $allrows                = 
(isset($data['allrows'])?$data['allrows']:'');
+                               $template_id    = 
(isset($data['template_id'])?$data['template_id']:0);
+                       }
+ 
+                       if ($order)
+                       {
+                               $ordermethod = " order by $order $sort";
+                       }
+                       else
+                       {
+                               $ordermethod = ' order by name';
+                       }
+ 
+                       $where = 'where';
+                       if ($chapter_id > 0)
+                       {
+                               $filtermethod .= " $where 
chapter_id='$chapter_id' ";
+                               $where = 'and';
+                       }
+                       if($query)
+                       {
+                               $query = ereg_replace("'",'',$query);
+                               $query = ereg_replace('"','',$query);
+ 
+                               $querymethod = " $where (fm_wo_template.descr 
LIKE '%$query%')";
+                       }
+ 
+                       $sql = "SELECT 
fm_wo_template.id,fm_wo_template.descr,fm_wo_template.name,fm_wo_template.owner,fm_wo_template.entry_date,fm_wo_chapter.descr
 as chapter  FROM fm_wo_template $this->join fm_wo_chapter  on 
fm_wo_template.chapter_id=fm_wo_chapter.id  $filtermethod $querymethod";
+ 
+                       $this->db2->query($sql,__LINE__,__FILE__);
+                       $this->total_records = $this->db2->num_rows();
+ 
+                       if(!$allrows)
+                       {
+                               $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);
+                       }
+                       else
+                       {
+                               $this->db->query($sql . 
$ordermethod,__LINE__,__FILE__);
+                       }
+ 
+                       while ($this->db->next_record())
+                       {
+                               $ngrants = 
(int)$this->grants[$this->db->f('fm_wo_wrkorders.owner')];
+                               $template_list[] = array
+                               (
+                                       'template_id'           => 
$this->db->f('id'),
+                                       'name'                          => 
stripslashes($this->db->f('name')),
+                                       'descr'                         => 
stripslashes($this->db->f('descr')),
+                                       'owner'                         => 
$this->db->f('owner'),
+                                       'entry_date'            => 
$this->db->f('entry_date'),
+                                       'chapter'                       => 
$this->db->f('chapter'),
+                                       'grants'                        => 
$ngrants
+                                       );
+                       }
+ //_debug_array($template_list);
+                       return $template_list;
+               }
+ 
+ 
+               function read_template_hour($data)
+               {
+ 
+                       if(is_array($data))
+                       {
+                               if ($data['start'])
+                               {
+                                       $start=$data['start'];
+                               }
+                               else
+                               {
+                                       $start=0;
+                               }
+                               $query                  = 
(isset($data['query'])?$data['query']:'');
+                               $sort                   = 
(isset($data['sort'])?$data['sort']:'DESC');
+                               $order                  = 
(isset($data['order'])?$data['order']:'');
+                               $chapter_id     = 
(isset($data['chapter_id'])?$data['chapter_id']:0);
+                               $allrows                = 
(isset($data['allrows'])?$data['allrows']:'');
+                               $template_id    = 
(isset($data['template_id'])?$data['template_id']:0);
+                       }
+ 
+                       if ($order)
+                       {
+                               $ordermethod = " order by $order $sort";
+                       }
+                       else
+                       {
+                               $ordermethod = ' order by record ';
+                       }
+ 
+ 
+                       $filtermethod .= " where template_id='$template_id' ";
+ 
+                       if($query)
+                       {
+                               $query = ereg_replace("'",'',$query);
+                               $query = ereg_replace('"','',$query);
+ 
+                               $querymethod = " AND (descr LIKE '%$query%' or 
remark LIKE '%$query%' or ns3420_id LIKE '%$query%')";
+                       }
+ 
+                       $sql = "SELECT fm_wo_template_hours.*, chapter_id from 
fm_wo_template_hours  $this->join fm_wo_template on 
fm_wo_template.id=fm_wo_template_hours.template_id $filtermethod $querymethod";
+ 
+                       $this->db2->query($sql,__LINE__,__FILE__);
+                       $this->total_records = $this->db2->num_rows();
+ 
+                       if(!$allrows)
+                       {
+                               $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);
+                       }
+                       else
+                       {
+                               $this->db->query($sql . 
$ordermethod,__LINE__,__FILE__);
+                       }
  
+                       while ($this->db->next_record())
+                       {
+                               $ngrants = 
(int)$this->grants[$this->db->f('fm_wo_wrkorders.owner')];
+                               $hour_list[] = array
+                               (
+                                       'hour_id'                       => 
$this->db->f('id'),
+                                       'chapter_id'            => 
$this->db->f('chapter_id'),
+                                       'activity_num'          => 
$this->db->f('activity_num'),
+                                       'hours_descr'           => 
stripslashes($this->db->f('hours_descr')),
+                                       'remark'                        => 
stripslashes($this->db->f('remark')),
+                                       'grouping_id'           => 
$this->db->f('grouping_id'),
+                                       'grouping_descr'        => 
$this->db->f('grouping_descr'),
+                                       'ns3420_id'                     => 
$this->db->f('ns3420_id'),
+                                       'tolerance'                     => 
$this->db->f('tolerance'),
+                                       'activity_id'           => 
$this->db->f('activity_id'),
+                                       'unit'                          => 
$this->db->f('unit'),
+                                       'record'                        => 
$this->db->f('record'),
+                                       'cost'                          => 
$this->db->f('cost'),
+                                       'billperae'                     => 
$this->db->f('billperae'),
+                                       'building_part'         => 
$this->db->f('building_part'),
+                                       'dim_d'                         => 
$this->db->f('dim_d'),
+                                       'grants'                        => 
$ngrants
+                                       );
+                       }
+ //_debug_array($hour_list);
+                       return $hour_list;
+               }
  
                function next_record($workorder_id)
***************
*** 144,147 ****
--- 304,362 ----
                }
  
+               function add_template($values,$workorder_id)
+               {
+ 
+                       $values['name'] = 
$this->db->db_addslashes($values['name']);
+                       $workorder      = 
$this->soworkorder->read_single($workorder_id);
+ //_debug_array($workorder);
+ 
+                       $this->db->query("insert into fm_wo_template 
(owner,name,descr,chapter_id,entry_date) "
+                               . " values ('" .
+                                       $this->account . "','" .
+                                       $values['name'] . "','" .
+                                       $values['descr'] . "','" .
+                                       $workorder['chapter_id'] . "','" .
+                                       time() . "')",__LINE__,__FILE__);
+ 
+                       $template_id = 
$this->db->get_last_insert_id('fm_wo_template','id');
+ 
+                       $hour = $this->read(array('workorder_id' => 
$workorder_id));
+ 
+ 
+                       $record = $this->next_record($hour[0]['workorder_id']);
+ 
+                       for ($i=0; $i<count($hour); $i++)
+                       {
+ 
+                               $this->db->query("insert into 
fm_wo_template_hours (activity_id,activity_num,owner,hours_descr,unit,"
+                               . 
"cost,quantity,billperae,ns3420_id,dim_d,grouping_id,grouping_descr,remark,tolerance,building_part,record,template_id)
 "
+                               . " values ('" .
+                                       $hour[$i]['activity_id'] . "','" .
+                                       $hour[$i]['activity_num'] . "','" .
+                                       $this->account . "','" .
+                                       $hour[$i]['hours_descr'] . "','" .
+                                       $hour[$i]['unit'] . "','" .
+                                       $hour[$i]['cost'] . "','" .
+                                       $hour[$i]['quantity'] . "','" .
+                                       $hour[$i]['billperae'] . "','" .
+                                       $hour[$i]['ns3420_id'] . "','" .
+                                       $hour[$i]['dim_d'] . "','" .
+                                       $hour[$i]['grouping_id'] . "','" .
+                                       $hour[$i]['grouping_descr'] . "','" .
+                                       $hour[$i]['remark'] . "','" .
+                                       $hour[$i]['tolerance'] . "','" .
+                                       $hour[$i]['building_part'] . "','" .
+                                       $record . "','" .
+                                       $template_id. "')",__LINE__,__FILE__);
+ 
+                               $record++;
+                       }
+ 
+ 
+                       $receipt['message'][] = array('msg'=>lang('template %1 
is added!',$values['name']));
+                       return $receipt;
+               }
+ 
+ 
                function add_hour($hour)
                {
***************
*** 178,181 ****
--- 393,459 ----
  
                }
+ 
+               function add_hour_from_template($hour,$workorder_id)
+               {
+ //_debug_array($hour);
+ 
+                       $record = $this->next_record($workorder_id);
+ 
+                       $this->db->query("UPDATE fm_wo_wrkorders set
+                               chapter_id      ='" . $hour[0]['chapter_id'] . 
"' WHERE id= '$workorder_id'",__LINE__,__FILE__);
+ 
+ 
+                       for ($i=0; $i<count($hour); $i++)
+                       {
+ 
+                               if($hour[$i]['new_grouping'])
+                               {
+                                       $this->db->query("SELECT grouping_id 
FROM fm_wo_hours where grouping_descr ='" .$hour[$i]['new_grouping'] . "' and 
workorder_id= '$workorder_id'",__LINE__,__FILE__);
+                                       $this->db->next_record();
+                                       if ( $this->db->f('grouping_id'))
+                                       {
+                                               $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();
+                                               $grouping_id    = 
$this->db->f('grouping_id')+1;
+                                       }
+ 
+                                       $grouping_descr = 
$hour[$i]['new_grouping'];
+                               }
+ 
+                               $this->db->query("insert into fm_wo_hours 
(owner,activity_id,activity_num,hours_descr,unit,cost,quantity,billperae,ns3420_id,dim_d,"
+                               . " 
grouping_id,grouping_descr,record,building_part,tolerance,remark,entry_date,workorder_id)
 "
+                               . " values ('" .
+                                       $this->account . "','" .
+                                       $hour[$i]['activity_id'] . "','" .
+                                       $hour[$i]['activity_num'] . "','" .
+                                       $hour[$i]['hours_descr'] . "','" .
+                                       $hour[$i]['unit'] . "','" .
+                                       $hour[$i]['cost'] . "','" .
+                                       $hour[$i]['quantity'] . "','" .
+                                       $hour[$i]['billperae'] . "','" .
+                                       $hour[$i]['ns3420_id'] . "','" .
+                                       $hour[$i]['dim_d'] . "','" .
+                                       $grouping_id . "','" .
+                                       $grouping_descr . "','" .
+                                       $record . "','" .
+                                       $hour[$i]['building_part_id'] . "','" .
+                                       $hour[$i]['tolerance_id'] . "','" .
+                                       $hour[$i]['remark'] . "','" .
+                                       time() . "','" .
+                                       $workorder_id . "')",__LINE__,__FILE__);
+ 
+                               $record++;
+                       }
+ 
+                       $receipt['message'][] = array('msg'=>lang('the number 
of %1 hour is added!',$i));
+ 
+                       return $receipt;
+ 
+               }
+ 
                function add_custom_hour($hour,$workorder_id)
                {

Index: class.uiwo_hour.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/property/inc/class.uiwo_hour.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** class.uiwo_hour.inc.php     26 Mar 2003 12:31:56 -0000      1.3
--- class.uiwo_hour.inc.php     29 Mar 2003 18:03:03 -0000      1.4
***************
*** 24,27 ****
--- 24,29 ----
                        'index'                 => True,
                        'pdf'                   => True,
+                       'template'              => True,
+                       'list_template' => True,
                        'save_template' => True,
  
***************
*** 58,62 ****
                        $this->filter                           = 
$this->bo->filter;
                        $this->cat_id                           = 
$this->bo->cat_id;
!                       $this->status_id                        = 
$this->bo->status_id;
  
                        
$GLOBALS['phpgw']->session->appsession('sub',$this->currentapp,'workorder');
--- 60,65 ----
                        $this->filter                           = 
$this->bo->filter;
                        $this->cat_id                           = 
$this->bo->cat_id;
!                       $this->chapter_id                       = 
$this->bo->chapter_id;
!                       $this->allrows                          = 
$this->bo->allrows;
  
                        
$GLOBALS['phpgw']->session->appsession('sub',$this->currentapp,'workorder');
***************
*** 83,87 ****
                        $hour_list = $this->bo->read($workorder_id);
  
! //_debug_array($hour_list);
  
                        while (is_array($hour_list) && list(,$hour) = 
each($hour_list))
--- 86,90 ----
                        $hour_list = $this->bo->read($workorder_id);
  
! //_debug_array($workorder);
  
                        while (is_array($hour_list) && list(,$hour) = 
each($hour_list))
***************
*** 135,139 ****
                                'lang_descr'    => lang('descr'),
                                'lang_unit'             => lang('Unit'),
!                               'lang_billperea'        => lang('Bill per 
unit'),
                                'lang_quantity'         => lang('Quantity'),
                                'lang_cost'                     => lang('cost'),
--- 138,142 ----
                                'lang_descr'    => lang('descr'),
                                'lang_unit'             => lang('Unit'),
!                               'lang_billperae'        => lang('Bill per 
unit'),
                                'lang_quantity'         => lang('Quantity'),
                                'lang_cost'                     => lang('cost'),
***************
*** 188,195 ****
                }
  
- 
- 
- 
- 
                function save_template()
                {
--- 191,194 ----
***************
*** 199,204 ****
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'app_header'));
  
!                       $name = get_var('name',array('POST','GET'));
!                       $workorder_id = 
get_var('workorder_id',array('POST','GET'));
  
                        $common_data=$this->common_data($workorder_id);
--- 198,208 ----
                                                                                
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'app_header'));
  
!                       $values                 = 
get_var('values',array('POST'));
!                       $workorder_id   = 
get_var('workorder_id',array('POST','GET'));
! 
!                       if($values['name'])
!                       {
!                               $receipt        = 
$this->bo->add_template($values,$workorder_id);
!                       }
  
                        $common_data=$this->common_data($workorder_id);
***************
*** 212,219 ****
                        $data = array
                        (
                                'appname'                                       
        => lang('Workorder'),
                                'function_msg'                                  
=> lang('Add template'),
                                'done_action'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
!                               'add_action'                                    
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.save_template'),
  
                                'lang_done_statustext'                  => 
lang('Back to the workorder list'),
--- 216,225 ----
                        $data = array
                        (
+                               'error'                                         
        => $receipt['error'],
+                               'message'                                       
        => $receipt['message'],
                                'appname'                                       
        => lang('Workorder'),
                                'function_msg'                                  
=> lang('Add template'),
                                'done_action'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
!                               'add_action'                                    
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.save_template&workorder_id='
 . $workorder_id),
  
                                'lang_done_statustext'                  => 
lang('Back to the workorder list'),
***************
*** 228,231 ****
--- 234,242 ----
                                'lang_name_statustext'          => lang('Enter 
the name the template'),
  
+                               'lang_descr'                                    
=> lang('Description'),
+                               'lang_descr_statustext'         => lang('Enter 
a short description of this template'),
+ 
+                               'table_header_hour'                             
=> $common_data['table_header'],
+                               'values_hour'                                   
=> $common_data['content'],
                                'workorder_data'                                
=> $common_data['workorder_data']
                        );
***************
*** 263,267 ****
                                'lang_add_template'                             
        => lang('Add from template'),
                                'lang_add_template_statustext'          => 
lang('add items from a predefined template'),
!                               'add_template_action'                           
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.template&workorder_id='
 . $workorder_id),
  
                                'lang_add_custom'                               
        => lang('Add custom'),
--- 274,278 ----
                                'lang_add_template'                             
        => lang('Add from template'),
                                'lang_add_template_statustext'          => 
lang('add items from a predefined template'),
!                               'add_template_action'                           
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.list_template&workorder_id='
 . $workorder_id),
  
                                'lang_add_custom'                               
        => lang('Add custom'),
***************
*** 476,479 ****
--- 487,865 ----
                }
  
+ 
+               function template()
+               {
+                       $GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour',
+                                                                               
'menu',
+                                                                               
'nextmatchs',
+                                                                               
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'app_header',
+                                                                               
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'search_field'));
+ 
+                       $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'));
+                       $template_id = 
get_var('template_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_from_template($values,$workorder_id);
+                       }
+ 
+                       $links = $this->bocommon->menu();
+ 
+                       $common_data=$this->common_data($workorder_id);
+ 
+                       $workorder      = $common_data['workorder'];
+ 
+                       $template_list  = 
$this->bo->read_template_hour($template_id);
+ 
+                       $i=0;
+                       while (is_array($template_list) && list(,$template) = 
each($template_list))
+                       {
+ 
+                               if($template['activity_num'])
+                               {
+                                       $code   = $template['activity_num'];
+                               }
+                               else
+                               {
+                                       $code   = 
str_replace("-",$template['tolerance'],$template['ns3420_id']);
+                               }
+ 
+ 
+                               $content_template_hour[] = array
+                               (
+                                       'counter'                               
=> $i,
+                                       'chapter_id'                    => 
$template['chapter_id'],
+                                       'grouping_descr'                => 
$template['grouping_descr'],
+                                       'building_part'                 => 
$template['building_part'],
+                                       'code'                                  
=> $code,
+                                       'activity_id'                   => 
$template['activity_id'],
+                                       'activity_num'                  => 
$template['activity_num'],
+                                       'hours_descr'                   => 
$template['hours_descr'],
+                                       'remark'                                
=> $template['remark'],
+                                       'ns3420_id'                             
=> $template['ns3420_id'],
+                                       'tolerance'                             
=> $template['tolerance'],
+                                       'cost'                                  
=> $template['cost'],
+                                       'unit'                                  
=> $template['unit'],
+                                       'billperae'                             
=> $template['billperae'],
+                                       'building_part'                 => 
$template['building_part'],
+                                       'dim_d'                                 
=> $template['dim_d']
+                               );
+ 
+                               $i++;
+                       }
+ 
+                       $table_header_template_hour[] = array
+                       (
+                               'lang_code'                     => lang('Code'),
+                               'lang_descr'            => lang('Description'),
+                               'lang_unit'                     => lang('Unit'),
+                               'lang_quantity'         => lang('Quantity'),
+                               'lang_billperae'        => lang('Bill per 
unit'),
+                               'lang_cost'     => lang('Cost'),
+ 
+                               'sort_billperae'        => 
$this->nextmatchs->show_sort_order(array
+                                                                               
(
+                                                                               
        'sort'  => $this->sort,
+                                                                               
        'var'   =>      'billperae',
+                                                                               
        'order' =>      $this->order,
+                                                                               
        'extra'         => array('menuaction'   => 
$this->currentapp.'.uiwo_hour.template',
+                                                                               
                                                        'workorder_id'  
=>$workorder_id,
+                                                                               
                                                        'template_id'   
=>$template_id,
+                                                                               
                                                        'query'                 
=>$this->query,
+                                                                               
                                                        'allrows'               
=>$this->allrows)
+                                                                               
)),
+                               'lang_select'           => lang('Select'),
+                               'sort_building_part'    => 
$this->nextmatchs->show_sort_order(array
+                                                                               
(
+                                                                               
        'sort'  => $this->sort,
+                                                                               
        'var'   =>      'building_part',
+                                                                               
        'order' =>      $this->order,
+                                                                               
        'extra'         => array('menuaction'   => 
$this->currentapp.'.uiwo_hour.template',
+                                                                               
                                                        'workorder_id'  
=>$workorder_id,
+                                                                               
                                                        'template_id'   
=>$template_id,
+                                                                               
                                                        'query'                 
=>$this->query,
+                                                                               
                                                        'allrows'               
=>$this->allrows)
+                                                                               
)),
+                               'lang_building_part'            => 
lang('Building part')
+                       );
+ 
+ 
+                       $table_done[] = array
+                       (
+                               'lang_done'                             => 
lang('Done'),
+                               'lang_done_statustext'  => lang('Back to list'),
+                               'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index&workorder_id='
 . $workorder_id)
+                       );
+ 
+                       $link_data = array
+                       (
+                               'menuaction'    => 
$this->currentapp.'.uiwo_hour.template',
+                                               'sort'                  
=>$this->sort,
+                                               'order'                 
=>$this->order,
+                                               'workorder_id'  =>$workorder_id,
+                                               'template_id'   =>$template_id,
+                                               'allrows'               
=>$this->bo->allrows,
+                                               'query'                 
=>$this->query
+                       );
+ 
+                       $link_data_delete = array
+                       (
+                               'menuaction'    => 
$this->currentapp.'.uiwo_hour.template',
+                                               'sort'                  
=>$this->sort,
+                                               'order'                 
=>$this->order,
+                                               'workorder_id'  =>$workorder_id,
+                                               'allrows'               
=>$this->bo->allrows,
+                                               'delete'                =>true,
+                                               'query'                 
=>$this->query
+                       );
+ 
+ 
+                       if(!$this->bo->allrows)
+                       {
+                               $record_limit   = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+                       }
+                       else
+                       {
+                               $record_limit   = $this->bo->total_records;
+                       }
+ 
+ 
+                       $data = array
+                       (
+                               'lang_select_all'                               
=> lang('Select All'),
+                               'img_check'                                     
        => 
$GLOBALS['phpgw']->common->get_image_path($this->currentapp).'/check.gif',
+                               'check_source'                                  
=> './'.$this->currentapp.'/inc/check.js',
+ 
+                               'error'                                         
        => $receipt['error'],
+                               'message'                                       
        => $receipt['message'],
+                               'form_action'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'lang_add_statustext'                   => 
lang('Add the selected items'),
+                               'lang_add'                                      
        => lang('Add'),
+                               'link_delete'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data_delete),
+ 
+                               'function'                                      
        => 'template',
+                               'links'                                         
        => $links,
+                               'allrows'                                       
        => $this->bo->allrows,
+                               'allow_allrows'                                 
=> true,
+                               'start_record'                                  
=> $this->start,
+                               'record_limit'                                  
=> $record_limit,
+                               'num_records'                                   
=> count($template_list),
+                               'all_records'                                   
=> $this->bo->total_records,
+                               'link_url'                                      
        => $GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'img_path'                                      
        => $GLOBALS['phpgw']->common->get_image_path('phpgwapi'),
+                               'appname'                                       
        => lang($this->currentapp),
+                               'function_msg'                                  
=> lang('list template'),
+                               'select_action'                                 
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 
+                               'lang_searchfield_statustext'   => lang('Enter 
the search string. To show all entries, empty this field and press the SUBMIT 
button again'),
+                               'lang_searchbutton_statustext'  => lang('Submit 
the search string'),
+                               'query'                                         
        => $this->query,
+                               'lang_submit'                                   
=> lang('submit'),
+                               'workorder_data'                                
=> $common_data['workorder_data'],
+                               'table_header_template_hour'            => 
$table_header_template_hour,
+                               'values_template_hour'                          
=> $content_template_hour,
+                               'table_header_hour'                             
=> $common_data['table_header'],
+                               'values_hour'                                   
=> $common_data['content'],
+                               'table_sum'                                     
        => $common_data['table_sum'],
+                               'table_done'                                    
=> $table_done
+                       );
+ 
+                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('template' => $data));
+                       $this->save_sessiondata();
+               }
+ 
+               function list_template()
+               {
+ 
+ //echo 'allrows: ' . $this->allrows;
+ //echo 'chapter_id: ' . $this->chapter_id;
+ 
+                       $GLOBALS['phpgw']->xslttpl->add_file(array('wo_hour',
+                                                                               
'menu',
+                                                                               
'nextmatchs',
+                                                                               
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'app_header',
+                                                                               
$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default') . SEP . 
'search_field'));
+ 
+                       $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);
+                       }
+ 
+                       $links = $this->bocommon->menu();
+ 
+                       $common_data=$this->common_data($workorder_id);
+ 
+                       $workorder      = $common_data['workorder'];
+ 
+                       $template_list  = $this->bo->read_template();
+ 
+ //_debug_array($template_list);
+                       while (is_array($template_list) && list(,$template) = 
each($template_list))
+                       {
+                               $content_template[] = array
+                               (
+                                       'workorder_id'                  => 
$workorder_id,
+                                       'template_id'                   => 
$template['template_id'],
+                                       'name'                                  
=> $template['name'],
+                                       'descr'                                 
=> $template['descr'],
+                                       'owner'                                 
=> $template['owner'],
+                                       'entry_date'                    => 
$template['entry_date'],
+                                       'chapter'                               
=> $template['chapter'],
+                                       'lang_select'                   => 
lang('Select'),
+                                       'form_action_select'    => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.template'),
+                                       'lang_select_statustext' => 
lang('Select this template to view the details')
+                               );
+ 
+                               $i++;
+                       }
+ 
+                       $table_header_template[] = array
+                       (
+ 
+                               'sort_template_id'      => 
$this->nextmatchs->show_sort_order(array
+                                                                               
(
+                                                                               
        'sort'  => $this->sort,
+                                                                               
        'var'   =>      'fm_wo_template.id',
+                                                                               
        'order' =>      $this->order,
+                                                                               
        'extra'         => array('menuaction'           => 
$this->currentapp.'.uiwo_hour.list_template',
+                                                                               
                                                        'chapter_id'    
=>$this->chapter_id,
+                                                                               
                                                        'query'                 
=>$this->query,
+                                                                               
                                                        'workorder_id'  
=>$workorder_id,
+                                                                               
                                                        'allrows'               
=>$this->allrows)
+                                                                               
)),
+                               'lang_template_id'                      => 
lang('ID'),
+                               'lang_name'                     => lang('Name'),
+                               'sort_name'     => 
$this->nextmatchs->show_sort_order(array
+                                                                               
(
+                                                                               
        'sort'  => $this->sort,
+                                                                               
        'var'   =>      'name',
+                                                                               
        'order' =>      $this->order,
+                                                                               
        'extra'         => array('menuaction'           => 
$this->currentapp.'.uiwo_hour.list_template',
+                                                                               
                                                        'chapter_id'    
=>$this->chapter_id,
+                                                                               
                                                        'query'                 
=>$this->query,
+                                                                               
                                                        'workorder_id'  
=>$workorder_id,
+                                                                               
                                                        'allrows'               
=>$this->allrows)
+                                                                               
)),
+                               'lang_name'                     => lang('Name'),
+                               'lang_chapter'          => lang('Chapter'),
+                               'lang_owner'            => lang('owner'),
+                               'lang_entry_date'       => lang('Entry Date'),
+                               'lang_descr'            => lang('Description'),
+                               'lang_view'                     => lang('view'),
+                               'lang_select'           => lang('Select'),
+                               'lang_edit'                     => lang('edit')
+                       );
+ 
+ 
+                       $table_done[] = array
+                       (
+                               'lang_done'                             => 
lang('Done'),
+                               'lang_done_statustext'  => lang('Back to list'),
+                               'done_action'                   => 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiwo_hour.index&workorder_id='
 . $workorder_id)
+                       );
+ 
+                       $link_data = array
+                       (
+                               'menuaction'    => 
$this->currentapp.'.uiwo_hour.list_template',
+                                               'sort'                  
=>$this->sort,
+                                               'order'                 
=>$this->order,
+                                               'chapter_id'            
=>$this->chapter_id,
+                                               'workorder_id'  =>$workorder_id,
+                                               'allrows'               
=>$this->allrows,
+                                               'query'                 
=>$this->query
+                       );
+ 
+                       $link_data_delete = array
+                       (
+                               'menuaction'    => 
$this->currentapp.'.uiwo_hour.list_template',
+                                               'sort'                  
=>$this->sort,
+                                               'order'                 
=>$this->order,
+                                               'workorder_id'  =>$workorder_id,
+                                               'allrows'               
=>$this->allrows,
+                                               'delete'                =>true,
+                                               'query'                 
=>$this->query
+                       );
+ 
+ 
+                       if(!$this->allrows)
+                       {
+                               $record_limit   = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+                       }
+                       else
+                       {
+                               $record_limit   = $this->bo->total_records;
+                       }
+ 
+ 
+                       $data = array
+                       (
+                               'error'                                         
        => $receipt['error'],
+                               'message'                                       
        => $receipt['message'],
+                               'form_action'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'lang_add_statustext'                   => 
lang('Add the selected items'),
+                               'lang_add'                                      
        => lang('Add'),
+                               'link_delete'                                   
=> $GLOBALS['phpgw']->link('/index.php',$link_data_delete),
+ 
+                               'chapter_list'                                  
=> $this->bo->get_chapter_list('filter',$this->chapter_id),
+                               'select_chapter'                                
=> 'chapter_id',
+                               'lang_no_chapter'                               
=> lang('Select chapter'),
+                               'lang_chapter_statustext'               => 
lang('Select the template-chapter'),
+ 
+                               'function'                                      
        => 'template',
+                               'links'                                         
        => $links,
+                               'allrows'                                       
        => $this->allrows,
+                               'allow_allrows'                                 
=> true,
+                               'start_record'                                  
=> $this->start,
+                               'record_limit'                                  
=> $record_limit,
+                               'num_records'                                   
=> count($template_list),
+                               'all_records'                                   
=> $this->bo->total_records,
+                               'link_url'                                      
        => $GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'img_path'                                      
        => $GLOBALS['phpgw']->common->get_image_path('phpgwapi'),
+                               'appname'                                       
        => lang($this->currentapp),
+                               'function_msg'                                  
=> lang('list template'),
+                               'select_action'                                 
=> $GLOBALS['phpgw']->link('/index.php',$link_data),
+ 
+                               'lang_searchfield_statustext'   => lang('Enter 
the search string. To show all entries, empty this field and press the SUBMIT 
button again'),
+                               'lang_searchbutton_statustext'  => lang('Submit 
the search string'),
+                               'query'                                         
        => $this->query,
+                               'lang_submit'                                   
=> lang('submit'),
+                               'workorder_data'                                
=> $common_data['workorder_data'],
+                               'table_header_template'                 => 
$table_header_template,
+                               'values_template'                               
=> $content_template,
+                               'table_header_hour'                             
=> $common_data['table_header'],
+                               'values_hour'                                   
=> $common_data['content'],
+                               'table_sum'                                     
        => $common_data['table_sum'],
+                               'table_done'                                    
=> $table_done
+                       );
+ //_debug_array($data);
+ 
+                       
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('list_template' => $data));
+                       $this->save_sessiondata();
+               }
+ 
                function edit()
                {
***************
*** 602,606 ****
  
                                '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'),
--- 988,992 ----
  
                                'lang_chapter'                                  
=> lang('chapter'),
!                               'chapter_list'                                  
=> $this->bo->get_chapter_list('select',$workorder['chapter_id']),
                                'select_chapter'                                
=> 'values[chapter_id]',
                                'lang_no_chapter'                               
=> lang('Select chapter'),





reply via email to

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