fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11179] controller: fix year-frequence


From: Sigurd Nes
Subject: [Fmsystem-commits] [11179] controller: fix year-frequence
Date: Sun, 16 Jun 2013 17:34:24 +0000

Revision: 11179
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11179
Author:   sigurdne
Date:     2013-06-16 17:34:23 +0000 (Sun, 16 Jun 2013)
Log Message:
-----------
controller: fix year-frequence

Modified Paths:
--------------
    trunk/controller/inc/component/class.date_generator.inc.php
    trunk/controller/inc/component/class.year_calendar.inc.php

Modified: trunk/controller/inc/component/class.date_generator.inc.php
===================================================================
--- trunk/controller/inc/component/class.date_generator.inc.php 2013-06-16 
17:02:16 UTC (rev 11178)
+++ trunk/controller/inc/component/class.date_generator.inc.php 2013-06-16 
17:34:23 UTC (rev 11179)
@@ -15,18 +15,20 @@
        
        private $calendar_array = array();
 
-       public function __construct($start_date, $end_date, $period_start_date, 
$period_end_date, $repeat_type, $repeat_interval){
+       public function __construct($start_date, $end_date, $period_start_date, 
$period_end_date, $repeat_type, $repeat_interval)
+       {
                $this->start_date = $start_date;
-    $this->end_date = $end_date;
-    $this->period_start_date = $period_start_date;
-    $this->period_end_date = $period_end_date;
-    $this->repeat_type = $repeat_type;
-    $this->repeat_interval = $repeat_interval;
+               $this->end_date = $end_date;
+               $this->period_start_date = $period_start_date;
+               $this->period_end_date = $period_end_date;
+               $this->repeat_type = $repeat_type;
+               $this->repeat_interval = $repeat_interval;
 
-    $this->generate_calendar();
-  }
+               $this->generate_calendar();
+       }
                
-       function generate_calendar(){
+       function generate_calendar()
+       {
                $control_start_date = $this->find_control_start_date();
                $control_end_date = $this->end_date;
                                
@@ -55,7 +57,8 @@
                        {
                                $month = date("m", 
$interval_date)+$this->repeat_interval;
                                $year = date("Y", $interval_date);
-                               if($month > 12){
+                               if($month > 12)
+                               {
                                        $month = $month % 12;
                                        $year += 1;
                                }
@@ -68,12 +71,12 @@
                                $interval_date = mktime(0,0,0, date("m", 
$interval_date), date("d", $interval_date), date("Y", 
$interval_date)+$this->repeat_interval);
                        }
                }
-  }
+       }
        
-  public function find_control_start_date(){
-       
-       if( $this->repeat_type == 0 )
-       {
+       public function find_control_start_date()
+       {
+               if( $this->repeat_type == 0 )
+               {
                        $control_start_date = $this->start_date;
                }
                else if( $this->repeat_type == 1 )
@@ -94,27 +97,31 @@
                                }
                        }
                }
-               else if( $this->repeat_type == 2 ){
+               else if( $this->repeat_type == 2 )
+               {
                        $num_days_in_month = cal_days_in_month(CAL_GREGORIAN, 
date("m", $this->start_date), date("y", $this->start_date));
                        $control_start_date = mktime(0,0,0, date("m", 
$this->start_date), $num_days_in_month, date("y", $this->start_date));
                }
-       else if( $this->repeat_type == 3 ){
-                       $num_days_in_month = cal_days_in_month(CAL_GREGORIAN, 
12, date("y", $this->start_date));
-                       $control_start_date = mktime(0,0,0, 12, 
$num_days_in_month, date("y", $this->start_date));
+               else if( $this->repeat_type == 3 )
+               {
+//                     $num_days_in_month = cal_days_in_month(CAL_GREGORIAN, 
12, date("y", $this->start_date));
+                       $num_days_in_month = cal_days_in_month(CAL_GREGORIAN, 
date("m", $this->start_date), date("y", $this->start_date));
+//                     $control_start_date = mktime(0,0,0, 12, 
$num_days_in_month, date("y", $this->start_date));
+                       $control_start_date = mktime(0,0,0, date("m", 
$this->start_date), $num_days_in_month, date("y", $this->start_date));
                }
                
                return $control_start_date;
   }
        
