[*] BO : #PSFV-94 - new controller for AdminOrders
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9546 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,28 @@
|
||||
{*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<div>
|
||||
<h1>{l s='Dashboard'}</h1>
|
||||
<hr style="background-color: #812143;color: #812143;" />
|
||||
|
||||
@@ -1,3 +1,28 @@
|
||||
{*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<div class="admin-box1">
|
||||
<h5>{l s='A good beginning...'}
|
||||
<span style="float:right">
|
||||
@@ -12,7 +37,7 @@
|
||||
<img src="../img/admin/{$i.image}" class="pico" />
|
||||
<a href="{$i.href}">{$i.title}</a>
|
||||
</li>
|
||||
|
||||
|
||||
{/foreach}
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -86,6 +86,8 @@
|
||||
{$tr.$key}
|
||||
{elseif isset($params.type) && $params.type == 'datetime'}
|
||||
{$tr.$key}
|
||||
{elseif isset($params.callback)}
|
||||
{$tr.$key}
|
||||
{elseif isset($tr.$key)}
|
||||
{$tr.$key|escape:'htmlall':'UTF-8'}
|
||||
{else}
|
||||
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
{*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
|
||||
{if ($product.customizedDatas)}
|
||||
<tr>
|
||||
<td align="center">{if ($product.image->id)}{$product.image_tag}{else}'--'{/if}</td>
|
||||
<td><a href="index.php?tab=AdminCatalog&id_product={$product['product_id']}&updateproduct&token={getAdminToken tab='AdminCatalog'}">
|
||||
<span class="productName">{$product['product_name']} - {l s='customized'}</span><br />
|
||||
{if ($product['product_reference'])}{l s='Ref:'} {$product['product_reference']}<br />{/if}
|
||||
{if ($product['product_supplier_reference'])}{l s='Ref Supplier:'} {$product['product_supplier_reference']}{/if}
|
||||
.'</a></td>
|
||||
<td align="center">{displayPrice price=$product['product_price_wt'] currency=$currency->id}</td>
|
||||
<td align="center" class="productQuantity">{$product['customizationQuantityTotal']}</td>
|
||||
{if ($order->hasBeenPaid())}<td align="center" class="productQuantity">{$product['customizationQuantityRefunded']}</td>{/if}
|
||||
{if ($order->hasBeenDelivered())}<td align="center" class="productQuantity">{$product['customizationQuantityReturned']}</td>{/if}
|
||||
<td align="center" class="productQuantity"> - </td>
|
||||
<td align="center">
|
||||
{if ($order->getTaxCalculationMethod() == PS_TAX_EXC)}
|
||||
{displayPrice price=Tools::ps_round($product['product_price'] * $product['customizationQuantityTotal'], 2) currency=$currency->id}
|
||||
{else}
|
||||
{displayPrice price=Tools::ps_round($product['product_price_wt'] * $product['customizationQuantityTotal'], 2) currency=$currency->id}
|
||||
{/if}
|
||||
</td>
|
||||
<td align="center" class="cancelCheck">--</td>
|
||||
</tr>
|
||||
{foreach from=$product.customizedDatas key=customizationId item=customization}
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
{foreach from=$customization.datas key=type item=datas}
|
||||
{if ($type == Product::CUSTOMIZE_FILE)}
|
||||
<ul style="margin: 4px 0px 4px 0px; padding: 0px; list-style-type: none;">
|
||||
{foreach from=$datas item=data}
|
||||
<li style="display: inline; margin: 2px;">
|
||||
<a href="displayImage.php?img={$data['value']}&name={$order->id}-file{$data@iteration}" target="_blank"><img src="'{$smarty.const._THEME_PROD_PIC_DIR_}{$data['value']}_small" alt="" /></a>
|
||||
</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
{elseif ($type == Product::CUSTOMIZE_TEXTFIELD)}
|
||||
<ul style="margin: 0px 0px 4px 0px; padding: 0px 0px 0px 6px; list-style-type: none;">
|
||||
{foreach from=$datas item=data}
|
||||
<li>{if $data['name']}{$data['name']}{else}{l s='Text #'}{$data@iteration}{/if}{l s=':'} {$data['value']}</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</td>
|
||||
<td align="center">-</td>
|
||||
<td align="center" class="productQuantity">{$customization['quantity']}</td>
|
||||
{if ($order->hasBeenPaid())}<td align="center">{$customization['quantity_refunded']}</td>{/if}
|
||||
{if ($order->hasBeenDelivered())}<td align="center">{$customization['quantity_returned']}</td>{/if}
|
||||
<td align="center">-</td>
|
||||
<td align="center">
|
||||
{if ($order->getTaxCalculationMethod() == PS_TAX_EXC)}
|
||||
{displayPrice price=Tools::ps_round($product['product_price'] * $customization['quantity'], 2) currency=$currency->id}
|
||||
{else}
|
||||
{displayPrice price=Tools::ps_round($product['product_price_wt'] * $customization['quantity'], 2) currency=$currency->id}
|
||||
{/if}
|
||||
</td>
|
||||
<td align="center" class="cancelCheck">
|
||||
<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')) && (int)(($customization['quantity_returned']) < (int)($customization['quantity'])))}
|
||||
<input type="checkbox" name="id_customization[{$customizationId}]" id="id_customization[{$customizationId}]" value="{$product['id_order_detail']}" onchange="setCancelQuantity(this, '{$customizationId}', '{$customization['quantity']}')" '.{if (($customization['quantity_returned'] + $customization['quantity_refunded']) >= $customization['quantity'])}disabled="disabled"{/if} />
|
||||
{else}
|
||||
--
|
||||
{/if}
|
||||
</td>
|
||||
<td class="cancelQuantity">
|
||||
{if (($customization['quantity_returned'] + $customization['quantity_refunded']) >= $customization['quantity'])}
|
||||
<input type="hidden" name="cancelCustomizationQuantity[{$customizationId}]" value="0" />
|
||||
{elseif (!$order->hasBeenDelivered() || Configuration::get('PS_ORDER_RETURN'))}
|
||||
<input type="text" id="cancelQuantity_{$customizationId}" name="cancelCustomizationQuantity[{$customizationId}]" size="2" onclick="selectCheckbox(this);" value="" />
|
||||
{/if}
|
||||
{if ($order->hasBeenDelivered())}
|
||||
{$customization['quantity_returned']}/{$customization['quantity']-$customization['quantity_refunded']}
|
||||
{elseif ($order->hasBeenPaid())}
|
||||
{$customization['quantity_returned']}/{$customization['quantity']}
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
{/if}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
{*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
|
||||
{* Assign product price *}
|
||||
{if ($order->getTaxCalculationMethod() == PS_TAX_EXC)}
|
||||
{assign var=product_price value=($product['product_price'] + $product['ecotax'])}
|
||||
{else}
|
||||
{assign var=product_price value=$product['product_price_wt']}
|
||||
{/if}
|
||||
|
||||
{if ($product['product_quantity'] > $product['customizationQuantityTotal'])}
|
||||
<tr{if ($product.image->id && isset($product.image_size))} height="{$product['image_size'][1] + 7}"{/if}>
|
||||
<td align="center">{if $product.image->id}{$product.image_tag}{/if}</td>
|
||||
<td><a href="index.php?tab=AdminCatalog&id_product={$product['product_id']}&updateproduct&token={getAdminToken tab='AdminCatalog'}">
|
||||
<span class="productName">{$product['product_name']}</span><br />
|
||||
{if $product.product_reference}{l s='Ref:'} {$product.product_reference}<br />{/if}
|
||||
{if $product.product_supplier_reference}{l s='Ref Supplier:'} {$product.product_supplier_reference}{/if}
|
||||
</a></td>
|
||||
<td align="center">{displayPrice price=$product_price currency=$currency->id}</td>
|
||||
<td align="center" class="productQuantity" {if ($product['product_quantity'] > 1)}style="font-weight:700;font-size:1.1em;color:red"{/if}>{$product['product_quantity']}</td>
|
||||
{if ($order->hasBeenPaid())}<td align="center" class="productQuantity">{$product['product_quantity_refunded']}</td>{/if}
|
||||
{if ($order->hasBeenDelivered())}<td align="center" class="productQuantity">{$product['product_quantity_return']}</td>{/if}
|
||||
<td align="center" class="productQuantity">{StockManagerFactory::getManager()->getProductRealQuantities($product['product_id'], $product['product_attribute_id'], null, true)}</td>
|
||||
<td align="center">{displayPrice price=(Tools::ps_round($product_price, 2) * ($product['product_quantity'] - $product['customizationQuantityTotal'])) currency=$currency->id}</td>
|
||||
<td align="center" class="cancelCheck">
|
||||
<input type="hidden" name="totalQtyReturn" id="totalQtyReturn" value="{$product['product_quantity_return']}" />
|
||||
<input type="hidden" name="totalQty" id="totalQty" value="{$product['product_quantity']}" />
|
||||
<input type="hidden" name="productName" id="productName" value="{$product['product_name']}" />
|
||||
{if ((!$order->hasBeenDelivered() OR Configuration::get('PS_ORDER_RETURN')) AND (int)($product['product_quantity_return']) < (int)($product['product_quantity']))}
|
||||
<input type="checkbox" name="id_order_detail[{$k}]" id="id_order_detail[{$k}]" value="{$product['id_order_detail']}" onchange="setCancelQuantity(this, {$product['id_order_detail']}, {$product['product_quantity_in_stock'] - $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">
|
||||
{if ($product['product_quantity_return'] + $product['product_quantity_refunded'] >= $product['product_quantity'])}
|
||||
<input type="hidden" name="cancelQuantity[{$k}]" value="0" />
|
||||
{elseif (!$order->hasBeenDelivered() OR Configuration::get('PS_ORDER_RETURN'))}
|
||||
<input type="text" id="cancelQuantity_{$product['id_order_detail']}" name="cancelQuantity[{$k}]" size="2" onclick="selectCheckbox(this);" value="" />
|
||||
{/if}
|
||||
|
||||
{if $product['customizationQuantityTotal']}
|
||||
{assign var=productQuantity value=($product['product_quantity']-$product['customizationQuantityTotal'])}
|
||||
{else}
|
||||
{assign var=productQuantity value=$product['product_quantity']}
|
||||
{/if}
|
||||
|
||||
{if ($order->hasBeenDelivered())}
|
||||
{$product['product_quantity_refunded']}/{$productQuantity-$product['product_quantity_refunded']}
|
||||
{elseif ($order->hasBeenPaid())}
|
||||
{$product['product_quantity_return']}/{$productQuantity}
|
||||
{else}
|
||||
0/{$productQuantity}
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
Executable
+458
@@ -0,0 +1,458 @@
|
||||
{*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
|
||||
<script type="text/javascript">
|
||||
{literal}
|
||||
function showWarehouseList()
|
||||
{
|
||||
{/literal}{if (count($warehouse_list) > 1)}{literal}
|
||||
$('#warehouse').show();
|
||||
{/literal}{/if}{literal}
|
||||
}
|
||||
|
||||
function hideWarehouseList()
|
||||
{
|
||||
$('#warehouse').hide();
|
||||
}
|
||||
hideWarehouseList();
|
||||
{/literal}
|
||||
</script>
|
||||
|
||||
{if ($order->total_paid != $order->total_paid_real)}
|
||||
<center><span class="warning" style="font-size: 16px">{l s='Warning:'} {displayPrice price=$order->total_paid_real currency=$currency->id} {l s='paid instead of'} {displayPrice price=$order->total_paid currency=$currency->id} !</span></center><div class="clear"><br /><br /></div>
|
||||
{/if}
|
||||
|
||||
{if ($HOOK_INVOICE)}
|
||||
<div style="float: right; margin: -40px 40px 10px 0;">{$HOOK_INVOICE}</div><br class="clear" />';
|
||||
{/if}
|
||||
|
||||
<div style="float:left" style="width:440px">
|
||||
<h2>
|
||||
{if $previousOrder}<a href="{$currentIndex}&token={$smarty.get.token}&vieworder&id_order={$previousOrder}"><img style="width:24px;height:24px" src="../img/admin/arrow-left.png" /></a>{/if}
|
||||
{if ($customer->id)}{$customer->firstname} {$customer->lastname} - {/if}{l s='Order #'}{"%06d"|sprintf:$order->id}
|
||||
{if $nextOrder}<a href="{$currentIndex}&token={$smarty.get.token}&vieworder&id_order={$nextOrder}"><img style="width:24px;height:24px" src="../img/admin/arrow-right.png" /></a>{/if}
|
||||
</h2>
|
||||
<div style="width:429px">
|
||||
{if (($currentState->invoice || $order->invoice_number) && count($products))}
|
||||
<a href="pdf.php?id_order={$order->id}&pdf"><img src="../img/admin/charged_ok.gif" alt="{l s='View invoice'}" /> {l s='View invoice'}</a>
|
||||
{else}
|
||||
<img src="../img/admin/charged_ko.gif" alt="{l s='No invoice'}" /> {l s='No invoice'}
|
||||
{/if}
|
||||
-
|
||||
{if ($currentState->delivery || $order->delivery_number)}
|
||||
<a href="pdf.php?id_delivery={$order->delivery_number}"><img src="../img/admin/delivery.gif" alt="{l s='View delivery slip'}" /> {l s='View delivery slip'}</a>
|
||||
{else}
|
||||
<img src="../img/admin/delivery_ko.gif" alt="{l s='No delivery slip'}" /> {l s='No delivery slip'}
|
||||
{/if}
|
||||
-
|
||||
<a href="javascript:window.print()"><img src="../img/admin/printer.gif" alt="{l s='Print order'}" title="{l s='Print order'}" /> {l s='Print order'}</a>
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
|
||||
<table cellspacing="0" cellpadding="0" class="table" style="width: 429px">
|
||||
{foreach from=$history item=row key=key}
|
||||
{if ($key == 0)}
|
||||
<tr>
|
||||
<th>{dateFormat date=$row['date_add'] full=true}</th>
|
||||
<th><img src="../img/os/{$row['id_order_state']}.gif" /></th>
|
||||
<th>{$row['ostate_name']|stripslashes}</th>
|
||||
<th>{if $row['employee_lastname']}{$row['employee_firstname']|stripslashes} {$row['employee_lastname']|stripslashes}{/if}</th>
|
||||
</tr>
|
||||
{else}
|
||||
<tr class="{if ($key % 2)}alt_row{/if}">
|
||||
<td>{dateFormat date=$row['date_add'] full=true}</td>
|
||||
<td><img src="../img/os/{$row['id_order_state']}.gif" /></td>
|
||||
<td>{$row['ostate_name']|stripslashes}</td>
|
||||
<td>{if $row['employee_lastname']}{$row['employee_firstname']|stripslashes} {$row['employee_lastname']|stripslashes}{/if}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</table>
|
||||
<br />
|
||||
|
||||
<form action="{$currentIndex}&viewOrder&token={$smarty.get.token}" method="post" style="text-align:center;">
|
||||
<select name="id_order_state">
|
||||
{foreach from=$states item=state}
|
||||
<option onclick="{if (!$currentState->shipped && $state['shipped'])}showWarehouseList(){else}hideWarehouseList(){/if}" value="{$state['id_order_state']}" {if $state['id_order_state'] == $currentState->id}selected="selected"{/if}>{$state['name']|stripslashes}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<select name="id_warehouse" id="warehouse">
|
||||
{foreach from=$warehouse_list item=warehouse}
|
||||
<option value="{$warehouse['id_warehouse']}">{$warehouse['name']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<input type="hidden" name="id_order" value="{$order->id}" />
|
||||
<input type="submit" name="submitState" value="{l s='Change'}" class="button" />
|
||||
</form>
|
||||
|
||||
{if $customer->id}
|
||||
<br />
|
||||
<fieldset style="width: 400px">
|
||||
<legend><img src="../img/admin/tab-customers.gif" /> {l s='Customer information'}</legend>
|
||||
<span style="font-weight: bold; font-size: 14px;"><a href="?tab=AdminCustomers&id_customer={$customer->id}&viewcustomer&token={getAdminToken tab='AdminCustomers'}"> {$customer->firstname} {$customer->lastname}</a></span> ({l s='#'}{$customer->id})<br />
|
||||
(<a href="mailto:{$customer->email}">{$customer->email}</a>)<br /><br />
|
||||
{if ($customer->isGuest())}
|
||||
{l s='This order has been placed by a'} <b>{l s='guest'}</b>
|
||||
{if (!Customer::customerExists($customer->email))}
|
||||
<form method="POST" action="index.php?tab=AdminCustomers&id_customer={$customer->id}&token={getAdminToken tab='AdminCustomers'}">
|
||||
<input type="hidden" name="id_lang" value="{$order->id_lang}" />
|
||||
<p class="center"><input class="button" type="submit" name="submitGuestToCustomer" value="{l s='Transform to customer'}" /></p>
|
||||
{l s='This feature will generate a random password and send an e-mail to the customer'}
|
||||
</form>
|
||||
{else}
|
||||
<div><b style="color:red;">{l s='A registered customer account exists with the same email address'}</b></div>
|
||||
{/if}
|
||||
{else}
|
||||
{l s='Account registered:'} <b>{dateFormat date=$customer->date_add full=true}</b><br />
|
||||
{l s='Valid orders placed:'} <b>{$customerStats['nb_orders']}</b><br />
|
||||
{l s='Total paid since registration:'} <b>{displayPrice price=Tools::ps_round(Tools::convertPrice($customerStats['total_orders'], $currency), 2) currency=$currency->id}</b><br />
|
||||
</fieldset>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{if (sizeof($sources))}
|
||||
<br />
|
||||
<fieldset style="width: 400px;">
|
||||
<legend><img src="../img/admin/tab-stats.gif" /> {l s='Sources'}</legend>
|
||||
<ul {if sizeof($sources) > 3}style="height: 200px; overflow-y: scroll; width: 360px;"{/if}>
|
||||
{foreach from=$sources item=source}
|
||||
<li>
|
||||
{dateFormat date=$source['date_add'] full=true}<br />
|
||||
<b>{l s='From:'}</b> <a href="{$source['http_referer']}">{parse_url($source['http_referer'], PHP_URL_HOST)|regex_replace:'/^www./':''}</a><br />
|
||||
<b>{l s='To:'}</b> {$source['request_uri']}<br />
|
||||
{if $source['keywords']}<b>{l s='Keywords:'}</b> {$source['keywords']}<br />{/if}<br />
|
||||
</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</fieldset>
|
||||
{/if}
|
||||
|
||||
{if $HOOK_ADMIN_ORDER}
|
||||
{$HOOK_ADMIN_ORDER}
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
<div style="float: left; margin-left: 40px">
|
||||
<fieldset style="width: 400px">
|
||||
{if (($currentState->invoice OR $order->invoice_number) AND count($products))}
|
||||
<legend><a href="pdf.php?id_order={$order->id}&pdf"><img src="../img/admin/charged_ok.gif" /> {l s='Invoice'}</a></legend>
|
||||
<a href="pdf.php?id_order={$order->id}&pdf">{l s='Invoice #'}<b>{$PS_INVOICE_PREFIX}{"%06d"|sprintf:$order->invoice_number}</b></a>
|
||||
<br />{l s='Created on:'} {dateFormat date=$order->invoice_date full=true}
|
||||
{else}
|
||||
<legend><img src="../img/admin/charged_ko.gif" /> {l s='Invoice'}</legend>
|
||||
{l s='No invoice yet.'}
|
||||
{/if}
|
||||
</fieldset>
|
||||
<br />
|
||||
|
||||
<fieldset style="width:400px">
|
||||
<legend><img src="../img/admin/delivery.gif" /> {l s='Shipping information'}</legend>
|
||||
{l s='Total weight:'} <b>{$order->getTotalWeight()|string_format:"%.3f"} {$PS_WEIGHT_UNIT}</b><br />
|
||||
{l s='Carrier:'} <b>{if $carrier->name == '0'}{$PS_SHOP_NAME}{else}{$carrier->name}{/if}</b><br />
|
||||
|
||||
{if ($currentState->delivery || $order->delivery_number)}
|
||||
<br /><a href="pdf.php?id_delivery={$order->delivery_number}">{l s='Delivery slip #'}<b>{$PS_DELIVERY_PREFIX}{"%06d"|sprintf:$order->delivery_number}</b></a><br />
|
||||
{/if}
|
||||
|
||||
{if $order->shipping_number}
|
||||
{l s='Tracking number:'} <b>{$order->shipping_number}</b>
|
||||
{if $carrier->url}
|
||||
<a href="{$carrier->url|replace:'@':$order->shipping_number}" target="_blank">{l s='Track the shipment'}</a>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{if $carrierModuleCall}
|
||||
{$carrierModuleCall}
|
||||
{/if}
|
||||
|
||||
{if ($carrier->url && $order->hasBeenShipped())}
|
||||
<form action="{$currentIndex}&viewOrder&token={$smarty.get.token}" method="post" style="margin-top:10px;">
|
||||
<input type="text" name="shipping_number" value="{$order->shipping_number}" />
|
||||
<input type="hidden" name="id_order" value="{$order->id}" />
|
||||
<input type="submit" name="submitShippingNumber" value="{l s='Set shipping number'}" class="button" />
|
||||
</form>
|
||||
{/if}
|
||||
</fieldset>
|
||||
|
||||
<br />
|
||||
<fieldset style="width: 400px">
|
||||
<legend><img src="../img/admin/details.gif" /> {l s='Order details'}</legend>
|
||||
{if (Shop::isFeatureActive())}
|
||||
<label>{l s='Shop:'}</label>
|
||||
<div style="margin: 2px 0 1em 190px;">{Shop::getInstance($order->id_shop)->name}</div>
|
||||
{/if}
|
||||
|
||||
<label>{l s='Original cart:'}</label>
|
||||
<div style="margin: 2px 0 1em 190px;"><a href="?tab=AdminCarts&id_cart={$cart->id}&viewcart&token={getAdminToken tab='AdminCarts'}">{l s='Cart #'}{"%06d"|sprintf:$cart->id}</a></div>
|
||||
<label>{l s='Payment mode:'}</label>
|
||||
<div style="margin: 2px 0 1em 190px;">{substr($order->payment, 0, 32)}{if $order->module} ({$order->module}){/if}</div>
|
||||
<div style="margin: 2px 0 1em 50px;">
|
||||
<table class="table" width="300px;" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td width="150px;">{l s='Products'}</td>
|
||||
<td align="right">{displayPrice price=$order->getTotalProductsWithTaxes() currency=$currency->id}</td>
|
||||
</tr>
|
||||
{if $order->total_discounts > 0}
|
||||
<tr>
|
||||
<td>{l s='Discounts'}</td>
|
||||
<td align="right">-{displayPrice price=$order->total_discounts currency=$currency->id}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
{if $order->total_wrapping > 0}
|
||||
<tr>
|
||||
<td>{l s='Wrapping'}</td>
|
||||
<td align="right">{displayPrice price=$order->total_wrapping currency=$currency->id}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<td>{l s='Shipping'}</td>
|
||||
<td align="right">{displayPrice price=$order->total_shipping currency=$currency->id}</td>
|
||||
</tr>
|
||||
<tr style="font-size: 20px">
|
||||
<td>{l s='Total'}</td>
|
||||
<td align="right">
|
||||
{displayPrice price=$order->total_paid currency=$currency->id}
|
||||
{if $order->total_paid != $order->total_paid_real}
|
||||
<br />
|
||||
<font color="red">{l s='Paid:'} {displayPrice price=$order->total_paid_real currency=$currency->id}</font>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div style="float: left; margin-right: 10px; margin-left: 42px;">
|
||||
<span class="bold">{l s='Recycled package:'}</span>
|
||||
{if $order->recyclable}
|
||||
<img src="../img/admin/enabled.gif" />
|
||||
{else}
|
||||
<img src="../img/admin/disabled.gif" />
|
||||
{/if}
|
||||
</div>
|
||||
<div style="float: left; margin-right: 10px;">
|
||||
<span class="bold">{l s='Gift wrapping:'}</span>
|
||||
{if $order->gift}
|
||||
<img src="../img/admin/enabled.gif" />
|
||||
</div>
|
||||
<div style="clear: left; margin: 0px 42px 0px 42px; padding-top: 2px;">
|
||||
{if $order->gift_message}
|
||||
<div style="border: 1px dashed #999; padding: 5px; margin-top: 8px;"><b>{l s='Message:'}</b><br />{$order->gift_message|nl2br}</div>
|
||||
{/if}
|
||||
{else}
|
||||
<img src="../img/admin/disabled.gif" />
|
||||
{/if}
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
|
||||
<div class="clear"> </div>
|
||||
<div style="float: left">
|
||||
<fieldset style="width: 400px;">
|
||||
<legend><img src="../img/admin/delivery.gif" alt="{l s='Shipping address'}" />{l s='Shipping address'}</legend>
|
||||
<div style="float: right">
|
||||
<a href="?tab=AdminAddresses&id_address={$addresses.delivery->id}&addaddress&realedit=1&id_order={$order->id}{if ($addresses.delivery->id == $addresses.invoice->id)}&address_type=1{/if}&token={getAdminToken tab='AdminAddresses'}&back={$smarty.server.REQUEST_URI}"><img src="../img/admin/edit.gif" /></a>
|
||||
<a href="http://maps.google.com/maps?f=q&hl={$iso_code_lang}&geocode=&q={$addresses.delivery->address1} {$addresses.delivery->postcode} {$addresses.delivery->city} {if ($addresses.delivery->id_state)} {$addresses.deliveryState->name}{/if}" target="_blank"><img src="../img/admin/google.gif" alt="" class="middle" /></a>
|
||||
</div>
|
||||
{displayAddressDetail address=$addresses.delivery newLine='<br />'}
|
||||
{if $addresses.delivery->other}<hr />{$addresses.delivery->other}<br />{/if}
|
||||
</fieldset>
|
||||
</div>
|
||||
<div style="float: left; margin-left: 40px">
|
||||
<fieldset style="width: 400px;">
|
||||
<legend><img src="../img/admin/invoice.gif" alt="{l s='Invoice address'}" />{l s='Invoice address'}</legend>
|
||||
<div style="float: right"><a href="?tab=AdminAddresses&id_address={$addresses.invoice->id}&addaddress&realedit=1&id_order={$order->id}{if ($addresses.delivery->id == $addresses.invoice->id)}&address_type=2{/if}&back={$smarty.server.REQUEST_URI}&token={getAdminToken tab='AdminAddresses'}"><img src="../img/admin/edit.gif" /></a></div>
|
||||
{displayAddressDetail address=$addresses.invoice newLine='<br />'}
|
||||
{if $addresses.invoice->other}<hr />{$addresses.invoice->other}<br />{/if}
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
|
||||
<form action="{$currentIndex}&submitCreditSlip&vieworder&token={$smarty.get.token}" method="post" onsubmit="return orderDeleteProduct('{l s='Cannot return this product'}', '{l s='Quantity to cancel is greater than quantity available'}');">
|
||||
<input type="hidden" name="id_order" value="{$order->id}" />
|
||||
<fieldset style="width: 868px; ">
|
||||
<legend><img src="../img/admin/cart.gif" alt="{l s='Products'}" />{l s='Products'}</legend>
|
||||
<div style="float:left;">
|
||||
<table style="width: 868px;" cellspacing="0" cellpadding="0" class="table" id="orderProducts">
|
||||
<tr>
|
||||
<th align="center" style="width: 60px"> </th>
|
||||
<th>{l s='Product'}</th>
|
||||
<th style="width: 80px; text-align: center">{l s='UP'} <sup>*</sup></th>
|
||||
<th style="width: 20px; text-align: center">{l s='Qty'}</th>
|
||||
{if ($order->hasBeenPaid())}<th style="width: 20px; text-align: center">{l s='Refunded'}</th>{/if}
|
||||
{if ($order->hasBeenDelivered())}<th style="width: 20px; text-align: center">{l s='Returned'}</th>{/if}
|
||||
<th style="width: 30px; text-align: center">{l s='Stock'}</th>
|
||||
<th style="width: 90px; text-align: center">{l s='Total'} <sup>*</sup></th>
|
||||
<th colspan="2" style="width: 120px;"><img src="../img/admin/delete.gif" alt="{l s='Products'}" />
|
||||
{if ($order->hasBeenDelivered())}
|
||||
{l s='Return'}
|
||||
{elseif ($order->hasBeenPaid())}
|
||||
{l s='Refund'}
|
||||
{else}
|
||||
{l s='Cancel'}
|
||||
{/if}
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
{foreach from=$products item=product key=k}
|
||||
{* Include customized datas partial *}
|
||||
{include file='orders/_customized_data.tpl'}
|
||||
|
||||
{* Include product line partial *}
|
||||
{include file='orders/_product_line.tpl'}
|
||||
{/foreach}
|
||||
</table>
|
||||
|
||||
<div style="float:left; width:280px; margin-top:15px;">
|
||||
<sup>*</sup> {l s='According to the group of this customer, prices are printed:'}
|
||||
{if ($order->getTaxCalculationMethod() == PS_TAX_EXC)}
|
||||
{l s='tax excluded.'}
|
||||
{else}
|
||||
{l s='tax included.'}
|
||||
{/if}
|
||||
|
||||
{if Configuration::get('PS_ORDER_RETURN')}
|
||||
<br /><br />{l s='Merchandise returns are disabled'}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{if (sizeof($discounts))}
|
||||
<div style="float:right; width:280px; margin-top:15px;">
|
||||
<table cellspacing="0" cellpadding="0" class="table" style="width:100%;">
|
||||
<tr>
|
||||
<th><img src="../img/admin/coupon.gif" alt="{l s='Discounts'}" />{l s='Discount name'}</th>
|
||||
<th align="center" style="width: 100px">{l s='Value'}</th>
|
||||
</tr>
|
||||
{foreach from=$discounts item=discount}
|
||||
<tr>
|
||||
<td>{$discount['name']}</td>
|
||||
<td align="center">
|
||||
{if $discount['value'] != 0.00}
|
||||
-
|
||||
{/if}
|
||||
{displayPrice price=$discount['value'] currency=$currency->id}
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div style="clear:both; height:15px;"> </div>
|
||||
<div style="float: right; width: 160px;">
|
||||
{if ($order->hasBeenDelivered() && Configuration::get('PS_ORDER_RETURN'))}
|
||||
<input type="checkbox" id="reinjectQuantities" name="reinjectQuantities" class="button" /> <label for="reinjectQuantities" style="float:none; font-weight:normal;">{l s='Re-stock products'}</label><br />
|
||||
{/if}
|
||||
{if ((!$order->hasBeenDelivered() && $order->hasBeenPaid()) || ($order->hasBeenDelivered() && Configuration::get('PS_ORDER_RETURN')))}
|
||||
<input type="checkbox" id="generateCreditSlip" name="generateCreditSlip" class="button" onclick="toogleShippingCost(this)" /> <label for="generateCreditSlip" style="float:none; font-weight:normal;">{l s='Generate a credit slip'}</label><br />
|
||||
<input type="checkbox" id="generateDiscount" name="generateDiscount" class="button" onclick="toogleShippingCost(this)" /> <label for="generateDiscount" style="float:none; font-weight:normal;">{l s='Generate a voucher'}</label><br />
|
||||
<span id="spanShippingBack" style="display:none;"><input type="checkbox" id="shippingBack" name="shippingBack" class="button" /> <label for="shippingBack" style="float:none; font-weight:normal;">{l s='Repay shipping costs'}</label><br /></span>
|
||||
{/if}
|
||||
{if (!$order->hasBeenDelivered() || ($order->hasBeenDelivered() && Configuration::get('PS_ORDER_RETURN')))}
|
||||
<div style="text-align:center; margin-top:5px;">
|
||||
<input type="submit" name="cancelProduct" value="{if $order->hasBeenDelivered()}{l s='Return products'}{elseif $order->hasBeenPaid()}{l s='Refund products'}{else}{l s='Cancel products'}{/if}" class="button" style="margin-top:8px;" />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
<div class="clear" style="height:20px;"> </div>
|
||||
|
||||
<div style="float: left">
|
||||
<form action="{$smarty.server.REQUEST_URI}&token={$smarty.get.token}" method="post" onsubmit="if (getE('visibility').checked == true) return confirm('{l s='Do you want to send this message to the customer?'}');">
|
||||
<fieldset style="width: 400px;">
|
||||
<legend style="cursor: pointer;" onclick="$('#message').slideToggle();$('#message_m').slideToggle();return false"><img src="../img/admin/email_edit.gif" /> {l s='New message'}</legend>
|
||||
<div id="message_m" style="display: {if Tools::getValue('message')}none{else}block{/if}; overflow: auto; width: 400px;">
|
||||
<a href="#" onclick="$('#message').slideToggle();$('#message_m').slideToggle();return false"><b>{l s='Click here'}</b> {l s='to add a comment or send a message to the customer'}</a>
|
||||
</div>
|
||||
<div id="message" style="display: {if Tools::getValue('message')}block{else}none{/if}">
|
||||
<select name="order_message" id="order_message" onchange="orderOverwriteMessage(this, '{l s='Do you want to overwrite your existing message?'}')">
|
||||
<option value="0" selected="selected">-- {l s='Choose a standard message'} --</option>
|
||||
{foreach from=$orderMessages item=orderMessage}
|
||||
<option value="{$orderMessage['message']|escape:'htmlall':'UTF-8'}">{$orderMessage['name']}</option>
|
||||
{/foreach}
|
||||
</select><br /><br />
|
||||
<b>{l s='Display to consumer?'}</b>
|
||||
<input type="radio" name="visibility" id="visibility" value="0" /> {l s='Yes'}
|
||||
<input type="radio" name="visibility" value="1" checked="checked" /> {l s='No'}
|
||||
<p id="nbchars" style="display:inline;font-size:10px;color:#666;"></p><br /><br />
|
||||
<textarea id="txt_msg" name="message" cols="50" rows="8" onKeyUp="var length = document.getElementById('txt_msg').value.length; if (length > 600) length = '600+'; document.getElementById('nbchars').innerHTML = '{l s='600 chars max'} (' + length + ')';">{Tools::getValue('message')|escape:'htmlall':'UTF-8'}</textarea><br /><br />
|
||||
<input type="hidden" name="id_order" value="{$order->id}" />
|
||||
<input type="hidden" name="id_customer" value="{$order->id_customer}" />
|
||||
<input type="submit" class="button" name="submitMessage" value="{l s='Send'}" />
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
{if (sizeof($messages))}
|
||||
<br />
|
||||
<fieldset style="width: 400px;">
|
||||
<legend><img src="../img/admin/email.gif" /> {l s='Messages'}</legend>
|
||||
{foreach from=$messages item=message}
|
||||
<div style="overflow:auto; width:400px;" {if $message['is_new_for_me']}class="new_message"{/if}>
|
||||
{if ($message['is_new_for_me'])}
|
||||
<a class="new_message" title="{l s='Mark this message as \'viewed\''}" href="{$smarty.get.REQUEST_URI}&token={$smarty.get.token}&messageReaded={$message['id_message']}"><img src="../img/admin/enabled.gif" alt="" /></a>
|
||||
{/if}
|
||||
{l s='At'} <i>{dateFormat date=$message['date_add']}
|
||||
</i> {l s='from'} <b>{if ($message['elastname'])}{$message['efirstname']} {$message['elastname']}{else}{$message['cfirstname']} {$message['clastname']}{/if}</b>
|
||||
{if ($message['private'] == 1)}<span style="color:red; font-weight:bold;">{l s='Private:'}</span>{/if}
|
||||
<p>{$message['message']|nl2br}</p>
|
||||
</div>
|
||||
<br />
|
||||
{/foreach}
|
||||
<p class="info">{l s='When you read a message, please click on the green check.'}</p>
|
||||
</fieldset>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div style="float: left; margin-left: 40px">
|
||||
<fieldset style="width: 400px;">
|
||||
<legend><img src="../img/admin/return.gif" alt="{l s='Merchandise returns'}" />{l s='Merchandise returns'}</legend>
|
||||
{if (!sizeof($returns))}
|
||||
{l s='No merchandise return for this order.'}
|
||||
{else}
|
||||
{foreach from=$returns item=return}
|
||||
({dateFormat date=$return['date_upd']}) :
|
||||
<b><a href="index.php?tab=AdminReturn&id_order_return={$return['id_order_return']}&updateorder_return&token={getAdminToken tab='AdminReturn'}">{l s='#'}{'%06d'|sprintf:$return['id_order_return']}</a></b> -
|
||||
{$return['state_name']}<br />
|
||||
{/foreach}
|
||||
{/if}
|
||||
</fieldset>
|
||||
|
||||
<br />
|
||||
<fieldset style="width: 400px;">
|
||||
<legend><img src="../img/admin/slip.gif" alt="{l s='Credit slip'}" />{l s='Credit slip'}</legend>
|
||||
{if (!sizeof($slips))}
|
||||
{l s='No slip for this order.'}
|
||||
{else}
|
||||
{foreach from=$slips item=slip}
|
||||
({dateFormat date=$slip['date_upd']}) : <b><a href="pdf.php?id_order_slip={$slip['id_order_slip']}">{l s='#'}{'%06d'|sprintf:$slip['id_order_slip']}</a></b><br />
|
||||
{/foreach}
|
||||
{/if}
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
<br /><br /><a href="{$currentIndex}&token={$smarty.get.token}"><img src="../img/admin/arrow2.gif" /> {l s='Back to list'}</a><br />
|
||||
@@ -341,12 +341,13 @@ class AddressFormatCore extends ObjectModel
|
||||
return $tab;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Generates the full address text
|
||||
* @address is an instanciate object of Address class
|
||||
* @patternrules is a defined rules array to avoid some pattern
|
||||
* @newLine is a string containing the newLine format
|
||||
* @separator is a string containing the separator format
|
||||
* @param address is an instanciate object of Address class
|
||||
* @param patternrules is a defined rules array to avoid some pattern
|
||||
* @param newLine is a string containing the newLine format
|
||||
* @param separator is a string containing the separator format
|
||||
* @return string
|
||||
*/
|
||||
public static function generateAddress(Address $address, $patternRules = array(), $newLine = "\r\n", $separator = ' ', $style = array())
|
||||
{
|
||||
@@ -375,6 +376,17 @@ class AddressFormatCore extends ObjectModel
|
||||
return $addressText;
|
||||
}
|
||||
|
||||
public static function generateAddressSmarty($params, &$smarty)
|
||||
{
|
||||
return self::generateAddress(
|
||||
$params['address'],
|
||||
(isset($params['patternRules']) ? $params['patternRules'] : array()),
|
||||
(isset($params['newLine']) ? $params['newLine'] : "\r\n"),
|
||||
(isset($params['separator']) ? $params['separator'] : ''),
|
||||
(isset($params['style']) ? $params['style'] : array())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns selected fields required for an address in an array according to a selection hash
|
||||
* @return array String values
|
||||
|
||||
+93
-14
@@ -408,9 +408,12 @@ class OrderCore extends ObjectModel
|
||||
|
||||
public function getFirstMessage()
|
||||
{
|
||||
$sql = 'SELECT `message` FROM `'._DB_PREFIX_.'message` WHERE `id_order` = '.(int)($this->id).' ORDER BY `id_message` asc';
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||
return $result['message'];
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT `message`
|
||||
FROM `'._DB_PREFIX_.'message`
|
||||
WHERE `id_order` = '.(int)$this->id.'
|
||||
ORDER BY `id_message`
|
||||
');
|
||||
}
|
||||
|
||||
public function setProductPrices(&$row)
|
||||
@@ -478,6 +481,8 @@ class OrderCore extends ObjectModel
|
||||
if (!$products)
|
||||
$products = $this->getProductsDetail();
|
||||
|
||||
$customized_datas = Product::getAllCustomizedDatas($this->id_cart);
|
||||
|
||||
$resultArray = array();
|
||||
foreach ($products AS $row)
|
||||
{
|
||||
@@ -492,19 +497,18 @@ class OrderCore extends ObjectModel
|
||||
continue ;
|
||||
}
|
||||
|
||||
$this->setProductImageInformations($row);
|
||||
$this->setProductCurrentStock($row);
|
||||
$this->setProductPrices($row);
|
||||
$this->setProductCustomizedDatas($row, $customized_datas);
|
||||
|
||||
/* Add information for virtual product */
|
||||
// Add information for virtual product
|
||||
if ($row['download_hash'] && !empty($row['download_hash']))
|
||||
{
|
||||
if ($row['product_attribute_id'] && !empty($row['product_attribute_id']))
|
||||
{
|
||||
$row['filename'] = ProductDownload::getFilenameFromIdAttribute((int)$row['product_id'], (int)$row['product_attribute_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$row['filename'] = ProductDownload::getFilenameFromIdProduct((int)$row['product_id']);
|
||||
}
|
||||
// Get the display filename
|
||||
$row['display_filename'] = ProductDownload::getFilenameFromFilename($row['filename']);
|
||||
}
|
||||
@@ -512,9 +516,58 @@ class OrderCore extends ObjectModel
|
||||
$resultArray[(int)$row['id_order_detail']] = $row;
|
||||
}
|
||||
|
||||
if ($customized_datas)
|
||||
Product::addCustomizationPrice($resultArray, $customized_datas);
|
||||
|
||||
return $resultArray;
|
||||
}
|
||||
|
||||
protected function setProductCustomizedDatas(&$product, $customized_datas)
|
||||
{
|
||||
$product['customizedDatas'] = null;
|
||||
if (isset($customized_datas[$product['product_id']][$product['product_attribute_id']]))
|
||||
$product['customizedDatas'] = $customized_datas[$product['product_id']][$product['product_attribute_id']];
|
||||
else
|
||||
$product['customizationQuantityTotal'] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This method allow to add stock information on a product detail
|
||||
* @param array &$product
|
||||
*/
|
||||
protected function setProductCurrentStock(&$product)
|
||||
{
|
||||
$product['current_stock'] = StockManagerFactory::getManager()->getProductRealQuantities($product['product_id'], $product['product_attribute_id'], null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This method allow to add image information on a product detail
|
||||
* @param array &$product
|
||||
*/
|
||||
protected function setProductImageInformations(&$product)
|
||||
{
|
||||
if (isset($product['product_attribute_id']) && $product['product_attribute_id'])
|
||||
$id_image = Db::getInstance()->getValue('
|
||||
SELECT id_image
|
||||
FROM '._DB_PREFIX_.'product_attribute_image
|
||||
WHERE id_product_attribute = '.(int)$product['product_attribute_id']);
|
||||
|
||||
if (!isset($image['id_image']) || !$image['id_image'])
|
||||
$id_image = Db::getInstance()->getValue('
|
||||
SELECT id_image
|
||||
FROM '._DB_PREFIX_.'image
|
||||
WHERE id_product = '.(int)($product['product_id']).' AND cover = 1
|
||||
');
|
||||
|
||||
$product['image'] = null;
|
||||
$product['image_size'] = null;
|
||||
|
||||
if ($id_image)
|
||||
$product['image'] = new Image($id_image);
|
||||
}
|
||||
|
||||
public function getTaxesAverageUsed()
|
||||
{
|
||||
return Cart::getTaxesAverageUsed((int)($this->id_cart));
|
||||
@@ -772,7 +825,6 @@ class OrderCore extends ObjectModel
|
||||
return $this->total_products_wt;
|
||||
/* Retro-compatibility (now set directly on the validateOrder() method) */
|
||||
|
||||
|
||||
if (!$products)
|
||||
$products = $this->getProductsDetail();
|
||||
|
||||
@@ -1042,13 +1094,40 @@ class OrderCore extends ObjectModel
|
||||
DELETE FROM `'._DB_PREFIX_.'order_detail`
|
||||
WHERE `id_order` = '.(int)($this->id)) !== false);
|
||||
}
|
||||
|
||||
/*
|
||||
** Get the an order detail list of the current order
|
||||
*/
|
||||
|
||||
/**
|
||||
* This method return the ID of the previous order
|
||||
* @return int
|
||||
*/
|
||||
public function getPreviousOrderId()
|
||||
{
|
||||
return Db::getInstance()->getValue('
|
||||
SELECT id_order
|
||||
FROM '._DB_PREFIX_.'orders
|
||||
WHERE id_order < '.(int)$this->id.'
|
||||
ORDER BY id_order DESC');
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return the ID of the next order
|
||||
* @return int
|
||||
*/
|
||||
public function getNextOrderId()
|
||||
{
|
||||
return Db::getInstance()->getValue('
|
||||
SELECT id_order
|
||||
FROM '._DB_PREFIX_.'orders
|
||||
WHERE id_order > '.(int)$this->id.'
|
||||
ORDER BY id_order ASC');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the an order detail list of the current order
|
||||
* @return array
|
||||
*/
|
||||
public function getOrderDetailList()
|
||||
{
|
||||
return OrderDetail::getList($this->id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -818,6 +818,12 @@ class ToolsCore
|
||||
return Tools::getAdminToken($tab.(int)Tab::getIdFromClassName($tab).(int)$context->employee->id);
|
||||
}
|
||||
|
||||
public static function getAdminTokenLiteSmarty($params, &$smarty)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
return Tools::getAdminToken($params['tab'].(int)Tab::getIdFromClassName($params['tab']).(int)$context->employee->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user's journey
|
||||
*
|
||||
|
||||
@@ -62,6 +62,8 @@ smartyRegisterFunction($smarty, 'function', 'displayWtPrice', array('Product', '
|
||||
smartyRegisterFunction($smarty, 'function', 'displayWtPriceWithCurrency', array('Product', 'displayWtPriceWithCurrency'));
|
||||
smartyRegisterFunction($smarty, 'function', 'displayPrice', array('Tools', 'displayPriceSmarty'));
|
||||
smartyRegisterFunction($smarty, 'modifier', 'convertAndFormatPrice', array('Product', 'convertAndFormatPrice')); // used twice
|
||||
smartyRegisterFunction($smarty, 'function', 'getAdminToken', array('Tools', 'getAdminTokenLiteSmarty'));
|
||||
smartyRegisterFunction($smarty, 'function', 'displayAddressDetail', array('AddressFormat', 'generateAddressSmarty'));
|
||||
|
||||
function smartyTranslate($params, &$smarty)
|
||||
{
|
||||
|
||||
Executable
+527
@@ -0,0 +1,527 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class AdminOrdersControllerCore extends AdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'order';
|
||||
$this->className = 'Order';
|
||||
$this->lang = false;
|
||||
|
||||
$this->addRowAction('view');
|
||||
|
||||
$this->deleted = false;
|
||||
$this->colorOnBackground = true;
|
||||
$this->requiredDatabase = false;
|
||||
$this->context = Context::getContext();
|
||||
|
||||
$this->_select = '
|
||||
a.id_order AS id_pdf,
|
||||
CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,
|
||||
osl.`name` AS `osname`,
|
||||
os.`color`,
|
||||
IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new,
|
||||
(SELECT COUNT(od.`id_order`) FROM `'._DB_PREFIX_.'order_detail` od WHERE od.`id_order` = a.`id_order` GROUP BY `id_order`) AS product_number';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = a.`id_order`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = oh.`id_order_state`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')';
|
||||
$this->_where = 'AND oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `'._DB_PREFIX_.'order_history` moh WHERE moh.`id_order` = a.`id_order` GROUP BY moh.`id_order`)';
|
||||
|
||||
$statesArray = array();
|
||||
$states = OrderState::getOrderStates((int)$this->context->language->id);
|
||||
|
||||
foreach ($states AS $state)
|
||||
$statesArray[$state['id_order_state']] = $state['name'];
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_order' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'new' => array('title' => $this->l('New'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'filter_key' => 'new', 'tmpTableFilter' => true, 'icon' => array(0 => 'blank.gif', 1 => 'news-new.gif'), 'orderby' => false),
|
||||
'customer' => array('title' => $this->l('Customer'), 'widthColumn' => 160, 'width' => 140, 'filter_key' => 'customer', 'tmpTableFilter' => true),
|
||||
'total_paid' => array('title' => $this->l('Total'), 'width' => 70, 'align' => 'right', 'prefix' => '<b>', 'suffix' => '</b>', 'price' => true, 'currency' => true),
|
||||
'payment' => array('title' => $this->l('Payment'), 'width' => 100),
|
||||
'osname' => array('title' => $this->l('Status'), 'widthColumn' => 230, 'type' => 'select', 'select' => $statesArray, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int', 'width' => 200),
|
||||
'date_add' => array('title' => $this->l('Date'), 'width' => 35, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add'),
|
||||
'id_pdf' => array('title' => $this->l('PDF'), 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false));
|
||||
$this->shopLinkType = 'shop';
|
||||
$this->shopShareDatas = Shop::SHARE_ORDER;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
$this->display = 'list';
|
||||
|
||||
if (Tools::isSubmit('view'.$this->table))
|
||||
{
|
||||
$this->display = 'view';
|
||||
$this->viewOrder();
|
||||
}
|
||||
|
||||
parent::initContent();
|
||||
}
|
||||
|
||||
public function printPDFIcons($id_order, $tr)
|
||||
{
|
||||
$order = new Order($id_order);
|
||||
$orderState = OrderHistory::getLastOrderState($id_order);
|
||||
if (!Validate::isLoadedObject($orderState) OR !Validate::isLoadedObject($order))
|
||||
die(Tools::displayError('Invalid objects'));
|
||||
|
||||
// Generate HTML code for printing Invoice Icon with link
|
||||
$content = '<span style="width:20px; margin-right:5px;">';
|
||||
if (($orderState->invoice && $order->invoice_number) && (int)$tr['product_number'])
|
||||
$content .= '<a href="pdf.php?id_order='.(int)$order->id.'&pdf"><img src="../img/admin/tab-invoice.gif" alt="invoice" /></a>';
|
||||
else
|
||||
$content .= '-';
|
||||
$content .= '</span>';
|
||||
|
||||
// Generate HTML code for printing Delivery Icon with link
|
||||
$content .= '<span style="width:20px;">';
|
||||
if ($orderState->delivery && $order->delivery_number)
|
||||
$content .= '<a href="pdf.php?id_delivery='.(int)$order->delivery_number.'"><img src="../img/admin/delivery.gif" alt="delivery" /></a>';
|
||||
else
|
||||
$content .= '-';
|
||||
$content .= '</span>';
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
/* Update shipping number */
|
||||
if (Tools::isSubmit('submitShippingNumber') AND ($id_order = (int)(Tools::getValue('id_order'))) AND Validate::isLoadedObject($order = new Order($id_order)))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (!$order->hasBeenShipped())
|
||||
die(Tools::displayError('The shipping number can only be set once the order has been shipped.'));
|
||||
$_GET['view'.$this->table] = true;
|
||||
|
||||
$shipping_number = pSQL(Tools::getValue('shipping_number'));
|
||||
$order->shipping_number = $shipping_number;
|
||||
$order->update();
|
||||
if ($shipping_number)
|
||||
{
|
||||
global $_LANGMAIL;
|
||||
$customer = new Customer((int)($order->id_customer));
|
||||
$carrier = new Carrier((int)($order->id_carrier));
|
||||
if (!Validate::isLoadedObject($customer) OR !Validate::isLoadedObject($carrier))
|
||||
die(Tools::displayError());
|
||||
$templateVars = array(
|
||||
'{followup}' => str_replace('@', $order->shipping_number, $carrier->url),
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{id_order}' => (int)($order->id)
|
||||
);
|
||||
@Mail::Send((int)($order->id_lang), 'in_transit', Mail::l('Package in transit'), $templateVars,
|
||||
$customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL, NULL,
|
||||
_PS_MAIL_DIR_, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
|
||||
/* Change order state, add a new entry in order history and send an e-mail to the customer if needed */
|
||||
elseif (Tools::isSubmit('submitState') AND ($id_order = (int)(Tools::getValue('id_order'))) AND Validate::isLoadedObject($order = new Order($id_order)))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
$_GET['view'.$this->table] = true;
|
||||
if (!$newOrderStatusId = (int)(Tools::getValue('id_order_state')))
|
||||
$this->_errors[] = Tools::displayError('Invalid new order status');
|
||||
else
|
||||
{
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int)$id_order;
|
||||
$history->id_employee = (int)$this->context->employee->id;
|
||||
if (!(int)Tools::getValue('id_warehouse'))
|
||||
$this->_errors[] = Tools::displayError('An error occurred while changing the status.');
|
||||
else
|
||||
{
|
||||
$history->changeIdOrderState((int)($newOrderStatusId), (int)($id_order), (int)Tools::getValue('id_warehouse'));
|
||||
$order = new Order((int)$order->id);
|
||||
$carrier = new Carrier((int)($order->id_carrier), (int)($order->id_lang));
|
||||
$templateVars = array();
|
||||
if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') AND $order->shipping_number)
|
||||
$templateVars = array('{followup}' => str_replace('@', $order->shipping_number, $carrier->url));
|
||||
else if ($history->id_order_state == Configuration::get('PS_OS_CHEQUE'))
|
||||
$templateVars = array(
|
||||
'{cheque_name}' => (Configuration::get('CHEQUE_NAME') ? Configuration::get('CHEQUE_NAME') : ''),
|
||||
'{cheque_address_html}' => (Configuration::get('CHEQUE_ADDRESS') ? nl2br(Configuration::get('CHEQUE_ADDRESS')) : ''));
|
||||
elseif ($history->id_order_state == Configuration::get('PS_OS_BANKWIRE'))
|
||||
$templateVars = array(
|
||||
'{bankwire_owner}' => (Configuration::get('BANK_WIRE_OWNER') ? Configuration::get('BANK_WIRE_OWNER') : ''),
|
||||
'{bankwire_details}' => (Configuration::get('BANK_WIRE_DETAILS') ? nl2br(Configuration::get('BANK_WIRE_DETAILS')) : ''),
|
||||
'{bankwire_address}' => (Configuration::get('BANK_WIRE_ADDRESS') ? nl2br(Configuration::get('BANK_WIRE_ADDRESS')) : ''));
|
||||
if ($history->addWithemail(true, $templateVars))
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$id_order.'&vieworder'.'&token='.$this->token);
|
||||
$this->_errors[] = Tools::displayError('An error occurred while changing the status or was unable to send e-mail to the customer.');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
|
||||
/* Add a new message for the current order and send an e-mail to the customer if needed */
|
||||
elseif (isset($_POST['submitMessage']))
|
||||
{
|
||||
$_GET['view'.$this->table] = true;
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (!($id_order = (int)(Tools::getValue('id_order'))) OR !($id_customer = (int)(Tools::getValue('id_customer'))))
|
||||
$this->_errors[] = Tools::displayError('An error occurred before sending message');
|
||||
elseif (!Tools::getValue('message'))
|
||||
$this->_errors[] = Tools::displayError('Message cannot be blank');
|
||||
else
|
||||
{
|
||||
/* Get message rules and and check fields validity */
|
||||
$rules = call_user_func(array('Message', 'getValidationRules'), 'Message');
|
||||
foreach ($rules['required'] AS $field)
|
||||
if (($value = Tools::getValue($field)) == false AND (string)$value != '0')
|
||||
if (!Tools::getValue('id_'.$this->table) OR $field != 'passwd')
|
||||
$this->_errors[] = Tools::displayError('field').' <b>'.$field.'</b> '.Tools::displayError('is required.');
|
||||
foreach ($rules['size'] AS $field => $maxLength)
|
||||
if (Tools::getValue($field) AND Tools::strlen(Tools::getValue($field)) > $maxLength)
|
||||
$this->_errors[] = Tools::displayError('field').' <b>'.$field.'</b> '.Tools::displayError('is too long.').' ('.$maxLength.' '.Tools::displayError('chars max').')';
|
||||
foreach ($rules['validate'] AS $field => $function)
|
||||
if (Tools::getValue($field))
|
||||
if (!Validate::$function(htmlentities(Tools::getValue($field), ENT_COMPAT, 'UTF-8')))
|
||||
$this->_errors[] = Tools::displayError('field').' <b>'.$field.'</b> '.Tools::displayError('is invalid.');
|
||||
if (!sizeof($this->_errors))
|
||||
{
|
||||
$order = new Order((int)(Tools::getValue('id_order')));
|
||||
$customer = new Customer((int)$order->id_customer);
|
||||
//check if a thread already exist
|
||||
$id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($customer->email, $order->id);
|
||||
$cm = new CustomerMessage();
|
||||
if (!$id_customer_thread)
|
||||
{
|
||||
$ct = new CustomerThread();
|
||||
$ct->id_contact = 0;
|
||||
$ct->id_customer = (int)$order->id_customer;
|
||||
$ct->id_shop = (int)$this->context->shop->getId(true);
|
||||
$ct->id_order = (int)$order->id;
|
||||
$ct->id_lang = (int)$this->context->language->id;
|
||||
$ct->email = $customer->email;
|
||||
$ct->status = 'open';
|
||||
$ct->token = Tools::passwdGen(12);
|
||||
$ct->add();
|
||||
}
|
||||
else
|
||||
$ct = new CustomerThread((int)$id_customer_thread);
|
||||
$cm->id_customer_thread = $ct->id;
|
||||
$cm->id_employee = (int)$this->context->employee->id;
|
||||
$cm->message = htmlentities(Tools::getValue('message'), ENT_COMPAT, 'UTF-8');
|
||||
$cm->private = Tools::getValue('visibility');
|
||||
if (!$cm->add())
|
||||
$this->_errors[] = Tools::displayError('An error occurred while sending message.');
|
||||
elseif ($message->private)
|
||||
Tools::redirectAdmin($currentIndex.'&id_order='.$id_order.'&vieworder&conf=11'.'&token='.$this->token);
|
||||
elseif (Validate::isLoadedObject($customer = new Customer($id_customer)))
|
||||
{
|
||||
if (Validate::isLoadedObject($order))
|
||||
{
|
||||
$varsTpl = array(
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{id_order}' => $order->id,
|
||||
'{message}' => (Configuration::get('PS_MAIL_TYPE') == 2 ? $cm->message : Tools::nl2br($cm->message))
|
||||
);
|
||||
if (@Mail::Send((int)($order->id_lang), 'order_merchant_comment',
|
||||
Mail::l('New message regarding your order'), $varsTpl, $customer->email,
|
||||
$customer->firstname.' '.$customer->lastname, NULL, NULL, NULL, NULL, _PS_MAIL_DIR_, true))
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$id_order.'&vieworder&conf=11'.'&token='.$this->token);
|
||||
}
|
||||
}
|
||||
$this->_errors[] = Tools::displayError('An error occurred while sending e-mail to customer.');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
|
||||
/* Cancel product from order */
|
||||
elseif (Tools::isSubmit('cancelProduct') AND Validate::isLoadedObject($order = new Order((int)(Tools::getValue('id_order')))))
|
||||
{
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
$productList = Tools::getValue('id_order_detail');
|
||||
$customizationList = Tools::getValue('id_customization');
|
||||
$qtyList = Tools::getValue('cancelQuantity');
|
||||
$customizationQtyList = Tools::getValue('cancelCustomizationQuantity');
|
||||
|
||||
$full_product_list = $productList;
|
||||
$full_quantity_list = $qtyList;
|
||||
|
||||
if ($customizationList)
|
||||
{
|
||||
foreach ($customizationList as $key => $id_order_detail)
|
||||
{
|
||||
$full_product_list[$id_order_detail] = $id_order_detail;
|
||||
$full_quantity_list[$id_order_detail] = $customizationQtyList[$key];
|
||||
}
|
||||
}
|
||||
|
||||
if ($productList OR $customizationList)
|
||||
{
|
||||
if ($productList)
|
||||
{
|
||||
$id_cart = Cart::getCartIdByOrderId($order->id);
|
||||
$customization_quantities = Customization::countQuantityByCart($id_cart);
|
||||
|
||||
foreach ($productList AS $key => $id_order_detail)
|
||||
{
|
||||
$qtyCancelProduct = abs($qtyList[$key]);
|
||||
if (!$qtyCancelProduct)
|
||||
$this->_errors[] = Tools::displayError('No quantity selected for product.');
|
||||
|
||||
// check actionable quantity
|
||||
$order_detail = new OrderDetail($id_order_detail);
|
||||
$customization_quantity = 0;
|
||||
if (array_key_exists($order_detail->product_id, $customization_quantities) && array_key_exists($order_detail->product_attribute_id, $customization_quantities[$order_detail->product_id]))
|
||||
$customization_quantity = (int) $customization_quantities[$order_detail->product_id][$order_detail->product_attribute_id];
|
||||
|
||||
if (($order_detail->product_quantity - $customization_quantity - $order_detail->product_quantity_refunded - $order_detail->product_quantity_return) < $qtyCancelProduct)
|
||||
$this->_errors[] = Tools::displayError('Invalid quantity selected for product.');
|
||||
|
||||
}
|
||||
}
|
||||
if ($customizationList)
|
||||
{
|
||||
$customization_quantities = Customization::retrieveQuantitiesFromIds(array_keys($customizationList));
|
||||
|
||||
foreach ($customizationList AS $id_customization => $id_order_detail)
|
||||
{
|
||||
$qtyCancelProduct = abs($customizationQtyList[$id_customization]);
|
||||
$customization_quantity = $customization_quantities[$id_customization];
|
||||
|
||||
if (!$qtyCancelProduct)
|
||||
$this->_errors[] = Tools::displayError('No quantity selected for product.');
|
||||
|
||||
if ($qtyCancelProduct > ($customization_quantity['quantity'] - ($customization_quantity['quantity_refunded'] + $customization_quantity['quantity_returned'])))
|
||||
$this->_errors[] = Tools::displayError('Invalid quantity selected for product.');
|
||||
}
|
||||
}
|
||||
|
||||
if (!sizeof($this->_errors) AND $productList)
|
||||
foreach ($productList AS $key => $id_order_detail)
|
||||
{
|
||||
$qtyCancelProduct = abs($qtyList[$key]);
|
||||
$orderDetail = new OrderDetail((int)($id_order_detail));
|
||||
|
||||
// Reinject product
|
||||
if (!$order->hasBeenDelivered() OR ($order->hasBeenDelivered() AND Tools::isSubmit('reinjectQuantities')))
|
||||
{
|
||||
$reinjectableQuantity = (int)($orderDetail->product_quantity) - (int)($orderDetail->product_quantity_reinjected);
|
||||
$quantityToReinject = $qtyCancelProduct > $reinjectableQuantity ? $reinjectableQuantity : $qtyCancelProduct;
|
||||
if (!Product::reinjectQuantities($orderDetail, $quantityToReinject))
|
||||
$this->_errors[] = Tools::displayError('Cannot re-stock product').' <span class="bold">'.$orderDetail->product_name.'</span>';
|
||||
else
|
||||
{
|
||||
$updProductAttributeID = !empty($orderDetail->product_attribute_id) ? (int)($orderDetail->product_attribute_id) : NULL;
|
||||
$newProductQty = Product::getQuantity($orderDetail->product_id, $updProductAttributeID);
|
||||
$product = get_object_vars(new Product($orderDetail->product_id, false, $this->context->language->id, $order->id_shop));
|
||||
if (!empty($orderDetail->product_attribute_id))
|
||||
{
|
||||
$updProduct['quantity_attribute'] = (int)($newProductQty);
|
||||
$product['quantity_attribute'] = $updProduct['quantity_attribute'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$updProduct['stock_quantity'] = (int)($newProductQty);
|
||||
$product['stock_quantity'] = $updProduct['stock_quantity'];
|
||||
}
|
||||
Hook::updateQuantity($product, $order);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete product
|
||||
if (!$order->deleteProduct($order, $orderDetail, $qtyCancelProduct))
|
||||
$this->_errors[] = Tools::displayError('An error occurred during deletion of the product.').' <span class="bold">'.$orderDetail->product_name.'</span>';
|
||||
Module::hookExec('cancelProduct', array('order' => $order, 'id_order_detail' => $id_order_detail));
|
||||
}
|
||||
if (!sizeof($this->_errors) AND $customizationList)
|
||||
foreach ($customizationList AS $id_customization => $id_order_detail)
|
||||
{
|
||||
$orderDetail = new OrderDetail((int)($id_order_detail));
|
||||
$qtyCancelProduct = abs($customizationQtyList[$id_customization]);
|
||||
if (!$order->deleteCustomization($id_customization, $qtyCancelProduct, $orderDetail))
|
||||
$this->_errors[] = Tools::displayError('An error occurred during deletion of product customization.').' '.$id_customization;
|
||||
}
|
||||
// E-mail params
|
||||
if ((isset($_POST['generateCreditSlip']) OR isset($_POST['generateDiscount'])) AND !sizeof($this->_errors))
|
||||
{
|
||||
$customer = new Customer((int)($order->id_customer));
|
||||
$params['{lastname}'] = $customer->lastname;
|
||||
$params['{firstname}'] = $customer->firstname;
|
||||
$params['{id_order}'] = $order->id;
|
||||
}
|
||||
|
||||
// Generate credit slip
|
||||
if (isset($_POST['generateCreditSlip']) AND !sizeof($this->_errors))
|
||||
{
|
||||
if (!OrderSlip::createOrderSlip($order, $full_product_list, $full_quantity_list, isset($_POST['shippingBack'])))
|
||||
$this->_errors[] = Tools::displayError('Cannot generate credit slip');
|
||||
else
|
||||
{
|
||||
Module::hookExec('orderSlip', array('order' => $order, 'productList' => $full_product_list, 'qtyList' => $full_quantity_list));
|
||||
@Mail::Send((int)$order->id_lang, 'credit_slip', Mail::l('New credit slip regarding your order', $order->id_lang),
|
||||
$params, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL, NULL,
|
||||
_PS_MAIL_DIR_, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Generate voucher
|
||||
if (isset($_POST['generateDiscount']) AND !sizeof($this->_errors))
|
||||
{
|
||||
if (!$voucher = Discount::createOrderDiscount($order, $full_product_list, $full_quantity_list, $this->l('Credit Slip concerning the order #'), isset($_POST['shippingBack'])))
|
||||
$this->_errors[] = Tools::displayError('Cannot generate voucher');
|
||||
else
|
||||
{
|
||||
$currency = $this->context->currency;
|
||||
$params['{voucher_amount}'] = Tools::displayPrice($voucher->value, $currency, false);
|
||||
$params['{voucher_num}'] = $voucher->name;
|
||||
@Mail::Send((int)($order->id_lang), 'voucher', Mail::l('New voucher regarding your order'),
|
||||
$params, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL,
|
||||
NULL, _PS_MAIL_DIR_, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('No product or quantity selected.');
|
||||
|
||||
// Redirect if no errors
|
||||
if (!sizeof($this->_errors))
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=24&token='.$this->token);
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
elseif (isset($_GET['messageReaded']))
|
||||
{
|
||||
Message::markAsReaded($_GET['messageReaded'], $this->context->employee->id);
|
||||
}
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
public function viewOrder()
|
||||
{
|
||||
$order = $this->loadObject();
|
||||
if (!Validate::isLoadedObject($order))
|
||||
return;
|
||||
|
||||
$customer = new Customer($order->id_customer);
|
||||
$carrier = new Carrier($order->id_carrier);
|
||||
$products = $order->getProducts();
|
||||
|
||||
foreach ($products as &$product)
|
||||
{
|
||||
if ($product['image'] != null)
|
||||
{
|
||||
$name = 'product_mini_'.(int)$product['product_id'].(isset($product['product_attribute_id']) ? '_'.(int)$product['product_attribute_id'] : '').'.jpg';
|
||||
// generate image cache, only for back office
|
||||
$product['image_tag'] = cacheImage(_PS_IMG_DIR_.'p/'.$product['image']->getExistingImgPath().'.jpg', $name, 45, 'jpg');
|
||||
$product['image_size'] = getimagesize(_PS_TMP_IMG_DIR_.$name);
|
||||
}
|
||||
}
|
||||
|
||||
// Carrier module call
|
||||
$carrier_module_call = null;
|
||||
if ($carrier->is_module)
|
||||
{
|
||||
$module = Module::getInstanceByName($carrier->external_module_name);
|
||||
if (method_exists($module, 'displayInfoByCart'))
|
||||
$carrier_module_call = call_user_func(array($module, 'displayInfoByCart'), $order->id_cart);
|
||||
}
|
||||
|
||||
// Retrieve addresses informations
|
||||
$addressInvoice = new Address($order->id_address_invoice, $this->context->language->id);
|
||||
if (Validate::isLoadedObject($addressInvoice) AND $addressInvoice->id_state)
|
||||
$invoiceState = new State((int)($addressInvoice->id_state));
|
||||
|
||||
if ($order->id_address_invoice == $order->id_address_delivery)
|
||||
{
|
||||
$addressDelivery = $addressInvoice;
|
||||
if (isset($invoiceState))
|
||||
$deliveryState = $invoiceState;
|
||||
}
|
||||
else
|
||||
{
|
||||
$addressDelivery = new Address($order->id_address_delivery, $this->context->language->id);
|
||||
if (Validate::isLoadedObject($addressDelivery) AND $addressDelivery->id_state)
|
||||
$deliveryState = new State((int)($addressDelivery->id_state));
|
||||
}
|
||||
|
||||
// Smarty assign
|
||||
$this->context->smarty->assign(array(
|
||||
'order' => $order,
|
||||
'cart' => new Cart($order->id),
|
||||
'customer' => $customer,
|
||||
'addresses' => array(
|
||||
'delivery' => $addressDelivery,
|
||||
'deliveryState' => isset($deliveryState) ? $deliveryState : null,
|
||||
'invoice' => $addressInvoice,
|
||||
'invoiceState' => isset($invoiceState) ? $invoiceState : null
|
||||
),
|
||||
'customerStats' => $customer->getStats(),
|
||||
'products' => $products,
|
||||
'discounts' => $order->getDiscounts(),
|
||||
'returns' => OrderReturn::getOrdersReturn($order->id_customer, $order->id),
|
||||
'slips' => OrderSlip::getOrdersSlip($order->id_customer, $order->id),
|
||||
'orderMessages' => OrderMessage::getOrderMessages($order->id_lang),
|
||||
'messages' => Message::getMessagesByOrderId($order->id, true),
|
||||
'carrier' => $carrier = new Carrier($order->id_carrier),
|
||||
'history' => $order->getHistory($this->context->language->id),
|
||||
'states' => OrderState::getOrderStates($this->context->language->id),
|
||||
'warehouse_list' => Warehouse::getWarehouseList(),
|
||||
'sources' => ConnectionsSource::getOrderSources($order->id),
|
||||
'currentState' => OrderHistory::getLastOrderState($order->id),
|
||||
'currency' => new Currency($order->id_currency),
|
||||
'previousOrder' => $order->getPreviousOrderId(),
|
||||
'nextOrder' => $order->getNextOrderId(),
|
||||
'currentIndex' => self::$currentIndex,
|
||||
'carrierModuleCall' => $carrier_module_call,
|
||||
'iso_code_lang' => $this->context->language->iso_code,
|
||||
'PS_INVOICE_PREFIX' => Configuration::get('PS_INVOICE_PREFIX', $this->context->language->id),
|
||||
'PS_WEIGHT_UNIT' => Configuration::get('PS_WEIGHT_UNIT'),
|
||||
'PS_SHOP_NAME' => Configuration::get('PS_SHOP_NAME'),
|
||||
'PS_DELIVERY_PREFIX' => Configuration::get('PS_DELIVERY_PREFIX', $this->context->language->id)
|
||||
));
|
||||
|
||||
// Assign Hook
|
||||
$this->context->smarty->assign(array(
|
||||
'HOOK_INVOICE' => Module::hookExec('invoice', array('id_order' => $order->id)),
|
||||
'HOOK_ADMIN_ORDER' => Module::hookExec('adminOrder', array('id_order' => $order->id))
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user