fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [8925]


From: Torstein
Subject: [Fmsystem-commits] [8925]
Date: Fri, 17 Feb 2012 15:11:45 +0000

Revision: 8925
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8925
Author:   vator
Date:     2012-02-17 15:11:45 +0000 (Fri, 17 Feb 2012)
Log Message:
-----------


Modified Paths:
--------------
    trunk/controller/inc/class.socheck_list.inc.php
    trunk/controller/inc/class.socontrol.inc.php
    trunk/controller/inc/class.uicalendar.inc.php
    trunk/controller/inc/component/class.calendar_builder.inc.php
    trunk/controller/inc/model/class.control.inc.php

Modified: trunk/controller/inc/class.socheck_list.inc.php
===================================================================
--- trunk/controller/inc/class.socheck_list.inc.php     2012-02-17 13:23:50 UTC 
(rev 8924)
+++ trunk/controller/inc/class.socheck_list.inc.php     2012-02-17 15:11:45 UTC 
(rev 8925)
@@ -200,6 +200,7 @@
                        
$control->set_equipment_id($this->unmarshal($this->db->f('equipment_id', true), 
'int'));
                        
$control->set_location_code($this->unmarshal($this->db->f('location_code', 
true), 'string'));
                        
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true), 
'int'));
+                       
$control->set_repeat_type_label($this->unmarshal($this->db->f('repeat_type', 
true), 'int'));
                        
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval', 
true), 'int'));
                                
                        $results[] = $control->toArray(); 
@@ -430,6 +431,7 @@
                                
$control->set_start_date($this->unmarshal($this->db->f('start_date', true), 
'int'));
                                
$control->set_end_date($this->unmarshal($this->db->f('end_date', true), 'int'));
                                
$control->set_control_area_id($this->unmarshal($this->db->f('control_area_id', 
true), 'int'));
+                                                               
                                if($use_location_inparam)
                                {
                                        
$control->set_location_code($location_code);
@@ -481,9 +483,7 @@
                
                $sql .= "AND deadline BETWEEN $from_date_ts AND $to_date_ts ";
                $sql .= "ORDER BY c.id;";
-
                
-               
                $this->db->query($sql);
                
                $control_id = 0;

Modified: trunk/controller/inc/class.socontrol.inc.php
===================================================================
--- trunk/controller/inc/class.socontrol.inc.php        2012-02-17 13:23:50 UTC 
(rev 8924)
+++ trunk/controller/inc/class.socontrol.inc.php        2012-02-17 15:11:45 UTC 
(rev 8925)
@@ -429,6 +429,7 @@
                        
$control->set_component_id($this->unmarshal($this->db->f('component_id', true), 
'int'));
                        
$control->set_location_code($this->unmarshal($this->db->f('location_code', 
true), 'string'));
                        
$control->set_repeat_type($this->unmarshal($this->db->f('repeat_type', true), 
'int'));
+                       
$control->set_repeat_type_label($control->get_repeat_type());
                        
$control->set_repeat_interval($this->unmarshal($this->db->f('repeat_interval', 
true), 'int'));
 
                        return $control;

Modified: trunk/controller/inc/class.uicalendar.inc.php
===================================================================
--- trunk/controller/inc/class.uicalendar.inc.php       2012-02-17 13:23:50 UTC 
(rev 8924)
+++ trunk/controller/inc/class.uicalendar.inc.php       2012-02-17 15:11:45 UTC 
(rev 8925)
@@ -201,9 +201,11 @@
                
                        $controls_calendar_array = array();
                
-                       foreach($controls_for_location_array as &$control){
+                       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);
+                                       $agg_open_cases_pr_month_array = 
$this->build_agg_open_cases_pr_month_array($control, $location_code, $year);
+                                                                               
+                                       
$control->set_agg_open_cases_pr_month_array( $agg_open_cases_pr_month_array );
                                }
                        }
                
@@ -223,6 +225,9 @@
        
                        $controls_calendar_array = 
$this->calendar_builder->build_calendar_array( $controls_for_location_array, 
12, "view_months" );
                        
+                       
+                       print_r($controls_calendar_array);
+                       
                        $location_array = 
execMethod('property.bolocation.read_single', array('location_code' => 
$location_code));
                        
                        $heading_array = array("Jan", "Feb", "Mar", "Apr", 
"Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Des");
@@ -255,30 +260,45 @@
                                $locations_for_control_array = 
$this->so_control->get_locations_for_control($control_id);
                        }
                        
-                       $year = date("Y");
-                       
-                       $year = intval($year);
+                       $year = intval( date("Y") );
                                                
                        $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");
 
                        $this->calendar_builder = new 
calendar_builder($from_date_ts, $to_date_ts);
-               
-                       $controls_calendar_array = array();
-                       foreach($locations_for_control_array as $location)
+                       
+                       $controls_with_check_lists_array = array();
+                       
+                       if( $control->get_repeat_type() == 0 | 
$control->get_repeat_type() == 1 )
                        {
-                               
$control->set_location_code($location["location_code"]);
-                               $controls_calendar_array = 
$this->calendar_builder->build_agg_calendar_array_2($controls_calendar_array, 
$control, $location["location_code"], $year);
-                               //_debug_array($controls_calendar_array);
-                               $control_check_list_array = 
$this->so->get_check_lists_for_location( $location["location_code"], 
$from_date_ts, $to_date_ts, $control->get_repeat_type(), $control->get_id() );
-                               //_debug_array($controls_check_list_array);
+                               foreach($locations_for_control_array as 
$location)
+                               {
+                                       $location_code = 
$location["location_code"];
+                                       
+                                       $agg_open_cases_pr_month_array = 
$this->build_agg_open_cases_pr_month_array($control, $location_code, $year);
+                                       $curr_control = clone $control;         
                                                                
+                                       
$curr_control->set_agg_open_cases_pr_month_array( 
$agg_open_cases_pr_month_array );
+                                       
$curr_control->set_location_code($location_code);
+
+                                       $controls_with_check_lists_array[] = 
$curr_control;
+                               }
                        }
