fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [8886]


From: Torstein
Subject: [Fmsystem-commits] [8886]
Date: Thu, 16 Feb 2012 08:22:48 +0000

Revision: 8886
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8886
Author:   vator
Date:     2012-02-16 08:22:48 +0000 (Thu, 16 Feb 2012)
Log Message:
-----------


Modified Paths:
--------------
    trunk/controller/inc/class.uicalendar.inc.php
    trunk/controller/inc/component/class.calendar_builder.inc.php

Added Paths:
-----------
    trunk/controller/inc/helper/class.check_list_status_manager.inc.php

Modified: trunk/controller/inc/class.uicalendar.inc.php
===================================================================
--- trunk/controller/inc/class.uicalendar.inc.php       2012-02-16 07:41:15 UTC 
(rev 8885)
+++ trunk/controller/inc/class.uicalendar.inc.php       2012-02-16 08:22:48 UTC 
(rev 8886)
@@ -163,21 +163,6 @@
                        
self::render_template_xsl('calendar/view_calendar_month', $data);
                }
                
-               public function 
populate_controls_with_check_lists($controls_for_location_array, 
$control_id_with_check_list_array){
-                       $controls_with_check_list = array();
-                       
-                       foreach($controls_for_location_array as $control){
-                               foreach($control_id_with_check_list_array as 
$control_id){
-                                       if($control->get_id() == 
$control_id->get_id())
-                                               
$control->set_check_lists_array($control_id->get_check_lists_array());          
                                
-                               }
-                                       
-                               $controls_with_check_list[] = $control;
-                       }
-                       
-                       return $controls_with_check_list;
-               }
-               
                public function view_calendar_for_year()
                {
                        $location_code = phpgw::get_var('location_code');
@@ -351,6 +336,21 @@
                        self::add_javascript('controller', 'controller', 
'ajax.js');
                }
                
+               public function 
populate_controls_with_check_lists($controls_for_location_array, 
$control_id_with_check_list_array){
+                       $controls_with_check_list = array();
+                       
+                       foreach($controls_for_location_array as $control){
+                               foreach($control_id_with_check_list_array as 
$control_id){
+                                       if($control->get_id() == 
$control_id->get_id())
+                                               
$control->set_check_lists_array($control_id->get_check_lists_array());          
                                
+                               }
+                                       
+                               $controls_with_check_list[] = $control;
+                       }
+                       
+                       return $controls_with_check_list;
+               }
+               
                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());    

Modified: trunk/controller/inc/component/class.calendar_builder.inc.php
===================================================================
--- trunk/controller/inc/component/class.calendar_builder.inc.php       
2012-02-16 07:41:15 UTC (rev 8885)
+++ trunk/controller/inc/component/class.calendar_builder.inc.php       
2012-02-16 08:22:48 UTC (rev 8886)
@@ -1,8 +1,9 @@
 <?php
 phpgw::import_class('controller.socheck_list');
 include_class('controller', 'date_generator', 'inc/component/');
-
-       
+include_class('controller', 'check_list_status_info', 'inc/helper/');
+include_class('controller', 'check_list_status_manager', 'inc/helper/');
+               
 class calendar_builder {
        
        private $period_start_date;
@@ -50,9 +51,9 @@
                return $calendar_array;
        }
        
-       public function build_calendar_array( $controls_for_location_array, 
$num, $period_type ){
+       public function build_calendar_array( $controls_with_check_lists_array, 
$num, $period_type ){
                
-               foreach($controls_for_location_array as $control){
+               foreach($controls_with_check_lists_array as $control){
 
                        $calendar_array = $this->init_calendar( $control, $num, 
$period_type );
 
@@ -60,43 +61,11 @@
                        {
                                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_manager = new 
check_list_status_manager( $check_list );
                                        
-                                       
$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;
+                                       $check_list_status_info = 
$check_list_status_manager->get_status_for_check_list(); 
+                                                               
+                                       $calendar_array[ date("j", 
$check_list->get_deadline()) ]["status"] = 
$check_list_status_info->get_status();
                                        $calendar_array[ date("j", 
$check_list->get_deadline()) ]["info"] = $check_list_status_info->serialize();
                                }
                                

Added: trunk/controller/inc/helper/class.check_list_status_manager.inc.php
===================================================================
--- trunk/controller/inc/helper/class.check_list_status_manager.inc.php         
                (rev 0)
+++ trunk/controller/inc/helper/class.check_list_status_manager.inc.php 
2012-02-16 08:22:48 UTC (rev 8886)
@@ -0,0 +1,83 @@
+<?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 8885 2012-02-16 
07:41:15Z vator $
+       */
+
+       include_class('controller', 'check_list_status_info', 'inc/helper/');
+
+       class check_list_status_manager
+       {               
+               private $check_list;
+               
+               public function __construct($check_list){
+                       $this->check_list = $check_list;
+               }
+               
+               function get_status_for_check_list(){
+               
+                       $check_list_status_info = new check_list_status_info();
+                       $check_list_status_info->set_check_list_id( 
$this->check_list->get_id() );
+       
+                       $todays_date_ts = mktime(0,0,0,date("m"), date("d"), 
date("Y"));
+       
+                       if( $this->check_list->get_status() == 0 & 
$this->check_list->get_planned_date() > 0 & $this->check_list->get_deadline() > 
$todays_date_ts)
+                       {
+                               $status = "control_planned";
+                       }
+                       else if( $this->check_list->get_status() == 0 & 
$this->check_list->get_planned_date() > 0 & $this->check_list->get_deadline() < 
$todays_date_ts )
+                       {
+                               $status = "control_not_accomplished_with_info";
+                       }
+                       else if( $this->check_list->get_status() == 0 & 
$this->check_list->get_deadline() < $todays_date_ts )
+                       {
+                               $status = "control_not_accomplished";
+                       }
+                       else if( $this->check_list->get_status() == 1 & 
$this->check_list->get_completed_date() > $this->check_list->get_deadline() & 
$this->check_list->get_num_open_cases() == 0)
+                       {
+                               $status = 
"control_accomplished_over_time_without_errors";
+                       }
+                       else if( $this->check_list->get_status() == 1 & 
$this->check_list->get_completed_date() < $this->check_list->get_deadline() & 
$this->check_list->get_num_open_cases() == 0)
+                       {
+                               $status = 
"control_accomplished_in_time_without_errors";
+                       }
+                       else if( $this->check_list->get_status() == 1 & 
$this->check_list->get_num_open_cases() > 0){
+                               $status = "control_accomplished_with_errors";
+                               
$check_list_status_info->set_num_open_cases($this->check_list->get_num_open_cases());
+                       }
+                       else if( $this->check_list->get_status() == 3 )
+                       {
+                               $status = "control_canceled";
+                       }
+                       
+                       
+                       $check_list_status_info->set_deadline_date( 
date("d/m-Y", $this->check_list->get_deadline()) );
+                       $check_list_status_info->set_status($status);
+               
+                       return $check_list_status_info; 
+               }
+       }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]