fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [14545] property::tts: SQL union search for left join


From: Sigurd Nes
Subject: [Fmsystem-commits] [14545] property::tts: SQL union search for left join on datesearch
Date: Wed, 09 Dec 2015 14:44:51 +0000

Revision: 14545
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14545
Author:   sigurdne
Date:     2015-12-09 14:44:50 +0000 (Wed, 09 Dec 2015)
Log Message:
-----------
property::tts: SQL union search for left join on datesearch

Modified Paths:
--------------
    trunk/phpgwapi/inc/class.db_pdo.inc.php
    trunk/property/inc/class.sotts.inc.php
    trunk/property/inc/class.uitts.inc.php
    trunk/property/js/yahoo/tts.view.js

Modified: trunk/phpgwapi/inc/class.db_pdo.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.db_pdo.inc.php     2015-12-08 00:34:00 UTC (rev 
14544)
+++ trunk/phpgwapi/inc/class.db_pdo.inc.php     2015-12-09 14:44:50 UTC (rev 
14545)
@@ -434,19 +434,15 @@
                }
 
                /**
-               * Execute a query with limited result set
+               * Get the limit statement for a query with limited result set
                *
                * @param string $sql the query to be executed
                * @param integer $offset row to start from
-               * @param integer $line the line method was called from - use 
__LINE__
-               * @param string $file the file method was called from - use 
__FILE__
                * @param integer $num_rows number of rows to return (optional), 
if unset will use 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']
-               * @return integer current query id if sucesful and null if fails
+               * @return string offset and limit
                */
-
-               function limit_query($sql, $offset, $line = '', $file = '', 
$num_rows = 0)
+               function get_offset($sql = '', $offset, $num_rows = 0)
                {
-                       $this->_get_fetchmode();
                        $offset         = (int)$offset;
                        $num_rows       = (int)$num_rows;
 
@@ -482,7 +478,26 @@
                                        $sql .= " LIMIT {$num_rows}";
                                        $sql .=  $offset ? " OFFSET {$offset}" 
: '';
                        }
+                       return $sql;
+               }
 
