parent
e0cb64fee7
commit
5ad3f7a4c4
@ -5,10 +5,10 @@ class Controller_api_user_orders extends Crunchbutton_Controller_Rest {
|
||||
switch ($this->method()) {
|
||||
case 'get':
|
||||
$orders = c::user()->orders('compact');
|
||||
if( $orders->count() > 0 ){
|
||||
if ($orders->count() > 0) {
|
||||
echo $orders->json();
|
||||
} else {
|
||||
json_encode([]);
|
||||
//echo json_encode([]);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@ -61,6 +61,7 @@ class Crunchbutton_User extends Cana_Table {
|
||||
if (!$this->id_user) {
|
||||
return new Order;
|
||||
}
|
||||
|
||||
if (!isset($this->_orders)) {
|
||||
if ($type == 'compact') {
|
||||
$q = '
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
<span ng-switch-when="2">We listen to our users</span>
|
||||
<span class="small" ng-switch-when="3">Let us know <br>and we will add it!</span>
|
||||
<span class="single-line" ng-switch-when="4"><i class="fa fa-heart"></i> <i class="fa fa-heart"></i> <i class="fa fa-heart"></i></span>
|
||||
<span ng-switch-default><b>What's your favorite?</b></span>
|
||||
<span ng-switch-default><b>What's your<br>favorite?</b></span>
|
||||
</div>
|
||||
<div ng-show="recommend.greetings">
|
||||
<span class="small" ng-switch-when="1">We check this<br> stuff daily!</span>
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
</tr>
|
||||
</table>
|
||||
</li>
|
||||
<li ng-click="navigation.link('/food-delivery')" ng-show="account.user.id_user && account.user.name">
|
||||
<li ng-click="navigation.link('/food-delivery')" ng-show="account.user.id_user">
|
||||
<table cellpadding="0" cellspacing="0" class="side-menu-wrap">
|
||||
<tr>
|
||||
<td class="side-menu-icon"><i class="fa fa-cutlery"></i></td>
|
||||
@ -20,7 +20,7 @@
|
||||
</tr>
|
||||
</table>
|
||||
</li>
|
||||
<li ng-show="account.user.id_user" ng-click="navigation.link('/orders')">
|
||||
<li ng-show="account.user.id_user && account.user.name" ng-click="navigation.link('/orders')">
|
||||
<table cellpadding="0" cellspacing="0" class="side-menu-wrap">
|
||||
<tr>
|
||||
<td class="side-menu-icon"><i class="fa fa-truck"></i></td>
|
||||
@ -127,9 +127,11 @@
|
||||
<li><a href="/about" ng-click="navigation.link('/about')"><i class="fa fa-lightbulb-o"></i>About</a></li>
|
||||
<li><a ng-click="navigation.signin()" ng-show="!account.user.id_user"><i class="fa fa-sign-in"></i>Log In</a></li>
|
||||
<li><a ng-click="signout.do()" ng-show="account.user.id_user"><i class="fa fa-sign-out"></i>Log Out</a></li>
|
||||
<li class="dropdown-divider" ng-show="account.user.debug"></li>
|
||||
<li><a href="/download" ng-click="navigation.link('/download')"><i class="fa fa-mobile-phone"></i>Download for iPhone</a></li>
|
||||
|
||||
<li class="dropdown-divider"></li>
|
||||
<li><a href="/download" ng-click="navigation.link('/download')"><i class="fa fa-mobile-phone"></i>Download for iPhone</a></li>
|
||||
|
||||
<li class="dropdown-divider" ng-show="account.user.debug"></li>
|
||||
<li><a ng-click="App.test.card()" ng-show="account.user.debug"><i class="fa fa-circle-o"></i>TEST: card</a></li>
|
||||
<li><a ng-click="App.test.clearloc()" ng-show="account.user.debug"><i class="fa fa-circle-o"></i>TEST: clear location</a></li>
|
||||
<li><a ng-click="navigation.link('/')" ng-show="account.user.debug"><i class="fa fa-circle-o"></i>TEST: go home</a></li>
|
||||
|
||||
@ -242,7 +242,7 @@ NGApp.config(['$routeProvider', '$locationProvider', function($routeProvider, $l
|
||||
}]);
|
||||
|
||||
// global route change items
|
||||
NGApp.controller('AppController', function ($scope, $route, $routeParams, $rootScope, $location, $window, AccountService, MainNavigationService, AccountSignOut, CartService, ReferralService) {
|
||||
NGApp.controller('AppController', function ($scope, $route, $routeParams, $rootScope, $location, $window, AccountService, MainNavigationService, AccountSignOut, CartService, ReferralService, LocationService) {
|
||||
|
||||
// define external pointers
|
||||
App.rootScope = $rootScope;
|
||||
@ -295,8 +295,17 @@ NGApp.controller('AppController', function ($scope, $route, $routeParams, $rootS
|
||||
if( !App.config.user.id_user ){
|
||||
CartService.clean();
|
||||
}
|
||||
// reload the actual controller
|
||||
|
||||
LocationService.init(true);
|
||||
if (App.config.user.id_user) {
|
||||
$location.path('/food-delivery');
|
||||
}
|
||||
|
||||
App.snap.close();
|
||||
|
||||
console.log('userAuth!');
|
||||
|
||||
// reload the actual controller
|
||||
if( !AccountService.forceDontReloadAfterAuth ){
|
||||
$rootScope.reload();
|
||||
}
|
||||
@ -414,6 +423,8 @@ NGApp.controller('AppController', function ($scope, $route, $routeParams, $rootS
|
||||
});
|
||||
|
||||
AccountService.checkUser();
|
||||
|
||||
LocationService.init();
|
||||
|
||||
ReferralService.check();
|
||||
|
||||
|
||||
@ -75,16 +75,17 @@ NGApp.controller('HelpCtrl', function ($scope) {
|
||||
*/
|
||||
NGApp.controller('HomeCtrl', function ($scope, $http, $location, RestaurantsService, LocationService) {
|
||||
if (!App.isPhoneGap) {
|
||||
LocationService.init();
|
||||
// If it have a valid restaurant position just reditect to restaurants page
|
||||
if (LocationService.position.pos().valid('restaurants')) {
|
||||
$location.path('/' + RestaurantsService.permalink);
|
||||
} else {
|
||||
$location.path('/location');
|
||||
}
|
||||
} else {
|
||||
// @hack
|
||||
// just force the location to the food-delivery page. if we dont have a loc it sends us back to location anyway
|
||||
$location.path( '/' + RestaurantsService.permalink );
|
||||
$location.path('/' + RestaurantsService.permalink);
|
||||
}
|
||||
// If it have a valid restaurant position just reditect to restaurants page
|
||||
if( LocationService.position.pos().valid( 'restaurants' ) ){
|
||||
$location.path( '/' + RestaurantsService.permalink );
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -123,13 +124,13 @@ NGApp.controller('DefaultCtrl', function ($scope, $http, $location, CommunityAli
|
||||
NGApp.controller( 'RestaurantsCtrl', function ( $scope, $rootScope, $http, $location, $timeout, RestaurantsService, LocationService) {
|
||||
$scope.restaurants = false;
|
||||
|
||||
$scope.showMoreRestaurants = function(){
|
||||
$scope.showMoreRestaurants = function() {
|
||||
var step = 3;
|
||||
$scope.restaurantsToShow += step;
|
||||
}
|
||||
};
|
||||
|
||||
var location = LocationService;
|
||||
if( !location.initied ){
|
||||
if (!location.initied) {
|
||||
location.init();
|
||||
$location.path( '/' );
|
||||
return;
|
||||
|
||||
@ -57,10 +57,6 @@ NGApp.factory('OrderService', function ($http, $location, $rootScope, $filter, A
|
||||
|
||||
service.init = function () {
|
||||
|
||||
// If this variable is true the restaurant's page will be loaded after the location get started
|
||||
service.location.loadRestaurantsPage = false;
|
||||
service.location.init();
|
||||
|
||||
if (App.config.ab && App.config.ab.dollarSign == 'show') {
|
||||
service.info.dollarSign = '$';
|
||||
}
|
||||
|
||||
@ -156,11 +156,17 @@ NGApp.factory('LocationService', function ($location, $rootScope, RestaurantsSer
|
||||
* initilize location functions
|
||||
*/
|
||||
service.init = function () {
|
||||
// force refresh
|
||||
|
||||
var force = false;
|
||||
if (arguments[0]) {
|
||||
force = true;
|
||||
}
|
||||
|
||||
// this method could not be called twice
|
||||
if (service.initied){
|
||||
if (service.initied && !force) {
|
||||
return;
|
||||
}
|
||||
service.initied = true;
|
||||
|
||||
// 1) set bounding to maxmind results if we have them
|
||||
if (App.config.loc.lat && App.config.loc.lon) {
|
||||
@ -176,13 +182,6 @@ NGApp.factory('LocationService', function ($location, $rootScope, RestaurantsSer
|
||||
for (var x in cookieLocs) {
|
||||
service.position.addLocation(new Location(cookieLocs[x]._properties));
|
||||
}
|
||||
// If we have a valid coockie position redirect the user to restaurants page
|
||||
if ( ( $location.path() == '/' || $location.path() == '/location' ) && service.position.pos().valid( 'restaurants' ) ) {
|
||||
setTimeout( function(){ $location.path( '/' + RestaurantsService.permalink ); }, 1 );
|
||||
service.loadRestaurantsPage = false;
|
||||
}
|
||||
} else {
|
||||
$location.path( '/location' );
|
||||
}
|
||||
|
||||
if (cookieBounding) {
|
||||
@ -197,7 +196,21 @@ NGApp.factory('LocationService', function ($location, $rootScope, RestaurantsSer
|
||||
lon: service.account.user.location_lon,
|
||||
type: 'user'
|
||||
};
|
||||
|
||||
service.position.addLocation(new Location({
|
||||
lat: service.account.user.location_lat,
|
||||
lon: service.account.user.location_lon,
|
||||
type: 'user'
|
||||
}));
|
||||
|
||||
service.loadRestaurantsPage = true;
|
||||
}
|
||||
|
||||
if (service.initied) {
|
||||
return;
|
||||
}
|
||||
|
||||
service.initied = true;
|
||||
|
||||
// 4) get a more specific bounding location result from google
|
||||
if (App.isPhoneGap) {
|
||||
@ -235,9 +248,6 @@ NGApp.factory('LocationService', function ($location, $rootScope, RestaurantsSer
|
||||
service.restaurantsService.list(
|
||||
// Success
|
||||
function () {
|
||||
if (service.loadRestaurantsPage) {
|
||||
$location.path('/' +RestaurantsService.permalink);
|
||||
}
|
||||
service.loadRestaurantsPage = true;
|
||||
},
|
||||
// Error
|
||||
@ -267,30 +277,27 @@ NGApp.factory('LocationService', function ($location, $rootScope, RestaurantsSer
|
||||
|
||||
// 5) if there are location
|
||||
if( service.position.locs.length ){
|
||||
var loc = service.position.pos();
|
||||
service.reverseGeocode(loc.lat(), loc.lon(),
|
||||
var loc = service.position.pos();
|
||||
service.reverseGeocode(loc.lat(), loc.lon(),
|
||||
// Success
|
||||
function (loc) {
|
||||
service.bounding = {
|
||||
lat: loc.lat(),
|
||||
lon: loc.lon(),
|
||||
city: loc.city()
|
||||
};
|
||||
service.restaurantsService.list(
|
||||
// Success
|
||||
function (loc) {
|
||||
service.bounding = {
|
||||
lat: loc.lat(),
|
||||
lon: loc.lon(),
|
||||
city: loc.city()
|
||||
};
|
||||
service.restaurantsService.list(
|
||||
// Success
|
||||
function () {
|
||||
if (service.loadRestaurantsPage) {
|
||||
$location.path('/' +RestaurantsService.permalink);
|
||||
}
|
||||
service.loadRestaurantsPage = true;
|
||||
},
|
||||
// Error
|
||||
function () {
|
||||
$rootScope.$broadcast( 'locationNotServed', true );
|
||||
});
|
||||
function () {
|
||||
service.loadRestaurantsPage = true;
|
||||
},
|
||||
// Error
|
||||
function () {});
|
||||
function () {
|
||||
$rootScope.$broadcast( 'locationNotServed', true );
|
||||
});
|
||||
},
|
||||
// Error
|
||||
function () {});
|
||||
} else
|
||||
// 6) if there is no previously used locations of any kind
|
||||
if (!service.position.locs.length) {
|
||||
@ -304,9 +311,6 @@ NGApp.factory('LocationService', function ($location, $rootScope, RestaurantsSer
|
||||
service.position.addLocation(loc);
|
||||
service.restaurantsService.list(
|
||||
function () {
|
||||
if (service.loadRestaurantsPage) {
|
||||
$location.path('/' +RestaurantsService.permalink);
|
||||
}
|
||||
service.loadRestaurantsPage = true;
|
||||
},
|
||||
function () {
|
||||
|
||||
@ -79,6 +79,7 @@ NGApp.factory('RestaurantsService', function ($http, $rootScope, PositionsServic
|
||||
}
|
||||
|
||||
service.list = function (success, error) {
|
||||
|
||||
if (!service.position.pos().valid('restaurants')) {
|
||||
if (error) {
|
||||
error();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user