[*] BO : Partial refund - part 3
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10611 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+1
-1
@@ -102,7 +102,7 @@ function generateOrderSlipPDF()
|
||||
$order->products = OrderSlip::getOrdersSlipProducts($orderSlip->id, $order);
|
||||
$tmp = NULL;
|
||||
|
||||
generatePDF($order, PDF::TEMPLATE_ORDER_SLIP);
|
||||
generatePDF($orderSlip, PDF::TEMPLATE_ORDER_SLIP);
|
||||
}
|
||||
|
||||
function generateDeliverySlipPDF()
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
0/{$productQuantity}
|
||||
{/if}
|
||||
</td>
|
||||
<td class="partial_refund_fields" style="text-align:right;background-color:rgb(232, 237, 194);display:none"><input type="text" size="3" name="partialRefund[{$k}]" /> €</td>
|
||||
<td class="partial_refund_fields" style="text-align:right;background-color:rgb(232, 237, 194);display:none"><input type="text" size="3" name="partialRefundProduct[{$k}]" /> €</td>
|
||||
{if $can_edit}
|
||||
<td class="product_invoice" colspan="2" style="display: none;text-align:center;">
|
||||
{if $order->hasBeenPaid()}
|
||||
|
||||
@@ -551,24 +551,29 @@
|
||||
<tr id="total_products">
|
||||
<td width="150px;">{l s='Products'}</td>
|
||||
<td align="right">{displayPrice price=$order->total_products_wt currency=$currency->id}</td>
|
||||
<td class="partial_refund_fields" style="background-color:rgb(232, 237, 194);"> </td>
|
||||
</tr>
|
||||
<tr id="total_discounts" {if $order->total_discounts_tax_incl == 0}style="display: none;"{/if}>
|
||||
<td>{l s='Discounts'}</td>
|
||||
<td align="right">-{displayPrice price=$order->total_discounts_tax_incl currency=$currency->id}</td>
|
||||
<td class="partial_refund_fields" style="background-color:rgb(232, 237, 194);"> </td>
|
||||
</tr>
|
||||
<tr id="total_wrapping" {if $order->total_wrapping_tax_incl == 0}style="display: none;"{/if}>
|
||||
<td>{l s='Wrapping'}</td>
|
||||
<td align="right">{displayPrice price=$order->total_wrapping_tax_incl currency=$currency->id}</td>
|
||||
<td class="partial_refund_fields" style="background-color:rgb(232, 237, 194);"> </td>
|
||||
</tr>
|
||||
<tr id="total_shipping">
|
||||
<td>{l s='Shipping'}</td>
|
||||
<td align="right">{displayPrice price=$order->total_shipping_tax_incl currency=$currency->id}</td>
|
||||
<td class="partial_refund_fields" style="background-color:rgb(232, 237, 194);"><input type="text" size="3" name="partialRefundShippingCost" /> €</td>
|
||||
</tr>
|
||||
<tr style="font-size: 20px" id="total_order">
|
||||
<td>{l s='Total'}</td>
|
||||
<td align="right">
|
||||
{displayPrice price=$order->total_paid_tax_incl currency=$currency->id}
|
||||
</td>
|
||||
<td class="partial_refund_fields" style="background-color:rgb(232, 237, 194);"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -39,9 +39,15 @@ class OrderSlipCore extends ObjectModel
|
||||
/** @var float */
|
||||
public $conversion_rate;
|
||||
|
||||
/** @var integer */
|
||||
public $amount;
|
||||
|
||||
/** @var integer */
|
||||
public $shipping_cost;
|
||||
|
||||
/** @var integer */
|
||||
public $shipping_cost_amount;
|
||||
|
||||
/** @var string Object creation date */
|
||||
public $date_add;
|
||||
|
||||
@@ -63,7 +69,9 @@ class OrderSlipCore extends ObjectModel
|
||||
$fields['id_customer'] = (int)($this->id_customer);
|
||||
$fields['id_order'] = (int)($this->id_order);
|
||||
$fields['conversion_rate'] = (float)($this->conversion_rate);
|
||||
$fields['amount'] = (int)($this->amount);
|
||||
$fields['shipping_cost'] = (int)($this->shipping_cost);
|
||||
$fields['shipping_cost_amount'] = (float)($this->shipping_cost_amount);
|
||||
$fields['date_add'] = pSQL($this->date_add);
|
||||
$fields['date_upd'] = pSQL($this->date_upd);
|
||||
return $fields;
|
||||
@@ -177,5 +185,29 @@ class OrderSlipCore extends ObjectModel
|
||||
$orderSlip->addSlipDetail($productList, $qtyList);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function createPartialOrderSlip($order, $amount, $shipping_cost_amount, $order_detail_list)
|
||||
{
|
||||
$currency = new Currency($order->id_currency);
|
||||
$orderSlip = new OrderSlip();
|
||||
$orderSlip->id_customer = (int)($order->id_customer);
|
||||
$orderSlip->id_order = (int)($order->id);
|
||||
$orderSlip->amount = (float)($amount);
|
||||
$orderSlip->shipping_cost = false;
|
||||
$orderSlip->shipping_cost_amount = (float)($shipping_cost_amount);
|
||||
$orderSlip->conversion_rate = $currency->conversion_rate;
|
||||
if (!$orderSlip->add())
|
||||
return false;
|
||||
|
||||
$orderSlip->addPartialSlipDetail($order_detail_list);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function addPartialSlipDetail($order_detail_list)
|
||||
{
|
||||
foreach ($order_detail_list as $id_order_detail => $amount)
|
||||
Db::getInstance()->AutoExecute(_DB_PREFIX_.'order_slip_detail', array('id_order_slip' => (int)($this->id), 'id_order_detail' => (int)($id_order_detail), 'product_quantity' => 0, 'amount' => (float)($amount)), 'INSERT');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
|
||||
'tax_tab' => '',
|
||||
));
|
||||
|
||||
return $this->smarty->fetch(_PS_THEME_DIR_.'/pdf/invoice.tpl');
|
||||
return $this->smarty->fetch(_PS_THEME_DIR_.'/pdf/order-slip.tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -333,6 +333,32 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
|
||||
/* Partial refund from order */
|
||||
elseif (Tools::isSubmit('partialRefund') AND Validate::isLoadedObject($order = new Order((int)(Tools::getValue('id_order')))))
|
||||
{
|
||||
$amount = 0;
|
||||
$order_detail_list = array();
|
||||
foreach ($_POST['partialRefundProduct'] as $id_order_detail => $amount_detail)
|
||||
if (isset($amount_detail) && !empty($amount_detail))
|
||||
{
|
||||
$amount += $amount_detail;
|
||||
$order_detail_list[$id_order_detail] = $amount_detail;
|
||||
}
|
||||
$shipping_cost_amount = (float)(Tools::getValue('partialRefundShippingCost'));
|
||||
|
||||
if ($shipping_cost_amount > 0 OR $amount > 0)
|
||||
{
|
||||
if (!OrderSlip::createPartialOrderSlip($order, $amount, $shipping_cost_amount, $order_detail_list))
|
||||
$this->_errors[] = Tools::displayError('Cannot generate partial credit slip');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You have to write an amount if you want to do a partial credit slip');
|
||||
|
||||
// Redirect if no errors
|
||||
if (!sizeof($this->_errors))
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=24&token='.$this->token);
|
||||
}
|
||||
|
||||
/* Cancel product from order */
|
||||
elseif (Tools::isSubmit('cancelProduct') AND Validate::isLoadedObject($order = new Order((int)(Tools::getValue('id_order')))))
|
||||
{
|
||||
|
||||
Executable
+206
@@ -0,0 +1,206 @@
|
||||
<div style="font-size: 8pt; color: #444">
|
||||
|
||||
<table>
|
||||
<tr><td> </td></tr>
|
||||
</table>
|
||||
|
||||
<!-- ADDRESSES -->
|
||||
<table style="width: 100%">
|
||||
<tr>
|
||||
<td style="width: 15%"></td>
|
||||
<td style="width: 85%">
|
||||
{if !empty($delivery_address)}
|
||||
<table style="width: 100%">
|
||||
<tr>
|
||||
<td style="width: 50%">
|
||||
<span style="font-weight: bold; font-size: 10pt; color: #9E9F9E">{l s='Delivery Address' pdf='true'}</span><br />
|
||||
{$delivery_address}
|
||||
</td>
|
||||
<td style="width: 50%">
|
||||
<span style="font-weight: bold; font-size: 10pt; color: #9E9F9E">{l s='Billing Address' pdf='true'}</span><br />
|
||||
{$invoice_address}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{else}
|
||||
<table style="width: 100%">
|
||||
<tr>
|
||||
<td style="width: 50%">
|
||||
<span style="font-weight: bold; font-size: 10pt; color: #9E9F9E">{l s='Billing & Delivery Address.' pdf='true'}</span><br />
|
||||
{$invoice_address}
|
||||
</td>
|
||||
<td style="width: 50%">
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- / ADDRESSES -->
|
||||
|
||||
<div style="line-height: 1pt"> </div>
|
||||
|
||||
<!-- PRODUCTS TAB -->
|
||||
<table style="width: 100%">
|
||||
<tr>
|
||||
<td style="width: 15%; padding-right: 7px; text-align: right; vertical-align: top; font-size: 7pt;">
|
||||
<!-- CUSTOMER INFORMATIONS -->
|
||||
<b>{l s='Order Number:' pdf='true'}</b><br />
|
||||
{'%06d'|sprintf:$order->id}<br />
|
||||
<br />
|
||||
<b>{l s='Order Date:' pdf='true'}</b><br />
|
||||
{$order->date_add|date_format:"%d-%m-%Y %H:%M"}<br />
|
||||
<br />
|
||||
<b>{l s='Payment Method:' pdf='true'}</b><br />
|
||||
{$order->payment}<br />
|
||||
<br />
|
||||
<!-- / CUSTOMER INFORMATIONS -->
|
||||
</td>
|
||||
<td style="width: 85%; text-align: right">
|
||||
<table style="width: 100%; font-size: 8pt;">
|
||||
<tr style="line-height:4px;">
|
||||
<td style="text-align: left; background-color: #4D4D4D; color: #FFF; padding-left: 10px; font-weight: bold; width: 45%">{l s='Product / Reference' pdf='true'}</td>
|
||||
<!-- unit price tax excluded is mandatory -->
|
||||
{if !$tax_excluded_display}
|
||||
<td style="background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold;; width: 10%">{l s='Unit Price' pdf='true'} <br />{l s='(Tax Excl.)' pdf='true'}</td>
|
||||
{/if}
|
||||
<td style="background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold;; width: 10%">{l s='Unit Price' pdf='true'}</td>
|
||||
<td style="background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold;; width: 10%">{l s='Discount' pdf='true'}</td>
|
||||
<td style="background-color: #4D4D4D; color: #FFF; text-align: center; font-weight: bold; width: 10%">{l s='Qty' pdf='true'}</td>
|
||||
<td style="background-color: #4D4D4D; color: #FFF; text-align: right; font-weight: bold;; width: 15%">{l s='Total' pdf='true'}</td>
|
||||
</tr>
|
||||
{foreach $order_details as $order_detail}
|
||||
{cycle values='#FFF,#DDD' assign=bgcolor}
|
||||
<tr style="line-height:6px;background-color:{$bgcolor};">
|
||||
<td style="text-align: left; width: 45%">{$order_detail.product_name}</td>
|
||||
<!-- unit price tax excluded is mandatory -->
|
||||
{if !$tax_excluded_display}
|
||||
<td style="text-align: right; width: 10%">
|
||||
{displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_excl}
|
||||
</td>
|
||||
{/if}
|
||||
<td style="text-align: right; width: 10%">
|
||||
{if $tax_excluded_display}
|
||||
{displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_excl}
|
||||
{else}
|
||||
{displayPrice currency=$order->id_currency price=$order_detail.unit_price_tax_incl}
|
||||
{/if}
|
||||
</td>
|
||||
<td style="text-align: right; width: 10%">
|
||||
{if (isset($order_detail.reduction_amount) && $order_detail.reduction_amount > 0)}
|
||||
-{displayPrice currency=$order->id_currency price=$order_detail.reduction_amount}
|
||||
{else if (isset($order_detail.reduction_percent) && $order_detail.reduction_percent > 0)}
|
||||
-{$order_detail.reduction_percent}%
|
||||
{else}
|
||||
--
|
||||
{/if}
|
||||
</td>
|
||||
<td style="text-align: center; width: 10%">{$order_detail.product_quantity}</td>
|
||||
<td style="width: 15%; text-align: right; width: 15%">
|
||||
{if $tax_excluded_display}
|
||||
{displayPrice currency=$order->id_currency price=$order_detail.total_price_tax_excl}
|
||||
{else}
|
||||
{displayPrice currency=$order->id_currency price=$order_detail.total_price_tax_incl}
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{foreach $order_detail.customizedDatas as $customization}
|
||||
<tr style="line-height:6px;background-color:{$bgcolor}; ">
|
||||
<td style="line-height:3px; text-align: left; width: 60%; vertical-align: top">
|
||||
{foreach $customization.datas as $customization_types}
|
||||
<blockquote>
|
||||
{foreach $customization_types as $customization_infos name=custo_foreach}
|
||||
{$customization_infos.name}: {$customization_infos.value}
|
||||
{if !$smarty.foreach.custo_foreach.last}<br />
|
||||
{else}
|
||||
<div style="line-height:0.4pt"> </div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</blockquote>
|
||||
{/foreach}
|
||||
</td>
|
||||
<td style="text-align: right; width: 15%"></td>
|
||||
<td style="text-align: center; width: 10%; vertical-align: top">({$customization.quantity})</td>
|
||||
<td style="width: 15%; text-align: right;"></td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
{/foreach}
|
||||
</table>
|
||||
|
||||
<table style="width: 100%">
|
||||
{if (($order->total_paid_tax_incl - $order->total_paid_tax_excl) > 0)}
|
||||
<tr style="line-height:5px;">
|
||||
<td style="width: 85%; text-align: right; font-weight: bold">{l s='Product Total (Tax Excl.)' pdf='true'}</td>
|
||||
<td style="width: 15%; text-align: right;">{displayPrice currency=$order->id_currency price=$order->total_products}</td>
|
||||
</tr>
|
||||
|
||||
<tr style="line-height:5px;">
|
||||
<td style="width: 85%; text-align: right; font-weight: bold">{l s='Product Total (Tax Incl.)' pdf='true'}</td>
|
||||
<td style="width: 15%; text-align: right;">{displayPrice currency=$order->id_currency price=$order->total_products_wt}</td>
|
||||
</tr>
|
||||
{else}
|
||||
<tr style="line-height:5px;">
|
||||
<td style="width: 85%; text-align: right; font-weight: bold">{l s='Product Total' pdf='true'}</td>
|
||||
<td style="width: 15%; text-align: right;">{displayPrice currency=$order->id_currency price=$order->total_products}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
{if $order->total_discounts_tax_incl > 0}
|
||||
<tr style="line-height:5px;">
|
||||
<td style="text-align: right; font-weight: bold">{l s='Total Vouchers' pdf='true'}</td>
|
||||
<td style="width: 15%; text-align: right;">-{displayPrice currency=$order->id_currency price=$order->total_discounts_tax_incl}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
{if $order->total_wrapping_tax_incl > 0}
|
||||
<tr style="line-height:5px;">
|
||||
<td style="text-align: right; font-weight: bold">{l s='Wrapping Cost' pdf='true'}</td>
|
||||
<td style="width: 15%; text-align: right;">
|
||||
{if $tax_excluded_display}
|
||||
{displayPrice currency=$order->id_currency price=$order->total_wrapping_tax_excl}
|
||||
{else}
|
||||
{displayPrice currency=$order->id_currency price=$order->total_wrapping_tax_incl}
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
{if $order->total_shipping_tax_incl > 0}
|
||||
<tr style="line-height:5px;">
|
||||
<td style="text-align: right; font-weight: bold">{l s='Shipping Cost' pdf='true'}</td>
|
||||
<td style="width: 15%; text-align: right;">
|
||||
{if $tax_excluded_display}
|
||||
{displayPrice currency=$order->id_currency price=$order->total_shipping_tax_excl}
|
||||
{else}
|
||||
{displayPrice currency=$order->id_currency price=$order->total_shipping_tax_incl}
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
{if ($order->total_paid_tax_incl - $order->total_paid_tax_excl) > 0}
|
||||
<tr style="line-height:5px;">
|
||||
<td style="text-align: right; font-weight: bold">{l s='Total Tax' pdf='true'}</td>
|
||||
<td style="width: 15%; text-align: right;">{displayPrice currency=$order->id_currency price=($order->total_paid_tax_incl - $order->total_paid_tax_excl)}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
<tr style="line-height:5px;">
|
||||
<td style="text-align: right; font-weight: bold">{l s='Total' pdf='true'}</td>
|
||||
<td style="width: 15%; text-align: right;">{displayPrice currency=$order->id_currency price=$order->total_paid_tax_incl}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- / PRODUCTS TAB -->
|
||||
|
||||
<div style="line-height: 1pt"> </div>
|
||||
|
||||
{$tax_tab}
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user