fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [10622] Property: update accounting reporting


From: Sigurd Nes
Subject: [Fmsystem-commits] [10622] Property: update accounting reporting
Date: Sat, 29 Dec 2012 12:52:55 +0000

Revision: 10622
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10622
Author:   sigurdne
Date:     2012-12-29 12:52:54 +0000 (Sat, 29 Dec 2012)
Log Message:
-----------
Property: update accounting reporting

Modified Paths:
--------------
    trunk/property/inc/class.bobudget.inc.php
    trunk/property/inc/class.sobudget.inc.php
    trunk/property/inc/class.uibudget.inc.php
    trunk/property/setup/phpgw_no.lang

Modified: trunk/property/inc/class.bobudget.inc.php
===================================================================
--- trunk/property/inc/class.bobudget.inc.php   2012-12-28 14:17:00 UTC (rev 
10621)
+++ trunk/property/inc/class.bobudget.inc.php   2012-12-29 12:52:54 UTC (rev 
10622)
@@ -88,9 +88,16 @@
                        $revision                               = 
phpgw::get_var('revision', 'int');
                        $allrows                                = 
phpgw::get_var('allrows', 'bool');
                        $details                                = 
phpgw::get_var('details', 'bool');
+                       $direction                              = 
phpgw::get_var('direction');
 
                        $this->start                    = $start;
-                       $this->query                    = isset($query) ? 
$query : $this->query;
+                       $this->query                    = $query ? $query : 
$this->query;
+                       $this->direction                = $direction ? 
$direction : $this->direction;
+                       if( !$this->direction )
+                       {
+                               $this->direction = 'expences';
+                       }
+                       
                        $this->filter                   = isset($filter) && 
$filter ? $filter : '';
                        $this->sort                             = isset($sort) 
&& $sort ? $sort : '';
                        $this->order                    = isset($order) && 
$order ? $order : '';
@@ -133,6 +140,7 @@
                        $this->cat_id                   = 
isset($data['cat_id'])?$data['cat_id']:'';
                        $this->dimb_id                  = 
isset($data['dimb_id'])?$data['dimb_id']:'';
                        $this->details                  = 
isset($data['details'])?$data['details']:'';
+                       $this->direction                = 
isset($data['direction'])?$data['direction']:'';
                }
 
                function check_perms($has, $needed)
@@ -183,7 +191,8 @@
                                'sort' => strtoupper($this->sort), 'order' => 
$this->order, 'filter' => $this->filter,
                                'cat_id' => $this->cat_id, 
'allrows'=>$this->allrows, 'district_id' => $this->district_id,
                                'year' => $this->year, 'grouping' => 
$this->grouping, 'revision' => $this->revision,
-                               'details' => $this->details,'dimb_id' => 
$this->dimb_id, 'department' => $this->department));
+                               'details' => $this->details,'dimb_id' => 
$this->dimb_id, 'department' => $this->department,
+                               'direction'     => $this->direction));
 
                        $this->total_records            = 
$this->so->total_records;
                        $this->sum_budget_cost          = 
$this->so->sum_budget_cost;

Modified: trunk/property/inc/class.sobudget.inc.php
===================================================================
--- trunk/property/inc/class.sobudget.inc.php   2012-12-28 14:17:00 UTC (rev 
10621)
+++ trunk/property/inc/class.sobudget.inc.php   2012-12-29 12:52:54 UTC (rev 
10622)
@@ -533,17 +533,28 @@
                        $details                = isset($data['details']) ? 
$data['details'] : '';
                        $dimb_id                = isset($data['dimb_id'])  && 
$data['dimb_id'] ? (int)$data['dimb_id'] : 0;
                        $department             = isset($data['department'])  
&& $data['department'] ? (int)$data['department'] : 0;
+                       $direction              = isset($data['direction'])  && 
$data['direction'] ? $data['direction'] : 'expences';
 
                        if(!$year)
                        {
                                return array();
                        }
-                       //_debug_array($allrows);
-                       $ordermethod = '';
+
+                       $filtermethod_direction = '';
+
+                       if($direction == 'income')
+                       {
+                               $filtermethod_direction = "fm_b_account.id 
{$this->like} '3%'";
+                       }
+                       else
+                       {
+                               $filtermethod_direction = "fm_b_account.id NOT 
{$this->like} '3%'";
+                       }
+
                        /* 0 => cancelled, 1 => obligation , 2 => paid */
-                       //$filtermethod = "WHERE fm_workorder.paid = 1 and 
fm_workorder.vendor_id > 0";
-//                     $filtermethod = "WHERE fm_workorder.vendor_id > 0";
 
