fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15245] property: project/workorder sorting


From: sigurdne
Subject: [Fmsystem-commits] [15245] property: project/workorder sorting
Date: Wed, 1 Jun 2016 14:23:29 +0000 (UTC)

Revision: 15245
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15245
Author:   sigurdne
Date:     2016-06-01 14:23:29 +0000 (Wed, 01 Jun 2016)
Log Message:
-----------
property: project/workorder sorting

Modified Paths:
--------------
    trunk/property/inc/class.soinvoice.inc.php
    trunk/property/inc/class.soproject.inc.php
    trunk/property/inc/class.uiproject.inc.php
    trunk/property/inc/class.uiworkorder.inc.php
    trunk/rental/inc/class.uiapplication.inc.php

Modified: trunk/property/inc/class.soinvoice.inc.php
===================================================================
--- trunk/property/inc/class.soinvoice.inc.php  2016-06-01 09:44:13 UTC (rev 
15244)
+++ trunk/property/inc/class.soinvoice.inc.php  2016-06-01 14:23:29 UTC (rev 
15245)
@@ -553,6 +553,18 @@
                                case 'pmwrkord_code':
                                        $ordermethod = " ORDER BY $order $sort";
                                        break;
+                               case 'workorder_id':
+                                       $ordermethod = " ORDER BY pmwrkord_code 
$sort";
+                                       break;
+                               case 'voucher_id':
+                                       $ordermethod = " ORDER BY bilagsnr_ut 
$sort, bilagsnr $sort";
+                                       break;
+                               case 'amount':
+                                       $ordermethod = " ORDER BY belop $sort";
+                                       break;
+                               case 'period':
+                                       $ordermethod = " ORDER BY periode 
$sort";
+                                       break;
                                default:
                                        $ordermethod = " ORDER BY pmwrkord_code 
DESC";
                        }

Modified: trunk/property/inc/class.soproject.inc.php
===================================================================
--- trunk/property/inc/class.soproject.inc.php  2016-06-01 09:44:13 UTC (rev 
15244)
+++ trunk/property/inc/class.soproject.inc.php  2016-06-01 14:23:29 UTC (rev 
15245)
@@ -991,8 +991,34 @@
 
                function project_workorder_data( $data = array() )
                {
+                       $start = isset($data['start']) && $data['start'] ? 
$data['start'] : 0;
                        $project_id = (int)$data['project_id'];
                        $year = (int)$data['year'];
+                       $sort = isset($data['sort']) ? $data['sort'] : 'DESC';
+                       $order = isset($data['order']) ? $data['order'] : 
'fm_workorder';
+                       $results = (isset($data['results']) ? $data['results'] 
: 0);
+
+                       $ordermethod = 'ORDER BY fm_workorder.id DESC';
+
+                       if ($order)
+                       {
+                               switch ($order)
+                               {
+                                       case 'workorder_id':
+                                               $ordermethod = "ORDER BY 
fm_workorder.id {$sort}";
+                                               break;
+                                       case 'title':
+                                               $ordermethod = "ORDER BY 
fm_workorder.title {$sort}";
+                                               break;
+                                       case 'b_account_id':
+                                               $ordermethod = "ORDER BY 
fm_workorder.account_id {$sort}";
+                                               break;
+                                       case 'status':
+                                               $ordermethod = "ORDER BY 
fm_workorder_status.descr {$sort}";
+                                               break;
+                               }
+                       }
+
                        $values = array();
 
                        $filter_year = '';
@@ -1001,20 +1027,29 @@
                                $filter_year = "AND (fm_workorder_budget.year = 
{$year} OR fm_workorder_status.closed IS NULL)";
                        }
 
