Merge branch 'ticket-11208-FactureCadeau' into develop

This commit is contained in:
Marion Muszynski 2016-12-02 10:16:13 +01:00
commit f95fc836e5
5 changed files with 430 additions and 172 deletions

View File

@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@ -33,7 +33,7 @@ include(PS_ADMIN_DIR.'/../config/config.inc.php');
$cookie = new Cookie('psAdmin');
if (!$cookie->id_employee)
Tools::redirectAdmin('login.php');
$functionArray = array(
'pdf' => 'generateInvoicePDF',
'id_order_slip' => 'generateOrderSlipPDF',
@ -109,7 +109,11 @@ function generateInvoicesPDFPrivateSales()
if(count($orders) == 0) {
die (Tools::displayError('No invoices found'));
}
PDF::multipleInvoices($orders, false, true);
if(Tools::getValue('gift')){
PDF::multipleInvoices($orders, false, true, false, true);
} else {
PDF::multipleInvoices($orders, false, true);
}
}
}
}
@ -179,7 +183,11 @@ function generateInvoicesPDFPrivateSalesAll()
if(count($orders) == 0) {
die (Tools::displayError('No invoices found'));
}
PDF::multipleInvoices($orders, false, true);
if(Tools::getValue('gift')){
PDF::multipleInvoices($orders, false, true, false, true);
} else {
PDF::multipleInvoices($orders, false, true);
}
}
}
}
@ -189,7 +197,7 @@ function generateInvoicesPDFPrivateMulti()
if(Module::isInstalled('privatesales')) {
include(dirname(__FILE__).'/../modules/privatesales/Sale.php');
if($sale = new Sale((int) Tools::getValue('id_sale'))) {
$statuts = array(17, Configuration::get('PS_OS_PAYMENT'));
$statuts = array(17, Configuration::get('PS_OS_PAYMENT'));
$orders = $sale->getOrdersFromSaleMulti($statuts, 2);
if(count($orders) == 0) {
die (Tools::displayError('No invoices found'));
@ -248,7 +256,11 @@ function generateInvoicesPDFPrivateM2Plus()
if(count($orders) == 0) {
die (Tools::displayError('No invoices found'));
}
PDF::multipleInvoices($orders, false, true);
if(Tools::getValue('gift')){
PDF::multipleInvoices($orders, false, true, false, true);
} else {
PDF::multipleInvoices($orders, false, true);
}
}
}
}
@ -268,7 +280,7 @@ function generateInvoicesPDFPrivateM2Bis()
die (Tools::displayError('Invalid from date'));
if (!Validate::isDate(Tools::getValue('date_from')))
die (Tools::displayError('Invalid end date'));
$statuts = array(17, Configuration::get('PS_OS_PAYMENT'));
$orders = Sale::getOrdersM3($statuts, $id_sales, Tools::getValue('date_from'), Tools::getValue('date_to'), true);

View File