+                       $filtermethod = '';
+
                        $start_date = mktime(1, 1, 1, 1, 1, $year);
                        $end_date = mktime  (23, 59, 59, 12, 31, $year);
 
@@ -551,6 +562,7 @@
                        $end_periode = date('Ym',mktime(2,0,0,12,31,$year));
 
 
+
                        $filtermethod .= " WHERE (fm_workorder.start_date >= 
$start_date AND fm_workorder.start_date <= $end_date";
                        $filtermethod .= " OR fm_workorder_status.closed IS 
NULL AND fm_workorder.start_date < $start_date)";
 
@@ -648,7 +660,7 @@
                                . " {$this->left_join} 
fm_orders_pending_cost_view ON  fm_workorder.id = 
fm_orders_pending_cost_view.order_id"
                                . " {$_join_district}"
                                . " {$this->join} fm_part_of_town ON 
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id"
-                               . " {$filtermethod} {$querymethod}";
+                               . " {$filtermethod} {$querymethod} {$where} 
{$filtermethod_direction}";
 
                        //_debug_array($sql);
                        //die();
@@ -672,13 +684,13 @@
                                unset($_id);
                                $_pending_cost = 
round($this->db->f('pending_cost'));
 
-                               $_taxfactor = 1 + 
($_taxcode[(int)$this->db->f('mvakode')]/100);
+                               $_taxfactor = 1 + 
($_taxcode[(int)$this->db->f('mva')]/100);
                                $_actual_cost = 
round($this->db->f('actual_cost')/$_taxfactor);
                //              $_actual_cost = 
round($this->db->f('actual_cost'));
                                $_obligation = $_combined_cost - $_actual_cost 
- $_pending_cost;
 
