fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15645] booking: more on scheduler


From: sigurdne
Subject: [Fmsystem-commits] [15645] booking: more on scheduler
Date: Fri, 9 Sep 2016 18:54:59 +0000 (UTC)

Revision: 15645
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15645
Author:   sigurdne
Date:     2016-09-09 18:54:59 +0000 (Fri, 09 Sep 2016)
Log Message:
-----------
booking: more on scheduler

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

Modified: trunk/booking/inc/class.bobooking.inc.php
===================================================================
--- trunk/booking/inc/class.bobooking.inc.php   2016-09-09 15:32:10 UTC (rev 
15644)
+++ trunk/booking/inc/class.bobooking.inc.php   2016-09-09 18:54:59 UTC (rev 
15645)
@@ -475,10 +475,9 @@
                                unset($booking['audience']);
                                unset($booking['agegroups']);
                        }
-                       //Sigurd: 09. Sept: testing
-                       $allocations = 
$this->split_allocations_test($allocations, $bookings);
-//                     $allocations = $this->split_allocations($allocations, 
$bookings);
 
+                       $allocations = $this->split_allocations($allocations, 
$bookings);
+
                        $event_ids = 
$this->so->event_ids_for_building($building_id, $from, $to);
                        $events = $this->event_so->read(array('filters' => 
array('id' => $event_ids)));
                        $events = $events['results'];
@@ -876,9 +875,9 @@
                                $booking['shortname'] = 
$booking['group_shortname'];
                                $booking['type'] = 'booking';
                        }
-                       //Sigurd: 09. Sept: testing
-                       $allocations = 
$this->split_allocations_test($allocations, $bookings);
 
+                       $allocations = $this->split_allocations($allocations, 
$bookings);
+
                        $event_ids = 
$this->so->event_ids_for_resource($resource_id, $from, $to);
                        $events = $this->event_so->read(array('filters' => 
array('id' => $event_ids)));
                        $events = $events['results'];
@@ -900,7 +899,7 @@
                 * Split allocations overlapped by bookings into multiple 
allocations
                 * to avoid overlaps
                 */
-               function split_allocations_test( $allocations, $all_bookings )
+               function split_allocations( $allocations, $all_bookings )
                {
 
                        function get_from2( $a )
@@ -961,54 +960,6 @@
                }
 
                /**
-         * Split allocations overlapped by bookings into multiple allocations
-         * to avoid overlaps
-         */
-        function split_allocations($allocations, $all_bookings)
-        {
-            function get_from2($a) {return $a['from_'];};
-            function get_to2($a) {return $a['to_'];};
-            $new_allocations = array();
-            foreach($allocations as $allocation)
-            {
-                // $ Find all associated bookings
-                $bookings = array();
-                foreach($all_bookings as $b)
-                {
-                    if($b['allocation_id'] == $allocation['id'])
-                        $bookings[] = $b;
-                }
-                $times = array($allocation['from_'], $allocation['to_']);
-                $times = array_merge(array_map("get_from2", $bookings), 
$times);
-                $times = array_merge(array_map("get_to2", $bookings), $times);
-                $times = array_unique($times);
-                sort($times);
-                while(count($times) >= 2)
-                {
-                    $from_ = $times[0];
-                    $to_ = $times[1];
-                    $resources = $allocation['resources'];
-                    $used = array();
-                    foreach($all_bookings as $b)
-                    {
-
-                        if(($b['from_'] >= $from_ && $b['from_'] < $to_) || 
($b['to_'] > $from_ && $b['to_'] <= $to_) || ($b['from_'] <= $from_ && 
$b['to_'] >= $to_))
-                            $resources = array_minus($resources, 
$b['resources']);
-                    }
-                    if($resources)
-                    {
-                        $a = $allocation;
-                        $a['from_'] = $times[0];
-                        $a['to_'] = $times[1];
-                        $new_allocations[] = $a;
-                    }
-                    array_shift($times);
-                }
-            }
-            return $new_allocations;
-        }
-
-               /**
                 * Split Multi-day bookings into separate single-day bookings
                 * */
                function _split_multi_day_bookings( $bookings, $t0, $t1 )

Modified: trunk/booking/inc/schedule.php
===================================================================
--- trunk/booking/inc/schedule.php      2016-09-09 15:32:10 UTC (rev 15644)
+++ trunk/booking/inc/schedule.php      2016-09-09 18:54:59 UTC (rev 15645)
@@ -88,10 +88,18 @@
                                                }
                                                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(empty($row[$booking['wday']]['type']) || $row[$booking['wday']]['type'] != 
'booking')
+                                                               {
+                                                                       
$row[$booking['wday']] = $booking;
+                                                               }
                                                        }
                                                        if ($booking['type'] == 
'booking')
                                                        {




reply via email to

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