From a7f2562c2cb13e3e4bd51fb4a42cdbdbc854c818 Mon Sep 17 00:00:00 2001 From: Daniel Camargo Date: Tue, 7 Jan 2014 18:39:54 -0200 Subject: [PATCH] partial #2278 - exporting the hours at the restaurant's api --- .../crunchbutton/api/restaurant/hours.php | 1 + include/library/Crunchbutton/Restaurant.php | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/controllers/default/crunchbutton/api/restaurant/hours.php b/include/controllers/default/crunchbutton/api/restaurant/hours.php index fe11d2803..083eb90fa 100644 --- a/include/controllers/default/crunchbutton/api/restaurant/hours.php +++ b/include/controllers/default/crunchbutton/api/restaurant/hours.php @@ -2,6 +2,7 @@ class Controller_api_restaurant_hours extends Crunchbutton_Controller_Rest { public function init() { + $r = Restaurant::o( c::getPagePiece( 3 ) ); if( !$r->id_restaurant ){ echo json_encode( [ 'error' => 'invalid object' ] ); diff --git a/include/library/Crunchbutton/Restaurant.php b/include/library/Crunchbutton/Restaurant.php index 0d17a9ebf..1a7d12b88 100644 --- a/include/library/Crunchbutton/Restaurant.php +++ b/include/library/Crunchbutton/Restaurant.php @@ -1292,6 +1292,9 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange { $ignore[ $property ] = true; } } +/* + + --> REMOVED THE HOURS MESSY #2278 $out['_open'] = $this->open(); $out['_force_open'] = $this->forceOpen(); @@ -1316,7 +1319,7 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange { $closesIn_hours = floor( $out['_closesIn'] / 60 ); $closesIn_minutes = $out['_closesIn'] - ( $closesIn_hours * 60 ); if( $closesIn_hours > 0 ){ - $out['_closesIn_formated'] = $closesIn_hours . ( $closesIn_hours > 1 ? ' hours ' : ' hour ' ) /* . ( $closesIn_minutes > 0 ? 'and ' . $closesIn_minutes . ' minutes' : '' ) */ ; + $out['_closesIn_formated'] = $closesIn_hours . ( $closesIn_hours > 1 ? ' hours ' : ' hour ' ); // . ( $closesIn_minutes > 0 ? 'and ' . $closesIn_minutes . ' minutes' : '' ) ; } else { $out['_closesIn_formated'] = ( $closesIn_minutes > 0 ? $closesIn_minutes . ' minutes' : '' ) ; } @@ -1326,7 +1329,7 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange { $openIn_hours = floor( $out['_openIn'] / 60 ); $openIn_minutes = $out['_openIn'] - ( $openIn_hours * 60 ); if( $openIn_hours > 0 ){ - $out['_openIn_formated'] = $openIn_hours . ( $openIn_hours > 1 ? ' hours ' : ' hour ' ) /* . ( $openIn_minutes > 0 ? 'and ' . $openIn_minutes . ' minutes' : '' ) */ ; + $out['_openIn_formated'] = $openIn_hours . ( $openIn_hours > 1 ? ' hours ' : ' hour ' ); // . ( $openIn_minutes > 0 ? 'and ' . $openIn_minutes . ' minutes' : '' ); } else { $out['_openIn_formated'] = ( $openIn_minutes > 0 ? $openIn_minutes . ' minutes' : '' ) ; } @@ -1347,6 +1350,7 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange { $out['_tag'] = 'force_close'; } } + */ $timezone = new DateTimeZone( $this->timezone ); $date = new DateTime( 'now ', $timezone ) ; @@ -1422,6 +1426,8 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange { $out['_notifications'][$notification->id_notification] = $notification->exports(); } } +/* + --> REMOVED THE HOURS MESSY #2278 if (!$ignore['_hoursFormat']) { foreach ($this->hours(true) as $hours) { @@ -1438,6 +1444,14 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange { $out['_hours'] = $this->overrideHours( $out['_hours'] ); $out['_hours_converted_utc'] = $this->hoursStartingMondayUTC( $out['_hours'] ); } +*/ + if( $isCockpit ){ + foreach ($this->hours() as $hours) { + $out['_hours'][$hours->day][] = [$hours->time_open, $hours->time_close]; + } + } else { + $out['_hours'] = $this->export_hours_next_24_hours(); + } if (!$ignore['_preset']) { if ($this->preset()->count()) {