partial #7327
This commit is contained in:
parent
051b1fcedb
commit
d113fc03e2
@ -72,10 +72,18 @@ class Controller_api_restaurant_hours extends Crunchbutton_Controller_Rest {
|
||||
break;
|
||||
|
||||
case 'pre-order':
|
||||
// echo '<pre>';var_dump( $r->preOrderHours() );exit();
|
||||
echo json_encode( $r->preOrderHours() );
|
||||
break;
|
||||
|
||||
case 'gmt':
|
||||
$no_utc = ( c::getPagePiece( 4 ) != 'regular' );
|
||||
$hours = $r->hours_next_24_hours( $no_utc );
|
||||
if( !$hours ){ $hours = []; }
|
||||
$utc_str = gmdate( 'Y/n/d/H/i/s', time() );
|
||||
$hours = [ 'hours' => $hours, 'gmt' => $utc_str ];
|
||||
echo json_encode( $hours );exit;;
|
||||
break;
|
||||
|
||||
// export the hours for the next 24 hours
|
||||
default:
|
||||
$no_utc = ( c::getPagePiece( 4 ) != 'regular' );
|
||||
|
||||
@ -9,13 +9,23 @@ class Controller_api_restaurants extends Crunchbutton_Controller_Rest {
|
||||
$this->_hours();
|
||||
break;
|
||||
|
||||
case 'hours-gmt':
|
||||
$this->_hoursGMT();
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->_byRange();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function _hours(){
|
||||
private function _hoursGMT(){
|
||||
$utc_str = gmdate( 'Y/n/d/H/i/s', time() );
|
||||
$out = [ 'hours' => $this->_hours( true ), 'gmt' => $utc_str ];
|
||||
echo json_encode( $out );exit;
|
||||
}
|
||||
|
||||
private function _hours( $return = false ){
|
||||
$lat = $this->request()[ 'lat' ];
|
||||
$lon = $this->request()[ 'lon' ];
|
||||
$range = $this->request()[ 'range' ];
|
||||
@ -47,6 +57,9 @@ class Controller_api_restaurants extends Crunchbutton_Controller_Rest {
|
||||
$out[] = $restaurant->timeInfo();
|
||||
}
|
||||
}
|
||||
if( $return ){
|
||||
return $out;
|
||||
}
|
||||
echo json_encode( $out );exit;
|
||||
}
|
||||
|
||||
|
||||
@ -1050,7 +1050,6 @@ NGApp.controller( 'RestaurantCtrl', function ($scope, $http, $routeParams, $root
|
||||
// update if the restaurant is closed or open every 35 seconds
|
||||
var updateStatus = function(){
|
||||
updateRestaurantStatus = $timeout( function(){
|
||||
dateTime.reload();
|
||||
$scope.restaurant.open();
|
||||
$scope.restaurant.reloadHours( true, function(){
|
||||
var open = $scope.restaurant._open;
|
||||
@ -1593,7 +1592,7 @@ NGApp.controller('ProfileCtrl', function ($scope, $filter, AccountService ) {
|
||||
if (!App.phone.validate($scope.account.phone)) {
|
||||
errors['phone'] = 'Please enter a valid phone #.';
|
||||
}
|
||||
console.log('$scope.account.email',$scope.account.email);
|
||||
|
||||
if ( $scope.account.email && !/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test( $scope.account.email ) ){
|
||||
errors['email'] = 'Please enter a valid email.';
|
||||
}
|
||||
|
||||
@ -5,16 +5,32 @@ var dateTime = {
|
||||
};
|
||||
|
||||
dateTime.update = function(){
|
||||
if( _gmtServer ){
|
||||
if( _gmtServer && typeof _gmtServer == 'string' ){
|
||||
var time = _gmtServer.split( '/' );
|
||||
dateTime.now = new Date( Number(time[0]), Number(time[1]-1), Number(time[2]), Number(time[3]), Number(time[4]), ( Number(time[5]) + dateTime.timer ) ) ;
|
||||
dateTime.timer++;
|
||||
dateTime.gears = setTimeout( function(){ dateTime.update(); }, 1000 );
|
||||
if( time.length == 6 ){
|
||||
dateTime.now = new Date( Number(time[0]), Number(time[1]-1), Number(time[2]), Number(time[3]), Number(time[4]), ( Number(time[5]) + dateTime.timer ) ) ;
|
||||
dateTime.timer++;
|
||||
dateTime.gears = setTimeout( function(){ dateTime.update(); }, 1000 );
|
||||
} else {
|
||||
dateTime.reload();
|
||||
}
|
||||
} else {
|
||||
dateTime.reload();
|
||||
}
|
||||
}
|
||||
|
||||
dateTime.updateGMT = function( gmt ){
|
||||
if( gmt ){
|
||||
_gmtServer = gmt;
|
||||
dateTime.timer = 0;
|
||||
if( dateTime.gears ){
|
||||
clearTimeout( dateTime.gears );
|
||||
}
|
||||
dateTime.update();
|
||||
App.rootScope.$broadcast( 'appResume', false );
|
||||
}
|
||||
}
|
||||
|
||||
// This method will be called by phonegap at the 'resume' event
|
||||
dateTime.restart = function(){
|
||||
dateTime.timer = 0;
|
||||
@ -26,17 +42,17 @@ dateTime.restart = function(){
|
||||
// Update the gmt time based on server
|
||||
dateTime.reload = function(){
|
||||
var url = App.service + 'gmt';
|
||||
App.http.get( url, {
|
||||
cache: false
|
||||
} ).success( function ( json ) {
|
||||
_gmtServer = json.gmt;
|
||||
dateTime.timer = 0;
|
||||
if( dateTime.gears ){
|
||||
clearTimeout( dateTime.gears );
|
||||
}
|
||||
dateTime.update();
|
||||
App.rootScope.$broadcast( 'appResume', false );
|
||||
} ).error( function(){ window.location.reload(); } );
|
||||
if( App.http && App.http.get ){
|
||||
App.http.get( url, {
|
||||
cache: false
|
||||
} ).success( function ( json ) {
|
||||
dateTime.updateGMT( json.gmt )
|
||||
} ).error( function(){ window.location.reload(); } );
|
||||
} else {
|
||||
setTimeout( function(){
|
||||
dateTime.reload();
|
||||
}, 500 );
|
||||
}
|
||||
}
|
||||
|
||||
dateTime.toString = function(){
|
||||
|
||||
@ -331,12 +331,16 @@ var Restaurant = function(id) {
|
||||
if( self.loadingHours ){
|
||||
return;
|
||||
}
|
||||
dateTime.reload();
|
||||
self.loadingHours = true;
|
||||
var url = App.service + 'restaurant/hours/' + self.id_restaurant;
|
||||
var url = App.service + 'restaurant/hours/' + self.id_restaurant + '/gmt';
|
||||
App.http.get( url, {
|
||||
cache: false
|
||||
} ).success( function ( hours ) {
|
||||
var gmt = hours.gmt;
|
||||
var hours = hours.hours;
|
||||
if( gmt ){
|
||||
dateTime.updateGMT( gmt );
|
||||
}
|
||||
self.loadingHours = false;
|
||||
if( hours && hours.constructor === Array ){
|
||||
self.cachedAt = now;
|
||||
|
||||
@ -211,23 +211,27 @@ NGApp.factory('RestaurantsService', function ($http, $rootScope, PositionsServic
|
||||
}
|
||||
var url = null;
|
||||
if( service.position.pos().lat() && service.position.pos().lon() ){
|
||||
url = App.service + 'restaurants/hours/?lat=' + service.position.pos().lat() + '&lon=' + service.position.pos().lon() + '&range=' + (service.position.range || 2 );
|
||||
url = App.service + 'restaurants/hours-gmt/?lat=' + service.position.pos().lat() + '&lon=' + service.position.pos().lon() + '&range=' + (service.position.range || 2 );
|
||||
} else {
|
||||
var ids = [];
|
||||
for ( var x in restaurants ) {
|
||||
ids.push( restaurants[x].id_restaurant );
|
||||
}
|
||||
if( ids.length > 0 ){
|
||||
url = App.service + 'restaurants/hours/' + ids.join( ',' );
|
||||
url = App.service + 'restaurants/hours-gmt/' + ids.join( ',' );
|
||||
}
|
||||
|
||||
}
|
||||
dateTime.reload();
|
||||
if( url ){
|
||||
service.loadingHours = true;
|
||||
$http.get( url, {
|
||||
cache: false
|
||||
}).success(function ( hours ) {
|
||||
var gmt = hours.gmt;
|
||||
var hours = hours.hours;
|
||||
if( gmt ){
|
||||
dateTime.updateGMT( gmt );
|
||||
}
|
||||
var now = ( Math.floor( new Date().getTime() / 1000 ) );
|
||||
for( var x in hours ){
|
||||
for ( var y in restaurants ) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user