-                               
-                               // only current year
+
+                               // only the current year
                                if($this->db->f('start_date') < $start_date)
                                {
                                        $_actual_cost = 0;
@@ -766,7 +778,7 @@
                                . " FROM fm_tts_tickets"
                                . " $this->join fm_b_account ON 
fm_tts_tickets.b_account_id = fm_b_account.id "
                                . " $this->join fm_location1 ON 
fm_tts_tickets.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 $filtermethod 
$filtermethod2 $querymethod GROUP BY 
fm_b_account.{$b_account_field},district_id,fm_tts_tickets.ecodimb";
+                               . " $this->join fm_part_of_town ON 
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id $filtermethod 
$filtermethod2 $querymethod  {$where} {$filtermethod_direction} GROUP BY 
fm_b_account.{$b_account_field},district_id,fm_tts_tickets.ecodimb";
 
                        //_debug_array($sql);die();
                        $this->db->query($sql . $ordermethod,__LINE__,__FILE__);
@@ -791,7 +803,7 @@
                                . " FROM fm_tts_tickets"
                                . " $this->join fm_b_account ON 
fm_tts_tickets.b_account_id = fm_b_account.id "
                                . " $this->join fm_location1 ON 
fm_tts_tickets.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 $filtermethod 
$querymethod GROUP BY 
fm_b_account.{$b_account_field},district_id,fm_tts_tickets.ecodimb";
+                               . " $this->join fm_part_of_town ON 
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id $filtermethod 
$querymethod  {$where} {$filtermethod_direction} GROUP BY 
fm_b_account.{$b_account_field},district_id,fm_tts_tickets.ecodimb";
 
 
                        $sql = str_replace('budget', 'actual_cost', $sql);
@@ -861,12 +873,14 @@
                        if( $details )
                        {
                                $sql = "SELECT budget_cost,b_account_id as 
b_account_field,district_id,ecodimb FROM fm_budget"
-                                       . " {$this->join} fm_b_account ON 
fm_budget.b_account_id =fm_b_account.id WHERE year={$year} AND revision = 
'$revision' $filtermethod GROUP BY 
budget_cost,b_account_id,district_id,ecodimb";
+                                       . " {$this->join} fm_b_account ON 
fm_budget.b_account_id =fm_b_account.id WHERE year={$year} AND revision = 
'$revision' $filtermethod {$where} {$filtermethod_direction}"
+                                       . " GROUP BY 
budget_cost,b_account_id,district_id,ecodimb";
                        }
                        else
                        {
                                $sql = "SELECT sum(budget_cost) as budget_cost 
,fm_b_account.category as b_account_field,district_id,ecodimb FROM fm_budget"
-                                       . " $this->join fm_b_account ON 
fm_budget.b_account_id =fm_b_account.id WHERE year={$year} AND revision = 
'$revision' $filtermethod GROUP BY fm_b_account.category,district_id,ecodimb";
+                                       . " $this->join fm_b_account ON 
fm_budget.b_account_id =fm_b_account.id WHERE year={$year} AND revision = 
'$revision' $filtermethod  {$where} {$filtermethod_direction}"
+                                       . " GROUP BY 
fm_b_account.category,district_id,ecodimb";
                        }
                        //_debug_array($sql);
                        $this->db->query($sql,__LINE__,__FILE__);
@@ -920,7 +934,7 @@
                                . " FROM fm_s_agreement"
                                . " {$this->join} fm_s_agreement_budget ON 
fm_s_agreement.id = fm_s_agreement_budget.agreement_id"
                                . " $this->join fm_b_account ON 
fm_s_agreement_budget.budget_account = fm_b_account.id "
-                               . " WHERE $filtermethod $querymethod GROUP BY 
fm_b_account.{$b_account_field},fm_s_agreement_budget.ecodimb";
+                               . " WHERE $filtermethod $querymethod {$where} 
{$filtermethod_direction} GROUP BY 
fm_b_account.{$b_account_field},fm_s_agreement_budget.ecodimb";
 
                        //_debug_array($sql);die();
                        $this->db->query($sql . $ordermethod,__LINE__,__FILE__);
@@ -948,7 +962,7 @@
                                . " {$this->join} fm_b_account ON 
fm_ecobilagoverf.spbudact_code =fm_b_account.id"
                                . " {$this->join} fm_s_agreement ON 
fm_ecobilagoverf.pmwrkord_code = fm_s_agreement.id"
                                . " {$this->join} fm_s_agreement_budget ON 
fm_s_agreement.id = fm_s_agreement_budget.agreement_id"
-                               . " WHERE periode >= $start_periode AND periode 
<= $end_periode AND {$filtermethod}"
+                               . " WHERE periode >= $start_periode AND periode 
<= $end_periode AND {$filtermethod} {$where} {$filtermethod_direction}"
                                . " GROUP BY fm_b_account.{$b_account_field}, 
ecodimb";
 //_debug_array($sql);
                        $this->db->query($sql,__LINE__,__FILE__);
@@ -1003,7 +1017,7 @@
                                . " {$this->join} fm_b_account ON 
fm_ecobilag.spbudact_code =fm_b_account.id"
                                . " {$this->join} fm_s_agreement ON 
fm_ecobilag.pmwrkord_code = fm_s_agreement.id"
                                . " {$this->join} fm_s_agreement_budget ON 
fm_s_agreement.id = fm_s_agreement_budget.agreement_id"
-                               . " {$filtermethod}"
+                               . " {$filtermethod} {$where} 
{$filtermethod_direction}"
                                . " GROUP BY fm_b_account.{$b_account_field}, 
ecodimb";
 //_debug_array($sql);
                        $this->db->query($sql,__LINE__,__FILE__);

Modified: trunk/property/inc/class.uibudget.inc.php
===================================================================
--- trunk/property/inc/class.uibudget.inc.php   2012-12-28 14:17:00 UTC (rev 
10621)
+++ trunk/property/inc/class.uibudget.inc.php   2012-12-29 12:52:54 UTC (rev 
10622)
@@ -78,6 +78,7 @@
                        $this->grouping         = $this->bo->grouping;
                        $this->revision         = $this->bo->revision;
                        $this->details          = $this->bo->details;
+                       $this->direction        = $this->bo->direction;
 
                        $this->acl                      = & 
$GLOBALS['phpgw']->acl;
 
@@ -94,7 +95,8 @@
                                        'filter'                => 
$this->filter,
                                        'cat_id'                => 
$this->cat_id,
                                        'dimb_id'               => 
$this->dimb_id,
-                                       'allrows'               => 
$this->allrows
+                                       'allrows'               => 
$this->allrows,
+                                       'direction'             => 
$this->direction
                                );
                        $this->bo->save_sessiondata($data);
                }
@@ -994,21 +996,22 @@
                        $datatable = array();
                        $values_combo_box = array();
                        $dry_run = false;
