partial #1382 - specific close times for restaurants (holidays)

This commit is contained in:
Daniel Camargo 2013-11-20 13:10:16 -02:00
parent b7ea95456d
commit 38e7d12b38
8 changed files with 290 additions and 104 deletions

View File

@ -44,12 +44,28 @@ class Controller_api_houroverride extends Crunchbutton_Controller_RestAccount {
$date_start = $this->request()[ 'date_start' ];
$date_start = explode( '/' , $date_start );
$date_start_hour = ( $this->request()[ 'date_start_hour' ] ) ? $this->request()[ 'date_start_hour' ] : '00:00';
$date_start = $date_start[ 2 ] . '/' . $date_start[ 0 ] . '/' . $date_start[ 1 ] . ' ' . $date_start_hour . ':00';
$date_start_hour = explode( ':', $date_start_hour );
$date_start_hr = $date_start_hour[ 0 ];
$date_start_mn = $date_start_hour[ 1 ];
$hour_override_date_start_ampm = $this->request()[ 'hour_override_date_start_ampm' ];
if( $hour_override_date_start_ampm == 'PM' ){
$date_start_hr = $date_start_hr + 12;
}
$date_start = $date_start[ 2 ] . '/' . $date_start[ 0 ] . '/' . $date_start[ 1 ] . ' ' . $date_start_hr . ':' . $date_start_mn;
$date_end = $this->request()[ 'date_end' ];
$date_end = explode( '/' , $date_end );
$date_end_hour = ( $this->request()[ 'date_end_hour' ] ) ? $this->request()[ 'date_end_hour' ] : '00:00';
$date_end = $date_end[ 2 ] . '/' . $date_end[ 0 ] . '/' . $date_end[ 1 ] . ' ' . $date_end_hour . ':00';
$date_end_hour = explode( ':', $date_end_hour );
$date_end_hr = $date_end_hour[ 0 ];
$date_end_mn = $date_end_hour[ 1 ];
$hour_override_date_end_ampm = $this->request()[ 'hour_override_date_end_ampm' ];
if( $hour_override_date_end_ampm == 'PM' ){
$date_end_hr = $date_end_hr + 12;
}
$date_end = $date_end[ 2 ] . '/' . $date_end[ 0 ] . '/' . $date_end[ 1 ] . ' ' . $date_end_hr . ':' . $date_end_mn;
$hour->date_start = $date_start;
$hour->date_end = $date_end;

View File

@ -2,7 +2,6 @@
class Controller_tests_hours extends Crunchbutton_Controller_Account {
public function init() {
$restaurant = new Restaurant($_REQUEST['r'] ? intval($_REQUEST['r']) : 1);
$now = (new DateTime('now'))->format('Y-m-d H:i:s');
if (!$_REQUEST['t'] || $_REQUEST['t'] == 'NOW') {
@ -11,15 +10,9 @@ class Controller_tests_hours extends Crunchbutton_Controller_Account {
} else {
$time = $_REQUEST['t'];
}
c::view()->restaurant = $restaurant;
c::view()->open = $restaurant->open($time);
c::view()->time = new DateTime($time, new DateTimeZone($restaurant->timezone));
c::view()->display('tests/hours/index');
}
}

View File

@ -32,6 +32,33 @@ class Cana_Util extends Cana_Model {
return $reverse ? array_reverse($array) : $array;
}
public static function format_time( $time ) {
$h = floor( $time / 100 );
$m = $time - ( 100 * $h );
if( $h >= 24 ){
$h -= 24;
}
$mintute_formated = ':' . str_pad( $m, 2, '0', STR_PAD_LEFT );
return $h . $mintute_formated;
}
function sort_col($table, $colname) {
$tn = $ts = $temp_num = $temp_str = array();
foreach ($table as $key => $row) {
if(is_numeric(substr($row[$colname], 0, 1))) {
$tn[$key] = $row[$colname];
$temp_num[$key] = $row;
}
else {
$ts[$key] = $row[$colname];
$temp_str[$key] = $row;
}
}
unset($table);
array_multisort($tn, SORT_ASC, SORT_NUMERIC, $temp_num);
array_multisort($ts, SORT_ASC, SORT_STRING, $temp_str);
return array_merge($temp_num, $temp_str);
}
public static function convertBytes($bytesIn, $from = 'bytes', $to = 'bytes') {

View File

@ -694,8 +694,6 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange {
}
public function hours($gmt = false) {
$force_close = $this->forceClose();
$gmt = $gmt ? '1' : '0';
@ -732,19 +730,24 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange {
/**
* Confirms a restaurant is open
*/
public function open($dt = null) {
public function open( $dt = null ) {
if (!$this->open_for_business) {
/*if( $this->forceOpen() ){
if( $this->forceOpen() ){
return true;
}*/
}
return false;
}
// it means some overrided hour is forcing it to be opened
if( $this->forceOpen() ){
return true;
}
// it means some overrided hour is forcing it to be closed
if( $this->forceClose() ){
return false;
}
/*if( $this->forceClose() ){
return false;
}
*/
$today = new DateTime( 'now', new DateTimeZone( $this->timezone ) );
$hours = $this->hours();
$day = strtolower($today->format('D'));
@ -806,13 +809,25 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange {
}
// Return minutes left to close
public function closesIn($dt = null) {
if (!$this->open()) {
public function closesIn( $dt = null ) {
if ( !$this->open() ) {
return false;
}
$hours = $this->hours();
$_hours = [];
foreach ( $this->hours() as $hour ) {
$_hours[$hour->day][] = [$hour->time_open, $hour->time_close];
}
$_hours = $this->overrideHours( $_hours );
$hours = [];
foreach( $_hours as $day => $segments ){
foreach( $segments as $segment ){
$hours[] = ( object ) [ 'day' => $day, 'time_open' => $segment[ 0 ], 'time_close' => $segment[ 1 ] ];
}
}
$today = new DateTime($dt ? $dt : 'now', new DateTimeZone($this->timezone));
$day = strtolower($today->format('D'));
$day = strtolower($today->format('D'));
foreach ($hours as $hour) {
if ($hour->day != $day) {
@ -835,14 +850,25 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange {
}
// Return minutes left to open
public function openIn($dt) {
public function openIn( $dt = null ) {
if ($this->open()) {
return false;
}
$hours = $this->hours();
$_hours = [];
foreach ( $this->hours() as $hour ) {
$_hours[$hour->day][] = [$hour->time_open, $hour->time_close];
}
$_hours = $this->overrideHours( $_hours );
$hours = [];
foreach( $_hours as $day => $segments ){
foreach( $segments as $segment ){
$hours[] = ( object ) [ 'day' => $day, 'time_open' => $segment[ 0 ], 'time_close' => $segment[ 1 ] ];
}
}
$today = new DateTime($dt ? $dt : 'now', new DateTimeZone($this->timezone));
$day = strtolower($today->format('D'));
$day = strtolower($today->format('D'));
foreach ($hours as $hour) {
if ($hour->day != $day) {
@ -1046,6 +1072,12 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange {
return $this->_weight;
}
public function export_force_override_hours(){
$data = $this->exports();
$data[ '_hours' ] = $this->overrideHours( $data[ '_hours' ] );
return $data;
}
/**
* Returns an array with all the information for a Restaurant.
*
@ -1073,7 +1105,7 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange {
$out['_closesIn'] = $this->closesIn();
$out['_weight'] = $this->weight();
$out['_minimumTime'] = 15; // Min minutes to show the hurry message
// $out['_openIn'] = $this->openIn();
$out['_openIn'] = $this->openIn();
if( $out['_closesIn'] == 0 ){
$out['_open'] = false;
@ -1177,7 +1209,10 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange {
$out['_hours'][$hours->day][] = [$hours->time_open, $hours->time_close];
}
$out['_hours'] = $this->overrideHours( $out['_hours'] );
// Dont export the overrided hours at cockpit
if( !$isCockpit || $ignore['force_override_hours'] == true ){
$out['_hours'] = $this->overrideHours( $out['_hours'] );
}
if (!$ignore['_preset']) {
if ($this->preset()->count()) {
@ -1213,40 +1248,146 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange {
}
public function overrideHours( $hours ){
/*
$overrides = Crunchbutton_Restaurant_Hour_Override::q( "SELECT * FROM restaurant_hour_override WHERE id_restaurant = {$this->id_restaurant}" );
if( $overrides->count() ){
foreach( $overrides as $override ){
$type = $override->type;
$date_start = new DateTime( $override->date_start, new DateTimeZone( $this->timezone ) );
$date_end = new DateTime( $override->date_end, new DateTimeZone( $this->timezone ) );
$date_start->setTimezone( new DateTimeZone('GMT' ) );
$date_end->setTimezone( new DateTimeZone('GMT' ) );
foreach ( $hours as $weekday => $hour ) {
$time_close = new DateTime( $hour->time_close, new DateTimeZone( $this->timezone ) );
// if it is the same weekday
if( $date_start->format( 'D' ) == $time_open->format( 'D' ) ){
if( $type == Crunchbutton_Restaurant_Hour_Override::TYPE_CLOSED ){
if( $date_start->format( 'His' ) > $time_open->format( 'His' ) ){
$hour->time_open = $time_open->format( 'Y-m-d' ) . ' ' . $date_start->format( 'H:i' );
}
$hour->time_close = $date_end->format( 'Y-m-d H:i' );
}
}
$interval = date_diff( $datetime1, $datetime2 );
/*if( $date_end->format( 'D' ) == $time_close->format( 'D' ) ){
if( $type == Crunchbutton_Restaurant_Hour_Override::TYPE_CLOSED ){
if( $date_end->format( 'His' ) < $time_close->format( 'His' ) ){
$hour->time_close = $time_close->format( 'Y-m-d' ) . ' ' . $date_end->format( 'H:i' );
}
}
}
}
if( count( $hours ) == 0 ){
return $hours;
}
$weekdays = [ 'mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun' ];
// Convert to hours starting at monday
$hoursStartFinish = [];
foreach( $hours as $day => $segments ){
$dayshours = array_search( $day, $weekdays ) * 2400;
foreach( $segments as $times ){
preg_match( '/(\d+):(\d+)/', $times[ 0 ], $hour_open );
preg_match( '/(\d+):(\d+)/', $times[ 1 ], $hour_close );
$hour_open = ( $dayshours + intval( $hour_open[ 1 ] ) * 100 ) + intval( $hour_open[ 2 ] );
$hour_close = ( $dayshours + intval( $hour_close[ 1 ] ) * 100 ) + intval( $hour_close[ 2 ] );
$hoursStartFinish[] = [ 'open' => $hour_open, 'close' => $hour_close ];
}
}
*/
return $hours;
$monday = date('Y-m-d', strtotime('monday this week') );
$sunday = date('Y-m-d', strtotime('sunday this week') );
$overrides = Crunchbutton_Restaurant_Hour_Override::q( "SELECT * FROM restaurant_hour_override
WHERE id_restaurant = {$this->id_restaurant}
AND
( DATE_FORMAT( date_start, '%Y-%m-%d' ) >= '{$monday}' AND DATE_FORMAT( date_start, '%Y-%m-%d' ) <= '{$sunday}' )
OR
( DATE_FORMAT( date_start, '%Y-%m-%d' ) < '{$monday}' AND DATE_FORMAT( date_end, '%Y-%m-%d' ) > '{$monday}' ) " );
$hoursStartFinishOverrideClose = [];
if( $overrides->count() ){
foreach( $overrides as $override ){
$monday = new DateTime( date('Y-m-d H:i:s', strtotime('monday this week') ), new DateTimeZone( $this->timezone ) );
$date_start = new DateTime( $override->date_start, new DateTimeZone( $this->timezone ) );
// Limit the override to this week
if( $date_start < $monday ){
$date_start = $monday;
}
$dayshours = array_search( strtolower( $date_start->format( 'D' ) ), $weekdays ) * 2400;
$hour_open = ( $dayshours + intval( $date_start->format( 'H' ) ) * 100 ) + intval( $date_start->format( 'i' ) );
$sunday = new DateTime( date('Y-m-d H:i:s', strtotime('sunday this week') ), new DateTimeZone( $this->timezone ) );
$sunday->setTime( 23, 59 );
$date_end = new DateTime( $override->date_end, new DateTimeZone( $this->timezone ) );
// Limit the override to this week
if( $date_end > $sunday ){
$date_end = $sunday;
}
$dayshours = array_search( strtolower( $date_end->format( 'D' ) ), $weekdays ) * 2400;
$hour_close = ( $dayshours + intval( $date_end->format( 'H' ) ) * 100 ) + intval( $date_end->format( 'i' ) );
if( $override->type == Crunchbutton_Restaurant_Hour_Override::TYPE_CLOSED ){
$hoursStartFinishOverrideClose[] = [ 'start' => $hour_open, 'end' => $hour_close ];
} else if( $override->type == 'open' ){
// Merge the override open hours at the open/close array
$hoursStartFinish[] = [ 'open' => $hour_open, 'close' => $hour_close ];
}
}
}
$hoursStartFinish = Cana_Util::sort_col( $hoursStartFinish, 'open' );
// Merge the hours
foreach( $hoursStartFinish as $key => $val ){
$getNext = false;
foreach( $hoursStartFinish as $keyNext => $valNext ){
if( $getNext ){
if( $hoursStartFinish[ $keyNext ][ 'open' ] <= $hoursStartFinish[ $key ][ 'close' ]
&& $hoursStartFinish[ $keyNext ][ 'close' ] - $hoursStartFinish[ $key ][ 'open' ] < 3600 ) {
$hoursStartFinish[ $key ][ 'close' ] = $hoursStartFinish[ $keyNext ][ 'close' ];
unset( $hoursStartFinish[ $keyNext ] );
$getNext = false;
}
}
if( $key == $keyNext ){
$getNext = true;
}
}
}
foreach( $hoursStartFinishOverrideClose as $keyClose => $valClose ){
foreach( $hoursStartFinish as $keyOpen => $valOpen ){
// the close override is between a segment
if( $hoursStartFinishOverrideClose[ $keyClose ][ 'start' ] >= $hoursStartFinish[ $keyOpen ][ 'open' ]
&& $hoursStartFinishOverrideClose[ $keyClose ][ 'end' ] < $hoursStartFinish[ $keyOpen ][ 'close' ] ){
$hoursStartFinish[] = [ 'open' => $hoursStartFinishOverrideClose[ $keyClose ][ 'end' ], 'close' => $hoursStartFinish[ $keyOpen ][ 'close' ] ];
$hoursStartFinish[ $keyOpen ][ 'close' ] = $hoursStartFinishOverrideClose[ $keyClose ][ 'start' ];
} else
// the close override start after the segment but ends before it
if( $hoursStartFinishOverrideClose[ $keyClose ][ 'start' ] <= $hoursStartFinish[ $keyOpen ][ 'open' ]
&& $hoursStartFinishOverrideClose[ $keyClose ][ 'end' ] > $hoursStartFinish[ $keyOpen ][ 'open' ]
&& $hoursStartFinishOverrideClose[ $keyClose ][ 'end' ] > $hoursStartFinish[ $keyOpen ][ 'close' ] ){
unset( $hoursStartFinish[ $keyOpen ] );
} else
if( $hoursStartFinishOverrideClose[ $keyClose ][ 'start' ] <= $hoursStartFinish[ $keyOpen ][ 'open' ]
&& $hoursStartFinishOverrideClose[ $keyClose ][ 'end' ] > $hoursStartFinish[ $keyOpen ][ 'open' ] ){
$hoursStartFinish[ $keyOpen ][ 'open' ] = $hoursStartFinishOverrideClose[ $keyClose ][ 'end' ];
}
}
}
$hoursStartFinish = Cana_Util::sort_col( $hoursStartFinish, 'open' );
foreach( $hoursStartFinish as $key => $val ){
$getNext = false;
foreach( $hoursStartFinish as $keyNext => $valNext ){
if( $getNext ){
if( $hoursStartFinish[ $keyNext ][ 'open' ] <= $hoursStartFinish[ $key ][ 'close' ]
&& $hoursStartFinish[ $keyNext ][ 'close' ] - $hoursStartFinish[ $key ][ 'open' ] < 3600 ) {
$hoursStartFinish[ $key ][ 'close' ] = $hoursStartFinish[ $keyNext ][ 'close' ];
unset( $hoursStartFinish[ $keyNext ] );
$getNext = false;
}
}
if( $key == $keyNext ){
$getNext = true;
}
}
}
$_hours = [];
foreach( $hoursStartFinish as $key => $val ){
$open = $hoursStartFinish[ $key ][ 'open' ];
$close = $hoursStartFinish[ $key ][ 'close' ];
$weekday = $weekdays[ floor( $open / 2400 ) ];
while( $open >= 2400 ) {
$open -= 2400;
$close -= 2400;
}
if( !$hours[ $weekday ] ){
$hours[ $weekday ] = [];
}
$_hours[ $weekday ][] = array( Cana_Util::format_time( $open ), Cana_Util::format_time( $close ) );
}
return $_hours;
}
/**
* Imports an array with all the information for a Restaurant.
*

View File

@ -41,13 +41,10 @@ class Crunchbutton_Restaurant_Hour_Override extends Cana_Table {
$restaurant = Restaurant::o( $id_restaurant );
$today = new DateTime( 'now', new DateTimeZone( $restaurant->timezone ) );
$today_mysql = $today->format('Y-m-d H:i');
$overrides = Crunchbutton_Restaurant_Hour_Override::q( "SELECT * FROM restaurant_hour_override WHERE date_start <= '{$today_mysql}' and date_end >= '{$today_mysql}'" );
$type_closed = Crunchbutton_Restaurant_Hour_Override::TYPE_CLOSED;
$overrides = Crunchbutton_Restaurant_Hour_Override::q( "SELECT * FROM restaurant_hour_override WHERE date_start <= '{$today_mysql}' and date_end >= '{$today_mysql}' AND type = '{$type_closed}' LIMIT 1" );
if( $overrides->count() > 0 ){
foreach( $overrides as $override ){
if( $override->type == Crunchbutton_Restaurant_Hour_Override::TYPE_CLOSED ){
return true;
}
}
return true;
}
return false;
}
@ -56,13 +53,10 @@ class Crunchbutton_Restaurant_Hour_Override extends Cana_Table {
$restaurant = Restaurant::o( $id_restaurant );
$today = new DateTime( 'now', new DateTimeZone( $restaurant->timezone ) );
$today_mysql = $today->format('Y-m-d H:i');
$overrides = Crunchbutton_Restaurant_Hour_Override::q( "SELECT * FROM restaurant_hour_override WHERE date_start <= '{$today_mysql}' and date_end >= '{$today_mysql}'" );
$type_opened = Crunchbutton_Restaurant_Hour_Override::TYPE_OPENED;
$overrides = Crunchbutton_Restaurant_Hour_Override::q( "SELECT * FROM restaurant_hour_override WHERE date_start <= '{$today_mysql}' and date_end >= '{$today_mysql}' AND type = '{$type_opened}' LIMIT 1" );
if( $overrides->count() > 0 ){
foreach( $overrides as $override ){
if( $override->type == Crunchbutton_Restaurant_Hour_Override::TYPE_OPENED ){
return true;
}
}
return true;
}
return false;
}

View File

@ -8,12 +8,14 @@ $timezone = new DateTimeZone( $restaurant->timezone );
$date_start = new DateTime( 'now ', $timezone );
$hour_override_date_start = $date_start->format( 'm/d/Y' );
$hour_override_date_start_hour = $date_start->format( 'H:i' );
$hour_override_date_start_hour = $date_start->format( 'h:i' );
$hour_override_date_start_ampm = $date_start->format( 'A' );
$date_end = $restaurant->next_open_time();
if( $date_end ){
$hour_override_date_end = $date_end->format( 'm/d/Y' );
$hour_override_date_end_hour = $date_end->format( 'H:i' );
$hour_override_date_end_hour = $date_end->format( 'h:i' );
$hour_override_date_end_ampm = $date_end->format( 'A' );
}
?>
<div class="row-fluid">
@ -26,33 +28,45 @@ if( $date_end ){
<form id="restaurant-bank-info" onsubmit="return false;">
<div class="row-fluid">
<div class="span12">
<div class="span4">
<div class="span3">
<strong>Start at:</strong>
</div>
<div class="span3">
<input type="text" value="<?php echo $hour_override_date_start; ?>" class="datepicker span12" id="hour_override_date_start" name="hour_override_date_start">
<input type="text" value="<?php echo $hour_override_date_start; ?>" class=" span12" id="hour_override_date_start" name="hour_override_date_start">
</div>
<div class="span2">
<div class="span1">
Hour:
</div>
<div class="span3">
<input type="text" value="<?php echo $hour_override_date_start_hour; ?>" name="hour_override_date_start_hour" id="hour_override_date_start_hour" class="span8">
<div class="span2">
<input type="text" value="<?php echo $hour_override_date_start_hour; ?>" name="hour_override_date_start_hour" id="hour_override_date_start_hour" class="span10">
</div>
<div class="span2">
<select class="span10" name="hour_override_date_start_ampm" id="hour_override_date_start_ampm">
<option <?php if( $hour_override_date_start_ampm == 'AM' ){ echo 'selected="selected"'; } ?> value="AM">AM</option>
<option <?php if( $hour_override_date_start_ampm == 'PM' ){ echo 'selected="selected"'; } ?> value="PM">PM</option>
</select>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<div class="span4">
<div class="span3">
<strong>Finish at:</strong>
</div>
<div class="span3">
<input type="text" value="<?php echo $hour_override_date_end; ?>" class="datepicker span12" id="hour_override_date_end" name="hour_override_date_end">
<input type="text" value="<?php echo $hour_override_date_end; ?>" class=" span12" id="hour_override_date_end" name="hour_override_date_end">
</div>
<div class="span2">
<div class="span1">
Hour:
</div>
<div class="span3">
<input type="text" value="<?php echo $hour_override_date_end_hour; ?>" name="hour_override_date_end_hour" id="hour_override_date_end_hour" class="span8">
<div class="span2">
<input type="text" value="<?php echo $hour_override_date_end_hour; ?>" name="hour_override_date_end_hour" id="hour_override_date_end_hour" class="span10">
</div>
<div class="span2">
<select class="span10" name="hour_override_date_end_ampm" id="hour_override_date_end_ampm">
<option <?php if( $hour_override_date_end_ampm == 'AM' ){ echo 'selected="selected"'; } ?> value="AM">AM</option>
<option <?php if( $hour_override_date_end_ampm == 'PM' ){ echo 'selected="selected"'; } ?> value="PM">PM</option>
</select>
</div>
</div>
</div>
@ -123,12 +137,12 @@ if( $date_end ){
?>
<tr>
<td nowrap="nowrap">
<?php echo $hour->date_start()->format('M jS Y'); ?>
<?php echo $hour->date_start()->format('M jS Y - D'); ?>
<br/>
<?php echo $hour->date_start()->format('g:i:s A'); ?>
</td>
<td nowrap="nowrap">
<?php echo $hour->date_end()->format('M jS Y'); ?>
<?php echo $hour->date_end()->format('M jS Y - D'); ?>
<br/>
<?php echo $hour->date_end()->format('g:i:s A'); ?>
</td>

View File

@ -1,4 +1,6 @@
<?
$this->restaurant->exports();
$this->title = 'TESTS';
$this->titleicon = 'food';
?>
@ -38,11 +40,15 @@
</div>
</div>
<div class="box">
<div class="box-content padded">
<?=$this->restaurant->name?> is <b><?=$this->open ? 'OPEN' : 'CLOSED'?></b> <?=$this->now ? 'now' : 'at '.$this->time->format('Y-m-d H:i:s')?>
<br/>
<strong>Curent time: </strong><?php
$today = new DateTime( 'now', new DateTimeZone( $this->restaurant->timezone ) );
echo $today->format(' M jS Y g:i:s A - D ');
echo ' (' . $this->restaurant->timezone . ')';
?>
</div>
</div>
@ -50,30 +56,24 @@
<div class="box">
<div class="box-content padded">
<strong>Closed message:</strong>
<br/><br/>
<br/>
<div id="closedMessage"></div>
<br/><br/>
<strong>Close in:</strong> <span id="closesIn"></span>
<br/>
<strong>Open in:</strong> <span id="openIn"></span>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="/assets/js/base.js"></script>
<script type="text/javascript" src="/assets/js/restaurant.js"></script>
<script type="text/javascript" src="/assets/js/date.js"></script>
<script>
/* override Orm.load method we dont need it right now */
var Orm = { load : function(){} };
<?php
$utc_str = gmdate( 'Y/n/d/H/i/s', time() );
$utc = strtotime( $utc_str );
?>
var _gmtServer = '<?php echo $utc_str;?>';
$(document).ready(function() {
var go = function() {
var loc = '/tests/hours?r=' + $('.test-restaurant option:selected').val() + '&t=' + $('.test-time').val();
location.href = loc;
@ -81,12 +81,10 @@ $(document).ready(function() {
$('.chosen-select').select2();
$('.test-restaurant').change(go);
$('.test-calculate').click(go);
var restaurant = new Restaurant();
$.extend( restaurant, <?php echo json_encode( $this->restaurant->exports() ); ?>);
$.extend( restaurant, <?php echo json_encode( $this->restaurant->export_force_override_hours() ); ?>);
$( '#closedMessage' ).html( restaurant.closedMessage() );
console.log('restaurant.open()',restaurant.open());
$( '#closesIn' ).html( ( restaurant._closesIn ? restaurant._closesIn + ' minutes' : 'it is closed!' ) );
$( '#openIn' ).html( ( restaurant._openIn ? restaurant._openIn + ' minutes' : 'it is opened!' ) );
});
</script>
<script type="text/javascript" src="/assets/js/datetime.js"></script>
</script>

View File

@ -1591,13 +1591,14 @@ hour_override.remove = function( id_restaurant_hour_override ){
});
}
hour_override.save = function(){
var date_start = $( '#hour_override_date_start' ).val();
var date_start_hour = $( '#hour_override_date_start_hour' ).val();
var hour_override_date_start_ampm = $( '#hour_override_date_start_ampm' ).val();
var date_end = $( '#hour_override_date_end' ).val();
var date_end_hour = $( '#hour_override_date_end_hour' ).val();
var hour_override_date_end_ampm = $( '#hour_override_date_end_ampm' ).val();
var type = $( '#hour_override_type' ).val();
var notes = $( '#hour_override_notes' ).val();
@ -1623,8 +1624,10 @@ hour_override.save = function(){
'id_restaurant' : _id_restaurant,
'date_start' : date_start,
'date_start_hour' : date_start_hour,
'hour_override_date_start_ampm' : hour_override_date_start_ampm,
'date_end' : date_end,
'date_end_hour' : date_end_hour,
'hour_override_date_end_ampm' : hour_override_date_end_ampm,
'type' : type,
'notes' : notes
}