fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11686] property: formatting


From: Sigurd Nes
Subject: [Fmsystem-commits] [11686] property: formatting
Date: Thu, 13 Feb 2014 13:14:39 +0000

Revision: 11686
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11686
Author:   sigurdne
Date:     2014-02-13 13:14:38 +0000 (Thu, 13 Feb 2014)
Log Message:
-----------
property: formatting

Modified Paths:
--------------
    trunk/property/inc/class.soinvoice.inc.php

Modified: trunk/property/inc/class.soinvoice.inc.php
===================================================================
--- trunk/property/inc/class.soinvoice.inc.php  2014-02-13 12:22:30 UTC (rev 
11685)
+++ trunk/property/inc/class.soinvoice.inc.php  2014-02-13 13:14:38 UTC (rev 
11686)
@@ -34,22 +34,22 @@
        class property_soinvoice
        {
 
-               public $total_records = 0;
-               public $sum_amount = 0;
-               public $role = array();
-               protected $invoice_approval = 2;
+               public $total_records            = 0;
+               public $sum_amount                       = 0;
+               public $role                             = array();
+               protected $invoice_approval      = 2;
 
                function __construct()
                {
-                       $this->account_id = 
$GLOBALS['phpgw_info']['user']['account_id'];
-                       $this->acl = & $GLOBALS['phpgw']->acl;
-                       $this->db = & $GLOBALS['phpgw']->db;
-                       $this->join = & $this->db->join;
-                       $this->left_join = & $this->db->left_join;
-                       $this->like = & $this->db->like;
-                       $this->config = CreateObject('phpgwapi.config', 
'property');
+                       $this->account_id                = 
$GLOBALS['phpgw_info']['user']['account_id'];
+                       $this->acl                               = & 
$GLOBALS['phpgw']->acl;
+                       $this->db                                = & 
$GLOBALS['phpgw']->db;
+                       $this->join                              = & 
$this->db->join;
+                       $this->left_join                 = & 
$this->db->left_join;
+                       $this->like                              = & 
$this->db->like;
+                       $this->config                    = 
CreateObject('phpgwapi.config', 'property');
                        $this->config->read();
-                       $this->invoice_approval = 
isset($this->config->config_data['invoice_approval']) && 
$this->config->config_data['invoice_approval'] ? 
$this->config->config_data['invoice_approval'] : 2;
+                       $this->invoice_approval  = 
isset($this->config->config_data['invoice_approval']) && 
$this->config->config_data['invoice_approval'] ? 
$this->config->config_data['invoice_approval'] : 2;
                }
 
                function read_invoice($data)
@@ -65,29 +65,29 @@
                                'periode'                        => true
                        );
 
-                       $start = isset($data['start']) && $data['start'] ? 
$data['start'] : 0;
-                       $query = isset($data['query']) ? $data['query'] : '';
-                       $sort = isset($data['sort']) && $data['sort'] ? 
$data['sort'] : 'DESC';
-                       $order = isset($data['order']) && 
$valid_order[$data['order']] ? $data['order'] : '';
-                       $cat_id = isset($data['cat_id']) && $data['cat_id'] ? 
$data['cat_id'] : 0;
-                       $user_lid = isset($data['user_lid']) && 
$data['user_lid'] ? $data['user_lid'] : 'none';
-                       $paid = isset($data['paid']) ? $data['paid'] : '';
-                       $start_date = isset($data['start_date']) && 
$data['start_date'] ? $data['start_date'] : mktime(0, 0, 0, '01', '01', 
date('Y'));
-                       $end_date = isset($data['end_date']) && 
$data['end_date'] ? $data['end_date'] : time();
-                       $vendor_id = isset($data['vendor_id']) ? 
$data['vendor_id'] : '';
-                       $loc1 = isset($data['loc1']) ? $data['loc1'] : '';
-                       $workorder_id = isset($data['workorder_id']) ? 
$data['workorder_id'] : '';
-                       $project_id = isset($data['project_id']) ? 
$data['project_id'] : '';
-                       $allrows = isset($data['allrows']) ? $data['allrows'] : 
'';
-                       $voucher_id = isset($data['voucher_id']) ? 
$data['voucher_id'] : '';
+                       $start                   = isset($data['start']) && 
$data['start'] ? $data['start'] : 0;
+                       $query                   = isset($data['query']) ? 
$data['query'] : '';
+                       $sort                    = isset($data['sort']) && 
$data['sort'] ? $data['sort'] : 'DESC';
+                       $order                   = isset($data['order']) && 
$valid_order[$data['order']] ? $data['order'] : '';
+                       $cat_id                  = isset($data['cat_id']) && 
$data['cat_id'] ? $data['cat_id'] : 0;
+                       $user_lid                = isset($data['user_lid']) && 
$data['user_lid'] ? $data['user_lid'] : 'none';
+                       $paid                    = isset($data['paid']) ? 
$data['paid'] : '';
+                       $start_date              = isset($data['start_date']) 
&& $data['start_date'] ? $data['start_date'] : mktime(0, 0, 0, '01', '01', 
date('Y'));
+                       $end_date                = isset($data['end_date']) && 
$data['end_date'] ? $data['end_date'] : time();
+                       $vendor_id               = isset($data['vendor_id']) ? 
$data['vendor_id'] : '';
+                       $loc1                    = isset($data['loc1']) ? 
$data['loc1'] : '';
+                       $workorder_id    = isset($data['workorder_id']) ? 
$data['workorder_id'] : '';
+                       $project_id              = isset($data['project_id']) ? 
$data['project_id'] : '';
+                       $allrows                 = isset($data['allrows']) ? 
$data['allrows'] : '';
+                       $voucher_id              = isset($data['voucher_id']) ? 
$data['voucher_id'] : '';
                        $b_account_class = isset($data['b_account_class']) ? 
$data['b_account_class'] : '';
-                       $district_id = isset($data['district_id']) ? 
$data['district_id'] : '';
-                       $invoice_id = $data['invoice_id'] ? $data['invoice_id'] 
: '';
-                       $ecodimb = isset($data['ecodimb']) ? $data['ecodimb'] : 
'';
+                       $district_id     = isset($data['district_id']) ? 
$data['district_id'] : '';
+                       $invoice_id              = $data['invoice_id'] ? 
$data['invoice_id'] : '';
+                       $ecodimb                 = isset($data['ecodimb']) ? 
$data['ecodimb'] : '';
 
-                       $join_tables = '';
-                       $filtermethod = '';
-                       $querymethod = '';
+                       $join_tables     = '';
+                       $filtermethod    = '';
+                       $querymethod     = '';
 
                        $this->db->query("SELECT * FROM fm_ecoart");
                        $art_list = array();
@@ -113,8 +113,8 @@
                        }
                        else if($user_lid != 'all')
                        {
-                               $filtermethod = " WHERE ( oppsynsmannid= 
'$user_lid' or saksbehandlerid= '$user_lid' or budsjettansvarligid= 
'$user_lid')";
-                               $where = 'AND';
+                               $filtermethod    = " WHERE ( oppsynsmannid= 
'$user_lid' or saksbehandlerid= '$user_lid' or budsjettansvarligid= 
'$user_lid')";
+                               $where                   = 'AND';
                        }
 
                        if($cat_id > 0)
@@ -134,7 +134,7 @@
                                $filtermethod .= " $where  
district_id='$district_id' ";
                                $join_tables = " $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)";
-                               $where = 'AND';
+                               $where           = 'AND';
                        }
 
                        if($vendor_id)
@@ -167,8 +167,8 @@
 
                                if(!$workorder_id && !$voucher_id && 
!$invoice_id)
                                {
-                                       $start_periode = date('Ym', 
$start_date);
-                                       $end_periode = date('Ym', $end_date);
+                                       $start_periode   = date('Ym', 
$start_date);
+                                       $end_periode     = date('Ym', 
$end_date);
 
                                        $filtermethod .= " $where (periode 
>='$start_periode' AND periode <= '$end_periode')";
                                        $where = 'AND';
@@ -182,14 +182,14 @@
                        $no_q = false;
                        if($voucher_id)
                        {
-                               $filtermethod = " WHERE bilagsnr = " . (int) 
$voucher_id . " OR bilagsnr_ut = '{$voucher_id}'";// OR spvend_code = ". 
(int)$query;
-                               $no_q = true;
+                               $filtermethod    = " WHERE bilagsnr = " . (int) 
$voucher_id . " OR bilagsnr_ut = '{$voucher_id}'";// OR spvend_code = ". 
(int)$query;
+                               $no_q                    = true;
                        }
 
                        if($workorder_id)
                        {
-                               $filtermethod = " WHERE pmwrkord_code 
='$workorder_id' ";
-                               $no_q = true;
+                               $filtermethod    = " WHERE pmwrkord_code 
='$workorder_id' ";
+                               $no_q                    = true;
                        }
                        else if($project_id)
                        {
@@ -200,39 +200,39 @@
                                        $_workorders[] = $this->db->f('id');
                                }
 
-                               $filtermethod = ' WHERE pmwrkord_code IN (' . 
implode(',', $_workorders) . ')';
+                               $filtermethod    = ' WHERE pmwrkord_code IN (' 
. implode(',', $_workorders) . ')';
                                $filtermethod .= " AND (periode 
>='$start_periode' AND periode <= '$end_periode')";
-                               $no_q = true;
+                               $no_q                    = true;
                        }
 
                        if($query && !$no_q)
                        {
-                               $query = (int) $query;
+                               $query           = (int) $query;
                                $querymethod = " $where ( spvend_code = 
{$query} OR bilagsnr = {$query})";
                        }
 
 