+               /**
+               * Execute a query with limited result set
+               *
+               * @param string $sql the query to be executed
+               * @param integer $offset row to start from
+               * @param integer $line the line method was called from - use 
__LINE__
+               * @param string $file the file method was called from - use 
__FILE__
+               * @param integer $num_rows number of rows to return (optional), 
if unset will use 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs']
+               * @return integer current query id if sucesful and null if fails
+               */
+
+               function limit_query($sql, $offset, $line = '', $file = '', 
$num_rows = 0)
+               {
+                       $this->_get_fetchmode();
+
+                       $sql = $this->get_offset($sql, $offset, $num_rows);
+
                        if ($this->debug)
                        {
                                printf("Debug: limit_query = %s<br />offset=%d, 
num_rows=%d<br />\n", $sql, $offset, $num_rows);

Modified: trunk/property/inc/class.sotts.inc.php
===================================================================
--- trunk/property/inc/class.sotts.inc.php      2015-12-08 00:34:00 UTC (rev 
14544)
+++ trunk/property/inc/class.sotts.inc.php      2015-12-09 14:44:50 UTC (rev 
14545)
@@ -146,18 +146,18 @@
                        $custom_filtermethod= 
isset($data['custom_filtermethod']) && $data['custom_filtermethod'] ? 
(array)$data['custom_filtermethod']:array();
 
 
-                       $result_order_field = '';
+                       $result_order_field = array();
                        if ($order)
                        {
                                if( $order == 'assignedto' )
                                {
-                                       $result_order_field = 
',account_lastname';
+                                       $result_order_field = 
array('account_lastname' => 'account_lastname');
                                        $order_join = "LEFT OUTER JOIN 
phpgw_accounts ON fm_tts_tickets.assignedto=phpgw_accounts.account_id";
                                        $order = 'account_lastname';
                                }
                                else if( $order == 'user' )
                                {
-                                       $result_order_field = 
',account_lastname';
+                                       $result_order_field = 
array('account_lastname' => 'account_lastname');
                                        $order_join = "LEFT OUTER JOIN 
phpgw_accounts ON fm_tts_tickets.user_id=phpgw_accounts.account_id";
                                        $order = 'account_lastname';
                                }
@@ -170,9 +170,10 @@
                        }
                        else
                        {
-                               $ordermethod = ' ORDER BY fm_tts_tickets.id 
DESC';
+                               $ordermethod = ' ORDER BY id DESC';
                        }
 
+                       $union_select = false;
                        $filtermethod = '';
 
                        $where= 'WHERE';
@@ -392,11 +393,12 @@
                                $where = 'AND';
                        }
 
-                       $actual_cost_field = 'fm_tts_tickets.actual_cost';
+                       $actual_cost_field = array('actual_cost' 
=>'fm_tts_tickets.actual_cost');
+                       $budget_field = array('budget' 
=>'fm_tts_tickets.budget');
+
                        $actual_cost_group_field = 
',fm_tts_tickets.actual_cost';
-                       $budget_field = 'fm_tts_tickets.budget';
                        $budget_group_field = ',fm_tts_tickets.budget';
-                       $date_join = '';
+                       $date_cost_join = '';
                        $date_budget_join = '';
 
                        if ($start_date)
@@ -405,28 +407,32 @@
                                $order_edit = 
$GLOBALS['phpgw']->acl->check('.ticket.order', PHPGW_ACL_EDIT, 'property');
                                $_end_date      = $end_date + 3600 * 16 + 
phpgwapi_datetime::user_timezone();
                                $_start_date    = $start_date - 3600 * 8 + 
phpgwapi_datetime::user_timezone();
-                               $filtermethod .= " $where 
(fm_tts_tickets.modified_date >= $_start_date AND fm_tts_tickets.modified_date 
<= $_end_date ";
+                               $filtermethod .= " $where 
fm_tts_tickets.modified_date >= $_start_date AND fm_tts_tickets.modified_date 
<= $_end_date ";
 
                                if($order_add || $order_edit)
                                {
+                                       $union_select = true;
                                        $end_period     = date('Ym', $end_date);
                                        $start_period   = date('Ym', 
$start_date);
-                                       $filtermethod .= " OR 
(fm_tts_payments.period >= {$start_period} AND fm_tts_payments.period <= 
{$end_period})";
-                                       $date_join = "LEFT JOIN fm_tts_payments 
ON ( fm_tts_tickets.id=fm_tts_payments.ticket_id AND fm_tts_payments.period >= 
$start_period AND fm_tts_payments.period <= $end_period )";
-                                       $actual_cost_field = 
'SUM(fm_tts_payments.amount) AS actual_cost';
+//                                     $filtermethod .= " OR 
(fm_tts_payments.period >= {$start_period} AND fm_tts_payments.period <= 
{$end_period})";
+                                       $date_cost_join = "LEFT OUTER JOIN 
fm_tts_payments ON ( fm_tts_tickets.id=fm_tts_payments.ticket_id AND 
fm_tts_payments.period >= $start_period AND fm_tts_payments.period <= 
$end_period )";
+//                                     $actual_cost_field = 
'SUM(fm_tts_payments.amount) AS actual_cost';
+                                       $actual_cost_field = 
array('SUM(actual_cost) AS actual_cost' =>'fm_tts_payments.amount as 
actual_cost');
+
                                        $actual_cost_group_field = '';
 
 
                                        $start_budget_period = date('Y', 
$end_date) . '00';
                                        $end_budget_period = date('Y', 
$start_date) . '13';
-                                       $filtermethod .= " OR 
(fm_tts_budget.period >= {$start_budget_period} AND fm_tts_budget.period <= 
{$end_budget_period}))";
-                                       $date_budget_join = "LEFT JOIN 
fm_tts_budget ON ( fm_tts_tickets.id=fm_tts_budget.ticket_id AND 
fm_tts_budget.period >= $start_budget_period AND fm_tts_budget.period <= 
$end_budget_period )";
-                                       $budget_field = 
'SUM(fm_tts_budget.amount) AS budget';
+//                                     $filtermethod .= " OR 
(fm_tts_budget.period >= {$start_budget_period} AND fm_tts_budget.period <= 
{$end_budget_period}))";
+                                       $date_budget_join = "LEFT OUTER JOIN 
fm_tts_budget ON ( fm_tts_tickets.id=fm_tts_budget.ticket_id AND 
fm_tts_budget.period >= $start_budget_period AND fm_tts_budget.period <= 
$end_budget_period )";
+//                                     $budget_field = 
'SUM(fm_tts_budget.amount) AS budget';
+                                       $budget_field = array('SUM(budget) AS 
budget' =>'fm_tts_budget.amount as budget');
                                        $budget_group_field = '';
                                }
                                else
                                {
-                                       $filtermethod .= ')';
+//                                     $filtermethod .= ')';
                                }
 
                                $where= 'AND';
@@ -497,41 +503,114 @@
                                }
                        }
 
-                       $return_fields = 
"fm_tts_tickets.id,fm_tts_tickets.assignedto,fm_tts_tickets.status,fm_tts_tickets.user_id,"
-                       . 
"fm_tts_tickets.subject,fm_tts_tickets.address,fm_tts_tickets.location_code,fm_tts_tickets.priority,fm_tts_tickets.cat_id,fm_tts_tickets.group_id,"
-                       . 
"fm_tts_tickets.entry_date,fm_tts_tickets.modified_date,fm_tts_tickets.finnish_date,fm_tts_tickets.finnish_date2,fm_tts_tickets.order_id,fm_tts_tickets.vendor_id,"
-                       . "fm_tts_tickets.billable_hours,fm_district.descr as 
district,fm_tts_views.id as 
view,fm_location1.loc1_name,fm_tts_tickets.ecodimb,fm_tts_tickets.order_dim1 
{$result_order_field}";
+                       $_return_field_array = array(
+                               'id'                            => 
'fm_tts_tickets.id',
+                               'assignedto'            => 
'fm_tts_tickets.assignedto',
+                               'status'                        => 
'fm_tts_tickets.status',
+                               'user_id'                       => 
'fm_tts_tickets.user_id',
+                               'subject'                       => 
'fm_tts_tickets.subject',
+                               'address'                       => 
'fm_tts_tickets.address',
+                               'location_code'         => 
'fm_tts_tickets.location_code',
+                               'priority'                      => 
'fm_tts_tickets.priority',
+                               'cat_id'                        => 
'fm_tts_tickets.cat_id',
+                               'group_id'                      => 
'fm_tts_tickets.group_id',
+                               'entry_date'            => 
'fm_tts_tickets.entry_date',
+                               'modified_date'         => 
'fm_tts_tickets.modified_date',
+                               'finnish_date'          => 
'fm_tts_tickets.finnish_date',
+                               'finnish_date2'         => 
'fm_tts_tickets.finnish_date2',
+                               'order_id'                      => 
'fm_tts_tickets.order_id',
+                               'vendor_id'                     => 
'fm_tts_tickets.vendor_id',
+                               'billable_hours'        => 
'fm_tts_tickets.billable_hours',
+                               'district'                      => 
'fm_district.descr as district',
+                               'view'                          => 
'fm_tts_views.id as view',
+                               'loc1_name'                     => 
'fm_location1.loc1_name',
+                               'ecodimb'                       => 
'fm_tts_tickets.ecodimb',
+                               'order_dim1'            => 
'fm_tts_tickets.order_dim1'
+                       );
 
                        $custom_cols = $this->custom->find('property', 
'.ticket', 0, '', 'ASC', 'attrib_sort', true, true);
-                       
+
                        foreach ($custom_cols as $custom_col)
                        {
-                               $return_fields .= 
",fm_tts_tickets.{$custom_col['column_name']}";
+                               
$_return_field_array[$custom_col['column_name']] = 
"fm_tts_tickets.{$custom_col['column_name']}";
                        }
 
-                       $sql = "SELECT DISTINCT 
{$return_fields},$budget_field,{$actual_cost_field} FROM fm_tts_tickets"
+                       if ($result_order_field)
+                       {
+                               $_return_field_array = 
array_merge($_return_field_array, $result_order_field);
+                       }
+
+                       $return_field_array = array_merge($_return_field_array, 
$actual_cost_field);
+                       $return_field_array = array_merge($return_field_array, 
$budget_field);
+
+                       $return_fields_union    = implode(',', 
array_values($_return_field_array));
+                       $return_fields                  = implode(',', 
array_keys($return_field_array));
+                       $return_fields_plain    = implode(',', 
array_values($return_field_array));
+
+                       $union_budget = "SELECT {$return_fields_union}, 0 as 
actual_cost ,SUM(fm_tts_budget.amount) as budget FROM fm_tts_tickets"
                                . " {$this->left_join} fm_location1 ON 
fm_tts_tickets.loc1=fm_location1.loc1"
                                . " {$this->left_join} fm_part_of_town ON 
fm_location1.part_of_town_id=fm_part_of_town.part_of_town_id"
                                . " {$this->left_join} fm_district ON 
fm_district.id = fm_part_of_town.district_id"
-                               . " 
{$order_join}{$date_join}{$date_budget_join}"
+                               . " {$order_join}{$date_budget_join}"
                                . " LEFT OUTER JOIN fm_tts_views ON 
(fm_tts_tickets.id = fm_tts_views.id AND 
fm_tts_views.account_id='{$this->account}')";
+                       $union_cost = "SELECT 
{$return_fields_union},SUM(fm_tts_payments.amount) as actual_cost, 0 as budget 
FROM fm_tts_tickets"
+                               . " {$this->left_join} fm_location1 ON 
fm_tts_tickets.loc1=fm_location1.loc1"
+                               . " {$this->left_join} fm_part_of_town ON 
fm_location1.part_of_town_id=fm_part_of_town.part_of_town_id"
+                               . " {$this->left_join} fm_district ON 
fm_district.id = fm_part_of_town.district_id"
+                               . " {$order_join}{$date_cost_join}"
+                               . " LEFT OUTER JOIN fm_tts_views ON 
(fm_tts_tickets.id = fm_tts_views.id AND 
fm_tts_views.account_id='{$this->account}')";
 
                        if(isset($custom_filter['joinmethod_datatype']) && 
$custom_filter['joinmethod_datatype'])
                        {
                                foreach($custom_filter['joinmethod_datatype'] 
as $_joinmethod)
                                {
+                                       $union_budget .= $_joinmethod;
+                                       $union_cost .= $_joinmethod;
+                               }
+                       }
+
+                       $sql = "SELECT DISTINCT {$return_fields_plain} FROM 
fm_tts_tickets"
+                               . " {$this->left_join} fm_location1 ON 
fm_tts_tickets.loc1=fm_location1.loc1"
+                               . " {$this->left_join} fm_part_of_town ON 
fm_location1.part_of_town_id=fm_part_of_town.part_of_town_id"
+                               . " {$this->left_join} fm_district ON 
fm_district.id = fm_part_of_town.district_id"
+                               . " 
{$order_join}{$date_cost_join}{$date_budget_join}"
+                               . " LEFT OUTER JOIN fm_tts_views ON 
(fm_tts_tickets.id = fm_tts_views.id AND 
fm_tts_views.account_id='{$this->account}')";
+
+                       if(isset($custom_filter['joinmethod_datatype']) && 
$custom_filter['joinmethod_datatype'])
+                       {
+                               foreach($custom_filter['joinmethod_datatype'] 
as $_joinmethod)
+                               {
                                        $sql .= $_joinmethod;
                                }
                        }
 
-                       $group_fields = str_ireplace(array('fm_district.descr 
as district', 'fm_tts_views.id as view'), 
array('fm_district.descr','fm_tts_views.id'), $return_fields);
-                       $sql .= " {$filtermethod} {$querymethod} GROUP BY 
{$group_fields}{$budget_group_field}{$actual_cost_group_field}";
+                       $limit_and_offset = '';
 
-                       $sql_cnt = "SELECT DISTINCT 
{$budget_field},{$actual_cost_field}, fm_tts_tickets.id FROM fm_tts_tickets"
+                       if(!$allrows && $union_select)
+                       {
+                               $allrows = true;//handled within the subselect
+                               $limit_and_offset = $this->db->get_offset('', 
$start);
+                       }
+
+                       $group_fields = str_ireplace(array('fm_district.descr 
as district', 'fm_tts_views.id as view'), 
array('fm_district.descr','fm_tts_views.id'), $return_fields_plain);
+                       $group_fields_union = 
str_ireplace(array('fm_district.descr as district', 'fm_tts_views.id as view'), 
array('fm_district.descr','fm_tts_views.id'), $return_fields_union);
+                       $sub_select = "({$union_budget} {$filtermethod} 
{$querymethod} GROUP BY {$group_fields_union} {$ordermethod} 
{$limit_and_offset}) UNION ({$union_cost} {$filtermethod} {$querymethod} GROUP 
BY {$group_fields_union} {$ordermethod} {$limit_and_offset})";
+
+                       if($union_select)
+                       {
+                               $main_sql = "SELECT {$return_fields} FROM 
({$sub_select} ) as t GROUP BY " . implode(',', 
array_keys($_return_field_array)) . " {$ordermethod}";
+                       
+                       }
+                       else
+                       {
+                               $main_sql = $sql . " {$filtermethod} 
{$querymethod} GROUP BY 
{$group_fields}{$budget_group_field}{$actual_cost_group_field} {$ordermethod}";
+                       }
+
+                       $sql_cnt = "SELECT DISTINCT budget,actual_cost, 
fm_tts_tickets.id FROM fm_tts_tickets"
                                . " {$this->left_join} fm_location1 ON 
fm_tts_tickets.loc1=fm_location1.loc1"
                                . " {$this->left_join} fm_part_of_town ON 
fm_location1.part_of_town_id=fm_part_of_town.part_of_town_id"
                                . " {$this->left_join} fm_district ON 
fm_district.id = fm_part_of_town.district_id"
-                               . " 
{$order_join}{$date_join}{$date_budget_join}"
+                               . " 
{$order_join}{$date_cost_join}{$date_budget_join}"
                                . " LEFT OUTER JOIN fm_tts_views ON 
(fm_tts_tickets.id = fm_tts_views.id AND 
fm_tts_views.account_id='{$this->account}')";
 
                        if(isset($custom_filter['joinmethod_datatype']) && 
$custom_filter['joinmethod_datatype'])
@@ -543,25 +622,32 @@
                        }
 
                        $sql_cnt .= " {$filtermethod} {$querymethod}";
