[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [17376] more on controller
From: |
sigurdne |
Subject: |
[Fmsystem-commits] [17376] more on controller |
Date: |
Wed, 29 Nov 2017 16:26:26 -0500 (EST) |
Revision: 17376
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=17376
Author: sigurdne
Date: 2017-11-29 16:26:26 -0500 (Wed, 29 Nov 2017)
Log Message:
-----------
more on controller
Modified Paths:
--------------
trunk/controller/inc/class.uicomponent.inc.php
trunk/controller/js/controller/component.index.js
trunk/controller/templates/base/component.xsl
Modified: trunk/controller/inc/class.uicomponent.inc.php
===================================================================
--- trunk/controller/inc/class.uicomponent.inc.php 2017-11-29 15:35:57 UTC
(rev 17375)
+++ trunk/controller/inc/class.uicomponent.inc.php 2017-11-29 21:26:26 UTC
(rev 17376)
@@ -59,6 +59,7 @@
private $org_units;
private $custom;
private $get_locations;
+ private $user_id;
public $public_functions = array
(
'index' => true,
@@ -103,6 +104,9 @@
$GLOBALS['phpgw_info']['flags']['noframework']
= true;
}
$this->custom = createObject('phpgwapi.custom_fields');
+ $user_id = phpgw::get_var('user_id', 'string',
'REQUEST', -1);
+ $this->user_id = $user_id == 'all' ? 0 : (int) $user_id;
+
}
public function add_controll_from_master()
@@ -269,7 +273,7 @@
unset($_my_negative_self);
array_unshift($user_list, $default_value);
- array_unshift($user_list, array('id' => '', 'name' =>
lang('select')));
+ array_unshift($user_list, array('id' => 'all', 'name'
=> lang('select')));
// Sigurd: Start categories
$cats = CreateObject('phpgwapi.categories', -1,
'controller', '.control');
@@ -436,7 +440,8 @@
'datatable' => array(
'source' =>
self::link(array('menuaction' => 'controller.uicomponent.index',
'phpgw_return_as' => 'json')),
- 'field' =>
$this->get_fields($filter_component),
+ 'field' => $this->get_fields(),
+ 'months' => $this->get_months($year)
),
);
@@ -445,37 +450,113 @@
self::render_template_xsl(array('component',
'calendar/icon_color_map'), $data);
}
- private function get_fields( $filter_component = '' )
+ private function get_months( $year = '' )
{
+ $months = array();
+ if($year == date('Y') && $this->user_id < 0)
+ {
+ $current_month = date('n') -1;
+ $i = 0;
+ for ($_month = $current_month; $_month < 13;
$_month++)
+ {
+ if($i > 2 )
+ {
+ break;
+ }
+
+ $months[] = array(
+ 'key' => $_month,
+ );
+ $i++;
+ }
+ }
+ else
+ {
+ for ($_month = 0; $_month < 13; $_month++)
+ {
+ $months[] = array(
+ 'key' => $_month,
+ );
+ }
+ }
+
+ return $months;
+ }
+ private function get_fields( $year = '' , $user_id = 0)
+ {
+
$fields = array
(
array(
+ 'id' => 'choose',
'key' => 'choose',
'label' => '',
'sortable' => false,
),
array(
+ 'id' => 'component_url',
'key' => 'component_url',
'label' => $this->get_locations ?
lang('location') : lang('component'),
'sortable' => true,
),
array(
+ 'id' => 'control_type',
'key' => 'control_type',
'label' => lang('type'),
'sortable' => true,
),
array(
+ 'id' => 'year',
'key' => 'year',
'label' => lang('year'),
'sortable' => true,
),
array(
+ 'id' => 'descr',
'key' => 'descr',
'label' => '',
'sortable' => true,
),
- array(
+ );
+
+ if($year == date('Y') && $user_id < 0)
+ {
+ $current_month = date('n');
+
+ $i = 0;
+ for ($_month = $current_month; $_month < 13;
$_month++)
+ {
+ if($i > 2 )
+ {
+ break;
+ }
+
+ $fields[] = array(
+ 'id' => $i,
+ 'key' => $_month,
+ 'label' => lang("short_month
{$_month} capitalized"),
+ 'sortable' => true,
+ );
+ $i++;
+ }
+ }
+ else
+ {
+ $i = 0;
+ for ($_month = 1; $_month < 13; $_month++)
+ {
+ $fields[] = array(
+ 'id' => $i,
+ 'key' => $_month,
+ 'label' => lang("short_month
{$_month} capitalized"),
+ 'sortable' => true,
+ );
+ $i++;
+ }
+ }
+
+ $old = array(array(
'key' => '1',
'label' => lang('short_month 1
capitalized'),
'sortable' => true,
@@ -650,7 +731,7 @@
$location_code = '';
}
$control_area = phpgw::get_var('control_area', 'int');
- $user_id = phpgw::get_var('user_id', 'int');
+ $user_id = $this->user_id;
$district_id = phpgw::get_var('district_id', 'int');
$query = phpgw::get_var('query', 'string');
$year = phpgw::get_var('year', 'int');
@@ -1131,7 +1212,8 @@
return array(
'components' => null,
'summary' =>
$this->get_summary($values, $user_id),
- 'location_filter' => $location_filter
+ 'location_filter' => $location_filter,
+ 'filter_months' => array()
);
}
@@ -1234,7 +1316,7 @@
$data_set[] = $row;
}
}
- $fields = $this->get_fields($filter_component_str);
+ $fields = $this->get_fields($year, $this->user_id);
$class = '';
$tbody = '';
foreach ($data_set as $row_data)
@@ -1299,6 +1381,7 @@
}
}
}
+ unset($_month);
$result['time_sum_actual'][0] = $sum_year_actual;
$result['total_records'] = $total_records;
$result['location_filter'] = $location_filter;
@@ -1315,12 +1398,26 @@
$result['checkall'] = '';
}
+ $months = $this->get_months($year);
+
+ $filter_months = array();
+// for ($_month = 0 ; $_month < 13; $_month++)
+// {
+// $filter_months[$_month] = 0;
+// }
+
+ foreach ($months as $entry)
+ {
+ $filter_months[] = $entry['key'];
+ }
+
return array(
'components' => $result,
'summary' => null,
'location_filter' => $location_filter,
'location_filter_options' =>
$location_filter_options,
- 'return_location_id' =>
(int)$_location_id
+ 'return_location_id' =>
(int)$_location_id,
+ 'filter_months' =>
$filter_months
);
}
Modified: trunk/controller/js/controller/component.index.js
===================================================================
--- trunk/controller/js/controller/component.index.js 2017-11-29 15:35:57 UTC
(rev 17375)
+++ trunk/controller/js/controller/component.index.js 2017-11-29 21:26:26 UTC
(rev 17376)
@@ -239,6 +239,39 @@
var time_sum = components_data.time_sum;
var time_sum_actual =
components_data.time_sum_actual;
+ console.log(show_months);
+ console.log(filter_months);
+
+ if(show_months.length > 0)
+ {
+ for (i = 0; i < 13; i++)
+ {
+ $("#month" + i).hide();
+ $("#head" + i).hide();
+ }
+ for (i = 0; i <
show_months.length; i++)
+ {
+ $("#month" +
show_months[i]).show();
+ $("#head" +
show_months[i]).show();
+ }
+ show_months = [];
+ }
+ else
+ {
+ var filter_months =
data.filter_months;
+ for (i = 0; i < 13; i++)
+ {
+ $("#month" + i).hide();
+ $("#head" + i).hide();
+ }
+ for (i = 0; i <
filter_months.length; i++)
+ {
+ $("#month" +
filter_months[i]).show();
+ $("#head" +
filter_months[i]).show();
+ }
+ }
+
+
$("#checkall").html(components_data.checkall);
$("#total_records").html(components_data.total_records);
$("#control_text").html('type');
@@ -258,6 +291,7 @@
$("#month12").html(time_sum[12] + '/' +
time_sum_actual[12]);
}
+
if (summary_data !== null)
{
$("#status_summary").show();
Modified: trunk/controller/templates/base/component.xsl
===================================================================
--- trunk/controller/templates/base/component.xsl 2017-11-29 15:35:57 UTC
(rev 17375)
+++ trunk/controller/templates/base/component.xsl 2017-11-29 21:26:26 UTC
(rev 17376)
@@ -331,7 +331,7 @@
<thead>
<tr>
<xsl:for-each select="//datatable/field">
- <th>
+ <th id = "head{id}">
<xsl:value-of select="label"/>
</th>
</xsl:for-each>
@@ -342,5 +342,13 @@
<div id="status_summary">
</div>
+ <script type="text/javascript">
+ var show_months = [];
+ <xsl:for-each select="//datatable/months">
+ show_months.push(<xsl:value-of select="key"/>);
+ </xsl:for-each>
+
+ </script>
+
</xsl:template>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [17376] more on controller,
sigurdne <=