@ -66,7 +66,7 @@ class AdminInvoices extends AdminTab
foreach ($result as $row)
$statusStats[$row['id_order_state']] = $row['nbOrders'];
echo '<h2>'.$this->l('Print PDF ').'</h2>
<fieldset style="width:300px;margin-right: 10px;"><legend><img src="../img/admin/pdf.gif" alt="" /> '.$this->l('By date').'</legend>
<form action="'.$currentIndex.'&token='.$this->token.'" method="post">
@ -88,13 +88,13 @@ class AdminInvoices extends AdminTab
</fieldset>';
if($this->print_sales) {
echo '<form action="'.$currentIndex.'&token='.$this->token.'" method="post">
if($this->print_sales) {
echo '<form id="form_admin_invoice" action="'.$currentIndex.'&token='.$this->token.'" method="post">
<table class="table" style="margin-top:30px; width: 100%">';
/*echo '
<tr>
<td colspan="6"></td>
<td colspan="6"></td>
<td align="center"><a id="checkm3" data-checked="0" href="#">'. $this->l('Check all') .'</a></td>
</tr>*/
echo '<tr>
@ -124,8 +124,8 @@ class AdminInvoices extends AdminTab
echo '<tr class="'.$class.'">
<td align="center">'. $sale['id_sale'] .'</td>
<td><label for="multi_'.$sale['id_sale'].'" style="text-align: left; font-weight: normal">'. $sale['title'] .'<label></td>
<td>'. $date->format('Y-m-d') .'</td>';
<td><label for="multi_'.$sale['id_sale'].'" style="text-align: left; font-weight: bold">'. $sale['title'] .'<label></td>
<td align="center">'. $date->format('Y-m-d') .'</td>';
/*<td align="center">';
if ($sale['delivery_delay'] == 2
|| $sale['delivery_delay'] == 6) {
@ -149,8 +149,11 @@ class AdminInvoices extends AdminTab
echo '</td>*/
echo '</td>
<td align="center">
<a onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printM1=1&id_sale='. $sale['id_sale'] .'&token='.$this->token.'">
<img src="../img/admin/pdf.gif" alt="">
<a title="Facture - Avec prix" onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printM1=1&id_sale='. $sale['id_sale'] .'&token='.$this->token.'">
<span class="text-green-light anticon anticon-file-pdf" style="cursor:pointer;"></span>
</a>
<a title="Facture cadeau - Sans prix" onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printM1=1&id_sale='. $sale['id_sale'] .'&gift=1&token='.$this->token.'">
<span class="text-rose anticon anticon-file-pdf" style="cursor:pointer;"></span>
</a>
</td>';
/*<td align="center">
@ -163,30 +166,37 @@ class AdminInvoices extends AdminTab
<td align="center"><input id="multi_plus_'. $sale['id_sale'].'" type="checkbox" name="multiPlus[]" value="'.$sale['id_sale'].'"/></td>
<td align="center">
<a onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printAll=1&id_sale='. $sale['id_sale'] .'&token='.$this->token.'">
<img src="../img/admin/pdf.gif" alt="">
<span class="text-green-light anticon anticon-file-pdf" style="cursor:pointer;"></span>
</a>
<a onclick="this.target=\'_blank\'" href="'.$currentIndex.'&printAll=1&id_sale='. $sale['id_sale'] .'&gift=1&token='.$this->token.'">
<span class="text-rose anticon anticon-file-pdf" style="cursor:pointer;"></span>
</a>
</td>
<td align="center" '.($sale['delivery_delay'] != 1?'style="background:#FFD3D3;"':'').'>'.(isset($sale['delivery_delay_name'])?$sale['delivery_delay_name']:'').'</td>
<td align="center" '.($sale['delivery_delay'] != 1?'style="background:#f49ac1;"':'').'>'.(isset($sale['delivery_delay_name'])?$sale['delivery_delay_name']:'').'</td>
</tr>';
}
// <td align="center"><input id="m2_'. $sale['id_sale'].'" type="checkbox" name="m2[]" value="'.$sale['id_sale'].'" /></td>
echo '<tr>
<td colspan="4">
<td colspan="4" style="padding:5px;">
<input type="hidden" name="date_to" value="'. Tools::getValue('date_to') .'" />
<input type="hidden" name="date_from" value="'. Tools::getValue('date_from') .'" />
<label style="float:none;" class="text-green-light "><span class="anticon anticon-file-pdf"></span> '.$this->l('Avec prix').'</label>
<label style="float:none;" class="text-rose "><span class="anticon anticon-file-pdf"></span> '.$this->l('Sans prix').'</label>
</td>';
/*<td align="center">
<input type="submit" name="submitPrintM2Bis" class="button" value="'.$this->l('Print M2\'').'" />
</td>*/
echo '<td align="center">
<input type="submit" name="submitPrintM2Plus" class="button" value="'.$this->l('Print M2+').'" />
<input type="submit" name="resetPrintM2Plus" class="button" value="'.$this->l('Unselect all').'" />
echo '<td align="center" style="padding:5px;">
<input type="submit" name="submitPrintM2Plus" class="btn btn-bbb btn-xs" value="'.$this->l('Print M2+').'" />
<input type="submit" name="resetPrintM2Plus" class="btn btn-bbb btn-xs" value="'.$this->l('Unselect all').'" />
</td>
<td align="center">
<input type="submit" name="submitPrintMPlus" class="button" value="'.$this->l('Print Même Marque').'" />
<td align="center" style="padding:5px;">
<input type="submit" name="submitPrintMPlus" class="btn btn-bbb btn-xs" value="'.$this->l('Print Même Marque').'" />
</td>
<td style="padding:5px;">
<p><label style="float:none;" class="text-purple"><input type="checkbox" name="gift" value="1" /> '.$this->l('Factures Cadeaux').'</label></p>
</td>
<td></td>
<td></td>
</tr>';
echo '</table>
@ -214,7 +224,7 @@ class AdminInvoices extends AdminTab
<div class="small"><sup>*</sup> '.$this->l('Required fields').'</div>
</form>
</fieldset>';
if(Module::isInstalled('privatesales')) {
include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php');
echo '
@ -279,7 +289,7 @@ class AdminInvoices extends AdminTab
<br />
</fieldset>';
}
echo '<fieldset style="float:left;width: 500px;margin-left:10px"><legend><img src="../img/admin/pdf.gif" alt="" /> '.$this->l('By statuses').'</legend>
<form action="'.$currentIndex.'&token='.$this->token.'" method="post">
<label style="width:90px">'.$this->l('Statuses').' :</label>
@ -303,7 +313,7 @@ class AdminInvoices extends AdminTab
</fieldset>
<div class="clear">&nbsp;</div>';
echo '<script>
echo '<script>
$(\'input[name="m2[]"]\').live("click", function(e){
if ($(\'input[name="m2[]"]:checked\').length > 2 ) {
alert("You can choose only 2 sales for this export");
@ -312,7 +322,7 @@ class AdminInvoices extends AdminTab
return true;
}
});
$("#checkm3").live("click", function(e){
e.preventDefault();
@ -330,19 +340,19 @@ class AdminInvoices extends AdminTab
});
$("input[name=resetPrintM2Plus]").click(function() {
var haveChecked = $("input[name=\'multi2[]\']:checked").length>0;
if (haveChecked && confirm(\''.$this->l("Are you sure to unselect all ?").'\')) {
$("input[name=\'multi2[]\']").each(function() {
$(this).attr(\'checked\', false);
});
});
$.post(\'ajax-tab.php\',
\'action=resetPrintM2Plus&tab=AdminInvoices&token='.$this->token.'\'
);
);
}
return false;
});
@ -409,8 +419,8 @@ class AdminInvoices extends AdminTab
}
// print 48h
elseif (Tools::getValue('print48h') == 1)
{
include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php');
{
include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php');
if($sale = new Sale((int) Tools::getValue('id_sale'))) {
if(!in_array($sale->delivery_delay, array(2 ,6) )) {
$this->_errors[] = $this->l('This sale is not delivery 48h');
@ -426,8 +436,8 @@ class AdminInvoices extends AdminTab
}
// print 48h bis (distinct multi)
elseif (Tools::getValue('print48hbis') == 1)
{
include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php');
{
include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php');
if($sale = new Sale((int) Tools::getValue('id_sale'))) {
if(!in_array($sale->delivery_delay, array(2 ,6) )) {
$this->_errors[] = $this->l('This sale is not delivery 48h');
@ -443,34 +453,42 @@ class AdminInvoices extends AdminTab
}
// print printAll
elseif (Tools::getValue('printAll') == 1)
{
include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php');
if($sale = new Sale((int) Tools::getValue('id_sale'))) {
{
include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php');
if($sale = new Sale((int) Tools::getValue('id_sale'))) {
$statuts = array(17, Configuration::get('PS_OS_PAYMENT'));
$orders = $sale->getOrdersFromSale($statuts, FALSE, TRUE);
if(sizeof($orders)) {
Tools::redirectAdmin('pdf.php?privatesalesAll&id_sale='.(int) $sale->id.'&token='.$this->token);
if(Tools::getValue('gift') == 1) {
Tools::redirectAdmin('pdf.php?privatesalesAll&gift=1&id_sale='.(int) $sale->id.'&token='.$this->token);
} else {
Tools::redirectAdmin('pdf.php?privatesalesAll&id_sale='.(int) $sale->id.'&token='.$this->token);
}
}
}
$this->_errors[] = $this->l('No invoice found for this sale');
}
// print M1
elseif (Tools::getValue('printM1') == 1)
{
include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php');
{
include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php');
if($sale = new Sale((int) Tools::getValue('id_sale'))) {
$statuts = array(17, Configuration::get('PS_OS_PAYMENT'));
$orders = $sale->getOrdersFromSale($statuts);
if(sizeof($orders)) {
Tools::redirectAdmin('pdf.php?privatesales&id_sale='.(int) $sale->id.'&token='.$this->token);
if(Tools::getValue('gift') == 1) {
Tools::redirectAdmin('pdf.php?privatesales&gift=1&id_sale='.(int) $sale->id.'&token='.$this->token);
} else {
Tools::redirectAdmin('pdf.php?privatesales&id_sale='.(int) $sale->id.'&token='.$this->token);
}
}
}
$this->_errors[] = $this->l('No invoice found for this sale');
}
// print M2
elseif (Tools::getValue('printM2') == 1)
{
include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php');
{
include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php');
if($sale = new Sale((int) Tools::getValue('id_sale'))) {
$statuts = array(17, Configuration::get('PS_OS_PAYMENT'));
$orders = $sale->getOrdersFromSaleMulti($statuts, 2);
@ -482,7 +500,7 @@ class AdminInvoices extends AdminTab
}
// print M2'
elseif (Tools::isSubmit('submitPrintM2Bis')) {
include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php');
include_once(dirname(__FILE__).'/../../modules/privatesales/Sale.php');
$id_sales = Tools::getValue('m2');
if (empty($id_sales) || (count($id_sales) != 2) ) {
$this->_errors[] = $this->l('You must select 2 sales for print M2\'');
@ -508,7 +526,11 @@ class AdminInvoices extends AdminTab
$statuts = array(17, Configuration::get('PS_OS_PAYMENT'));
$orders = Sale::getOrdersM2($statuts, $id_sales, Tools::getValue('date_from'), Tools::getValue('date_to'));
if(sizeof($orders)) {
Tools::redirectAdmin('pdf.php?privatesalesM2Plus&id_sale='.implode(',', $id_sales) .'&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&token='.$this->token);
if(Tools::getValue('gift') == 1) {
Tools::redirectAdmin('pdf.php?privatesalesM2Plus&gift=1&id_sale='.implode(',', $id_sales) .'&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&token='.$this->token);
} else {
Tools::redirectAdmin('pdf.php?privatesalesM2Plus&id_sale='.implode(',', $id_sales) .'&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&token='.$this->token);
}
}
$this->_errors[] = $this->l('No invoice found for these sales');
}
@ -524,7 +546,11 @@ class AdminInvoices extends AdminTab
$statuts = array(17, Configuration::get('PS_OS_PAYMENT'));
$orders = Sale::getOrdersM2($statuts, $id_sales, Tools::getValue('date_from'), Tools::getValue('date_to'));
if(sizeof($orders)) {
Tools::redirectAdmin('pdf.php?privatesalesM2Plus&id_sale='.implode(',', $id_sales) .'&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&token='.$this->token);
if(Tools::getValue('gift') == 1) {
Tools::redirectAdmin('pdf.php?privatesalesM2Plus&gift=1&id_sale='.implode(',', $id_sales) .'&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&token='.$this->token);
} else {
Tools::redirectAdmin('pdf.php?privatesalesM2Plus&id_sale='.implode(',', $id_sales) .'&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&token='.$this->token);
}
}
$this->_errors[] = $this->l('No invoice found for these sales');
}

View File

@ -329,14 +329,14 @@ class PDFCore extends PDF_PageGroupCore
$this->MultiCell(0.0, 4.0, $merchantDetailFooter, 0, 'C', 1);
}
public static function multipleInvoices($invoices, $multi = false, $tri = false, $expe48 = false)
public static function multipleInvoices($invoices, $multi = false, $tri = false, $expe48 = false, $gift = false)
{
$pdf = new PDF('P', 'mm', 'A4');
foreach ($invoices AS $id_order)
{
$orderObj = new Order((int)$id_order);
if (Validate::isLoadedObject($orderObj))
PDF::invoice($orderObj, 'D', true, $pdf, false, false, $multi, $tri, $expe48);
PDF::invoice($orderObj, 'D', true, $pdf, false, false, $multi, $tri, $expe48, $gift);
}
return $pdf->Output('invoices.pdf', 'D');
}
@ -564,7 +564,243 @@ class PDFCore extends PDF_PageGroupCore
* @param object $order Order
* @param string $mode Download or display (optional)
*/
public static function invoice($order, $mode = 'D', $multiple = false, &$pdf = NULL, $slip = false, $delivery = false, $multi = false, $tri = false, $expe48 = false)
public static function invoice($order, $mode = 'D', $multiple = false, &$pdf = NULL, $slip = false, $delivery = false, $multi = false, $tri = false, $expe48 = false, $gift = false)
{
global $cookie;
if (!Validate::isLoadedObject($order) OR (!$cookie->id_employee AND (!OrderState::invoiceAvailable($order->getCurrentState()) AND !$order->invoice_number)))
die('Invalid order or invalid order state');
if($gift && $order->gift == 1) {
self::invoiceWithoutPrice($order, $mode = 'D', $multiple, $pdf, $slip, $delivery, $multi, $tri, $expe48);
} else {
self::$order = $order;
self::$orderSlip = $slip;
self::$delivery = $delivery;
self::$_iso = strtoupper(Language::getIsoById((int)(self::$order->id_lang)));
if ((self::$_priceDisplayMethod = $order->getTaxCalculationMethod()) === false)
die(self::l('No price display method defined for the customer group'));
if (!$multiple)
$pdf = new PDF('P', 'mm', 'A4');
$pdf->SetAutoPageBreak(true, 35);
$pdf->StartPageGroup();
self::$currency = Currency::getCurrencyInstance((int)(self::$order->id_currency));
$pdf->AliasNbPages();
$pdf->AddPage();
$width = 100;
$pdf->SetX(10);
$pdf->SetY(25);
$pdf->SetFont(self::fontname(), '', 12);
$pdf->Cell($width, 10, self::l('Delivery'), 0, 'L');
$pdf->Cell($width, 10, self::l('Invoicing'), 0, 'L');
$pdf->Ln(5);
$pdf->SetFont(self::fontname(), '', 9);
$addressType = array(
'delivery' => array(),
'invoice' => array(),
);
$patternRules = array(
'optional' => array(
'address2',
'company'),
'avoid' => array(
'State:iso_code'));
$addressType = self::generateHeaderAddresses($pdf, $order, $addressType, $patternRules, $width);
if (Configuration::get('VATNUMBER_MANAGEMENT') AND !empty($addressType['invoice']['addressObject']->vat_number))
{
$vat_delivery = '';
if ($addressType['invoice']['addressObject']->id != $addressType['delivery']['addressObject']->id)
$vat_delivery = $addressType['delivery']['addressObject']->vat_number;
$pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $vat_delivery), 0, 'L');
$pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $addressType['invoice']['addressObject']->vat_number), 0, 'L');
$pdf->Ln(5);
}
if ($addressType['invoice']['addressObject']->dni != NULL)
$pdf->Cell($width, 10,
self::l('Tax ID number:').' '.Tools::iconv('utf-8', self::encoding(),
$addressType['invoice']['addressObject']->dni), 0, 'L');
/*
* display order information
*/
$carrier = new Carrier(self::$order->id_carrier);
if ($carrier->name == '0')
$carrier->name = Configuration::get('PS_SHOP_NAME');
$history = self::$order->getHistory(self::$order->id_lang);
foreach($history as $h)
if ($h['id_order_state'] == Configuration::get('PS_OS_SHIPPING'))
$shipping_date = $h['date_add'];
$pdf->Ln(12);
$pdf->SetFillColor(240, 240, 240);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont(self::fontname(), '', 9);
if (self::$orderSlip)
$pdf->Cell(0, 6, self::l('SLIP #').' '.sprintf('%06d', self::$orderSlip->id).' '.self::l('from') . ' ' .Tools::displayDate(self::$orderSlip->date_upd, self::$order->id_lang), 1, 2, 'L', 1);
elseif (self::$delivery)
$pdf->Cell(0, 6, self::l('DELIVERY SLIP #').Tools::iconv('utf-8', self::encoding(), Configuration::get('PS_DELIVERY_PREFIX', (int)($cookie->id_lang))).sprintf('%06d', self::$delivery).' '.self::l('from') . ' ' .Tools::displayDate(self::$order->delivery_date, self::$order->id_lang), 1, 2, 'L', 1);
elseif ((int)self::$order->invoice_date)
$pdf->Cell(0, 6, self::l('INVOICE #').' '.Tools::iconv('utf-8', self::encoding(), Configuration::get('PS_INVOICE_PREFIX', (int)($cookie->id_lang))).sprintf('%06d', self::$order->invoice_number).' '.self::l('from') . ' ' .Tools::displayDate(self::$order->invoice_date, self::$order->id_lang), 1, 2, 'L', 1);
else
$pdf->Cell(0, 6, self::l('Invoice draft'), 1, 2, 'L', 1);
$pdf->Cell(55, 6, self::l('Order #').' '.sprintf('%06d', self::$order->id), 'L', 0);
$pdf->Cell(70, 6, self::l('Carrier:'), 'L');
$pdf->Cell(0, 6, self::l('Payment method:'), 'LR');
$pdf->Ln(5);
$pdf->Cell(55, 6, (isset($shipping_date) ? self::l('Shipping date:').' '.Tools::displayDate($shipping_date, self::$order->id_lang) : ' '), 'LB', 0);
$pdf->Cell(70, 6, Tools::iconv('utf-8', self::encoding(), $carrier->name), 'LRB');
$pdf->Cell(0, 6, Tools::iconv('utf-8', self::encoding(), $order->payment), 'LRB');
$pdf->Ln(15);
$pdf->ProdTab((self::$delivery ? true : ''), $tri);
/* Canada */
$taxable_address = new Address((int)self::$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
if (!self::$delivery && strtoupper(Country::getIsoById((int)$taxable_address->id_country)) == 'CA')
{
$pdf->Ln(15);
$taxToDisplay = Db::getInstance()->ExecuteS('SELECT * FROM '._DB_PREFIX_.'order_tax WHERE id_order = '.(int)self::$order->id);
foreach ($taxToDisplay AS $t)
{
$pdf->Cell(0, 6, utf8_decode($t['tax_name']).' ('.number_format($t['tax_rate'], 2, '.', '').'%) '.self::convertSign(Tools::displayPrice($t['amount'], self::$currency, true)), 0, 0, 'R');
$pdf->Ln(5);
}
}
/* End */
/* Exit if delivery */
if (!self::$delivery)
{
if (!self::$orderSlip)
$pdf->DiscTab();
$priceBreakDown = array();
$pdf->priceBreakDownCalculation($priceBreakDown);
if (!self::$orderSlip OR (self::$orderSlip AND self::$orderSlip->shipping_cost))
{
$priceBreakDown['totalWithoutTax'] += Tools::ps_round($priceBreakDown['shippingCostWithoutTax'], 2) + Tools::ps_round($priceBreakDown['wrappingCostWithoutTax'], 2);
$priceBreakDown['totalWithTax'] += self::$order->total_shipping + self::$order->total_wrapping;
}
if (!self::$orderSlip)
{
$taxDiscount = self::$order->getTaxesAverageUsed();
if ($taxDiscount != 0)
$priceBreakDown['totalWithoutTax'] -= Tools::ps_round(self::$order->total_discounts / (1 + self::$order->getTaxesAverageUsed() * 0.01), 2);
else
$priceBreakDown['totalWithoutTax'] -= self::$order->total_discounts;
$priceBreakDown['totalWithTax'] -= self::$order->total_discounts;
}
/*
* Display price summation
*/
if (Configuration::get('PS_TAX') OR $order->total_products_wt != $order->total_products)
{
$pdf->Ln(5);
$pdf->SetFont(self::fontname(), 'B', 8);
$width = 165;
$pdf->Cell($width, 0, self::l('Total products (tax excl.)').' : ', 0, 0, 'R');
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithoutTax'], self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
$pdf->SetFont(self::fontname(), 'B', 8);
$width = 165;
$pdf->Cell($width, 0, self::l('Total products (tax incl.)').' : ', 0, 0, 'R');
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithTax'], self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
}
else
{
$pdf->Ln(5);
$pdf->SetFont(self::fontname(), 'B', 8);
$width = 165;
$pdf->Cell($width, 0, self::l('Total products ').' : ', 0, 0, 'R');
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithoutTax'], self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
}
if (!self::$orderSlip AND self::$order->total_discounts != '0.00')
{
$pdf->Cell($width, 0, self::l('Total discounts (tax incl.)').' : ', 0, 0, 'R');
$pdf->Cell(0, 0, (!self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice(self::$order->total_discounts, self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
}
if (isset(self::$order->total_wrapping) and ((float)(self::$order->total_wrapping) > 0))
{
$pdf->Cell($width, 0, self::l('Total gift-wrapping').' : ', 0, 0, 'R');
if (self::$_priceDisplayMethod == PS_TAX_EXC)
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['wrappingCostWithoutTax'], self::$currency, true)), 0, 0, 'R');
else
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice(self::$order->total_wrapping, self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
}
if (self::$order->total_shipping != '0.00' AND (!self::$orderSlip OR (self::$orderSlip AND self::$orderSlip->shipping_cost)))
{
$pdf->Cell($width, 0, self::l('Total shipping').' : ', 0, 0, 'R');
if (self::$_priceDisplayMethod == PS_TAX_EXC)
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice(Tools::ps_round($priceBreakDown['shippingCostWithoutTax'], 2), self::$currency, true)), 0, 0, 'R');
else
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice(self::$order->total_shipping, self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
}
if (Configuration::get('PS_TAX') OR $order->total_products_wt != $order->total_products)
{
$pdf->Cell($width, 0, self::l('Total').' '.(self::$_priceDisplayMethod == PS_TAX_EXC ? self::l(' (tax incl.)') : self::l(' (tax excl.)')).' : ', 0, 0, 'R');
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice((self::$_priceDisplayMethod == PS_TAX_EXC ? $priceBreakDown['totalWithTax'] : $priceBreakDown['totalWithoutTax']), self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
$pdf->Cell($width, 0, self::l('Total').' '.(self::$_priceDisplayMethod == PS_TAX_EXC ? self::l(' (tax excl.)') : self::l(' (tax incl.)')).' : ', 0, 0, 'R');
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice((self::$_priceDisplayMethod == PS_TAX_EXC ? $priceBreakDown['totalWithoutTax'] : $priceBreakDown['totalWithTax']), self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
}
else
{
$pdf->Cell($width, 0, self::l('Total').' : ', 0, 0, 'R');
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice(($priceBreakDown['totalWithoutTax']), self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
}
$pdf->TaxTab($priceBreakDown);
if($multi) {
$pdf->Ln(15);
$pdf->SetFont(self::fontname(), 'B', 10);
$pdf->Cell(190, 0, Tools::iconv('utf-8', self::encoding(), 'Commande expédiée partiellement') , 0, 0, 'C');
}
if ($expe48) {
$pdf->Ln(15);
$pdf->SetFont(self::fontname(), '', 7);
$pdf->Cell(190, 0, Tools::iconv('utf-8', self::encoding(), 'Produit expédié sous 48h, si la commande comprend dautres articles, ceux-ci arriveront dans les délais indiqués lors de lachat') , 0, 0, 'L');
}
}
Hook::PDFInvoice($pdf, self::$order->id);
if (!$multiple)
return $pdf->Output(sprintf('%06d', self::$order->id).'.pdf', $mode);
}
}
/**
* invoiceWithoutPrice
*
* @param object $order Order
* @param string $mode Download or display (optional)
*/
public static function invoiceWithoutPrice($order, $mode = 'D', $multiple = false, &$pdf = NULL, $slip = false, $delivery = false, $multi = false, $tri = false, $expe48 = false)
{
global $cookie;
@ -650,16 +886,14 @@ class PDFCore extends PDF_PageGroupCore
$pdf->Cell(0, 6, self::l('Invoice draft'), 1, 2, 'L', 1);
$pdf->Cell(55, 6, self::l('Order #').' '.sprintf('%06d', self::$order->id), 'L', 0);
$pdf->Cell(70, 6, self::l('Carrier:').($order->gift ? ' '.Tools::iconv('utf-8', self::encoding(), $carrier->name) : ''), 'L');
$pdf->Cell(70, 6, self::l('Carrier:'), 'L');
$pdf->Cell(0, 6, self::l('Payment method:'), 'LR');
$pdf->Ln(5);
$pdf->Cell(55, 6, (isset($shipping_date) ? self::l('Shipping date:').' '.Tools::displayDate($shipping_date, self::$order->id_lang) : ' '), 'LB', 0);
$pdf->Cell(70, 6, ($order->gift ? self::l('Gift-wrapped order') : Tools::iconv('utf-8', self::encoding(), $carrier->name)), 'LRB');
$pdf->Cell(0, 6, Tools::iconv('utf-8', self::encoding(), $order->payment), 'LRB');
$pdf->Cell(70, 6, Tools::iconv('utf-8', self::encoding(), $carrier->name), 'LRB');
$pdf->Cell(0, 6, self::l('--'), 'LRB');
$pdf->Ln(15);
$pdf->ProdTab((self::$delivery ? true : ''), $tri);
$pdf->ProdTab(true, $tri,true);
/* Canada */
$taxable_address = new Address((int)self::$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
@ -678,99 +912,11 @@ class PDFCore extends PDF_PageGroupCore
/* Exit if delivery */
if (!self::$delivery)
{
if (!self::$orderSlip)
$pdf->DiscTab();
$priceBreakDown = array();
$pdf->priceBreakDownCalculation($priceBreakDown);
if (!self::$orderSlip OR (self::$orderSlip AND self::$orderSlip->shipping_cost))
{
$priceBreakDown['totalWithoutTax'] += Tools::ps_round($priceBreakDown['shippingCostWithoutTax'], 2) + Tools::ps_round($priceBreakDown['wrappingCostWithoutTax'], 2);
$priceBreakDown['totalWithTax'] += self::$order->total_shipping + self::$order->total_wrapping;
if(!empty(self::$order->gift_message)) {
$pdf->Ln(15);
$pdf->SetFont(self::fontname(), 'B', 10);
$pdf->Cell(190, 0, Tools::iconv('utf-8', self::encoding(), self::$order->gift_message) , 0, 0, 'C');
}
if (!self::$orderSlip)
{
$taxDiscount = self::$order->getTaxesAverageUsed();
if ($taxDiscount != 0)
$priceBreakDown['totalWithoutTax'] -= Tools::ps_round(self::$order->total_discounts / (1 + self::$order->getTaxesAverageUsed() * 0.01), 2);
else
$priceBreakDown['totalWithoutTax'] -= self::$order->total_discounts;
$priceBreakDown['totalWithTax'] -= self::$order->total_discounts;
}
/*
* Display price summation
*/
if (Configuration::get('PS_TAX') OR $order->total_products_wt != $order->total_products)
{
$pdf->Ln(5);
$pdf->SetFont(self::fontname(), 'B', 8);
$width = 165;
$pdf->Cell($width, 0, self::l('Total products (tax excl.)').' : ', 0, 0, 'R');
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithoutTax'], self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
$pdf->SetFont(self::fontname(), 'B', 8);
$width = 165;
$pdf->Cell($width, 0, self::l('Total products (tax incl.)').' : ', 0, 0, 'R');
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithTax'], self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
}
else
{
$pdf->Ln(5);
$pdf->SetFont(self::fontname(), 'B', 8);
$width = 165;
$pdf->Cell($width, 0, self::l('Total products ').' : ', 0, 0, 'R');
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithoutTax'], self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
}
if (!self::$orderSlip AND self::$order->total_discounts != '0.00')
{
$pdf->Cell($width, 0, self::l('Total discounts (tax incl.)').' : ', 0, 0, 'R');
$pdf->Cell(0, 0, (!self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice(self::$order->total_discounts, self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
}
if (isset(self::$order->total_wrapping) and ((float)(self::$order->total_wrapping) > 0))
{
$pdf->Cell($width, 0, self::l('Total gift-wrapping').' : ', 0, 0, 'R');
if (self::$_priceDisplayMethod == PS_TAX_EXC)
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['wrappingCostWithoutTax'], self::$currency, true)), 0, 0, 'R');
else
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice(self::$order->total_wrapping, self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
}
if (self::$order->total_shipping != '0.00' AND (!self::$orderSlip OR (self::$orderSlip AND self::$orderSlip->shipping_cost)))
{
$pdf->Cell($width, 0, self::l('Total shipping').' : ', 0, 0, 'R');
if (self::$_priceDisplayMethod == PS_TAX_EXC)
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice(Tools::ps_round($priceBreakDown['shippingCostWithoutTax'], 2), self::$currency, true)), 0, 0, 'R');
else
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice(self::$order->total_shipping, self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
}
if (Configuration::get('PS_TAX') OR $order->total_products_wt != $order->total_products)
{
$pdf->Cell($width, 0, self::l('Total').' '.(self::$_priceDisplayMethod == PS_TAX_EXC ? self::l(' (tax incl.)') : self::l(' (tax excl.)')).' : ', 0, 0, 'R');
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice((self::$_priceDisplayMethod == PS_TAX_EXC ? $priceBreakDown['totalWithTax'] : $priceBreakDown['totalWithoutTax']), self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
$pdf->Cell($width, 0, self::l('Total').' '.(self::$_priceDisplayMethod == PS_TAX_EXC ? self::l(' (tax excl.)') : self::l(' (tax incl.)')).' : ', 0, 0, 'R');
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice((self::$_priceDisplayMethod == PS_TAX_EXC ? $priceBreakDown['totalWithoutTax'] : $priceBreakDown['totalWithTax']), self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
}
else
{
$pdf->Cell($width, 0, self::l('Total').' : ', 0, 0, 'R');
$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice(($priceBreakDown['totalWithoutTax']), self::$currency, true)), 0, 0, 'R');
$pdf->Ln(4);
}
$pdf->TaxTab($priceBreakDown);
if($multi) {
$pdf->Ln(15);
$pdf->SetFont(self::fontname(), 'B', 10);
@ -779,9 +925,9 @@ class PDFCore extends PDF_PageGroupCore
if ($expe48) {
$pdf->Ln(15);
$pdf->SetFont(self::fontname(), '', 7);
$pdf->Cell(190, 0, Tools::iconv('utf-8', self::encoding(), 'Produit expédié sous 48h, si la commande comprend dautres articles, ceux-ci arriveront dans les délais indiqués lors de lachat') , 0, 0, 'L');
$pdf->Cell(190, 0, Tools::iconv('utf-8', self::encoding(), 'Produit expédié sous 48h, si la commande comprend dautres articles, ceux-ci arriveront dans les délais indiqués lors de lachat') , 0, 0, 'L');
}
}
Hook::PDFInvoice($pdf, self::$order->id);
@ -824,7 +970,7 @@ class PDFCore extends PDF_PageGroupCore
/**
* Product table with price, quantities...
*/
public function ProdTab($delivery = false)
public function ProdTab($delivery = false, $tri=false, $gift=false)
{
if (!$delivery)
$w = array(100, 15, 30, 15, 30);
@ -849,7 +995,7 @@ class PDFCore extends PDF_PageGroupCore
$line = 0;
foreach($products AS $product)
if (!$delivery OR ((int)($product['product_quantity']) - (int)($product['product_quantity_refunded']) > 0))
if ((!$delivery || ($delivery && $gift)) || ((int)($product['product_quantity']) - (int)($product['product_quantity_refunded']) > 0))
{
if ($counter >= $lines)
{

View File

@ -3369,6 +3369,77 @@ a.link-anticon:hover{
color: #483e93!important;
}
/** button bootstrap */
.btn {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 14px;
font-weight: 400;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
}
.btn.focus, .btn:focus, .btn:hover {
color: #333;
text-decoration: none;
}
.btn-default {
color: #333;
background-color: #fff;
border-color: #ccc;
}
.btn-default:hover {
color: #333;
background-color: #e6e6e6;
border-color: #adadad;
}
.btn-default.focus,
.btn-default:focus {
color: #333;
background-color: #e6e6e6;
border-color: #8c8c8c;
}
.btn-bbb{
box-shadow: none;
text-align: center;
color: #504d8b;
border: 1px solid #ddd;
background-color: #fafafa;
font-size: 12px;
}
.btn-bbb:hover {
color: #504d8b;
background: #f4f4f4;
border-color: #8c8c8c;
}
.btn-bbb.focus,
.btn-bbb:focus {
color: #504d8b;
background: #f4f4f4;
border-color: #8c8c8c;
}
.btn-group-xs>.btn, .btn-xs {
padding: 1px 5px;
font-size: 12px;
line-height: 1.5;
border-radius: 3px;
}
button.btn, html input.btn{
cursor: pointer;
}
/** CustomerThread **/
form.form-subject-message{
width: 320px;
@ -3651,7 +3722,8 @@ form.form-forward-message .button:focus{
background-color: #F1F1F1;
}
#form_customer_thread table table,
.table.customerThread-table {
.table.customerThread-table,
#form_admin_invoice .table {
width: 100%;
border: 1px solid #565485;
background: #fff;
@ -3670,6 +3742,7 @@ form.form-forward-message .button:focus{
}
#form_customer_thread table table tr th,
.tab_customer_thread table tr th,
#form_admin_invoice .table tr th,
.table.customerThread-table tr th {
background: rgba(86,84,133,0.9);
color: #fff;
@ -3677,6 +3750,7 @@ form.form-forward-message .button:focus{
}
#form_customer_thread table table tr td,
.tab_customer_thread table tr td,
#form_admin_invoice .table tr td,
.table.customerThread-table tr td {
border-bottom: 1px solid #DEDEDE;
color: #000;

View File

@ -66,60 +66,60 @@ $(document).ready( function() {
$('.color_pick').click(function () {
displayExpressCheckoutShortcut();
});
{/literal}
{if isset($paypal_authorization)}
{literal}
/* 1.5 One page checkout*/
// var qty = $('.qty-field.cart_quantity_input').val();
// $('.qty-field.cart_quantity_input').after(qty);
// $('.qty-field.cart_quantity_input, .cart_total_bar, .cart_quantity_delete, #cart_voucher *').remove();
var br = $('.cart > a').prev();
br.prev().remove();
br.remove();
$('.cart.ui-content > a').remove();
var gift_fieldset = $('#gift_div').prev();
var gift_title = gift_fieldset.prev();
$('#gift_div, #gift_mobile_div').remove();
gift_fieldset.remove();
gift_title.remove();
// $('#gift_div, #gift_mobile_div').remove();
// gift_fieldset.remove();
// gift_title.remove();
{/literal}
{/if}
{if isset($paypal_confirmation)}
{literal}
$('#container_express_checkout').hide();
$('#cgv').live('click', function() {
if ($('#cgv:checked').length != 0)
$(location).attr('href', '{/literal}{$paypal_confirmation}{literal}');
});
// old jQuery compatibility
$('#cgv').click(function() {
if ($('#cgv:checked').length != 0)
$(location).attr('href', '{/literal}{$paypal_confirmation}{literal}');
});
{/literal}
{else if isset($paypal_order_opc)}
{literal}
$('#cgv').live('click', function() {
if ($('#cgv:checked').length != 0)
checkOrder();
});
// old jQuery compatibility
$('#cgv').click(function() {
if ($('#cgv:checked').length != 0)
checkOrder();
});
{/literal}
{/if}
{literal}
@ -135,7 +135,7 @@ $(document).ready( function() {
{literal}
var fullPath = baseDirPP + modulePath + subFolder;
var confirmTimer = false;
if ($('form[target="hss_iframe"]').length == 0) {
if ($('select[name^="group_"]').length > 0)
displayExpressCheckoutShortcut();