fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11671] booking: fix loop in scheduler


From: Sigurd Nes
Subject: [Fmsystem-commits] [11671] booking: fix loop in scheduler
Date: Tue, 11 Feb 2014 13:44:50 +0000

Revision: 11671
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11671
Author:   sigurdne
Date:     2014-02-11 13:44:49 +0000 (Tue, 11 Feb 2014)
Log Message:
-----------
booking: fix loop in scheduler

Modified Paths:
--------------
    trunk/booking/inc/schedule.php

Modified: trunk/booking/inc/schedule.php
===================================================================
--- trunk/booking/inc/schedule.php      2014-02-11 10:12:41 UTC (rev 11670)
+++ trunk/booking/inc/schedule.php      2014-02-11 13:44:49 UTC (rev 11671)
@@ -11,12 +11,14 @@
        function get_to($a) {return $a['to_'];};
        function cmp_from($a, $b) {return strcmp($a['from_'], $b['from_']);};
        function cmp_to($a, $b) {return strcmp($a['to_'], $b['to_']);};
-       while(true) {
+       while(true)
+       {
                usort($bookings, 'cmp_from');
                // No bookings left
                if (count($bookings) == 0)
                {
-                       if($t != '24:00') {
+                       if($t != '24:00')
+                       {
                                $data[] = array(
                                        'time' => $t.'-00:00',
                                        '_from' => $t,
@@ -38,19 +40,27 @@
                        continue;
                }
                // Bookings found
-               else {
+               else
+               {
                        $next = array_filter(array_merge(array_map('get_from', 
$bookings), 
                                                                                
         array_map('get_to', $bookings)),
                                                                 
create_function('$a', "return \$a > '$t';"));
+                       if(!$next)
+                       {
+                               break;
+                       }
                        $next_t = min($next);
+
                        $first_row = true;
-                       foreach($resources as $res) {
+                       foreach($resources as $res)
+                       {
                                $row = array('resource'=> $res['name'], 
'resource_id' => $res['id']);
                                if($first_row)
                                {
                                        $tmp_t = $next_t == '24:00' ? '00:00' : 
$next_t;
                                        $row['time'] = $t.'-'.$tmp_t;
                                }
+
                                $row['_from'] = $t;
                                $row['_to'] = $tmp_t;
                                $empty = true;
@@ -63,16 +73,19 @@
                                        }
                                        if(in_array($res['id'], 
$booking['resources']))
                                        {
-                        if(!(($tempbooking[$booking['wday']]['from_'] <= 
$booking['from_']) and ($tempbooking[$booking['wday']]['to_'] == 
$booking['to_']) and ($tempbooking[$booking['wday']]['allocation_id'] == 
$booking['id']) and ($booking['type'] == 'allocation'))){
+                        if(!(($tempbooking[$booking['wday']]['from_'] <= 
$booking['from_']) and ($tempbooking[$booking['wday']]['to_'] == 
$booking['to_']) and ($tempbooking[$booking['wday']]['allocation_id'] == 
$booking['id']) and ($booking['type'] == 'allocation')))
+                        {
                                                    $empty = false;
                                                    $row[$booking['wday']] = 
$booking;
                         }
-                        if($booking['type'] == 'booking'){
+                        if($booking['type'] == 'booking')
+                        {
                                                $tempbooking[$booking['wday']] 
= $booking;
                         } 
                                        }
                                }
-                               if(!$empty) {
+                               if(!$empty)
+                               {
                                        $data[] = $row;
                                        $first_row = false;
                                }
@@ -84,7 +97,6 @@
                                array_shift($bookings);
                        }
                }
-
        }
        return $data;
 }




reply via email to

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