1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-20 14:54:15 +01:00

display summary after payment + ongoing clean template from references to machine

This commit is contained in:
Sylvain 2017-02-21 17:23:53 +01:00
parent 11619dc6c5
commit 4fa171da9d
3 changed files with 19 additions and 11 deletions

View File

@ -310,6 +310,7 @@ Application.Controllers.controller "ReserveMachineController", ["$scope", "$stat
reserved: []
modifiable: null
placable: null
paid: []
## total amount of the bill to pay
$scope.amountTotal = 0

View File

@ -210,6 +210,11 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs',
else
# slot is in the cart, remove it
$scope.removeSlot($scope.slot, index)
# in every cases, because a new reservation has started
# we reset the array of settled events, the selected plan and the coupon
$scope.events.paid = []
$scope.selectedPlan = null
$scope.coupon.applied = null
# finally, we update the prices
updateCartPrice()
else if !$scope.slot.is_reserved && $scope.events.modifiable
@ -430,6 +435,7 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs',
$scope.attempting = false
]
.result['finally'](null).then (reservation)->
$scope.events.paid = $scope.events.reserved
$scope.afterPayment(reservation) if typeof $scope.afterPayment == 'function'
@ -493,6 +499,7 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs',
$uibModalInstance.dismiss('cancel')
]
.result['finally'](null).then (reservation)->
$scope.events.paid = $scope.events.reserved
$scope.afterPayment(reservation) if typeof $scope.afterPayment == 'function'

View File

@ -3,7 +3,7 @@
<h3 translate>{{ 'summary' }}</h3>
</div>
<div class="widget-content no-bg auto wrapper" ng-show="events.reserved.length == 0 && (!paidMachineSlots || paidMachineSlots.length == 0)">
<div class="widget-content no-bg auto wrapper" ng-show="events.reserved.length == 0 && (!events.paid || events.paid.length == 0)">
<p class="font-felt fleche-left text-lg"><%= image_tag("fleche-left.png", class: 'fleche-left visible-lg') %>
{{ 'select_one_or_more_slots_in_the_calendar' | translate }}</p>
</div>
@ -12,28 +12,28 @@
<div class="font-sbold m-b-sm " translate>{{ 'you_ve_just_selected_the_slot' }}</div>
<div class="panel panel-default bg-light" ng-repeat="machineSlot in events.reserved">
<div class="panel panel-default bg-light" ng-repeat="slot in events.reserved">
<div class="panel-body">
<div class="font-sbold text-u-c">{{ 'datetime_to_time' | translate:{START_DATETIME:(machineSlot.start | amDateFormat:'LLLL'), END_TIME:(machineSlot.end | amDateFormat:'LT') } }}</div>
<div class="text-base">{{ 'cost_of_a_machine_hour' | translate }} <span ng-class="{'text-blue': !machineSlot.promo, 'red': machineSlot.promo}">{{machineSlot.price | currency}}</span></div>
<div class="font-sbold text-u-c">{{ 'datetime_to_time' | translate:{START_DATETIME:(slot.start | amDateFormat:'LLLL'), END_TIME:(slot.end | amDateFormat:'LT') } }}</div>
<div class="text-base">{{ 'cost_of_a_machine_hour' | translate }} <span ng-class="{'text-blue': !slot.promo, 'red': slot.promo}">{{slot.price | currency}}</span></div>
<div ng-show="currentUser.role == 'admin'" class="m-t">
<label for="offerSlot" class="control-label m-r" translate>{{ 'offer_this_slot' }}</label>
<input bs-switch
ng-model="machineSlot.offered"
ng-model="slot.offered"
id="offerSlot"
type="checkbox"
class="form-control"
switch-on-text="{{ 'yes' | translate}}"
switch-off-text="{{ 'no' | translate}}"
switch-animate="true"
switch-readonly="{{machineSlot.isValid}}"/>
switch-readonly="{{slot.isValid}}"/>
</div>
</div>
<div>
<button class="btn btn-valid btn-warning btn-block text-u-c r-b" ng-click="validateSlot(machineSlot)" ng-if="!machineSlot.isValid" translate>{{ 'confirm_this_slot' }}</button>
<button class="btn btn-valid btn-warning btn-block text-u-c r-b" ng-click="validateSlot(slot)" ng-if="!slot.isValid" translate>{{ 'confirm_this_slot' }}</button>
</div>
<div class="clear"><a class="pull-right m-b-sm text-u-l ng-scope m-r-sm" href="#" ng-click="removeSlot(machineSlot, $index, $event)" ng-if="machineSlot.isValid" translate>{{ 'remove_this_slot' }}</a></div>
<div class="clear"><a class="pull-right m-b-sm text-u-l ng-scope m-r-sm" href="#" ng-click="removeSlot(slot, $index, $event)" ng-if="slot.isValid" translate>{{ 'remove_this_slot' }}</a></div>
</div>
<coupon show="isSlotsValid() && (!modePlans || selectedPlan)" coupon="coupon.applied" total="totalNoCoupon" user-id="{{user.id}}"></coupon>
@ -62,12 +62,12 @@
<button class="btn btn-valid btn-info btn-block p-l btn-lg text-u-c r-b text-base" ng-click="payCart()" ng-if="isSlotsValid() && (!modePlans || selectedPlan)">{{ 'confirm_and_pay' | translate }} {{amountTotal | currency}}</button>
</div>
<div class="widget-content no-bg auto wrapper" ng-if="paidMachineSlots">
<div class="widget-content no-bg auto wrapper" ng-show="events.paid && events.paid.length > 0">
{{ 'you_have_settled_the_following_machine_hours' | translate }} <strong>{{machine.name}}</strong>:
<div class="well well-warning m-t-sm" ng-repeat="paidSlot in paidMachineSlots">
<div class="well well-warning m-t-sm" ng-repeat="paidSlot in events.paid">
<i class="font-sbold text-u-c">{{ 'datetime_to_time' | translate:{START_DATETIME:(paidSlot.start | amDateFormat:'LLLL'), END_TIME:(paidSlot.end | amDateFormat:'LT') } }}</i>
<div class="font-sbold">{{ 'cost_of_a_machine_hour' | translate }} {{paidSlot.machine.amount() | currency}}</div>
<div class="font-sbold">{{ 'cost_of_a_machine_hour' | translate }} {{paidSlot.price | currency}}</div>
</div>
<div ng-if="selectedPlan">