[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [8885]
From: |
Torstein |
Subject: |
[Fmsystem-commits] [8885] |
Date: |
Thu, 16 Feb 2012 07:41:16 +0000 |
Revision: 8885
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8885
Author: vator
Date: 2012-02-16 07:41:15 +0000 (Thu, 16 Feb 2012)
Log Message:
-----------
Modified Paths:
--------------
trunk/controller/inc/class.socheck_list.inc.php
trunk/controller/inc/class.uicalendar.inc.php
trunk/controller/inc/component/class.calendar_builder.inc.php
trunk/controller/inc/component/class.date_generator.inc.php
trunk/controller/inc/helper/class.check_list_status_info.inc.php
trunk/controller/inc/model/class.control.inc.php
Added Paths:
-----------
trunk/controller/inc/helper/class.status_agg_month_info.inc.php
Modified: trunk/controller/inc/class.socheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.socheck_list.inc.php 2012-02-15 22:12:15 UTC
(rev 8884)
+++ trunk/controller/inc/class.socheck_list.inc.php 2012-02-16 07:41:15 UTC
(rev 8885)
@@ -372,7 +372,6 @@
$sql .= "FROM controller_check_list cl, controller_control c ";
$sql .= "WHERE cl.location_code = '{$location_code}' ";
$sql .= "AND c.id = $control_id ";
- $sql .= "AND c.repeat_type < 2 ";
$sql .= "AND cl.control_id = c.id ";
$sql .= "AND cl.deadline >= $from_date_ts AND $to_date_ts >
cl.deadline ";
$sql .= "GROUP BY c.id";
Modified: trunk/controller/inc/class.uicalendar.inc.php
===================================================================
--- trunk/controller/inc/class.uicalendar.inc.php 2012-02-15 22:12:15 UTC
(rev 8884)
+++ trunk/controller/inc/class.uicalendar.inc.php 2012-02-16 07:41:15 UTC
(rev 8885)
@@ -34,6 +34,7 @@
include_class('controller', 'check_list', 'inc/model/');
include_class('controller', 'check_item', 'inc/model/');
include_class('controller', 'check_list_status_info', 'inc/helper/');
+ include_class('controller', 'status_agg_month_info', 'inc/helper/');
include_class('controller', 'calendar_builder', 'inc/component/');
include_class('controller', 'location_finder', 'inc/helper/');
@@ -117,10 +118,9 @@
$control_id_with_check_list_array =
$this->so->get_check_lists_for_location_2($location_code, $from_date_ts,
$to_date_ts);
// Loops through all controls for location and
populates controls with check lists
- $controls_with_check_list =
$this->populate_controls_with_check_lists($controls_for_location_array,
$control_id_with_check_list_array);
+ $control_with_check_list_array =
$this->populate_controls_with_check_lists($controls_for_location_array,
$control_id_with_check_list_array);
- $controls_calendar_array = array();
- $controls_calendar_array =
$this->calendar_builder->build_calendar_array( $controls_calendar_array,
$controls_with_check_list, $num_days_in_month, "view_days" );
+ $controls_calendar_array =
$this->calendar_builder->build_calendar_array( $control_with_check_list_array,
$num_days_in_month, "view_days" );
foreach($controls_calendar_array as &$inst)
{
@@ -191,7 +191,7 @@
$from_date_ts = strtotime("01/01/$year");
$to_year = $year + 1;
- $to_date_ts = strtotime("01/01/$to_year");
+ $to_date_ts = strtotime("01/01/$to_year");
$criteria = array
(
@@ -211,43 +211,32 @@
$repeat_type = null;
$controls_for_location_array =
$this->so_control->get_controls_by_location($location_code, $from_date_ts,
$to_date_ts, $repeat_type);
-
+
$this->calendar_builder = new
calendar_builder($from_date_ts, $to_date_ts);
$controls_calendar_array = array();
-
- // Puts aggregate values for daily controls in a twelve
month array
- foreach($controls_for_location_array as $control)
- {
- if($control->get_repeat_type() == 0 |
$control->get_repeat_type() == 1)
- {
- $controls_calendar_array =
$this->calendar_builder->build_agg_calendar_array($controls_calendar_array,
$control, $location_code, $year);
+
+ foreach($controls_for_location_array as &$control){
+ if($control->get_repeat_type() == 0 |
$control->get_repeat_type() == 1){
+ $control =
$this->build_agg_open_cases_for_month_array($control, $location_code, $year);
}
}
+
+ $repeat_type = 2;
+ // Fetches control ids with check lists for specified
time period
+ $control_id_with_check_list_array =
$this->so->get_check_lists_for_location_2($location_code, $from_date_ts,
$to_date_ts, $repeat_type);
- $repeat_type = 2;
- $control_check_list_array_for_month =
$this->so->get_check_lists_for_location( $location_code, $from_date_ts,
$to_date_ts, $repeat_type );
-
+ // 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);
+
$repeat_type = 3;
- $control_check_list_array_for_year =
$this->so->get_check_lists_for_location( $location_code, $from_date_ts,
$to_date_ts, $repeat_type );
+ // Fetches control ids with check lists for specified
time period
+ $control_id_with_check_list_array =
$this->so->get_check_lists_for_location_2($location_code, $from_date_ts,
$to_date_ts, $repeat_type);
- $control_check_list_array =
array_merge($control_check_list_array_for_month,
$control_check_list_array_for_year);
-
- $in_array = 0;
- foreach($controls_for_location_array as $control_loc){
- foreach($control_check_list_array as
$control_check_list){
- if($control_loc->get_id() ==
$control_check_list->get_id()){
- $in_array = 1;
- }
- }
-
- if($in_array == 0 &
$control_loc->get_repeat_type() != 0 & $control_loc->get_repeat_type() != 1 ){
- $control_check_list_array[] =
$control_loc;
- }
- }
-
- $controls_calendar_array =
$this->calendar_builder->build_calendar_array( $controls_calendar_array,
$control_check_list_array, 12, "view_months" );
+ // 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);
+ $controls_calendar_array =
$this->calendar_builder->build_calendar_array( $controls_for_location_array,
12, "view_months" );
foreach($controls_calendar_array as &$inst)
{
@@ -361,6 +350,45 @@
self::add_javascript('controller', 'controller',
'jquery.js');
self::add_javascript('controller', 'controller',
'ajax.js');
}
+
+ function build_agg_open_cases_for_month_array($control,
$location_code, $year){
+ if( date("Y", $control->get_start_date()) == $year ){
+ $from_month = date("n",
$control->get_start_date());
+ }else{
+ $from_month = 1;
+ }
+
+ if( date("Y", $control->get_end_date()) == $year ){
+ $to_month = date("n", $control->get_end_date());
+ }else{
+ $to_month = 12;
+ }
+
+ $agg_open_cases_for_month_array = array();
+
+ for($from_month;$from_month<=$to_month;$from_month++){
+
+ $trail_from_date_ts =
strtotime("$from_month/01/$year");
+
+ $trail_to_date_ts =
strtotime("$to_month/01/$year");
+ $so_check_list =
CreateObject('controller.socheck_list');
+
+ $num_open_cases_for_control_array = array();
+ $num_open_cases_for_control_array =
$so_check_list->get_num_open_cases_for_control( $control->get_id(),
$location_code, $trail_from_date_ts, $trail_to_date_ts );
+
+ if( !empty($num_open_cases_for_control_array) ){
+ $status_agg_month_info = new
status_agg_month_info();
+
$status_agg_month_info->set_month_nr(date("n", $from_month));
+
$status_agg_month_info->set_agg_open_cases(
$num_open_cases_for_control_array["count"] );
+ $agg_open_cases_for_month_array[] =
$status_agg_month_info;
+ }
+ }
+
+
$control->set_agg_open_cases_for_month_array($agg_open_cases_for_month_array);
+
+ return $control;
+ }
+
public function query(){}
}
\ No newline at end of file
Modified: trunk/controller/inc/component/class.calendar_builder.inc.php
===================================================================
--- trunk/controller/inc/component/class.calendar_builder.inc.php
2012-02-15 22:12:15 UTC (rev 8884)
+++ trunk/controller/inc/component/class.calendar_builder.inc.php
2012-02-16 07:41:15 UTC (rev 8885)
@@ -13,130 +13,10 @@
$this->period_end_date = $period_end_date;
}
- public function build_calendar_array( $controls_calendar_array,
$control_array, $num, $period_type ){
+ function init_calendar( $control, $num, $period_type ){
- foreach($control_array as $control){
-
- $calendar_array = $this->init_calendar( $control,
$calendar_array, $num, $period_type );
-
- foreach($control->get_check_lists_array() as
$check_list){
-
- $check_list_status_info = new
check_list_status_info();
- $check_list_status_info->set_check_list_id(
$check_list->get_id() );
+ $calendar_array = array();
- $todays_date_ts = mktime(0,0,0,date("m"),
date("d"), date("Y"));
-
- if( $check_list->get_status() == 0 &
$check_list->get_planned_date() > 0 & $check_list->get_deadline() >
$todays_date_ts)
- {
- $status = "control_planned";
- }
- else if( $check_list->get_status() == 0 &
$check_list->get_planned_date() > 0 & $check_list->get_deadline() <
$todays_date_ts )
- {
- $status =
"control_not_accomplished_with_info";
- }
- else if( $check_list->get_status() == 0 &
$check_list->get_deadline() < $todays_date_ts )
- {
- $status = "control_not_accomplished";
- }
- else if( $check_list->get_status() == 1 &
$check_list->get_completed_date() > $check_list->get_deadline() &
$check_list->get_num_open_cases() == 0)
- {
- $status =
"control_accomplished_over_time_without_errors";
- }
- else if( $check_list->get_status() == 1 &
$check_list->get_completed_date() < $check_list->get_deadline() &
$check_list->get_num_open_cases() == 0)
- {
- $status =
"control_accomplished_in_time_without_errors";
- }
- else if( $check_list->get_status() == 1 &
$check_list->get_num_open_cases() > 0){
- $status =
"control_accomplished_with_errors";
-
$check_list_status_info->set_num_open_cases($check_list->get_num_open_cases());
- }
- else if( $check_list->get_status() == 3 )
- {
- $status = "control_canceled";
- }
-
- $check_list_status_info->set_deadline_date(
date("d/m-Y", $check_list->get_deadline()) );
-
- if($period_type == "view_months")
- {
- $calendar_array[ date("n",
$check_list->get_deadline()) ]["status"] = $status;
- $calendar_array[ date("n",
$check_list->get_deadline()) ]["info"] = $check_list_status_info->serialize();
- }
- else if( $period_type == "view_days" )
- {
- $calendar_array[ date("j",
$check_list->get_deadline()) ]["status"] = $status;
- $calendar_array[ date("j",
$check_list->get_deadline()) ]["info"] = $check_list_status_info->serialize();
- }
- }
-
- $controls_calendar_array[] = array("control" =>
$control->toArray(), "calendar_array" => $calendar_array);
- }
-
- return $controls_calendar_array;
- }
-
- public function build_agg_calendar_array($controls_calendar_array,
$control, $location_code, $year){
-
- if( date("Y", $control->get_start_date()) == $year ){
- $from_month = date("n", $control->get_start_date());
- }else{
- $from_month = 1;
- }
-
- if( date("Y", $control->get_end_date()) == $year ){
- $to_month = date("n", $control->get_end_date());
- }else{
- $to_month = 12;
- }
-
- /*
- $todays_date_ts = mktime(0,0,0,date("m"), date("d"), date("Y"));
-
- $twelve_month_array = array();
-
-
- for($i=1;$i<=12;$i++){
- $trail_date_ts = strtotime("$i/01/$year");
-
- if($trail_date_ts > $control->get_start_date() &
$trail_date_ts < $todays_date_ts){
- $status = "controls_not_accomplished";
- }else if($trail_date_ts > $control->get_start_date() &
$trail_date_ts > $todays_date_ts){
- $status = "controls_registered";
- }
-
- $twelve_month_array[$i-1]["status"] = $status;
- }
- */
-
- for($from_month;$from_month<=$to_month;$from_month++){
-
- $trail_from_date_ts = strtotime("$from_month/01/$year");
-
- $trail_to_date_ts = strtotime("$to_month/01/$year");
- $so_check_list =
CreateObject('controller.socheck_list');
-
- $num_open_cases_for_control_array = array();
- $num_open_cases_for_control_array =
$so_check_list->get_num_open_cases_for_control( $control->get_id(),
$location_code, $trail_from_date_ts, $trail_to_date_ts );
-
- if( !empty($num_open_cases_for_control_array) ){
- $status = "controls_accomplished_with_errors";
-
- $twelve_month_array[$from_month-1]["status"] =
$status;
- $twelve_month_array[$from_month-1]["info"] =
$num_open_cases_for_control_array["count"];
- }else if( empty($num_open_cases_for_control_array) &
$todays_date_ts > $trail_to_date_ts){
- $status =
"controls_accomplished_without_errors";
-
- $twelve_month_array[$from_month-1]["status"] =
$status;
- }
- }
-
- $controls_calendar_array[] = array("control" =>
$control->toArray(), "calendar_array" => $twelve_month_array);
-
- return $controls_calendar_array;
- }
-
- function init_calendar( $control, $calendar_array, $num, $period_type ){
-
for($i=1;$i<=$num;$i++){
$calendar_array[$i] = null;
}
@@ -168,5 +48,76 @@
}
return $calendar_array;
- }
+ }
+
+ public function build_calendar_array( $controls_for_location_array,
$num, $period_type ){
+
+ foreach($controls_for_location_array as $control){
+
+ $calendar_array = $this->init_calendar( $control, $num,
$period_type );
+
+ if($period_type == "view_days" | ($period_type ==
"view_months" & $control->get_repeat_type() == 2 | $control->get_repeat_type()
== 3))
+ {
+ foreach($control->get_check_lists_array() as
$check_list)
+ {
+ $check_list_status_info = new
check_list_status_info();
+
$check_list_status_info->set_check_list_id( $check_list->get_id() );
+
+ $todays_date_ts =
mktime(0,0,0,date("m"), date("d"), date("Y"));
+
+ if( $check_list->get_status() == 0 &
$check_list->get_planned_date() > 0 & $check_list->get_deadline() >
$todays_date_ts)
+ {
+ $status = "control_planned";
+ }
+ else if( $check_list->get_status() == 0
& $check_list->get_planned_date() > 0 & $check_list->get_deadline() <
$todays_date_ts )
+ {
+ $status =
"control_not_accomplished_with_info";
+ }
+ else if( $check_list->get_status() == 0
& $check_list->get_deadline() < $todays_date_ts )
+ {
+ $status =
"control_not_accomplished";
+ }
+ else if( $check_list->get_status() == 1
& $check_list->get_completed_date() > $check_list->get_deadline() &
$check_list->get_num_open_cases() == 0)
+ {
+ $status =
"control_accomplished_over_time_without_errors";
+ }
+ else if( $check_list->get_status() == 1
& $check_list->get_completed_date() < $check_list->get_deadline() &
$check_list->get_num_open_cases() == 0)
+ {
+ $status =
"control_accomplished_in_time_without_errors";
+ }
+ else if( $check_list->get_status() == 1
& $check_list->get_num_open_cases() > 0){
+ $status =
"control_accomplished_with_errors";
+
$check_list_status_info->set_num_open_cases($check_list->get_num_open_cases());
+ }
+ else if( $check_list->get_status() == 3
)
+ {
+ $status = "control_canceled";
+ }
+
+
$check_list_status_info->set_deadline_date( date("d/m-Y",
$check_list->get_deadline()) );
+
+ $calendar_array[ date("j",
$check_list->get_deadline()) ]["status"] = $status;
+ $calendar_array[ date("j",
$check_list->get_deadline()) ]["info"] = $check_list_status_info->serialize();
+ }
+
+ $controls_calendar_array[] = array("control" =>
$control->toArray(), "calendar_array" => $calendar_array);
+ }
+ else if($period_type == "view_months" &
($control->get_repeat_type() == 0 | $control->get_repeat_type() == 1))
+ {
+ $twelve_month_array = array();
+
+
foreach($control->get_agg_open_cases_for_month_array() as
$status_agg_month_info)
+ {
+ $status =
"controls_accomplished_with_errors";
+
+
$twelve_month_array[$status_agg_month_info->get_month_nr()]["status"] = $status;
+
$twelve_month_array[$status_agg_month_info->get_month_nr()]["info"] =
$status_agg_month_info->get_agg_open_cases();
+ }
+
+ $controls_calendar_array[] = array("control" =>
$control->toArray(), "calendar_array" => $twelve_month_array);
+ }
+ }
+
+ return $controls_calendar_array;
+ }
}
\ No newline at end of file
Modified: trunk/controller/inc/component/class.date_generator.inc.php
===================================================================
--- trunk/controller/inc/component/class.date_generator.inc.php 2012-02-15
22:12:15 UTC (rev 8884)
+++ trunk/controller/inc/component/class.date_generator.inc.php 2012-02-16
07:41:15 UTC (rev 8885)
@@ -32,7 +32,7 @@
}
$period_start_date = $this->find_start_date_for_period(
$control_start_date );
-
+
$interval_date = $period_start_date;
while(($interval_date < $this->period_end_date) &&
($interval_date <= $control_end_date)){
Modified: trunk/controller/inc/helper/class.check_list_status_info.inc.php
===================================================================
--- trunk/controller/inc/helper/class.check_list_status_info.inc.php
2012-02-15 22:12:15 UTC (rev 8884)
+++ trunk/controller/inc/helper/class.check_list_status_info.inc.php
2012-02-16 07:41:15 UTC (rev 8885)
@@ -36,7 +36,7 @@
private $deadline_date;
private $info_text;
private $num_open_cases;
-
+
public function __construct(){}
public function set_check_list_id($check_list_id)
Added: trunk/controller/inc/helper/class.status_agg_month_info.inc.php
===================================================================
--- trunk/controller/inc/helper/class.status_agg_month_info.inc.php
(rev 0)
+++ trunk/controller/inc/helper/class.status_agg_month_info.inc.php
2012-02-16 07:41:15 UTC (rev 8885)
@@ -0,0 +1,59 @@
+<?php
+ /**
+ * phpGroupWare - controller: a part of a Facilities Management System.
+ *
+ * @author Erink Holm-Larsen <address@hidden>
+ * @author Torstein Vadla <address@hidden>
+ * @copyright Copyright (C) 2011,2012 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
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * phpGroupWare is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with phpGroupWare; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
+ *
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @internal Development of this application was funded by
http://www.bergen.kommune.no/
+ * @package property
+ * @subpackage controller
+ * @version $Id: class.check_list_status_info.inc.php 8571 2012-01-15
13:46:27Z vator $
+ */
+
+ class status_agg_month_info
+ {
+ private $month_nr;
+ private $agg_open_cases;
+
+ public function __construct(){}
+
+ public function set_month_nr($month_nr)
+ {
+ $this->month_nr = $month_nr;
+ }
+
+ public function get_month_nr() { return $this->month_nr; }
+
+ public function set_agg_open_cases($agg_open_cases)
+ {
+ $this->agg_open_cases = $agg_open_cases;
+ }
+
+ public function get_agg_open_cases() { return
$this->agg_open_cases; }
+
+ public function serialize()
+ {
+ return array(
+ 'agg_open_cases' => $this->get_agg_open_cases(),
+ 'month_nr' => $this->get_month_nr()
+ );
+ }
+ }
Modified: trunk/controller/inc/model/class.control.inc.php
===================================================================
--- trunk/controller/inc/model/class.control.inc.php 2012-02-15 22:12:15 UTC
(rev 8884)
+++ trunk/controller/inc/model/class.control.inc.php 2012-02-16 07:41:15 UTC
(rev 8885)
@@ -58,7 +58,7 @@
// Objects
protected $check_lists_array = array();
// Array that contains open cases for a month
- protected $agg_check_lists_array = array();
+ protected $agg_open_cases_for_month_array = array();
/**
* Constructor. Takes an optional ID. If a contract is
created from outside
@@ -211,6 +211,13 @@
public function get_check_lists_array() { return
$this->check_lists_array; }
+ public function
set_agg_open_cases_for_month_array($agg_open_cases_for_month_array)
+ {
+ $this->agg_open_cases_for_month_array =
$agg_open_cases_for_month_array;
+ }
+
+ public function get_agg_open_cases_for_month_array() { return
$this->agg_open_cases_for_month_array; }
+
/**
* Get a static reference to the storage object associated with
this model object
*
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [8885],
Torstein <=