fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [10582] property: more on condition survey


From: Sigurd Nes
Subject: [Fmsystem-commits] [10582] property: more on condition survey
Date: Mon, 10 Dec 2012 14:28:56 +0000

Revision: 10582
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10582
Author:   sigurdne
Date:     2012-12-10 14:28:47 +0000 (Mon, 10 Dec 2012)
Log Message:
-----------
property: more on condition survey

Modified Paths:
--------------
    trunk/property/inc/class.bocondition_survey.inc.php
    trunk/property/inc/class.socondition_survey.inc.php
    trunk/property/inc/class.uicondition_survey.inc.php
    trunk/property/setup/phpgw_no.lang
    trunk/property/templates/base/condition_survey.xsl

Modified: trunk/property/inc/class.bocondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.bocondition_survey.inc.php 2012-12-10 12:52:07 UTC 
(rev 10581)
+++ trunk/property/inc/class.bocondition_survey.inc.php 2012-12-10 14:28:47 UTC 
(rev 10582)
@@ -57,6 +57,9 @@
                        $this->bocommon         = 
CreateObject('property.bocommon');
                        $this->dateformat                       = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
 
+                       $this->cats                                     = 
CreateObject('phpgwapi.categories', -1, 'property', $this->acl_location);
+                       $this->cats->supress_info       = true;
+
                        $start                          = 
phpgw::get_var('start', 'int', 'REQUEST', 0);
                        $query                          = 
phpgw::get_var('query');
                        $sort                           = 
phpgw::get_var('sort');
@@ -301,6 +304,28 @@
                        }
                }
 
+               public function get_summation($id)
+               {
+                       $data = $this->so->get_summation($id);
+
+                       $values =array();
+                       foreach ($data as $entry)
+                       {
+                               
$values[$entry['building_part']][$entry['cat_id']][$entry['year']] += 
$entry['amount'];
+
+       //                      $entry['category'] = 
$this->get_category_name($entry['cat_id']);
+                       }
+_debug_array($values);
+                       return $values;
+               }
+
+               function get_category_name($cat_id)
+               {
+                       $category = $this->cats->return_single($cat_id);
+                       return $category[0]['name'];
+               }
+
+
                public function delete($id)
                {
                        try

Modified: trunk/property/inc/class.socondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.socondition_survey.inc.php 2012-12-10 12:52:07 UTC 
(rev 10581)
+++ trunk/property/inc/class.socondition_survey.inc.php 2012-12-10 14:28:47 UTC 
(rev 10582)
@@ -349,6 +349,31 @@
                        $this->_db->transaction_commit();
                }
 
+               public function get_summation($id)
+               {
+                       $table = 'fm_request';
+
+                       $condition_survey_id            = (int)$id;
+                       $sql = "SELECT category as cat_id, 
building_part,fm_request_planning.amount, fm_request_planning.date FROM 
{$table} {$this->_join} fm_request_planning ON fm_request_planning.request_id = 
{$table}.id  WHERE condition_survey_id={$condition_survey_id}";
+
+                       $this->_db->query($sql,__LINE__,__FILE__);
+
+                       $values = array();
+                       while ($this->_db->next_record())
+                       {
+                               $values[] = array
+                               (
+                                       'building_part'         => 
$this->_db->f('building_part'),
+                                       'amount'                        => 
$this->_db->f('amount'),
+                                       'year'                          => 
date('Y', $this->_db->f('date')),
+                                       'cat_id'                        => 
$this->_db->f('cat_id'),
+                               );
+                       }
+
+                       return $values;
+               }
+
+
                public function delete($id)
                {
                        $id = (int) $id;

Modified: trunk/property/inc/class.uicondition_survey.inc.php
===================================================================
--- trunk/property/inc/class.uicondition_survey.inc.php 2012-12-10 12:52:07 UTC 
(rev 10581)
+++ trunk/property/inc/class.uicondition_survey.inc.php 2012-12-10 14:28:47 UTC 
(rev 10582)
@@ -48,6 +48,7 @@
                        'edit_survey_title'     => true,
                        'get_files'                     => true,
                        'get_related'           => true,
+                       'get_summation'         => true,
                        'view_file'                     => true,
                        'import'                        => true
                );
@@ -306,6 +307,7 @@
                        $active_tab = 'generic';
                        $tabs['documents']      = array('label' => 
lang('documents'), 'link' => null);
                        $tabs['related']        = array('label' => 
lang('related'), 'link' => null);
+                       $tabs['summation']      = array('label' => 
lang('summation'), 'link' => null);
                        $tabs['import']         = array('label' => 
lang('import'), 'link' => null);
 
                        if ($id)
@@ -316,6 +318,7 @@
                                }
                                $tabs['documents']['link'] = '#documents';
                                $tabs['related']['link'] = '#related';
+                               $tabs['summation']['link'] = '#summation';
 
                                if (!$values)
                                {
@@ -378,6 +381,26 @@
                                'ColumnDefs'    => json_encode($related_def)
                        );
 