-//_debug_array($sql);
 
-                       $cache_info = 
phpgwapi_cache::session_get('property','tts_listing_metadata');
+//                     $cache_info = 
phpgwapi_cache::session_get('property','tts_listing_metadata');
 
                        if (!isset($cache_info['sql_hash']) || 
$cache_info['sql_hash'] != md5($sql_cnt))
                        {
                                $cache_info = array();
                        }
-
-                       if(!$cache_info)
+//_debug_array($main_sql);
+//                     if(!$cache_info)
                        {
-                               $sql2 = "SELECT count(*) as cnt, sum(budget) as 
sum_budget, sum(actual_cost) as sum_actual_cost FROM ({$sql_cnt} GROUP BY 
fm_tts_tickets.id, fm_tts_tickets.budget {$actual_cost_group_field}) as t";
+                               if($union_select)
+                               {
+                                       $sub_select = "({$union_budget} 
{$filtermethod} {$querymethod} {$filter_closed} GROUP BY {$group_fields_union}) 
UNION ({$union_cost} {$filtermethod} {$querymethod} {$filter_closed} GROUP BY 
{$group_fields_union})";
+                                       $sql2 = "SELECT count(*) as cnt, 
sum(budget) as sum_budget, sum(actual_cost) as sum_actual_cost FROM 
({$sub_select} ) as t";
+                               }
+                               else
+                               {
+                                       $sql2 = "SELECT count(*) as cnt, 
sum(budget) as sum_budget, sum(actual_cost) as sum_actual_cost FROM ({$sql_cnt} 
GROUP BY fm_tts_tickets.id, fm_tts_tickets.budget) as t";
+                               }
                                $this->db->query($sql2,__LINE__,__FILE__);
                                $this->db->next_record();
                                unset($sql2);
 
                                $cache_info = array
                                (
-                                       'total_records'         => 
$this->db->f('cnt'),
+                                       'total_records'         => 
$union_select ? ((int)$this->db->f('cnt')/2) : $this->db->f('cnt'),
                                        'sum_budget'            => 
$this->db->f('sum_budget'),
                                        'sum_actual_cost'       => 
$this->db->f('sum_actual_cost'),
                                        'sql_hash'                      => 
md5($sql_cnt)
@@ -578,14 +664,23 @@
                                        }
                                }
                                $filter_closed = " AND fm_tts_tickets.status 
