// fix bug on Payment addition

This commit is contained in:
aFolletete
2011-12-12 16:51:47 +00:00
parent ad5426d6b8
commit 9b417ab764
3 changed files with 9 additions and 4 deletions
+1 -1
View File
@@ -293,7 +293,7 @@
</tr> </tr>
{/foreach} {/foreach}
<tr> <tr>
<td><input type="text" name="payment_date" class="datepicker" size="17" value="{dateFormat date=date('Y-m-d H:i:s') full=true}" /></td> <td><input type="text" name="payment_date" class="datepicker" size="17" value="{date('Y-m-d H:i:s')}" /></td>
<td> <td>
<select name="payment_method"> <select name="payment_method">
{foreach from=PaymentModule::getInstalledPaymentModules() item=payment_method} {foreach from=PaymentModule::getInstalledPaymentModules() item=payment_method}
+2 -1
View File
@@ -1365,7 +1365,8 @@ class OrderCore extends ObjectModel
else else
$this->total_paid_real += Tools::ps_round(Tools::convertPrice($order_payment->amount, $order_payment->id_currency, false), 2); $this->total_paid_real += Tools::ps_round(Tools::convertPrice($order_payment->amount, $order_payment->id_currency, false), 2);
return $order_payment->add() && $this->update(); // We put autodate parameter of add method to true if date_add field is null
return $order_payment->add(is_null($order_payment->date_add)) && $this->update();
} }
/** /**
+5 -1
View File
@@ -572,8 +572,12 @@ class AdminOrdersControllerCore extends AdminController
elseif (!Validate::isDate(Tools::getValue('payment_date'))) elseif (!Validate::isDate(Tools::getValue('payment_date')))
$this->_errors[] = Tools::displayError('Date is invalid'); $this->_errors[] = Tools::displayError('Date is invalid');
else else
{
if (!$order->addOrderPayment($amount, Tools::getValue('payment_method'), Tools::getValue('payment_transaction_id'), $currency, Tools::getValue('payment_date'))) if (!$order->addOrderPayment($amount, Tools::getValue('payment_method'), Tools::getValue('payment_transaction_id'), $currency, Tools::getValue('payment_date')))
$this->_errors[] = Tools::displayError('An error occured on adding of order payment'); $this->_errors[] = Tools::displayError('An error occured on adding of order payment');
else
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token);
}
} }
else else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.'); $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
@@ -585,7 +589,7 @@ class AdminOrdersControllerCore extends AdminController
$payment_module = Module::getInstanceByName($module_name); $payment_module = Module::getInstanceByName($module_name);
$cart = new Cart((int)$id_cart); $cart = new Cart((int)$id_cart);
$payment_module->validateOrder((int)$cart->id, (int)$id_order_state, $cart->getOrderTotal(true, Cart::BOTH), $payment_module->displayName, $this->l(sprintf('Manual order - ID Employee :%1', (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(sprintf('Manual order - ID Employee :%1', (int)Context::getContext()->cookie->id_employee)));
if($payment_module->currentOrder) if ($payment_module->currentOrder)
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$payment_module->currentOrder.'&vieworder'.'&token='.$this->token); Tools::redirectAdmin(self::$currentIndex.'&id_order='.$payment_module->currentOrder.'&vieworder'.'&token='.$this->token);
} }
else else