Merge branch 'ticket/r15587-refund-paypal'
This commit is contained in:
commit
af4f1270c8
@ -1584,7 +1584,7 @@ class AdminOrders extends AdminTab
|
||||
$html .= '
|
||||
</div>
|
||||
</form>';
|
||||
if($order->module && $order->module=="paypal"){
|
||||
if($order->module && $order->module == "paypal"){
|
||||
$html.='
|
||||
<form style="margin-top:10px;" action="" method="post" id="form_refund_paypal">
|
||||
<div class="form-horizontal text-right col-md-offset-9 col-md-3">
|
||||
@ -1629,42 +1629,28 @@ class AdminOrders extends AdminTab
|
||||
</div>';
|
||||
}
|
||||
$html .= '<div style="padding:10px 20px;background:#efefef;font-size: 12px;" '.(sizeof($slips)?'class="col-md-8"':'').'>';
|
||||
if($order->module && $order->module=="paybox"){
|
||||
$refundsMethod = array();
|
||||
if ($order->module == "paybox") {
|
||||
require_once dirname(__FILE__).'/../../modules/paybox/paybox.php';
|
||||
$refundsPaybox = Paybox::getAllRefundbyOrder($order->id);
|
||||
if (sizeof($refundsPaybox))
|
||||
{
|
||||
$html .='<table class="table table-condensed" width="100%;" cellspacing="0" cellpadding="0">';
|
||||
foreach ($refundsPaybox as $refund) {
|
||||
$html .='
|
||||
$refundsMethod = Paybox::getAllRefundbyOrder($order->id);
|
||||
} elseif ($order->module == "paypal") {
|
||||
require_once dirname(__FILE__).'/../../modules/paypal/paypal.php';
|
||||
$refundsMethod = Paypal::getAllRefundbyOrder($order->id);
|
||||
}
|
||||
if (count($refundsMethod) > 0) {
|
||||
$html .='<table class="table table-condensed" width="100%;" cellspacing="0" cellpadding="0">';
|
||||
foreach ($refundsMethod as $refund) {
|
||||
$html .='
|
||||
<tr>
|
||||
<td><b>'.(!empty($refund['product_name'])?$refund['product_name']:'Frais de port').'</b></td>
|
||||
<td><b>'.(!empty($refund['product_name']) ? $refund['product_name'] : 'Frais de port').'</b></td>
|
||||
<td>'. $refund['amount'] / 100 . '€</td>
|
||||
</tr>';
|
||||
}
|
||||
$html .='</table>';
|
||||
} else {
|
||||
$html .= '<p class="text-center">Pas de remboursement</p>';
|
||||
}
|
||||
} elseif($order->module && $order->module=="paypal") {
|
||||
$paypal_messages = Db::getInstance()->ExecuteS('
|
||||
SELECT `message`, `date_add`
|
||||
FROM `ps_message`
|
||||
WHERE `id_order` = '.$order->id.'
|
||||
AND (`message` LIKE "%Refund operation%" || `message` LIKE "%Cancel products%")
|
||||
ORDER BY `date_add` DESC
|
||||
');
|
||||
if($paypal_messages && !empty($paypal_message)) {
|
||||
foreach ($paypal_message as $message) {
|
||||
$html .= '<p>('.date('d/m/Y',strtotime($message['message'])).'):<br>'.$message['message'].'</p>';
|
||||
}
|
||||
}
|
||||
if(empty($paypal_messages)){
|
||||
$html .= '<p class="text-center">Pas de remboursement</p>';
|
||||
}
|
||||
|
||||
}
|
||||
$html .='</div>
|
||||
}
|
||||
$html .='</table>';
|
||||
} else {
|
||||
$html .= '<p class="text-center">Pas de remboursement</p>';
|
||||
}
|
||||
$html .='</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -1720,8 +1706,7 @@ class AdminOrders extends AdminTab
|
||||
</div>
|
||||
<div class="panel-content">';
|
||||
if (sizeof($messages)) {
|
||||
foreach ($messages as $message)
|
||||
{
|
||||
foreach ($messages as $message) {
|
||||
$html.= '<div style="background:#efefef;padding:5px;margin-bottom:10px;overflow:auto;" '.($message['is_new_for_me'] ?'class="new_message"':'').'>';
|
||||
if ($message['is_new_for_me']){
|
||||
$html.= '<a class="new_message" title="'.$this->l('Mark this message as \'viewed\'').'" href="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'&token='.$this->token.'&messageReaded='.(int)($message['id_message']).'"><img src="../img/admin/enabled.gif" alt="" /></a>';
|
||||
|
@ -725,6 +725,7 @@ class PayPal extends PaymentModule
|
||||
|
||||
// Get product amount to refund
|
||||
$amount = $order->total_shipping;
|
||||
$message = $this->l('Cancel shipping cost result:').'<br>';
|
||||
|
||||
if ($amount > 0){
|
||||
$refund = $this->_makeRefund($paypal_order['id_transaction'], (int)$order->id, $amount);
|
||||
@ -734,8 +735,12 @@ class PayPal extends PaymentModule
|
||||
mail('contact@bebeboutik.com', 'Erreur dans le remboursement', 'Erreur remboursement échoué pour la commande ' . $order_detail->id_order);
|
||||
} else {
|
||||
$this->refundSave($order->id, 0, $amount, $cookie->id_employee);
|
||||
$message .= $this->l('Transaction error because of the amount of the shipping cost!').'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
$this->formatMessage($refund, $message);
|
||||
$this->_addNewPrivateMessage((int)$order->id, $message);
|
||||
}
|
||||
|
||||
public function hookCancelProduct($params)
|
||||
@ -1697,4 +1702,21 @@ class PayPal extends PaymentModule
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recupere la liste des remboursements effectués sur un id cmomande
|
||||
* @param int $order_id id de la commande
|
||||
* @return array
|
||||
*/
|
||||
public static function getAllRefundbyOrder($order_id)
|
||||
{
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT e.`email`, r.`date`, r.`amount`, r.`id_order_detail`, d.`product_name`
|
||||
FROM `'._DB_PREFIX_.'refund_transaction` r
|
||||
LEFT JOIN `'._DB_PREFIX_.'employee` e ON r.`id_employee` = e.`id_employee`
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_detail` d on d.`id_order_detail` = r.`id_order_detail`
|
||||
WHERE r.`id_order` = '. (int)$order_id
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user