NOT IN ('" . implode("','", $closed_status) . "')";
-                               $sql2 = "SELECT (SUM(budget) - 
SUM(actual_cost)) as sum_difference FROM ({$sql_cnt} {$filter_closed} GROUP BY 
fm_tts_tickets.id, fm_tts_tickets.budget {$actual_cost_group_field}) as t";
+                               if($union_select)
+                               {
+                                       $sub_select = "({$union_budget} 
{$filtermethod} {$querymethod} {$filter_closed} GROUP BY {$group_fields_union}) 
UNION ({$union_cost} {$filtermethod} {$querymethod} {$filter_closed} GROUP BY 
{$group_fields_union})";
+                                       $sql2 = "SELECT (SUM(budget) - 
SUM(actual_cost)) as sum_difference FROM ({$sub_select}) as t";
+                               }
+                               else
+                               {
+                                       $sql2 = "SELECT (SUM(budget) - 
SUM(actual_cost)) as sum_difference FROM ({$sql_cnt} {$filter_closed} GROUP BY 
fm_tts_tickets.id) as t";
+                               }
+
                                $this->db->query($sql2,__LINE__,__FILE__);
                                $this->db->next_record();
                                unset($sql2);
 
                                $cache_info['sum_difference']   = 
(float)$this->db->f('sum_difference');
 
