Skip to content

Commit d1260ab

Browse files
authored
Merge pull request #1094 from shreesh-webkul/gli-1993
Added: Admin can set voucher expiry along with voucher when managing refund request
2 parents 204258c + ac0de7b commit d1260ab

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed

modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php

+15-2
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ public function renderView()
245245
'isRefundCompleted' => $objOrderReturn->hasBeenCompleted(),
246246
'paymentMethods' => $paymentMethods,
247247
'name_controller' => Tools::getValue('controller'),
248-
'info_icon_path' => $this->context->link->getMediaLink(_MODULE_DIR_.'hotelreservationsystem/views/img/Slices/icon-info.svg')
248+
'info_icon_path' => $this->context->link->getMediaLink(_MODULE_DIR_.'hotelreservationsystem/views/img/Slices/icon-info.svg'),
249+
'expiry_date' => time() + (3600 * 24 * 365.25)
249250
)
250251
);
251252

@@ -325,6 +326,11 @@ public function postProcess()
325326
} else {
326327
$this->errors[] = $this->l('Invalid refund state.');
327328
}
329+
if (!$voucher_expiry_date = Tools::getValue('voucher_expiry_date')) {
330+
$this->errors[] = $this->l('Voucher expiry date is required.');
331+
} elseif (!Validate::isDate($voucher_expiry_date)) {
332+
$this->errors[] = $this->l('Invalid voucher expiry date.');
333+
}
328334
} else {
329335
$this->errors[] = $this->l('Invalid refund information found.');
330336
}
@@ -480,7 +486,12 @@ public function postProcess()
480486
$cartrule->id_customer = $objOrder->id_customer;
481487
$now = time();
482488
$cartrule->date_from = date('Y-m-d H:i:s', $now);
483-
$cartrule->date_to = date('Y-m-d H:i:s', $now + (3600 * 24 * 365.25)); /* 1 year */
489+
// generateDiscount
490+
if ($voucher_expiry_date) {
491+
$cartrule->date_to = date('Y-m-d H:i:s', strtotime($voucher_expiry_date));
492+
} else {
493+
$cartrule->date_to = date('Y-m-d H:i:s', $now + (3600 * 24 * 365.25)); /* 1 year */
494+
}
484495
$cartrule->active = 1;
485496
$cartrule->highlight = 1;
486497
$cartrule->reduction_amount = $totalRefundedAmount;
@@ -560,6 +571,8 @@ public function setMedia()
560571

561572
if ($this->display == 'view') {
562573
$this->addJqueryUI('ui.tooltip', 'base', true);
574+
$this->removeJS(Media::getJqueryUIPath('effects.core', 'base', false), false);
575+
563576
$this->addJs(_MODULE_DIR_.$this->module->name.'/views/js/admin/wk_refund_request.js');
564577
$this->addCSS(_MODULE_DIR_.$this->module->name.'/views/css/admin/wk_refund_request.css');
565578
}

modules/hotelreservationsystem/views/js/admin/wk_refund_request.js

+30
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ $(document).ready(function() {
2323
manageRefundOptions();
2424
}
2525

26+
$('#order_return_form').on('submit', function() {
27+
if ($("#id_refund_state option:selected").attr('refunded') == 1) {
28+
if ($('#generateDiscount:checked').length) {
29+
if ($('#voucher_expiry').val() == '') {
30+
$('#voucher_expiry').parent().addClass('has-error');
31+
return false;
32+
}
33+
}
34+
}
35+
});
36+
37+
$('#voucher_expiry').on('focus', function() {
38+
$('#voucher_expiry').parent().removeClass('has-error');
39+
});
40+
2641
// initialize tootip for room price
2742
if ($('#rooms_refund_info .price_info').length) {
2843
$('#rooms_refund_info .price_info').each(function (i, element) {
@@ -70,6 +85,21 @@ $(document).ready(function() {
7085
}
7186
});
7287

88+
$('#voucher_expiry').datepicker({
89+
dateFormat: 'dd-mm-yy',
90+
altFormat: 'yy-mm-dd',
91+
altField: '#voucher_expiry_date',
92+
minDate: 0,
93+
});
94+
95+
$(document).on('change', '#generateDiscount', function() {
96+
if ($(this).is(':checked')) {
97+
$(".generate_discount_fields").show(200);
98+
} else {
99+
$(".generate_discount_fields").hide(200);
100+
}
101+
});
102+
73103
$('#id_refund_state').on('change', function() {
74104
if ($("#id_refund_state option:selected").attr('refunded') == 1) {
75105
$(".refunded_state_fields").show(200);

modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl

+16
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,22 @@
369369
</div>
370370
</div>
371371
</div>
372+
<div class="generate_discount_fields" style="display:none;">
373+
<div class="form-group">
374+
<div class="col-sm-3">
375+
<label for="voucher_expiry" class="control-label required">
376+
<span title="" data-toggle="tooltip" class="label-tooltip" data-original-title="{l s='Please select the date until which the voucher can be used.' mod='hotelreservationsystem'}">{l s='Voucher expiry date' mod='hotelreservationsystem'}</span> :
377+
</label>
378+
</div>
379+
<div class="col-sm-3">
380+
<div class="input-group">
381+
<input type="text" id="voucher_expiry" value="{$expiry_date|date_format:"%d-%m-%Y"}">
382+
<div class="input-group-addon"><i class="icon-calendar"></i></div>
383+
<input type="hidden" name="voucher_expiry_date" id="voucher_expiry_date" value="{$expiry_date|date_format:"%Y-%m-%d"}">
384+
</div>
385+
</div>
386+
</div>
387+
</div>
372388
</div>
373389
{/if}
374390
{/if}

0 commit comments

Comments
 (0)