phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] property/class.boproject.php, 1.1.1.3


From: nomail
Subject: [Phpgroupware-cvs] property/class.boproject.php, 1.1.1.3
Date: Fri, 21 May 2004 15:43:50 -0000

Update of /property
Modified Files:
        Branch: 
          class.boproject.php

date: 2004/04/23 21:26:33;  author: sigurdne;  state: Exp;  lines: +552 -552

Log Message:
no message
=====================================================================
Index: property/class.boproject.php
diff -u property/class.boproject.php:1.1.1.2 
property/class.boproject.php:1.1.1.3
--- property/class.boproject.php:1.1.1.2        Fri Apr 23 20:25:24 2004
+++ property/class.boproject.php        Fri Apr 23 21:26:33 2004
@@ -1,552 +1,552 @@
-<?php
-       
/**************************************************************************\
-       * phpGroupWare - property                                               
   *
-       * http://www.phpgroupware.org                                           
   *
-       *                                                                       
   *
-       * Facilities Management                                                 
   *
-       * Written by Sigurd Nes [sigurdne at online.no]                         
   *
-       * 
------------------------------------------------------------------------ *
-       * Copyright 2000 - 2003 Free Software Foundation, Inc                   
   *
-       * This program is part of the GNU project, see http://www.gnu.org/      
   *
-       * 
------------------------------------------------------------------------ *
-       * This program is free software; you can redistribute it and/or modify 
it  *
-       * under the terms of the GNU General Public License as published by the 
   *
-       * Free Software Foundation; either version 2 of the License, or (at 
your   *
-       * option) any later version.                                            
   *
-       
\**************************************************************************/
-
-       class property_boproject
-       {
-               var $start;
-               var $query;
-               var $filter;
-               var $sort;
-               var $order;
-               var $cat_id;
-
-               var $public_functions = array
-               (
-                       'read'                          => True,
-                       'read_single'           => True,
-                       'save'                          => True,
-                       'delete'                        => True,
-                       'check_perms'           => True
-               );
-
-               function property_boproject($session=False)
-               {
-                       $this->currentapp       = 'property'; 
//$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $this->so                       = 
CreateObject($this->currentapp.'_soproject');
-                       $this->bocommon         = 
CreateObject($this->currentapp.'_bocommon');
-                       $this->solocation = 
CreateObject($this->currentapp.'_solocation');
-                       $this->fm_session       = 
CreateObject($this->currentapp.'_session');
-
-                       if ($session)
-                       {
-                               $this->read_sessiondata();
-                               $this->use_session = True;
-                       }
-
-                       $start  = get_var('start',array('POST','GET'));
-                       $query  = get_var('query',array('POST','GET'));
-                       $sort   = get_var('sort',array('POST','GET'));
-                       $order  = get_var('order',array('POST','GET'));
-                       $filter = get_var('filter',array('POST','GET'));
-                       $cat_id = get_var('cat_id',array('POST','GET'));
-                       $status_id      = 
get_var('status_id',array('POST','GET'));
-
-                       if ($start)
-                       {
-                               $this->start=$start;
-                       }
-                       else
-                       {
-                               $this->start=0;
-                       }
-
-                       if(isset($query))
-                       {
-                               $this->query = $query;
-                       }
-                       if(isset($filter))
-                       {
-                               $this->filter = $filter;
-                       }
-                       if(isset($sort))
-                       {
-                               $this->sort = $sort;
-                       }
-                       if(isset($order))
-                       {
-                               $this->order = $order;
-                       }
-                       if(isset($cat_id))
-                       {
-                               $this->cat_id = $cat_id;
-                       }
-                       if(isset($status_id))
-                       {
-                               $this->status_id = $status_id;
-                       }
-               }
-
-               function save_sessiondata($data)
-               {
-                       if ($this->use_session)
-                       {
-                               
$this->fm_session->appsession('session_data','project',$data);
-                       }
-               }
-
-               function read_sessiondata()
-               {
-                       $data = 
$this->fm_session->appsession('session_data','project');
-
-                       $this->start    = $data['start'];
-                       $this->query    = $data['query'];
-                       $this->filter   = $data['filter'];
-                       $this->sort             = $data['sort'];
-                       $this->order    = $data['order'];
-                       $this->cat_id   = $data['cat_id'];
-                       $this->status_id        = $data['status_id'];
-               }
-
-               function select_status_list($format='',$selected='')
-               {
-                       switch($format)
-                       {
-                               case 'select':
-                                       
$this->bocommon->xsl_add_file(array('status_select'));
-                                       break;
-                               case 'filter':
-                                       
$this->bocommon->xsl_add_file(array('status_filter'));
-                                       break;
-                       }
-
-                       $status_entries= $this->so->select_status_list();
-
-                       while (is_array($status_entries) && list(,$status) = 
each($status_entries))
-                       {
-                               $sel_status = '';
-                               if ($status['id']==$selected)
-                               {
-                                       $sel_status = 'selected';
-                               }
-
-                               $status_list[] = array
-                               (
-                                       'id'            => $status['id'],
-                                       'name'          => $status['name'],
-                                       'selected'      => $sel_status
-                               );
-                       }
-
-                       for ($i=0;$i<count($status_list);$i++)
-                       {
-                               if ($status_list[$i]['selected'] != 'selected')
-                               {
-                                       unset($status_list[$i]['selected']);
-                               }
-                       }
-
-                       return $status_list;
-               }
-
-               function select_branch_list($selected='')
-               {
-
-                       $branch_entries= $this->so->select_branch_list();
-
-                       while (is_array($branch_entries) && list(,$branch) = 
each($branch_entries))
-                       {
-                               $sel_branch = '';
-                               if ($branch['id']==$selected)
-                               {
-                                       $sel_branch = 'selected';
-                               }
-
-                               $branch_list[] = array
-                               (
-                                       'id'            => $branch['id'],
-                                       'name'          => $branch['name'],
-                                       'selected'      => $sel_branch
-                               );
-                       }
-
-                       for ($i=0;$i<count($branch_list);$i++)
-                       {
-                               if ($branch_list[$i]['selected'] != 'selected')
-                               {
-                                       unset($branch_list[$i]['selected']);
-                               }
-                       }
-
-                       return $branch_list;
-               }
-
-               function select_branch_p_list($project_id='')
-               {
-
-                       $selected               = 
$this->so->branch_p_list($project_id);
-                       $branch_entries = $this->so->select_branch_list();
-
-                       $j=0;
-                       while (is_array($branch_entries) && list(,$branch) = 
each($branch_entries))
-                       {
-                               $branch_list[$j]['id'] = $branch['id'];
-                               $branch_list[$j]['name'] = $branch['name'];
-
-                               for ($i=0;$i<count($selected);$i++)
-                               {
-                                       if($selected[$i]['branch_id'] == 
$branch['id'])
-                                       {
-                                               $branch_list[$j]['selected'] = 
'selected';
-                                       }
-                               }
-                               $j++;
-                       }
-
-                       for ($i=0;$i<count($branch_list);$i++)
-                       {
-                               if ($branch_list[$i]['selected'] != 'selected')
-                               {
-                                       unset($branch_list[$i]['selected']);
-                               }
-                       }
-
-                       return $branch_list;
-               }
-
-
-               function select_key_location_list($selected='')
-               {
-
-                       $key_location_entries= 
$this->so->select_key_location_list();
-
-                       while (is_array($key_location_entries) && 
list(,$key_location) = each($key_location_entries))
-                       {
-                               $sel_key_location = '';
-                               if ($key_location['id']==$selected)
-                               {
-                                       $sel_key_location = 'selected';
-                               }
-
-                               $key_location_list[] = array
-                               (
-                                       'id'            => $key_location['id'],
-                                       'name'          => 
$key_location['name'],
-                                       'selected'      => $sel_key_location
-                               );
-                       }
-
-                       for ($i=0;$i<count($key_location_list);$i++)
-                       {
-                               if ($key_location_list[$i]['selected'] != 
'selected')
-                               {
-                                       
unset($key_location_list[$i]['selected']);
-                               }
-                       }
-
-                       return $key_location_list;
-               }
-
-               function select_category_project_list($format='',$selected='')
-               {
-                       switch($format)
-                       {
-                               case 'select':
-                                       
$this->bocommon->xsl_add_file(array('cat_select'));
-                                       break;
-                               case 'filter':
-                                       
$this->bocommon->xsl_add_file(array('cat_filter'));
-                                       break;
-                       }
-
-                       $categories= 
$this->so->select_category_workorder_list();
-
-                       while (is_array($categories) && list(,$category) = 
each($categories))
-                       {
-                               $sel_category = '';
-                               if ($category['id']==$selected)
-                               {
-                                       $sel_category = 'selected';
-                               }
-
-                               $category_list[] = array
-                               (
-                                       'cat_id'        => $category['id'],
-                                       'name'          => $category['name'],
-                                       'selected'      => $sel_category
-                               );
-                       }
-
-                       for ($i=0;$i<count($category_list);$i++)
-                       {
-                               if ($category_list[$i]['selected'] != 
'selected')
-                               {
-                                       unset($category_list[$i]['selected']);
-                               }
-                       }
-
-                       return $category_list;
-               }
-
-
-               function read($start_date='',$end_date='',$allrows='')
-               {
-                       $start_date     = 
$this->bocommon->date_to_timestamp($start_date);
-                       $end_date       = 
$this->bocommon->date_to_timestamp($end_date);
-
-                       $project = $this->so->read(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
-                                                                               
        'filter' => $this->filter,'cat_id' => $this->cat_id,'status_id' => 
$this->status_id,
-                                                                               
        'start_date'=>$start_date,'end_date'=>$end_date,'allrows'=>$allrows));
-                       $this->total_records = $this->so->total_records;
-
-                       $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-
-                       $this->uicols   = $this->so->uicols;
-                       $this->uicols['input_type'][]   = 'link';
-                       $this->uicols['name'][]                 = 'ticket_id';
-                       $this->uicols['descr'][]                = 
lang('ticket');
-                       $this->uicols['statustext'][]   = false;
-
-//                     $cols_extra             = $this->so->cols_extra;
-
-                       for ($i=0; $i<count($project); $i++)
-                       {
-                               $project[$i]['start_date'] = 
$GLOBALS['phpgw']->common->show_date($project[$i]['start_date'],$dateformat);
-                               $project[$i]['ticket_id'] = 
$this->so->get_ticket($project[$i]['project_id']);
-
-/*                             
$location_data=$this->solocation->read_single($project[$i]['location_code']);
-
-                               for ($j=0;$j<count($cols_extra);$j++)
-                               {
-                                       $project[$i][$cols_extra[$j]] = 
$location_data[$cols_extra[$j]];
-                               }
-*/
-                       }
-
-//html_print_r($project);
-
-                       return $project;
-               }
-
-               function read_single($project_id)
-               {
-                       $contacts               = 
CreateObject('phpgwapi_contacts');
-                       $config                         = 
CreateObject('phpgwapi_config');
-                       $config->read_repository();
-                       $tax = 1+($config->config_data['fm_tax'])/100;
-
-                       $project                                                
= $this->so->read_single($project_id);
-                       $dateformat                                             
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-                       $project['start_date']                  = 
$GLOBALS['phpgw']->common->show_date($project['start_date'],$dateformat);
-                       $project['end_date']                    = 
$GLOBALS['phpgw']->common->show_date($project['end_date'],$dateformat);
-                       $workorder_data                         = 
$this->so->project_workorder_data($project_id);
-
-                       for ($i=0;$i<count($workorder_data);$i++)
-                       {
-                               $sum_workorder_budget= 
$sum_workorder_budget+$workorder_data[$i]['budget'];
-                               $sum_deviation= 
$sum_deviation+$workorder_data[$i]['deviation'];
-                               $sum_workorder_calculation= 
$sum_workorder_calculation+$workorder_data[$i]['calculation'];
-                               
$project['workorder_budget'][$i]['workorder_id']=$workorder_data[$i]['workorder_id'];
-                               
$project['workorder_budget'][$i]['budget']=number_format($workorder_data[$i]['budget'],
 2, ',', '');
-                               
$project['workorder_budget'][$i]['calculation']=number_format($workorder_data[$i]['calculation']*$tax,
 2, ',', '');
-                               $vendor = 
$contacts->read_single_entry((int)$workorder_data[$i]['vendor_id'],array('org_name'=>'org_name'));
-                               $project['workorder_budget'][$i]['vendor_name'] 
= $vendor[0]['org_name'];
-                       }
-                       if($workorder_data)
-                       {
-                               $project['sum_workorder_budget']= 
number_format($sum_workorder_budget, 2, ',', '');
-                               $project['deviation']= $sum_deviation;
-                               $project['sum_workorder_calculation']= 
number_format($sum_workorder_calculation*$tax, 2, ',', '');
-                       }
-
-                       if($project['location_code'])
-                       {
-                               $project['location_data'] 
=$this->solocation->read_single($project['location_code']);
-                       }
-
-                       if($project['tenant_id']>0)
-                       {
-                               
$tenant_data=$this->bocommon->read_single_tenant($project['tenant_id']);
-                               $project['location_data']['tenant_id']= 
$project['tenant_id'];
-                               $project['location_data']['contact_phone']= 
$tenant_data['contact_phone'];
-                               $project['location_data']['last_name']  = 
$tenant_data['last_name'];
-                               $project['location_data']['first_name'] = 
$tenant_data['first_name'];
-                       }
-                       else
-                       {
-                               unset($project['location_data']['tenant_id']);
-                               
unset($project['location_data']['contact_phone']);
-                               unset($project['location_data']['last_name']);
-                               unset($project['location_data']['first_name']);
-                       }
-
-                       if($project['p_num'])
-                       {
-                               $soadmin_entity = 
CreateObject($this->currentapp.'_soadmin_entity');
-                               $category = 
$soadmin_entity->read_single_category($project['p_entity_id'],$project['p_cat_id']);
-
-                               
$project['p'][$project['p_entity_id']]['p_num']=$project['p_num'];
-                               
$project['p'][$project['p_entity_id']]['p_entity_id']=$project['p_entity_id'];
-                               
$project['p'][$project['p_entity_id']]['p_cat_id']=$project['p_cat_id'];
-                               
$project['p'][$project['p_entity_id']]['p_cat_name'] = $category['name'];
-                       }
-
-
-//html_print_r($project);
-                       return $project;
-               }
-
-               function read_single_mini($project_id)
-               {
-                       $project                                                
= $this->so->read_single($project_id);
-                       $dateformat                                             
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-                       $project['start_date']                  = 
$GLOBALS['phpgw']->common->show_date($project['start_date'],$dateformat);
-                       $project['end_date']                    = 
$GLOBALS['phpgw']->common->show_date($project['end_date'],$dateformat);
-
-                       if($project['location_code'])
-                       {
-                               $project['location_data'] 
=$this->solocation->read_single($project['location_code']);
-                       }
-
-                       if($project['tenant_id']>0)
-                       {
-                               
$tenant_data=$this->bocommon->read_single_tenant($project['tenant_id']);
-                               $project['location_data']['tenant_id']= 
$project['tenant_id'];
-                               $project['location_data']['contact_phone']= 
$tenant_data['contact_phone'];
-                               $project['location_data']['last_name']  = 
$tenant_data['last_name'];
-                               $project['location_data']['first_name'] = 
$tenant_data['first_name'];
-                       }
-                       else
-                       {
-                               unset($project['location_data']['tenant_id']);
-                               
unset($project['location_data']['contact_phone']);
-                               unset($project['location_data']['last_name']);
-                               unset($project['location_data']['first_name']);
-                       }
-
-//html_print_r($project);
-                       return $project;
-               }
-
-
-               function read_record_history($id)
-               {
-                       $historylog     = 
CreateObject($this->currentapp.'_historylog','project');
-                       $history_array = 
$historylog->return_array(array('O'),array(),'','',$id);
-                       $i=0;
-                       while (is_array($history_array) && list(,$value) = 
each($history_array))
-                       {
-
-                               $record_history[$i]['value_date']       = 
$GLOBALS['phpgw']->common->show_date($value['datetime']);
-                               $record_history[$i]['value_user']       = 
$value['owner'];
-
-                               switch ($value['status'])
-                               {
-                                       case 'R': $type = lang('Re-opened'); 
break;
-                                       case 'X': $type = lang('Closed');    
break;
-                                       case 'O': $type = lang('Opened');    
break;
-                                       case 'A': $type = lang('Re-assigned'); 
break;
-                                       case 'P': $type = lang('Priority 
changed'); break;
-                                       case 'CO': $type = lang('Initial 
Coordinator'); break;
-                                       case 'C': $type = lang('Coordinator 
changed'); break;
-                                       case 'TO': $type = lang('Initial 
Category'); break;
-                                       case 'T': $type = lang('Category 
changed'); break;
-                                       case 'SO': $type = lang('Initial 
Status'); break;
-                                       case 'S': $type = lang('Status 
changed'); break;
-                                       default: break;
-                               }
-
-                               
if($value['new_value']=='O'){$value['new_value']=lang('Opened');}
-                               
if($value['new_value']=='X'){$value['new_value']=lang('Closed');}
-
-
-                               $record_history[$i]['value_action']     = 
$type?$type:'';
-                               unset($type);
-
-                               if ($value['status'] == 'A')
-                               {
-                                       if (! $value['new_value'])
-                                       {
-                                               
$record_history[$i]['value_new_value']  = lang('None');
-                                       }
-                                       else
-                                       {
-                                               
$record_history[$i]['value_new_value']  = 
$GLOBALS['phpgw']->accounts->id2name($value['new_value']);
-                                       }
-                               }
-                               else if ($value['status'] == 'C' || 
$value['status'] == 'CO')
-                               {
-                                       $record_history[$i]['value_new_value']  
= $GLOBALS['phpgw']->accounts->id2name($value['new_value']);
-                               }
-                               else if ($value['status'] == 'T' || 
$value['status'] == 'TO')
-                               {
-                                       $record_history[$i]['value_new_value']  
= $this->so->read_single_project_category($value['new_value']);
-                               }
-                               else if ($value['status'] != 'O' && 
$value['new_value'])
-                               {
-                                       $record_history[$i]['value_new_value']  
= $value['new_value'];
-                               }
-                               else
-                               {
-                                       $record_history[$i]['value_new_value']  
= '';
-                               }
-
-                               $i++;
-                       }
-
-                       return $record_history;
-               }
-
-
-               function next_project_id()
-               {
-                       return $this->so->next_project_id();
-               }
-
-               function save($project,$action='')
-               {
-
-//html_print_r($project);
-                       while (is_array($project['location']) && list(,$value) 
= each($project['location']))
-                       {
-                               if($value)
-                               {
-                                       $location[] = $value;
-                               }
-                       }
-
-                       $project['location_code']=implode("-", $location);
-
-                       $start_date     = 
$this->bocommon->date_array($project['start_date']);
-                       $end_date       = 
$this->bocommon->date_array($project['end_date']);
-
-                       $project['start_date']  = mktime 
(2,0,0,$start_date['month'],$start_date['day'],$start_date['year']);
-                       $project['end_date']    = mktime 
(2,0,0,$end_date['month'],$end_date['day'],$end_date['year']);
-
-
-                       if ($action=='edit')
-                       {
-                                       $receipt = $this->so->edit($project);
-                       }
-                       else
-                       {
-                               $receipt = $this->so->add($project);
-                       }
-                       return $receipt;
-               }
-
-               function add_request($add_request,$id)
-               {
-
-                       return $this->so->add_request($add_request,$id);
-               }
-
-               function delete($project_id)
-               {
-                       $this->so->delete($project_id);
-               }
-       }
-?>
+<?php
+       
/**************************************************************************\
+       * phpGroupWare - property                                               
   *
+       * http://www.phpgroupware.org                                           
   *
+       *                                                                       
   *
+       * Facilities Management                                                 
   *
+       * Written by Sigurd Nes [sigurdne at online.no]                         
   *
+       * 
------------------------------------------------------------------------ *
+       * Copyright 2000 - 2003 Free Software Foundation, Inc                   
   *
+       * This program is part of the GNU project, see http://www.gnu.org/      
   *
+       * 
------------------------------------------------------------------------ *
+       * This program is free software; you can redistribute it and/or modify 
it  *
+       * under the terms of the GNU General Public License as published by the 
   *
+       * Free Software Foundation; either version 2 of the License, or (at 
your   *
+       * option) any later version.                                            
   *
+       
\**************************************************************************/
+
+       class property_boproject
+       {
+               var $start;
+               var $query;
+               var $filter;
+               var $sort;
+               var $order;
+               var $cat_id;
+
+               var $public_functions = array
+               (
+                       'read'                          => True,
+                       'read_single'           => True,
+                       'save'                          => True,
+                       'delete'                        => True,
+                       'check_perms'           => True
+               );
+
+               function property_boproject($session=False)
+               {
+                       $this->currentapp       = 'property'; 
//$GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $this->so                       = 
CreateObject($this->currentapp.'_soproject');
+                       $this->bocommon         = 
CreateObject($this->currentapp.'_bocommon');
+                       $this->solocation = 
CreateObject($this->currentapp.'_solocation');
+                       $this->fm_session       = 
CreateObject($this->currentapp.'_session');
+
+                       if ($session)
+                       {
+                               $this->read_sessiondata();
+                               $this->use_session = True;
+                       }
+
+                       $start  = get_var('start',array('POST','GET'));
+                       $query  = get_var('query',array('POST','GET'));
+                       $sort   = get_var('sort',array('POST','GET'));
+                       $order  = get_var('order',array('POST','GET'));
+                       $filter = get_var('filter',array('POST','GET'));
+                       $cat_id = get_var('cat_id',array('POST','GET'));
+                       $status_id      = 
get_var('status_id',array('POST','GET'));
+
+                       if ($start)
+                       {
+                               $this->start=$start;
+                       }
+                       else
+                       {
+                               $this->start=0;
+                       }
+
+                       if(isset($query))
+                       {
+                               $this->query = $query;
+                       }
+                       if(isset($filter))
+                       {
+                               $this->filter = $filter;
+                       }
+                       if(isset($sort))
+                       {
+                               $this->sort = $sort;
+                       }
+                       if(isset($order))
+                       {
+                               $this->order = $order;
+                       }
+                       if(isset($cat_id))
+                       {
+                               $this->cat_id = $cat_id;
+                       }
+                       if(isset($status_id))
+                       {
+                               $this->status_id = $status_id;
+                       }
+               }
+
+               function save_sessiondata($data)
+               {
+                       if ($this->use_session)
+                       {
+                               
$this->fm_session->appsession('session_data','project',$data);
+                       }
+               }
+
+               function read_sessiondata()
+               {
+                       $data = 
$this->fm_session->appsession('session_data','project');
+
+                       $this->start    = $data['start'];
+                       $this->query    = $data['query'];
+                       $this->filter   = $data['filter'];
+                       $this->sort             = $data['sort'];
+                       $this->order    = $data['order'];
+                       $this->cat_id   = $data['cat_id'];
+                       $this->status_id        = $data['status_id'];
+               }
+
+               function select_status_list($format='',$selected='')
+               {
+                       switch($format)
+                       {
+                               case 'select':
+                                       
$this->bocommon->xsl_add_file(array('status_select'));
+                                       break;
+                               case 'filter':
+                                       
$this->bocommon->xsl_add_file(array('status_filter'));
+                                       break;
+                       }
+
+                       $status_entries= $this->so->select_status_list();
+
+                       while (is_array($status_entries) && list(,$status) = 
each($status_entries))
+                       {
+                               $sel_status = '';
+                               if ($status['id']==$selected)
+                               {
+                                       $sel_status = 'selected';
+                               }
+
+                               $status_list[] = array
+                               (
+                                       'id'            => $status['id'],
+                                       'name'          => $status['name'],
+                                       'selected'      => $sel_status
+                               );
+                       }
+
+                       for ($i=0;$i<count($status_list);$i++)
+                       {
+                               if ($status_list[$i]['selected'] != 'selected')
+                               {
+                                       unset($status_list[$i]['selected']);
+                               }
+                       }
+
+                       return $status_list;
+               }
+
+               function select_branch_list($selected='')
+               {
+
+                       $branch_entries= $this->so->select_branch_list();
+
+                       while (is_array($branch_entries) && list(,$branch) = 
each($branch_entries))
+                       {
+                               $sel_branch = '';
+                               if ($branch['id']==$selected)
+                               {
+                                       $sel_branch = 'selected';
+                               }
+
+                               $branch_list[] = array
+                               (
+                                       'id'            => $branch['id'],
+                                       'name'          => $branch['name'],
+                                       'selected'      => $sel_branch
+                               );
+                       }
+
+                       for ($i=0;$i<count($branch_list);$i++)
+                       {
+                               if ($branch_list[$i]['selected'] != 'selected')
+                               {
+                                       unset($branch_list[$i]['selected']);
+                               }
+                       }
+
+                       return $branch_list;
+               }
+
+               function select_branch_p_list($project_id='')
+               {
+
+                       $selected               = 
$this->so->branch_p_list($project_id);
+                       $branch_entries = $this->so->select_branch_list();
+
+                       $j=0;
+                       while (is_array($branch_entries) && list(,$branch) = 
each($branch_entries))
+                       {
+                               $branch_list[$j]['id'] = $branch['id'];
+                               $branch_list[$j]['name'] = $branch['name'];
+
+                               for ($i=0;$i<count($selected);$i++)
+                               {
+                                       if($selected[$i]['branch_id'] == 
$branch['id'])
+                                       {
+                                               $branch_list[$j]['selected'] = 
'selected';
+                                       }
+                               }
+                               $j++;
+                       }
+
+                       for ($i=0;$i<count($branch_list);$i++)
+                       {
+                               if ($branch_list[$i]['selected'] != 'selected')
+                               {
+                                       unset($branch_list[$i]['selected']);
+                               }
+                       }
+
+                       return $branch_list;
+               }
+
+
+               function select_key_location_list($selected='')
+               {
+
+                       $key_location_entries= 
$this->so->select_key_location_list();
+
+                       while (is_array($key_location_entries) && 
list(,$key_location) = each($key_location_entries))
+                       {
+                               $sel_key_location = '';
+                               if ($key_location['id']==$selected)
+                               {
+                                       $sel_key_location = 'selected';
+                               }
+
+                               $key_location_list[] = array
+                               (
+                                       'id'            => $key_location['id'],
+                                       'name'          => 
$key_location['name'],
+                                       'selected'      => $sel_key_location
+                               );
+                       }
+
+                       for ($i=0;$i<count($key_location_list);$i++)
+                       {
+                               if ($key_location_list[$i]['selected'] != 
'selected')
+                               {
+                                       
unset($key_location_list[$i]['selected']);
+                               }
+                       }
+
+                       return $key_location_list;
+               }
+
+               function select_category_project_list($format='',$selected='')
+               {
+                       switch($format)
+                       {
+                               case 'select':
+                                       
$this->bocommon->xsl_add_file(array('cat_select'));
+                                       break;
+                               case 'filter':
+                                       
$this->bocommon->xsl_add_file(array('cat_filter'));
+                                       break;
+                       }
+
+                       $categories= 
$this->so->select_category_workorder_list();
+
+                       while (is_array($categories) && list(,$category) = 
each($categories))
+                       {
+                               $sel_category = '';
+                               if ($category['id']==$selected)
+                               {
+                                       $sel_category = 'selected';
+                               }
+
+                               $category_list[] = array
+                               (
+                                       'cat_id'        => $category['id'],
+                                       'name'          => $category['name'],
+                                       'selected'      => $sel_category
+                               );
+                       }
+
+                       for ($i=0;$i<count($category_list);$i++)
+                       {
+                               if ($category_list[$i]['selected'] != 
'selected')
+                               {
+                                       unset($category_list[$i]['selected']);
+                               }
+                       }
+
+                       return $category_list;
+               }
+
+
+               function read($start_date='',$end_date='',$allrows='')
+               {
+                       $start_date     = 
$this->bocommon->date_to_timestamp($start_date);
+                       $end_date       = 
$this->bocommon->date_to_timestamp($end_date);
+
+                       $project = $this->so->read(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
+                                                                               
        'filter' => $this->filter,'cat_id' => $this->cat_id,'status_id' => 
$this->status_id,
+                                                                               
        'start_date'=>$start_date,'end_date'=>$end_date,'allrows'=>$allrows));
+                       $this->total_records = $this->so->total_records;
+
+                       $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+                       $this->uicols   = $this->so->uicols;
+                       $this->uicols['input_type'][]   = 'link';
+                       $this->uicols['name'][]                 = 'ticket_id';
+                       $this->uicols['descr'][]                = 
lang('ticket');
+                       $this->uicols['statustext'][]   = false;
+
+//                     $cols_extra             = $this->so->cols_extra;
+
+                       for ($i=0; $i<count($project); $i++)
+                       {
+                               $project[$i]['start_date'] = 
$GLOBALS['phpgw']->common->show_date($project[$i]['start_date'],$dateformat);
+                               $project[$i]['ticket_id'] = 
$this->so->get_ticket($project[$i]['project_id']);
+
+/*                             
$location_data=$this->solocation->read_single($project[$i]['location_code']);
+
+                               for ($j=0;$j<count($cols_extra);$j++)
+                               {
+                                       $project[$i][$cols_extra[$j]] = 
$location_data[$cols_extra[$j]];
+                               }
+*/
+                       }
+
+//html_print_r($project);
+
+                       return $project;
+               }
+
+               function read_single($project_id)
+               {
+                       $contacts               = 
CreateObject('phpgwapi_contacts');
+                       $config                         = 
CreateObject('phpgwapi_config');
+                       $config->read_repository();
+                       $tax = 1+($config->config_data['fm_tax'])/100;
+
+                       $project                                                
= $this->so->read_single($project_id);
+                       $dateformat                                             
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+                       $project['start_date']                  = 
$GLOBALS['phpgw']->common->show_date($project['start_date'],$dateformat);
+                       $project['end_date']                    = 
$GLOBALS['phpgw']->common->show_date($project['end_date'],$dateformat);
+                       $workorder_data                         = 
$this->so->project_workorder_data($project_id);
+
+                       for ($i=0;$i<count($workorder_data);$i++)
+                       {
+                               $sum_workorder_budget= 
$sum_workorder_budget+$workorder_data[$i]['budget'];
+                               $sum_deviation= 
$sum_deviation+$workorder_data[$i]['deviation'];
+                               $sum_workorder_calculation= 
$sum_workorder_calculation+$workorder_data[$i]['calculation'];
+                               
$project['workorder_budget'][$i]['workorder_id']=$workorder_data[$i]['workorder_id'];
+                               
$project['workorder_budget'][$i]['budget']=number_format($workorder_data[$i]['budget'],
 2, ',', '');
+                               
$project['workorder_budget'][$i]['calculation']=number_format($workorder_data[$i]['calculation']*$tax,
 2, ',', '');
+                               $vendor = 
$contacts->read_single_entry((int)$workorder_data[$i]['vendor_id'],array('org_name'=>'org_name'));
+                               $project['workorder_budget'][$i]['vendor_name'] 
= $vendor[0]['org_name'];
+                       }
+                       if($workorder_data)
+                       {
+                               $project['sum_workorder_budget']= 
number_format($sum_workorder_budget, 2, ',', '');
+                               $project['deviation']= $sum_deviation;
+                               $project['sum_workorder_calculation']= 
number_format($sum_workorder_calculation*$tax, 2, ',', '');
+                       }
+
+                       if($project['location_code'])
+                       {
+                               $project['location_data'] 
=$this->solocation->read_single($project['location_code']);
+                       }
+
+                       if($project['tenant_id']>0)
+                       {
+                               
$tenant_data=$this->bocommon->read_single_tenant($project['tenant_id']);
+                               $project['location_data']['tenant_id']= 
$project['tenant_id'];
+                               $project['location_data']['contact_phone']= 
$tenant_data['contact_phone'];
+                               $project['location_data']['last_name']  = 
$tenant_data['last_name'];
+                               $project['location_data']['first_name'] = 
$tenant_data['first_name'];
+                       }
+                       else
+                       {
+                               unset($project['location_data']['tenant_id']);
+                               
unset($project['location_data']['contact_phone']);
+                               unset($project['location_data']['last_name']);
+                               unset($project['location_data']['first_name']);
+                       }
+
+                       if($project['p_num'])
+                       {
+                               $soadmin_entity = 
CreateObject($this->currentapp.'_soadmin_entity');
+                               $category = 
$soadmin_entity->read_single_category($project['p_entity_id'],$project['p_cat_id']);
+
+                               
$project['p'][$project['p_entity_id']]['p_num']=$project['p_num'];
+                               
$project['p'][$project['p_entity_id']]['p_entity_id']=$project['p_entity_id'];
+                               
$project['p'][$project['p_entity_id']]['p_cat_id']=$project['p_cat_id'];
+                               
$project['p'][$project['p_entity_id']]['p_cat_name'] = $category['name'];
+                       }
+
+
+//html_print_r($project);
+                       return $project;
+               }
+
+               function read_single_mini($project_id)
+               {
+                       $project                                                
= $this->so->read_single($project_id);
+                       $dateformat                                             
= $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+                       $project['start_date']                  = 
$GLOBALS['phpgw']->common->show_date($project['start_date'],$dateformat);
+                       $project['end_date']                    = 
$GLOBALS['phpgw']->common->show_date($project['end_date'],$dateformat);
+
+                       if($project['location_code'])
+                       {
+                               $project['location_data'] 
=$this->solocation->read_single($project['location_code']);
+                       }
+
+                       if($project['tenant_id']>0)
+                       {
+                               
$tenant_data=$this->bocommon->read_single_tenant($project['tenant_id']);
+                               $project['location_data']['tenant_id']= 
$project['tenant_id'];
+                               $project['location_data']['contact_phone']= 
$tenant_data['contact_phone'];
+                               $project['location_data']['last_name']  = 
$tenant_data['last_name'];
+                               $project['location_data']['first_name'] = 
$tenant_data['first_name'];
+                       }
+                       else
+                       {
+                               unset($project['location_data']['tenant_id']);
+                               
unset($project['location_data']['contact_phone']);
+                               unset($project['location_data']['last_name']);
+                               unset($project['location_data']['first_name']);
+                       }
+
+//html_print_r($project);
+                       return $project;
+               }
+
+
+               function read_record_history($id)
+               {
+                       $historylog     = 
CreateObject($this->currentapp.'_historylog','project');
+                       $history_array = 
$historylog->return_array(array('O'),array(),'','',$id);
+                       $i=0;
+                       while (is_array($history_array) && list(,$value) = 
each($history_array))
+                       {
+
+                               $record_history[$i]['value_date']       = 
$GLOBALS['phpgw']->common->show_date($value['datetime']);
+                               $record_history[$i]['value_user']       = 
$value['owner'];
+
+                               switch ($value['status'])
+                               {
+                                       case 'R': $type = lang('Re-opened'); 
break;
+                                       case 'X': $type = lang('Closed');    
break;
+                                       case 'O': $type = lang('Opened');    
break;
+                                       case 'A': $type = lang('Re-assigned'); 
break;
+                                       case 'P': $type = lang('Priority 
changed'); break;
+                                       case 'CO': $type = lang('Initial 
Coordinator'); break;
+                                       case 'C': $type = lang('Coordinator 
changed'); break;
+                                       case 'TO': $type = lang('Initial 
Category'); break;
+                                       case 'T': $type = lang('Category 
changed'); break;
+                                       case 'SO': $type = lang('Initial 
Status'); break;
+                                       case 'S': $type = lang('Status 
changed'); break;
+                                       default: break;
+                               }
+
+                               
if($value['new_value']=='O'){$value['new_value']=lang('Opened');}
+                               
if($value['new_value']=='X'){$value['new_value']=lang('Closed');}
+
+
+                               $record_history[$i]['value_action']     = 
$type?$type:'';
+                               unset($type);
+
+                               if ($value['status'] == 'A')
+                               {
+                                       if (! $value['new_value'])
+                                       {
+                                               
$record_history[$i]['value_new_value']  = lang('None');
+                                       }
+                                       else
+                                       {
+                                               
$record_history[$i]['value_new_value']  = 
$GLOBALS['phpgw']->accounts->id2name($value['new_value']);
+                                       }
+                               }
+                               else if ($value['status'] == 'C' || 
$value['status'] == 'CO')
+                               {
+                                       $record_history[$i]['value_new_value']  
= $GLOBALS['phpgw']->accounts->id2name($value['new_value']);
+                               }
+                               else if ($value['status'] == 'T' || 
$value['status'] == 'TO')
+                               {
+                                       $record_history[$i]['value_new_value']  
= $this->so->read_single_project_category($value['new_value']);
+                               }
+                               else if ($value['status'] != 'O' && 
$value['new_value'])
+                               {
+                                       $record_history[$i]['value_new_value']  
= $value['new_value'];
+                               }
+                               else
+                               {
+                                       $record_history[$i]['value_new_value']  
= '';
+                               }
+
+                               $i++;
+                       }
+
+                       return $record_history;
+               }
+
+
+               function next_project_id()
+               {
+                       return $this->so->next_project_id();
+               }
+
+               function save($project,$action='')
+               {
+
+//html_print_r($project);
+                       while (is_array($project['location']) && list(,$value) 
= each($project['location']))
+                       {
+                               if($value)
+                               {
+                                       $location[] = $value;
+                               }
+                       }
+
+                       $project['location_code']=implode("-", $location);
+
+                       $start_date     = 
$this->bocommon->date_array($project['start_date']);
+                       $end_date       = 
$this->bocommon->date_array($project['end_date']);
+
+                       $project['start_date']  = mktime 
(2,0,0,$start_date['month'],$start_date['day'],$start_date['year']);
+                       $project['end_date']    = mktime 
(2,0,0,$end_date['month'],$end_date['day'],$end_date['year']);
+
+
+                       if ($action=='edit')
+                       {
+                                       $receipt = $this->so->edit($project);
+                       }
+                       else
+                       {
+                               $receipt = $this->so->add($project);
+                       }
+                       return $receipt;
+               }
+
+               function add_request($add_request,$id)
+               {
+
+                       return $this->so->add_request($add_request,$id);
+               }
+
+               function delete($project_id)
+               {
+                       $this->so->delete($project_id);
+               }
+       }
+?>




reply via email to

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