Ignore:
Timestamp:
05/14/12 16:15:42 (12 years ago)
Author:
acoutinho
Message:

Ticket #2727 - Quando criado evento com repeticoes com a hora data ou hora menor que a hora atual

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/prototype/modules/calendar/interceptors/Helpers.php

    r5636 r6177  
    33class Helpers {     
    44 
    5     public static function futureEvent( $startTime , $rangeEnd ) 
     5    public static function futureEvent( $startTime , $rangeEnd, $idSchedulable ) 
    66    {    
    77        //Verifica data   
    8                 $range = new DateTime( '@'.(int)($rangeEnd / 1000) , new DateTimeZone('UTC') ); 
     8        $range = new DateTime( '@'.(int)($rangeEnd / 1000) , new DateTimeZone('UTC') ); 
    99        list( $y1  , $m1 , $d1) = explode( '-' , $range->format('y-m-d'));  
    1010                 
     
    1313         
    1414        if($rangeEndMicrotime < $nowMicrotime )  
    15             return false; 
     15            return self::futureEventDecodedRepeat($startTime , $idSchedulable, $nowMicrotime); 
    1616         
    17         if($rangeEndMicrotime  === $nowMicrotime ) //caso seja o mesmo dia verifica a hora do evento. 
     17        if($rangeEndMicrotime === $nowMicrotime ) //caso seja o mesmo dia verifica a hora do evento. 
    1818        { 
    1919            $sTime = new DateTime( '@'.(int)($startTime / 1000) , new DateTimeZone('UTC') );             
     
    2222             
    2323            if( $eventHour  <  $nowHour ) 
    24                     return false; 
     24                    return self::futureEventDecodedRepeat($startTime , $idSchedulable, $nowMicrotime); 
    2525        } 
    2626       return true;  
    2727    } 
     28     
     29    public static function futureEventDecodedRepeat( $startTime , $idSchedulable, $nowMicrotime ) 
     30    {    
     31 
     32        $sql = 'SELECT calendar_repeat_occurrence.occurrence as "occurrence" ' 
     33        .'FROM calendar_repeat, calendar_repeat_occurrence WHERE calendar_repeat_occurrence.occurrence >= \'' . $startTime . '\' ' 
     34        .'AND calendar_repeat.object_id = \'' . $idSchedulable . '\' ' 
     35        .'AND calendar_repeat.id = calendar_repeat_occurrence.repeat_id AND ' 
     36        .'calendar_repeat_occurrence.exception != 1'; 
     37         
     38        $ocurrences = Controller::service('PostgreSQL')->execResultSql($sql); 
     39         
     40        if($ocurrences){ 
     41            $valid = FALSE; 
     42            foreach($ocurrences as $value) 
     43                if(($value['occurrence'] / 1000) > $nowMicrotime){ 
     44                    $valid = true; 
     45                    break; 
     46                }        
     47                return $valid; 
     48        }  else 
     49            return false; 
     50    } 
     51     
     52     
     53     
    2854     
    2955    /** 
Note: See TracChangeset for help on using the changeset viewer.