phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] property/inc class.sobudget.inc.php class.uibud...


From: Sigurd Nes
Subject: [Phpgroupware-cvs] property/inc class.sobudget.inc.php class.uibud...
Date: Sun, 07 May 2006 19:42:49 +0000

CVSROOT:        /sources/phpgroupware
Module name:    property
Branch:         
Changes by:     Sigurd Nes <address@hidden>     06/05/07 19:42:49

Modified files:
        inc            : class.sobudget.inc.php class.uibudget.inc.php 

Log message:
        

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.sobudget.inc.php.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uibudget.inc.php.diff?tr1=1.14&tr2=1.15&r1=text&r2=text

Patches:
Index: property/inc/class.sobudget.inc.php
diff -u property/inc/class.sobudget.inc.php:1.14 
property/inc/class.sobudget.inc.php:1.15
--- property/inc/class.sobudget.inc.php:1.14    Fri May  5 12:09:17 2006
+++ property/inc/class.sobudget.inc.php Sun May  7 19:42:49 2006
@@ -8,7 +8,7 @@
        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
        * @package property
        * @subpackage budget
-       * @version $Id: class.sobudget.inc.php,v 1.14 2006/05/05 12:09:17 
sigurdne Exp $
+       * @version $Id: class.sobudget.inc.php,v 1.15 2006/05/07 19:42:49 
sigurdne Exp $
        */
 
        /**
@@ -21,15 +21,15 @@
                function sobudget()
                {
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $this->account  = 
$GLOBALS['phpgw_info']['user']['account_id'];
-                       $this->bocommon         = 
CreateObject($this->currentapp.'.bocommon');
+                       $this->account          = 
$GLOBALS['phpgw_info']['user']['account_id'];
+                       $this->bocommon = 
CreateObject($this->currentapp.'.bocommon');
                        $this->db               = $this->bocommon->new_db();
                        $this->db2              = $this->bocommon->new_db();
                        $this->account          = 
$GLOBALS['phpgw_info']['user']['account_id'];
 
-                       $this->join                     = $this->bocommon->join;
-                       $this->left_join                = 
$this->bocommon->left_join;
-                       $this->like                     = $this->bocommon->like;
+                       $this->join             = $this->bocommon->join;
+                       $this->left_join        = $this->bocommon->left_join;
+                       $this->like             = $this->bocommon->like;
                }
 
                function read($data)
@@ -477,7 +477,7 @@
                        $this->db2->query($sql,__LINE__,__FILE__);
                        $this->total_records = $this->db2->num_rows();
 
-                       if(!$allrows)
+/*                     if(!$allrows)
                        {
                                $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);
                        }
@@ -485,16 +485,18 @@
                        {
                                $this->db->query($sql . 
$ordermethod,__LINE__,__FILE__);
                        }
+*/
+                       $this->db->query($sql . $ordermethod,__LINE__,__FILE__);
+
+                       if(!$year)
+                       {
+                               $year = date("Y");
+                       }
 
                        while ($this->db->next_record())
                        {
-                               if($this->db->f('b_group')>0)
-                               {
-                                       if(!$year)
-                                       {
-                                               $year = date("Y");
-                                       }
-                                       
+/*                             if($this->db->f('b_group')>0)
+                               {                                       
                                        $this->db2->query("select max(revision) 
as revision from fm_budget_basis where year='$year'",__LINE__,__FILE__);
                                        $this->db2->next_record();
                                        $revision = $this->db2->f('revision');
@@ -511,14 +513,100 @@
                                
                                $obligations[] = array
                                (
-                                       'budget_cost'           => $budget_cost,
                                        'grouping'              => 
$this->db->f('b_group'),
                                        'district_id'           => 
$this->db->f('district_id'),
                                        'obligation'            => 
round($this->db->f('combined_cost')),
                                        'hits'                  => 
$this->db->f('hits')
                                );
+*/                             
+                               
$obligations[$this->db->f('b_group')][$this->db->f('district_id')] = 
round($this->db->f('combined_cost'));
+                               
$hits[$this->db->f('b_group')][$this->db->f('district_id')] = 
$this->db->f('hits');
+                               $grouping[$this->db->f('b_group')] = true;
+                               $district[$this->db->f('district_id')] = true;
+                       }
+
+//_debug_array($obligations);
+                       $this->db->query("select max(revision) as revision from 
fm_budget_basis where year='$year'",__LINE__,__FILE__);
+                       $this->db->next_record();
+                       $revision = $this->db->f('revision');
+
+                       $sql = "select budget_cost,b_group,district_id from 
fm_budget_basis where year='$year' AND revision = '$revision' GROUP BY 
budget_cost,b_group,district_id";
+                       $this->db->query($sql,__LINE__,__FILE__);
+       
+                       $budget_cost = array();
+                       while ($this->db->next_record())
+                       {
+                       /*      $budget_cost[] = array
+                               (
+                                       'grouping'              => 
$this->db->f('b_group'),
+                                       'district_id'           => 
$this->db->f('district_id'),
+                                       'budget_cost'           => 
$this->db->f('budget_cost'),
+                               );
+                       */
+
+                               
$budget_cost[$this->db->f('b_group')][$this->db->f('district_id')] = 
round($this->db->f('budget_cost'));
+                               $grouping[$this->db->f('b_group')] = true;
+                               $district[$this->db->f('district_id')] = true;
                        }
-                       return $obligations;
+
+//_debug_array($budget_cost);
+
+
+                       $start_date = 
date($this->bocommon->dateformat,mktime(2,0,0,1,1,$year));
+                       $end_date = 
date($this->bocommon->dateformat,mktime(2,0,0,12,31,$year));
+
+                       $sql = "SELECT fm_b_account.category as b_group, 
district_id, sum(godkjentbelop) as actual_cost FROM fm_ecobilagoverf"
+                               . " $this->join fm_b_account ON 
fm_ecobilagoverf.spbudact_code =fm_b_account.id "
+                               . " $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 forfallsdato > '$start_date' AND 
forfallsdato < '$end_date'"
+                               . " GROUP BY b_group, district_id";
+                               
+//_debug_array($sql);                          
+                       $this->db->query($sql,__LINE__,__FILE__);
+
+                       while ($this->db->next_record())
+                       {
+/*                             $actual_cost[] = array
+                               (
+                                       'grouping'              => 
$this->db->f('b_group'),
+                                       'district_id'           => 
$this->db->f('district_id'),
+                                       'actual_cost'           => 
round($this->db->f('actual_cost')),
+                               );
+*/
+                               
$actual_cost[$this->db->f('b_group')][$this->db->f('district_id')] = 
round($this->db->f('actual_cost'));
+                               $grouping[$this->db->f('b_group')] = true;
+                               $district[$this->db->f('district_id')] = true;
+                       }
+
+                       ksort($grouping);
+                       ksort($district);                       
+                       $grouping = array_keys($grouping);
+                       $district = array_keys($district);
+                       
+//_debug_array($actual_cost);
+//_debug_array(array_keys($grouping));
+
+                       if (is_array($grouping))
+                       {
+                               foreach($grouping as $b_group)
+                               {       
+                                       foreach($district as $district_id)
+                                       {
+                                               $result[] = array(
+                                                       'grouping'              
=> $b_group,
+                                                       'district_id'           
=> $district_id,
+                                                       'actual_cost'           
=> round($actual_cost[$b_group][$district_id]),
+                                                       'budget_cost'           
=> round($budget_cost[$b_group][$district_id]),
+                                                       'obligation'            
=> round($obligations[$b_group][$district_id]),
+                                                       'hits'          => 
round($hits[$b_group][$district_id]),                                           
             
+                                               );
+                                       }               
+                               }
+                       }
+
+//_debug_array($result);
+                       return $result;
                }
 
                function get_b_group_list()
Index: property/inc/class.uibudget.inc.php
diff -u property/inc/class.uibudget.inc.php:1.14 
property/inc/class.uibudget.inc.php:1.15
--- property/inc/class.uibudget.inc.php:1.14    Fri May  5 12:09:17 2006
+++ property/inc/class.uibudget.inc.php Sun May  7 19:42:49 2006
@@ -8,7 +8,7 @@
        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
        * @package property
        * @subpackage budget
-       * @version $Id: class.uibudget.inc.php,v 1.14 2006/05/05 12:09:17 
sigurdne Exp $
+       * @version $Id: class.uibudget.inc.php,v 1.15 2006/05/07 19:42:49 
sigurdne Exp $
        */
 
        /**
@@ -535,6 +535,8 @@
                                                'grouping'                      
=> $entry['grouping'],
                                                'district_id'                   
=> $entry['district_id'],
                                                'obligation'                    
=> number_format($entry['obligation'], 0, ',', ' '),
+                                               'actual_cost'                   
=> number_format($entry['actual_cost'], 0, ',', ' '),
+                                               'diff'                          
=> number_format($entry['budget_cost'] - $entry['actual_cost'] - 
$entry['obligation'], 0, ',', ' '),
                                                'hits'                          
=> number_format($entry['hits'], 0, ',', ' '),
                                                'link_details'                  
=> 
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->currentapp.'.uiworkorder.index&filter=all&status_id=Bestilt&district_id='
 . $entry['district_id'] . '&b_group=' . $entry['grouping']),
                                                'lang_details_text'             
=> lang('obligation details'),
@@ -543,15 +545,20 @@
                                        $sum_obligation = $sum_obligation + 
$entry['obligation'];
                                        $sum_hits = $sum_hits + $entry['hits'];
                                        $sum_budget_cost = $sum_budget_cost + 
$entry['budget_cost'];
+                                       $sum_actual_cost = $sum_actual_cost + 
$entry['actual_cost'];
                                }
                        }
 
+                       $sum_diff = number_format($sum_budget_cost - 
$sum_actual_cost - $sum_obligation, 0, ',', ' ');
                        $sum_obligation = number_format($sum_obligation, 0, 
',', ' ');
                        $sum_hits = number_format($sum_hits, 0, ',', ' ');
                        $sum_budget_cost = number_format($sum_budget_cost, 0, 
',', ' ');
-                       
+                       $sum_actual_cost = number_format($sum_actual_cost, 0, 
',', ' ');                        
+
                        $table_header[] = array
                        (
+                               'lang_diff'             => lang('difference'),
+                               'lang_actual_cost'      => lang('paid'),
                                'lang_budget_cost'      => lang('budget'),
                                'lang_obligations'      => lang('obligations'),
                                'lang_grouping'         => lang('grouping'),
@@ -646,12 +653,13 @@
                        {
                                $record_limit   = $this->bo->total_records;
                        }
-
                                                
                        $msgbox_data = $this->bocommon->msgbox_data($receipt);
 
                        $data = array
                        (
+                               'sum_actual_cost'                               
=> $sum_actual_cost,
+                               'sum_diff'                                      
=> $sum_diff,
                                'sum_obligation'                                
=> $sum_obligation,
                                'sum_hits'                                      
=> $sum_hits,
                                'sum_budget_cost'                               
=> $sum_budget_cost,




reply via email to

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