[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [13134] more on controller
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [13134] more on controller |
Date: |
Mon, 04 May 2015 14:30:50 +0000 |
Revision: 13134
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=13134
Author: sigurdne
Date: 2015-05-04 14:30:49 +0000 (Mon, 04 May 2015)
Log Message:
-----------
more on controller
Modified Paths:
--------------
trunk/controller/inc/class.socheck_list.inc.php
trunk/controller/inc/class.socontrol.inc.php
trunk/controller/inc/class.uicomponent.inc.php
trunk/controller/inc/component/class.check_list_status_manager.inc.php
trunk/controller/inc/component/class.year_calendar.inc.php
trunk/controller/inc/model/class.check_list.inc.php
trunk/controller/templates/base/component.xsl
Modified: trunk/controller/inc/class.socheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.socheck_list.inc.php 2015-05-02 11:07:42 UTC
(rev 13133)
+++ trunk/controller/inc/class.socheck_list.inc.php 2015-05-04 14:30:49 UTC
(rev 13134)
@@ -629,16 +629,19 @@
* @param $repeat_type_expr repeat type expression
* @return array with check list objects
*/
- function get_check_lists_for_control_and_component( $control_id,
$location_id, $component_id, $from_date_ts, $to_date_ts, $repeat_type = null )
+ function get_check_lists_for_control_and_component( $control_id,
$location_id, $component_id, $from_date_ts, $to_date_ts, $repeat_type = null,
$user_id=0 )
{
$control_id = (int) $control_id;
$location_id = (int) $location_id;
$component_id = (int) $component_id;
+ $user_id = (int) $user_id;
- $sql = "SELECT cl.id as cl_id, cl.status as cl_status,
cl.comment as cl_comment, deadline, planned_date, completed_date, assigned_to,
";
- $sql .= "cl.component_id as cl_component_id, cl.location_id as
cl_location_id, cl.location_code as cl_location_code, num_open_cases,
num_pending_cases ,cl.serie_id ";
+ $sql = "SELECT cl.id as cl_id, cl.status as cl_status,
cl.comment as cl_comment, deadline, planned_date, completed_date,
cl.assigned_to, ";
+ $sql .= "cl.component_id as cl_component_id, cl.location_id as
cl_location_id,"
+ . " cl.location_code as cl_location_code, num_open_cases,
num_pending_cases ,cl.serie_id, cs.repeat_type ";
$sql .= "FROM controller_check_list cl ";
$sql .= "LEFT JOIN controller_control c on cl.control_id = c.id
";
+ $sql .= "LEFT JOIN controller_control_serie cs on cl.serie_id =
cs.id ";
$sql .= "WHERE cl.control_id = {$control_id} ";
$sql .= "AND cl.component_id = {$component_id} ";
$sql .= "AND cl.location_id = {$location_id} ";
@@ -647,9 +650,14 @@
{
$sql .= "AND c.repeat_type = $repeat_type ";
}
+
+// if($user_id)
+// {
+// $sql .= " AND assigned_to = {$user_id} ";
+// }
$sql .= "AND deadline BETWEEN $from_date_ts AND $to_date_ts ";
-
+// _debug_array($sql);
$this->db->query($sql);
$check_lists_array = array();
@@ -668,6 +676,8 @@
$check_list->set_num_pending_cases($this->unmarshal($this->db->f('num_pending_cases'),
'int'));
$check_list->set_assigned_to($this->unmarshal($this->db->f('assigned_to'),
'int'));
$check_list->set_serie_id($this->db->f('serie_id'));
+
$check_list->set_repeat_type($this->db->f('repeat_type'));
+
$check_lists_array[] = $check_list;
}
Modified: trunk/controller/inc/class.socontrol.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol.inc.php 2015-05-02 11:07:42 UTC
(rev 13133)
+++ trunk/controller/inc/class.socontrol.inc.php 2015-05-04 14:30:49 UTC
(rev 13134)
@@ -657,16 +657,17 @@
* @param $control_id control id
* @return array with arrays of component info
*/
- function get_components_for_control($control_id, $location_id =
0, $component_id = 0, $serie_id = 0)
+ function get_components_for_control($control_id, $location_id =
0, $component_id = 0, $serie_id = 0, $user_id = 0)
{
$control_id = (int) $control_id;
$serie_id = (int) $serie_id;
+ $user_id = (int) $user_id;
$controls_array = array();
$sql = "SELECT ccl.control_id, ccl.component_id as
component_id,"
. " ccl.location_id as location_id, ccs.id as serie_id,
ccs.assigned_to, ccs.start_date,"
- . " ccs.repeat_type, ccs.repeat_interval,
ccs.service_time, ccs.controle_time,"
+ . " ccs.repeat_type, ccs.repeat_interval,
ccs.service_time, ccs.controle_time, ccs.enabled as serie_enabled,"
. " bim_type.description, bim_item.location_code ";
$sql .= "FROM controller_control_component_list
ccl,controller_control_serie ccs, fm_bim_item bim_item, fm_bim_type bim_type ";
@@ -686,7 +687,11 @@
{
$sql .= " AND ccs.id = {$serie_id}";
}
-
+ if($user_id)
+ {
+ $sql .= " AND ccs.assigned_to = {$user_id}";
+ }
+// _debug_array($sql);
$this->db->query($sql);
while($this->db->next_record())
@@ -699,7 +704,8 @@
'repeat_type' =>
$this->db->f('repeat_type'),
'repeat_interval' =>
$this->db->f('repeat_interval'),
'service_time' =>
$this->db->f('service_time'),
- 'controle_time' =>
$this->db->f('controle_time')
+ 'controle_time' =>
$this->db->f('controle_time'),
+ 'serie_enabled' =>
(int)$this->db->f('serie_enabled')
);
$component = new controller_component();
@@ -715,7 +721,7 @@
$components_array[] = $component;
}
-
+// _debug_array($components_array);
if( count( $components_array ) > 0 )
{
return $components_array;
Modified: trunk/controller/inc/class.uicomponent.inc.php
===================================================================
--- trunk/controller/inc/class.uicomponent.inc.php 2015-05-02 11:07:42 UTC
(rev 13133)
+++ trunk/controller/inc/class.uicomponent.inc.php 2015-05-04 14:30:49 UTC
(rev 13134)
@@ -4,7 +4,8 @@
*
* @author Erink Holm-Larsen <address@hidden>
* @author Torstein Vadla <address@hidden>
- * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @author Sigurd Nes <address@hidden>
+ * @copyright Copyright (C) 2015 Free Software Foundation, Inc.
http://www.fsf.org/
* This file is part of phpGroupWare.
*
* phpGroupWare is free software; you can redistribute it and/or modify
@@ -134,6 +135,7 @@
'selected' => $this->account ==
$user['account_id'] ? 1 : 0
);
}
+ array_unshift($user_list, array('id' => '', 'name' =>
lang('select')));
// Sigurd: Start categories
$cats =
CreateObject('phpgwapi.categories', -1, 'controller', '.control');
@@ -158,7 +160,20 @@
array_unshift($district_list, array('id' => '', 'name'
=> lang('no district')));
// end district
+ $year_list = array();
+ $year = date('Y');
+ for ( $_year= ($year - 2); $_year < ($year + 5);
$_year++ )
+ {
+ $year_list[] = array
+ (
+ 'id' => $_year,
+ 'name' => $_year,
+ 'selected' => $_year == $year ? 1
: 0
+ );
+ }
+
+
$data = array(
'datatable_name' => lang('status components'),
'form' => array(
@@ -178,18 +193,24 @@
'text' =>
lang('Control_area'),
'list' =>
$control_areas_array,
'onchange'
=> 'update_table();'
- ),
+ ),*/
array('type' =>
'filter',
'name' =>
'user_id',
'text' =>
lang('User'),
'list' =>
$user_list,
'onchange'
=> 'update_table();'
- ),*/
+ ),
array('type' =>
'filter',
'name' =>
'district_id',
'text' =>
lang('district'),
'list' =>
$district_list,
'onchange'
=> 'update_table();'
+ ),
+ array('type' =>
'filter',
+ 'name' =>
'year',
+ 'text' =>
lang('year'),
+ 'list' =>
$year_list,
+ 'onchange'
=> 'update_table();'
),/*
array('type' =>
'text',
'text' =>
lang('searchfield'),
@@ -321,17 +342,22 @@
$components =
execMethod('property.soentity.read',array('location_id' => $location_id,
'district_id' => $district_id, 'allrows' => true));
$all_components = array();
$components_with_calendar_array = array();
-
+// _debug_array($components);
foreach($components as $_component)
{
$component_id = $_component['id'];
$all_components[$component_id] = $_component;
$controls =
execMethod('controller.socontrol.get_controls_at_component',
array('location_id' => $location_id, 'component_id' => $component_id));
+//_debug_array($controls);
foreach($controls as $_control)
{
+ if(!$_control['serie_enabled'])
+ {
+ // continue;
+ }
$control_id
= $_control['control_id'];
$control
= $so_control->get_single($_control['control_id']);
- $components_for_control_array =
$so_control->get_components_for_control($control_id, $location_id,
$component_id);
+ $components_for_control_array =
$so_control->get_components_for_control($control_id, $location_id,
$component_id,0);//,$user_id);
// LOCATIONS: Process aggregated values
for controls with repeat type day or week
if($control->get_repeat_type() <=
controller_control::REPEAT_TYPE_WEEK)
@@ -413,7 +439,7 @@
$component->set_xml_short_desc($short_desc_arr);
$repeat_type
= $control->get_repeat_type();
-
$component_with_check_lists =
$this->so->get_check_lists_for_control_and_component($control_id,
$component->get_location_id(), $component->get_id(), $from_date_ts,
$to_date_ts, $repeat_type);
+
$component_with_check_lists =
$this->so->get_check_lists_for_control_and_component($control_id,
$component->get_location_id(), $component->get_id(), $from_date_ts,
$to_date_ts, $repeat_type);// ,$user_id);
$check_lists_array =
$component_with_check_lists["check_lists_array"];
@@ -439,10 +465,18 @@
$control->set_repeat_interval($control_relation['repeat_interval']);
}
+
if(!$control_relation['serie_enabled'])
+ {
+ //
$control->set_repeat_interval(1000);
+ }
+
/*
* End override control
with data from serie
*/
-
+ if($check_lists_array)
+ {
+//
_debug_array($component_with_check_lists);
+ }
$year_calendar = new
year_calendar($control, $year, $component, null, "component",
$control_relation);
$calendar_array =
$year_calendar->build_calendar($check_lists_array);
@@ -450,13 +484,11 @@
"calendar_array" => $calendar_array);
}
}
-
-
-
}
}
+ _debug_array($components_with_calendar_array);
unset($component_id);
- _debug_array($components_with_calendar_array[1]);
+// _debug_array($components_with_calendar_array[1]);
// _debug_array($components);
//
_debug_array(array_keys($components_with_calendar_array));
$repeat_type_array = array
@@ -488,6 +520,9 @@
foreach($entry as $dataset)
{
$repeat_type =
(int)$dataset['component']['control_relation']['repeat_type'];
+ $service_time =
$dataset['component']['control_relation']['service_time'];
+ $controle_time =
$dataset['component']['control_relation']['controle_time'];
+
if($repeat_type > $max_repeat_type)
{
$max_repeat_type = $repeat_type;
@@ -496,6 +531,8 @@
{
if($calendar)
{
+
$calendar['info']['service_time'] = $calendar['info']['service_time'] ?
$calendar['info']['service_time'] : $service_time;
+
$calendar['info']['controle_time'] = $calendar['info']['controle_time'] ?
$calendar['info']['controle_time'] : $controle_time;
$_data[$month][$repeat_type] = $calendar;
}
}
@@ -569,8 +606,11 @@
}
//_debug_array($values);
$data_set = array();
+ $total_time = array();
foreach ($values as $entry)
{
+ $row = array();
+ $row_sum = array();
$row['component_id'] = $entry['component_id'];
$row['year'] = '';
$row['descr'] = '';
@@ -584,8 +624,16 @@
for ( $_month=1; $_month < 13; $_month++ )
{
$row[$_month] =
$this->translate_calendar_info($entry[$_month],$year, $_month);
+ if( !$user_id ||
$entry[$_month]['info']['assigned_to'] == $user_id)
+ {
+ $row_sum[$_month] =
$entry[$_month]['info']['service_time'] +
$entry[$_month]['info']['controle_time'];
+ }
+ else
+ {
+ $row_sum[$_month] = 0;
+ }
}
-
+ $total_time[] = $row_sum;
$data_set[] = $row;
}
$fields = $this->get_fields();
@@ -607,6 +655,31 @@
(
'tbody' => $tbody
);
+
+ unset($_month);
+
+ $sum_year = 0;
+
+ if(!$total_time)
+ {
+ for ( $_month=1; $_month < 13; $_month++ )
+ {
+ $result['time_sum'][$_month] = 0;
+ }
+ }
+ else
+ {
+ foreach ($total_time as $_row)
+ {
+ for ( $_month=1; $_month < 13;
$_month++ )
+ {
+ $result['time_sum'][$_month] +=
$_row[$_month];
+ $sum_year += $_row[$_month];
+ }
+ }
+ }
+ $result['time_sum'][0] = $sum_year;
+
return $result;
}
Modified: trunk/controller/inc/component/class.check_list_status_manager.inc.php
===================================================================
--- trunk/controller/inc/component/class.check_list_status_manager.inc.php
2015-05-02 11:07:42 UTC (rev 13133)
+++ trunk/controller/inc/component/class.check_list_status_manager.inc.php
2015-05-04 14:30:49 UTC (rev 13134)
@@ -35,10 +35,14 @@
private $check_list;
private $type;
- public function __construct($check_list, $type)
+ public function __construct($check_list, $type = '')
{
$this->check_list = $check_list;
$this->type = $type;
+ if(!$type)
+ {
+ $check_list->get_component_id() ? 'component' :
'';
+ }
}
function get_status_for_check_list()
Modified: trunk/controller/inc/component/class.year_calendar.inc.php
===================================================================
--- trunk/controller/inc/component/class.year_calendar.inc.php 2015-05-02
11:07:42 UTC (rev 13133)
+++ trunk/controller/inc/component/class.year_calendar.inc.php 2015-05-04
14:30:49 UTC (rev 13134)
@@ -38,8 +38,13 @@
{
$this->calendar_array[$i] = null;
}
-
- $ctr_start_date_ts = $this->control->get_start_date();
+
+ if($this->control_relation &&
!$this->control_relation['serie_enabled'])
+ {
+ return;
+ }
+
+ $ctr_start_date_ts = $this->control->get_start_date();
$ctr_end_date_ts = $this->control->get_end_date();
$period_start_date_ts = $this->get_start_date_year_ts($this->year);
$period_end_date_ts = $this->get_start_date_year_ts($this->year+1);
@@ -56,7 +61,8 @@
$check_list = new controller_check_list();
$check_list->set_deadline( $date_ts );
$check_list->set_control_id( $this->control->get_id() );
-
+
$check_list->set_assigned_to($this->control_relation['assigned_to']);
+
if($this->type == "component")
{
$check_list->set_component_id(
$this->component->get_id() );
@@ -68,9 +74,9 @@
$check_list->set_location_code( $this->location_code );
$check_list_status_manager = new
check_list_status_manager( $check_list, "location" );
}
+
+ $check_list_status_info =
$check_list_status_manager->get_status_for_check_list();
- $check_list_status_info =
$check_list_status_manager->get_status_for_check_list();
-
$month_nr = date("n", $date_ts);
$this->calendar_array[ $month_nr ]["status"] =
$check_list_status_info->get_status();
@@ -93,8 +99,13 @@
$month_nr = date("n",
$check_list_status_info->get_deadline_date_ts());
- $this->calendar_array[ $month_nr ]["status"] =
$check_list_status_info->get_status();
- $this->calendar_array[ $month_nr ]["info"] =
$check_list_status_info->serialize();
+ $repeat_type = $check_list->get_repeat_type();
+ if( !isset($this->calendar_array[ $month_nr ]) ||
$repeat_type > $this->calendar_array[ $month_nr ]['repeat_type'])
+ {
+ $this->calendar_array[ $month_nr
]['repeat_type'] = $repeat_type;
+ $this->calendar_array[ $month_nr ]["status"] =
$check_list_status_info->get_status();
+ $this->calendar_array[ $month_nr ]["info"] =
$check_list_status_info->serialize();
+ }
}
return $this->calendar_array;
Modified: trunk/controller/inc/model/class.check_list.inc.php
===================================================================
--- trunk/controller/inc/model/class.check_list.inc.php 2015-05-02 11:07:42 UTC
(rev 13133)
+++ trunk/controller/inc/model/class.check_list.inc.php 2015-05-04 14:30:49 UTC
(rev 13134)
@@ -43,6 +43,7 @@
protected $description;//
protected $control_id;
protected $serie_id;
+ protected $repeat_type;
protected $status;
protected $comment;
protected $deadline;
@@ -205,7 +206,16 @@
{
return $this->serie_id;
}
+ public function set_repeat_type($repeat_type)
+ {
+ $this->repeat_type = $repeat_type;
+ }
+ public function get_repeat_type()
+ {
+ return $this->repeat_type;
+ }
+
public function get_num_open_cases() { return
$this->num_open_cases; }
public function set_num_open_cases($num_open_cases)
Modified: trunk/controller/templates/base/component.xsl
===================================================================
--- trunk/controller/templates/base/component.xsl 2015-05-02 11:07:42 UTC
(rev 13133)
+++ trunk/controller/templates/base/component.xsl 2015-05-04 14:30:49 UTC
(rev 13134)
@@ -167,6 +167,22 @@
if( data != null)
{
$("#tbody").html(data.tbody);
+ var time_sum = data.time_sum;
+
+ $("#sum_text").html('Sum');
+ $("#month0").html(time_sum[0]);
+ $("#month1").html(time_sum[1]);
+ $("#month2").html(time_sum[2]);
+ $("#month3").html(time_sum[3]);
+ $("#month4").html(time_sum[4]);
+ $("#month5").html(time_sum[5]);
+ $("#month6").html(time_sum[6]);
+ $("#month7").html(time_sum[7]);
+ $("#month8").html(time_sum[8]);
+ $("#month9").html(time_sum[9]);
+
$("#month10").html(time_sum[10]);
+
$("#month11").html(time_sum[11]);
+
$("#month12").html(time_sum[12]);
}
}
});
@@ -177,6 +193,40 @@
<table id="datatable-container" class="display cell-border compact
responsive no-wrap" width="100%">
<thead>
<tr>
+ <td>
+ </td>
+ <td id='sum_text'>
+ </td>
+ <td id='month0'>
+ </td>
+ <td id='month1'>
+ </td>
+ <td id='month2'>
+ </td>
+ <td id='month3'>
+ </td>
+ <td id='month4'>
+ </td>
+ <td id='month5'>
+ </td>
+ <td id='month6'>
+ </td>
+ <td id='month7'>
+ </td>
+ <td id='month8'>
+ </td>
+ <td id='month9'>
+ </td>
+ <td id='month10'>
+ </td>
+ <td id='month11'>
+ </td>
+ <td id='month12'>
+ </td>
+ </tr>
+ </thead>
+ <thead>
+ <tr>
<xsl:for-each select="//datatable/field">
<th>
<xsl:value-of select="label"/>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [13134] more on controller,
Sigurd Nes <=