-
+                       $this->save_sessiondata();
                        if( phpgw::get_var('phpgw_return_as') != 'json' )
                        {
                                $datatable['config']['base_url']        = 
$GLOBALS['phpgw']->link('/index.php', array
                                        (
-                                               'menuaction'    
=>'property.uibudget.obligations',
-                                               'cat_id'                
=>$this->cat_id,
-                                               'filter'                
=>$this->filter,
-                                               'query'                 
=>$this->query,
-                                               'district_id'   
=>$this->district_id,
-                                               'grouping'              
=>$this->grouping,
-                                               'year'                  
=>$this->year,
+                                               'menuaction'    => 
'property.uibudget.obligations',
+                                               'cat_id'                => 
$this->cat_id,
+                                               'filter'                => 
$this->filter,
+                                               'query'                 => 
$this->query,
+                                               'district_id'   => 
$this->district_id,
+                                               'grouping'              => 
$this->grouping,
+                                               'year'                  => 
$this->year,
                                                'details'               => 
$this->details,
                                                'allrows'               => 
$this->allrows,
-                                               'dimb_id'               
=>$this->dimb_id
+                                               'dimb_id'               => 
$this->dimb_id,
+                                               'direction'             => 
$this->direction
                                        ));
                                $datatable['config']['allow_allrows'] = true;
 
@@ -1021,6 +1024,7 @@
                                        ."year:'{$this->year}',"
                                        ."details:'{$this->details}',"
                                        ."dimb_id:'{$this->dimb_id}',"
+                                       ."direction:'{$this->direction}',"
                                        ."allrows:'{$this->allrows}',"
                                        ."download:'obligations'";
 
@@ -1062,6 +1066,23 @@
                                $default_value = array 
('id'=>'','name'=>lang('no dimb'));
                                array_unshift 
($values_combo_box[5],$default_value);
 
+
+                               $values_combo_box[6]  = array
+                               (
+                                       array
+                                       (
+                                               'id' => 'expences',
+                                               'name'  => lang('expences'),
+                                               'selected'      => 
$this->direction == 'expences' ? 1 : 0
+                                       ),
+                                       array
+                                       (
+                                               'id' => 'income',
+                                               'name'  => lang('income'),
+                                               'selected'      => 
$this->direction == 'income' ? 1 : 0
+                                       )
+                               );
+
                                $datatable['actions']['form'] = array
                                        (
                                                array
@@ -1167,15 +1188,27 @@
                                                                        'style' 
=> 'filter',
                                                                        
'values' => $values_combo_box[5],
                                                                        
'onchange'=> 'onChangeSelect("dimb_id");',
-                                                                       
'tab_index' => 5
+                                                                       
'tab_index' => 6
                                                                ),
+                                                               array
+                                                               ( //boton       
USER
+                                                                       //      
'id' => 'btn_user_id',
+                                                                       'id' => 
'sel_direction',
+                                                                       'name' 
=> 'direction',
+                                                                       'value' 
=> lang('direction'),
+                                                                       'type' 
=> 'select',
+                                                                       'style' 
=> 'filter',
+                                                                       
'values' => $values_combo_box[6],
+                                                                       
'onchange'=> 'onChangeSelect("direction");',
+                                                                       
'tab_index' => 7
+                                                               ),
 
                                                                array
                                                                (
                                                                        'type'  
=> 'button',
                                                                        'id'    
=> 'btn_export',
                                                                        'value' 
=> lang('download'),
-                                                                       
'tab_index' => 8
+                                                                       
'tab_index' => 10
                                                                ),
                                                                array
                                                                ( //boton     
SEARCH
@@ -1183,7 +1216,7 @@
                                                                        'name'  
        => 'search',
                                                                        'value' 
        => lang('search'),
                                                                        'type'  
        => 'button',
-                                                                       
'tab_index' => 7
+                                                                       
'tab_index' => 9
                                                                ),
                                                                array
                                                                ( // TEXT IMPUT
@@ -1193,7 +1226,7 @@
                                                                        'type'  
        => 'text',
                                                                        'size'  
        => 28,
                                                                        
'onkeypress'=> 'return pulsar(event)',
-                                                                       
'tab_index' => 6
+                                                                       
'tab_index' => 8
                                                                )
                                                        ),
                                                        'hidden_value' => array

Modified: trunk/property/setup/phpgw_no.lang
===================================================================
--- trunk/property/setup/phpgw_no.lang  2012-12-28 14:17:00 UTC (rev 10621)
+++ trunk/property/setup/phpgw_no.lang  2012-12-29 12:52:54 UTC (rev 10622)
@@ -5,6 +5,8 @@
 %1 group       property        no      %1 gruppe
 %1 is notified property        no      Melding sendt til %1
 %1 properties has been updated to not active of %2 already not active  
property        no      %1 Eiendommer er oppdatert til IKKE AKTIVE av %2 som 
var IKKE AKTIVE fra før
+expences       property        no      Utgifter
+income property        no      Inntekter
 about  common  no      Om
 access error   property        no      Manglende tilgang
 accounting     property        no      Regnskap




reply via email to

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