Skip to content

Commit

Permalink
Merge pull request #1094 from shreesh-webkul/gli-1993
Browse files Browse the repository at this point in the history
Added: Admin can set voucher expiry along with voucher when managing refund request
  • Loading branch information
rohit053 authored Jul 11, 2024
2 parents 204258c + ac0de7b commit d1260ab
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ public function renderView()
'isRefundCompleted' => $objOrderReturn->hasBeenCompleted(),
'paymentMethods' => $paymentMethods,
'name_controller' => Tools::getValue('controller'),
'info_icon_path' => $this->context->link->getMediaLink(_MODULE_DIR_.'hotelreservationsystem/views/img/Slices/icon-info.svg')
'info_icon_path' => $this->context->link->getMediaLink(_MODULE_DIR_.'hotelreservationsystem/views/img/Slices/icon-info.svg'),
'expiry_date' => time() + (3600 * 24 * 365.25)
)
);

Expand Down Expand Up @@ -325,6 +326,11 @@ public function postProcess()
} else {
$this->errors[] = $this->l('Invalid refund state.');
}
if (!$voucher_expiry_date = Tools::getValue('voucher_expiry_date')) {
$this->errors[] = $this->l('Voucher expiry date is required.');
} elseif (!Validate::isDate($voucher_expiry_date)) {
$this->errors[] = $this->l('Invalid voucher expiry date.');
}
} else {
$this->errors[] = $this->l('Invalid refund information found.');
}
Expand Down Expand Up @@ -480,7 +486,12 @@ public function postProcess()
$cartrule->id_customer = $objOrder->id_customer;
$now = time();
$cartrule->date_from = date('Y-m-d H:i:s', $now);
$cartrule->date_to = date('Y-m-d H:i:s', $now + (3600 * 24 * 365.25)); /* 1 year */
// generateDiscount
if ($voucher_expiry_date) {
$cartrule->date_to = date('Y-m-d H:i:s', strtotime($voucher_expiry_date));
} else {
$cartrule->date_to = date('Y-m-d H:i:s', $now + (3600 * 24 * 365.25)); /* 1 year */
}
$cartrule->active = 1;
$cartrule->highlight = 1;
$cartrule->reduction_amount = $totalRefundedAmount;
Expand Down Expand Up @@ -560,6 +571,8 @@ public function setMedia()

if ($this->display == 'view') {
$this->addJqueryUI('ui.tooltip', 'base', true);
$this->removeJS(Media::getJqueryUIPath('effects.core', 'base', false), false);

$this->addJs(_MODULE_DIR_.$this->module->name.'/views/js/admin/wk_refund_request.js');
$this->addCSS(_MODULE_DIR_.$this->module->name.'/views/css/admin/wk_refund_request.css');
}
Expand Down
30 changes: 30 additions & 0 deletions modules/hotelreservationsystem/views/js/admin/wk_refund_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ $(document).ready(function() {
manageRefundOptions();
}

$('#order_return_form').on('submit', function() {
if ($("#id_refund_state option:selected").attr('refunded') == 1) {
if ($('#generateDiscount:checked').length) {
if ($('#voucher_expiry').val() == '') {
$('#voucher_expiry').parent().addClass('has-error');
return false;
}
}
}
});

$('#voucher_expiry').on('focus', function() {
$('#voucher_expiry').parent().removeClass('has-error');
});

// initialize tootip for room price
if ($('#rooms_refund_info .price_info').length) {
$('#rooms_refund_info .price_info').each(function (i, element) {
Expand Down Expand Up @@ -70,6 +85,21 @@ $(document).ready(function() {
}
});

$('#voucher_expiry').datepicker({
dateFormat: 'dd-mm-yy',
altFormat: 'yy-mm-dd',
altField: '#voucher_expiry_date',
minDate: 0,
});

$(document).on('change', '#generateDiscount', function() {
if ($(this).is(':checked')) {
$(".generate_discount_fields").show(200);
} else {
$(".generate_discount_fields").hide(200);
}
});

$('#id_refund_state').on('change', function() {
if ($("#id_refund_state option:selected").attr('refunded') == 1) {
$(".refunded_state_fields").show(200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,22 @@
</div>
</div>
</div>
<div class="generate_discount_fields" style="display:none;">
<div class="form-group">
<div class="col-sm-3">
<label for="voucher_expiry" class="control-label required">
<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> :
</label>
</div>
<div class="col-sm-3">
<div class="input-group">
<input type="text" id="voucher_expiry" value="{$expiry_date|date_format:"%d-%m-%Y"}">
<div class="input-group-addon"><i class="icon-calendar"></i></div>
<input type="hidden" name="voucher_expiry_date" id="voucher_expiry_date" value="{$expiry_date|date_format:"%Y-%m-%d"}">
</div>
</div>
</div>
</div>
</div>
{/if}
{/if}
Expand Down

0 comments on commit d1260ab

Please sign in to comment.