-                               
phpgwapi_cache::session_set('property','tts_listing_metadata',$cache_info);
+//                             
phpgwapi_cache::session_set('property','tts_listing_metadata',$cache_info);
                        }
 
                        $this->total_records    = 
(int)$cache_info['total_records'];
@@ -598,22 +693,12 @@
                        {
                                if(!$allrows)
                                {
-                                       $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);
+                                       
$this->db->limit_query($main_sql,$start,__LINE__,__FILE__);
                                }
                                else
                                {
                                        $_fetch_single = false;
-/*
-                                       if($this->total_records > 200)
-                                       {
-                                               $_fetch_single = true;
-                                       }
-                                       else
-                                       {
-                                               $_fetch_single = false;
-                                       }
-*/
-                                       $this->db->query($sql . 
$ordermethod,__LINE__,__FILE__, false, $_fetch_single );
+                                       
$this->db->query($main_sql,__LINE__,__FILE__, false, $_fetch_single );
                                        unset($_fetch_single);
                                }
 

Modified: trunk/property/inc/class.uitts.inc.php
===================================================================
--- trunk/property/inc/class.uitts.inc.php      2015-12-08 00:34:00 UTC (rev 
14544)
+++ trunk/property/inc/class.uitts.inc.php      2015-12-09 14:44:50 UTC (rev 
14545)
@@ -829,6 +829,9 @@
                                                        $_filter_buildingpart = 
