[-] Core: Fix cache issue and order slip pdf generation

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@17902 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rGaillard committed 2012-10-22 12:40:15 +00:00
1 parent 6c09e8328d
commit 20ac37e6bb
13 files changed
+96 -37

No files matched your search

@@ -109,11 +109,29 @@
{else} {else}
{displayPrice price=Tools::ps_round($product['product_price_wt'] * $customization['quantity'], 2) currency=$currency->id} {displayPrice price=Tools::ps_round($product['product_price_wt'] * $customization['quantity'], 2) currency=$currency->id}
{/if} {/if}
</td>
<td align="center" class="cancelCheck standard_refund_fields current-edit" style="display:none">
<input type="hidden" name="totalQtyReturn" id="totalQtyReturn" value="{$customization['quantity_returned']}" />
<input type="hidden" name="totalQty" id="totalQty" value="{$customization['quantity']}" />
<input type="hidden" name="productName" id="productName" value="{$product['product_name']}" />
{if ((!$order->hasBeenDelivered() OR Configuration::get('PS_ORDER_RETURN')) AND (int)($customization['quantity_returned']) < (int)($customization['quantity']))}
<input type="checkbox" name="id_order_detail[{$product['id_order_detail']}]" id="id_order_detail[{$product['id_order_detail']}]" value="{$product['id_order_detail']}" onchange="setCancelQuantity(this, {$product['id_order_detail']}, {$customization['quantity'] - $product['customizationQuantityTotal'] - $product['product_quantity_reinjected']})" {if ($product['product_quantity_return'] + $product['product_quantity_refunded'] >= $product['product_quantity'])}disabled="disabled" {/if}/>
{else}
--
{/if}
</td>
<td class="cancelQuantity standard_refund_fields current-edit" style="display:none">
{if ($customization['quantity_returned'] + $customization['quantity_refunded'] >= $customization['quantity'])}
<input type="hidden" name="cancelQuantity[{$product['id_order_detail']}]" value="0" />
{elseif (!$order->hasBeenDelivered() OR Configuration::get('PS_ORDER_RETURN'))}
<input type="text" id="cancelQuantity_{$product['id_order_detail']}" name="cancelQuantity[{$product['id_order_detail']}]" size="2" onclick="selectCheckbox(this);" value="" />0/{$customization['quantity']-$customization['quantity_refunded']}
{/if}
</td> </td>
<td class="partial_refund_fields current-edit" style="text-align:left;display:none"> <td class="partial_refund_fields current-edit" style="text-align:left;display:none">
<div style="width:40%;margin-top:5px;float:left">{l s='Quantity:'}</div> <div style="width:60%;margin-top:2px;float:left"><input type="text" size="3" name="partialRefundProductQuantity[{$k}]" value="0" /> 0/{$customization['quantity']-$product['product_quantity_refunded']}</div> <div style="width:40%;margin-top:5px;float:left">{l s='Quantity:'}</div> <div style="width:60%;margin-top:2px;float:left"><input type="text" size="3" name="partialRefundProductQuantity[{$product['id_order_detail']}]" value="0" />
<div style="width:40%;margin-top:5px;float:left">{l s='Amount:'}</div> <div style="width:60%;margin-top:2px;float:left"><input type="text" size="3" name="partialRefundProduct[{$k}]" /> &euro;</div> 0/{$customization['quantity']-$customization['quantity_refunded']}
</td> </div>
<div style="width:40%;margin-top:5px;float:left">{l s='Amount:'}</div> <div style="width:60%;margin-top:2px;float:left">{$currency->prefix}<input type="text" size="3" name="partialRefundProduct[{$product['id_order_detail']}]" />{$currency->suffix}</div>
<td class="edit_product_fields" colspan="2" style="display:none"></td> <td class="edit_product_fields" colspan="2" style="display:none"></td>
<td class="product_action" style="text-align:right"> <td class="product_action" style="text-align:right">
</td> </td>
@@ -652,7 +652,7 @@
cart_content += (!this.id_customization ? '<div style="float:left;"><input type="text" rel="'+this.id_product+'_'+this.id_product_attribute+'_'+(this.id_customization ? this.id_customization : 0)+'" class="cart_quantity" size="2" value="'+this.cart_quantity+'" />' : ''); cart_content += (!this.id_customization ? '<div style="float:left;"><input type="text" rel="'+this.id_product+'_'+this.id_product_attribute+'_'+(this.id_customization ? this.id_customization : 0)+'" class="cart_quantity" size="2" value="'+this.cart_quantity+'" />' : '');
cart_content += (!this.id_customization ? '<a href="#" class="delete_product" rel="delete_'+this.id_product+'_'+this.id_product_attribute+'_'+(this.id_customization ? this.id_customization : 0)+'" ><img src="../img/admin/delete.gif" /></a></div>' : ''); cart_content += (!this.id_customization ? '<a href="#" class="delete_product" rel="delete_'+this.id_product+'_'+this.id_product_attribute+'_'+(this.id_customization ? this.id_customization : 0)+'" ><img src="../img/admin/delete.gif" /></a></div>' : '');
cart_content += '</td><td>'+this.total+'&nbsp;<span class="currency_sign"></span></td></tr>'; cart_content += '</td><td>'+this.total+'&nbsp;<span class="currency_sign"></span></td></tr>';
if (this.id_customization) if (this.id_customization != 0)
{ {
$.each(this.customized_datas[this.id_product][this.id_product_attribute][id_address_delivery], function() { $.each(this.customized_datas[this.id_product][this.id_product_attribute][id_address_delivery], function() {
var customized_desc = ''; var customized_desc = '';
@@ -678,6 +678,7 @@
}); });
} }
}); });
$.each(gifts, function() { $.each(gifts, function() {
cart_content += '<tr><td><img src="'+this.image_link+'" title="'+this.name+'" /></td><td>'+this.name+'<br />'+this.attributes_small+'</td><td>'+this.reference+'</td>'; cart_content += '<tr><td><img src="'+this.image_link+'" title="'+this.name+'" /></td><td>'+this.name+'<br />'+this.attributes_small+'</td><td>'+this.reference+'</td>';
cart_content += '<td>{l s='Gift !'}</td><td>'+this.cart_quantity+'</td><td>{l s='Gift !'}</td></tr>'; cart_content += '<td>{l s='Gift !'}</td><td>'+this.cart_quantity+'</td><td>{l s='Gift !'}</td></tr>';
+1 -1
View File
@@ -1523,7 +1523,7 @@ class CartCore extends ObjectModel
$in_order = true; $in_order = true;
if ($in_order) 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) // If the cart rule offers a reduction, the amount is prorated (with the products in the package)
+4 -1
View File
@@ -1112,7 +1112,10 @@ class CartRuleCore extends ObjectModel
*/ */
public static function isFeatureActive() 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 */ /* When an entity associated to a product rule (product, category, attribute, supplier, manufacturer...) is deleted, the product rules must be updated */
+3 -3
View File
@@ -164,9 +164,9 @@ class ConfigurationCore extends ObjectModel
if ($id_shop && Configuration::hasKey($key, $id_lang, null, $id_shop)) if ($id_shop && Configuration::hasKey($key, $id_lang, null, $id_shop))
return self::$_CONF[$id_lang]['shop'][$id_shop][$key]; 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]; 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 self::$_CONF[$id_lang]['global'][$key];
return false; return false;
} }
@@ -231,7 +231,7 @@ class ConfigurationCore extends ObjectModel
$id_lang = (int)$id_lang; $id_lang = (int)$id_lang;
if ($id_shop) if ($id_shop)
return isset(self::$_CONF[$id_lang]['shop'][$id_shop]) && array_key_exists($key, self::$_CONF[$id_lang]['shop'][$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]['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']); return isset(self::$_CONF[$id_lang]['global']) && array_key_exists($key, self::$_CONF[$id_lang]['global']);
} }
+1 -1
View File
@@ -410,7 +410,7 @@ class CurrencyCore extends ObjectModel
public static function getCurrencyInstance($id) public static function getCurrencyInstance($id)
{ {
if (!array_key_exists($id, self::$currencies)) if (!isset(self::$currencies[$id]))
self::$currencies[(int)($id)] = new Currency($id); self::$currencies[(int)($id)] = new Currency($id);
return self::$currencies[(int)($id)]; return self::$currencies[(int)($id)];
} }
+2 -2
View File
@@ -210,8 +210,8 @@ abstract class ObjectModelCore
// Get shop informations // Get shop informations
if (Shop::isTableAssociated($this->def['table'])) 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); $sql->leftJoin($this->def['table'].'_shop', 'c', 'a.'.$this->def['primary'].' = c.'.$this->def['primary'].' AND c.id_shop = '.(int)$this->id_shop);
if ($row = ObjectModel::$db->getRow($sql))
Cache::store($cache_id, ObjectModel::$db->getRow($sql)); Cache::store($cache_id, $row);
} }
$result = Cache::retrieve($cache_id); $result = Cache::retrieve($cache_id);
+3 -3
View File
@@ -381,7 +381,7 @@ class OrderInvoiceCore extends ObjectModel
public function getEcoTaxTaxesBreakdown() public function getEcoTaxTaxesBreakdown()
{ {
$res = Db::getInstance()->executeS(' $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` FROM `'._DB_PREFIX_.'order_detail`
WHERE `id_order` = '.(int)$this->id_order.' WHERE `id_order` = '.(int)$this->id_order.'
AND `id_order_invoice` = '.(int)$this->id.' AND `id_order_invoice` = '.(int)$this->id.'
@@ -391,8 +391,8 @@ class OrderInvoiceCore extends ObjectModel
if ($res) if ($res)
foreach ($res as &$row) 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_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'] * $row['product_quantity'], 2); $row['ecotax_tax_excl'] = Tools::ps_round($row['ecotax_tax_excl'], 2);
} }
return $res; return $res;
} }
+21
View File
@@ -296,5 +296,26 @@ class OrderSlipCore extends ObjectModel
Db::getInstance()->insert('order_slip_detail', $insertOrderSlip); 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;
}
} }
+11 -1
View File
@@ -154,6 +154,7 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
'product_tax_breakdown' => $this->getProductTaxesBreakdown(), 'product_tax_breakdown' => $this->getProductTaxesBreakdown(),
'shipping_tax_breakdown' => $this->getShippingTaxesBreakdown(), 'shipping_tax_breakdown' => $this->getShippingTaxesBreakdown(),
'order' => $this->order, 'order' => $this->order,
'ecotax_tax_breakdown' => $this->order_slip->getEcoTaxTaxesBreakdown(),
'is_order_slip' => true 'is_order_slip' => true
)); ));
@@ -205,8 +206,17 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
} }
$tmp_tax_infos[(string)number_format($tax_rate, 3)] = $infos; $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; return $tmp_tax_infos;
} }
+1 -1
View File
@@ -873,7 +873,7 @@ class AdminImportControllerCore extends AdminController
$category->parent = $cat_moved[$category->parent]; $category->parent = $cat_moved[$category->parent];
$category->id_parent = $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); $category_parent = Category::searchByName($default_language_id, $category->parent, true);
if ($category_parent['id_category']) if ($category_parent['id_category'])
-2
View File
@@ -30,8 +30,6 @@
<td style="width: 80%"> <td style="width: 80%">
{if $tax_exempt} {if $tax_exempt}
{l s='Exempt of VAT according section 259B of the General Tax Code.' pdf='true'} {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} {else}
<table style="width: 70%" > <table style="width: 70%" >
<tr style="line-height:5px;"> <tr style="line-height:5px;">
+26 -18
View File
@@ -107,25 +107,33 @@
- {displayPrice currency=$order->id_currency price=$order_detail.total_price_tax_incl} - {displayPrice currency=$order->id_currency price=$order_detail.total_price_tax_incl}
</td> </td>
</tr> </tr>
{foreach $order_detail.customizedDatas as $customization} {foreach $order_detail.customizedDatas as $customizationPerAddress}
<tr style="line-height:6px;background-color:{$bgcolor}; "> {foreach $customizationPerAddress as $customizationId => $customization}
<td style="line-height:3px; text-align: left; width: 60%; vertical-align: top"> <tr style="line-height:6px;background-color:{$bgcolor}; ">
{foreach $customization.datas as $customization_types} <td style="line-height:3px; text-align: left; width: 60%; vertical-align: top">
<blockquote> {foreach $customization.datas as $customization_types}
{foreach $customization_types as $customization_infos name=custo_foreach} <blockquote>
{$customization_infos.name}: {$customization_infos.value} {if isset($customization.datas[$smarty.const._CUSTOMIZE_TEXTFIELD_]) && count($customization.datas[$smarty.const._CUSTOMIZE_TEXTFIELD_]) > 0}
{if !$smarty.foreach.custo_foreach.last}<br /> {foreach $customization.datas[$smarty.const._CUSTOMIZE_TEXTFIELD_] as $customization_infos}
{else} {$customization_infos.name}: {$customization_infos.value}
<div style="line-height:0.4pt">&nbsp;</div> {if !$smarty.foreach.custo_foreach.last}<br />
{/if} {else}
<div style="line-height:0.4pt">&nbsp;</div>
{/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}
</blockquote>
{/foreach} {/foreach}
</blockquote> </td>
{/foreach} <td style="text-align: right; width: 15%"></td>
</td> <td style="text-align: center; width: 10%; vertical-align: top">({$customization.quantity})</td>
<td style="text-align: right; width: 15%"></td> <td style="width: 15%; text-align: right;"></td>
<td style="text-align: center; width: 10%; vertical-align: top">({$customization.quantity})</td> </tr>
<td style="width: 15%; text-align: right;"></td> {/foreach}
</tr>
{/foreach} {/foreach}
{/foreach} {/foreach}
</table> </table>