phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] property/inc/class.bowo_hour.inc.php, 1.2


From: nomail
Subject: [Phpgroupware-cvs] property/inc/class.bowo_hour.inc.php, 1.2
Date: Wed, 2 Jun 2004 20:54:28 +0200

Update of /property/inc
Added Files:
        Branch: 
          class.bowo_hour.inc.php

date: 2004/06/02 18:54:28;  author: sigurdne;  state: Exp;  lines: +485 -0

Log Message:
no message
=====================================================================
<?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 bowo_hour
        {
                var $start;
                var $query;
                var $filter;
                var $sort;
                var $order;
                var $cat_id;

                var $public_functions = array
                (
                        'read'                          => True,
                        'read_single'           => True,
                        'save'                          => True,
                        'delete'                        => True,
                        'check_perms'           => True
                );

                function bowo_hour($session=False)
                {
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->so                       = 
CreateObject($this->currentapp.'.sowo_hour');

                        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'));
                        $chapter_id     = 
get_var('chapter_id',array('POST','GET'));
                        $allrows        = 
get_var('allrows',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($allrows))
                        {
                                $this->allrows = $allrows;
                        }
                        if(isset($chapter_id))
                        {
                                $this->chapter_id = $chapter_id;
                        }
                }

                function save_sessiondata($data)
                {
                        if ($this->use_session)
                        {
                                
$GLOBALS['phpgw']->session->appsession('session_data','wo_hour',$data);
                        }
                }

                function read_sessiondata()
                {
                        $data = 
$GLOBALS['phpgw']->session->appsession('session_data','wo_hour');

                        $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->allrows  = $data['allrows'];
                        $this->chapter_id       = $data['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();

                        while (is_array($chapters) && list(,$chapter_entry) = 
each($chapters))
                        {
                                $sel_chapter_entry = '';
                                if ($chapter_entry['id']==$selected)
                                {
                                        $sel_chapter_entry = 'selected';
                                }

                                $chapter_list[] = array
                                (
                                        'id'            => $chapter_entry['id'],
                                        'name'          => 
$chapter_entry['name'],
                                        'selected'      => $sel_chapter_entry
                                );
                        }

                        for ($i=0;$i<count($chapter_list);$i++)
                        {
                                if ($chapter_list[$i]['selected'] != 'selected')
                                {
                                        unset($chapter_list[$i]['selected']);
                                }
                        }

                        return $chapter_list;
                }

                function get_tolerance_list($selected='')
                {
                        
$GLOBALS['phpgw']->xslttpl->add_file(array('tolerance_select'));

                        $tolerances[0]['id']= 1;
                        $tolerances[1]['id']= 2;
                        $tolerances[2]['id']= 3;

                        while (is_array($tolerances) && list(,$tolerance_entry) 
= each($tolerances))
                        {
                                $sel_tolerance_entry = '';
                                if ($tolerance_entry['id']==$selected)
                                {
                                        $sel_tolerance_entry = 'selected';
                                }

                                $tolerance_list[] = array
                                (
                                        'id'            => 
$tolerance_entry['id'],
                                        'name'          => 
$tolerance_entry['id'],
                                        'selected'      => $sel_tolerance_entry
                                );
                        }

                        for ($i=0;$i<count($tolerance_list);$i++)
                        {
                                if ($tolerance_list[$i]['selected'] != 
'selected')
                                {
                                        unset($tolerance_list[$i]['selected']);
                                }
                        }

                        return $tolerance_list;
                }

                function get_grouping_list($selected='',$workorder_id)
                {
                        
$GLOBALS['phpgw']->xslttpl->add_file(array('grouping_select'));

                        $groupings= $this->so->get_grouping_list($workorder_id);

                        while (is_array($groupings) && list(,$grouping_entry) = 
each($groupings))
                        {
                                $sel_grouping_entry = '';
                                if ($grouping_entry['id']==$selected)
                                {
                                        $sel_grouping_entry = 'selected';
                                }

                                $grouping_list[] = array
                                (
                                        'id'            => 
$grouping_entry['id'],
                                        'name'          => 
$grouping_entry['name'],
                                        'selected'      => $sel_grouping_entry
                                );
                        }

                        for ($i=0;$i<count($grouping_list);$i++)
                        {
                                if ($grouping_list[$i]['selected'] != 
'selected')
                                {
                                        unset($grouping_list[$i]['selected']);
                                }
                        }

                        return $grouping_list;
                }

                function get_building_part_list($selected='')
                {
                        
$GLOBALS['phpgw']->xslttpl->add_file(array('building_part_select'));

                        $building_parts= $this->so->get_building_part_list();

                        while (is_array($building_parts) && 
list(,$building_part_entry) = each($building_parts))
                        {
                                $sel_building_part_entry = '';
                                if ($building_part_entry['id']==$selected)
                                {
                                        $sel_building_part_entry = 'selected';
                                }

                                $building_part_list[] = array
                                (
                                        'id'            => 
$building_part_entry['id'],
                                        'name'          => '[ ' . 
$building_part_entry['id'] . ' ] ' . $building_part_entry['name'],
                                        'selected'      => 
$sel_building_part_entry
                                );
                        }

                        for ($i=0;$i<count($building_part_list);$i++)
                        {
                                if ($building_part_list[$i]['selected'] != 
'selected')
                                {
                                        
unset($building_part_list[$i]['selected']);
                                }
                        }

                        return $building_part_list;
                }


                function read($workorder_id='')
                {
                        $hour = $this->so->read(array('workorder_id' => 
$workorder_id));
                        $this->total_records = $this->so->total_records;
                        return $hour;
                }

                function read_deviation($data)
                {
                        $deviation = 
$this->so->read_deviation(array('workorder_id' => 
$data['workorder_id'],'hour_id' => $data['hour_id']));
                        $this->total_records = $this->so->total_records;
                        return $deviation;
                }

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

                function update_deviation($data)
                {
                        $this->so->update_deviation($data);
                }

                function update_calculation($data)
                {
                        $this->so->update_calculation($data);
                }

                function save_deviation($values,$action='')
                {
                        if ($action=='edit')
                        {
                                if ($values['id'] != '')
                                {
                                        $receipt = 
$this->so->edit_deviation($values);
                                }
                        }
                        else
                        {
                                $receipt = $this->so->add_deviation($values);
                        }
                        return $receipt;
                }

                function add_template($values,$workorder_id)
                {
                        return $this->so->add_template($values,$workorder_id);
                }

                function add_hour($values,$workorder_id)
                {

//_debug_array($values);

                        foreach($values['select'] as $n)
                        {

                                if(!$values['quantity'][$n])
                                {
                                        $values['quantity'][$n]=1;
                                }

                                $values['quantity'][$n]         = 
str_replace(",",".",$values['quantity'][$n]);

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

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

                        }
//_debug_array($hour);

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

                        return $receipt;

                }

                function add_hour_from_template($values,$workorder_id)
                {

//_debug_array($values);

                        foreach($values['select'] as $n)
                        {
                                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
                        {
                                        $receipt['message'][] = 
array('msg'=>lang('Nothing to do!'));
                        }

                        return $receipt;

                }

                function read_single_hour($hour_id)
                {
                        $hour   = $this->so->read_single_hour($hour_id);
                        return $hour;
                }

                function save_hour($values,$workorder_id)
                {
                        $values['billperae']    = 
str_replace(",",".",$values['billperae']);
                        $values['quantity']             = 
str_replace(",",".",$values['quantity']);
                        $values['cost']                 = 
$values['billperae']*$values['quantity'];
                        if($values['ns3420_descr'])
                        {
                                $values['descr']=$values['ns3420_descr'];
                        }

                        if ($values['hour_id'])
                        {
                                if ($values['hour_id'] != 0)
                                {
                                        $receipt = 
$this->so->edit($values,$workorder_id);
                                }
                        }
                        else
                        {
//_debug_array($values);
                                $receipt = 
$this->so->add_custom_hour($values,$workorder_id);
                        }
                        return $receipt;
                }

                function get_email($to_email,$vendor_id)
                {
                        $selected = $to_email;

                        $email_ist = $this->so->get_email($vendor_id);

                        while (is_array($email_ist) && list(,$email_entry) = 
each($email_ist))
                        {
                                $sel_email = '';
                                if ($email_entry['email']==$selected)
                                {
                                        $sel_email = 'selected';
                                }

                                $email_list[] = array
                                (
                                        'email'         => 
$email_entry['email'],
                                        'selected'      => $sel_email
                                );
                        }

                        for ($i=0;$i<count($email_list);$i++)
                        {
                                if ($email_list[$i]['selected'] != 'selected')
                                {
                                        unset($email_list[$i]['selected']);
                                }
                        }

                        return  $email_list;
                }


                function update_email($to_email,$workorder_id)
                {
                        $this->so->update_email($to_email,$workorder_id);
                }


                function delete($hour_id,$workorder_id)
                {
                        return $this->so->delete($hour_id,$workorder_id);
                }

                function delete_deviation($workorder_id,$hour_id,$id)
                {
                        return 
$this->so->delete_deviation($workorder_id,$hour_id,$id);
                }
        }
?>




reply via email to

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