Fixed: Add the remark field

Co-authored-by: Name <sumit201@webkul.in>
This commit is contained in:
aradhana kumari
2026-06-17 10:19:01 +05:30
parent 2603350b73
commit 4bfb66bb0d
8 changed files with 123 additions and 13 deletions

View File

@@ -19,5 +19,8 @@
* @copyright Since 2010 Webkul
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*}
{l s='Total cost of room and service:'} <strong><span id="booking-amount">-</span></strong>
{l s='Total room price:'} <strong><span id="booking-room-amount">-</span></strong><br>
{l s='Total service price:'} <strong><span id="booking-service-amount">-</span></strong><br>
{l s='Total order amount:'} <strong><span id="booking-amount">-</span></strong><br>
{l s='Total credit slip amount for this order:'} <strong><span id="booking-total-slip-amount">-</span></strong><br>
<span id="booking-slip-ids-wrapper" style="display:none;">{l s='Credit slip which are generated is -'} <strong><span id="booking-slip-ids"></span></strong></span>

View File

@@ -24,6 +24,8 @@
<a class="btn btn-link" href="{$link->getAdminLink('AdminCartRules')|escape:'html':'UTF-8'}&updatecart_rule&id_cart_rule={$id_cart_rule}" target="_blank">
#{$id_cart_rule}
</a>
{elseif $row['redeem_status'] == OrderSlip::REDEEM_STATUS_REDEEMED}
--
{else}
<a href="{$link->getAdminLink('AdminSlip')|escape:'html':'UTF-8'}&generateVoucher=1&id_order_slip={$row['id_order_slip']}" class="btn btn-default" title="{l s='Generate voucher for credit slip'}">
<i class="icon-refresh"></i> {l s='Generate Voucher'}

View File

@@ -22,7 +22,7 @@
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><i class="icon-remove-sign"></i></button>
<h4 class="modal-title"><i class="icon icon-exclamation-triangle"></i>&nbsp;{l s='Confirm Update'}</h4>
<p>{l s='This action is irreversable, Are you sure you want to change the status?'}</p>
<p>{l s='You will not create a voucher. This action is irreversible. Are you sure you want to change the status?'}</p>
</div>
<div class="modal-body">
<div class="row">

View File

