diff --git a/admin-dev/themes/default/template/controllers/orders/_customized_data.tpl b/admin-dev/themes/default/template/controllers/orders/_customized_data.tpl
index f0be3dac4..83a011448 100755
--- a/admin-dev/themes/default/template/controllers/orders/_customized_data.tpl
+++ b/admin-dev/themes/default/template/controllers/orders/_customized_data.tpl
@@ -109,11 +109,29 @@
{else}
{displayPrice price=Tools::ps_round($product['product_price_wt'] * $customization['quantity'], 2) currency=$currency->id}
{/if}
+
+
+
+
+
+ {if ((!$order->hasBeenDelivered() OR Configuration::get('PS_ORDER_RETURN')) AND (int)($customization['quantity_returned']) < (int)($customization['quantity']))}
+ = $product['product_quantity'])}disabled="disabled" {/if}/>
+ {else}
+ --
+ {/if}
+ |
+
+ {if ($customization['quantity_returned'] + $customization['quantity_refunded'] >= $customization['quantity'])}
+
+ {elseif (!$order->hasBeenDelivered() OR Configuration::get('PS_ORDER_RETURN'))}
+ 0/{$customization['quantity']-$customization['quantity_refunded']}
+ {/if}
|
- {l s='Quantity:'} 0/{$customization['quantity']-$product['product_quantity_refunded']}
- {l s='Amount:'} €
- |
+ {l s='Quantity:'}
+ 0/{$customization['quantity']-$customization['quantity_refunded']}
+
+ {l s='Amount:'}
{$currency->prefix}{$currency->suffix}
|
|
diff --git a/admin-dev/themes/default/template/controllers/orders/form.tpl b/admin-dev/themes/default/template/controllers/orders/form.tpl
index ff504f15b..08b7fa45c 100755
--- a/admin-dev/themes/default/template/controllers/orders/form.tpl
+++ b/admin-dev/themes/default/template/controllers/orders/form.tpl
@@ -652,7 +652,7 @@
cart_content += (!this.id_customization ? '' : '');
cart_content += ''+this.total+' | ';
- if (this.id_customization)
+ if (this.id_customization != 0)
{
$.each(this.customized_datas[this.id_product][this.id_product_attribute][id_address_delivery], function() {
var customized_desc = '';
@@ -678,6 +678,7 @@
});
}
});
+
$.each(gifts, function() {
cart_content += ' | '+this.name+' '+this.attributes_small+' | '+this.reference+' | ';
cart_content += '{l s='Gift !'} | '+this.cart_quantity+' | {l s='Gift !'} |
';
diff --git a/classes/Cart.php b/classes/Cart.php
index 66af2dfea..7c258a1ed 100644
--- a/classes/Cart.php
+++ b/classes/Cart.php
@@ -1523,7 +1523,7 @@ class CartCore extends ObjectModel
$in_order = true;
if ($in_order)
- $order_total_discount += $cart_rule['obj']->getContextualValue($with_taxes, null, CartRule::FILTER_ACTION_GIFT, $package, $use_cache);
+ $order_total_discount += $cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_GIFT, $package, $use_cache);
}
// If the cart rule offers a reduction, the amount is prorated (with the products in the package)
diff --git a/classes/CartRule.php b/classes/CartRule.php
index 007d22789..24118ac50 100644
--- a/classes/CartRule.php
+++ b/classes/CartRule.php
@@ -1112,7 +1112,10 @@ class CartRuleCore extends ObjectModel
*/
public static function isFeatureActive()
{
- return (bool)Configuration::get('PS_CART_RULE_FEATURE_ACTIVE');
+ static $is_feature_active = null;
+ if ($is_feature_active === null)
+ $is_feature_active = (bool)Configuration::get('PS_CART_RULE_FEATURE_ACTIVE');
+ return $is_feature_active;
}
/* When an entity associated to a product rule (product, category, attribute, supplier, manufacturer...) is deleted, the product rules must be updated */
diff --git a/classes/Configuration.php b/classes/Configuration.php
index 1a6ac61bd..0d63e10f9 100644
--- a/classes/Configuration.php
+++ b/classes/Configuration.php
@@ -164,9 +164,9 @@ class ConfigurationCore extends ObjectModel
if ($id_shop && Configuration::hasKey($key, $id_lang, null, $id_shop))
return self::$_CONF[$id_lang]['shop'][$id_shop][$key];
- else if ($id_shop_group && Configuration::hasKey($key, $id_lang, $id_shop_group))
+ elseif ($id_shop_group && Configuration::hasKey($key, $id_lang, $id_shop_group))
return self::$_CONF[$id_lang]['group'][$id_shop_group][$key];
- else if (Configuration::hasKey($key, $id_lang))
+ elseif (Configuration::hasKey($key, $id_lang))
return self::$_CONF[$id_lang]['global'][$key];
return false;
}
@@ -231,7 +231,7 @@ class ConfigurationCore extends ObjectModel
$id_lang = (int)$id_lang;
if ($id_shop)
return isset(self::$_CONF[$id_lang]['shop'][$id_shop]) && array_key_exists($key, self::$_CONF[$id_lang]['shop'][$id_shop]);
- else if ($id_shop_group)
+ elseif ($id_shop_group)
return isset(self::$_CONF[$id_lang]['group'][$id_shop_group]) && array_key_exists($key, self::$_CONF[$id_lang]['group'][$id_shop_group]);
return isset(self::$_CONF[$id_lang]['global']) && array_key_exists($key, self::$_CONF[$id_lang]['global']);
}
diff --git a/classes/Currency.php b/classes/Currency.php
index ed77d731e..3eb02a81d 100644
--- a/classes/Currency.php
+++ b/classes/Currency.php
@@ -410,7 +410,7 @@ class CurrencyCore extends ObjectModel
public static function getCurrencyInstance($id)
{
- if (!array_key_exists($id, self::$currencies))
+ if (!isset(self::$currencies[$id]))
self::$currencies[(int)($id)] = new Currency($id);
return self::$currencies[(int)($id)];
}
diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php
index ec589093c..8b3964ffe 100644
--- a/classes/ObjectModel.php
+++ b/classes/ObjectModel.php
@@ -210,8 +210,8 @@ abstract class ObjectModelCore
// Get shop informations
if (Shop::isTableAssociated($this->def['table']))
$sql->leftJoin($this->def['table'].'_shop', 'c', 'a.'.$this->def['primary'].' = c.'.$this->def['primary'].' AND c.id_shop = '.(int)$this->id_shop);
-
- Cache::store($cache_id, ObjectModel::$db->getRow($sql));
+ if ($row = ObjectModel::$db->getRow($sql))
+ Cache::store($cache_id, $row);
}
$result = Cache::retrieve($cache_id);
diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php
index 57d2adfd5..fb5d44ba8 100644
--- a/classes/order/OrderInvoice.php
+++ b/classes/order/OrderInvoice.php
@@ -381,7 +381,7 @@ class OrderInvoiceCore extends ObjectModel
public function getEcoTaxTaxesBreakdown()
{
$res = Db::getInstance()->executeS('
- SELECT `ecotax_tax_rate` as `rate`, SUM(`ecotax`) as `ecotax_tax_excl`, SUM(`ecotax`) as `ecotax_tax_incl`, `product_quantity`
+ SELECT `ecotax_tax_rate` as `rate`, SUM(`ecotax` * `product_quantity`) as `ecotax_tax_excl`, SUM(`ecotax` * `product_quantity`) as `ecotax_tax_incl`
FROM `'._DB_PREFIX_.'order_detail`
WHERE `id_order` = '.(int)$this->id_order.'
AND `id_order_invoice` = '.(int)$this->id.'
@@ -391,8 +391,8 @@ class OrderInvoiceCore extends ObjectModel
if ($res)
foreach ($res as &$row)
{
- $row['ecotax_tax_incl'] = Tools::ps_round(($row['ecotax_tax_excl'] * $row['product_quantity']) + ($row['ecotax_tax_excl'] * $row['product_quantity'] * $row['rate'] / 100), 2);
- $row['ecotax_tax_excl'] = Tools::ps_round($row['ecotax_tax_excl'] * $row['product_quantity'], 2);
+ $row['ecotax_tax_incl'] = Tools::ps_round($row['ecotax_tax_excl'] + ($row['ecotax_tax_excl'] * $row['rate'] / 100), 2);
+ $row['ecotax_tax_excl'] = Tools::ps_round($row['ecotax_tax_excl'], 2);
}
return $res;
}
diff --git a/classes/order/OrderSlip.php b/classes/order/OrderSlip.php
index 98e03dcd7..e94adfb89 100644
--- a/classes/order/OrderSlip.php
+++ b/classes/order/OrderSlip.php
@@ -296,5 +296,26 @@ class OrderSlipCore extends ObjectModel
Db::getInstance()->insert('order_slip_detail', $insertOrderSlip);
}
}
+
+ public function getEcoTaxTaxesBreakdown()
+ {
+ $ecotax_detail = array();
+ foreach ($this->getOrdersSlipDetail((int)$this->id) as $order_slip_details)
+ {
+ $row = Db::getInstance()->getRow('
+ SELECT `ecotax_tax_rate` as `rate`, `ecotax` as `ecotax_tax_excl`, `ecotax` as `ecotax_tax_incl`, `product_quantity`
+ FROM `'._DB_PREFIX_.'order_detail`
+ WHERE `id_order_detail` = '.(int)$order_slip_details['id_order_detail']
+ );
+
+ if (!isset($ecotax_detail[$row['rate']]))
+ $ecotax_detail[$row['rate']] = array('ecotax_tax_incl' => 0, 'ecotax_tax_excl' => 0, 'rate' => $row['rate']);
+
+ $ecotax_detail[$row['rate']]['ecotax_tax_incl'] += Tools::ps_round(($row['ecotax_tax_excl'] * $order_slip_details['product_quantity']) + ($row['ecotax_tax_excl'] * $order_slip_details['product_quantity'] * $row['rate'] / 100), 2);
+ $ecotax_detail[$row['rate']]['ecotax_tax_excl'] += Tools::ps_round($row['ecotax_tax_excl'] * $order_slip_details['product_quantity'], 2);
+ }
+
+ return $ecotax_detail;
+ }
}
diff --git a/classes/pdf/HTMLTemplateOrderSlip.php b/classes/pdf/HTMLTemplateOrderSlip.php
index a19ac7302..f0aa42af0 100644
--- a/classes/pdf/HTMLTemplateOrderSlip.php
+++ b/classes/pdf/HTMLTemplateOrderSlip.php
@@ -154,6 +154,7 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
'product_tax_breakdown' => $this->getProductTaxesBreakdown(),
'shipping_tax_breakdown' => $this->getShippingTaxesBreakdown(),
'order' => $this->order,
+ 'ecotax_tax_breakdown' => $this->order_slip->getEcoTaxTaxesBreakdown(),
'is_order_slip' => true
));
@@ -205,8 +206,17 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
}
$tmp_tax_infos[(string)number_format($tax_rate, 3)] = $infos;
}
-
}
+
+ // Delete ecotax from the total
+ $ecotax = $this->order_slip->getEcoTaxTaxesBreakdown();
+ if ($ecotax)
+ foreach ($tmp_tax_infos as $rate => &$row)
+ {
+ $row['total_price_tax_excl'] -= $ecotax[$rate]['ecotax_tax_excl'];
+ $row['total_amount'] -= ($ecotax[$rate]['ecotax_tax_incl'] - $ecotax[$rate]['ecotax_tax_excl']);
+ }
+
return $tmp_tax_infos;
}
diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php
index f56b71ba1..271eab8a3 100644
--- a/controllers/admin/AdminImportController.php
+++ b/controllers/admin/AdminImportController.php
@@ -873,7 +873,7 @@ class AdminImportControllerCore extends AdminController
$category->parent = $cat_moved[$category->parent];
$category->id_parent = $category->parent;
}
- else if (isset($category->parent) && is_string($category->parent))
+ elseif (isset($category->parent) && is_string($category->parent))
{
$category_parent = Category::searchByName($default_language_id, $category->parent, true);
if ($category_parent['id_category'])
diff --git a/pdf/invoice.tax-tab.tpl b/pdf/invoice.tax-tab.tpl
index 4cf26c89c..74da3b8d7 100755
--- a/pdf/invoice.tax-tab.tpl
+++ b/pdf/invoice.tax-tab.tpl
@@ -30,8 +30,6 @@
{if $tax_exempt}
{l s='Exempt of VAT according section 259B of the General Tax Code.' pdf='true'}
- {else if (count($shipping_tax_breakdown) + count($product_tax_breakdown) + count($ecotax_tax_breakdown) + count($wrapping_tax_breakdown) == 0)}
- {l s='No tax' pdf='true'}
{else}
diff --git a/pdf/order-slip.tpl b/pdf/order-slip.tpl
index b5bc5283a..91cb908fc 100755
--- a/pdf/order-slip.tpl
+++ b/pdf/order-slip.tpl
@@ -107,25 +107,33 @@
- {displayPrice currency=$order->id_currency price=$order_detail.total_price_tax_incl}
- {foreach $order_detail.customizedDatas as $customization}
-
-
- {foreach $customization.datas as $customization_types}
-
- {foreach $customization_types as $customization_infos name=custo_foreach}
- {$customization_infos.name}: {$customization_infos.value}
- {if !$smarty.foreach.custo_foreach.last}
- {else}
-
- {/if}
+ {foreach $order_detail.customizedDatas as $customizationPerAddress}
+ {foreach $customizationPerAddress as $customizationId => $customization}
+
+
+ {foreach $customization.datas as $customization_types}
+
+ {if isset($customization.datas[$smarty.const._CUSTOMIZE_TEXTFIELD_]) && count($customization.datas[$smarty.const._CUSTOMIZE_TEXTFIELD_]) > 0}
+ {foreach $customization.datas[$smarty.const._CUSTOMIZE_TEXTFIELD_] as $customization_infos}
+ {$customization_infos.name}: {$customization_infos.value}
+ {if !$smarty.foreach.custo_foreach.last}
+ {else}
+
+ {/if}
+ {/foreach}
+ {/if}
+
+ {if isset($customization.datas[$smarty.const._CUSTOMIZE_FILE_]) && count($customization.datas[$smarty.const._CUSTOMIZE_FILE_]) > 0}
+ {count($customization.datas[$smarty.const._CUSTOMIZE_FILE_])} {l s='image(s)' pdf='true'}
+ {/if}
+
{/foreach}
-
- {/foreach}
- |
- |
- ({$customization.quantity}) |
- |
-
+ |
+ |
+ ({$customization.quantity}) |
+ |
+
+ {/foreach}
{/foreach}
{/foreach}
|