Allow admin to add partial order payment when creating a new booking
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<select name="payment_module_name" id="payment_module_name">
|
||||
<select class="fixed-width-xxl" name="payment_module_name" id="payment_module_name">
|
||||
{if !$PS_CATALOG_MODE}
|
||||
{foreach from=$payment_modules item='module'}
|
||||
<option value="{$module->name}" {if isset($smarty.post.payment_module_name) && $module->name == $smarty.post.payment_module_name}selected="selected"{/if}>{$module->displayName}</option>
|
||||
|
||||
@@ -1186,6 +1186,7 @@
|
||||
$('#go_order_process').hide();
|
||||
}
|
||||
$('#order_message').val(jsonSummary.order_message);
|
||||
$('#payment_amount').siblings('.input-group-addon').html(currency_sign);
|
||||
resetBind();
|
||||
}
|
||||
|
||||
@@ -2081,9 +2082,9 @@
|
||||
{/if}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-lg-3">{l s='Payment'}</label>
|
||||
<label class="control-label col-lg-3">{l s='Payment method'}</label>
|
||||
<div class="col-lg-9">
|
||||
<select name="payment_module_name" id="payment_module_name">
|
||||
<select class="fixed-width-xxl" name="payment_module_name" id="payment_module_name">
|
||||
{if !$PS_CATALOG_MODE}
|
||||
{foreach from=$payment_modules item='module'}
|
||||
<option value="{$module->name}" {if isset($smarty.post.payment_module_name) && $module->name == $smarty.post.payment_module_name}selected="selected"{/if}>{$module->displayName}</option>
|
||||
@@ -2094,10 +2095,20 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-lg-3">{l s='Payment amount'}</label>
|
||||
<div class="col-lg-9">
|
||||
<div class="input-group fixed-width-xl">
|
||||
<span class="input-group-addon">{$currency->sign}</span>
|
||||
<input type="text" class="fixed-width-xl" name="payment_amount" id="payment_amount" value="{0|string_format:"%.`$smarty.const._PS_PRICE_DISPLAY_PRECISION_`f"}" />
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-lg-3">{l s='Order status'}</label>
|
||||
<div class="col-lg-9">
|
||||
<select name="id_order_state" id="id_order_state">
|
||||
<select class="fixed-width-xxl" name="id_order_state" id="id_order_state">
|
||||
{foreach from=$order_states item='order_state'}
|
||||
<option value="{$order_state.id_order_state}" {if isset($smarty.post.id_order_state) && $order_state.id_order_state == $smarty.post.id_order_state}selected="selected"{/if}>{$order_state.name}</option>
|
||||
{/foreach}
|
||||
|
||||
@@ -430,6 +430,7 @@ abstract class PaymentModuleCore extends Module
|
||||
if ($order_status->logable
|
||||
&& number_format($cart_total_paid, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_)
|
||||
&& $this->name != 'wsorder'
|
||||
&& !(isset($this->hasPartialPayment) && $this->hasPartialPayment)
|
||||
) {
|
||||
// if customer is paying full payment amount
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
@@ -478,7 +479,7 @@ abstract class PaymentModuleCore extends Module
|
||||
}
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($order_status->logable) {
|
||||
if ($order_status->logable || (isset($this->hasPartialPayment) && $this->hasPartialPayment && $amount_paid)) {
|
||||
// $order is the last order loop in the foreach
|
||||
// The method addOrderPayment of the class Order make a create a paymentOrder
|
||||
// linked to the order reference and not to the order id
|
||||
|
||||
@@ -950,48 +950,65 @@ class AdminOrdersControllerCore extends AdminController
|
||||
($module_name = Tools::getValue('payment_module_name')) &&
|
||||
($id_order_state = Tools::getValue('id_order_state')) && Validate::isModuleName($module_name)) {
|
||||
if ($this->tabAccess['edit'] === '1') {
|
||||
if (!Configuration::get('PS_CATALOG_MODE')) {
|
||||
$payment_module = Module::getInstanceByName($module_name);
|
||||
} else {
|
||||
$payment_module = new BoOrder();
|
||||
$paymentAmount = Tools::getValue('payment_amount');
|
||||
if ($paymentAmount && !Validate::isPrice($paymentAmount)) { // $paymentAmount = '' means no payment
|
||||
$this->errors[] = Tools::displayError('Payment amount is invalid. Please enter correct amount.');
|
||||
}
|
||||
|
||||
$cart = new Cart((int)$id_cart);
|
||||
Context::getContext()->currency = new Currency((int)$cart->id_currency);
|
||||
Context::getContext()->customer = new Customer((int)$cart->id_customer);
|
||||
|
||||
$bad_delivery = false;
|
||||
if (($bad_delivery = (bool)!Address::isCountryActiveById((int)$cart->id_address_delivery))
|
||||
|| !Address::isCountryActiveById((int)$cart->id_address_invoice)) {
|
||||
if ($bad_delivery) {
|
||||
$this->errors[] = Tools::displayError('This booking address country is not active.');
|
||||
if (!count($this->errors)) {
|
||||
if (!Configuration::get('PS_CATALOG_MODE')) {
|
||||
$payment_module = Module::getInstanceByName($module_name);
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('This invoice address country is not active.');
|
||||
}
|
||||
} else {
|
||||
$employee = new Employee((int)Context::getContext()->cookie->id_employee);
|
||||
$payment_module->validateOrder(
|
||||
(int)$cart->id,
|
||||
(int)$id_order_state,
|
||||
$cart->getOrderTotal(true, Cart::BOTH),
|
||||
$payment_module->displayName,
|
||||
$this->l('Manual order -- Employee:').' '.
|
||||
substr($employee->firstname, 0, 1).'. '.$employee->lastname,
|
||||
array(),
|
||||
null,
|
||||
false,
|
||||
$cart->secure_key
|
||||
);
|
||||
|
||||
if (isset($this->context->cookie->id_cart)) {
|
||||
unset($this->context->cookie->id_cart);
|
||||
}
|
||||
if (isset($this->context->cookie->id_guest)) {
|
||||
unset($this->context->cookie->id_guest);
|
||||
$payment_module = new BoOrder();
|
||||
}
|
||||
|
||||
if ($payment_module->currentOrder) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$payment_module->currentOrder.'&vieworder'.'&token='.$this->token.'&conf=3');
|
||||
$cart = new Cart((int)$id_cart);
|
||||
Context::getContext()->currency = new Currency((int)$cart->id_currency);
|
||||
Context::getContext()->customer = new Customer((int)$cart->id_customer);
|
||||
|
||||
$bad_delivery = false;
|
||||
if (($bad_delivery = (bool)!Address::isCountryActiveById((int)$cart->id_address_delivery))
|
||||
|| !Address::isCountryActiveById((int)$cart->id_address_invoice)) {
|
||||
if ($bad_delivery) {
|
||||
$this->errors[] = Tools::displayError('This booking address country is not active.');
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('This invoice address country is not active.');
|
||||
}
|
||||
} else {
|
||||
$amountPaid = $cart->getOrderTotal(true, Cart::BOTH);
|
||||
if (((float) $paymentAmount != 0) && Validate::isPrice($paymentAmount)) { // $paymentAmount != {'', '0', '0.00'}
|
||||
$objOrderState = new OrderState($id_order_state);
|
||||
if (!$objOrderState->is_logable && !$objOrderState->paid) {
|
||||
$amountPaid = Tools::ps_round($paymentAmount, 6);
|
||||
$payment_module->hasPartialPayment = true;
|
||||
$payment_module->payment_type = OrderPayment::PAYMENT_TYPE_PAY_AT_HOTEL;
|
||||
}
|
||||
}
|
||||
|
||||
$employee = new Employee((int)Context::getContext()->cookie->id_employee);
|
||||
$payment_module->validateOrder(
|
||||
(int)$cart->id,
|
||||
(int)$id_order_state,
|
||||
$amountPaid,
|
||||
$payment_module->displayName,
|
||||
$this->l('Manual order -- Employee:').' '.
|
||||
substr($employee->firstname, 0, 1).'. '.$employee->lastname,
|
||||
array(),
|
||||
null,
|
||||
false,
|
||||
$cart->secure_key
|
||||
);
|
||||
|
||||
if (isset($this->context->cookie->id_cart)) {
|
||||
unset($this->context->cookie->id_cart);
|
||||
}
|
||||
if (isset($this->context->cookie->id_guest)) {
|
||||
unset($this->context->cookie->id_guest);
|
||||
}
|
||||
|
||||
if ($payment_module->currentOrder) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$payment_module->currentOrder.'&vieworder'.'&token='.$this->token.'&conf=3');
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user