[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [17566] Added aggregated view on control status for l
From: |
erikhl |
Subject: |
[Fmsystem-commits] [17566] Added aggregated view on control status for locations |
Date: |
Fri, 12 Jan 2018 07:28:43 -0500 (EST) |
Revision: 17566
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=17566
Author: erikhl
Date: 2018-01-12 07:28:43 -0500 (Fri, 12 Jan 2018)
Log Message:
-----------
Added aggregated view on control status for locations
Modified Paths:
--------------
trunk/controller/inc/class.uicalendar.inc.php
trunk/controller/inc/class.uicontrol_group.inc.php
Added Paths:
-----------
trunk/controller/js/controller/ajax_calendar_for_locations.js
trunk/controller/templates/base/calendar/view_calendar_aggregated.xsl
Modified: trunk/controller/inc/class.uicalendar.inc.php
===================================================================
--- trunk/controller/inc/class.uicalendar.inc.php 2018-01-12 09:35:36 UTC
(rev 17565)
+++ trunk/controller/inc/class.uicalendar.inc.php 2018-01-12 12:28:43 UTC
(rev 17566)
@@ -57,13 +57,18 @@
private $so_check_list;
private $so_check_item;
private $location_finder;
+ var $type_id;
+ private $bo;
+ private $bocommon;
public $public_functions = array
(
'view_calendar_for_month' => true,
'view_calendar_for_year' => true,
+ 'view_calendar_for_year2' => true,
'view_calendar_year_for_locations' => true,
'view_calendar_month_for_locations' => true,
- 'update_bookmark' => true
+ 'update_bookmark' => true,
+ 'query' => true
);
public function __construct()
@@ -76,6 +81,10 @@
$delete = $GLOBALS['phpgw']->acl->check('.control',
PHPGW_ACL_DELETE, 'controller'); //8
$manage = $GLOBALS['phpgw']->acl->check('.control', 16,
'controller'); //16
+
+ $this->bo = CreateObject('property.bolocation', true);
+ $this->bocommon = & $this->bo->bocommon;
+ $this->type_id = $this->bo->type_id;
$this->so = CreateObject('controller.socheck_list');
$this->so_control =
CreateObject('controller.socontrol');
@@ -475,7 +484,301 @@
self::render_template_xsl('calendar/calendar_year_no_loc', $data);
}
}
+
+ public function view_calendar_for_year2($location_array = null,
$year = null)
+ {
+ //$location_array = phpgw::get_var('location_array');
+ //_debug_array($location_array['data']);
+// if(!empty($location_array))
+// {
+// _debug_array($location_array['data']);
+//// foreach ($location_array as $loc_no => $currval)
+//// {
+//// var_dump($loc_no);
+//// }
+// }
+//
+ $location_code = phpgw::get_var('location_code');
+ if($year == null)
+ $year = phpgw::get_var('year');
+ $role = phpgw::get_var('role', 'int');
+ $repeat_type = phpgw::get_var('repeat_type');
+
+ //show only controls that are not done
+ $selected_ctrl_status =
phpgw::get_var('current_ctrl_status');
+
+ // Validates year. If year is not set, current year is
chosen
+ $year = $this->validate_year($year);
+
+ // Validates repeat type.
+ $repeat_type =
$this->validate_repeat_type($repeat_type);
+
+ // Validates role.
+// $role = $this->validate_role($role);
+ // Gets timestamp of first day in year
+ $from_date_ts = $this->get_start_date_year_ts($year);
+
+ // Gets timestamp of first day in next year
+ $to_date_ts = $this->get_end_date_year_ts($year);
+
+ // Array that will be populated with controls and
calendar objects that will be sent to view
+ $controls_calendar_array = array();
+
+ // Validates location_code. If not set, first location
among assigned locations
+ $location_code =
$this->validate_location_code($location_code);
+
+// if ($location_code != null && $location_code != "")
+// {
+ if(is_array($location_array))
+ {
+ $locations_with_control = array();
+ foreach ($location_array as $loc_code
=>&$curr_pos)
+ {
+ $curr_pos['location_code'] = $loc_code;
+ //_debug_array($curr_pos);
+ }
+
+ foreach ($location_array as $curr_loc)
+ {
+ //$curr = array();
+ //$curr['location_code'] =
$curr_loc['location_code'];
+ //$curr['controls_calendar_array'] =
$curr_loc['controls_calendar_array'];
+
if(is_array($curr_loc['controls_calendar_array']) &&
!empty($curr_loc['controls_calendar_array']))
+ {
+ $locations_with_control[] =
$curr_loc;
+ }
+ }
+ //_debug_array($locations_with_control);
+
+ $heading_array =
year_calendar::get_heading_array();
+// _debug_array($heading_array);
+
+ $roles_array = $this->so_control->get_roles();
+
+ $repeat_type_array = array(
+ array('id' => "0", 'value' => "Dag"),
+ array('id' => "1", 'value' => "Uke"),
+ array('id' => "2", 'value' => "Måned"),
+ array('id' => "3", 'value' => "År")
+ );
+
+ $ctrl_status_array = array(
+ array('id' => "CONTROL_REGISTERED",
'value' => "CONTROL_REGISTERED"),
+ array('id' => "CONTROL_PLANNED",
'value' => "CONTROL_PLANNED"),
+ array('id' =>
"CONTROL_DONE_OVER_TIME_WITHOUT_ERRORS", 'value' =>
"CONTROL_DONE_OVER_TIME_WITHOUT_ERRORS"),
+ array('id' =>
"CONTROL_DONE_IN_TIME_WITHOUT_ERRORS", 'value' =>
"CONTROL_DONE_IN_TIME_WITHOUT_ERRORS"),
+ array('id' =>
"CONTROL_DONE_WITH_ERRORS", 'value' => "CONTROL_DONE_WITH_ERRORS"),
+ array('id' => "CONTROL_NOT_DONE",
'value' => "CONTROL_NOT_DONE"),
+ //array('id' =>
"CONTROL_NOT_DONE_WITH_PLANNED_DATE", 'value' =>
"CONTROL_NOT_DONE_WITH_PLANNED_DATE"),
+ array('id' => "CONTROL_CANCELED",
'value' => "CONTROL_CANCELED")
+ );
+
+
$GLOBALS['phpgw']->translation->add_app('property');
+
+ $district_list =
$this->bocommon->select_district_list('filter', $this->district_id);
+
+ $part_of_town_list =
execMethod('property.bogeneric.get_list', array('type' => 'part_of_town',
+ 'selected' => $part_of_town_id));
+ $location_type_list =
execMethod('property.soadmin_location.select_location_type');
+
+ array_unshift($district_list, array('id' => '',
'name' => lang('select')));
+ array_unshift($part_of_town_list, array('id' =>
'', 'name' => lang('select')));
+ array_unshift($location_type_list, array('id'
=> '', 'name' => lang('select')));
+
+
+ $data = array
+ (
+ 'heading_array' => $heading_array,
+ 'location_calendar_array' =>
$locations_with_control,
+ 'roles_array' => $roles_array,
+ 'repeat_type_array' =>
$repeat_type_array,
+ 'ctrl_status_array' =>
$ctrl_status_array,
+ 'current_year' => $year,
+ 'multiple_locations' => 'yes',
+ 'filter_form' => array
+ (
+ 'district_list' =>
array('options' => $district_list),
+ 'part_of_town_list' =>
array('options' => $part_of_town_list),
+ 'location_type_list' =>
array('options' => $location_type_list),
+ ),
+ 'update_action' =>
self::link(array('menuaction' => 'controller.uicalendar.query'))
+ );
+
+ phpgwapi_jquery::load_widget('autocomplete');
+ self::add_javascript('controller',
'controller', 'ajax.js');
+ self::add_javascript('controller',
'controller', 'ajax_calendar_for_locations.js');
+
+
self::render_template_xsl(array('calendar/view_calendar_aggregated',
'calendar/check_list_status_manager',
+ 'calendar/icon_color_map',
'calendar/nav_calendar_year',
+ 'calendar/calendar_filters'), $data);
+ }
+ else
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] =
true;
+ $receipt = array();
+
+ if (phpgw::get_var('phpgw_return_as') == 'json')
+ {
+ return $this->query();
+ }
+
+ $msgbox_data = array();
+ if (phpgw::get_var('phpgw_return_as') != 'json'
&& $receipt = phpgwapi_cache::session_get('phpgwapi', 'phpgw_messages'))
+ {
+
phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
+ $msgbox_data =
$GLOBALS['phpgw']->common->msgbox_data($receipt);
+ $msgbox_data =
$GLOBALS['phpgw']->common->msgbox($msgbox_data);
+ }
+
+
$GLOBALS['phpgw']->translation->add_app('property');
+
+ $district_list =
$this->bocommon->select_district_list('filter', $this->district_id);
+
+ $part_of_town_list =
execMethod('property.bogeneric.get_list', array('type' => 'part_of_town',
+ 'selected' => $part_of_town_id));
+ $location_type_list =
execMethod('property.soadmin_location.select_location_type');
+
+ array_unshift($district_list, array('id' => '',
'name' => lang('select')));
+ array_unshift($part_of_town_list, array('id' =>
'', 'name' => lang('select')));
+ array_unshift($location_type_list, array('id'
=> '', 'name' => lang('select')));
+
+
+ $data = array
+ (
+ 'msgbox_data' => $msgbox_data,
+ 'filter_form' => array
+ (
+ 'district_list' =>
array('options' => $district_list),
+ 'part_of_town_list' =>
array('options' => $part_of_town_list),
+ 'location_type_list' =>
array('options' => $location_type_list),
+ ),
+ 'update_action' =>
self::link(array('menuaction' => 'controller.uicalendar.query'))
+ );
+
+ self::add_javascript('controller',
'controller', 'ajax_calendar_for_locations.js');
+
+
self::render_template_xsl(array('calendar/view_calendar_aggregated'), $data);
+ }
+ }
+
+ public function get_location_calendar_for_year($location_code,
$year = null)
+ {
+ $role = phpgw::get_var('role', 'int');
+ $repeat_type = phpgw::get_var('repeat_type');
+
+ //show only controls that are not done
+ $selected_ctrl_status =
phpgw::get_var('current_ctrl_status');
+
+ // Validates year. If year is not set, current year is
chosen
+ $year = $this->validate_year($year);
+
+ // Validates repeat type.
+ $repeat_type =
$this->validate_repeat_type($repeat_type);
+
+ // Gets timestamp of first day in year
+ $from_date_ts = $this->get_start_date_year_ts($year);
+
+ // Gets timestamp of first day in next year
+ $to_date_ts = $this->get_end_date_year_ts($year);
+
+ // Array that will be populated with controls and
calendar objects that will be sent to view
+ $controls_calendar_array = array();
+
+ // Validates location_code. If not set, first location
among assigned locations
+ $location_code =
$this->validate_location_code($location_code);
+
+ $level =
$this->location_finder->get_location_level($location_code);
+
+ $user_role = true;
+
+ // Fetches buildings on property
+ $buildings_on_property =
$this->location_finder->get_buildings_on_property($user_role, $location_code,
$level);
+
+ // Fetches all controls for the location within time
period
+ $controls_for_location_array =
$this->so_control->get_controls_by_location($location_code, $from_date_ts,
$to_date_ts, $repeat_type, "return_object", $role);
+
+ // Loops through controls with repeat type day or week
+ // and populates array that contains aggregated open
cases pr month.
+ foreach ($controls_for_location_array as $control)
+ {
+ if ($control->get_repeat_type() ==
controller_control::REPEAT_TYPE_DAY | $control->get_repeat_type() ==
controller_control::REPEAT_TYPE_WEEK)
+ {
+ $cl_criteria = new
controller_check_list();
+
$cl_criteria->set_control_id($control->get_id());
+
$cl_criteria->set_location_code($location_code);
+
+ $from_month =
$this->get_start_month_for_control($control);
+ $to_month =
$this->get_end_month_for_control($control);
+
+ // Loops through controls and populates
aggregate open cases pr month array.
+ $agg_open_cases_pr_month_array =
$this->build_agg_open_cases_pr_month_array($cl_criteria, $year, $from_month,
$to_month);
+
+ $year_calendar_agg = new
year_calendar_agg($control, $year, $location_code,
"VIEW_CONTROLS_FOR_LOCATION");
+ $calendar_array =
$year_calendar_agg->build_calendar($agg_open_cases_pr_month_array);
+
+ $controls_calendar_array[] =
array("control" => $control->toArray(), "calendar_array" => $calendar_array);
+ }
+ }
+
+ $repeat_type_expr = ">=2";
+ // Fetches control ids with check lists for specified
time period
+ $control_id_with_check_list_array =
$this->so->get_check_lists_for_location($location_code, $from_date_ts,
$to_date_ts, $repeat_type_expr);
+
+ // Loops through all controls for location and
populates controls with check lists
+ $controls_for_location_array =
$this->populate_controls_with_check_lists($controls_for_location_array,
$control_id_with_check_list_array);
+
+ foreach ($controls_for_location_array as $control)
+ {
+ if ($control->get_repeat_type() ==
controller_control::REPEAT_TYPE_MONTH | $control->get_repeat_type() ==
controller_control::REPEAT_TYPE_YEAR)
+ {
+ $year_calendar = new
year_calendar($control, $year, null, $location_code, "location");
+ $calendar_array =
$year_calendar->build_calendar($control->get_check_lists_array(),
$selected_ctrl_status);
+
+ $controls_calendar_array[] =
array("control" => $control->toArray(), "calendar_array" => $calendar_array);
+ }
+ }
+
+ $location_array =
execMethod('property.bolocation.read_single', array('location_code' =>
$location_code));
+
+ // Gets array of locations assigned to current user
+ $my_locations =
$this->get_my_assigned_locations($location_code);
+
+ $heading_array = year_calendar::get_heading_array();
+
+ $roles_array = $this->so_control->get_roles();
+
+ $repeat_type_array = array(
+ array('id' => "0", 'value' => "Dag"),
+ array('id' => "1", 'value' => "Uke"),
+ array('id' => "2", 'value' => "Måned"),
+ array('id' => "3", 'value' => "År")
+ );
+
+ $ctrl_status_array = array(
+ array('id' => "CONTROL_REGISTERED", 'value' =>
"CONTROL_REGISTERED"),
+ array('id' => "CONTROL_PLANNED", 'value' =>
"CONTROL_PLANNED"),
+ array('id' =>
"CONTROL_DONE_OVER_TIME_WITHOUT_ERRORS", 'value' =>
"CONTROL_DONE_OVER_TIME_WITHOUT_ERRORS"),
+ array('id' =>
"CONTROL_DONE_IN_TIME_WITHOUT_ERRORS", 'value' =>
"CONTROL_DONE_IN_TIME_WITHOUT_ERRORS"),
+ array('id' => "CONTROL_DONE_WITH_ERRORS",
'value' => "CONTROL_DONE_WITH_ERRORS"),
+ array('id' => "CONTROL_NOT_DONE", 'value' =>
"CONTROL_NOT_DONE"),
+ //array('id' =>
"CONTROL_NOT_DONE_WITH_PLANNED_DATE", 'value' =>
"CONTROL_NOT_DONE_WITH_PLANNED_DATE"),
+ array('id' => "CONTROL_CANCELED", 'value' =>
"CONTROL_CANCELED")
+ );
+
+ $data = array
+ (
+ 'heading_array' => $heading_array,
+ 'controls_calendar_array' =>
$controls_calendar_array,
+ 'roles_array' => $roles_array,
+ 'repeat_type_array' => $repeat_type_array,
+ 'ctrl_status_array' => $ctrl_status_array,
+ 'current_year' => $year
+ );
+
+ return $data;
+ }
+
public function view_calendar_year_for_locations()
{
static $_location_name = array();
@@ -1163,7 +1466,64 @@
public function query()
{
+ $year = date('Y');
+ $from_date_ts = mktime(0, 0, 0, 1, 1, $year);
+ $to_date_ts = mktime(0, 0, 0, 1, 1, $year+1);
+ $loc_array = array();
+ $loc_checklist_array = array();
+
+ $params = array(
+ 'start' => phpgw::get_var('start', 'int',
'REQUEST', 0),
+ 'results' => phpgw::get_var('length', 'int',
'REQUEST', 0),
+ 'order' =>
$columns[$order[0]['column']]['data'],
+ 'sort' => $order[0]['dir'],
+ 'allrows' => true,
+ 'district_id' => phpgw::get_var('district_id',
'int'),
+ 'cat_id' => phpgw::get_var('cat_id', 'int'),
+ 'status' => phpgw::get_var('status'),
+ 'part_of_town_id' =>
phpgw::get_var('part_of_town_id', 'int'),
+ 'location_code' =>
phpgw::get_var('location_code'),
+ 'type_id' => phpgw::get_var('location_level',
'int', 'REQUEST', 1)
+ );
+
+ $values = $this->bo->read($params);
+
+ foreach ($values as &$entry)
+ {
+ $loc_array[] = $entry['location_code'];
+ }
+ foreach ($loc_array as $curr_loc)
+ {
+ //get checklists for found locations
+ $loc_checklist_array[$curr_loc] =
$this->get_location_calendar_for_year($curr_loc, $year);
+ $loc_checklist_array[$curr_loc]['loc_name'] =
$this->bo->get_location_name($curr_loc);
+
+ }
+
+ foreach ($loc_checklist_array as &$curr_loc_checklist)
+ {
+
if(empty($curr_loc_checklist['controls_calendar_array']))
+ {
+ $curr_loc_checklist = [];
+ }
+ }
+// _debug_array($loc_checklist_array);
+ //die();
+
+ $result_data = array
+ (
+ 'results' => $loc_checklist_array
+ );
+
+ $this->view_calendar_for_year2($loc_checklist_array,
$year);
+
+ //$GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'controller.uicalendar.view_calendar_for_year2',
'location_array' => $loc_checklist_array));
+
+
+
+ //return $this->jquery_results($result_data);
+ //return $this->jquery_results($loc_checklist_array);
}
public function update_bookmark()
Modified: trunk/controller/inc/class.uicontrol_group.inc.php
===================================================================
--- trunk/controller/inc/class.uicontrol_group.inc.php 2018-01-12 09:35:36 UTC
(rev 17565)
+++ trunk/controller/inc/class.uicontrol_group.inc.php 2018-01-12 12:28:43 UTC
(rev 17566)
@@ -209,7 +209,7 @@
public function edit()
{
- //
phpgwapi_jquery::formvalidator_generate(array('location','date', 'security',
'file'));
+ //
phpgwapi_jquery::formvalidator_generate(array('location','date', 'security',
'file')); a
self::add_javascript('controller', 'controller',
'ajax.js');
$tabs = array
Added: trunk/controller/js/controller/ajax_calendar_for_locations.js
===================================================================
--- trunk/controller/js/controller/ajax_calendar_for_locations.js
(rev 0)
+++ trunk/controller/js/controller/ajax_calendar_for_locations.js
2018-01-12 12:28:43 UTC (rev 17566)
@@ -0,0 +1,394 @@
+var myColumnDefs = new Array();
+var oTable = null;
+
+$(document).ready(function ()
+{
+ $("#location_type").change(function ()
+ {
+ get_table_def();
+
+ var oArgs = {menuaction:
'controller.uicontrol_register_to_location.get_location_type_category',
location_type: $(this).val()};
+ var requestUrl = phpGWLink('index.php', oArgs, true);
+
+ var htmlString = "<option value=''>Velg</option>";
+
+ $.ajax({
+ type: 'POST',
+ dataType: 'json',
+ url: requestUrl,
+ success: function (data)
+ {
+ if (data != null)
+ {
+ var obj = data;
+
+ $.each(obj, function (i)
+ {
+ htmlString += "<option value='"
+ obj[i].id + "'>" + obj[i].name + "</option>";
+ });
+
+
$("#location_type_category").html(htmlString);
+ $("#loc1").html("<option
value=''>Velg</option>");
+ $("#loc2").html("<option
value=''>Velg</option>");
+ }
+ else
+ {
+ htmlString += "<option
value=''>Velg</option>";
+ $("#part_of_town_id").html(htmlString);
+ $("#loc1").html(htmlString);
+ $("#loc2").html(htmlString);
+ }
+ }
+ });
+ });
+
+ $("#location_type_category").change(function ()
+ {
+ var level = $("#location_type").val();
+ update_loc(level);
+ });
+
+ var oArgs = {menuaction: 'property.bolocation.get_locations_by_name'};
+ var baseUrl = phpGWLink('index.php', oArgs, true);
+ var location_type = 1;
+
+ //update part of town category based on district
+ $("#district_id").change(function ()
+ {
+ var district_id = $(this).val();
+ var oArgs = {menuaction:
'controller.uicontrol_register_to_location.get_district_part_of_town'};
+ var requestUrl = phpGWLink('index.php', oArgs, true);
+
+ var htmlString = "";
+
+ $.ajax({
+ type: 'POST',
+ dataType: 'json',
+ url: requestUrl + "&district_id=" + district_id,
+ success: function (data)
+ {
+ if (data != null)
+ {
+ var obj = JSON.parse(data);
+
+ $.each(obj, function (i)
+ {
+ htmlString += "<option value='"
+ obj[i].id + "'>" + obj[i].name + "</option>";
+ });
+
+ $("#part_of_town_id").html(htmlString);
+ $("#loc1").html("<option
value=''>Velg</option>");
+ $("#loc2").html("<option
value=''>Velg</option>");
+ }
+ else
+ {
+ htmlString += "<option
value=''>Velg</option>";
+ $("#part_of_town_id").html(htmlString);
+ $("#loc1").html(htmlString);
+ $("#loc2").html(htmlString);
+ }
+ }
+ });
+
+ $("#search-location_code").val('');
+ });
+
+
+ $("#part_of_town_id").change(function ()
+ {
+ var oArgs = {menuaction:
'controller.uicontrol_register_to_location.get_locations', child_level: 1,
part_of_town_id: $(this).val()};
+ var requestUrl = phpGWLink('index.php', oArgs, true);
+
+ var htmlString = "<option value=''>Velg</option>";
+
+ $.ajax({
+ type: 'POST',
+ dataType: 'json',
+ url: requestUrl,
+ success: function (data)
+ {
+ if (data != null)
+ {
+ var obj = data;
+
+ $.each(obj, function (i)
+ {
+ htmlString += "<option value='"
+ obj[i].id + "'>" + obj[i].id + " " + obj[i].name + "</option>";
+ });
+
+ $("#loc1").html(htmlString);
+ $("#loc2").html("<option
value=''>Velg</option>");
+ }
+ else
+ {
+ htmlString = "<option>Ingen</option>";
+ $("#loc1").html(htmlString);
+ $("#loc2").html(htmlString);
+ }
+ }
+ });
+
+ $("#search-location_code").val('');
+ });
+
+ $("#loc1").change(function ()
+ {
+ var oArgs = {menuaction:
'controller.uicontrol_register_to_location.get_locations', child_level: 2,
location_code: $(this).val()};
+ var requestUrl = phpGWLink('index.php', oArgs, true);
+
+ var htmlString = "<option value=''>Velg</option>";
+
+ $.ajax({
+ type: 'POST',
+ dataType: 'json',
+ url: requestUrl,
+ success: function (data)
+ {
+ if (data != null)
+ {
+ var obj = data;
+
+ $.each(obj, function (i)
+ {
+ htmlString += "<option value='"
+ obj[i].id + "'>" + obj[i].id + " " + obj[i].name + "</option>";
+ });
+
+ $("#loc2").html(htmlString);
+ }
+ else
+ {
+ htmlString = "<option>Ingen</option>";
+ $("#loc2").html(htmlString);
+ }
+ }
+ });
+
+ $("#search-location_code").val('');
+
+ });
+
+ $("#loc2").change(function ()
+ {
+ $("#search-location_code").val('');
+ update_location_table();
+ });
+
+
+
+ $("#search").click(function (e)
+ {
+ update_location_table();
+ });
+
+/*
+ * Display calendar based on selection
+ */
+ $("#acl_form").on("submit", function (e)
+ {
+ e.preventDefault();
+ //update_location_table();
+
+ var oArgs = {
+ menuaction: 'controller.uicalendar.query',
+ location_level: $("#location_type").val(),
+ cat_id: $("#location_type_category").val(),
+ district_id: $("#district_id").val(),
+ part_of_town_id: $("#part_of_town_id").val(),
+ //location_code: $("#loc1").val(),
+ };
+
+ var requestUrl = phpGWLink('index.php', oArgs, true);
+ window.location.href = requestUrl;
+
+ //alert(requestUrl);
+
+/* $.ajax({
+ type: 'POST',
+ dataType: 'json',
+ url: requestUrl,
+ success: function (data)
+ {
+ if (data)
+ {
+ if (data.sessionExpired)
+ {
+ alert('Sesjonen er utløpt - du
må logge inn på nytt');
+ return;
+ }
+ var htmlString = "";
+ var obj = data;
+ //console.log(data);
+ $.each(obj, function (i, val)
+ {
+ if(val !== null)
+ {
+ //console.log(i);
+ //console.log(val);
+ var oArgs2 = {
+ menuaction:
'controller.uicalendar.view_calendar_for_year2',
+ location_level:
$("#location_type").val(),
+ cat_id:
$("#location_type_category").val(),
+ district_id:
$("#district_id").val(),
+
part_of_town_id: $("#part_of_town_id").val(),
+ location_array:
val,
+ }
+ var requestUrl2 =
phpGWLink('index.php', oArgs2, true);
+ window.location.href =
requestUrl2;
+ /*
+ $.each(val, function
(key, value)
+ {
+
if(!$.isEmptyObject(value))
+ {
+
htmlString += key + " " + val[key]['loc_name'] + "<br/>";
+ }
+ })
+ }
+ });
+
+ $("#receipt").html(htmlString);
+ }
+ }
+ });*/
+ });
+});
+
+
+function update_loc(level)
+{
+ var oArgs = {
+ menuaction: 'property.bolocation.read',
+ cat_id: $("#location_type_category").val(),
+ district_id: $("#district_id").val(),
+ part_of_town_id: $("#part_of_town_id").val(),
+ location_code: $("#loc1").val(),
+ type_id: level
+ };
+
+ var requestUrl = phpGWLink('index.php', oArgs, true);
+
+ var htmlString = "<option value=''>Velg</option>";
+
+ $.ajax({
+ type: 'POST',
+ dataType: 'json',
+ url: requestUrl,
+ success: function (data)
+ {
+ if (data != null)
+ {
+ var obj = data;
+
+ $.each(obj, function (i)
+ {
+ htmlString += "<option value='" +
obj[i].location_code + "'>" + obj[i].location_code + " " + obj[i]["loc" + level
+ "_name"] + "</option>";
+ });
+
+ $("#loc" + level).html(htmlString);
+ if (level == 1)
+ {
+ $("#loc2").html("<option value=''>Velg
Eiendom først</option>");
+ }
+ if (level == 2)
+ {
+ $("#loc1").html("");
+ }
+ }
+ else
+ {
+ htmlString = "<option>Ingen</option>";
+ $("#loc1").html(htmlString);
+ $("#loc2").html(htmlString);
+ }
+ }
+ });
+
+
+
+}
+
+function get_table_def()
+{
+ var oArgs = {
+ menuaction:
'controller.uicontrol_register_to_location.get_entity_table_def',
+ location_level: $("#location_type").val()
+ };
+
+ var requestUrl = phpGWLink('index.php', oArgs, true);
+ $.ajax({
+ type: 'POST',
+ dataType: 'json',
+ url: requestUrl,
+ success: function (data)
+ {
+ if (data != null)
+ {
+ myColumnDefs = data;
+ init_component_table();
+ }
+ else
+ {
+ alert('error');
+ }
+ }
+ });
+
+}
+
+
+function init_component_table()
+{
+ var location_type = $("#location_type").val() != null ?
$("#location_type").val() : '';
+
+ if (!location_type)
+ {
+ return false;
+ }
+
+ var cat_id = $("#location_type_category").val() != null ?
$("#location_type_category").val() : '';
+
+ var control_registered = 0;
+ if ($("#control_registered").prop("checked"))
+ {
+ control_registered = 1;
+ }
+
+ var location_code = '';
+
+ if ($("#search-location_code").val() != null &&
$("#search-location_code").val())
+ {
+ location_code = $("#search-location_code").val();
+ }
+ else if ($("#loc2").val() != null && $("#loc2").val())
+ {
+ location_code = $("#loc2").val();
+ }
+ else if ($("#loc1").val() != null && $("#loc1").val())
+ {
+ location_code = $("#loc1").val();
+ }
+
+ var oArgs = {
+ menuaction: 'controller.uicalendar.query',
+ location_level: location_type,
+ district_id: $("#district_id").val(),
+ part_of_town_id: $("#part_of_town_id").val(),
+ cat_id: cat_id,
+ location_code: location_code
+ };
+ var requestUrl = phpGWLink('index.php', oArgs, true);
+
+ if (oTable)
+ {
+ api = oTable.api();
+ api.destroy();
+ }
+ $("#table_def").html('<table cellpadding="0" cellspacing="0" border="0"
id="datatable-container_0"></table>');
+ oTable = JqueryPortico.inlineTableHelper('datatable-container_0',
requestUrl, myColumnDefs);
+
+}
+
+function update_location_table()
+{
+ init_component_table();
+}
+
Added: trunk/controller/templates/base/calendar/view_calendar_aggregated.xsl
===================================================================
--- trunk/controller/templates/base/calendar/view_calendar_aggregated.xsl
(rev 0)
+++ trunk/controller/templates/base/calendar/view_calendar_aggregated.xsl
2018-01-12 12:28:43 UTC (rev 17566)
@@ -0,0 +1,450 @@
+<!--
+ Document : view_calendar_aggregated.xsl
+ Created on : 14. november 2017, 12:13
+ Author : Erik
+ Description:
+ Purpose of transformation follows.
+-->
+
+<xsl:template match="data" xmlns:php="http://php.net/xsl">
+<xsl:variable name="session_url"><xsl:text>&</xsl:text><xsl:value-of
select="php:function('get_phpgw_session_url')" /></xsl:variable>
+<xsl:variable name="serie_id"><xsl:value-of select="serie_id" /></xsl:variable>
+
+ <script>
+<xsl:text>
+
+$(document).ready(function(){
+
+ var oArgs = {menuaction:'property.bolocation.get_locations_by_name'};
+ var baseUrl = phpGWLink('index.php', oArgs, false);
+
+ var location_type = $("#loc_type").val();
+
+ $("#search-location-name").autocomplete({
+ source: function( request, response ) {
+ location_type = $("#loc_type").val();
+
+ $.ajax({
+ url: baseUrl,
+ dataType: "json",
+ data: {
+ location_name: request.term,
+ level: location_type,
+ phpgw_return_as: "json"
+ },
+ success: function( data ) {
+ response( $.map( data, function( item )
{
+ return {
+ label: item.name,
+ value:
item.location_code
+ }
+ }));
+ }
+ });
+ },
+ focus: function (event, ui) {
+ $(event.target).val(ui.item.label);
+ return false;
+ },
+ minLength: 1,
+ select: function( event, ui ) {
+ chooseLocation( ui.item.label, ui.item.value);
+ }
+ });
+});
+
+function chooseLocation( label, value ){
+ var currentYear = $("#currentYear").val();
+
+ var oArgs = {menuaction:'controller.uicalendar.view_calendar_for_year'};
+ var baseUrl = phpGWLink('index.php', oArgs, false);
+ var requestUrl = baseUrl + "&location_code=" + value +
"&year=" + currentYear;
+
+ window.location.replace(requestUrl);
+}
+
+</xsl:text>
+
+</script>
+
+<div class="yui-navset yui-navset-top" id="control_calendar_tabview">
+ <xsl:call-template name="view_calendar_for_locations" />
+ <xsl:if test="multiple_locations">
+ <xsl:call-template name="calendar_location" />
+ </xsl:if>
+</div>
+</xsl:template>
+
+
+<xsl:template name="view_calendar_for_locations"
xmlns:php="http://php.net/xsl">
+ <div class="content-wrp">
+ <div>
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <xsl:call-template name="msgbox"/>
+ </xsl:when>
+ </xsl:choose>
+ <div class="body">
+
+ <style type="text/css">
+
+ </style>
+
+ <div id="choose-location">
+ <xsl:apply-templates
select="filter_form" />
+
+ <form action="{update_action}"
name="acl_form" id="acl_form" method="post">
+
<xsl:call-template name="datatable"/>
+ </form>
+ </div>
+ </div>
+ </div>
+ </div>
+</xsl:template>
+
+<xsl:template match="filter_form" xmlns:php="http://php.net/xsl">
+ <xsl:call-template name="filter_list"/>
+</xsl:template>
+
+<xsl:template name="filter_list" xmlns:php="http://php.net/xsl">
+ <h4>Velg lokasjoner som du vil se årsplan for</h4>
+ <fieldset id="comp-filters">
+ <div class="select-box">
+ <div class="filter">
+ <label><xsl:value-of
select="php:function('lang', 'location type')" /></label>
+ <select id="location_type" name="location_type">
+ <xsl:apply-templates
select="location_type_list/options"/>
+ </select>
+ </div>
+ <div class="filter">
+ <label><xsl:value-of
select="php:function('lang', 'location category')" /></label>
+ <select id="location_type_category"
name="location_type_category"></select>
+ </div>
+ </div>
+
+ <div class="select-box">
+ <div class="filter">
+ <label><xsl:value-of select="php:function('lang',
'district')" /></label>
+ <select id="district_id" name="district_id">
+ <xsl:apply-templates
select="district_list/options"/>
+ </select>
+ </div>
+ <div class="filter">
+ <label><xsl:value-of
select="php:function('lang', 'part of town')" /></label>
+ <select id="part_of_town_id"
name="part_of_town_id">
+ <xsl:apply-templates
select="part_of_town_list/options"/>
+ </select>
+ </div>
+ </div>
+ </fieldset>
+</xsl:template>
+
+<xsl:template name="datatable" xmlns:php="http://php.net/xsl">
+ <xsl:variable name="label_show"><xsl:value-of select="php:function('lang',
'show')" /></xsl:variable>
+ <input type="submit" name="update_acl" id="frm_update_acl" class="btn"
value="{$label_show}"/>
+
+ <div id="receipt"></div>
+</xsl:template>
+
+<!-- options for use with select-->
+<xsl:template match="options">
+ <option value="{id}">
+ <xsl:if test="selected != 0">
+ <xsl:attribute name="selected" value="selected"/>
+ </xsl:if>
+ <xsl:value-of disable-output-escaping="yes" select="name"/>
+ </option>
+</xsl:template>
+
+<xsl:template name="calendar_location" xmlns:php="http://php.net/xsl">
+ <div id="main_content">
+ <div id="control_plan">
+ <div class="top">
+
+ <xsl:choose>
+ <xsl:when test="location_level = 1">
+ <h1>Kontrollplan for eiendom:
+ <xsl:value-of
select="current_location/loc1_name"/>
+ </h1>
+ </xsl:when>
+ <xsl:otherwise>
+ <h1>Kontrollplan for bygg:
+ <xsl:value-of
select="current_location/loc2_name"/>
+ </h1>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <h3>Kalenderoversikt for
+ <span class="year">
+ <xsl:value-of
select="current_year"/>
+ </span>
+ </h3>
+
+ <!-- ===================== SEARCH FOR LOCATION
================= -->
+ <div id="search-location" class="select-box">
+ <div id="choose-loc">
+ <input id="loc_type"
type="hidden" name="loc_type" value="2" />
+ <input type="hidden"
id="currentYear">
+ <xsl:attribute
name="value">
+ <xsl:value-of
select="current_year"/>
+ </xsl:attribute>
+ </input>
+ <label>Søk etter</label>
+ <span>
+ <a href="loc_type_2"
class="btn first active">Bygg</a>
+ <a href="loc_type_1"
class="btn">Eiendom</a>
+ </span>
+ </div>
+ <input type="text" value=""
id="search-location-name" />
+ </div>
+ </div>
+
+ <div class="middle">
+
+
+
+ <!-- ===================== COLOR ICON MAP
================= -->
+ <xsl:call-template name="icon_color_map" />
+
+ <!-- ===================== FILTERS
================= -->
+ <xsl:call-template name="calendar_filters" >
+ <xsl:with-param
name="view_period">year</xsl:with-param>
+ </xsl:call-template>
+
+ <!-- ===================== CALENDAR NAVIGATION
================= -->
+ <xsl:call-template name="nav_calendar_year">
+ <xsl:with-param
name="view">VIEW_CONTROLS_FOR_LOCATION</xsl:with-param>
+ </xsl:call-template>
+ </div>
+
+ <div id="cal_wrp">
+ <h2>Bygg/eiendom</h2>
+ <table id="calendar" class="year">
+ <tr class="heading">
+ <th class="title">
+ <span>Tittel</span>
+ </th>
+ <th class="assigned">
+ <span>Tildelt</span>
+ </th>
+ <th class="frequency">
+ <span>Frekvens</span>
+ </th>
+ <xsl:for-each
select="heading_array">
+ <th>
+ <xsl:variable
name="month_str">short_month <xsl:number/> capitalized</xsl:variable>
+ <xsl:value-of
select="php:function('lang', $month_str)" />
+ </th>
+ </xsl:for-each>
+ </tr>
+ <xsl:for-each
select="location_calendar_array">
+ <xsl:choose>
+ <xsl:when
test="controls_calendar_array/child::node()">
+ <xsl:for-each
select="controls_calendar_array">
+
<xsl:variable name="control_id">
+
<xsl:value-of select="control/id"/>
+
</xsl:variable>
+ <tr>
+
<xsl:choose>
+
<xsl:when test="(position() mod 2) != 1">
+
<xsl:attribute name="class">odd</xsl:attribute>
+
</xsl:when>
+
<xsl:otherwise>
+
<xsl:attribute name="class">even</xsl:attribute>
+
</xsl:otherwise>
+
</xsl:choose>
+
<td class="title">
+
<a class="show-control-details">
+
<xsl:attribute name="href">
+
<xsl:text>index.php?menuaction=controller.uicontrol.get_control_details</xsl:text>
+
<xsl:text>&control_id=</xsl:text>
+
<xsl:value-of select="control/id"/>
+
<xsl:text>&phpgw_return_as=stripped_html</xsl:text>
+
<xsl:value-of
select="php:function('get_phpgw_session_url')" />
+
</xsl:attribute>
+
<xsl:variable name="control_info_params">
+
<!--<xsl:text>index.php?menuaction=controller.uicontrol.get_control_details,
control_id</xsl:text>-->
+
<!--<xsl:value-of select="control/id"/>-->
+
<!--<xsl:text>&phpgw_return_as=stripped_html</xsl:text>-->
+
<!--<xsl:value-of select="$session_url"/>-->
+
</xsl:variable>
+
<xsl:value-of select="control/title"/>
+
</a>
+
</td>
+
<td class="assigned">
+
<span>
+
<xsl:value-of select="control/responsibility_name"/>
+
</span>
+
</td>
+
<td class="frequency">
+
<span>
+
<xsl:choose>
+
<xsl:when test="control/repeat_interval = 1 and
control/repeat_type < 3">
+
<span class="pre">Hver</span>
+
</xsl:when>
+
<xsl:when test="control/repeat_interval = 1 and
control/repeat_type = 3">
+
<span class="pre">Hvert</span>
+
</xsl:when>
+
<xsl:when test="control/repeat_interval = 2">
+
<span class="pre">Annenhver</span>
+
</xsl:when>
+
<xsl:when test="control/repeat_interval > 2">
+
<span class="pre">Hver</span>
+
<span>
+
<xsl:value-of
select="control/repeat_interval"/>.
+
</span>
+
</xsl:when>
+
</xsl:choose>
+
+
<span class="val">
+
<xsl:value-of select="control/repeat_type_label"/>
+
</span>
+
</span>
+
</td>
+
<xsl:for-each select="calendar_array">
+
<td>
+
<xsl:call-template name="check_list_status_manager" >
+
<xsl:with-param name="location_code">
+
<xsl:value-of select="/location_code"/>
+
</xsl:with-param>
+
<xsl:with-param name="serie_id"><xsl:value-of
select="/serie_id" /></xsl:with-param>
+
<xsl:with-param name="session_url"><xsl:value-of
select="php:function('get_phpgw_session_url')" /></xsl:with-param>
+
</xsl:call-template>
+
</td>
+
</xsl:for-each>
+ </tr>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+ <tr
class="cal_info_msg">
+ <td
colspan="3">
+
<xsl:value-of select="php:function('lang', 'error_msg_no_controls_in_period')"
/>
+ </td>
+ </tr>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </table>
+
+ <h2 class="components">Komponenter</h2>
+ <xsl:choose>
+ <xsl:when
test="components_calendar_array/child::node()">
+ <xsl:for-each
select="components_calendar_array">
+ <h3>
+ <xsl:value-of
select="component/xml_short_desc"/>
+ </h3>
+
+ <table id="calendar"
class="year">
+ <tr
class="heading">
+ <th
class="title">
+
<span>Tittel</span>
+ </th>
+ <th
class="assigned">
+
<span>Tildelt</span>
+ </th>
+ <th
class="frequency">
+
<span>Frekvens</span>
+ </th>
+
<xsl:for-each select="//heading_array">
+
<th>
+
<a>
+
<xsl:attribute name="href">
+
<xsl:text>index.php?menuaction=controller.uicalendar.view_calendar_for_month</xsl:text>
+
<xsl:text>&year=</xsl:text>
+
<xsl:value-of select="//current_year"/>
+
<xsl:text>&location_code=</xsl:text>
+
<xsl:value-of
select="//current_location/location_code"/>
+
<xsl:text>&month=</xsl:text>
+
<xsl:number/>
+
<xsl:value-of select="$session_url"/>
+
</xsl:attribute>
+
+
<xsl:variable name="month_str">short_month <xsl:number/>
capitalized</xsl:variable>
+
<xsl:value-of select="php:function('lang', $month_str)" />
+
</a>
+
</th>
+
</xsl:for-each>
+ </tr>
+
+ <xsl:for-each
select="controls_calendar">
+
<xsl:variable name="control_id">
+
<xsl:value-of select="control/id"/>
+
</xsl:variable>
+
+ <tr>
+
<xsl:choose>
+
<xsl:when test="(position() mod 2) != 1">
+
<xsl:attribute name="class">odd</xsl:attribute>
+
</xsl:when>
+
<xsl:otherwise>
+
<xsl:attribute name="class">even</xsl:attribute>
+
</xsl:otherwise>
+
</xsl:choose>
+
<td class="title">
+
<a class="show-control-details">
+
<xsl:attribute name="href">
+
<xsl:text>index.php?menuaction=controller.uicontrol.get_control_details</xsl:text>
+
<xsl:text>&control_id=</xsl:text>
+
<xsl:value-of select="control/id"/>
+
<xsl:text>&phpgw_return_as=stripped_html</xsl:text>
+
<xsl:value-of select="$session_url"/>
+
</xsl:attribute>
+
<xsl:value-of select="control/title"/>
+
</a>
+
</td>
+
<td class="assigned">
+
<span>
+
<xsl:value-of select="control/responsibility_name"/>
+
</span>
+
</td>
+
<td class="frequency">
+
<span>
+
<xsl:choose>
+
<xsl:when test="control/repeat_interval = 1 and
control/repeat_type < 3">
+
<span class="pre">Hver</span>
+
</xsl:when>
+
<xsl:when test="control/repeat_interval = 1 and
control/repeat_type = 3">
+
<span class="pre">Hvert</span>
+
</xsl:when>
+
<xsl:when test="control/repeat_interval = 2">
+
<span class="pre">Annenhver</span>
+
</xsl:when>
+
<xsl:when test="control/repeat_interval > 2">
+
<span class="pre">Hver</span>
+
<span>
+
<xsl:value-of
select="control/repeat_interval"/>.
+
</span>
+
</xsl:when>
+
</xsl:choose>
+
+
<span class="val">
+
<xsl:value-of select="control/repeat_type_label"/>
+
</span>
+
</span>
+
</td>
+
<xsl:for-each select="calendar_array">
+
<td>
+
<xsl:call-template name="check_list_status_manager" >
+
<xsl:with-param name="location_code">
+
<xsl:value-of
select="//current_location/location_code"/>
+
</xsl:with-param>
+
<xsl:with-param name="serie_id"><xsl:value-of
select="$serie_id"/></xsl:with-param>
+
<xsl:with-param name="session_url"><xsl:value-of
select="$session_url"/></xsl:with-param>
+
</xsl:call-template>
+
</td>
+
</xsl:for-each>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+ <div id="calendar">
+ <p
class="no-comp-msg">Ingen komponenter tilknyttet kontroll</p>
+ </div>
+ </xsl:otherwise>
+ </xsl:choose>
+ </div>
+ </div>
+ </div>
+</xsl:template>
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [17566] Added aggregated view on control status for locations,
erikhl <=