[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [14937] property: tickets
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [14937] property: tickets |
Date: |
Tue, 26 Apr 2016 10:29:24 +0000 |
Revision: 14937
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14937
Author: sigurdne
Date: 2016-04-26 10:29:21 +0000 (Tue, 26 Apr 2016)
Log Message:
-----------
property: tickets
Modified Paths:
--------------
trunk/property/inc/class.botts.inc.php
trunk/property/inc/class.sotts.inc.php
trunk/property/inc/class.uitts.inc.php
Modified: trunk/property/inc/class.botts.inc.php
===================================================================
--- trunk/property/inc/class.botts.inc.php 2016-04-25 16:40:07 UTC (rev
14936)
+++ trunk/property/inc/class.botts.inc.php 2016-04-26 10:29:21 UTC (rev
14937)
@@ -65,7 +65,7 @@
'addfiles' => true,
);
- function __construct( $session = false )
+ function __construct( )
{
if ($GLOBALS['phpgw_info']['flags']['currentapp'] !=
'property')
{
@@ -108,86 +108,29 @@
}
}
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = true;
- }
-
- $start = phpgw::get_var('start', 'int', 'REQUEST', 0);
- $query = phpgw::get_var('query');
- $sort = phpgw::get_var('sort');
- $order = phpgw::get_var('order');
- $status_id = phpgw::get_var('status_id', 'string');
- $user_id = phpgw::get_var('user_id', 'int');
- $reported_by = phpgw::get_var('reported_by', 'int');
- $cat_id = phpgw::get_var('cat_id', 'int');
- $part_of_town_id = phpgw::get_var('part_of_town_id',
'int');
- $district_id = phpgw::get_var('district_id', 'int');
- $allrows = phpgw::get_var('allrows', 'bool');
- $start_date = phpgw::get_var('start_date', 'string');
- $end_date = phpgw::get_var('end_date', 'string');
- $location_code = phpgw::get_var('location_code');
- $vendor_id = phpgw::get_var('vendor_id', 'int');
- $ecodimb = phpgw::get_var('ecodimb', 'int');
- $b_account = phpgw::get_var('b_account', 'string');
- $building_part = phpgw::get_var('building_part',
'string');
- $branch_id = phpgw::get_var('branch_id', 'int');
- $order_dim1 = phpgw::get_var('order_dim1', 'int');
-
- $this->start = $start ? $start : 0;
-
- $this->query = isset($_REQUEST['query']) ? $query :
$this->query;
- $this->sort = isset($_REQUEST['sort']) ? $sort :
$this->sort;
- $this->order = isset($_REQUEST['order']) ? $order :
$this->order;
- $this->cat_id = isset($_REQUEST['cat_id']) ? $cat_id :
$this->cat_id;
- $this->status_id = isset($_REQUEST['status_id']) ?
$status_id : $this->status_id;
- $this->user_id = isset($_REQUEST['user_id']) ? $user_id
: $this->user_id;
- $this->reported_by = isset($_REQUEST['user_id']) ?
$reported_by : $this->reported_by;
-
- $this->part_of_town_id =
isset($_REQUEST['part_of_town_id']) ? $part_of_town_id : $this->part_of_town_id;
- $this->district_id = isset($_REQUEST['district_id']) ?
$district_id : $this->district_id;
- $this->allrows = isset($allrows) && $allrows ? $allrows
: '';
- $this->start_date = isset($_REQUEST['start_date']) ?
$start_date : $this->start_date;
- $this->end_date = isset($_REQUEST['end_date']) ?
$end_date : $this->end_date;
- $this->location_code = isset($location_code) &&
$location_code ? $location_code : '';
- $this->vendor_id = isset($_REQUEST['vendor_id']) ?
$vendor_id : $this->vendor_id;
+ $this->start = phpgw::get_var('start', 'int',
'REQUEST', 0);
+ $this->query = phpgw::get_var('query');
+ $this->sort = phpgw::get_var('sort');
+ $this->order = phpgw::get_var('order');
+ $this->status_id = phpgw::get_var('status_id',
'string');
+ $this->user_id = phpgw::get_var('user_id', 'int');
+ $this->reported_by = phpgw::get_var('reported_by',
'int');
+ $this->cat_id = phpgw::get_var('cat_id', 'int');
+ $this->part_of_town_id =
phpgw::get_var('part_of_town_id', 'int');
+ $this->district_id = phpgw::get_var('district_id',
'int');
+ $this->allrows = phpgw::get_var('allrows', 'bool');
+ $this->start_date = phpgw::get_var('filter_start_date',
'string');
+ $this->end_date = phpgw::get_var('filter_end_date',
'string');
+ $this->location_code = phpgw::get_var('location_code');
+ $this->vendor_id = phpgw::get_var('vendor_id', 'int');
+ $this->ecodimb = phpgw::get_var('ecodimb', 'int');
+ $this->b_account = phpgw::get_var('b_account',
'string');
+ $this->building_part = phpgw::get_var('building_part',
'string');
+ $this->branch_id = phpgw::get_var('branch_id', 'int');
+ $this->order_dim1 = phpgw::get_var('order_dim1', 'int');
$this->p_num = phpgw::get_var('p_num');
- $this->ecodimb = isset($_REQUEST['ecodimb']) ? $ecodimb
: $this->ecodimb;
- $this->b_account = isset($_REQUEST['b_account']) ?
$b_account : $this->b_account;
- $this->building_part =
isset($_REQUEST['building_part']) ? $building_part : $this->building_part;
- $this->branch_id = isset($_REQUEST['branch_id']) ?
$branch_id : $this->branch_id;
- $this->order_dim1 = isset($_REQUEST['order_dim1']) ?
$order_dim1 : $this->order_dim1;
}
- function save_sessiondata( $data )
- {
- if ($this->use_session)
- {
-
$GLOBALS['phpgw']->session->appsession('session_data', 'fm_tts', $data);
- }
- }
-
- function read_sessiondata()
- {
- $data =
$GLOBALS['phpgw']->session->appsession('session_data', 'fm_tts');
-
- $this->start = isset($data['start']) ? $data['start'] :
'';
- $this->query = isset($data['query']) ? $data['query'] :
'';
- $this->user_id = isset($data['user_id']) ?
$data['user_id'] : '';
- $this->reported_by = isset($data['reported_by']) ?
$data['reported_by'] : '';
- $this->sort = isset($data['sort']) ? $data['sort'] : '';
- $this->order = isset($data['order']) ? $data['order'] :
'';
- $this->status_id = isset($data['status_id']) ?
$data['status_id'] : '';
- $this->cat_id = isset($data['cat_id']) ?
$data['cat_id'] : '';
- $this->district_id = isset($data['district_id']) ?
$data['district_id'] : '';
- $this->part_of_town_id =
isset($data['part_of_town_id']) ? $data['part_of_town_id'] : '';
- $this->allrows = isset($data['allrows']) ?
$data['allrows'] : '';
- $this->start_date = isset($data['start_date']) ?
$data['start_date'] : '';
- $this->end_date = isset($data['end_date']) ?
$data['end_date'] : '';
- $this->vendor_id = isset($data['vendor_id']) ?
$data['vendor_id'] : '';
- }
-
function column_list( $selected = array() )
{
if (!$selected)
@@ -274,6 +217,31 @@
'id' => 'order_dim1',
'name' => lang('order_dim1')
);
+ $columns['external_project_id'] = array
+ (
+ 'id' => 'external_project_id',
+ 'name' => lang('external project')
+ );
+ $columns['contract_id'] = array
+ (
+ 'id' => 'contract_id',
+ 'name' => lang('contract')
+ );
+ $columns['service_id'] = array
+ (
+ 'id' => 'service_id',
+ 'name' => lang('service')
+ );
+ $columns['tax_code'] = array
+ (
+ 'id' => 'tax_code',
+ 'name' => lang('tax code')
+ );
+ $columns['unspsc_code'] = array
+ (
+ 'id' => 'unspsc_code',
+ 'name' => lang('unspsc code')
+ );
}
$columns['ecodimb'] = array
Modified: trunk/property/inc/class.sotts.inc.php
===================================================================
--- trunk/property/inc/class.sotts.inc.php 2016-04-25 16:40:07 UTC (rev
14936)
+++ trunk/property/inc/class.sotts.inc.php 2016-04-26 10:29:21 UTC (rev
14937)
@@ -125,7 +125,7 @@
$start_date = isset($data['start_date']) &&
$data['start_date'] ? (int)$data['start_date'] : 0;
$results = isset($data['results']) && $data['results']
? (int)$data['results'] : 0;
$allrows = $results == -1 ? true : false;
- $end_date = isset($data['end_date']) &&
$data['end_date'] ? (int)$data['end_date'] : time();
+ $end_date = isset($data['end_date']) &&
$data['end_date'] ? (int)$data['end_date'] : mktime(23, 59, 59,
date("n"),date("j"),date("Y"));
$external = isset($data['external']) ?
$data['external'] : '';
$dry_run = isset($data['dry_run']) ? $data['dry_run'] :
'';
$new = isset($data['new']) ? $data['new'] : '';
@@ -404,8 +404,8 @@
if ($order_add || $order_edit)
{
$union_select = true;
+ $start_period = date('Ym', $start_date);
$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_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';
@@ -413,8 +413,8 @@
$actual_cost_group_field = '';
- $start_budget_period = date('Y',
$end_date) . '00';
- $end_budget_period = date('Y',
$start_date) . '13';
+ $start_budget_period = date('Y',
$start_date) . '00';
+ $end_budget_period = date('Y',
$end_date) . '13';
// $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';
@@ -516,7 +516,12 @@
'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'
+ 'order_dim1' => 'fm_tts_tickets.order_dim1',
+ 'external_project_id' =>
'fm_tts_tickets.external_project_id',
+ 'contract_id' => 'fm_tts_tickets.contract_id',
+ 'service_id' => 'fm_tts_tickets.service_id',
+ 'tax_code' => 'fm_tts_tickets.tax_code',
+ 'unspsc_code' => 'fm_tts_tickets.unspsc_code',
);
$custom_cols = $this->custom->find('property',
'.ticket', 0, '', 'ASC', 'attrib_sort', true, true);
@@ -538,13 +543,13 @@
$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"
+ $union_budget = " 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.id"
. " {$this->left_join} fm_district ON
fm_district.id = fm_part_of_town.district_id"
. " {$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"
+ $union_cost = " 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.id"
. " {$this->left_join} fm_district ON
fm_district.id = fm_part_of_town.district_id"
@@ -588,13 +593,16 @@
if ($union_select)
{
+ $cache_test =
"{$return_fields_union},{$union_budget} {$filtermethod} {$querymethod}";
$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})";
+ $sub_select = "(SELECT
{$return_fields_union},{$union_budget} {$filtermethod} {$querymethod} GROUP BY
{$group_fields_union} {$ordermethod} {$limit_and_offset})"
+ . " UNION (SELECT
{$return_fields_union},{$union_cost} {$filtermethod} {$querymethod} GROUP BY
{$group_fields_union} {$ordermethod} {$limit_and_offset})";
$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}";
+ $cache_test = $main_sql;
}
$sql_cnt = "SELECT DISTINCT budget,actual_cost,
fm_tts_tickets.id FROM fm_tts_tickets"
@@ -614,55 +622,45 @@
$sql_cnt .= " {$filtermethod} {$querymethod}";
-// $cache_info =
phpgwapi_cache::session_get('property','tts_listing_metadata');
+ $filter_closed = '';// not needed
+ if ($union_select)
+ {
+ $sub_select = "(SELECT
fm_tts_tickets.id,{$union_budget} {$filtermethod} {$querymethod}
{$filter_closed} GROUP BY fm_tts_tickets.id)"
+ . " UNION (SELECT
fm_tts_tickets.id,{$union_cost} {$filtermethod} {$querymethod} {$filter_closed}
GROUP BY fm_tts_tickets.id)";
+ $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}
{$filter_closed} GROUP BY fm_tts_tickets.id) as t";
+ }
- if (!isset($cache_info['sql_hash']) ||
$cache_info['sql_hash'] != md5($sql_cnt))
+ $cache_info =
phpgwapi_cache::session_get('property','tts_listing_metadata');
+
+ if (!isset($cache_info['sql_hash']) ||
$cache_info['sql_hash'] != md5($cache_test))
{
$cache_info = array();
}
//_debug_array($main_sql);
-// if(!$cache_info)
+ if(!$cache_info)
{
- 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);
+ $count = $this->db->f('cnt');
+ $sum_budget = (float)$this->db->f('sum_budget');
+ $sum_actual_cost =
(float)$this->db->f('sum_actual_cost');
$cache_info = array(
- '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)
+ 'total_records' =>
$union_select ? ((int)$count / 2) : $count,
+ 'sum_budget' => $sum_budget,
+ 'sum_actual_cost' =>
$sum_actual_cost,
+ 'sum_difference' => $sum_budget
- $sum_actual_cost,
+ 'sql_hash' =>
md5($cache_test)
);
- 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";
- }
-// _debug_array($sql2);
-
- $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'];
$this->sum_budget = (int)$cache_info['sum_budget'];
$this->sum_actual_cost =
(int)$cache_info['sum_actual_cost'];
@@ -711,6 +709,11 @@
'billable_hours' =>
$this->db->f('billable_hours'),
'ecodimb' =>
$this->db->f('ecodimb'),
'order_dim1' =>
$this->db->f('order_dim1'),
+ 'external_project_id' =>
$this->db->f('external_project_id'),
+ 'contract_id' =>
$this->db->f('contract_id'),
+ 'service_id' =>
$this->db->f('service_id'),
+ 'tax_code' =>
$this->db->f('tax_code'),
+ 'unspsc_code' =>
$this->db->f('unspsc_code'),
);
foreach ($custom_cols as $custom_col)
Modified: trunk/property/inc/class.uitts.inc.php
===================================================================
--- trunk/property/inc/class.uitts.inc.php 2016-04-25 16:40:07 UTC (rev
14936)
+++ trunk/property/inc/class.uitts.inc.php 2016-04-26 10:29:21 UTC (rev
14937)
@@ -199,28 +199,6 @@
return $this->jquery_results($result_data);
}
- function save_sessiondata()
- {
- $data = array
- (
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'status_id' => $this->status_id,
- 'user_id' => $this->user_id,
- 'reported_by' => $this->reported_by,
- 'cat_id' => $this->cat_id,
- 'vendor_id' => $this->vendor_id,
- 'district_id' => $this->district_id,
- 'part_of_town_id' => $this->part_of_town_id,
- 'allrows' => $this->allrows,
- 'start_date' => $this->start_date,
- 'end_date' => $this->end_date
- );
- $this->bo->save_sessiondata($data);
- }
-
function _print()
{
if (!$this->acl_read)
@@ -525,7 +503,6 @@
private function _get_fields()
{
- $this->bo->read(array('dry_run' => true));
$this->bo->get_origin_entity_type();
$uicols_related = $this->bo->uicols_related;
@@ -910,8 +887,8 @@
),
'datatable' => array(
'source' =>
self::link(array('menuaction' => 'property.uitts.index',
- 'start_date' => $start_date,
- 'end_date' => $end_date,
+ // 'start_date' => $start_date,
+ // 'end_date' => $end_date,
'phpgw_return_as' => 'json')),
'download' =>
self::link(array('menuaction' => 'property.uitts.download',
'export' => true, 'allrows' =>
true)),
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [14937] property: tickets,
Sigurd Nes <=