Skip to content

Commit

Permalink
#97: настроил логику изменения статусов аренды. пока нет проверки бал…
Browse files Browse the repository at this point in the history
…анса.
  • Loading branch information
kirzas committed Jul 23, 2015
1 parent 05e585c commit 804f48b
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 22 deletions.
7 changes: 7 additions & 0 deletions sources/client/app/controllers/cashier-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ export default ListController.extend({
this.transitionToRoute("rent.edit", rentId, {queryParams: {tab: "info"}});
}
},
gotoRentEdit: function(){
let selected = this.get("selectedRow");
let rentId = selected.get("rentId");
if (rentId != null) {
this.transitionToRoute("rent.edit", rentId, {queryParams: {tab: "general"}});
}
},
gotoCash: function(){
this.transitionToRoute("cash");
}
Expand Down
65 changes: 65 additions & 0 deletions sources/client/app/controllers/rent/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,30 @@ export default RentController.extend({
let a = moment.duration(minutes, 'minutes');
return Math.floor(a.asDays()) + ' дней ' + a.hours() + ' часов ' + a.minutes() + ' минут';
}.property('rentTotal.minutes'),
rentIsActive: function(){
if(this.get("status") === "Active"){
return 1;
}
return 0;
}.property("status"),
rentIsSuspended: function(){
if(this.get("status") === "Suspended"){
return 1;
}
return 0;
}.property("status"),
rentIsSettlingUp: function(){
if(this.get("status") === "SettlingUp"){
return 1;
}
return 0;
}.property("status"),
rentIsClosed: function(){
if(this.get("status") === "Closed"){
return 1;
}
return 0;
}.property("status"),
actions: {
showOperation: function(operation){
this.transitionToRoute('operations.edit', operation.operationId);
Expand All @@ -26,6 +50,47 @@ export default RentController.extend({
},
switchPanel: function(panel) {
this.set('panel', panel);
},
createRefund: function(){
this.transitionToRoute("refunds.new", this.get("id"));
},
createPaymentOperation: function(){
this.transitionToRoute("operations.new", this.get("rentId"),"payment");
},
createChargeOperation: function(){
this.transitionToRoute("operations.new", this.get("rentId"),"charge");
},
suspendRent:function(){
let rentId = this.get("id");
this.store.find("rent",rentId).then(rent => {
rent.set("status", "Suspended");
rent.save();
this.set("status", "Suspended");
});
},
settleUpRent:function(){
let rentId = this.get("id");
this.store.find("rent",rentId).then(rent => {
rent.set("status", "SettlingUp");
rent.save();
this.set("status", "SettlingUp");
});
},
closeRent:function(){
let rentId = this.get("id");
this.store.find("rent",rentId).then(rent => {
rent.set("status", "Closed");
rent.save();
this.set("status", "Closed");
});
},
resumeRent:function(){
let rentId = this.get("id");
this.store.find("rent",rentId).then(rent => {
rent.set("status", "Active");
rent.save();
this.set("status", "Active");
});
}
}
});
15 changes: 3 additions & 12 deletions sources/client/app/templates/cashier-list.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,12 @@
<button type="button" class="btn btn-primary" {{action "createChargeOperation"}} {{bind-attr disabled=selectionRentIsEmpty}}>
<i class="fa fa-taxi"></i> Создать списание
</button>
<button type="button" class="btn btn-primary" {{action "createRefund"}} {{bind-attr disabled=selectionRentIsEmpty}}>
<i class="fa fa-taxi"></i> Возврат денег
</button>
{{#if selectionRentIsSuspended}}
<button type="button" class="btn btn-primary" {{action "resumeRent"}}>
<i class="fa fa-taxi"></i> Возобновить аренду
</button>
{{else}}
<button type="button" class="btn btn-primary" {{action "suspendRent"}} {{bind-attr disabled=selectionRentIsNotActive}}>
<i class="fa fa-taxi"></i> Приостановить аренду
</button>
{{/if}}
<button type="button" class="btn btn-primary" {{action "gotoRentInfo"}} {{bind-attr disabled=selectionRentIsEmpty}}>
<i class="fa fa-rub"></i> Просмотр сводки по аренде
</button>
<button type="button" class="btn btn-primary" {{action "gotoRentEdit"}} {{bind-attr disabled=selectionRentIsEmpty}}>
<i class="fa fa-rub"></i> Управление арендой
</button>
<button type="button" class="btn btn-primary" {{action "gotoCash"}}>
<i class="fa fa-rub"></i> Касса
</button>
Expand Down
79 changes: 69 additions & 10 deletions sources/client/app/templates/rent/edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,9 @@
<div class="tab-content">
<div role="tabpanel" id="general" {{bind-attr class=":tab-pane isGeneral:active"}}>
<form class="form-horizontal">
{{#property-row title="Статус" errors=errors.status}}
{{ember-selectize
content=statuses
optionValuePath="content.id"
optionLabelPath="content.label"
selection=selectedStatus
placeholder="Выберите статус"
}}
{{/property-row}}
{{#property-row title="Статус" errors=errors.status}}
{{input value=displayStatus readonly="true"}}
{{/property-row}}
{{#property-row title="Водитель" errors=errors.driver}}
{{input value=driverDisplayName readonly="true"}}
{{/property-row}}
Expand Down Expand Up @@ -112,6 +106,71 @@

</div>
</div>
<div class="command-panel clearfix">
<div class="buttons btn-group pull-right" role="group">
{{#if rentIsActive}}
<button type="button" class="btn btn-primary" {{action "suspendRent"}} >
<i class="fa fa-taxi"></i> Приостановить
</button>
<button type="button" class="btn btn-primary" {{action "settleUpRent"}}>
<i class="fa fa-taxi"></i> Под расчет
</button>
<button type="button" class="btn btn-primary" {{action "createPaymentOperation"}} >
<i class="fa fa-rub"></i> Создать платеж
</button>
<button type="button" class="btn btn-primary" {{action "createChargeOperation"}}>
<i class="fa fa-taxi"></i> Создать списание
</button>
<button type="button" class="btn btn-primary" {{action "save"}} >
<i class="fa fa-floppy-o"></i> Сохранить
</button>
{{/if}}
{{#if rentIsSuspended}}
<button type="button" class="btn btn-primary" {{action "resumeRent"}}>
<i class="fa fa-taxi"></i> Возобновить
</button>
<button type="button" class="btn btn-primary" {{action "settleUpRent"}}>
<i class="fa fa-taxi"></i> Под расчет
</button>
<button type="button" class="btn btn-primary" {{action "createPaymentOperation"}} >
<i class="fa fa-rub"></i> Создать платеж
</button>
<button type="button" class="btn btn-primary" {{action "createChargeOperation"}}>
<i class="fa fa-taxi"></i> Создать списание
</button>
<button type="button" class="btn btn-primary" {{action "save"}} >
<i class="fa fa-floppy-o"></i> Сохранить
</button>
{{/if}}
{{#if rentIsSettlingUp}}
<button type="button" class="btn btn-primary" {{action "closeRent"}}>
<i class="fa fa-taxi"></i> Расчет
</button>
<button type="button" class="btn btn-primary" {{action "resumeRent"}}>
<i class="fa fa-taxi"></i> Возобновить
</button>
<button type="button" class="btn btn-primary" {{action "createRefund"}}>
<i class="fa fa-taxi"></i> Возврат денег
</button>
<button type="button" class="btn btn-primary" {{action "createPaymentOperation"}} >
<i class="fa fa-rub"></i> Создать платеж
</button>
<button type="button" class="btn btn-primary" {{action "createChargeOperation"}} >
<i class="fa fa-taxi"></i> Создать списание
</button>
<button type="button" class="btn btn-primary" {{action "save"}} >
<i class="fa fa-floppy-o"></i> Сохранить
</button>
{{/if}}
{{#if rentIsClosed}}
<button type="button" class="btn btn-primary" {{action "settleUpRent"}}>
<i class="fa fa-taxi"></i> Под расчет
</button>
{{/if}}
<button type="button" class="btn btn-default" {{action "cancel"}}>
<i class="fa fa-times"></i> Отмена
</button>
</div>
</div>

{{save-cancel}}
</div>

0 comments on commit 804f48b

Please sign in to comment.