-  public function find_start_date_for_period( $trail_period_start_date )
-  {                            
-       while( $trail_period_start_date < $this->period_start_date )
-       {
+       public function find_start_date_for_period( $trail_period_start_date )
+       {                               
+               while( $trail_period_start_date < $this->period_start_date )
+               {
                        if($this->repeat_type == 0)
                        {
                                $trail_period_start_date = mktime(0,0,0, 
date("m", $trail_period_start_date), date("d", $trail_period_start_date) + 
$this->repeat_interval, date("Y", $trail_period_start_date));
                        }
-               else if($this->repeat_type == 1)
+                       else if($this->repeat_type == 1)
                        {
                                $trail_period_start_date = mktime(0,0,0, 
date("m", $trail_period_start_date), date("d", $trail_period_start_date) + 
($this->repeat_interval * 7), date("Y", $trail_period_start_date));
                        }
@@ -123,7 +130,8 @@
                                $month = date("m", $trail_period_start_date) + 
$this->repeat_interval;
                                $year = date("Y", $trail_period_start_date);
                                
-                               if($month > 12){
+                               if($month > 12)
+                               {
                                        $month = $month % 12;
                                        $year += 1;
                                }
@@ -140,7 +148,8 @@
                return $trail_period_start_date;
        }
                
-       public function get_dates(){
+       public function get_dates()
+       {
                return $this->calendar_array;
        }
 }

Modified: trunk/controller/inc/component/class.year_calendar.inc.php
===================================================================
--- trunk/controller/inc/component/class.year_calendar.inc.php  2013-06-16 
17:02:16 UTC (rev 11178)
+++ trunk/controller/inc/component/class.year_calendar.inc.php  2013-06-16 
17:34:23 UTC (rev 11179)
@@ -32,47 +32,47 @@
        function init_calendar()
        {
                // Sets null values for twelve months in calendar array 
-    for($i = 1;$i <= 12;$i++)
-    {
-                 $this->calendar_array[$i] = null;
-    }
+           for($i = 1;$i <= 12;$i++)
+           {
+                         $this->calendar_array[$i] = null;
+           }
                
-    $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);
-    $repeat_type = $this->control->get_repeat_type();
-    $repeat_interval = $this->control->get_repeat_interval();
+           $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);
+           $repeat_type = $this->control->get_repeat_type();
+           $repeat_interval = $this->control->get_repeat_interval();
     
     // Generates dates for time period with specified interval 
-    $date_generator = new date_generator($ctr_start_date_ts, $ctr_end_date_ts, 
$period_start_date_ts, $period_end_date_ts, $repeat_type, $repeat_interval);
-    $dates_array = $date_generator->get_dates();
+           $date_generator = new date_generator($ctr_start_date_ts, 
$ctr_end_date_ts, $period_start_date_ts, $period_end_date_ts, $repeat_type, 
$repeat_interval);
+           $dates_array = $date_generator->get_dates();
                
     // Set status for control on each date to NOT DONE or REGISTERED   
-    foreach($dates_array as $date_ts)
-    {
-       $check_list = new controller_check_list();
-       $check_list->set_deadline( $date_ts );
-       $check_list->set_control_id( $this->control->get_id() );
+           foreach($dates_array as $date_ts)
+           {
+               $check_list = new controller_check_list();
+               $check_list->set_deadline( $date_ts );
+               $check_list->set_control_id( $this->control->get_id() );
        
-       if($this->type == "component")
-       {
-               $check_list->set_component_id( $this->component->get_id() );
-               $check_list->set_location_id( 
$this->component->get_location_id() );
-               $check_list_status_manager = new check_list_status_manager( 
$check_list, "component" );
-       }
-       else 
-       {
-               $check_list->set_location_code( $this->location_code );
-               $check_list_status_manager = new check_list_status_manager( 
$check_list, "location" );
-       } 
+               if($this->type == "component")
+               {
+                       $check_list->set_component_id( 
$this->component->get_id() );
+                       $check_list->set_location_id( 
$this->component->get_location_id() );
+                       $check_list_status_manager = new 
check_list_status_manager( $check_list, "component" );
+               }
+               else 
+               {
+                       $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(); 
        
                        $month_nr = date("n", $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();
+             $this->calendar_array[ $month_nr ]["status"] = 
$check_list_status_info->get_status();
+             $this->calendar_array[ $month_nr ]["info"]   = 
$check_list_status_info->serialize();
                }
        }
        
@@ -122,4 +122,4 @@
                        
                return $start_date_year_ts;
        }
-}
\ No newline at end of file
+}




reply via email to

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