@@ -77,6 +77,8 @@ class OrderSlipCore extends ObjectModel
/** @var int */
public $order_slip_type = 0;
public $remark;
const REDEEM_STATUS_ACTIVE = 1;
const REDEEM_STATUS_REDEEMED = 2;
const REFUND_ORDER_SLIP_TYPE = 1;
@@ -103,9 +105,10 @@ class OrderSlipCore extends ObjectModel
'partial' => array('type' => self::TYPE_INT),
'redeem_status' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_cart_rule' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'order_slip_type' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
'remark' => array('type' => self::TYPE_STRING, 'validate' => 'isString'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'order_slip_type' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
),
);
@@ -157,6 +160,34 @@ class OrderSlipCore extends ObjectModel
ORDER BY `date_add` DESC');
}
public static function getTotalSlipAmountByOrder($id_order)
{
return (float) Db::getInstance()->getValue('
SELECT SUM(`amount`)
FROM `'._DB_PREFIX_.'order_slip`
WHERE `id_order` = '.(int)$id_order
);
}
public static function getSlipIdsByOrder($id_order)
{
$rows = Db::getInstance()->executeS('
SELECT `id_order_slip`
FROM `'._DB_PREFIX_.'order_slip`
WHERE `id_order` = '.(int)$id_order.'
ORDER BY `id_order_slip` ASC'
);
$slipIds = array();
if ($rows) {
foreach ($rows as $row) {
$slipIds[] = (int) $row['id_order_slip'];
}
}
return $slipIds;
}
public static function getOrdersSlipDetail($id_order_slip = false, $id_order_detail = false)
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
@@ -313,7 +344,7 @@ class OrderSlipCore extends ObjectModel
return OrderSlip::create($order, $product_list, $shipping);
}
public static function create(Order $order, $product_list, $shipping_cost = false, $amount = 0, $amount_choosen = false, $add_tax = true , $orderSlipType = false)
public static function create(Order $order, $product_list, $shipping_cost = false, $amount = 0, $amount_choosen = false, $add_tax = true , $orderSlipType = false, $remark = '')
{
$currency = new Currency((int)$order->id_currency);
$order_slip = new OrderSlip();
@@ -437,6 +468,9 @@ class OrderSlipCore extends ObjectModel
if (isset($orderSlipType) && $orderSlipType) {
$order_slip->order_slip_type = $orderSlipType;
}
if (isset($remark) && $remark) {
$order_slip->remark = $remark;
}
if (!$order_slip->add()) {
return false;

View File

@@ -26,7 +26,7 @@
/* Debug only */
if (!defined('_PS_MODE_DEV_')) {
define('_PS_MODE_DEV_', false);
define('_PS_MODE_DEV_', true);
}
/* Compatibility warning */
define('_PS_DISPLAY_COMPATIBILITY_WARNING_', false);

View File

@@ -52,20 +52,22 @@ class AdminSlipControllerCore extends AdminController
),
'id_order' => array(
'title' => $this->l('Order ID'),
'align' => 'left',
'align' => 'center',
'class' => 'fixed-width-md',
'havingFilter' => true
),
'date_add' => array(
'title' => $this->l('Date issued'),
'type' => 'date',
'align' => 'right',
'class' => 'fixed-width-md',
'align' => 'center',
'filter_key' => 'a!date_add'
),
'id_pdf' => array(
'title' => $this->l('PDF'),
'align' => 'center',
'callback' => 'printPDFIcons',
'class' => 'fixed-width-xxl',
'orderby' => false,
'search' => false,
'remove_onclick' => true
@@ -80,13 +82,21 @@ class AdminSlipControllerCore extends AdminController
'align' => 'center',
'filter_key' => 'a!redeem_status',
'callback' => 'displayRedeemStatus',
'class' => 'fixed-width-md',
'class' => 'fixed-width-xxl',
),
'id_cart_rule' => array(
'title' => $this->l('Voucher'),
'align' => 'center',
'callback' => 'displayVoucherLink',
'class' => 'fixed-width-lg',
'class' => 'fixed-width-xxl',
),
'remark' => array(
'title' => $this->l('Remark'),
'filter_key' => 'a!remark',
'align' => 'center',
// 'class' => 'fixed-width-xxl',
'orderby' => false,
'callback' => 'displayRemark',
),
);
@@ -191,12 +201,21 @@ class AdminSlipControllerCore extends AdminController
'hint' => $this->l('Enter the amount of the credit slip for the customer'),
'name' => 'credit_slip_amount',
'required' => true,
'col' => 2,
'col' => 3,
'suffix' => $this->context->currency->sign,
'desc' => $this->context->smarty->fetch(
_PS_ADMIN_DIR_ . '/themes/default/template/controllers/slip/_booking_amount_desc.tpl'
),
),
array(
'type' => 'textarea',
'label' => $this->l('Remark'),
'hint' => $this->l('Enter any remark for this credit slip'),
'name' => 'remark',
'required' => true,
'col' => 9,
'rows' => 3,
),
),
'submit' => array(
'title' => $this->l('Generate'),
@@ -256,6 +275,13 @@ class AdminSlipControllerCore extends AdminController
$this->errors[] = $this->l('Credit slip Amount must be greater than 0');
}
$remark = trim(Tools::getValue('remark'));
if (empty($remark)) {
$this->errors[] = $this->l('Remark is required.');
} elseif (!Validate::isString($remark)) {
$this->errors[] = $this->l('Remark must be a valid text.');
}
if (!count($this->errors)) {
$objOrder = new Order(Tools::getValue('id_order'));
$creditAmount = $creditSlipAmount;
@@ -284,7 +310,7 @@ class AdminSlipControllerCore extends AdminController
);
}
if (!$idCreditSlip = OrderSlip::create($objOrder, $bookingList, 0, $creditAmount, $creditAmount, 0 , OrderSlip::MANUAL_CREDIT_SLIP_TYPE)) {
if (!$idCreditSlip = OrderSlip::create($objOrder, $bookingList, 0, $creditAmount, $creditAmount, 0 , OrderSlip::MANUAL_CREDIT_SLIP_TYPE, $remark)) {
$this->errors[] = $this->l('A credit slip cannot be generated. ');
} else {
@@ -444,6 +470,22 @@ class AdminSlipControllerCore extends AdminController
return $this->createTemplate('_display_voucher_link.tpl')->fetch();
}
public function displayRemark($remark, $row)
{
if (empty($remark)) {
return '--';
}
$maxLength = 100;
if (Tools::strlen($remark) > $maxLength) {
return '<span title="' . htmlspecialchars($remark, ENT_QUOTES, 'UTF-8') . '">'
. htmlspecialchars(Tools::substr($remark, 0, $maxLength), ENT_QUOTES, 'UTF-8')
. '<strong style="cursor:pointer;">...</strong></span>';
}
return htmlspecialchars($remark, ENT_QUOTES, 'UTF-8');
}
public function displayStatusChangeLink($token, $id)
{
$objOrderSlip = new OrderSlip($id);
@@ -540,9 +582,14 @@ class AdminSlipControllerCore extends AdminController
}
unset($booking);
$totalSlipAmount = OrderSlip::getTotalSlipAmountByOrder($idOrder);
$slipIds = OrderSlip::getSlipIdsByOrder($idOrder);
die(Tools::jsonEncode(array(
'bookings' => $bookingDetails,
'currency' => $currency
'currency' => $currency,
'total_slip_amount' => $totalSlipAmount,
'slip_ids' => $slipIds
)));
}

