diff --git a/include/controllers/default/cockpit2/api/order/index.php b/include/controllers/default/cockpit2/api/order/index.php
index 8f39e9663..a821080df 100644
--- a/include/controllers/default/cockpit2/api/order/index.php
+++ b/include/controllers/default/cockpit2/api/order/index.php
@@ -12,11 +12,6 @@ class Controller_api_order extends Crunchbutton_Controller_RestAccount {
$_POST = [
- 'name' => 'MR TEST DEVIN',
- 'subtotal' => '11.50',
- 'tip' => '2.00',
- 'phone' => '_PHONE_',
- 'address' => '123 main santa monica',
'card' => [
'id' => 'CC1yW7tINe5OHE77eplt5hPs',
'uri' => '/cards/CC1yW7tINe5OHE77eplt5hPs',
@@ -27,9 +22,10 @@ class Controller_api_order extends Crunchbutton_Controller_RestAccount {
],
'pay_type' => 'card',
'delivery_type' => 'delivery',
- 'restaurant' => '26',
- 'notes' => 'test'
];
+
+ // @todo check to see if the restaurant has the permissions for that restaurant id
+ // $_POST['restaurant']
switch ($this->method()) {
@@ -54,11 +50,10 @@ class Controller_api_order extends Crunchbutton_Controller_RestAccount {
$charge = $order->process($_POST, 'restaurant');
if ($charge === true) {
echo json_encode([
- 'id_user' => c::auth()->session()->id_user,
- 'txn' => $order->txn,
+ 'id_order' => $order->id_order,
+ 'id_user' => $order->user()->id_user,
'final_price' => $order->final_price,
- 'uuid' => (new Order($order->id_order))->uuid,
- 'token' => c::auth()->session()->token
+ 'uuid' => (new Order($order->id_order))->uuid
]);
} else {
echo json_encode(['status' => 'false', 'errors' => $charge]);
diff --git a/include/views/default/cockpit2/frontend/restaurant-order-new.phtml b/include/views/default/cockpit2/frontend/restaurant-order-new.phtml
index 5e8c1512a..e203aaada 100644
--- a/include/views/default/cockpit2/frontend/restaurant-order-new.phtml
+++ b/include/views/default/cockpit2/frontend/restaurant-order-new.phtml
@@ -4,77 +4,83 @@
New Order
+
- Please fill out all of the customer's information. Their name and phone number will be sent to the delivery drivers.
-
-
-
- -
-
Name
-
-
-
-
- Required.
- Name is too short. Name is required to be at least 5 characters.
- Name cannot be longer than 40 characters.
-
-
- -
-
Phone
-
-
-
-
- -
-
Address
-
-
-
-
- -
-
Notes
-
-
-
-
+
-
-
-
Subtotal
-
-
-
-
-
-
-
Tip
-
-
-
-
-
-
-
-
-
-
Card Number
-
-
-
-
-
-
-
-
-
Card Expiration
-
-
-
-
-
-
-
-
+
Please fill out all of the customer's information. Their name and phone number will be sent to the delivery drivers.
+
+
+
+
+
diff --git a/include/views/default/cockpit2/frontend/restaurant-order-view.phtml b/include/views/default/cockpit2/frontend/restaurant-order-view.phtml
new file mode 100644
index 000000000..05a2eeee1
--- /dev/null
+++ b/include/views/default/cockpit2/frontend/restaurant-order-view.phtml
@@ -0,0 +1,13 @@
+
+
+
+
+
Order Complete
+
+
+ Total {{order.final_price_plus_delivery_markup || order.final_price}}
+
+
+
+
+
diff --git a/www/assets/cockpit/js/cockpit.js b/www/assets/cockpit/js/cockpit.js
index 9e4330054..11dfdb6cf 100644
--- a/www/assets/cockpit/js/cockpit.js
+++ b/www/assets/cockpit/js/cockpit.js
@@ -84,6 +84,11 @@ NGApp.config(['$routeProvider', '$locationProvider', function($routeProvider, $l
controller: 'RestaurantOrderNew',
templateUrl: 'assets/view/restaurant-order-new.html'
})
+ .when('/restaurant/order/:id', {
+ action: 'restaurant-order',
+ controller: 'RestaurantOrderView',
+ templateUrl: 'assets/view/restaurant-order-view.html'
+ })
/* Settlement */
.when('/settlement', {
action: 'settlement',
diff --git a/www/assets/cockpit/js/controllers.restaurants.js b/www/assets/cockpit/js/controllers.restaurants.js
index 6b943e74c..7034f6f0d 100644
--- a/www/assets/cockpit/js/controllers.restaurants.js
+++ b/www/assets/cockpit/js/controllers.restaurants.js
@@ -1,23 +1,32 @@
-NGApp.controller('RestaurantOrderNew', function ($scope, $http) {
+NGApp.controller('RestaurantOrderView', function ($scope, $http, $routeParams) {
+ $http.get('/api/order/' + $routeParams.id).success(function(data){
+ $scope.order = data;
+ });
+});
+
+NGApp.controller('RestaurantOrderNew', function ($scope, $http, MainNavigationService, AccountService) {
$scope.isSubmitting = false;
$scope.order = {};
$scope.submit = function() {
$scope.isSubmitting = true;
-
-
-
-
-
+ $scope.order.restaurant = AccountService.restaurant;
+
$http({
method: 'POST',
url: '/api/order',
data: $scope.order,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(data) {
- console.log(data);
+ console.debug(data);
+
$scope.isSubmitting = false;
+ if (data.id_order) {
+ MainNavigationService.link('/restaurant/order/' + data.id_order);
+ } else {
+ alert(data.errors);
+ }
});
}
diff --git a/www/assets/cockpit/js/service.account.js b/www/assets/cockpit/js/service.account.js
index f4055e0fe..00313925b 100644
--- a/www/assets/cockpit/js/service.account.js
+++ b/www/assets/cockpit/js/service.account.js
@@ -15,7 +15,8 @@ NGApp.factory( 'AccountService', function($http, $rootScope, $resource) {
isRestaurant: false,
isDriver: false,
isSupport: false,
- isAdmin: false
+ isAdmin: false,
+ restaurants: []
};
service.isLoggedIn = function(){
@@ -51,25 +52,31 @@ NGApp.factory( 'AccountService', function($http, $rootScope, $resource) {
service.isRestaurant = service.isDriver = service.isSupport = service.isAdmin = false;
+ service.restaurants = [];
if (service.user.permissions.GLOBAL) {
service.isAdmin = true;
}
if (service.user.permissions.RESTAURANT) {
service.isRestaurant = true;
+
+ for (var x in service.user.permissions) {
+ if (x.indexOf('RESTAURANT-') == 0) {
+ service.restaurants.push(x.replace(/[^0-9]/g,''));
+ }
+ }
+
+ // only one restaurant for now
+ service.restaurant = service.restaurants[0];
}
+
for (var x in service.user.groups) {
if (service.user.groups[x].indexOf('drivers-') == 0) {
service.isDriver = true;
break;
}
}
- for (var x in service.user.groups) {
- if (service.user.groups[x].indexOf('restaurants-') == 0) {
- service.isRestaurant = true;
- break;
- }
- }
+
if (service.user && service.user.id_admin) {
App.snap.enable();