array("filter_{$filter_key}" => 1);
                                                }
 
+                                               $building_parts = 
$this->bocommon->select_category_list(array('type'=> 'building_part','selected' 
=>$this->building_part, 'order' => 'id', 'id_in_name' => 'num', 'filter' => 
$_filter_buildingpart));
+                                               array_unshift 
($building_parts,array('id'=>'','name'=>lang('building part')));
+
                                                
$datatable['actions']['form'][0]['fields']['field'][] = array
                                                (
                                                                        'id' => 
'sel_building_part', // testing traditional listbox for long list
@@ -837,7 +840,7 @@
                                                                        'type' 
=> 'select',
                                                                        'style' 
=> 'filter',
                                                                        
//'values' => $this->bo->get_building_part($this->building_part),
-                                                                       
'values'        => $this->bocommon->select_category_list(array('type'=> 
'building_part','selected' =>$this->building_part, 'order' => 'id', 
'id_in_name' => 'num', 'filter' => $_filter_buildingpart)),
+                                                                       
'values'        => $building_parts,
                                                                        
'onchange'=> 'onChangeSelect("building_part");',
                                                                        
'tab_index' => $i++
                                                );
@@ -2433,6 +2436,8 @@
                                $access_order = true;
                        }
 
+                       $ticket = $this->bo->read_single($id, $values);
+
                        if(isset($values['save']))
                        {
                                if(!$this->acl_edit)
@@ -2484,7 +2489,7 @@
 
                                if($access_order)
                                {
-                                       if((isset($values['order_id']) && 
$values['order_id']) && (!isset($values['budget']) || !$values['budget']) )
+                                       if(!$ticket['budget'] && 
((isset($values['order_id']) && $values['order_id']) && 
(!isset($values['budget']) || !$values['budget'])) )
                                        {
                                                
$receipt['error'][]=array('msg'=>lang('budget') . ': ' . lang('Missing value'));
                                        }
@@ -2597,7 +2602,6 @@
                                $values = 
$this->bocommon->preserve_attribute_values($values,$values_attribute);
                        }
 
-                       $ticket = $this->bo->read_single($id, $values);
 
                        if (isset($ticket['attributes']) && 
is_array($ticket['attributes']))
                        {

Modified: trunk/property/js/yahoo/tts.view.js
===================================================================
--- trunk/property/js/yahoo/tts.view.js 2015-12-08 00:34:00 UTC (rev 14544)
+++ trunk/property/js/yahoo/tts.view.js 2015-12-09 14:44:50 UTC (rev 14545)
@@ -4,6 +4,7 @@
 var    myPaginator_3, myDataTable_3;
 var    myPaginator_4, myDataTable_4;
 var    myPaginator_5, myDataTable_5;
+var    myPaginator_6, myDataTable_6;
 var d;
 var vendor_id = 0;
 
@@ -11,6 +12,7 @@
 this.myParticularRenderEvent = function()
 {
        this.addFooterDatatable(myPaginator_4,myDataTable_4);
+       this.addFooterDatatable2(myPaginator_5,myDataTable_5);
 }
 
 this.addFooterDatatable = function(paginator,datatable)
@@ -39,7 +41,33 @@
        myfoot.setAttribute("id","myfoot");
        myfoot.appendChild(newTR);
 }
+this.addFooterDatatable2 = function(paginator,datatable)
+{
+       //call getSumPerPage(name of column) in property.js
+       tmp_sum1 = getTotalSum('amount',2,paginator,datatable);
 
+       if(typeof(tableYUI2)=='undefined')
+       {
+               tableYUI2 = 
YAHOO.util.Dom.getElementsByClassName("yui-dt-data","tbody")[3].parentNode;
+               tableYUI2.setAttribute("id","tableYUI2");
+       }
+       else
+       {
+               tableYUI2.deleteTFoot();
+       }
+
+       //Create ROW
+       newTR = document.createElement('tr');
+
+       td_sum('Sum');
+       td_sum(tmp_sum1);
+       td_empty(1);
+
+       myfoot = tableYUI2.createTFoot();
+       myfoot.setAttribute("id","myfoot");
+       myfoot.appendChild(newTR);
+}
+
 
/********************************************************************************/
     
 var FormatterCenter = function(elCell, oRecord, oColumn, oData)
 {




reply via email to

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