View File

@@ -1408,6 +1408,7 @@ CREATE TABLE `PREFIX_order_slip` (
`redeem_status` TINYINT(1) NOT NULL DEFAULT '0',
`id_cart_rule` int(10) unsigned NOT NULL DEFAULT '0',
`order_slip_type` TINYINT(1) unsigned NOT NULL DEFAULT '0',
`remark` text,
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
PRIMARY KEY (`id_order_slip`),

View File

@@ -134,6 +134,9 @@ $(document).ready(function() {
if (!idOrder) {
$('#order-info').hide();
$('#order-view-link').hide();
$('#booking-total-slip-amount').text('-');
$('#booking-slip-ids').html('');
$('#booking-slip-ids-wrapper').hide();
return;
}
@@ -157,6 +160,22 @@ $(document).ready(function() {
allBookings = response.bookings || [];
currencySign = response.currency.sign;
var totalSlipAmount = parseFloat(response.total_slip_amount || 0);
$('#booking-total-slip-amount').text(currencySign + ' ' + totalSlipAmount.toFixed(2));
var slipIds = response.slip_ids || [];
if (slipIds.length) {
var links = slipIds.map(function (id) {
var href = admin_order_slip_tab_link
+ '&order_slipFilter_id_order_slip=' + id
+ '&submitFilterorder_slip=1';
return '<a href="' + href + '">#' + id + '</a>';
});
$('#booking-slip-ids').html(links.join(', '));
$('#booking-slip-ids-wrapper').show();
} else {
$('#booking-slip-ids').html('');
$('#booking-slip-ids-wrapper').hide();
}
$('#credit_slip_amount')
.closest('.input-group')
.find('.input-group-addon, .input-group-text')
@@ -228,8 +247,12 @@ $(document).ready(function() {
var roomCost = parseFloat(booking.total_price_tax_incl);
var serviceCost = parseFloat(booking.extra_service_total_price_tax_incl || 0);
var total = roomCost + serviceCost;
$('#booking-room-amount').text(currencySign + ' ' + roomCost.toFixed(2));
$('#booking-service-amount').text(currencySign + ' ' + serviceCost.toFixed(2));
$('#booking-amount').text(currencySign + ' ' + total.toFixed(2));
} else {
$('#booking-room-amount').text('-');
$('#booking-service-amount').text('-');
$('#booking-amount').text('-');
}
});