[-] 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
2012-10-22 12:40:15 +00:00
parent 6c09e8328d
commit 20ac37e6bb
13 changed files with 96 additions and 37 deletions
@@ -109,11 +109,29 @@
{else}
{displayPrice price=Tools::ps_round($product['product_price_wt'] * $customization['quantity'], 2) currency=$currency->id}
{/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 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='Amount:'}</div> <div style="width:60%;margin-top:2px;float:left"><input type="text" size="3" name="partialRefundProduct[{$k}]" /> &euro;</div>
</td>
<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" />
0/{$customization['quantity']-$customization['quantity_refunded']}
</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="product_action" style="text-align:right">
</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 ? '<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>';
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 += '<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>';
+1 -1
View File
@@ -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)
+4 -1
View File
@@ -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 */
+3 -3
View File
@@ -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']);
}
+1 -1
View File
@@ -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)];
}
+2 -2
View File
@@ -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);
+3 -3
View File
@@ -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;
}
+21
View File
@@ -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;
}
}
+11 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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'])
-2
View File
@@ -30,8 +30,6 @@
<td style="width: 80%">
{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}
<table style="width: 70%" >
<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}
</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">&nbsp;</div>
{/if}
{foreach $order_detail.customizedDatas as $customizationPerAddress}
{foreach $customizationPerAddress as $customizationId => $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>
{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}<br />
{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}
</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>
</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}
{/foreach}
</table>