+                       else if($control->get_repeat_type() == 2 | 
$control->get_repeat_type() == 3)
+                       {
+                               foreach($locations_for_control_array as 
$location)
+                               {
+                                       $location_code = 
$location["location_code"];
+                                       $curr_control = clone $control;
+                                       $control_check_list_array = 
$this->so->get_check_lists_for_location( $location_code, $from_date_ts, 
$to_date_ts, $control->get_repeat_type(), $control->get_id() );
+                                       
$curr_control->set_location_code($location_code);
+                                       
+                                       $controls_with_check_lists_array[] = 
$curr_control;
+                               }
+                       }
                        
-                       $controls_calendar_array = 
$this->calendar_builder->build_calendar_array_2( $controls_calendar_array, 
$control_check_list_array, 12, "view_months" );
-                       
-                       //_debug_array($controls_calendar_array);
-                       
+                       $controls_calendar_array = 
$this->calendar_builder->build_calendar_array($controls_with_check_lists_array, 
12, "view_months" );
+                                               
                        foreach($controls_calendar_array as &$inst)
                        {       
                                $curr_control = &$inst['control'];
@@ -288,15 +308,6 @@
                                        if($curr_control["location_code"] == 
$loc1["location_code"])
                                                $curr_control["location_name"] 
= $loc1["loc1_name"];
                                }
-
-                               if($curr_control['repeat_type'] == 0)
-                                       $curr_control['repeat_type'] = "Dag";
-                               else if($curr_control['repeat_type'] == 1)
-                                       $curr_control['repeat_type'] = "Uke";
-                               else if($curr_control['repeat_type'] == 2)
-                                       $curr_control['repeat_type'] = "Måned";
-                               else if($curr_control['repeat_type'] == 3)
-                                       $curr_control['repeat_type'] = "År";
                        }
                        
                        //_debug_array($controls_calendar_array);
@@ -338,7 +349,7 @@
                        return $controls_with_check_list;
                }
                
-               function build_agg_open_cases_for_month_array($control, 
$location_code, $year){
+               function build_agg_open_cases_pr_month_array($control, 
$location_code, $year){
                        if( date("Y", $control->get_start_date()) == $year ){
                                $from_month = date("n", 
$control->get_start_date());    
                        }else{
@@ -351,7 +362,7 @@
                                $to_month = 12;
                        }
                                        
-                       $agg_open_cases_for_month_array = array();
+                       $agg_open_cases_pr_month_array = array();
                        
                        for($from_month;$from_month<=$to_month;$from_month++){
                
@@ -367,13 +378,11 @@
                                        $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;
+                                       $agg_open_cases_pr_month_array[] = 
$status_agg_month_info;
                                } 
                        }
                        
-                       
$control->set_agg_open_cases_for_month_array($agg_open_cases_for_month_array);
-                       
-                       return $control;
+                       return $agg_open_cases_pr_month_array;
                }
                
 

Modified: trunk/controller/inc/component/class.calendar_builder.inc.php
===================================================================
--- trunk/controller/inc/component/class.calendar_builder.inc.php       
2012-02-17 13:23:50 UTC (rev 8924)
+++ trunk/controller/inc/component/class.calendar_builder.inc.php       
2012-02-17 15:11:45 UTC (rev 8925)
@@ -82,7 +82,7 @@
                        {
                                $calendar_array = array();
                                
-                               
foreach($control->get_agg_open_cases_for_month_array() as 
$status_agg_month_info)
+                               
foreach($control->get_agg_open_cases_pr_month_array() as $status_agg_month_info)
                                {
                                        $status = 
"controls_accomplished_with_errors";
                                        
@@ -96,126 +96,4 @@
 
                return $controls_calendar_array;
        }
-       
-       public function build_agg_calendar_array_2($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;
-       }
-       
-       public function build_calendar_array_2( $controls_calendar_array, 
$control_array, $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() );
-               
-                               $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;
-       }
 }
\ No newline at end of file

Modified: trunk/controller/inc/model/class.control.inc.php
===================================================================
--- trunk/controller/inc/model/class.control.inc.php    2012-02-17 13:23:50 UTC 
(rev 8924)
+++ trunk/controller/inc/model/class.control.inc.php    2012-02-17 15:11:45 UTC 
(rev 8925)
@@ -64,7 +64,7 @@
                // Objects
                protected $check_lists_array = array();
                // Array that contains open cases for a month   
-               protected $agg_open_cases_for_month_array = array();
+               protected $agg_open_cases_pr_month_array = array();
                
                /**
                 * Constructor.  Takes an optional ID.  If a contract is 
created from outside
@@ -241,12 +241,12 @@
                
                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)
+               public function 
set_agg_open_cases_pr_month_array($agg_open_cases_pr_month_array)
                {
-                       $this->agg_open_cases_for_month_array = 
$agg_open_cases_for_month_array;
+                       $this->agg_open_cases_pr_month_array = 
$agg_open_cases_pr_month_array;
                }
                
-               public function get_agg_open_cases_for_month_array() { return 
$this->agg_open_cases_for_month_array; }
+               public function get_agg_open_cases_pr_month_array() { return 
$this->agg_open_cases_pr_month_array; }
                
                /**
                 * Get a static reference to the storage object associated with 
this model object




reply via email to

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