restaurant order placement: new order #3350
This commit is contained in:
parent
0bd12301cb
commit
2c8ae1c2fa
@ -9,12 +9,12 @@ class Controller_api_order extends Crunchbutton_Controller_RestAccount {
|
||||
case 'get':
|
||||
switch ( c::getPagePiece( 2 ) ) {
|
||||
|
||||
case 'list':
|
||||
case 'restaurant-list-last':
|
||||
|
||||
$restaurant = Admin::restaurantOrderPlacement();
|
||||
if( $restaurant->id_restaurant ){
|
||||
$out = [];
|
||||
$orders = Order::q( 'SELECT * FROM `order` WHERE id_restaurant = "' . $restaurant->id_restaurant . '" ORDER BY id_order DESC LIMIT 20' );
|
||||
$orders = Order::q( 'SELECT * FROM `order` o WHERE id_restaurant = "' . $restaurant->id_restaurant . '" AND o.date BETWEEN CURDATE() - INTERVAL 7 DAY AND CURDATE() ORDER BY id_order DESC' );
|
||||
foreach( $orders as $order ) {
|
||||
$out[] = array( 'id_order' => $order->id_order,
|
||||
'lastStatus' => $order->deliveryLastStatus(),
|
||||
|
@ -18,16 +18,15 @@
|
||||
|
||||
<div ng-if="orders.length">
|
||||
|
||||
<h3 class="title">Showing last {{orders.length}} orders.</h3>
|
||||
<h3 class="title">Showing orders from last 7 days. Total {{orders.length}} orders. </h3>
|
||||
|
||||
<table class="tb-grid">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>#</td>
|
||||
<td class="td-medium">Name</td>
|
||||
<td class="td-medium">Phone</td>
|
||||
<td class="td-medium">Customer</td>
|
||||
<td>Date</td>
|
||||
<td>Driver / Status</td>
|
||||
<td class="td-medium">Driver / Status</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -36,10 +35,7 @@
|
||||
{{order.id_order}}
|
||||
</td>
|
||||
<td>
|
||||
{{order.name}}
|
||||
</td>
|
||||
<td>
|
||||
{{order.phone}}
|
||||
{{order.name}} / {{order.phone}}
|
||||
</td>
|
||||
<td>
|
||||
{{order.date}}
|
||||
|
@ -81,29 +81,12 @@
|
||||
|
||||
<li class="li-input" ng-class="{'error':form.orderSubtotal.$invalid}">
|
||||
<div class="label">Subtotal:</div>
|
||||
<div class="input"><input type="number" name="orderSubtotal" ng-model="order.subtotal" required placeholder="0.00"></div>
|
||||
<div class="input"><input type="number" ignore-mouse-wheel name="orderSubtotal" ng-model="order.subtotal" required placeholder="0.00"></div>
|
||||
<div class="box-error">
|
||||
<small ng-show="form.orderSubtotal.$error.required">Required.</small>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="li-input">
|
||||
<div class="label">Tip Type</div>
|
||||
<div class="input">
|
||||
<div class="box-filter">
|
||||
<button class="button green" ng-class="{ 'inactive': order.tip_type == 'percent' }" ng-click="order.tip_type = 'dollar'">$</button>
|
||||
<button class="button green" ng-class="{ 'inactive': order.tip_type == 'dollar' }" ng-click="order.tip_type = 'percent'">%</button>
|
||||
<div class="divider"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input" ng-show="order.tip_type == 'dollar'">
|
||||
<input type="number" name="orderTip" ng-model="order.tip" placeholder="0.00">
|
||||
</div>
|
||||
<div class="input" ng-show="order.tip_type == 'percent'">
|
||||
<select ng-model="order.tip" name="orderTip" ng-options="tip.value as tip.label for tip in tip._percents"></select>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="li-input">
|
||||
<div class="label">Payment Type</div>
|
||||
<div class="input">
|
||||
@ -126,12 +109,29 @@
|
||||
<li class="li-input" ng-class="{'error':form.cardMonth.$invalid, 'error':form.cardYear.$invalid}" ng-show="order.pay_type=='card'">
|
||||
<div class="label">Card Expiration</div>
|
||||
<div class="input">
|
||||
<select ng-model="card.month" ng-required="order.pay_type=='card'" name="cardMonth" ng-options="month.value as month.label for month in card._months"></select>
|
||||
<select ng-model="card.year" ng-required="order.pay_type=='card'" name="cardYear" ng-options="year.value as year.label for year in card._years"></select>
|
||||
<select ng-model="card.month" is-bigger-than-zero="{{order.pay_type=='card'}}" ng-required="order.pay_type=='card'" name="cardMonth" ng-options="month.value as month.label for month in card._months"></select>
|
||||
<select ng-model="card.year" is-bigger-than-zero="{{order.pay_type=='card'}}" ng-required="order.pay_type=='card'" name="cardYear" ng-options="year.value as year.label for year in card._years"></select>
|
||||
</div>
|
||||
<div class="box-error">
|
||||
<small ng-show="form.cardMonth.$error.required">Card month is required.</small>
|
||||
<small ng-show="form.cardYear.$error.required">Card year is required.</small>
|
||||
<small ng-show="form.cardMonth.$error.required || form.cardMonth.$error.isBiggerThanZero">Card month is required.</small>
|
||||
<small ng-show="form.cardYear.$error.required || form.cardYear.$error.isBiggerThanZero">Card year is required.</small>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="li-input" ng-show="order.pay_type=='card'">
|
||||
<div class="label">Tip Type</div>
|
||||
<div class="input">
|
||||
<div class="box-filter">
|
||||
<button class="button green" ng-class="{ 'inactive': order.tip_type == 'percent' }" ng-click="order.tip_type = 'dollar'">$</button>
|
||||
<button class="button green" ng-class="{ 'inactive': order.tip_type == 'dollar' }" ng-click="order.tip_type = 'percent'">%</button>
|
||||
<div class="divider"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input" ng-show="order.tip_type == 'dollar'">
|
||||
<input type="number" ignore-mouse-wheel name="orderTip" ng-model="order.tip" placeholder="0.00">
|
||||
</div>
|
||||
<div class="input" ng-show="order.tip_type == 'percent'">
|
||||
<select ng-model="order.tip" name="orderTip" ng-options="tip.value as tip.label for tip in tip._percents"></select>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@ -139,7 +139,7 @@
|
||||
<div class="final-amount">
|
||||
<div class="final-amount-padding">
|
||||
<sup>$</sup><span class="total">{{finalAmount}}</span>
|
||||
<span class="description">Total Price</span>
|
||||
<span class="description">Customer's Total Price</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
@ -15,12 +15,6 @@
|
||||
|
||||
<div class="content box-content" ng-show="order.id_order">
|
||||
<div class="wrap">
|
||||
<div class="status"></div>
|
||||
<div class="header">
|
||||
<div class="restaurant-name">{{order._restaurant_name}}</div>
|
||||
<div class="order-id">{{order.id_order}}</div>
|
||||
<div class="divider"></div>
|
||||
</div>
|
||||
<div class="order">
|
||||
<div class="order-item-block">
|
||||
<div class="order-icon">
|
||||
|
@ -31,7 +31,7 @@ NGApp.controller( 'RestaurantOrderNew', function ( $scope, RestaurantService, Re
|
||||
|
||||
$scope.order = { 'tip_type': 'dollar', 'pay_type': 'card' };
|
||||
$scope.tip = { 'dollar' : '', 'percent': '10' };
|
||||
$scope.card = {};
|
||||
$scope.card = { 'month': 0, 'year': 0 };
|
||||
$scope.map = {};
|
||||
|
||||
var start = function(){
|
||||
@ -105,9 +105,11 @@ NGApp.controller( 'RestaurantOrderNew', function ( $scope, RestaurantService, Re
|
||||
|
||||
$scope.processOrder = function(){
|
||||
if( $scope.form.$invalid ){
|
||||
App.alert( 'Please fill in all required fields' );
|
||||
$scope.submitted = true;
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.isProcessing = true;
|
||||
var order = angular.copy( $scope.order );
|
||||
if( $scope.order.tip_type == 'dollar' ){
|
||||
|
@ -39,7 +39,7 @@ NGApp.factory( 'RestaurantOrderService', function( $rootScope, $resource, $route
|
||||
var orders = $resource( App.service + 'order/:action', { action: '@action' }, {
|
||||
'process' : { 'method': 'POST' },
|
||||
'get' : { 'method': 'GET' },
|
||||
'list' : { 'method': 'GET' , params : { 'action' : 'list' }, isArray: true },
|
||||
'list' : { 'method': 'GET' , params : { 'action' : 'restaurant-list-last' }, isArray: true },
|
||||
}
|
||||
);
|
||||
|
||||
@ -142,7 +142,7 @@ NGApp.factory( 'RestaurantOrderService', function( $rootScope, $resource, $route
|
||||
|
||||
service.cardYears = function(){
|
||||
var years = [];
|
||||
years.push( { value: '', label: 'Year' } );
|
||||
years.push( { value: 0, label: 'Year' } );
|
||||
var date = new Date().getFullYear();
|
||||
for ( var x = date; x <= date + 20; x++ ) {
|
||||
years.push( { value: x.toString(), label: x.toString() } );
|
||||
@ -152,7 +152,7 @@ NGApp.factory( 'RestaurantOrderService', function( $rootScope, $resource, $route
|
||||
|
||||
service.cardMonths = function(){
|
||||
var months = [];
|
||||
months.push( { value: '', label: 'Month' } );
|
||||
months.push( { value: 0, label: 'Month' } );
|
||||
for ( var x = 1; x <= 12; x++ ) {
|
||||
months.push( { value: x.toString(), label: x.toString() } );
|
||||
}
|
||||
|
@ -513,6 +513,34 @@ NGApp.directive( 'phoneValidate', function () {
|
||||
};
|
||||
});
|
||||
|
||||
NGApp.directive('isBiggerThanZero', function() {
|
||||
return {
|
||||
restrict: 'A',
|
||||
require: 'ngModel',
|
||||
link: function(scope, elem, attrs, ngModel) {
|
||||
|
||||
// observe the other value and re-validate on change
|
||||
attrs.$observe( 'isBiggerThanZero', function () {
|
||||
validate();
|
||||
});
|
||||
|
||||
scope.$watch(attrs.ngModel, function() { validate(); } );
|
||||
|
||||
var validate = function() {
|
||||
var isValid = false;
|
||||
// if it is false it means it should not be validated
|
||||
if( attrs.isBiggerThanZero === 'true' || attrs.isBiggerThanZero === true ){
|
||||
if( parseInt( ngModel.$viewValue ) > 0 ){
|
||||
isValid = true;
|
||||
}
|
||||
} else {
|
||||
isValid = true;
|
||||
}
|
||||
ngModel.$setValidity('isBiggerThanZero', isValid );
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
NGApp.directive('equals', function() {
|
||||
return {
|
||||
@ -677,6 +705,17 @@ NGApp.directive('splashPositionFix', function() {
|
||||
}
|
||||
});
|
||||
|
||||
NGApp.directive( 'ignoreMouseWheel', function( $rootScope ) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function( scope, element, attrs ){
|
||||
element.bind('mousewheel', function ( event ) {
|
||||
element.blur();
|
||||
} );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
NGApp.directive( 'positiveOrNegativeColor', function( $rootScope ) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
|
Loading…
x
Reference in New Issue
Block a user