phpgroupware-cvs
[Top][All Lists]
Advanced

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

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


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

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

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

Log Message:
no message
=====================================================================
Index: property/class.soinvoice.php
diff -u property/class.soinvoice.php:1.1.1.2 
property/class.soinvoice.php:1.1.1.3
--- property/class.soinvoice.php:1.1.1.2        Fri Apr 23 20:25:50 2004
+++ property/class.soinvoice.php        Fri Apr 23 21:26:33 2004
@@ -1,903 +1,903 @@
-<?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.                                            
   *
-       
\**************************************************************************/
-  /* $Id$ */
-
-       class property_soinvoice
-       {
-
-               function property_soinvoice()
-               {
-                       $this->db               = $GLOBALS['phpgw']->db;
-                       $this->db2              = $this->db;
-
-                       $this->currentapp       = 'property'; 
//$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $this->bocommon         = 
CreateObject($this->currentapp.'_bocommon');
-                       $this->account_id       = 
$GLOBALS['phpgw_data']['user']['id'];
-                       $this->acl2             = 
CreateObject($this->currentapp.'_acl2','##DEFAULT##','##DEFAULT##');
-
-                       $this->join                     = $this->bocommon->join;
-                       $this->left_join        = $this->bocommon->left_join;
-
-               }
-
-
-               function read_invoice($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']:'');
-                               $cat_id                 = 
(isset($data['cat_id'])?$data['cat_id']:0);
-                               $user_lid               = 
(isset($data['user_lid'])?$data['user_lid']:'none');
-                               $paid                   = 
(isset($data['paid'])?$data['paid']:'');
-                               $start_date     = 
(isset($data['start_date'])?$data['start_date']:'');
-                               $end_date               = 
(isset($data['end_date'])?$data['end_date']:'');
-                               $vendor_id              = 
(isset($data['vendor_id'])?$data['vendor_id']:'');
-                               $loc1                   = 
(isset($data['loc1'])?$data['loc1']:'');
-                               $workorder_id   = 
(isset($data['workorder_id'])?$data['workorder_id']:'');
-                               $allrows                = 
(isset($data['allrows'])?$data['allrows']:'');
-                       }
-
-//html_print_r($data);
-
-                       if ($order)
-                       {
-                               $ordermethod = " order by $order $sort";
-                       }
-                       else
-                       {
-                               $ordermethod = ' order by bilagsnr DESC';
-                       }
-
-                       $where= 'WHERE';
-
-                       if ($user_lid=='none' || !$user_lid):
-                       {
-                               return;
-                       }
-                       elseif ($user_lid!='all'):
-                       {
-                               $filtermethod = " WHERE ( oppsynsmannid= 
'$user_lid' or saksbehandlerid= '$user_lid' or budsjettansvarligid= 
'$user_lid')";
-                               $where= 'AND';
-                       }
-                       endif;
-
-                       if ($cat_id > 0)
-                       {
-                               $filtermethod .= " $where typeid='$cat_id' ";
-                               $where= 'AND';
-                       }
-
-                       if ($district_id > 0)
-                       {
-                               $filtermethod .= " $where  
district_id='$district_id' ";
-                               $where= 'AND';
-                       }
-
-                       if ($vendor_id)
-                       {
-                               $filtermethod .= " $where  spvend_code 
='$vendor_id' ";
-                               $where= 'AND';
-                       }
-                       if ($loc1)
-                       {
-                               $filtermethod .= " $where  dima ='$loc1' ";
-                               $where= 'AND';
-                       }
-                       if ($workorder_id)
-                       {
-                               $filtermethod .= " $where  pmwrkord_code 
='$workorder_id' ";
-                               $where= 'AND';
-                       }
-
-
-                       if ($paid)
-                       {
-                               $table = 'fm_ecobilagoverf';
-                               $dateformat = 
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                               $dateformat = str_replace(".","",$dateformat);
-                               $dateformat = str_replace("-","",$dateformat);
-                               $dateformat = str_replace("/","",$dateformat);
-                               $y=strpos($dateformat,'y');
-                               $d=strpos($dateformat,'d');
-                               $m=strpos($dateformat,'m');
-
-                               $dateparts = explode('/', $start_date);
-                               $sday = $dateparts[$d];
-                               $smonth = $dateparts[$m];
-                               $syear = $dateparts[$y];
-
-                               $dateparts = explode('/', $end_date);
-                               $eday = $dateparts[$d];
-                               $emonth = $dateparts[$m];
-                               $eyear = $dateparts[$y];
-
-                               $start_date = 
date($this->bocommon->dateformat,mktime(2,0,0,$smonth,$sday,$syear));
-                               $end_date = 
date($this->bocommon->dateformat,mktime(2,0,0,$emonth,$eday,$eyear));
-
-                               if (!$workorder_id)
-                               {
-                                       $filtermethod .= " $where  overftid 
>'$start_date' and overftid < '$end_date'";
-                               }
-                       }
-                       else
-                       {
-                               $table ='fm_ecobilag';
-                       }
-
-
-                       if($query)
-                       {
-                               $query = ereg_replace("'",'',$query);
-                               $query = ereg_replace('"','',$query);
-
-                               $querymethod = " $where ( spvend_code LIKE 
'%$query%' OR bilagsnr LIKE '%$query%' )";
-                       }
-
-
-                       $sql = "SELECT DISTINCT bilagsnr, count(bilagsnr) as 
invoice_count, sum(belop) as belop,spvend_code,fakturadato FROM  $table  
$filtermethod $querymethod group by bilagsnr,spvend_code,fakturadato ";
-                       $sql2 = "SELECT DISTINCT bilagsnr FROM  $table  
$filtermethod $querymethod";
-
-//echo $sql;
-                       $this->db2->query($sql2);
-                       $this->total_records = $dbresult2->_numOfRows;
-
-                       $maxmatchs = 15;
-
-                       if(!$allrows)
-                       {
-                               $dbresult = 
$GLOBALS['phpgw']->db->SelectLimit($sql . $ordermethod,$maxmatchs,$start);
-
-                       }
-                       else
-                       {
-                               $dbresult = $GLOBALS['phpgw']->db->Execute($sql 
. $ordermethod);
-                       }
-
-                       while (!$dbresult->EOF)
-                       {
-                               $temp[] = array
-                               (
-                                       'voucher_id'            => 
$dbresult->fields['bilagsnr'],
-                                       'invoice_count'         => 
$dbresult->fields['invoice_count'],
-                                       'amount'                        => 
$dbresult->fields['belop']
-                                       );
-                               $dbresult->MoveNext();
-                       }
-
-                       if ($temp)
-                       {
-                               $role= $this->check_role();
-                               $i = 0;
-                               foreach($temp as $invoice_temp)
-                               {
-                                       $voucher_id=$invoice_temp['voucher_id'];
-
-                                       $sql = "SELECT 
spvend_code,oppsynsmannid,saksbehandlerid,budsjettansvarligid,"
-                                       . " 
utbetalingid,oppsynsigndato,saksigndato,budsjettsigndato,utbetalingsigndato,fakturadato,org_name,"
-                                       . " 
forfallsdato,periode,artid,kidnr,kreditnota "
-                                       . " from $table $this->join 
phpgw_addressbook ON phpgw_addressbook.id = $table.spvend_code WHERE bilagsnr = 
$voucher_id "
-                                       . " group by 
bilagsnr,spvend_code,oppsynsmannid,saksbehandlerid,budsjettansvarligid,"
-                                       . " 
utbetalingid,oppsynsigndato,saksigndato,budsjettsigndato,utbetalingsigndato,fakturadato,org_name,"
-                                       . " 
forfallsdato,periode,artid,kidnr,kreditnota ";
-
-                                       $dbresult = 
$GLOBALS['phpgw']->db->Execute($sql);
-
-
-
-                                       $timestamp_voucher_date= 
mktime(0,0,0,date(m,strtotime($dbresult->fields['fakturadato'])),date(d,strtotime($dbresult->fields['fakturadato'])),date(y,strtotime($dbresult->fields['fakturadato'])));
-                                       $timestamp_payment_date= 
mktime(0,0,0,date(m,strtotime($dbresult->fields['forfallsdato'])),date(d,strtotime($dbresult->fields['forfallsdato'])),date(y,strtotime($dbresult->fields['forfallsdato'])));
-
-                                       if($dbresult->fields['oppsynsmannid'] 
&& $dbresult->fields['oppsynsigndato'])
-                                       {
-//                                             $timestamp_jan_date             
        = 
mktime(0,0,0,date(m,strtotime($dbresult->fields['oppsynsigndato'])),date(d,strtotime($dbresult->fields['oppsynsigndato'])),date(y,strtotime($dbresult->fields['oppsynsigndato'])));
-//                                             $invoice[$i]['jan_date']        
= 
$GLOBALS['phpgw']->common->show_date($timestamp_jan_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                                               
$invoice[$i]['jan_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($dbresult->fields['oppsynsigndato']));
-                                       }
-                                       else
-                                       {
-                                               $invoice[$i]['jan_date']        
='';
-                                       }
-                                       if($dbresult->fields['saksbehandlerid'] 
&& $dbresult->fields['saksigndato'])
-                                       {
-//                                             $timestamp_super_date           
= 
mktime(0,0,0,date(m,strtotime($dbresult->fields['saksigndato'])),date(d,strtotime($dbresult->fields['saksigndato'])),date(y,strtotime($dbresult->fields['saksigndato'])));
-//                                             $invoice[$i]['super_date']      
= 
$GLOBALS['phpgw']->common->show_date($timestamp_super_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                                               
$invoice[$i]['super_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($dbresult->fields['saksigndato']));
-                                       }
-                                       else
-                                       {
-                                               $invoice[$i]['super_date']      
='';
-                                       }
-
-                                       
if($dbresult->fields['budsjettansvarligid'] && 
$dbresult->fields['budsjettsigndato'])
-                                       {
-//                                                     $timestamp_budget_date  
        = 
mktime(0,0,0,date(m,strtotime($dbresult->fields['budsjettsigndato'])),date(d,strtotime($dbresult->fields['budsjettsigndato'])),date(y,strtotime($dbresult->fields['budsjettsigndato'])));
-//                                                     
$invoice[$i]['budget_date']     = 
$GLOBALS['phpgw']->common->show_date($timestamp_budget_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                                                       
$invoice[$i]['budget_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($dbresult->fields['budsjettsigndato']));
-                                       }
-                                       else
-                                       {
-                                               $invoice[$i]['budget_date']     
='';
-                                       }
-
-                                       if($dbresult->fields['utbetalingid'] && 
$dbresult->fields['utbetalingsigndato'])
-                                       {
-//                                             $timestamp_transfer_date= 
mktime(0,0,0,date(m,strtotime($dbresult->fields['utbetalingsigndato'])),date(d,strtotime($dbresult->fields['utbetalingsigndato'])),date(y,strtotime($dbresult->fields['utbetalingsigndato'])));
-//                                             $invoice[$i]['transfer_date']   
                = 
$GLOBALS['phpgw']->common->show_date($timestamp_transfer_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                                               
$invoice[$i]['transfer_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($dbresult->fields['utbetalingsigndato']));
-                                       }
-                                       else
-                                       {
-                                               $invoice[$i]['transfer_date']   
='';
-                                       }
-
-                                       $invoice[$i]['counter']                 
                = $i;
-                                       $invoice[$i]['current_user']            
        = strtoupper($GLOBALS['phpgw_info']['user']['account_lid']);
-                                       $invoice[$i]['voucher_id']              
                = $voucher_id;
-                                       $invoice[$i]['invoice_count']           
        = $invoice_temp['invoice_count'];
-                                       $invoice[$i]['vendor_id']               
                = $dbresult->fields['spvend_code'];
-                                       $invoice[$i]['vendor']                  
                = $dbresult->fields['org_name'];
-                                       $invoice[$i]['is_janitor']              
                = $role['is_janitor'];
-                                       $invoice[$i]['is_supervisor']           
        = $role['is_supervisor'];
-                                       $invoice[$i]['is_budget_responsible']   
= $role['is_budget_responsible'];
-                                       $invoice[$i]['is_janitor']              
                = $role['is_janitor'];
-                                       $invoice[$i]['is_transfer']             
                = $role['is_transfer'];
-                                       $invoice[$i]['janitor']                 
                = $dbresult->fields['oppsynsmannid'];
-                                       $invoice[$i]['supervisor']              
                = $dbresult->fields['saksbehandlerid'];
-                                       $invoice[$i]['budget_responsible']      
        = $dbresult->fields['budsjettansvarligid'];
-                                       $invoice[$i]['transfer_id']             
                = $dbresult->fields['utbetalingid'];
-                                       $invoice[$i]['voucher_date']            
        = 
$GLOBALS['phpgw']->common->show_date($timestamp_voucher_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                                       $invoice[$i]['payment_date']            
        = 
$GLOBALS['phpgw']->common->show_date($timestamp_payment_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                                       $invoice[$i]['period']                  
                = $dbresult->fields['periode'];
-                                       $invoice[$i]['type']                    
                = $dbresult->fields['artid'];
-                                       $invoice[$i]['kidnr']                   
                = $dbresult->fields['kidnr'];
-                                       $invoice[$i]['kreditnota']              
                = $dbresult->fields['kreditnota'];
-                                       $invoice[$i]['amount']                  
                = $invoice_temp['amount'];
-                                       $invoice[$i]['num_days']                
                = 
intval(($timestamp_payment_date-$timestamp_voucher_date)/(24*3600));
-                                       $invoice[$i]['timestamp_voucher_date']  
= $timestamp_voucher_date;
-
-                                       
if($invoice[$i]['current_user']==$invoice[$i]['janitor'] && 
$invoice[$i]['jan_date']):
-                                       {
-                                               
$invoice[$i]['sign_orig']='sign_janitor';
-                                       }
-                                       
elseif($invoice[$i]['current_user']==$invoice[$i]['supervisor'] && 
$invoice[$i]['super_date']):
-                                       {
-                                               
$invoice[$i]['sign_orig']='sign_supervisor';
-                                       }
-                                       
elseif($invoice[$i]['current_user']==$invoice[$i]['budget_responsible'] && 
$invoice[$i]['budget_date']):
-                                       {
-                                               
$invoice[$i]['sign_orig']='sign_budget_responsible';
-                                       }
-                                       endif;
-
-                                       $i++;
-
-                               }
-                       }
-//                     $end_time = explode(' ',microtime());
-//                     $this->end_time = $end_time;
-
-//html_print_r($invoice);
-//html_print_r($invoice_temp);
-
-                       return $invoice;
-
-               }
-
-
-               function read_invoice_sub($data)
-               {
-                       if(is_array($data))
-                       {
-                               if ($data['start'])
-                               {
-                                       $start=$data['start'];
-                               }
-                               else
-                               {
-                                       $start=0;
-                               }
-                               $filter = 
(isset($data['filter'])?$data['filter']:'none');
-                               $sort = 
(isset($data['sort'])?$data['sort']:'DESC');
-                               $order = 
(isset($data['order'])?$data['order']:'');
-                               $voucher_id = 
(isset($data['voucher_id'])?$data['voucher_id']:0);
-                               $paid = (isset($data['paid'])?$data['paid']:'');
-                       }
-
-                       if ($paid)
-                       {
-                               $table = 'fm_ecobilagoverf';
-                       }
-                       else
-                       {
-                               $table ='fm_ecobilag';
-                       }
-
-
-                       if ($order)
-                       {
-                               $ordermethod = " order by $order $sort";
-                       }
-                       else
-                       {
-                               $ordermethod = ' order by bilagsnr DESC';
-                       }
-
-                       if ($voucher_id)
-                       {
-                               $filtermethod = " WHERE ( bilagsnr= 
'$voucher_id')";
-                       }
-
-                       $sql = "SELECT 
$table.*,fm_workorder.status,fm_workorder.charge_tenant ,org_name FROM (( 
$table $this->left_join "
-                       . "fm_workorder on fm_workorder.id = 
$table.pmwrkord_code ) $this->join "
-                       . "phpgw_addressbook  on $table.spvend_code = 
phpgw_addressbook.id ) $filtermethod ";
-
-                       $dbresult2 = $GLOBALS['phpgw']->db->Execute($sql);
-                       $this->total_records = $dbresult2->_numOfRows;
-                       $this->db->query($sql . $ordermethod,$start);
-
-                       $i = 0;
-
-                       while (!$dbresult->EOF)
-                       {
-                               $invoice[$i]['counter']                         
        = $i;
-                               $invoice[$i]['workorder_id']                    
= $dbresult->fields['pmwrkord_code'];
-                               $invoice[$i]['status']                          
        = $dbresult->fields['status'];
-                               if ($dbresult->fields['status']=='closed')
-                               {
-                                       $invoice[$i]['closed']                  
        = True;
-                               }
-                               $invoice[$i]['voucher_id']                      
        = $voucher_id;
-                               $invoice[$i]['id']                              
                = $dbresult->fields['id'];
-                               $invoice[$i]['invoice_id']                      
        = $dbresult->fields['fakturanr'];
-                               $invoice[$i]['budget_account']                  
= $dbresult->fields['spbudact_code'];
-                               $invoice[$i]['dima']                            
        = $dbresult->fields['dima'];
-                               $invoice[$i]['dimb']                            
        = $dbresult->fields['dimb'];
-                               $invoice[$i]['dimd']                            
        = $dbresult->fields['dimd'];
-                               if ($dbresult->fields['merknad'])
-                               {
-                                       $invoice[$i]['remark']                  
        = True;
-                               }
-                               $invoice[$i]['tax_code']                        
        = $dbresult->fields['mvakode'];
-                               $invoice[$i]['amount']                          
        = $dbresult->fields['belop'];
-                               $invoice[$i]['charge_tenant']                   
= $dbresult->fields['charge_tenant'];
-                               $invoice[$i]['vendor']                          
        = $dbresult->fields['org_name'];
-                               $i++;
-                               $dbresult->MoveNext();
-
-                       }
-
-                       return $invoice;
-
-               }
-
-
-               function read_consume($data)
-               {
-                       if(is_array($data))
-                       {
-                               if ($data['start'])
-                               {
-                                       $start=$data['start'];
-                               }
-                               else
-                               {
-                                       $start=0;
-                               }
-                               $filter                 = 
(isset($data['filter'])?$data['filter']:'none');
-                               $query                  = 
(isset($data['query'])?$data['query']:'');
-                               $sort                   = 
(isset($data['sort'])?$data['sort']:'DESC');
-                               $order                  = 
(isset($data['order'])?$data['order']:'');
-                               $cat_id                 = 
(isset($data['cat_id'])?$data['cat_id']:0);
-                               $start_date     = 
(isset($data['start_date'])?$data['start_date']:'');
-                               $end_date               = 
(isset($data['end_date'])?$data['end_date']:'');
-                               $vendor_id              = 
(isset($data['vendor_id'])?$data['vendor_id']:'');
-                               $loc1   = 
(isset($data['loc1'])?$data['loc1']:'');
-                               $district_id    = 
(isset($data['district_id'])?$data['district_id']:'');
-                               $workorder_id   = 
(isset($data['workorder_id'])?$data['workorder_id']:0);
-                               $b_account_class = 
(isset($data['b_account_class'])?$data['b_account_class']:'');
-                       }
-//html_print_r($data);
-
-                       $dateformat = 
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                       $dateformat = str_replace(".","",$dateformat);
-                       $dateformat = str_replace("-","",$dateformat);
-                       $dateformat = str_replace("/","",$dateformat);
-                       $y=strpos($dateformat,'y');
-                       $d=strpos($dateformat,'d');
-                       $m=strpos($dateformat,'m');
-                       $dateparts = explode('/', $start_date);
-                       $sday = $dateparts[$d];
-                       $smonth = $dateparts[$m];
-                       $syear = $dateparts[$y];
-
-                       $dateparts = explode('/', $end_date);
-                       $eday = $dateparts[$d];
-                       $emonth = $dateparts[$m];
-                       $eyear = $dateparts[$y];
-
-                       $start_date = 
date($this->bocommon->dateformat,mktime(2,0,0,$smonth,$sday,$syear));
-                       $end_date = 
date($this->bocommon->dateformat,mktime(2,0,0,$emonth,$eday,$eyear));
-
-
-                       $where = 'WHERE';
-
-                       if($b_account_class)
-                       {
-                               $filtermethod= " $where 
fm_b_account.grouping='$b_account_class'";
-                               $where= 'AND';
-                       }
-                       else
-                       {
-                               $select_account_class=',fm_b_account.grouping 
as b_account_class';
-                               $group_account_class=', 
spbudact_code,fm_b_account.grouping';
-                       }
-
-                       if ($vendor_id)
-                       {
-                               $filtermethod .= " $where (spvend_code = 
$vendor_id)";
-                               $where= 'AND';
-                       }
-
-                       if($loc1)
-                       {
-                               $filtermethod .=" $where (dima like '%$loc1%')";
-                               $where= 'AND';
-                       }
-
-
-                       if ($district_id)
-                       {
-                               $filtermethod.= " $where district_id= 
$district_id ";
-                               $where= 'AND';
-                       }
-
-                       if ($workorder_id)
-                       {
-                               $filtermethod.= " $where pmwrkord_code = 
$workorder_id";
-                               $where= 'AND';
-                       }
-
-
-                       if ($cat_id>0)
-                       {
-                               $filtermethod .= " $where typeid = $cat_id";
-                               $where= 'AND';
-                       }
-
-                       $filtermethod .= " $where (fakturadato >'$start_date') 
AND (fakturadato < '$end_date')";
-
-                       $sql = "SELECT district_id,periode,sum(godkjentbelop) 
as consume $select_account_class "
-                               . " FROM  fm_ecobilagoverf $this->join 
fm_location1 ON (fm_ecobilagoverf.loc1 = fm_location1.loc1) "
-                               . " $this->join fm_part_of_town ON 
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id) "
-                               . " $this->join fm_b_account ON 
(fm_ecobilagoverf.spbudact_code = fm_b_account.id) "
-                       . " $filtermethod group by district_id,periode 
$group_account_class";
-//echo $sql;
-
-                       $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
-                       $this->total_records = $this->db->num_rows();
-                       $this->db->query($sql . $ordermethod,$start);
-
-                       $i = 0;
-
-                       while (!$dbresult->EOF)
-                       {
-                               $consume[$i]['consume']                         
        = $dbresult->fields['consume'];
-                               $consume[$i]['period']                          
        = $dbresult->fields['periode'];
-                               $consume[$i]['district_id']                     
        = $dbresult->fields['district_id'];
-                               if(!$b_account_class)
-                               {
-                                       $consume[$i]['account_class']           
        = $dbresult->fields['b_account_class'];
-                               }
-                               else
-                               {
-                                       $consume[$i]['account_class']           
        = $b_account_class;
-                               }
-
-                               $i++;
-                               $dbresult->MoveNext();
-                       }
-//html_print_r($consume);
-                       return $consume;
-               }
-
-               function check_for_updates($values)
-               {
-                       $update=False;
-
-                       if($values['sign_orig']!=$values['sign'])
-                       {
-                               $update=True;
-                               return $update;
-                       }
-
-                       $sql = "SELECT * FROM fm_ecobilag WHERE bilagsnr=" . 
$values['voucher_id'];
-
-                       $dbresult = 
$GLOBALS['phpgw']->db->SelectLimit($sql,0,1);
-
-                       if( ($dbresult->fields['utbetalingsigndato'] && 
!$values['transfer']) || (!$dbresult->fields['utbetalingsigndato'] && 
$values['transfer']))
-                       {
-                               $update=True;
-                               return $update;
-                       }
-
-                       if( ($dbresult->fields['kreditnota'] && 
!$values['kreditnota']) || (!$dbresult->fields['kreditnota'] && 
$values['kreditnota']) )
-                       {
-                               $update=True;
-                               return $update;
-                       }
-
-                       $timestamp_voucher_date= 
mktime(0,0,0,date(m,strtotime($dbresult->fields['fakturadato'])),date(d,strtotime($dbresult->fields['fakturadato'])),date(y,strtotime($dbresult->fields['fakturadato'])));
-                       $timestamp_payment_date= 
mktime(0,0,0,date(m,strtotime($dbresult->fields['forfallsdato'])),date(d,strtotime($dbresult->fields['forfallsdato'])),date(y,strtotime($dbresult->fields['forfallsdato'])));
-
-                       if( 
((intval(($timestamp_payment_date-$timestamp_voucher_date)/(24*3600)))!=$values['num_days'])
 )
-                       {
-                               $update=True;
-                               return $update;
-                       }
-               }
-
-               function update_invoice_sub($values)
-               {
-
-                       $GLOBALS['phpgw']->db->begintrans();
-
-                       while($entry=each($values['counter']))
-                               {
-                                       $local_error='';
-
-                                       $n=$entry[0];
-
-
-//html_print_r($entry);
-
-
-                               if ($values['budget_account'][$n])
-                               {
-                                       
$budget_account=$values['budget_account'][$n];
-
-                                       $dbresult = 
$GLOBALS['phpgw']->db->Execute("SELECT count(*) from fm_b_account  where id 
=$budget_account");
-                                       if ($dbresult->fields[0] == 0)
-                                       {
-                                               $receipt['error'][] = 
array('msg'=> lang('This account is not valid:'). " ".$budget_account);
-                                               $local_error= true;
-                                       }
-                               }
-                               else
-                               {
-                                               $receipt['error'][] = 
array('msg'=>lang('Budget account is missing:'));
-                                               $local_error= true;
-                               }
-
-                               if(!$values['dimd'][$n])
-                               {
-                                       $dimd_field="dimd=NULL";
-                               }
-                               else
-                               {
-                                       $dimd=$values['dimd'][$n];
-                                       $dbresult = 
$GLOBALS['phpgw']->db->Execute("SELECT count(*) from  fm_dim_d where id 
=$dimd");
-                                       if ($dbresult->fields[0] == 0)
-                                       {
-                                               $receipt['error'][] = 
array('msg'=>lang('This Dim D is not valid:'). " ".$dimd);
-                                               $local_error= true;
-                                       }
-
-                                       $dimd_field="dimd="."'" . $dimd . "'";
-                               }
-
-                               if (!$values['dima'][$n])
-                               {
-                                       $dima_field="dima=NULL";
-                                       $receipt['error'][] = 
array('msg'=>lang('Dim A is missing'));
-                                       $local_error= true;
-                               }
-                               else
-                               {
-                                       
$dima_check=substr($values['dima'][$n],0,4);
-                                       $dbresult = 
$GLOBALS['phpgw']->db->Execute("SELECT count(*) from fm_location1 where loc1 = 
'$dima_check' ");
-                                       if ($dbresult->fields[0] == 0)
-                                       {
-                                               $receipt['error'][] = 
array('msg'=>lang('This Dim A is not valid:'). " ".$values['dima'][$n]);
-                                               $local_error= true;
-                                       }
-                                       settype($values['dima'][$n],"int");
-                                       $dima_field="dima="."'" . 
$values['dima'][$n] . "'";
-
-                               }
-
-                               if (! $local_error)
-                               {
-                                       $id                     = 
$values['id'][$n];
-                                       $tax_code       = 
$values['tax_code'][$n];
-                                       
$workorder_id=$values['workorder_id'][$n];
-                                       if($values['close_order'][$n])
-                                       {
-                                               
$update_status[$workorder_id]='X';
-                                       }
-
-                                       if(!$values['close_order'][$n] && 
$values['close_order_orig'][$n])
-                                       {
-                                               
$update_status[$workorder_id]='R';
-                                       }
-
-                                       $GLOBALS['phpgw']->db->query("update 
fm_ecobilag set $dima_field , $dimd_field, mvakode = '$tax_code',spbudact_code 
= '$budget_account' where id='$id'");
-
-                                       $receipt['message'][] = 
array('msg'=>lang('Voucher is updated '));
-                               }
-
-
-                       }
-
-                       if (isset($update_status) AND is_array($update_status))
-                       {
-                               
$status_code=array('X'=>'closed','R'=>'re_opened');
-
-                               $historylog_workorder   = 
CreateObject($this->currentapp.'_historylog','workorder');
-
-                               while (list($id,$entry) = each($update_status))
-                               {
-                                       
$historylog_workorder->add($entry,$id,$status_code[$entry]);
-                                       $GLOBALS['phpgw']->db->query("update 
fm_workorder set status=" . "'$status_code[$entry]'" . "where id=$id");
-                                       $receipt['message'][] = 
array('msg'=>lang('Workorder %1 is %2',$id, $status_code[$entry]));
-                               }
-                       }
-
-                       $GLOBALS['phpgw']->db->committrans();
-
-                       return $receipt;
-               }
-
-               function read_remark($id='',$paid='')
-               {
-                       if ($paid)
-                       {
-                               $table = 'fm_ecobilagoverf';
-                       }
-                       else
-                       {
-                               $table ='fm_ecobilag';
-                       }
-
-                       $this->db->query(" SELECT merknad from $table  where 
id= '$id'");
-
-
-                       return $dbresult->fields['merknad'];
-               }
-
-               function check_role()
-               {
-                       if(!$this->role)
-                       {
-                               $this->role=array(
-                                       'is_janitor'                            
=> $this->acl2->check('.invoice',32),
-                                       'is_supervisor'                         
=> $this->acl2->check('.invoice',64),
-                                       'is_budget_responsible'         => 
$this->acl2->check('.invoice',128),
-                                       'is_transfer'                           
=> $this->acl2->check('.invoice',16)
-                                       );
-                       }
-                       return $this->role;
-               }
-
-               function check_count($voucher_id)
-               {
-
-                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT 
count(dima) as dima_count , count(spbudact_code) as spbudact_code_count from 
fm_ecobilag where bilagsnr ='$voucher_id'");
-
-
-                       $check_count=array(
-                               'dima_count'                            => 
$dbresult->fields['dima_count'],
-                               'spbudact_code_count'           => 
$dbresult->fields['spbudact_code_count']
-                               );
-
-                       return $check_count;
-               }
-
-
-               function update_period($voucher_id='',$period='')
-               {
-                       $GLOBALS['phpgw']->db->begintrans();
-
-                       $GLOBALS['phpgw']->db->Execute("UPDATE fm_ecobilag set 
periode='$period' where bilagsnr='$voucher_id'");
-
-                       $GLOBALS['phpgw']->db->committrans();
-
-                       $receipt['message'][] = array('msg'=>lang('voucher 
period is updated'));
-                       return $receipt;
-               }
-
-
-               function increment_bilagsnr()
-               {
-
-                       $GLOBALS['phpgw']->db->Execute("UPDATE fm_idgenerator 
set value = value + 1 where name = 'Bilagsnummer'");
-                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT 
value from fm_idgenerator where name = 'Bilagsnummer'");
-
-                       $bilagsnr = $dbresult->fields['value'];
-                       return $bilagsnr;
-
-               }
-
-               function next_bilagsnr()
-               {
-
-                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT 
value from fm_idgenerator where name = 'Bilagsnummer'");
-
-                       $bilagsnr = $dbresult->fields['value']+1;
-
-                       return $bilagsnr;
-               }
-
-               function check_vendor($vendor_id)
-               {
-
-                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT 
count(*) from phpgw_addressbook where id='$vendor_id'");
-
-                       return $dbresult->fields[0];
-               }
-
-
-               function tax_code_list($selected='')
-               {
-                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT * 
FROM fm_ecomva order by id asc ");
-                       while (!$dbresult->EOF)
-                       {
-                               $tax_code_list[] = Array(
-                                       'id'        => $dbresult->fields['id'],
-                               );
-                               $dbresult->MoveNext();
-                       }
-
-                       return $tax_code_list;
-               }
-
-
-               function get_lisfm_ecoart()
-               {
-                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT * 
FROM fm_ecoart order by id asc ");
-                       while (!$dbresult->EOF)
-                       {
-                               $art_list[] = Array(
-                                       'id'        => $dbresult->fields['id'],
-                                       'num'       => $dbresult->fields['name']
-                               );
-                               $dbresult->MoveNext();
-                       }
-
-                       return $art_list;
-               }
-
-       //----------
-
-               function get_type_list()
-               {
-                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT * 
FROM fm_ecobilagtype order by id asc ");
-                       while (!$dbresult->EOF)
-                       {
-                               $art_list[] = Array(
-                                       'id'        => $dbresult->fields['id'],
-                                       'num'       => $dbresult->fields['name']
-                               );
-                               $dbresult->MoveNext();
-                       }
-                       return $art_list;
-               }
-
-       //----------
-               function select_dimb_list()
-               {
-                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT * 
FROM fm_ecodimb order by id asc ");
-                       while (!$dbresult->EOF)
-                       {
-                               $dimb_list[] = Array(
-                                       'id'        => $dbresult->fields['id'],
-                                       'num'       => $dbresult->fields['name']
-                               );
-                               $dbresult->MoveNext();
-                       }
-                       return $dimb_list;
-               }
-
-       //-------------------
-               function select_dimd_list()
-               {
-                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT * 
FROM fm_ecodimd order by id asc ");
-                       while (!$dbresult->EOF)
-                       {
-                               $dimd_list[] = Array(
-                                       'id'        => $dbresult->fields['id'],
-                                       'num'       => $dbresult->fields['name']
-                               );
-                               $dbresult->MoveNext();
-                       }
-                       return $dimd_list;
-               }
-       //---------------------
-
-               function select_tax_code_list()
-               {
-                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT * 
FROM fm_ecomva order by id asc ");
-                       while (!$dbresult->EOF)
-                       {
-                               $tax_code_list[] = Array(
-                                       'id'        => $dbresult->fields['id'],
-                                       'num'       => $dbresult->fields['name']
-                               );
-                               $dbresult->MoveNext();
-                       }
-                       return $tax_code_list;
-               }
-
-               function get_invoice_user_list()
-               {
-
-                       $sql = "SELECT * FROM fm_acl2 $this->join 
phpgw_accounts on phpgw_accounts.account_id=fm_acl2.acl_account where 
acl_location ='.invoice' and account_type='u' ";
-                       $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
-
-                       $employees[] = Array(
-                               'account_lid'       => 'all',
-                               'account_lastname'  => lang('All')
-                       );
-
-                       while (!$dbresult->EOF)
-                       {
-                               $employees[] = Array(
-                                       'account_id'        => 
$dbresult->fields['account_id'],
-                                       'account_lid'       => 
$dbresult->fields['account_lid'],
-                                       'account_type'      => 
$dbresult->fields['account_type'],
-                                       'account_firstname' => 
$dbresult->fields['account_firstname'],
-                                       'account_lastname'  => 
$dbresult->fields['account_lastname'],
-                                       'account_status'    => 
$dbresult->fields['account_status'],
-                                       'account_expires'   => 
$dbresult->fields['account_expires']
-                               );
-                               $dbresult->MoveNext();
-                       }
-//html_print_r($employees);
-                       return $employees;
-               }
-
-               function select_account_class()
-               {
-                       $sql = "SELECT DISTINCT grouping as id from 
fm_b_account ";
-                       $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
-
-                       while (!$dbresult->EOF)
-                       {
-                               $class[] = Array(
-                                       'id'        => $dbresult->fields['id']
-                               );
-                               $dbresult->MoveNext();
-                       }
-                       return $class;
-               }
-               function delete($bilagsnr)
-               {
-                       $GLOBALS['phpgw']->db->Execute("DELETE FROM fm_ecobilag 
WHERE bilagsnr ='" . $bilagsnr  ."'");
-               }
-
-
-       }
-?>
+<?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.                                            
   *
+       
\**************************************************************************/
+  /* $Id$ */
+
+       class property_soinvoice
+       {
+
+               function property_soinvoice()
+               {
+                       $this->db               = $GLOBALS['phpgw']->db;
+                       $this->db2              = $this->db;
+
+                       $this->currentapp       = 'property'; 
//$GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $this->bocommon         = 
CreateObject($this->currentapp.'_bocommon');
+                       $this->account_id       = 
$GLOBALS['phpgw_data']['user']['id'];
+                       $this->acl2             = 
CreateObject($this->currentapp.'_acl2','##DEFAULT##','##DEFAULT##');
+
+                       $this->join                     = $this->bocommon->join;
+                       $this->left_join        = $this->bocommon->left_join;
+
+               }
+
+
+               function read_invoice($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']:'');
+                               $cat_id                 = 
(isset($data['cat_id'])?$data['cat_id']:0);
+                               $user_lid               = 
(isset($data['user_lid'])?$data['user_lid']:'none');
+                               $paid                   = 
(isset($data['paid'])?$data['paid']:'');
+                               $start_date     = 
(isset($data['start_date'])?$data['start_date']:'');
+                               $end_date               = 
(isset($data['end_date'])?$data['end_date']:'');
+                               $vendor_id              = 
(isset($data['vendor_id'])?$data['vendor_id']:'');
+                               $loc1                   = 
(isset($data['loc1'])?$data['loc1']:'');
+                               $workorder_id   = 
(isset($data['workorder_id'])?$data['workorder_id']:'');
+                               $allrows                = 
(isset($data['allrows'])?$data['allrows']:'');
+                       }
+
+//html_print_r($data);
+
+                       if ($order)
+                       {
+                               $ordermethod = " order by $order $sort";
+                       }
+                       else
+                       {
+                               $ordermethod = ' order by bilagsnr DESC';
+                       }
+
+                       $where= 'WHERE';
+
+                       if ($user_lid=='none' || !$user_lid):
+                       {
+                               return;
+                       }
+                       elseif ($user_lid!='all'):
+                       {
+                               $filtermethod = " WHERE ( oppsynsmannid= 
'$user_lid' or saksbehandlerid= '$user_lid' or budsjettansvarligid= 
'$user_lid')";
+                               $where= 'AND';
+                       }
+                       endif;
+
+                       if ($cat_id > 0)
+                       {
+                               $filtermethod .= " $where typeid='$cat_id' ";
+                               $where= 'AND';
+                       }
+
+                       if ($district_id > 0)
+                       {
+                               $filtermethod .= " $where  
district_id='$district_id' ";
+                               $where= 'AND';
+                       }
+
+                       if ($vendor_id)
+                       {
+                               $filtermethod .= " $where  spvend_code 
='$vendor_id' ";
+                               $where= 'AND';
+                       }
+                       if ($loc1)
+                       {
+                               $filtermethod .= " $where  dima ='$loc1' ";
+                               $where= 'AND';
+                       }
+                       if ($workorder_id)
+                       {
+                               $filtermethod .= " $where  pmwrkord_code 
='$workorder_id' ";
+                               $where= 'AND';
+                       }
+
+
+                       if ($paid)
+                       {
+                               $table = 'fm_ecobilagoverf';
+                               $dateformat = 
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+                               $dateformat = str_replace(".","",$dateformat);
+                               $dateformat = str_replace("-","",$dateformat);
+                               $dateformat = str_replace("/","",$dateformat);
+                               $y=strpos($dateformat,'y');
+                               $d=strpos($dateformat,'d');
+                               $m=strpos($dateformat,'m');
+
+                               $dateparts = explode('/', $start_date);
+                               $sday = $dateparts[$d];
+                               $smonth = $dateparts[$m];
+                               $syear = $dateparts[$y];
+
+                               $dateparts = explode('/', $end_date);
+                               $eday = $dateparts[$d];
+                               $emonth = $dateparts[$m];
+                               $eyear = $dateparts[$y];
+
+                               $start_date = 
date($this->bocommon->dateformat,mktime(2,0,0,$smonth,$sday,$syear));
+                               $end_date = 
date($this->bocommon->dateformat,mktime(2,0,0,$emonth,$eday,$eyear));
+
+                               if (!$workorder_id)
+                               {
+                                       $filtermethod .= " $where  overftid 
>'$start_date' and overftid < '$end_date'";
+                               }
+                       }
+                       else
+                       {
+                               $table ='fm_ecobilag';
+                       }
+
+
+                       if($query)
+                       {
+                               $query = ereg_replace("'",'',$query);
+                               $query = ereg_replace('"','',$query);
+
+                               $querymethod = " $where ( spvend_code LIKE 
'%$query%' OR bilagsnr LIKE '%$query%' )";
+                       }
+
+
+                       $sql = "SELECT DISTINCT bilagsnr, count(bilagsnr) as 
invoice_count, sum(belop) as belop,spvend_code,fakturadato FROM  $table  
$filtermethod $querymethod group by bilagsnr,spvend_code,fakturadato ";
+                       $sql2 = "SELECT DISTINCT bilagsnr FROM  $table  
$filtermethod $querymethod";
+
+//echo $sql;
+                       $this->db2->query($sql2);
+                       $this->total_records = $dbresult2->_numOfRows;
+
+                       $maxmatchs = 15;
+
+                       if(!$allrows)
+                       {
+                               $dbresult = 
$GLOBALS['phpgw']->db->SelectLimit($sql . $ordermethod,$maxmatchs,$start);
+
+                       }
+                       else
+                       {
+                               $dbresult = $GLOBALS['phpgw']->db->Execute($sql 
. $ordermethod);
+                       }
+
+                       while (!$dbresult->EOF)
+                       {
+                               $temp[] = array
+                               (
+                                       'voucher_id'            => 
$dbresult->fields['bilagsnr'],
+                                       'invoice_count'         => 
$dbresult->fields['invoice_count'],
+                                       'amount'                        => 
$dbresult->fields['belop']
+                                       );
+                               $dbresult->MoveNext();
+                       }
+
+                       if ($temp)
+                       {
+                               $role= $this->check_role();
+                               $i = 0;
+                               foreach($temp as $invoice_temp)
+                               {
+                                       $voucher_id=$invoice_temp['voucher_id'];
+
+                                       $sql = "SELECT 
spvend_code,oppsynsmannid,saksbehandlerid,budsjettansvarligid,"
+                                       . " 
utbetalingid,oppsynsigndato,saksigndato,budsjettsigndato,utbetalingsigndato,fakturadato,org_name,"
+                                       . " 
forfallsdato,periode,artid,kidnr,kreditnota "
+                                       . " from $table $this->join 
phpgw_addressbook ON phpgw_addressbook.id = $table.spvend_code WHERE bilagsnr = 
$voucher_id "
+                                       . " group by 
bilagsnr,spvend_code,oppsynsmannid,saksbehandlerid,budsjettansvarligid,"
+                                       . " 
utbetalingid,oppsynsigndato,saksigndato,budsjettsigndato,utbetalingsigndato,fakturadato,org_name,"
+                                       . " 
forfallsdato,periode,artid,kidnr,kreditnota ";
+
+                                       $dbresult = 
$GLOBALS['phpgw']->db->Execute($sql);
+
+
+
+                                       $timestamp_voucher_date= 
mktime(0,0,0,date(m,strtotime($dbresult->fields['fakturadato'])),date(d,strtotime($dbresult->fields['fakturadato'])),date(y,strtotime($dbresult->fields['fakturadato'])));
+                                       $timestamp_payment_date= 
mktime(0,0,0,date(m,strtotime($dbresult->fields['forfallsdato'])),date(d,strtotime($dbresult->fields['forfallsdato'])),date(y,strtotime($dbresult->fields['forfallsdato'])));
+
+                                       if($dbresult->fields['oppsynsmannid'] 
&& $dbresult->fields['oppsynsigndato'])
+                                       {
+//                                             $timestamp_jan_date             
        = 
mktime(0,0,0,date(m,strtotime($dbresult->fields['oppsynsigndato'])),date(d,strtotime($dbresult->fields['oppsynsigndato'])),date(y,strtotime($dbresult->fields['oppsynsigndato'])));
+//                                             $invoice[$i]['jan_date']        
= 
$GLOBALS['phpgw']->common->show_date($timestamp_jan_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+                                               
$invoice[$i]['jan_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($dbresult->fields['oppsynsigndato']));
+                                       }
+                                       else
+                                       {
+                                               $invoice[$i]['jan_date']        
='';
+                                       }
+                                       if($dbresult->fields['saksbehandlerid'] 
&& $dbresult->fields['saksigndato'])
+                                       {
+//                                             $timestamp_super_date           
= 
mktime(0,0,0,date(m,strtotime($dbresult->fields['saksigndato'])),date(d,strtotime($dbresult->fields['saksigndato'])),date(y,strtotime($dbresult->fields['saksigndato'])));
+//                                             $invoice[$i]['super_date']      
= 
$GLOBALS['phpgw']->common->show_date($timestamp_super_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+                                               
$invoice[$i]['super_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($dbresult->fields['saksigndato']));
+                                       }
+                                       else
+                                       {
+                                               $invoice[$i]['super_date']      
='';
+                                       }
+
+                                       
if($dbresult->fields['budsjettansvarligid'] && 
$dbresult->fields['budsjettsigndato'])
+                                       {
+//                                                     $timestamp_budget_date  
        = 
mktime(0,0,0,date(m,strtotime($dbresult->fields['budsjettsigndato'])),date(d,strtotime($dbresult->fields['budsjettsigndato'])),date(y,strtotime($dbresult->fields['budsjettsigndato'])));
+//                                                     
$invoice[$i]['budget_date']     = 
$GLOBALS['phpgw']->common->show_date($timestamp_budget_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+                                                       
$invoice[$i]['budget_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($dbresult->fields['budsjettsigndato']));
+                                       }
+                                       else
+                                       {
+                                               $invoice[$i]['budget_date']     
='';
+                                       }
+
+                                       if($dbresult->fields['utbetalingid'] && 
$dbresult->fields['utbetalingsigndato'])
+                                       {
+//                                             $timestamp_transfer_date= 
mktime(0,0,0,date(m,strtotime($dbresult->fields['utbetalingsigndato'])),date(d,strtotime($dbresult->fields['utbetalingsigndato'])),date(y,strtotime($dbresult->fields['utbetalingsigndato'])));
+//                                             $invoice[$i]['transfer_date']   
                = 
$GLOBALS['phpgw']->common->show_date($timestamp_transfer_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+                                               
$invoice[$i]['transfer_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($dbresult->fields['utbetalingsigndato']));
+                                       }
+                                       else
+                                       {
+                                               $invoice[$i]['transfer_date']   
='';
+                                       }
+
+                                       $invoice[$i]['counter']                 
                = $i;
+                                       $invoice[$i]['current_user']            
        = strtoupper($GLOBALS['phpgw_info']['user']['account_lid']);
+                                       $invoice[$i]['voucher_id']              
                = $voucher_id;
+                                       $invoice[$i]['invoice_count']           
        = $invoice_temp['invoice_count'];
+                                       $invoice[$i]['vendor_id']               
                = $dbresult->fields['spvend_code'];
+                                       $invoice[$i]['vendor']                  
                = $dbresult->fields['org_name'];
+                                       $invoice[$i]['is_janitor']              
                = $role['is_janitor'];
+                                       $invoice[$i]['is_supervisor']           
        = $role['is_supervisor'];
+                                       $invoice[$i]['is_budget_responsible']   
= $role['is_budget_responsible'];
+                                       $invoice[$i]['is_janitor']              
                = $role['is_janitor'];
+                                       $invoice[$i]['is_transfer']             
                = $role['is_transfer'];
+                                       $invoice[$i]['janitor']                 
                = $dbresult->fields['oppsynsmannid'];
+                                       $invoice[$i]['supervisor']              
                = $dbresult->fields['saksbehandlerid'];
+                                       $invoice[$i]['budget_responsible']      
        = $dbresult->fields['budsjettansvarligid'];
+                                       $invoice[$i]['transfer_id']             
                = $dbresult->fields['utbetalingid'];
+                                       $invoice[$i]['voucher_date']            
        = 
$GLOBALS['phpgw']->common->show_date($timestamp_voucher_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+                                       $invoice[$i]['payment_date']            
        = 
$GLOBALS['phpgw']->common->show_date($timestamp_payment_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+                                       $invoice[$i]['period']                  
                = $dbresult->fields['periode'];
+                                       $invoice[$i]['type']                    
                = $dbresult->fields['artid'];
+                                       $invoice[$i]['kidnr']                   
                = $dbresult->fields['kidnr'];
+                                       $invoice[$i]['kreditnota']              
                = $dbresult->fields['kreditnota'];
+                                       $invoice[$i]['amount']                  
                = $invoice_temp['amount'];
+                                       $invoice[$i]['num_days']                
                = 
intval(($timestamp_payment_date-$timestamp_voucher_date)/(24*3600));
+                                       $invoice[$i]['timestamp_voucher_date']  
= $timestamp_voucher_date;
+
+                                       
if($invoice[$i]['current_user']==$invoice[$i]['janitor'] && 
$invoice[$i]['jan_date']):
+                                       {
+                                               
$invoice[$i]['sign_orig']='sign_janitor';
+                                       }
+                                       
elseif($invoice[$i]['current_user']==$invoice[$i]['supervisor'] && 
$invoice[$i]['super_date']):
+                                       {
+                                               
$invoice[$i]['sign_orig']='sign_supervisor';
+                                       }
+                                       
elseif($invoice[$i]['current_user']==$invoice[$i]['budget_responsible'] && 
$invoice[$i]['budget_date']):
+                                       {
+                                               
$invoice[$i]['sign_orig']='sign_budget_responsible';
+                                       }
+                                       endif;
+
+                                       $i++;
+
+                               }
+                       }
+//                     $end_time = explode(' ',microtime());
+//                     $this->end_time = $end_time;
+
+//html_print_r($invoice);
+//html_print_r($invoice_temp);
+
+                       return $invoice;
+
+               }
+
+
+               function read_invoice_sub($data)
+               {
+                       if(is_array($data))
+                       {
+                               if ($data['start'])
+                               {
+                                       $start=$data['start'];
+                               }
+                               else
+                               {
+                                       $start=0;
+                               }
+                               $filter = 
(isset($data['filter'])?$data['filter']:'none');
+                               $sort = 
(isset($data['sort'])?$data['sort']:'DESC');
+                               $order = 
(isset($data['order'])?$data['order']:'');
+                               $voucher_id = 
(isset($data['voucher_id'])?$data['voucher_id']:0);
+                               $paid = (isset($data['paid'])?$data['paid']:'');
+                       }
+
+                       if ($paid)
+                       {
+                               $table = 'fm_ecobilagoverf';
+                       }
+                       else
+                       {
+                               $table ='fm_ecobilag';
+                       }
+
+
+                       if ($order)
+                       {
+                               $ordermethod = " order by $order $sort";
+                       }
+                       else
+                       {
+                               $ordermethod = ' order by bilagsnr DESC';
+                       }
+
+                       if ($voucher_id)
+                       {
+                               $filtermethod = " WHERE ( bilagsnr= 
'$voucher_id')";
+                       }
+
+                       $sql = "SELECT 
$table.*,fm_workorder.status,fm_workorder.charge_tenant ,org_name FROM (( 
$table $this->left_join "
+                       . "fm_workorder on fm_workorder.id = 
$table.pmwrkord_code ) $this->join "
+                       . "phpgw_addressbook  on $table.spvend_code = 
phpgw_addressbook.id ) $filtermethod ";
+
+                       $dbresult2 = $GLOBALS['phpgw']->db->Execute($sql);
+                       $this->total_records = $dbresult2->_numOfRows;
+                       $this->db->query($sql . $ordermethod,$start);
+
+                       $i = 0;
+
+                       while (!$dbresult->EOF)
+                       {
+                               $invoice[$i]['counter']                         
        = $i;
+                               $invoice[$i]['workorder_id']                    
= $dbresult->fields['pmwrkord_code'];
+                               $invoice[$i]['status']                          
        = $dbresult->fields['status'];
+                               if ($dbresult->fields['status']=='closed')
+                               {
+                                       $invoice[$i]['closed']                  
        = True;
+                               }
+                               $invoice[$i]['voucher_id']                      
        = $voucher_id;
+                               $invoice[$i]['id']                              
                = $dbresult->fields['id'];
+                               $invoice[$i]['invoice_id']                      
        = $dbresult->fields['fakturanr'];
+                               $invoice[$i]['budget_account']                  
= $dbresult->fields['spbudact_code'];
+                               $invoice[$i]['dima']                            
        = $dbresult->fields['dima'];
+                               $invoice[$i]['dimb']                            
        = $dbresult->fields['dimb'];
+                               $invoice[$i]['dimd']                            
        = $dbresult->fields['dimd'];
+                               if ($dbresult->fields['merknad'])
+                               {
+                                       $invoice[$i]['remark']                  
        = True;
+                               }
+                               $invoice[$i]['tax_code']                        
        = $dbresult->fields['mvakode'];
+                               $invoice[$i]['amount']                          
        = $dbresult->fields['belop'];
+                               $invoice[$i]['charge_tenant']                   
= $dbresult->fields['charge_tenant'];
+                               $invoice[$i]['vendor']                          
        = $dbresult->fields['org_name'];
+                               $i++;
+                               $dbresult->MoveNext();
+
+                       }
+
+                       return $invoice;
+
+               }
+
+
+               function read_consume($data)
+               {
+                       if(is_array($data))
+                       {
+                               if ($data['start'])
+                               {
+                                       $start=$data['start'];
+                               }
+                               else
+                               {
+                                       $start=0;
+                               }
+                               $filter                 = 
(isset($data['filter'])?$data['filter']:'none');
+                               $query                  = 
(isset($data['query'])?$data['query']:'');
+                               $sort                   = 
(isset($data['sort'])?$data['sort']:'DESC');
+                               $order                  = 
(isset($data['order'])?$data['order']:'');
+                               $cat_id                 = 
(isset($data['cat_id'])?$data['cat_id']:0);
+                               $start_date     = 
(isset($data['start_date'])?$data['start_date']:'');
+                               $end_date               = 
(isset($data['end_date'])?$data['end_date']:'');
+                               $vendor_id              = 
(isset($data['vendor_id'])?$data['vendor_id']:'');
+                               $loc1   = 
(isset($data['loc1'])?$data['loc1']:'');
+                               $district_id    = 
(isset($data['district_id'])?$data['district_id']:'');
+                               $workorder_id   = 
(isset($data['workorder_id'])?$data['workorder_id']:0);
+                               $b_account_class = 
(isset($data['b_account_class'])?$data['b_account_class']:'');
+                       }
+//html_print_r($data);
+
+                       $dateformat = 
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+                       $dateformat = str_replace(".","",$dateformat);
+                       $dateformat = str_replace("-","",$dateformat);
+                       $dateformat = str_replace("/","",$dateformat);
+                       $y=strpos($dateformat,'y');
+                       $d=strpos($dateformat,'d');
+                       $m=strpos($dateformat,'m');
+                       $dateparts = explode('/', $start_date);
+                       $sday = $dateparts[$d];
+                       $smonth = $dateparts[$m];
+                       $syear = $dateparts[$y];
+
+                       $dateparts = explode('/', $end_date);
+                       $eday = $dateparts[$d];
+                       $emonth = $dateparts[$m];
+                       $eyear = $dateparts[$y];
+
+                       $start_date = 
date($this->bocommon->dateformat,mktime(2,0,0,$smonth,$sday,$syear));
+                       $end_date = 
date($this->bocommon->dateformat,mktime(2,0,0,$emonth,$eday,$eyear));
+
+
+                       $where = 'WHERE';
+
+                       if($b_account_class)
+                       {
+                               $filtermethod= " $where 
fm_b_account.grouping='$b_account_class'";
+                               $where= 'AND';
+                       }
+                       else
+                       {
+                               $select_account_class=',fm_b_account.grouping 
as b_account_class';
+                               $group_account_class=', 
spbudact_code,fm_b_account.grouping';
+                       }
+
+                       if ($vendor_id)
+                       {
+                               $filtermethod .= " $where (spvend_code = 
$vendor_id)";
+                               $where= 'AND';
+                       }
+
+                       if($loc1)
+                       {
+                               $filtermethod .=" $where (dima like '%$loc1%')";
+                               $where= 'AND';
+                       }
+
+
+                       if ($district_id)
+                       {
+                               $filtermethod.= " $where district_id= 
$district_id ";
+                               $where= 'AND';
+                       }
+
+                       if ($workorder_id)
+                       {
+                               $filtermethod.= " $where pmwrkord_code = 
$workorder_id";
+                               $where= 'AND';
+                       }
+
+
+                       if ($cat_id>0)
+                       {
+                               $filtermethod .= " $where typeid = $cat_id";
+                               $where= 'AND';
+                       }
+
+                       $filtermethod .= " $where (fakturadato >'$start_date') 
AND (fakturadato < '$end_date')";
+
+                       $sql = "SELECT district_id,periode,sum(godkjentbelop) 
as consume $select_account_class "
+                               . " FROM  fm_ecobilagoverf $this->join 
fm_location1 ON (fm_ecobilagoverf.loc1 = fm_location1.loc1) "
+                               . " $this->join fm_part_of_town ON 
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id) "
+                               . " $this->join fm_b_account ON 
(fm_ecobilagoverf.spbudact_code = fm_b_account.id) "
+                       . " $filtermethod group by district_id,periode 
$group_account_class";
+//echo $sql;
+
+                       $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
+                       $this->total_records = $this->db->num_rows();
+                       $this->db->query($sql . $ordermethod,$start);
+
+                       $i = 0;
+
+                       while (!$dbresult->EOF)
+                       {
+                               $consume[$i]['consume']                         
        = $dbresult->fields['consume'];
+                               $consume[$i]['period']                          
        = $dbresult->fields['periode'];
+                               $consume[$i]['district_id']                     
        = $dbresult->fields['district_id'];
+                               if(!$b_account_class)
+                               {
+                                       $consume[$i]['account_class']           
        = $dbresult->fields['b_account_class'];
+                               }
+                               else
+                               {
+                                       $consume[$i]['account_class']           
        = $b_account_class;
+                               }
+
+                               $i++;
+                               $dbresult->MoveNext();
+                       }
+//html_print_r($consume);
+                       return $consume;
+               }
+
+               function check_for_updates($values)
+               {
+                       $update=False;
+
+                       if($values['sign_orig']!=$values['sign'])
+                       {
+                               $update=True;
+                               return $update;
+                       }
+
+                       $sql = "SELECT * FROM fm_ecobilag WHERE bilagsnr=" . 
$values['voucher_id'];
+
+                       $dbresult = 
$GLOBALS['phpgw']->db->SelectLimit($sql,0,1);
+
+                       if( ($dbresult->fields['utbetalingsigndato'] && 
!$values['transfer']) || (!$dbresult->fields['utbetalingsigndato'] && 
$values['transfer']))
+                       {
+                               $update=True;
+                               return $update;
+                       }
+
+                       if( ($dbresult->fields['kreditnota'] && 
!$values['kreditnota']) || (!$dbresult->fields['kreditnota'] && 
$values['kreditnota']) )
+                       {
+                               $update=True;
+                               return $update;
+                       }
+
+                       $timestamp_voucher_date= 
mktime(0,0,0,date(m,strtotime($dbresult->fields['fakturadato'])),date(d,strtotime($dbresult->fields['fakturadato'])),date(y,strtotime($dbresult->fields['fakturadato'])));
+                       $timestamp_payment_date= 
mktime(0,0,0,date(m,strtotime($dbresult->fields['forfallsdato'])),date(d,strtotime($dbresult->fields['forfallsdato'])),date(y,strtotime($dbresult->fields['forfallsdato'])));
+
+                       if( 
((intval(($timestamp_payment_date-$timestamp_voucher_date)/(24*3600)))!=$values['num_days'])
 )
+                       {
+                               $update=True;
+                               return $update;
+                       }
+               }
+
+               function update_invoice_sub($values)
+               {
+
+                       $GLOBALS['phpgw']->db->begintrans();
+
+                       while($entry=each($values['counter']))
+                               {
+                                       $local_error='';
+
+                                       $n=$entry[0];
+
+
+//html_print_r($entry);
+
+
+                               if ($values['budget_account'][$n])
+                               {
+                                       
$budget_account=$values['budget_account'][$n];
+
+                                       $dbresult = 
$GLOBALS['phpgw']->db->Execute("SELECT count(*) from fm_b_account  where id 
=$budget_account");
+                                       if ($dbresult->fields[0] == 0)
+                                       {
+                                               $receipt['error'][] = 
array('msg'=> lang('This account is not valid:'). " ".$budget_account);
+                                               $local_error= true;
+                                       }
+                               }
+                               else
+                               {
+                                               $receipt['error'][] = 
array('msg'=>lang('Budget account is missing:'));
+                                               $local_error= true;
+                               }
+
+                               if(!$values['dimd'][$n])
+                               {
+                                       $dimd_field="dimd=NULL";
+                               }
+                               else
+                               {
+                                       $dimd=$values['dimd'][$n];
+                                       $dbresult = 
$GLOBALS['phpgw']->db->Execute("SELECT count(*) from  fm_dim_d where id 
=$dimd");
+                                       if ($dbresult->fields[0] == 0)
+                                       {
+                                               $receipt['error'][] = 
array('msg'=>lang('This Dim D is not valid:'). " ".$dimd);
+                                               $local_error= true;
+                                       }
+
+                                       $dimd_field="dimd="."'" . $dimd . "'";
+                               }
+
+                               if (!$values['dima'][$n])
+                               {
+                                       $dima_field="dima=NULL";
+                                       $receipt['error'][] = 
array('msg'=>lang('Dim A is missing'));
+                                       $local_error= true;
+                               }
+                               else
+                               {
+                                       
$dima_check=substr($values['dima'][$n],0,4);
+                                       $dbresult = 
$GLOBALS['phpgw']->db->Execute("SELECT count(*) from fm_location1 where loc1 = 
'$dima_check' ");
+                                       if ($dbresult->fields[0] == 0)
+                                       {
+                                               $receipt['error'][] = 
array('msg'=>lang('This Dim A is not valid:'). " ".$values['dima'][$n]);
+                                               $local_error= true;
+                                       }
+                                       settype($values['dima'][$n],"int");
+                                       $dima_field="dima="."'" . 
$values['dima'][$n] . "'";
+
+                               }
+
+                               if (! $local_error)
+                               {
+                                       $id                     = 
$values['id'][$n];
+                                       $tax_code       = 
$values['tax_code'][$n];
+                                       
$workorder_id=$values['workorder_id'][$n];
+                                       if($values['close_order'][$n])
+                                       {
+                                               
$update_status[$workorder_id]='X';
+                                       }
+
+                                       if(!$values['close_order'][$n] && 
$values['close_order_orig'][$n])
+                                       {
+                                               
$update_status[$workorder_id]='R';
+                                       }
+
+                                       $GLOBALS['phpgw']->db->query("update 
fm_ecobilag set $dima_field , $dimd_field, mvakode = '$tax_code',spbudact_code 
= '$budget_account' where id='$id'");
+
+                                       $receipt['message'][] = 
array('msg'=>lang('Voucher is updated '));
+                               }
+
+
+                       }
+
+                       if (isset($update_status) AND is_array($update_status))
+                       {
+                               
$status_code=array('X'=>'closed','R'=>'re_opened');
+
+                               $historylog_workorder   = 
CreateObject($this->currentapp.'_historylog','workorder');
+
+                               while (list($id,$entry) = each($update_status))
+                               {
+                                       
$historylog_workorder->add($entry,$id,$status_code[$entry]);
+                                       $GLOBALS['phpgw']->db->query("update 
fm_workorder set status=" . "'$status_code[$entry]'" . "where id=$id");
+                                       $receipt['message'][] = 
array('msg'=>lang('Workorder %1 is %2',$id, $status_code[$entry]));
+                               }
+                       }
+
+                       $GLOBALS['phpgw']->db->committrans();
+
+                       return $receipt;
+               }
+
+               function read_remark($id='',$paid='')
+               {
+                       if ($paid)
+                       {
+                               $table = 'fm_ecobilagoverf';
+                       }
+                       else
+                       {
+                               $table ='fm_ecobilag';
+                       }
+
+                       $this->db->query(" SELECT merknad from $table  where 
id= '$id'");
+
+
+                       return $dbresult->fields['merknad'];
+               }
+
+               function check_role()
+               {
+                       if(!$this->role)
+                       {
+                               $this->role=array(
+                                       'is_janitor'                            
=> $this->acl2->check('.invoice',32),
+                                       'is_supervisor'                         
=> $this->acl2->check('.invoice',64),
+                                       'is_budget_responsible'         => 
$this->acl2->check('.invoice',128),
+                                       'is_transfer'                           
=> $this->acl2->check('.invoice',16)
+                                       );
+                       }
+                       return $this->role;
+               }
+
+               function check_count($voucher_id)
+               {
+
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT 
count(dima) as dima_count , count(spbudact_code) as spbudact_code_count from 
fm_ecobilag where bilagsnr ='$voucher_id'");
+
+
+                       $check_count=array(
+                               'dima_count'                            => 
$dbresult->fields['dima_count'],
+                               'spbudact_code_count'           => 
$dbresult->fields['spbudact_code_count']
+                               );
+
+                       return $check_count;
+               }
+
+
+               function update_period($voucher_id='',$period='')
+               {
+                       $GLOBALS['phpgw']->db->begintrans();
+
+                       $GLOBALS['phpgw']->db->Execute("UPDATE fm_ecobilag set 
periode='$period' where bilagsnr='$voucher_id'");
+
+                       $GLOBALS['phpgw']->db->committrans();
+
+                       $receipt['message'][] = array('msg'=>lang('voucher 
period is updated'));
+                       return $receipt;
+               }
+
+
+               function increment_bilagsnr()
+               {
+
+                       $GLOBALS['phpgw']->db->Execute("UPDATE fm_idgenerator 
set value = value + 1 where name = 'Bilagsnummer'");
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT 
value from fm_idgenerator where name = 'Bilagsnummer'");
+
+                       $bilagsnr = $dbresult->fields['value'];
+                       return $bilagsnr;
+
+               }
+
+               function next_bilagsnr()
+               {
+
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT 
value from fm_idgenerator where name = 'Bilagsnummer'");
+
+                       $bilagsnr = $dbresult->fields['value']+1;
+
+                       return $bilagsnr;
+               }
+
+               function check_vendor($vendor_id)
+               {
+
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT 
count(*) from phpgw_addressbook where id='$vendor_id'");
+
+                       return $dbresult->fields[0];
+               }
+
+
+               function tax_code_list($selected='')
+               {
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT * 
FROM fm_ecomva order by id asc ");
+                       while (!$dbresult->EOF)
+                       {
+                               $tax_code_list[] = Array(
+                                       'id'        => $dbresult->fields['id'],
+                               );
+                               $dbresult->MoveNext();
+                       }
+
+                       return $tax_code_list;
+               }
+
+
+               function get_lisfm_ecoart()
+               {
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT * 
FROM fm_ecoart order by id asc ");
+                       while (!$dbresult->EOF)
+                       {
+                               $art_list[] = Array(
+                                       'id'        => $dbresult->fields['id'],
+                                       'num'       => $dbresult->fields['name']
+                               );
+                               $dbresult->MoveNext();
+                       }
+
+                       return $art_list;
+               }
+
+       //----------
+
+               function get_type_list()
+               {
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT * 
FROM fm_ecobilagtype order by id asc ");
+                       while (!$dbresult->EOF)
+                       {
+                               $art_list[] = Array(
+                                       'id'        => $dbresult->fields['id'],
+                                       'num'       => $dbresult->fields['name']
+                               );
+                               $dbresult->MoveNext();
+                       }
+                       return $art_list;
+               }
+
+       //----------
+               function select_dimb_list()
+               {
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT * 
FROM fm_ecodimb order by id asc ");
+                       while (!$dbresult->EOF)
+                       {
+                               $dimb_list[] = Array(
+                                       'id'        => $dbresult->fields['id'],
+                                       'num'       => $dbresult->fields['name']
+                               );
+                               $dbresult->MoveNext();
+                       }
+                       return $dimb_list;
+               }
+
+       //-------------------
+               function select_dimd_list()
+               {
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT * 
FROM fm_ecodimd order by id asc ");
+                       while (!$dbresult->EOF)
+                       {
+                               $dimd_list[] = Array(
+                                       'id'        => $dbresult->fields['id'],
+                                       'num'       => $dbresult->fields['name']
+                               );
+                               $dbresult->MoveNext();
+                       }
+                       return $dimd_list;
+               }
+       //---------------------
+
+               function select_tax_code_list()
+               {
+                       $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT * 
FROM fm_ecomva order by id asc ");
+                       while (!$dbresult->EOF)
+                       {
+                               $tax_code_list[] = Array(
+                                       'id'        => $dbresult->fields['id'],
+                                       'num'       => $dbresult->fields['name']
+                               );
+                               $dbresult->MoveNext();
+                       }
+                       return $tax_code_list;
+               }
+
+               function get_invoice_user_list()
+               {
+
+                       $sql = "SELECT * FROM fm_acl2 $this->join 
phpgw_accounts on phpgw_accounts.account_id=fm_acl2.acl_account where 
acl_location ='.invoice' and account_type='u' ";
+                       $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
+
+                       $employees[] = Array(
+                               'account_lid'       => 'all',
+                               'account_lastname'  => lang('All')
+                       );
+
+                       while (!$dbresult->EOF)
+                       {
+                               $employees[] = Array(
+                                       'account_id'        => 
$dbresult->fields['account_id'],
+                                       'account_lid'       => 
$dbresult->fields['account_lid'],
+                                       'account_type'      => 
$dbresult->fields['account_type'],
+                                       'account_firstname' => 
$dbresult->fields['account_firstname'],
+                                       'account_lastname'  => 
$dbresult->fields['account_lastname'],
+                                       'account_status'    => 
$dbresult->fields['account_status'],
+                                       'account_expires'   => 
$dbresult->fields['account_expires']
+                               );
+                               $dbresult->MoveNext();
+                       }
+//html_print_r($employees);
+                       return $employees;
+               }
+
+               function select_account_class()
+               {
+                       $sql = "SELECT DISTINCT grouping as id from 
fm_b_account ";
+                       $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
+
+                       while (!$dbresult->EOF)
+                       {
+                               $class[] = Array(
+                                       'id'        => $dbresult->fields['id']
+                               );
+                               $dbresult->MoveNext();
+                       }
+                       return $class;
+               }
+               function delete($bilagsnr)
+               {
+                       $GLOBALS['phpgw']->db->Execute("DELETE FROM fm_ecobilag 
WHERE bilagsnr ='" . $bilagsnr  ."'");
+               }
+
+
+       }
+?>




reply via email to

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