-                       $sql = "SELECT bilagsnr, bilagsnr_ut, count(bilagsnr) 
as invoice_count, sum(belop) as belop, sum(godkjentbelop) as 
godkjentbelop,spvend_code,fakturadato FROM  $table $join_tables $filtermethod 
$querymethod GROUP BY periode, 
bilagsnr,bilagsnr_ut,spvend_code,fakturadato,oppsynsigndato,saksigndato,budsjettsigndato";
-                       $sql2 = "SELECT DISTINCT bilagsnr FROM  $table 
$join_tables $filtermethod $querymethod";
+                       $sql     = "SELECT bilagsnr, bilagsnr_ut, 
count(bilagsnr) as invoice_count, sum(belop) as belop, sum(godkjentbelop) as 
godkjentbelop,spvend_code,fakturadato FROM  $table $join_tables $filtermethod 
$querymethod GROUP BY periode, 
bilagsnr,bilagsnr_ut,spvend_code,fakturadato,oppsynsigndato,saksigndato,budsjettsigndato";
+                       $sql2    = "SELECT DISTINCT bilagsnr FROM  $table 
$join_tables $filtermethod $querymethod";
 
                        if($GLOBALS['phpgw_info']['server']['db_type'] == 
'postgres')
                        {
-                               $sql_count = 'SELECT count(bilagsnr) as cnt, 
sum(godkjentbelop) AS sum_amount FROM (SELECT DISTINCT bilagsnr, 
sum(godkjentbelop) as godkjentbelop ' . substr($sql2, strripos($sql2, 'FROM')) 
. ' GROUP BY bilagsnr) AS t';
+                               $sql_count                       = 'SELECT 
count(bilagsnr) as cnt, sum(godkjentbelop) AS sum_amount FROM (SELECT DISTINCT 
bilagsnr, sum(godkjentbelop) as godkjentbelop ' . substr($sql2, strripos($sql2, 
'FROM')) . ' GROUP BY bilagsnr) AS t';
                                //_debug_array($sql_count);
                                $this->db->query($sql_count, __LINE__, 
__FILE__);
                                $this->db->next_record();
                                $this->total_records = $this->db->f('cnt');
-                               $this->sum_amount = $this->db->f('sum_amount');
+                               $this->sum_amount        = 
$this->db->f('sum_amount');
                        }
                        else
                        {
                                $this->db->query($sql2, __LINE__, __FILE__);
                                $this->total_records = $this->db->num_rows();
 
-                               $sql3 = "SELECT sum(godkjentbelop) as 
sum_amount FROM $table $join_tables $filtermethod $querymethod";
+                               $sql3                            = "SELECT 
sum(godkjentbelop) as sum_amount FROM $table $join_tables $filtermethod 
$querymethod";
                                $this->db->query($sql3, __LINE__, __FILE__);
                                $this->db->next_record();
-                               $this->sum_amount = $this->db->f('sum_amount');
+                               $this->sum_amount        = 
$this->db->f('sum_amount');
                        }
 
                        if(!$allrows)