-                       $this->db->query("SELECT DISTINCT fm_workorder.id AS 
workorder_id, fm_workorder.title, fm_workorder.vendor_id, 
fm_workorder.addition,"
+                       $sql =  "SELECT DISTINCT fm_workorder.id AS 
workorder_id, fm_workorder.title, fm_workorder.vendor_id, 
fm_workorder.addition,"
                                . " fm_workorder_status.descr as status, 
fm_workorder_status.closed, fm_workorder.account_id AS b_account_id, 
fm_workorder.charge_tenant,"
                                . " fm_workorder.mail_recipients"
                                . " FROM fm_workorder"
                                . " {$this->join} fm_workorder_status ON 
fm_workorder.status = fm_workorder_status.id"
                                . " {$this->join} fm_workorder_budget ON 
fm_workorder.id = fm_workorder_budget.order_id"
+                               . " WHERE project_id={$project_id} 
{$filter_year} {$ordermethod}";
+
+                       $this->db->query("SELECT count(fm_workorder.id) AS cnt 
FROM fm_workorder"
+                               . " {$this->join} fm_workorder_status ON 
fm_workorder.status = fm_workorder_status.id"
+                               . " {$this->join} fm_workorder_budget ON 
fm_workorder.id = fm_workorder_budget.order_id"
                                . " WHERE project_id={$project_id} 
{$filter_year}", __LINE__, __FILE__);
+                               
+                       $this->db->next_record();
+                       $this->total_records = (int)$this->db->f('cnt');
 
+                       $this->db->limit_query($sql, $start, __LINE__, 
__FILE__, $results);
+
                        $_orders = array();
 
                        while ($this->db->next_record())
                        {
-                               $values[] = array
-                                       (
+                               $values[] = array(
                                        'workorder_id' => 
$this->db->f('workorder_id'),
                                        'title' => $this->db->f('title', true),
                                        'vendor_id' => 
$this->db->f('vendor_id'),

Modified: trunk/property/inc/class.uiproject.inc.php
===================================================================
--- trunk/property/inc/class.uiproject.inc.php  2016-06-01 09:44:13 UTC (rev 
15244)
+++ trunk/property/inc/class.uiproject.inc.php  2016-06-01 14:23:29 UTC (rev 
15245)
@@ -1648,8 +1648,8 @@
 
                                $budget_def = array
                                        (
-                                       array('key' => 'year', 'label' => 
lang('year'), 'sortable' => false, 'value_footer' => lang('Sum')),
-                                       array('key' => 'entry_date', 'label' => 
lang('entry date'), 'sortable' => true),
+                                       array('key' => 'year', 'label' => 
lang('year'), 'sortable' => true, 'value_footer' => lang('Sum')),
+                                       array('key' => 'entry_date', 'label' => 
lang('entry date'), 'sortable' => false),
                                        array('key' => 'amount_in', 'label' => 
lang('amount in'), 'sortable' => false,
                                                'className' => 'right', 
'formatter' => 'JqueryPortico.FormatterAmount0', 'value_footer' => 
number_format($s_amount_in, 0, $this->decimal_separator, '.')),
                                        array('key' => 'from_project', 'label' 
=> lang('from project'), 'sortable' => true,
@@ -1665,7 +1665,7 @@
                        {
                                $budget_def = array
                                        (
-                                       array('key' => 'year', 'label' => 
lang('year'), 'sortable' => false, 'value_footer' => lang('Sum')),
+                                       array('key' => 'year', 'label' => 
lang('year'), 'sortable' => true, 'value_footer' => lang('Sum')),
                                        array('key' => 'month', 'label' => 
lang('month'), 'sortable' => false),
                                        array('key' => 'budget', 'label' => 
lang('budget'), 'sortable' => false, 'className' => 'right',
                                                'formatter' => 
'JqueryPortico.FormatterAmount0', 'value_footer' => number_format($s_budget, 0, 
$this->decimal_separator, '.')),
@@ -1714,18 +1714,18 @@
                                array('key' => 'title', 'label' => 
lang('title'), 'sortable' => true),
                                array('key' => 'b_account_id', 'label' => 
lang('Budget account'), 'sortable' => true,
                                        'className' => 'right'),
-                               array('key' => 'budget', 'label' => 
lang('budget'), 'sortable' => true, 'className' => 'right',
+                               array('key' => 'budget', 'label' => 
lang('budget'), 'sortable' => false, 'className' => 'right',
                                        'formatter' => 
'JqueryPortico.FormatterAmount0'),
-                               array('key' => 'cost', 'label' => lang('cost'), 
'sortable' => true, 'className' => 'right',
+                               array('key' => 'cost', 'label' => lang('cost'), 
'sortable' => false, 'className' => 'right',
                                        'formatter' => 
'JqueryPortico.FormatterAmount0'),
                                array('key' => 'addition_percentage', 'label' 
=> '%', 'sortable' => false, 'className' => 'right'),
-                               array('key' => 'obligation', 'label' => 
lang('sum orders'), 'sortable' => true,
+                               array('key' => 'obligation', 'label' => 
lang('sum orders'), 'sortable' => false,
                                        'className' => 'right', 'formatter' => 
'JqueryPortico.FormatterAmount0'),
-                               array('key' => 'actual_cost', 'label' => 
lang('actual cost'), 'sortable' => true,
+                               array('key' => 'actual_cost', 'label' => 
lang('actual cost'), 'sortable' => false,
                                        'className' => 'right', 'formatter' => 
'JqueryPortico.FormatterAmount0'),
-                               array('key' => 'diff', 'label' => 
lang('difference'), 'sortable' => true, 'className' => 'right',
+                               array('key' => 'diff', 'label' => 
lang('difference'), 'sortable' => false, 'className' => 'right',
                                        'formatter' => 
'JqueryPortico.FormatterAmount0'),
-                               array('key' => 'vendor_name', 'label' => 
lang('Vendor'), 'sortable' => true),
+                               array('key' => 'vendor_name', 'label' => 
lang('Vendor'), 'sortable' => false),
                                array('key' => 'status', 'label' => 
lang('Status'), 'sortable' => true),
                                array('key' => 'send_order', 'label' => 
lang('send workorder'), 'sortable' => false,
                                        'className' => 'center')
@@ -1740,7 +1740,7 @@
                                'ColumnDefs' => $orders_def,
                                'config' => array(
                                        array('disableFilter' => true),
-                                       array('disablePagination' => true)
+                       //              array('disablePagination' => true)
                                )
                        );
 
@@ -2176,8 +2176,18 @@
 
                        $year = phpgw::get_var('year', 'int');
                        $draw = phpgw::get_var('draw', 'int');
+                       $order = phpgw::get_var('order');
+                       $columns = phpgw::get_var('columns');
 
-                       $values = $this->bo->get_orders(array('project_id' => 
$project_id, 'year' => $year));
+                       $values = $this->bo->get_orders(array(
+                               'start' => phpgw::get_var('start', 'int', 
'REQUEST', 0),
+                               'project_id' => $project_id,
+                               'year' => $year,
+                               'order' => 
$columns[$order[0]['column']]['data'],
+                               'sort' => $order[0]['dir'],
+                               'results' => phpgw::get_var('length', 'int', 
'REQUEST', 0),
+                               )
+                       );
                        foreach ($values as & $_order_entry)
                        {
                                $_order_entry['send_order'] = '';
@@ -2188,7 +2198,7 @@
                                }
                        }
 
-                       $total_records = count($values);
+                       $total_records = $this->bo->so->total_records;
 
                        $result_data = array('results' => $values);
 
@@ -2196,20 +2206,6 @@
                        $result_data['draw'] = $draw;
 
                        return $this->jquery_results($result_data);
-
-                       /* if( phpgw::get_var('phpgw_return_as') == 'json' )
-                         {
-
-                         if(count($content))
-                         {
-                         return json_encode($content);
-                         }
-                         else
-                         {
-                         return "";
-                         }
-                         }
-                         return $content; */
                }
 
                public function get_vouchers()
@@ -2226,11 +2222,24 @@
 
                        $year = phpgw::get_var('year', 'int');
                        $draw = phpgw::get_var('draw', 'int');
+                       $order = phpgw::get_var('order');
+                       $columns = phpgw::get_var('columns');
 
                        $active_invoices = 
execMethod('property.soinvoice.read_invoice_sub_sum', array(
-                               'project_id' => $project_id, 'year' => $year));
+                               'project_id' => $project_id,
+                               'year' => $year,
+                               'order' => 
$columns[$order[0]['column']]['data'],
+                               'sort' => $order[0]['dir'],
+                               )
+                       );
                        $historical_invoices = 
execMethod('property.soinvoice.read_invoice_sub_sum', array(
-                               'project_id' => $project_id, 'year' => $year, 
'paid' => true));
+                               'project_id' => $project_id,
+                               'year' => $year,
+                               'paid' => true,
+                               'order' => 
$columns[$order[0]['column']]['data'],
+                               'sort' => $order[0]['dir'],
+                               )
+                       );
                        $invoices = array_merge($active_invoices, 
$historical_invoices);
 
                        foreach ($invoices as $entry)

Modified: trunk/property/inc/class.uiworkorder.inc.php
===================================================================
--- trunk/property/inc/class.uiworkorder.inc.php        2016-06-01 09:44:13 UTC 
(rev 15244)
+++ trunk/property/inc/class.uiworkorder.inc.php        2016-06-01 14:23:29 UTC 
(rev 15245)
@@ -1772,7 +1772,7 @@
                                array(
                                        'key' => 'voucher_id',
                                        'label' => lang('bilagsnr'),
-                                       'sortable' => false,
+                                       'sortable' => true,
                                        'value_footer' => lang('Sum')),
                                array(
                                        'key' => 'voucher_out_id',
@@ -1788,19 +1788,19 @@
                                array(
                                        'key' => 'amount',
                                        'label' => lang('amount'),
-                                       'sortable' => false,
+                                       'sortable' => true,
                                        'className' => 'right',
                                        'value_footer' => 
number_format($amount, 2, $this->decimal_separator, '.')),
                                array(
                                        'key' => 'approved_amount',
                                        'label' => lang('approved amount'),
-                                       'sortable' => false,
+                                       'sortable' => true,
                                        'className' => 'right',
                                        'value_footer' => 
number_format($approved_amount, 2, $this->decimal_separator, '.')),
                                array(
                                        'key' => 'period',
                                        'label' => lang('period'),
-                                       'sortable' => false),
+                                       'sortable' => true),
                                array(
                                        'key' => 'periodization',
                                        'label' => lang('periodization'),
@@ -1838,10 +1838,8 @@
                                'data' => json_encode($content_invoice),
                                'ColumnDefs' => $invoice_def,
                                'config' => array(
-                                       array(
-                                               'disableFilter' => true),
-                                       array(
-                                               'disablePagination' => true)
+                                       array('disableFilter' => true),
+//                                     array('disablePagination' => true)
                                )
                        );
 

Modified: trunk/rental/inc/class.uiapplication.inc.php
===================================================================
--- trunk/rental/inc/class.uiapplication.inc.php        2016-06-01 09:44:13 UTC 
(rev 15244)
+++ trunk/rental/inc/class.uiapplication.inc.php        2016-06-01 14:23:29 UTC 
(rev 15245)
@@ -286,8 +286,8 @@
                        $payment_method = array();
                        $payment_method[] = array('id' => 1, 'name' => 
'Faktura');
                        $payment_method[] = array('id' => 2, 'name' => 'Trekk i 
l√łnn');
+                       $payment_method[] = array('id' => 3, 'name' => 'intern 
faktura');
 
-
                        $bocommon = CreateObject('property.bocommon');
 
                        $GLOBALS['phpgw']->jqcal->add_listener('date_start');




reply via email to

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