+                       $summation_def = array
+                       (
+                               array('key' => 
'building_part','label'=>lang('building 
part'),'sortable'=>false,'resizeable'=>true),
+                               array('key' => 
'category','label'=>lang('category'),'sortable'=>true,'resizeable'=>true),
+                               array('key' => 'period_1','label'=>lang('year') 
. ':: < 1' ,'sortable'=>false,'resizeable'=>true),
+                               array('key' => 'period_1','label'=>lang('year') 
. ':: 1 - 5' ,'sortable'=>false,'resizeable'=>true),
+                               array('key' => 'period_1','label'=>lang('year') 
. ':: 6 - 10' ,'sortable'=>false,'resizeable'=>true),
+                               array('key' => 'period_1','label'=>lang('year') 
. ':: 11 - 15' ,'sortable'=>false,'resizeable'=>true),
+                               array('key' => 'period_1','label'=>lang('year') 
. ':: 16 - 20' ,'sortable'=>false,'resizeable'=>true),
+                               array('key' => 'period_1','label'=>lang('year') 
. ':: 21 +' ,'sortable'=>false,'resizeable'=>true),
+                               array('key' => 
'sum','label'=>lang('sum'),'sortable'=>false,'resizeable'=>true),
+                       );
+
+                       $datatable_def[] = array
+                       (
+                               'container'             => 
'datatable-container_2',
+                               'requestUrl'    => 
json_encode(self::link(array('menuaction' => 
'property.uicondition_survey.get_summation', 'id' => 
$id,'phpgw_return_as'=>'json'))),
+                               'ColumnDefs'    => json_encode($summation_def)
+                       );
+
                        $data = array
                        (
                                'datatable_def'                                 
=> $datatable_def,
@@ -559,6 +582,49 @@
 
                }
 
+               function get_summation()
+               {
+                       $id     = phpgw::get_var('id', 'int', 'REQUEST');
+
+                       if( !$this->acl_read)
+                       {
+                               return;
+                       }
+
+                       $values = $this->bo->get_summation($id);
+                       
+                       $total_records = count($values);
+
+                       $num_rows = 
isset($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']) && 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] ? (int) 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] : 15;      
                
+                       $start = phpgw::get_var('startIndex', 'int', 'REQUEST', 
0);
+
+                       if($allrows)
+                       {
+                               $out = $values;
+                       }
+                       else
+                       {
+                               $page = ceil( ( $start / $total_records ) * 
($total_records/ $num_rows) );
+                               $values_part = array_chunk($values, $num_rows);
+                               $out = $values_part[$page];
+                       }
+
+
+                       $data = array(
+                                'ResultSet' => array(
+                                       'totalResultsAvailable' => 
$total_records,
+                                       'startIndex' => $start,
+                                       'sortKey' => 'type', 
+                                       'sortDir' => "ASC", 
+                                       'Result' => $out,
+                                       'pageSize' => $num_rows,
+                                       'activePage' => floor($start / 
$num_rows) + 1
+                               )
+                       );
+                       return $data;
+               }
+
+
                function get_related()
                {
                        $id     = phpgw::get_var('id', 'int', 'REQUEST');
@@ -629,6 +695,8 @@
                }
 
 
+
+
                /**
                * Dowloads a single file to the browser
                *

Modified: trunk/property/setup/phpgw_no.lang
===================================================================
--- trunk/property/setup/phpgw_no.lang  2012-12-10 12:52:07 UTC (rev 10581)
+++ trunk/property/setup/phpgw_no.lang  2012-12-10 14:28:47 UTC (rev 10582)
@@ -1686,6 +1686,7 @@
 sum calculation        property        no      Sum kalkulasjon
 sum deviation  property        no      Sum avvik
 summary        property        no      Sammendrag
+summation      property        no      Summering
 sum of calculation     property        no      Sum kalkulasjon
 sum tax        property        no      sum mva
 sum workorder  property        no      Sum bestilling

Modified: trunk/property/templates/base/condition_survey.xsl
===================================================================
--- trunk/property/templates/base/condition_survey.xsl  2012-12-10 12:52:07 UTC 
(rev 10581)
+++ trunk/property/templates/base/condition_survey.xsl  2012-12-10 14:28:47 UTC 
(rev 10582)
@@ -256,6 +256,16 @@
                                        </dd>
                                </dl>
                        </div>
+                       <div id="summation">
+                               <dl class="proplist-col">
+                                       <dt>
+                                               <label><xsl:value-of 
select="php:function('lang', 'summation')"/></label>
+                                       </dt>
+                                       <dd>
+                                               <div style="clear:both;" 
id="datatable-container_2"></div>
+                                       </dd>
+                               </dl>
+                       </div>
                        <div id="import">
                                <xsl:choose>
                                        <xsl:when test="editable = 1">




reply via email to

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