@@ -261,8 +261,8 @@
 
                        if($temp)
                        {
-                               $role = $this->check_role();
-                               $i = 0;
+                               $role    = $this->check_role();
+                               $i               = 0;
                                foreach($temp as $invoice_temp)
                                {
                                        $voucher_id = 
$invoice_temp['voucher_id'];
@@ -279,8 +279,8 @@
 
                                        $this->db->next_record();
 
-                                       $timestamp_voucher_date = mktime(0, 0, 
0, date('m', strtotime($this->db->f('fakturadato'))), date('d', 
strtotime($this->db->f('fakturadato'))), date('y', 
strtotime($this->db->f('fakturadato'))));
-                                       $timestamp_payment_date = mktime(0, 0, 
0, date('m', strtotime($this->db->f('forfallsdato'))), date('d', 
strtotime($this->db->f('forfallsdato'))), date('y', 
strtotime($this->db->f('forfallsdato'))));
+                                       $timestamp_voucher_date  = mktime(0, 0, 
0, date('m', strtotime($this->db->f('fakturadato'))), date('d', 
strtotime($this->db->f('fakturadato'))), date('y', 
strtotime($this->db->f('fakturadato'))));
+                                       $timestamp_payment_date  = mktime(0, 0, 
0, date('m', strtotime($this->db->f('forfallsdato'))), date('d', 
strtotime($this->db->f('forfallsdato'))), date('y', 
strtotime($this->db->f('forfallsdato'))));
 
                                        if($this->db->f('oppsynsmannid') && 
$this->db->f('oppsynsigndato'))
                                        {
@@ -317,36 +317,36 @@
                                                $invoice[$i]['transfer_date'] = 
'';
                                        }
 
-                                       $invoice[$i]['counter'] = $i;
-                                       $invoice[$i]['current_user'] = 
$GLOBALS['phpgw_info']['user']['account_lid'];
-                                       $invoice[$i]['voucher_id'] = 
$voucher_id;
-                                       $invoice[$i]['voucher_out_id'] = 
$invoice_temp['voucher_out_id'];
-                                       $invoice[$i]['invoice_count'] = 
$invoice_temp['invoice_count'];
-                                       $invoice[$i]['vendor_id'] = 
$this->db->f('spvend_code');
-                                       $invoice[$i]['vendor'] = 
$this->db->f('org_name', true);
-                                       $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_transfer'] = 
$role['is_transfer'];
-                                       $invoice[$i]['janitor'] = 
$this->db->f('oppsynsmannid');
-                                       $invoice[$i]['supervisor'] = 
$this->db->f('saksbehandlerid');
-                                       $invoice[$i]['budget_responsible'] = 
$this->db->f('budsjettansvarligid');
-                                       $invoice[$i]['transfer_id'] = 
$this->db->f('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'] = 
$this->db->f('periode');
-                                       $invoice[$i]['periodization'] = 
$this->db->f('periodization');
-                                       $invoice[$i]['periodization_start'] = 
$this->db->f('periodization_start');
+                                       $invoice[$i]['counter']                 
                 = $i;
+                                       $invoice[$i]['current_user']            
         = $GLOBALS['phpgw_info']['user']['account_lid'];
+                                       $invoice[$i]['voucher_id']              
                 = $voucher_id;
+                                       $invoice[$i]['voucher_out_id']          
         = $invoice_temp['voucher_out_id'];
+                                       $invoice[$i]['invoice_count']           
         = $invoice_temp['invoice_count'];
+                                       $invoice[$i]['vendor_id']               
                 = $this->db->f('spvend_code');
+                                       $invoice[$i]['vendor']                  
                 = $this->db->f('org_name', true);
+                                       $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_transfer']             
                 = $role['is_transfer'];
+                                       $invoice[$i]['janitor']                 
                 = $this->db->f('oppsynsmannid');
+                                       $invoice[$i]['supervisor']              
                 = $this->db->f('saksbehandlerid');
+                                       $invoice[$i]['budget_responsible']      
         = $this->db->f('budsjettansvarligid');
+                                       $invoice[$i]['transfer_id']             
                 = $this->db->f('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']                  
                 = $this->db->f('periode');
+                                       $invoice[$i]['periodization']           
         = $this->db->f('periodization');
+                                       $invoice[$i]['periodization_start']     
         = $this->db->f('periodization_start');
 
-                                       $invoice[$i]['type'] = 
$art_list[$this->db->f('artid')];
-                                       $invoice[$i]['kidnr'] = 
$this->db->f('kidnr');
-                                       $invoice[$i]['kreditnota'] = 
$this->db->f('kreditnota');
-                                       $invoice[$i]['currency'] = 
$this->db->f('currency');
-                                       $invoice[$i]['order_id'] = 
$this->db->f('pmwrkord_code');
-                                       $invoice[$i]['amount'] = 
$invoice_temp['amount'];
-                                       $invoice[$i]['approved_amount'] = 
$invoice_temp['approved_amount'];
-                                       $invoice[$i]['num_days'] = 
intval(($timestamp_payment_date - $timestamp_voucher_date) / (24 * 3600));
-                                       $invoice[$i]['timestamp_voucher_date'] 
= $timestamp_voucher_date;
+                                       $invoice[$i]['type']                    
                 = $art_list[$this->db->f('artid')];
+                                       $invoice[$i]['kidnr']                   
                 = $this->db->f('kidnr');
+                                       $invoice[$i]['kreditnota']              
                 = $this->db->f('kreditnota');
+                                       $invoice[$i]['currency']                
                 = $this->db->f('currency');
+                                       $invoice[$i]['order_id']                
                 = $this->db->f('pmwrkord_code');
+                                       $invoice[$i]['amount']                  
                 = $invoice_temp['amount'];
+                                       $invoice[$i]['approved_amount']         
         = $invoice_temp['approved_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'])
                                        {
@@ -372,16 +372,16 @@
 
                function read_invoice_sub($data)
                {
-                       $start = isset($data['start']) && $data['start'] ? 
(int) $data['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'] ? (int) $data['voucher_id'] : 0;
-                       $paid = isset($data['paid']) ? $data['paid'] : '';
-                       $project_id = isset($data['project_id']) && 
$data['project_id'] ? (int) $data['project_id'] : 0;
-                       $order_id = isset($data['order_id']) && 
$data['order_id'] ? $data['order_id'] : 0;//might be bigint
-                       $results = isset($data['results']) && $data['results'] 
? (int) $data['results'] : 0;
-                       $allrows = isset($data['allrows']) ? $data['allrows'] : 
'';
+                       $start           = isset($data['start']) && 
$data['start'] ? (int) $data['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'] ? (int) $data['voucher_id'] : 0;
+                       $paid            = isset($data['paid']) ? $data['paid'] 
: '';
+                       $project_id      = isset($data['project_id']) && 
$data['project_id'] ? (int) $data['project_id'] : 0;
+                       $order_id        = isset($data['order_id']) && 
$data['order_id'] ? $data['order_id'] : 0;//might be bigint
+                       $results         = isset($data['results']) && 
$data['results'] ? (int) $data['results'] : 0;
+                       $allrows         = isset($data['allrows']) ? 
$data['allrows'] : '';
                        if($paid)
                        {
                                $table = 'fm_ecobilagoverf';
@@ -409,8 +409,8 @@
                                        $ordermethod = ' ORDER BY pmwrkord_code 
DESC, id DESC';
                        }
 
-                       $filtermethod = '';
-                       $where = 'WHERE';
+                       $filtermethod    = '';
+                       $where                   = 'WHERE';
 
                        if($voucher_id)
                        {
@@ -520,25 +520,25 @@
 
                function read_invoice_sub_sum($data)
                {
-                       $start = isset($data['start']) && $data['start'] ? 
(int) $data['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'] ? (int) $data['voucher_id'] : 0;
-                       $paid = isset($data['paid']) ? $data['paid'] : '';
-                       $year = isset($data['year']) ? $data['year'] : '';
-                       $project_id = isset($data['project_id']) && 
$data['project_id'] ? (int) $data['project_id'] : 0;
-                       $order_id = isset($data['order_id']) && 
$data['order_id'] ? $data['order_id'] : 0;//might be bigint
+                       $start           = isset($data['start']) && 
$data['start'] ? (int) $data['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'] ? (int) $data['voucher_id'] : 0;
+                       $paid            = isset($data['paid']) ? $data['paid'] 
: '';
+                       $year            = isset($data['year']) ? $data['year'] 
: '';
+                       $project_id      = isset($data['project_id']) && 
$data['project_id'] ? (int) $data['project_id'] : 0;
+                       $order_id        = isset($data['order_id']) && 
$data['order_id'] ? $data['order_id'] : 0;//might be bigint
 
                        if($paid)
                        {
-                               $table = 'fm_ecobilagoverf';
-                               $overftid = ',overftid';
+                               $table           = 'fm_ecobilagoverf';
+                               $overftid        = ',overftid';
                        }
                        else
                        {
-                               $table = 'fm_ecobilag';
-                               $overftid = '';
+                               $table           = 'fm_ecobilag';
+                               $overftid        = '';
                        }
 
                        switch($order)
@@ -553,8 +553,8 @@
                                        $ordermethod = " ORDER BY pmwrkord_code 
DESC";
                        }
 
-                       $filtermethod = '';
-                       $where = 'WHERE';
+                       $filtermethod    = '';
+                       $where                   = 'WHERE';
 
                        if($voucher_id)
                        {
@@ -622,9 +622,9 @@
 
                                $this->db->query($sql, __LINE__, __FILE__);
                                $this->db->next_record();
-                               $entry['budsjettsigndato'] = 
$this->db->f('budsjettsigndato');
-                               $entry['transfer_time'] = 
$this->db->f('overftid');
-                               $entry['type'] = $this->db->f('type');
+                               $entry['budsjettsigndato']       = 
$this->db->f('budsjettsigndato');
+                               $entry['transfer_time']          = 
$this->db->f('overftid');
+                               $entry['type']                           = 
$this->db->f('type');
                        }
 
                        return $values;
@@ -634,42 +634,42 @@
                {
                        if(is_array($data))
                        {
-                               $start = isset($data['start']) && 
$data['start'] ? $data['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'] ? (int) $data['cat_id'] : 0;
-                               $start_date = isset($data['start_date']) && 
$data['start_date'] ? $data['start_date'] : 0;
-                               $end_date = isset($data['end_date']) && 
$data['end_date'] ? $data['end_date'] : time();
-                               $vendor_id = isset($data['vendor_id']) ? (int) 
$data['vendor_id'] : 0;
-                               $loc1 = isset($data['loc1']) ? $data['loc1'] : 
'';
-                               $district_id = isset($data['district_id']) ? 
(int) $data['district_id'] : 0;
-                               $workorder_id = isset($data['workorder_id']) && 
$data['workorder_id'] ? $data['workorder_id'] : 0;
+                               $start                   = 
isset($data['start']) && $data['start'] ? $data['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'] ? (int) $data['cat_id'] : 0;
+                               $start_date              = 
isset($data['start_date']) && $data['start_date'] ? $data['start_date'] : 0;
+                               $end_date                = 
isset($data['end_date']) && $data['end_date'] ? $data['end_date'] : time();
+                               $vendor_id               = 
isset($data['vendor_id']) ? (int) $data['vendor_id'] : 0;
+                               $loc1                    = isset($data['loc1']) 
? $data['loc1'] : '';
+                               $district_id     = isset($data['district_id']) 
? (int) $data['district_id'] : 0;
+                               $workorder_id    = isset($data['workorder_id']) 
&& $data['workorder_id'] ? $data['workorder_id'] : 0;
                                $b_account_class = 
isset($data['b_account_class']) ? $data['b_account_class'] : '';
-                               $b_account = isset($data['b_account']) ? 
$data['b_account'] : '';
-                               $ecodimb = isset($data['ecodimb']) ? 
$data['ecodimb'] : '';
+                               $b_account               = 
isset($data['b_account']) ? $data['b_account'] : '';
+                               $ecodimb                 = 
isset($data['ecodimb']) ? $data['ecodimb'] : '';
                        }
 
                        $where = 'AND';
 
                        if($b_account_class)
                        {
-                               $filtermethod = " $where 
fm_b_account.category='$b_account_class'";
-                               $where = 'AND';
+                               $filtermethod    = " $where 
fm_b_account.category='$b_account_class'";
+                               $where                   = 'AND';
                        }
                        else
                        {
-                               $select_account_class = ',fm_b_account.category 
as b_account_class';
-                               $group_account_class = ', 
spbudact_code,fm_b_account.category';
+                               $select_account_class    = 
',fm_b_account.category as b_account_class';
+                               $group_account_class     = ', 
spbudact_code,fm_b_account.category';
                        }
 
                        if($b_account)
                        {
                                $filtermethod .= " {$where} fm_b_account.id = 
'{$b_account}'";
-                               $where = 'AND';
-                               $select_account_class = ',fm_b_account.id as 
b_account_class';
-                               $group_account_class = ', 
spbudact_code,fm_b_account.id';
+                               $where                                   = 
'AND';
+                               $select_account_class    = ',fm_b_account.id as 
b_account_class';
+                               $group_account_class     = ', 
spbudact_code,fm_b_account.id';
                        }
 
 
@@ -711,8 +711,8 @@
                                $where = 'AND';
                        }
 
-                       $start_periode = date('Ym', $start_date);
-                       $end_periode = date('Ym', $end_date);
+                       $start_periode   = date('Ym', $start_date);
+                       $end_periode     = date('Ym', $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) "
@@ -795,8 +795,8 @@
                                return $update;
                        }
 
-                       $timestamp_voucher_date = mktime(0, 0, 0, date('m', 
strtotime($this->db->f('fakturadato'))), date('d', 
strtotime($this->db->f('fakturadato'))), date('y', 
strtotime($this->db->f('fakturadato'))));
-                       $timestamp_payment_date = mktime(0, 0, 0, date('m', 
strtotime($this->db->f('forfallsdato'))), date('d', 
strtotime($this->db->f('forfallsdato'))), date('y', 
strtotime($this->db->f('forfallsdato'))));
+                       $timestamp_voucher_date  = mktime(0, 0, 0, date('m', 
strtotime($this->db->f('fakturadato'))), date('d', 
strtotime($this->db->f('fakturadato'))), date('y', 
strtotime($this->db->f('fakturadato'))));
+                       $timestamp_payment_date  = mktime(0, 0, 0, date('m', 
strtotime($this->db->f('forfallsdato'))), date('d', 
strtotime($this->db->f('forfallsdato'))), date('y', 
strtotime($this->db->f('forfallsdato'))));
 
                        if(((intval(($timestamp_payment_date - 
$timestamp_voucher_date) / (24 * 3600))) != $values['num_days']))
                        {
@@ -807,8 +807,8 @@
 
                function update_invoice_sub($values)
                {
-                       $update_status = array();
-                       $receipt = array();
+                       $update_status   = array();
+                       $receipt                 = array();
                        $GLOBALS['phpgw']->db->transaction_begin();
 
                        while($entry = each($values['counter']))
@@ -818,7 +818,7 @@
                                $n = $entry[0];
 
                                //_debug_array($entry);
-                               $id = (int) $values['id'][$n];
+                               $id                              = (int) 
$values['id'][$n];
                                $approved_amount = 
isset($values['approved_amount'][$n]) && $values['approved_amount'][$n] ? 
str_replace(',', '.', $values['approved_amount'][$n]) : 0;
                                if(!$approved_amount || $approved_amount == 
'00.0')
                                {
@@ -835,21 +835,21 @@
                                        $GLOBALS['phpgw']->db->next_record();
                                        if($GLOBALS['phpgw']->db->f('cnt') == 0)
                                        {
-                                               $receipt['error'][] = 
array('msg' => lang('This account is not valid:') . " " . $budget_account);
-                                               $local_error = true;
+                                               $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;
+                                       $receipt['error'][]      = array('msg' 
=> lang('Budget account is missing:'));
+                                       $local_error             = true;
                                }
 
                                if(!$values['dimd'][$n])
                                {
-                                       $dimd_field = "dimd=NULL";
-                                       $local_error = true;
-                                       $receipt['error'][] = array('msg' => 
lang('Dim D is mandatory'));
+                                       $dimd_field                      = 
"dimd=NULL";
+                                       $local_error             = true;
+                                       $receipt['error'][]      = array('msg' 
=> lang('Dim D is mandatory'));
                                }
                                else
                                {
@@ -858,18 +858,18 @@
                                        $GLOBALS['phpgw']->db->next_record();
                                        if($GLOBALS['phpgw']->db->f('cnt') == 0)
                                        {
-                                               $receipt['error'][] = 
array('msg' => lang('This Dim D is not valid:') . " " . $dimd);
-                                               $local_error = true;
+                                               $receipt['error'][]      = 
array('msg' => lang('This Dim D is not valid:') . " " . $dimd);
+                                               $local_error             = true;
                                        }
 
-                                       $dimd_field = "dimd=" . "'" . $dimd . 
"'";
+                                       $dimd_field = "dimd='{$dimd}', dime = 
'{$dimd}'";
                                }
 
                                if(!$values['dima'][$n])
                                {
-                                       $dima_field = "dima=NULL";
-                                       $receipt['error'][] = array('msg' => 
lang('Dim A is missing'));
-                                       $local_error = true;
+                                       $dima_field                      = 
"dima=NULL";
+                                       $receipt['error'][]      = array('msg' 
=> lang('Dim A is missing'));
+                                       $local_error             = true;
                                }
                                else
                                {
@@ -878,14 +878,14 @@
                                        $GLOBALS['phpgw']->db->next_record();
                                        if(!$GLOBALS['phpgw']->db->f('loc1'))
                                        {
-                                               $receipt['error'][] = 
array('msg' => lang('This Dim A is not valid:') . " " . $values['dima'][$n]);
-                                               $local_error = true;
+                                               $receipt['error'][]      = 
array('msg' => lang('This Dim A is not valid:') . " " . $values['dima'][$n]);
+                                               $local_error             = true;
                                        }
 
                                        
if(!$GLOBALS['phpgw']->db->f('kostra_id') || 
$GLOBALS['phpgw']->db->f('kostra_id') == 0)
                                        {
-                                               $receipt['error'][] = 
array('msg' => 'objektet mangler tjeneste - utgått? ' . " " . 
$values['dima'][$n]);
-                                               $local_error = true;
+                                               $receipt['error'][]      = 
array('msg' => 'objektet mangler tjeneste - utgått? ' . " " . 
$values['dima'][$n]);
+                                               $local_error             = true;
                                        }
 
                                        //      $dima_field="dima="."'" . 
$values['dima'][$n] . "'";
@@ -896,9 +896,9 @@
 
                                if(!$local_error)
                                {
-                                       $tax_code = (int) 
$values['tax_code'][$n];
-                                       $dimb = isset($values['dimb'][$n]) && 
$values['dimb'][$n] ? (int) $values['dimb'][$n] : 'NULL';
-                                       $workorder_id = 
$values['workorder_id'][$n];
+                                       $tax_code                = (int) 
$values['tax_code'][$n];
+                                       $dimb                    = 
isset($values['dimb'][$n]) && $values['dimb'][$n] ? (int) $values['dimb'][$n] : 
'NULL';
+                                       $workorder_id    = 
$values['workorder_id'][$n];
                                        if(isset($values['close_order'][$n]) && 
$values['close_order'][$n] && !$values['close_order_orig'][$n])
                                        {
                                                $update_status[$workorder_id] = 
'X';
@@ -932,8 +932,8 @@
 
                        if($update_status)
                        {
-                               $closed = 
isset($this->config->config_data['workorder_closed_status']) && 
$this->config->config_data['workorder_closed_status'] ? 
$this->config->config_data['workorder_closed_status'] : '';
-                               $reopen = 
isset($this->config->config_data['workorder_reopen_status']) && 
$this->config->config_data['workorder_reopen_status'] ? 
$this->config->config_data['workorder_reopen_status'] : '';
+                               $closed  = 
isset($this->config->config_data['workorder_closed_status']) && 
$this->config->config_data['workorder_closed_status'] ? 
$this->config->config_data['workorder_closed_status'] : '';
+                               $reopen  = 
isset($this->config->config_data['workorder_reopen_status']) && 
$this->config->config_data['workorder_reopen_status'] ? 
$this->config->config_data['workorder_reopen_status'] : '';
 
                                if(!$closed)
                                {
@@ -1008,7 +1008,7 @@
                                $table = 'fm_ecobilagoverf';
 
                                $value_set = array
-                                       (
+                               (
                                        //                      'project_id'    
=> $values['project_group'] ? $values['project_group'] : '',
                                        'pmwrkord_code' => $values['order_id'],
                                //                      'process_log'   => 
$this->db->db_addslashes($values['process_log']),
@@ -1027,29 +1027,29 @@
                                switch($values['sign_orig'])
                                {
                                        case 'is_janitor':
-                                               $value_set['oppsynsigndato'] = 
null;
+                                               $value_set['oppsynsigndato']    
 = null;
                                                break;
                                        case 'is_supervisor':
-                                               $value_set['saksigndato'] = 
null;
+                                               $value_set['saksigndato']       
         = null;
                                                break;
                                        case 'is_budget_responsible':
-                                               $value_set['budsjettsigndato'] 
= null;
+                                               $value_set['budsjettsigndato']  
 = null;
                                                break;
                                }
 
                                switch($values['approve'])
                                {
                                        case 'is_janitor':
-                                               $value_set['oppsynsigndato'] = 
date($this->db->datetime_format());
-                                               $value_set['oppsynsmannid'] = 
$values['my_initials'];
+                                               $value_set['oppsynsigndato']    
         = date($this->db->datetime_format());
+                                               $value_set['oppsynsmannid']     
                 = $values['my_initials'];
                                                break;
                                        case 'is_supervisor':
-                                               $value_set['saksigndato'] = 
date($this->db->datetime_format());
-                                               $value_set['saksbehandlerid'] = 
$values['my_initials'];
+                                               $value_set['saksigndato']       
                 = date($this->db->datetime_format());
+                                               $value_set['saksbehandlerid']   
         = $values['my_initials'];
                                                break;
                                        case 'is_budget_responsible':
-                                               $value_set['budsjettsigndato'] 
= date($this->db->datetime_format());
-                                               
$value_set['budsjettansvarligid'] = $values['my_initials'];
+                                               $value_set['budsjettsigndato']  
         = date($this->db->datetime_format());
+                                               
$value_set['budsjettansvarligid']        = $values['my_initials'];
                                                break;
                                }
 
@@ -1086,8 +1086,8 @@
 
                        if(isset($values['split_line']) && 
$values['split_amount'] && isset($values['split_amount']) && 
$values['split_amount'])
                        {
-                               $metadata = $this->db->metadata($table);
-                               $sql = "SELECT * FROM {$table} WHERE id= {$id}";
+                               $metadata        = $this->db->metadata($table);
+                               $sql             = "SELECT * FROM {$table} 
WHERE id= {$id}";
                                $this->db->query($sql, __LINE__, __FILE__);
                                $this->db->next_record();
 
@@ -1108,23 +1108,23 @@
 
                                $this->db->query("SELECT belop FROM {$table} 
WHERE id={$id}", __LINE__, __FILE__);
                                $this->db->next_record();
-                               $amount = $this->db->f('belop');
-                               $new_amount = $amount - $values['split_amount'];
+                               $amount          = $this->db->f('belop');
+                               $new_amount      = $amount - 
$values['split_amount'];
 
-                               $value_set = array
+                               $value_set       = array
                                        (
                                        'belop'                  => $new_amount,
                                        'godkjentbelop'  => $new_amount,
                                );
-                               $value_set = 
$this->db->validate_update($value_set);
+                               $value_set       = 
$this->db->validate_update($value_set);
                                $this->db->query("UPDATE {$table} SET 
$value_set WHERE id= {$id}", __LINE__, __FILE__);
 
-                               $value_set = array
+                               $value_set       = array
                                        (
                                        'belop'                  => 
$values['split_amount'],
                                        'godkjentbelop'  => 
$values['split_amount'],
                                );
-                               $value_set = 
$this->db->validate_update($value_set);
+                               $value_set       = 
$this->db->validate_update($value_set);
                                $this->db->query("UPDATE {$table} SET 
$value_set WHERE id= {$new_id}", __LINE__, __FILE__);
                        }
 
@@ -1157,11 +1157,11 @@
 
                        if(isset($this->config->config_data['invoice_acl']) && 
$this->config->config_data['invoice_acl'] == 'dimb')
                        {
-                               $dimb = (int) $dimb;
-                               $filter_dimb = $dimb ? "AND ecodimb = {$dimb}" 
: '';
+                               $dimb                                           
 = (int) $dimb;
+                               $filter_dimb                             = 
$dimb ? "AND ecodimb = {$dimb}" : '';
                                $this->db->query("SELECT user_id FROM 
fm_ecodimb_role_user WHERE user_id = {$this->account_id} AND role_id IN (1, 2, 
3) {$filter_dimb} AND expired_on IS NULL AND active_from < " . time() . ' AND 
(active_to > ' . time() . ' OR active_to = 0)');
                                $this->db->next_record();
-                               $this->role['is_janitor'] = 
!!$this->db->f('user_id');
+                               $this->role['is_janitor']        = 
!!$this->db->f('user_id');
 
                                $this->db->query("SELECT user_id FROM 
fm_ecodimb_role_user WHERE user_id = {$this->account_id} AND role_id IN (2, 3) 
{$filter_dimb} AND expired_on IS NULL AND active_from < " . time() . ' AND 
(active_to > ' . time() . ' OR active_to = 0)');
                                $this->db->next_record();
@@ -1186,7 +1186,7 @@
                function get_dimb_role_user($role_id, $dimb = '', $selected = 
'')
                {
                        $filter_dimb = $dimb ? "AND ecodimb = {$dimb}" : '';
-                       $role_id = (int) $role_id;
+                       $role_id         = (int) $role_id;
                        switch($role_id)
                        {
                                case 1:
@@ -1216,8 +1216,8 @@
                        $values = array();
                        while($this->db->next_record())
                        {
-                               $id = $this->db->f('account_lid');
-                               $values[] = array
+                               $id                      = 
$this->db->f('account_lid');
+                               $values[]        = array
                                        (
                                        'id'             => $id,
                                        'name'           => 
$this->db->f('account_lastname') . ', ' . $this->db->f('account_firstname'),
@@ -1229,9 +1229,9 @@
 
                function get_default_dimb_role_user($role_id, $dimb)
                {
-                       $dimb = (int) $dimb;
+                       $dimb    = (int) $dimb;
                        $role_id = (int) $role_id;
-                       $sql = "SELECT user_id FROM fm_ecodimb_role_user"
+                       $sql     = "SELECT user_id FROM fm_ecodimb_role_user"
                        . " WHERE role_id = {$role_id} AND ecodimb = {$dimb} 
AND expired_on IS NULL AND default_user = 1  AND active_from < " . time() . ' 
AND (active_to > ' . time() . ' OR active_to = 0)';
 //_debug_array($sql);
                        $this->db->query($sql, __LINE__, __FILE__);
@@ -1242,7 +1242,8 @@
                function check_count($voucher_id)
                {
 
-                       $this->db->query("SELECT count(id) as invoice_count, 
count(dima) as dima_count, count(spbudact_code) as spbudact_code_count FROM 
fm_ecobilag WHERE bilagsnr ='$voucher_id'");
+                       $this->db->query("SELECT count(id) AS invoice_count, 
count(dima) AS dima_count, count(spbudact_code) AS spbudact_code_count, 
count(dimd) AS dimd_count"
+                       . " FROM fm_ecobilag WHERE bilagsnr ='{$voucher_id}'");
                        $this->db->next_record();
 
                        $check_count = array
@@ -1250,6 +1251,7 @@
                                'dima_count'                     => 
$this->db->f('dima_count'),
                                'spbudact_code_count'    => 
$this->db->f('spbudact_code_count'),
                                'invoice_count'                  => 
$this->db->f('invoice_count'),
+                               'dimd_count'                     => 
$this->db->f('dimd_count'),
                        );
 
                        $this->db->query("select count(kostra_id) as 
kostra_count  from fm_ecobilag where bilagsnr ='$voucher_id' and kostra_id > 
0");
@@ -1309,12 +1311,12 @@
 
                function increment_bilagsnr()
                {
-                       $name = 'Bilagsnummer';
-                       $now = time();
+                       $name            = 'Bilagsnummer';
+                       $now             = time();
                        $this->db->query("SELECT value, start_date FROM 
fm_idgenerator WHERE name = '{$name}' AND start_date < {$now} ORDER BY 
start_date DESC");
                        $this->db->next_record();
-                       $bilagsnr = $this->db->f('value') + 1;
-                       $start_date = (int) $this->db->f('start_date');
+                       $bilagsnr        = $this->db->f('value') + 1;
+                       $start_date      = (int) $this->db->f('start_date');
 
                        $this->db->query("UPDATE fm_idgenerator SET value = 
value + 1 WHERE name = '{$name}' AND start_date = $start_date");
                        return $bilagsnr;
@@ -1322,11 +1324,11 @@
 
                function next_bilagsnr()
                {
-                       $name = 'Bilagsnummer';
-                       $now = time();
+                       $name            = 'Bilagsnummer';
+                       $now             = time();
                        $this->db->query("SELECT value FROM fm_idgenerator 
WHERE name = '{$name}' AND start_date < {$now} ORDER BY start_date DESC");
                        $this->db->next_record();
-                       $bilagsnr = $this->db->f('value') + 1;
+                       $bilagsnr        = $this->db->f('value') + 1;
 
                        return $bilagsnr;
                }
@@ -1344,8 +1346,8 @@
                        $values = array();
                        while($this->db->next_record())
                        {
-                               $id = $this->db->f('id');
-                               $values[] = array
+                               $id                      = $this->db->f('id');
+                               $values[]        = array
                                        (
                                        'id'     => $id,
                                        'name'   => $id,
@@ -1388,25 +1390,25 @@
                //----------
                function select_dimb_list($selected = 0)
                {
-                       $selected = (int) $selected;
-                       $include_selected = false;
+                       $selected                        = (int) $selected;
+                       $include_selected        = false;
 
                        if(isset($this->config->config_data['invoice_acl']) && 
$this->config->config_data['invoice_acl'] == 'dimb')
                        {
-                               $sql = "SELECT DISTINCT fm_ecodimb.* FROM 
fm_ecodimb {$this->db->join} fm_ecodimb_role_user ON fm_ecodimb.id = 
fm_ecodimb_role_user.ecodimb"
+                               $sql                             = "SELECT 
DISTINCT fm_ecodimb.* FROM fm_ecodimb {$this->db->join} fm_ecodimb_role_user ON 
fm_ecodimb.id = fm_ecodimb_role_user.ecodimb"
                                . ' WHERE fm_ecodimb_role_user.user_id = ' . 
(int) $this->account_id
                                . ' AND expired_on IS NULL'
                                . ' ORDER BY descr ASC';
-                               $include_selected = true;
+                               $include_selected        = true;
                        }
                        else
                        {
                                $sql = "SELECT * FROM fm_ecodimb ORDER BY descr 
ASC";
                        }
 
-                       $selected_found = false;
+                       $selected_found  = false;
                        $this->db->query($sql);
-                       $dimb_list = array();
+                       $dimb_list               = array();
                        while($this->db->next_record())
                        {
                                $id = $this->db->f('id');
@@ -1492,8 +1494,8 @@
                                $table = 'fm_ecobilagoverf';
                        }
 
-                       $bilagsnr = (int) $bilagsnr;
-                       $id = (int) $id;
+                       $bilagsnr        = (int) $bilagsnr;
+                       $id                      = (int) $id;
 
                        if($bilagsnr)
                        {
@@ -1617,144 +1619,150 @@
 
                                                if(!($check_count['dima_count'] 
== $values['invoice_count'][$n]))
                                                {
-                                                       $receipt['error'][] = 
array('msg' => lang('Dima is missing from sub invoice in:') . " " . 
$values['voucher_id'][$n]);
-                                                       $local_error = true;
+                                                       $receipt['error'][]     
 = array('msg' => lang('Dima is missing from sub invoice in:') . " " . 
$values['voucher_id'][$n]);
+                                                       $local_error            
 = true;
                                                }
 
                                                
if(!($check_count['spbudact_code_count'] == $values['invoice_count'][$n]))
                                                {
-                                                       $receipt['error'][] = 
array('msg' => lang('Budget code is missing from sub invoice in :') . " " . 
$values['voucher_id'][$n]);
-                                                       $local_error = true;
+                                                       $receipt['error'][]     
 = array('msg' => lang('Budget code is missing from sub invoice in :') . " " . 
$values['voucher_id'][$n]);
+                                                       $local_error            
 = true;
                                                }
 
+                                               if($check_count['dimd_count'] 
!= $check_count['invoice_count'])
+                                               {
+                                                       $receipt['error'][]     
 = array('msg' => lang('Dim D is mandatory') . ": {$values['voucher_id'][$n]}");
+                                                       $local_error            
 = true;
+                                               }
+
                                                
if(!($check_count['kostra_count'] == $values['invoice_count'][$n]))
                                                {
-                                                       $receipt['error'][] = 
array('msg' => 'Tjenestekode mangler for undebilag: ' . " " . 
$values['voucher_id'][$n]);
-                                                       $local_error = true;
+                                                       $receipt['error'][]     
 = array('msg' => 'Tjenestekode mangler for undebilag: ' . " " . 
$values['voucher_id'][$n]);
+                                                       $local_error            
 = true;
                                                }
 
                                                
if($this->check_claim($voucher_id))
                                                {
-                                                       $receipt['error'][] = 
array('msg' => lang('Tenant claim is not issued for project in voucher %1', 
$voucher_id));
-                                                       $local_error = true;
+                                                       $receipt['error'][]     
 = array('msg' => lang('Tenant claim is not issued for project in voucher %1', 
$voucher_id));
+                                                       $local_error            
 = true;
                                                }
 
-                                               $blank_date = '';
-                                               $sign_field = '';
-                                               $sign_id = '';
-                                               $sign_date_field = '';
-                                               $sign_date = '';
-                                               $kommma = '';
+                                               $blank_date                     
 = '';
+                                               $sign_field                     
 = '';
+                                               $sign_id                        
 = '';
+                                               $sign_date_field         = '';
+                                               $sign_date                      
 = '';
+                                               $kommma                         
 = '';
                                                $wait_for_kreditnota = '';
-                                               $user_lid = 
$GLOBALS['phpgw_info']['user']['account_lid'];
+                                               $user_lid                       
 = $GLOBALS['phpgw_info']['user']['account_lid'];
 
                                                if(($values['sign'][$n] == 
'sign_none') && ($values['sign_orig'][$n] == 'sign_janitor'))
                                                {
-                                                       $blank_date = 
'oppsynsigndato= NULL';
-                                                       $sign_field = '';
-                                                       $sign_id = '';
+                                                       $blank_date             
 = 'oppsynsigndato= NULL';
+                                                       $sign_field             
 = '';
+                                                       $sign_id                
 = '';
                                                        $sign_date_field = '';
-                                                       $sign_date = '';
-                                                       $kommma = '';
+                                                       $sign_date              
 = '';
+                                                       $kommma                 
 = '';
                                                }
                                                else if(($values['sign'][$n] == 
'sign_none') && ($values['sign_orig'][$n] == 'sign_supervisor'))
                                                {
-                                                       $blank_date = 
'saksigndato= NULL';
-                                                       $sign_field = '';
-                                                       $sign_id = '';
+                                                       $blank_date             
 = 'saksigndato= NULL';
+                                                       $sign_field             
 = '';
+                                                       $sign_id                
 = '';
                                                        $sign_date_field = '';
-                                                       $sign_date = '';
-                                                       $kommma = '';
+                                                       $sign_date              
 = '';
+                                                       $kommma                 
 = '';
                                                }
                                                else if(($values['sign'][$n] == 
'sign_none') && ($values['sign_orig'][$n] == 'sign_budget_responsible'))
                                                {
-                                                       $blank_date = 
'budsjettsigndato= NULL';
-                                                       $sign_field = '';
-                                                       $sign_id = '';
+                                                       $blank_date             
 = 'budsjettsigndato= NULL';
+                                                       $sign_field             
 = '';
+                                                       $sign_id                
 = '';
                                                        $sign_date_field = '';
-                                                       $sign_date = '';
-                                                       $kommma = '';
+                                                       $sign_date              
 = '';
+                                                       $kommma                 
 = '';
                                                }
                                                else if($values['sign'][$n] == 
'sign_janitor' && !$values['sign_orig'][$n])
                                                {
-                                                       $blank_date = '';
-                                                       $sign_field = 
'oppsynsmannid=';
-                                                       $sign_id = 
"'$user_lid'";
+                                                       $blank_date             
 = '';
+                                                       $sign_field             
 = 'oppsynsmannid=';
+                                                       $sign_id                
 = "'$user_lid'";
                                                        $sign_date_field = 
'oppsynsigndato=';
-                                                       $sign_date = "'" . 
date($this->db->datetime_format()) . "'";
-                                                       $kommma = ",";
+                                                       $sign_date              
 = "'" . date($this->db->datetime_format()) . "'";
+                                                       $kommma                 
 = ",";
                                                }
                                                else if($values['sign'][$n] == 
'sign_janitor' && $values['sign_orig'][$n] == 'sign_supervisor')
                                                {
-                                                       $blank_date = 
'saksigndato= NULL';
-                                                       $sign_field = 
'oppsynsmannid=';
-                                                       $sign_id = 
"'$user_lid'";
+                                                       $blank_date             
 = 'saksigndato= NULL';
+                                                       $sign_field             
 = 'oppsynsmannid=';
+                                                       $sign_id                
 = "'$user_lid'";
                                                        $sign_date_field = 
'oppsynsigndato=';
-                                                       $sign_date = "'" . 
date($this->db->datetime_format()) . "'";
-                                                       $kommma = ",";
+                                                       $sign_date              
 = "'" . date($this->db->datetime_format()) . "'";
+                                                       $kommma                 
 = ",";
                                                }
                                                else if($values['sign'][$n] == 
'sign_janitor' && $values['sign_orig'][$n] == 'sign_budget_responsible')
                                                {
-                                                       $blank_date = 
'budsjettsigndato= NULL';
-                                                       $sign_field = 
'oppsynsmannid=';
-                                                       $sign_id = 
"'$user_lid'";
+                                                       $blank_date             
 = 'budsjettsigndato= NULL';
+                                                       $sign_field             
 = 'oppsynsmannid=';
+                                                       $sign_id                
 = "'$user_lid'";
                                                        $sign_date_field = 
'oppsynsigndato=';
-                                                       $sign_date = "'" . 
date($this->db->datetime_format()) . "'";
-                                                       $kommma = ",";
+                                                       $sign_date              
 = "'" . date($this->db->datetime_format()) . "'";
+                                                       $kommma                 
 = ",";
                                                }
                                                else if($values['sign'][$n] == 
'sign_supervisor' && !$values['sign_orig'][$n])
                                                {
-                                                       $blank_date = '';
-                                                       $sign_field = 
'saksbehandlerid=';
-                                                       $sign_id = 
"'$user_lid'";
+                                                       $blank_date             
 = '';
+                                                       $sign_field             
 = 'saksbehandlerid=';
+                                                       $sign_id                
 = "'$user_lid'";
                                                        $sign_date_field = 
'saksigndato=';
-                                                       $sign_date = "'" . 
date($this->db->datetime_format()) . "'";
-                                                       $kommma = ",";
+                                                       $sign_date              
 = "'" . date($this->db->datetime_format()) . "'";
+                                                       $kommma                 
 = ",";
                                                }
                                                else if($values['sign'][$n] == 
'sign_supervisor' && $values['sign_orig'][$n] == 'sign_janitor')
                                                {
-                                                       $blank_date = 
'oppsynsigndato= NULL';
-                                                       $sign_field = 
'saksbehandlerid=';
-                                                       $sign_id = 
"'$user_lid'";
+                                                       $blank_date             
 = 'oppsynsigndato= NULL';
+                                                       $sign_field             
 = 'saksbehandlerid=';
+                                                       $sign_id                
 = "'$user_lid'";
                                                        $sign_date_field = 
'saksigndato=';
-                                                       $sign_date = "'" . 
date($this->db->datetime_format()) . "'";
-                                                       $kommma = ",";
+                                                       $sign_date              
 = "'" . date($this->db->datetime_format()) . "'";
+                                                       $kommma                 
 = ",";
                                                }
                                                else if($values['sign'][$n] == 
'sign_supervisor' && $values['sign_orig'][$n] == 'sign_budget_responsible')
                                                {
-                                                       $blank_date = 
'budsjettsigndato= NULL';
-                                                       $sign_field = 
'saksbehandlerid=';
-                                                       $sign_id = 
"'$user_lid'";
+                                                       $blank_date             
 = 'budsjettsigndato= NULL';
+                                                       $sign_field             
 = 'saksbehandlerid=';
+                                                       $sign_id                
 = "'$user_lid'";
                                                        $sign_date_field = 
'saksigndato=';
-                                                       $sign_date = "'" . 
date($this->db->datetime_format()) . "'";
-                                                       $kommma = ",";
+                                                       $sign_date              
 = "'" . date($this->db->datetime_format()) . "'";
+                                                       $kommma                 
 = ",";
                                                }
                                                else if($values['sign'][$n] == 
'sign_budget_responsible' && $values['sign_orig'][$n] == 'sign_janitor')
                                                {
-                                                       $blank_date = 
'oppsynsigndato= NULL';
-                                                       $sign_field = 
'budsjettansvarligid=';
-                                                       $sign_id = 
"'$user_lid'";
+                                                       $blank_date             
 = 'oppsynsigndato= NULL';
+                                                       $sign_field             
 = 'budsjettansvarligid=';
+                                                       $sign_id                
 = "'$user_lid'";
                                                        $sign_date_field = 
'budsjettsigndato=';
-                                                       $sign_date = "'" . 
date($this->db->datetime_format()) . "'";
-                                                       $kommma = ",";
+                                                       $sign_date              
 = "'" . date($this->db->datetime_format()) . "'";
+                                                       $kommma                 
 = ",";
                                                }
                                                else if($values['sign'][$n] == 
'sign_budget_responsible' && $values['sign_orig'][$n] == 'sign_supervisor')
                                                {
-                                                       $blank_date = 
'saksigndato= NULL';
-                                                       $sign_field = 
'budsjettansvarligid=';
-                                                       $sign_id = 
"'$user_lid'";
+                                                       $blank_date             
 = 'saksigndato= NULL';
+                                                       $sign_field             
 = 'budsjettansvarligid=';
+                                                       $sign_id                
 = "'$user_lid'";
                                                        $sign_date_field = 
'budsjettsigndato=';
-                                                       $sign_date = "'" . 
date($this->db->datetime_format()) . "'";
-                                                       $kommma = ",";
+                                                       $sign_date              
 = "'" . date($this->db->datetime_format()) . "'";
+                                                       $kommma                 
 = ",";
                                                }
                                                else if($values['sign'][$n] == 
'sign_budget_responsible' && !$values['sign_orig'][$n])
                                                {
-                                                       $blank_date = '';
-                                                       $sign_field = 
'budsjettansvarligid=';
-                                                       $sign_id = 
"'$user_lid'";
+                                                       $blank_date             
 = '';
+                                                       $sign_field             
 = 'budsjettansvarligid=';
+                                                       $sign_id                
 = "'$user_lid'";
                                                        $sign_date_field = 
'budsjettsigndato=';
-                                                       $sign_date = "'" . 
date($this->db->datetime_format()) . "'";
-                                                       $kommma = ",";
+                                                       $sign_date              
 = "'" . date($this->db->datetime_format()) . "'";
+                                                       $kommma                 
 = ",";
                                                }
 
 
@@ -1776,27 +1784,27 @@
                                                        
$GLOBALS['phpgw']->db->query("UPDATE fm_ecobilag set forfallsdato= 
'$payment_date' where bilagsnr='$voucher_id'");
                                                }
 
-                                               $transfer_id = "Null" . ",";
-                                               $transfer_date = "Null";
+                                               $transfer_id     = "Null" . ",";
+                                               $transfer_date   = "Null";
 
                                                if($values['transfer'][$n])
                                                {
                                                        
if($this->check_for_transfer($voucher_id))
                                                        {
-                                                               $transfer_id = 
"'$user_lid',";
-                                                               $transfer_date 
= "'" . date($this->db->datetime_format()) . "'";
+                                                               $transfer_id    
 = "'$user_lid',";
+                                                               $transfer_date  
 = "'" . date($this->db->datetime_format()) . "'";
                                                        }
                                                        else
                                                        {
-                                                               
$receipt['error'][] = array('msg' => 'Dette bilaget er ikkje godkjent: ' . " " 
. $voucher_id);
-                                                               $local_error = 
true;
+                                                               
$receipt['error'][]      = array('msg' => 'Dette bilaget er ikkje godkjent: ' . 
" " . $voucher_id);
+                                                               $local_error    
         = true;
                                                        }
                                                }
 
                                                if($values['kreditnota'][$n])
                                                {
                                                        $wait_for_kreditnota = 
1;
-                                                       $transfer_date = "Null";
+                                                       $transfer_date          
 = "Null";
                                                }
                                                else
                                                {
@@ -1892,8 +1900,8 @@
                        $values = array();
                        while($this->db->next_record())
                        {
-                               $periode = $this->db->f('periode');
-                               $values[] = array
+                               $periode         = $this->db->f('periode');
+                               $values[]        = array
                                        (
                                        'id'     => $periode,
                                        'name'   => $periode
@@ -1907,7 +1915,7 @@
                                {
                                        break;
                                }
-                               $sql = "SELECT count(id) as cnt FROM 
fm_ecobilagoverf WHERE periode = {$periode['id']}";
+                               $sql                     = "SELECT count(id) as 
cnt FROM fm_ecobilagoverf WHERE periode = {$periode['id']}";
                                $this->db->query($sql, __LINE__, __FILE__);
                                $this->db->next_record();
                                $periode['name'] = $periode['name'] . ' [' . 
sprintf("%010s", $this->db->f('cnt')) . ']';
@@ -1980,11 +1988,11 @@
                        }
                        else if(isset($data['forward']) && 
is_array($data['forward']) && isset($data['voucher_id']) && $data['voucher_id'])
                        {
-                               $condition = 'WHERE bilagsnr =' . (int) 
$data['voucher_id'];
-                               $global_check = true;
+                               $condition               = 'WHERE bilagsnr =' . 
(int) $data['voucher_id'];
+                               $global_check    = true;
                        }
 
-                       $receipt = array();
+                       $receipt         = array();
                        $local_error = false;
                        if($condition)
                        {
@@ -2011,6 +2019,12 @@
                                                $local_error = true;
                                        }
 
+                                       if($check_count['dimd_count'] != 
$check_count['invoice_count'])
+                                       {
+                                               
phpgwapi_cache::message_set(lang('Dim D is mandatory') . ": 
{$data['voucher_id']}", 'error');
+                                               $local_error = true;
+                                       }
+
                                        
if($this->check_claim($data['voucher_id']))
                                        {
                                                
phpgwapi_cache::message_set(lang('Tenant claim is not issued for project in 
voucher %1', $data['voucher_id']), 'error');
@@ -2045,29 +2059,29 @@
                                        switch($data['sign_orig'])
                                        {
                                                case 'is_janitor':
-                                                       
$value_set['oppsynsigndato'] = null;
+                                                       
$value_set['oppsynsigndato']     = null;
                                                        break;
                                                case 'is_supervisor':
-                                                       
$value_set['saksigndato'] = null;
+                                                       
$value_set['saksigndato']                = null;
                                                        break;
                                                case 'is_budget_responsible':
-                                                       
$value_set['budsjettsigndato'] = null;
+                                                       
$value_set['budsjettsigndato']   = null;
                                                        break;
                                        }
 
                                        switch($data['approve'])
                                        {
                                                case 'is_janitor':
-                                                       
$value_set['oppsynsigndato'] = date($this->db->datetime_format());
-                                                       
$value_set['oppsynsmannid'] = $data['my_initials'];
+                                                       
$value_set['oppsynsigndato']             = date($this->db->datetime_format());
+                                                       
$value_set['oppsynsmannid']                      = $data['my_initials'];
                                                        break;
                                                case 'is_supervisor':
-                                                       
$value_set['saksigndato'] = date($this->db->datetime_format());
-                                                       
$value_set['saksbehandlerid'] = $data['my_initials'];
+                                                       
$value_set['saksigndato']                        = 
date($this->db->datetime_format());
+                                                       
$value_set['saksbehandlerid']            = $data['my_initials'];
                                                        break;
                                                case 'is_budget_responsible':
-                                                       
$value_set['budsjettsigndato'] = date($this->db->datetime_format());
-                                                       
$value_set['budsjettansvarligid'] = $data['my_initials'];
+                                                       
$value_set['budsjettsigndato']           = date($this->db->datetime_format());
+                                                       
$value_set['budsjettansvarligid']        = $data['my_initials'];
                                                        break;
                                        }
                                }
@@ -2088,10 +2102,10 @@
 
                function get_order_info($order_id)
                {
-                       $order_info = array();
-                       $toarray = array();
-                       $order_id = (int) $order_id;
-                       $sql = "SELECT 
fm_workorder.location_code,fm_workorder.vendor_id,fm_workorder.account_id,fm_workorder.ecodimb,fm_workorder.category,
 fm_workorder.user_id,fm_workorder.title"
+                       $order_info      = array();
+                       $toarray         = array();
+                       $order_id        = (int) $order_id;
+                       $sql             = "SELECT 
fm_workorder.location_code,fm_workorder.vendor_id,fm_workorder.account_id,fm_workorder.ecodimb,fm_workorder.category,
 fm_workorder.user_id,fm_workorder.title"
                        . " FROM fm_workorder {$this->join} fm_project ON 
fm_workorder.project_id = fm_project.id WHERE fm_workorder.id = {$order_id}";
                        $this->db->query($sql, __LINE__, __FILE__);
                        if($this->db->next_record())
@@ -2100,20 +2114,20 @@
                        }
                        if($this->db->f('location_code'))
                        {
-                               $parts = explode('-', 
$this->db->f('location_code'));
-                               $order_info['dima'] = implode('', $parts);
-                               $order_info['loc1'] = $parts[0];
+                               $parts                           = explode('-', 
$this->db->f('location_code'));
+                               $order_info['dima']      = implode('', $parts);
+                               $order_info['loc1']      = $parts[0];
                        }
 
-                       $order_info['vendor_id'] = $this->db->f('vendor_id');
+                       $order_info['vendor_id']         = 
$this->db->f('vendor_id');
                        $order_info['spbudact_code'] = 
$this->db->f('account_id');
-                       $order_info['dimb'] = $this->db->f('ecodimb');
-                       $order_info['dime'] = $this->db->f('category');
-                       $order_info['title'] = $this->db->f('title', true);
+                       $order_info['dimb']                      = 
$this->db->f('ecodimb');
+                       $order_info['dime']                      = 
$this->db->f('category');
+                       $order_info['title']             = 
$this->db->f('title', true);
 
-                       $janitor_user_id = $this->db->f('user_id');
-                       $order_info['janitor'] = 
$GLOBALS['phpgw']->accounts->get($janitor_user_id)->lid;
-                       $supervisor_user_id = 
$this->get_default_dimb_role_user(2, $order_info['dimb']);
+                       $janitor_user_id                 = 
$this->db->f('user_id');
+                       $order_info['janitor']   = 
$GLOBALS['phpgw']->accounts->get($janitor_user_id)->lid;
+                       $supervisor_user_id              = 
$this->get_default_dimb_role_user(2, $order_info['dimb']);
                        if($supervisor_user_id)
                        {
                                $order_info['supervisor'] = 
$GLOBALS['phpgw']->accounts->get($supervisor_user_id)->lid;
@@ -2147,9 +2161,9 @@
                        $this->db->query("SELECT * FROM fm_ecobilag WHERE id =" 
. (int) $line_id, __LINE__, __FILE__);
 
                        $this->db->next_record();
-                       $old_janitor = $this->db->f('oppsynsmannid');
-                       $old_supervisor = $this->db->f('saksbehandlerid');
-                       $old_budget_responsible = 
$this->db->f('budsjettansvarligid');
+                       $old_janitor                     = 
$this->db->f('oppsynsmannid');
+                       $old_supervisor                  = 
$this->db->f('saksbehandlerid');
+                       $old_budget_responsible  = 
$this->db->f('budsjettansvarligid');
 
                        $value_set = array();
 
@@ -2168,18 +2182,18 @@
                                $value_set['budsjettsigndato'] = '';
                        }
 
-                       $value_set['pmwrkord_code'] = $order_id;
-                       $value_set['dima'] = $order_info['dima'];
-                       $value_set['dimb'] = $order_info['dimb'];
-                       $value_set['dime'] = $order_info['dime'];
-                       $value_set['loc1'] = $order_info['loc1'];
-                       $value_set['line_text'] = $order_info['title'];
-                       $value_set['spbudact_code'] = 
$order_info['spbudact_code'];
-                       $value_set['oppsynsmannid'] = $order_info['janitor'];
-                       $value_set['saksbehandlerid'] = 
$order_info['supervisor'];
-                       $value_set['budsjettansvarligid'] = 
$order_info['budget_responsible'];
-                       $value_set['project_id'] = 
execMethod('property.soXport.get_project', $order_id);
-                       $value_set = $this->db->validate_update($value_set);
+                       $value_set['pmwrkord_code']                      = 
$order_id;
+                       $value_set['dima']                                      
 = $order_info['dima'];
+                       $value_set['dimb']                                      
 = $order_info['dimb'];
+                       $value_set['dime']                                      
 = $order_info['dime'];
+                       $value_set['loc1']                                      
 = $order_info['loc1'];
+                       $value_set['line_text']                          = 
$order_info['title'];
+                       $value_set['spbudact_code']                      = 
$order_info['spbudact_code'];
+                       $value_set['oppsynsmannid']                      = 
$order_info['janitor'];
+                       $value_set['saksbehandlerid']            = 
$order_info['supervisor'];
+                       $value_set['budsjettansvarligid']        = 
$order_info['budget_responsible'];
+                       $value_set['project_id']                         = 
execMethod('property.soXport.get_project', $order_id);
+                       $value_set                                              
         = $this->db->validate_update($value_set);
                        $this->db->query("UPDATE fm_ecobilag SET $value_set 
WHERE id =" . (int) $line_id, __LINE__, __FILE__);
                        return $GLOBALS['phpgw']->db->transaction_commit();
                }
@@ -2211,10 +2225,10 @@
                        $GLOBALS['phpgw']->db->transaction_begin();
                        $value_set = array();
 
-                       $value_set['periode'] = $data['period'];
-                       $value_set['periodization'] = $data['periodization'];
-                       $value_set['periodization_start'] = 
$data['periodization_start'];
-                       $value_set['kreditnota'] = !!$data['park_invoice'];
+                       $value_set['periode']                            = 
$data['period'];
+                       $value_set['periodization']                      = 
$data['periodization'];
+                       $value_set['periodization_start']        = 
$data['periodization_start'];
+                       $value_set['kreditnota']                         = 
!!$data['park_invoice'];
 
                        $value_set = $this->db->validate_update($value_set);
                        $this->db->query("UPDATE fm_ecobilag SET $value_set 
WHERE bilagsnr =" . (int) $data['voucher_id'], __LINE__, __FILE__);
@@ -2223,15 +2237,15 @@
                        $value_set_line = array();
 
                        $value_set_line['pmwrkord_code'] = $data['order_id'];
-                       $value_set_line['dimb'] = $data['dim_b'];
-                       $value_set_line['dima'] = $data['dim_a'];
-                       $value_set_line['dime'] = $data['dim_e'];
-                       $value_set_line['mvakode'] = $data['tax_code'];
-                       $value_set_line['project_id'] = $data['project_group'];
+                       $value_set_line['dimb']                  = 
$data['dim_b'];
+                       $value_set_line['dima']                  = 
$data['dim_a'];
+                       $value_set_line['dime']                  = 
$data['dim_e'];
+                       $value_set_line['mvakode']               = 
$data['tax_code'];
+                       $value_set_line['project_id']    = 
$data['project_group'];
                        $value_set_line['spbudact_code'] = 
$data['b_account_id'];
-                       $value_set_line['line_text'] = 
$this->db->db_addslashes($data['line_text']);
-                       $value_set_line['process_log'] = 
$this->db->db_addslashes($data['process_log']);
-                       $value_set_line['process_code'] = $data['process_code'];
+                       $value_set_line['line_text']     = 
$this->db->db_addslashes($data['line_text']);
+                       $value_set_line['process_log']   = 
$this->db->db_addslashes($data['process_log']);
+                       $value_set_line['process_code']  = 
$data['process_code'];
 
                        $value_set_line = 
$this->db->validate_update($value_set_line);
                        $this->db->query("UPDATE fm_ecobilag SET 
{$value_set_line} WHERE id = " . (int) $data['line_id'], __LINE__, __FILE__);
@@ -2245,8 +2259,8 @@
                                switch($this->db->f('type'))
                                {
                                        case 'workorder':
-                                               $value_set_line['account_id'] = 
$data['b_account_id'];
-                                               $value_set_line['category'] = 
$data['dim_e'];
+                                               $value_set_line['account_id']   
 = $data['b_account_id'];
+                                               $value_set_line['category']     
         = $data['dim_e'];
 
                                                $value_set_line = 
$this->db->validate_update($value_set_line);
                                                $this->db->query("UPDATE 
fm_workorder SET {$value_set_line} WHERE id='{$data['order_id']}'");
@@ -2308,8 +2322,8 @@
                                                }
                                        }
 
-                                       $metadata = $this->db->metadata($table);
-                                       $sql = "SELECT * FROM {$table} WHERE 
id= {$id}";
+                                       $metadata        = 
$this->db->metadata($table);
+                                       $sql             = "SELECT * FROM 
{$table} WHERE id= {$id}";
                                        $this->db->query($sql, __LINE__, 
__FILE__);
                                        $this->db->next_record();
 
@@ -2331,21 +2345,21 @@
                                        $new_id = 
$this->db->get_last_insert_id($table, 'id');
 
 
-                                       $value_set = array
+                                       $value_set       = array
                                                (
                                                'belop'                  => 
$split_amount,
                                                'godkjentbelop'  => 
$split_amount
                                        );
-                                       $value_set = 
$this->db->validate_update($value_set);
+                                       $value_set       = 
$this->db->validate_update($value_set);
                                        $this->db->query("UPDATE {$table} SET 
$value_set WHERE id= {$id}", __LINE__, __FILE__);
 
-                                       $value_set = array
+                                       $value_set       = array
                                                (
                                                'belop'                  => 
$amount - $split_amount,
                                                'godkjentbelop'  => $amount - 
$split_amount,
                                                'splitt'                 => $id
                                        );
-                                       $value_set = 
$this->db->validate_update($value_set);
+                                       $value_set       = 
$this->db->validate_update($value_set);
                                        $this->db->query("UPDATE {$table} SET 
$value_set WHERE id= {$new_id}", __LINE__, __FILE__);
                                }
                        }
@@ -2400,9 +2414,9 @@
 
                public function get_vouchers($data)
                {
-                       $filtermethod = '';
-                       $querymethod = '';
-                       $where = 'WHERE';
+                       $filtermethod    = '';
+                       $querymethod     = '';
+                       $where                   = 'WHERE';
 
                        if($data['janitor_lid'])
                        {
@@ -2410,7 +2424,7 @@
                                {
                                        $data['janitor_lid'] = 
ltrim($data['janitor_lid'], '*');
                                        $filtermethod .= " $where 
oppsynsigndato IS NULL";
-                                       $where = 'AND';
+                                       $where                           = 
'AND';
                                }
                                $filtermethod .= " $where oppsynsmannid = 
'{$data['janitor_lid']}'";
                                $where = 'AND';
@@ -2420,10 +2434,10 @@
                        {
                                if(stripos($data['supervisor_lid'], '*') === 0)
                                {
-                                       $data['supervisor_lid'] = 
ltrim($data['supervisor_lid'], '*');
+                                       $data['supervisor_lid']  = 
ltrim($data['supervisor_lid'], '*');
                                        //                      $filtermethod 
.= " $where oppsynsigndato IS NOT NULL AND saksigndato IS NULL";
                                        $filtermethod .= " $where saksigndato 
IS NULL";
-                                       $where = 'AND';
+                                       $where                                  
 = 'AND';
                                }
 
                                $filtermethod .= " $where saksbehandlerid = 
'{$data['supervisor_lid']}'";
@@ -2434,9 +2448,9 @@
                        {
                                if(stripos($data['budget_responsible_lid'], 
'*') === 0)
                                {
-                                       $data['budget_responsible_lid'] = 
ltrim($data['budget_responsible_lid'], '*');
+                                       $data['budget_responsible_lid']  = 
ltrim($data['budget_responsible_lid'], '*');
                                        $filtermethod .= " $where saksigndato 
IS NOT NULL AND budsjettsigndato IS NULL";
-                                       $where = 'AND';
+                                       $where                                  
                 = 'AND';
                                }
                                $filtermethod .= " $where budsjettansvarligid = 
'{$data['budget_responsible_lid']}'";
                                $where = 'AND';
@@ -2447,32 +2461,32 @@
                                switch($data['criteria'])
                                {
                                        case 'voucher_id':
-                                               $query = (int) $data['query'];
+                                               $query           = (int) 
$data['query'];
                                                $querymethod = " $where 
(bilagsnr = {$query} OR bilagsnr_ut = {$query})";
                                                break;
 
                                        case 'invoice_id':
-                                               $query = $data['query'];
+                                               $query           = 
$data['query'];
                                                $querymethod = " $where 
fakturanr = '{$query}'";
                                                break;
 
                                        case 'order_id':
-                                               $query = $data['query'];
+                                               $query           = 
$data['query'];
                                                $querymethod = " $where 
pmwrkord_code = '{$query}'";
                                                break;
 
                                        case 'vendor_id':
-                                               $query = (int) $data['query'];
+                                               $query           = (int) 
$data['query'];
                                                $querymethod = " $where 
(spvend_code = {$query} OR org_name {$this->like} '%{$data['query']}%')";
                                                break;
 
                                        case 'b_account':
-                                               $query = $data['query'];
+                                               $query           = 
$data['query'];
                                                $querymethod = " $where 
spbudact_code = '{$query}'";
                                                break;
 
                                        case 'dimb':
-                                               $query = (int) $data['query'];
+                                               $query           = (int) 
$data['query'];
                                                $querymethod = " $where dimb = 
{$query}";
                                                break;
 
@@ -2488,13 +2502,13 @@
                        . " {$this->join} fm_ecoart ON fm_ecoart.id = 
fm_ecobilag.artid"
                        . " $filtermethod $querymethod ORDER BY forfallsdato 
ASC, bilagsnr ASC";
 
-                       $lang_voucer = lang('voucher id');
-                       $lang_vendor = lang('vendor');
-                       $lang_currency = lang('currency');
-                       $lang_parked = lang('parked');
-                       $lang_type = lang('type');
-                       $lang_approved_amount = lang('approved amount');
-                       $lang_payment_date = lang('payment date');
+                       $lang_voucer                     = lang('voucher id');
+                       $lang_vendor                     = lang('vendor');
+                       $lang_currency                   = lang('currency');
+                       $lang_parked                     = lang('parked');
+                       $lang_type                               = lang('type');
+                       $lang_approved_amount    = lang('approved amount');
+                       $lang_payment_date               = lang('payment date');
 
                        $this->db->query($sql, __LINE__, __FILE__);
                        $values = array();
@@ -2503,12 +2517,12 @@
                        {
                                $bilagsnr = $this->db->f('bilagsnr');
 
-                               $values[$bilagsnr]['bilagsnr_ut'] = 
$this->db->f('bilagsnr_ut');
-                               $values[$bilagsnr]['org_name'] = 
$this->db->f('org_name', true);
-                               $values[$bilagsnr]['currency'] = 
$this->db->f('currency');
-                               $values[$bilagsnr]['kreditnota'] = 
$this->db->f('kreditnota');
-                               $values[$bilagsnr]['type'] = 
$this->db->f('type');
-                               $values[$bilagsnr]['payment_date'] = 
$this->db->f('forfallsdato');
+                               $values[$bilagsnr]['bilagsnr_ut']        = 
$this->db->f('bilagsnr_ut');
+                               $values[$bilagsnr]['org_name']           = 
$this->db->f('org_name', true);
+                               $values[$bilagsnr]['currency']           = 
$this->db->f('currency');
+                               $values[$bilagsnr]['kreditnota']         = 
$this->db->f('kreditnota');
+                               $values[$bilagsnr]['type']                      
 = $this->db->f('type');
+                               $values[$bilagsnr]['payment_date']       = 
$this->db->f('forfallsdato');
 
                                if(isset($values[$bilagsnr]['godkjentbelop']))
                                {
@@ -2539,12 +2553,12 @@
                        $voucers = array();
                        foreach($values as $bilagsnr => $entry)
                        {
-                               $payment_date = 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'], 
strtotime($entry['payment_date']));
-                               $status = $entry['status'];
+                               $payment_date    = 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'], 
strtotime($entry['payment_date']));
+                               $status                  = $entry['status'];
                                sort($status);
 
-                               $voucher_id = $entry['bilagsnr_ut'] ? 
$entry['bilagsnr_ut'] : $bilagsnr;
-                               $name = sprintf("{$lang_payment_date}: % 10s | 
{$lang_voucer}:% 8s | {$lang_vendor}: % 50s | {$lang_currency}: % 3s | 
{$lang_parked}: % 1s | {$lang_type}: % 12s | {$lang_approved_amount}: % 19s | 
Status: % 1s", $payment_date, $voucher_id, 
trim(strtoupper($entry['org_name'])), $entry['currency'], $entry['kreditnota'] 
? 'X' : '', $entry['type'], number_format($entry['godkjentbelop'], 2, ',', ' 
'), $status[0]
+                               $voucher_id      = $entry['bilagsnr_ut'] ? 
$entry['bilagsnr_ut'] : $bilagsnr;
+                               $name            = 
sprintf("{$lang_payment_date}: % 10s | {$lang_voucer}:% 8s | {$lang_vendor}: % 
50s | {$lang_currency}: % 3s | {$lang_parked}: % 1s | {$lang_type}: % 12s | 
{$lang_approved_amount}: % 19s | Status: % 1s", $payment_date, $voucher_id, 
trim(strtoupper($entry['org_name'])), $entry['currency'], $entry['kreditnota'] 
? 'X' : '', $entry['type'], number_format($entry['godkjentbelop'], 2, ',', ' 
'), $status[0]
                                );
 
                                $voucers[] = array
@@ -2559,8 +2573,8 @@
 
                public function get_auto_generated_invoice_num($vendor_id)
                {
-                       $vendor_id = (int) $vendor_id;
-                       $sql = "SELECT max(cast(fakturanr as int)) as 
invoice_num FROM fm_ecobilagoverf WHERE spvend_code = {$vendor_id}";
+                       $vendor_id       = (int) $vendor_id;
+                       $sql             = "SELECT max(cast(fakturanr as int)) 
as invoice_num FROM fm_ecobilagoverf WHERE spvend_code = {$vendor_id}";
                        $this->db->query($sql, __LINE__, __FILE__);
                        $this->db->next_record();
                        $invoice_num = $this->db->f('invoice_num') + 1;




reply via email to

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