Compare commits
2 Commits
1.5.6.1
...
export_exc
| Author | SHA1 | Date | |
|---|---|---|---|
| 8804720cb6 | |||
| 284fcc72f7 |
326
CONTRIBUTORS.md
326
CONTRIBUTORS.md
@@ -1,186 +1,140 @@
|
||||
- adonis karavokyros
|
||||
- aFolletete
|
||||
- Agence CINS
|
||||
- aKorczak
|
||||
- Aleksander Palyan
|
||||
- Alexander Otchenashev
|
||||
- anat
|
||||
- Andrew
|
||||
- aNiassy
|
||||
- antoniofr
|
||||
- AntonLejon
|
||||
- Arnaud Lemercier
|
||||
- Axome
|
||||
- Benjamin PONGY
|
||||
- BigZ
|
||||
- bLeveque
|
||||
- bMancone
|
||||
- bumbu
|
||||
- Burhan
|
||||
- Caleydon Media
|
||||
- cam.lafit
|
||||
- Captain FLAM
|
||||
- Captain-FLAM
|
||||
- ccauw
|
||||
- cedricfontaine
|
||||
- Cédric Mouleyre
|
||||
- Chris
|
||||
- ChristopheBoucaut
|
||||
- CINS
|
||||
- cippest
|
||||
- cmouleyre
|
||||
- Corentin Delcourt
|
||||
- Cosmin Hutanu
|
||||
- Damien Metzger
|
||||
- DamienMetzger
|
||||
- Damon Skelhorn
|
||||
- Daniel
|
||||
- Daniele Giachino
|
||||
- David Gasperoni
|
||||
- Davy Rolink
|
||||
- Dinis Lage
|
||||
- djfm
|
||||
- dlage
|
||||
- dMetzger
|
||||
- (d)oekia
|
||||
- Dragan Skrbic
|
||||
- dreammeup
|
||||
- DrySs
|
||||
- DrÿSs
|
||||
- DrÿSs'
|
||||
- dSevere
|
||||
- Edouard Gaulué
|
||||
- emily-d
|
||||
- Eric Le Lay
|
||||
- Fabio Chelly
|
||||
- fBrignoli
|
||||
- fchellypresta
|
||||
- fram
|
||||
- Francois Gaillard
|
||||
- François Gaillard
|
||||
- Fran<EFBFBD>ois Gaillard
|
||||
- fSerny
|
||||
- Gabriel Schwardy
|
||||
- Gaelle ITZKOVITZ
|
||||
- gBrunier
|
||||
- gCharmes
|
||||
- gPoulain
|
||||
- gr4devel
|
||||
- Grégoire Bélorgey
|
||||
- Gregory Roussac
|
||||
- gRoussac
|
||||
- Guillaume DELOINCE
|
||||
- ha99y
|
||||
- hAitmansour
|
||||
- Ha!*!*y
|
||||
- indesign47
|
||||
- inem0o
|
||||
- ivancasasempere
|
||||
- Jáchym Toušek
|
||||
- Javsmile
|
||||
- jBreux
|
||||
- jeckyl
|
||||
- jeromenadaud
|
||||
- Jerome Nadaud
|
||||
- Jérôme Nadaud
|
||||
- jessylenne
|
||||
- jmCollin
|
||||
- jObregon
|
||||
- Jonathan Danse
|
||||
- joseantgv
|
||||
- Julien
|
||||
- Kevin Granger
|
||||
- kiropowered
|
||||
- kpodemski
|
||||
- Krystian Podemski
|
||||
- lBrieu
|
||||
- lCherifi
|
||||
- ldecoker
|
||||
- lLefevre
|
||||
- LOIC ROSSET ltd
|
||||
- Madef
|
||||
- Mainmich
|
||||
- makk1ntosh
|
||||
- marcinsz101
|
||||
- Marco Cervellin
|
||||
- matiasiglesias
|
||||
- Mats Rynge
|
||||
- MatthieuB
|
||||
- Maxence
|
||||
- mBertholino
|
||||
- mDeflotte
|
||||
- Michel Courtade
|
||||
- Mickael Desgranges
|
||||
- Mikael Blotin
|
||||
- Milow
|
||||
- minic studio
|
||||
- misthero
|
||||
- mMarinetti
|
||||
- montes
|
||||
- MustangZhong
|
||||
- nezenmoins
|
||||
- Nicolas Sorosac
|
||||
- Nils-Helge Garli Hegvik
|
||||
- Nino Uzelac
|
||||
- nPellicari
|
||||
- nturato
|
||||
- oleacorner
|
||||
- Otto Nascarella
|
||||
- Patanock
|
||||
- PhpMadman
|
||||
- Pierre
|
||||
- Piotr Kaczor
|
||||
- Piotr Moćko
|
||||
- PrestaEdit
|
||||
- PrestaLab
|
||||
- PrestanceDesign
|
||||
- prestarocket
|
||||
- Prestaspirit
|
||||
- pxls
|
||||
- Raphaël Malié
|
||||
- raulgundin
|
||||
- Rémi Gaillard
|
||||
- rGaillard
|
||||
- Rimas Kudelis
|
||||
- rMalie
|
||||
- rMontagne
|
||||
- romainberger
|
||||
- root
|
||||
- runningz
|
||||
- sagaradonis
|
||||
- Samy Rabih
|
||||
- Sarah Lorenzini
|
||||
- Seb
|
||||
- Sébastien
|
||||
- Sébastien Bocahu
|
||||
- Seynaeve
|
||||
- Shagshag
|
||||
- sjousse
|
||||
- sLorenzini
|
||||
- smartdatasoft
|
||||
- soufyan
|
||||
- soware
|
||||
- Staging
|
||||
- sThiebaut
|
||||
- Sylvain Gougouzian
|
||||
- Sylvain WITMEYER
|
||||
- tDidierjean
|
||||
- thoma202
|
||||
- Tomasz Slominski
|
||||
- Tom Panier
|
||||
- tucoinfo
|
||||
- unknown
|
||||
- vAugagneur
|
||||
- vChabot
|
||||
- Vincent Augagneur
|
||||
- Vincent Schoener
|
||||
- Vincent Terenti
|
||||
- vinvin27
|
||||
- vKham
|
||||
- vSchoener
|
||||
- Xavier
|
||||
- Xavier POITAU
|
||||
- Yoozio
|
||||
- zimmi1
|
||||
- Zollner Robert
|
||||
|
||||
- adonis karavokyros
|
||||
- aFolletete
|
||||
- Agence CINS
|
||||
- aKorczak
|
||||
- Alexander Otchenashev
|
||||
- anat
|
||||
- Andrew
|
||||
- aNiassy
|
||||
- antoniofr
|
||||
- AntonLejon
|
||||
- Arnaud Lemercier
|
||||
- Axome
|
||||
- Benjamin PONGY
|
||||
- BigZ
|
||||
- bLeveque
|
||||
- bMancone
|
||||
- bumbu
|
||||
- Burhan
|
||||
- Cédric Mouleyre
|
||||
- Caleydon Media
|
||||
- cam.lafit
|
||||
- Captain FLAM
|
||||
- Captain-FLAM
|
||||
- ccauw
|
||||
- ChristopheBoucaut
|
||||
- cippest
|
||||
- cmouleyre
|
||||
- Corentin Delcourt
|
||||
- Cosmin Hutanu
|
||||
- Damien Metzger
|
||||
- DamienMetzger
|
||||
- Damon Skelhorn
|
||||
- Daniel
|
||||
- David Gasperoni
|
||||
- Davy Rolink
|
||||
- djfm
|
||||
- dMetzger
|
||||
- (d)oekia
|
||||
- Dragan Skrbic
|
||||
- DrÿSs'
|
||||
- dreammeup
|
||||
- DrySs
|
||||
- dSevere
|
||||
- Edouard Gaulué
|
||||
- emily-d
|
||||
- Fabio Chelly
|
||||
- fBrignoli
|
||||
- fram
|
||||
- François Gaillard
|
||||
- fSerny
|
||||
- Gabriel Schwardy
|
||||
- gBrunier
|
||||
- gCharmes
|
||||
- gPoulain
|
||||
- Grégoire Bélorgey
|
||||
- Gregory Roussac
|
||||
- gRoussac
|
||||
- Guillaume DELOINCE
|
||||
- hAitmansour
|
||||
- Ha!*!*y
|
||||
- indesign47
|
||||
- inem0o
|
||||
- ivancasasempere
|
||||
- Jérôme Nadaud
|
||||
- jBreux
|
||||
- jeromenadaud
|
||||
- Jerome Nadaud
|
||||
- jessylenne
|
||||
- jmCollin
|
||||
- jObregon
|
||||
- Jonathan Danse
|
||||
- joseantgv
|
||||
- Kevin Granger
|
||||
- kpodemski
|
||||
- Krystian Podemski
|
||||
- lBrieu
|
||||
- lCherifi
|
||||
- ldecoker
|
||||
- lLefevre
|
||||
- marcinsz101
|
||||
- Marco Cervellin
|
||||
- Mats Rynge
|
||||
- MatthieuB
|
||||
- Maxence
|
||||
- mBertholino
|
||||
- mDeflotte
|
||||
- Michel Courtade
|
||||
- Milow
|
||||
- minic studio
|
||||
- misthero
|
||||
- mMarinetti
|
||||
- montes
|
||||
- nezenmoins
|
||||
- Nicolas Sorosac
|
||||
- Nils-Helge Garli Hegvik
|
||||
- nPellicari
|
||||
- nturato
|
||||
- oleacorner
|
||||
- Otto Nascarella
|
||||
- Patanock
|
||||
- PhpMadman
|
||||
- Pierre
|
||||
- Piotr Kaczor
|
||||
- Piotr Moćko
|
||||
- PrestaEdit
|
||||
- prestarocket
|
||||
- pxls
|
||||
- Rémi Gaillard
|
||||
- Raphaël Malié
|
||||
- raulgundin
|
||||
- rGaillard
|
||||
- Rimas Kudelis
|
||||
- rMalie
|
||||
- rMontagne
|
||||
- root
|
||||
- runningz
|
||||
- Sébastien
|
||||
- Sébastien Bocahu
|
||||
- Samy Rabih
|
||||
- Sarah Lorenzini
|
||||
- Seb
|
||||
- Seynaeve
|
||||
- Shagshag
|
||||
- sLorenzini
|
||||
- soware
|
||||
- Staging
|
||||
- sThiebaut
|
||||
- Sylvain WITMEYER
|
||||
- tDidierjean
|
||||
- vAugagneur
|
||||
- vChabot
|
||||
- Vincent Augagneur
|
||||
- Vincent Schoener
|
||||
- Vincent Terenti
|
||||
- vinvin27
|
||||
- vKham
|
||||
- vSchoener
|
||||
- Xavier
|
||||
- Xavier POITAU
|
||||
- Yoozio
|
||||
|
||||
@@ -22,18 +22,26 @@
|
||||
|
||||
$upload->setInvalidFileExt(explode(",", CONFIG_UPLOAD_INVALID_EXTS));
|
||||
if(CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_UPLOAD)
|
||||
{
|
||||
$error = SYS_DISABLED;
|
||||
}
|
||||
elseif(empty($_GET['folder']) || !isUnderRoot($_GET['folder']))
|
||||
{
|
||||
$error = ERR_FOLDER_PATH_NOT_ALLOWED;
|
||||
elseif (!$upload->isFileUploaded('file'))
|
||||
}else if(!$upload->isFileUploaded('file'))
|
||||
{
|
||||
$error = ERR_FILE_NOT_UPLOADED;
|
||||
elseif (!$upload->isPermittedFileExt(explode(",", CONFIG_UPLOAD_VALID_EXTS)))
|
||||
$error = ERR_FILE_TYPE_NOT_ALLOWED;
|
||||
elseif (defined('CONFIG_UPLOAD_MAXSIZE') && CONFIG_UPLOAD_MAXSIZE && $upload->isSizeTooBig(CONFIG_UPLOAD_MAXSIZE))
|
||||
$error = sprintf(ERROR_FILE_TOO_BID, transformFileSize(CONFIG_UPLOAD_MAXSIZE));
|
||||
elseif (!$upload->moveUploadedFile($_GET['folder']))
|
||||
}else if(!$upload->moveUploadedFile($_GET['folder']))
|
||||
{
|
||||
$error = ERR_FILE_MOVE_FAILED;
|
||||
else
|
||||
}
|
||||
elseif(!$upload->isPermittedFileExt(explode(",", CONFIG_UPLOAD_VALID_EXTS)))
|
||||
{
|
||||
$error = ERR_FILE_TYPE_NOT_ALLOWED;
|
||||
}elseif(defined('CONFIG_UPLOAD_MAXSIZE') && CONFIG_UPLOAD_MAXSIZE && $upload->isSizeTooBig(CONFIG_UPLOAD_MAXSIZE))
|
||||
{
|
||||
$error = sprintf(ERROR_FILE_TOO_BID, transformFileSize(CONFIG_UPLOAD_MAXSIZE));
|
||||
}else
|
||||
{
|
||||
include_once(CLASS_FILE);
|
||||
$path = $upload->getFilePath();
|
||||
|
||||
@@ -24,8 +24,7 @@
|
||||
if(!empty($_GET['search']))
|
||||
{
|
||||
include_once(CLASS_SEARCH);
|
||||
if (!preg_match('/^'.Tools::pRegexp(realpath(dirname(__FILE__).'/'.$_GET['search_folder']), '/').'/i', _PS_ROOT_DIR_.'/img/cms'))
|
||||
exit;
|
||||
|
||||
$search = new Search($_GET['search_folder']);
|
||||
$search->addSearchKeyword('recursive', @$_GET['search_recursively']);
|
||||
$search->addSearchKeyword('mtime_from', @$_GET['search_mtime_from']);
|
||||
|
||||
@@ -78,9 +78,9 @@
|
||||
define('CONFIG_EDITABLE_VALID_EXTS', 'txt,htm,html,xml,js,css'); //make you include all these extension in CONFIG_UPLOAD_VALID_EXTS if you want all valid
|
||||
|
||||
define('CONFIG_OVERWRITTEN', false); //overwirte when processing paste
|
||||
define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,jpeg,png');// //
|
||||
define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,png');// //
|
||||
//define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,png,bmp,tif,zip,sit,rar,gz,tar,htm,html,mov,mpg,avi,asf,mpeg,wmv,aif,aiff,wav,mp3,swf,ppt,rtf,doc,pdf,xls,txt,xml,xsl,dtd');//
|
||||
define("CONFIG_VIEWABLE_VALID_EXTS", 'gif,jpg,jpeg,jpeg,png');
|
||||
define("CONFIG_VIEWABLE_VALID_EXTS", 'gif,jpg,png');
|
||||
//define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,png,txt'); //
|
||||
define('CONFIG_UPLOAD_INVALID_EXTS', '');
|
||||
|
||||
|
||||
@@ -10,9 +10,6 @@
|
||||
|
||||
//FILESYSTEM CONFIG <br>
|
||||
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "class.auth.php");
|
||||
if (_PS_MODE_DEMO_)
|
||||
die('This functionality has been disabled.');
|
||||
|
||||
define('CONFIG_QUERY_STRING_ENABLE', true); //Enable passed query string to setting the system configuration
|
||||
if(!isset($_SESSION))
|
||||
{
|
||||
|
||||
@@ -73,9 +73,9 @@
|
||||
define('CONFIG_EDITABLE_VALID_EXTS', 'txt,htm,html,xml,js,css'); //make you include all these extension in CONFIG_UPLOAD_VALID_EXTS if you want all valid
|
||||
|
||||
define('CONFIG_OVERWRITTEN', false); //overwirte when processing paste
|
||||
define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,jpeg,png,txt'); //
|
||||
define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,png,txt'); //
|
||||
//define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,png,bmp,tif,zip,sit,rar,gz,tar,htm,html,mov,mpg,avi,asf,mpeg,wmv,aif,aiff,wav,mp3,swf,ppt,rtf,doc,pdf,xls,txt,xml,xsl,dtd');//
|
||||
define("CONFIG_VIEWABLE_VALID_EXTS", 'gif,bmp,txt,jpg,jpeg,png,tif,html,htm,js,css,xml,xsl,dtd,mp3,wav,wmv,wma,rm,rmvb,mov,swf');
|
||||
define("CONFIG_VIEWABLE_VALID_EXTS", 'gif,bmp,txt,jpg,png,tif,html,htm,js,css,xml,xsl,dtd,mp3,wav,wmv,wma,rm,rmvb,mov,swf');
|
||||
//define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,png,txt'); //
|
||||
define('CONFIG_UPLOAD_INVALID_EXTS', '');
|
||||
|
||||
|
||||
@@ -27,9 +27,6 @@
|
||||
$timer_start = microtime(true);
|
||||
define('_PS_ADMIN_DIR_', getcwd());
|
||||
|
||||
if (!defined('PS_ADMIN_DIR'))
|
||||
define('PS_ADMIN_DIR', _PS_ADMIN_DIR_);
|
||||
|
||||
require(_PS_ADMIN_DIR_.'/../config/config.inc.php');
|
||||
require(_PS_ADMIN_DIR_.'/functions.php');
|
||||
|
||||
|
||||
@@ -49,12 +49,9 @@ try
|
||||
AdminTab::$currentIndex = $currentIndex;
|
||||
|
||||
$iso = $context->language->iso_code;
|
||||
if (file_exists(_PS_TRANSLATIONS_DIR_.$iso.'/errors.php'))
|
||||
include(_PS_TRANSLATIONS_DIR_.$iso.'/errors.php');
|
||||
if (file_exists(_PS_TRANSLATIONS_DIR_.$iso.'/fields.php'))
|
||||
include(_PS_TRANSLATIONS_DIR_.$iso.'/fields.php');
|
||||
if (file_exists(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php'))
|
||||
include(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php');
|
||||
include(_PS_TRANSLATIONS_DIR_.$iso.'/errors.php');
|
||||
include(_PS_TRANSLATIONS_DIR_.$iso.'/fields.php');
|
||||
include(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php');
|
||||
|
||||
/* Server Params */
|
||||
$protocol_link = (Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://';
|
||||
|
||||
@@ -232,6 +232,7 @@ a.module_toggle_all{color: #268CCD;}
|
||||
.toolbarBox .process-icon-save-and-preview { background-image: url('../img/process-icon-preview.png');}
|
||||
.toolbarBox .process-icon-import { background-image: url('../img/process-icon-export-csv.png');}
|
||||
.toolbarBox .process-icon-export { background-image: url('../img/process-icon-export-csv.png');}
|
||||
.toolbarBox .process-icon-export-excel { background-image: url('../img/process-icon-export-csv.png');}
|
||||
.toolbarBox .process-icon-export-all { background-image: url('../img/process-icon-export-csv-details.png');}
|
||||
.toolbarBox .process-icon-export-stock-state-quantities-csv { background-image: url('../img/process-icon-export-csv.png');}
|
||||
.toolbarBox .process-icon-export-stock-state-prices-csv { background-image: url('../img/process-icon-export-csv-details.png');}
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
.toolbarBox .process-icon-new-module { background-image: url('../img/process-icon-new-module.png')}
|
||||
.toolbarBox .process-icon-new-module-addon { background-image: url('../img/process-icon-new-module-addon.png')}
|
||||
|
||||
div.fix-toolbar {border-bottom: 1px solid #E0E0E0;position:fixed;top:0;opacity:0.9;z-index:11}
|
||||
div.fix-toolbar {border-bottom: 1px solid #E0E0E0;position:fixed;top:0;opacity:0.9;z-index:1}
|
||||
|
||||
|
||||
/*FILTER MODULE*/
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
</td>
|
||||
{foreach from=$ranges key=r item=range}
|
||||
<td class="center">
|
||||
<input name="fees[{$zone.id_zone|intval}][{$range.id_range|intval}]" type="text"
|
||||
<input name="fees[{$zone.id_zone|intval}][{$range.id_range|intval}]" type="text"
|
||||
{if !isset($fields_value['zones'][$zone.id_zone]) || (isset($fields_value['zones'][$zone.id_zone]) && !$fields_value['zones'][$zone.id_zone])} disabled="disabled"{/if} {if isset($price_by_range[$range.id_range][$zone.id_zone]) && $price_by_range[$range.id_range][$zone.id_zone] && isset($fields_value['zones'][$zone.id_zone]) && $fields_value['zones'][$zone.id_zone]} value="{$price_by_range[$range.id_range][$zone.id_zone]|string_format:'%.6f'}" {else} value="" {/if} /> {$currency_sign}
|
||||
</td>
|
||||
{/foreach}
|
||||
@@ -53,7 +53,7 @@
|
||||
{if $smarty.foreach.ranges.first}
|
||||
<td class="center"> </td>
|
||||
{else}
|
||||
<td class="center"><button class="button">{l s='Delete'}</button></td>
|
||||
<td class="center"><button class="button">{l s='Delete'}</button</td>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</tr>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<h2><img src="../img/admin/cart.gif" /> {l s='Order information'}</h2>
|
||||
<span>
|
||||
{if $order->id}
|
||||
<a href="{$link->getAdminLink('AdminOrders')|escape:'htmlall':'UTF-8'}&id_order={$order->id}&vieworder"> {l s='Order #%s' sprintf=$order->reference}</a></span>
|
||||
<a href="{$link->getAdminLink('AdminOrders')|escape:'htmlall':'UTF-8'}&id_order={$order->id}&vieworder"> {l s='Order #%d' sprintf=$order->id|string_format:"%06d"}</a></span>
|
||||
<br /><br />
|
||||
{l s='Made on:'} {dateFormat date=$order->date_add}<br /><br /><br /><br />
|
||||
{else}
|
||||
@@ -187,4 +187,4 @@
|
||||
<div class="clear" style="height:20px;"> </div>
|
||||
{/block}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -57,14 +57,14 @@
|
||||
|
||||
<dl>
|
||||
<dt>{l s='Sent on:'}</dt>
|
||||
<dd>{$message.date_add} </dd>
|
||||
<dd>{$message.date_add}</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
{if empty($message.id_employee)}
|
||||
<dl>
|
||||
<dt>{l s='Browser:'}</dt>
|
||||
<dd>{$message.user_agent} </dd>
|
||||
<dd>{$message.user_agent}</dd>
|
||||
</dl>
|
||||
{/if}
|
||||
|
||||
@@ -79,35 +79,34 @@
|
||||
</dl>
|
||||
{/if}
|
||||
|
||||
{if !empty($message.id_order) && $is_valid_order_id && empty($message.id_employee)}
|
||||
{if !empty($message.id_order) && empty($message.id_employee)}
|
||||
<dl>
|
||||
<dt>{l s='Order #'}</dt>
|
||||
<dd><a href="index.php?tab=AdminOrders&id_order={$message.id_order}&vieworder&token={getAdminToken tab='AdminOrders'}" title="{l s='View order'}">{$message.id_order} <img src="../img/admin/search.gif" alt="{l s='View'}" /></a>
|
||||
</dd>
|
||||
<dd><a href="index.php?tab=AdminOrders&id_order={$message.id_order}&vieworder&token={getAdminToken tab='AdminOrders'}" title="{l s='View order'}">
|
||||
{$message.id_order} <img src="../img/admin/search.gif" alt="{l s='View'}" />
|
||||
</a></dd>
|
||||
</dl>
|
||||
{/if}
|
||||
|
||||
{if !empty($message.id_product) && empty($message.id_employee)}
|
||||
<dl>
|
||||
<dt>{l s='Product #'}</dt>
|
||||
<dd><a href="index.php?tab=AdminProducts&id_product={$message.id_product}&updateproduct&token={getAdminToken tab='AdminProducts'}" title="{l s='View order'}">{$message.id_product} <img src="../img/admin/search.gif" alt="{l s='View'}" /></a></dd>
|
||||
<dd><a href="index.php?tab=AdminProducts&id_product={$message.id_product}&updateproduct&token={getAdminToken tab='AdminProducts'}" title="{l s='View order'}">
|
||||
{$message.id_product} <img src="../img/admin/search.gif" alt="{l s='View'}" />
|
||||
</a></dd>
|
||||
</dl>
|
||||
{/if}
|
||||
|
||||
<form action="{$current}&token={$token}&id_customer_thread={$message.id_customer_thread}&viewcustomer_thread" method="post">
|
||||
<b>{l s='Subject:'}</b>
|
||||
<input type="hidden" name="id_customer_message" value="{$message.id_customer_message}" />
|
||||
<dl>
|
||||
<dt>{l s='Subject:'}</dt>
|
||||
<dd>
|
||||
<select name="id_contact" onchange="this.form.submit();">
|
||||
{foreach $contacts as $contact}
|
||||
<option value="{$contact.id_contact}" {if $contact.id_contact == $message.id_contact}selected="selected"{/if}>
|
||||
{$contact.name}
|
||||
</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</dd>
|
||||
</dl>
|
||||
<select name="id_contact" onchange="this.form.submit();">
|
||||
{foreach $contacts as $contact}
|
||||
<option value="{$contact.id_contact}" {if $contact.id_contact == $message.id_contact}selected="selected"{/if}>
|
||||
{$contact.name}
|
||||
</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "index.php",
|
||||
data: "token={getAdminToken tab='AdminCustomers'}&tab=AdminCustomers&ajax=1&action=updateCustomerNote&id_customer={$customer->id}¬e="+encodeURIComponent(noteContent),
|
||||
data: "token={getAdminToken tab='AdminCustomers'}&tab=AdminCustomers&ajax=1&action=updateCustomerNote&id_customer={$customer->id}¬e="+noteContent,
|
||||
async : true,
|
||||
success: function(r) {
|
||||
$('#note_feedback').html('').hide();
|
||||
|
||||
@@ -138,7 +138,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#group_discount_category_table').append('<tr class="alt_row" id="'+jsonData.id_category+'"><td>'+jsonData.catPath+'</td><td>{l s='Discount:'}' + ' ' + jsonData.discount+'{l s='%'}</td><td><a href="#" onclick="deleteCategoryReduction('+jsonData.id_category+');"><img src="../img/admin/delete.gif"></a></td></tr>');
|
||||
$('#group_discount_category_table').append('<tr class="alt_row" id="'+jsonData.id_category+'"><td>'+jsonData.catPath+'</td><td>{l s='Discount:'}'+jsonData.discount+'{l s='%'}</td><td><a href="#" onclick="deleteCategoryReduction('+jsonData.id_category+');"><img src="../img/admin/delete.gif"></a></td></tr>');
|
||||
|
||||
var input_hidden = document.createElement("input");
|
||||
input_hidden.setAttribute('type', 'hidden');
|
||||
@@ -168,7 +168,7 @@
|
||||
{foreach $input['values'] key=key item=category }
|
||||
<tr class="alt_row" id="{$category.id_category}">
|
||||
<td>{$category.path}</td>
|
||||
<td>{l s='Discount: %.2f%%' sprintf=$category.reduction}</td>
|
||||
<td>{l s='Discount: %d%%' sprintf=$category.reduction}</td>
|
||||
<td>
|
||||
<a href="#" onclick="deleteCategoryReduction({$category.id_category});"><img src="../img/admin/delete.gif"></a>
|
||||
<input type="hidden" class="category_reduction" name="category_reduction[{$category.id_category}]" value="{$category.reduction}">
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<fieldset>
|
||||
<ul>
|
||||
<li><span style="font-weight: bold; font-size: 13px; color:#000;">{l s='Name:'}</span> {$group->name[$language->id]}</li>
|
||||
<li><span style="font-weight: bold; font-size: 13px; color:#000;">{l s='Discount: %.2f%%' sprintf=$group->reduction}</span></li>
|
||||
<li><span style="font-weight: bold; font-size: 13px; color:#000;">{l s='Discount: %d%%' sprintf=$group->reduction}</span></li>
|
||||
<li><span style="font-weight: bold; font-size: 13px; color:#000;">{l s='Current category discount:'}</span>
|
||||
{if !$categorieReductions}
|
||||
{l s='None'}
|
||||
@@ -39,7 +39,7 @@
|
||||
{foreach $categorieReductions key=key item=category }
|
||||
<tr class="alt_row">
|
||||
<td>{$category.path}</td>
|
||||
<td>{l s='Discount: %.2f%%' sprintf=$category.reduction}</td>
|
||||
<td>{l s='Discount: %d%%' sprintf=$category.reduction}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
@@ -58,7 +58,7 @@
|
||||
</ul>
|
||||
</fieldset>
|
||||
<h2>{l s='Members of this customer group'}</h2>
|
||||
<p>{l s='Limited to the first 100 customers.'} {l s='Please use filters to narrow your search.'}</p>
|
||||
<p>{l s='Limited to the 100th first customers.'} {l s='Please use filters to narrow your search.'}</p>
|
||||
{$customerList}
|
||||
|
||||
{/block}
|
||||
{/block}
|
||||
@@ -26,7 +26,7 @@
|
||||
<div class="leadin">{block name="leadin"}{/block}</div>
|
||||
{if $module_confirmation}
|
||||
<div class="module_confirmation conf confirm">
|
||||
{l s='Your .CSV file has been sucessfully imported into your shop. Don\'t forget to Re-build the products search index.'}
|
||||
{l s='Your .CSV file has been sucessfully imported into your shop.'}
|
||||
</div>
|
||||
{/if}
|
||||
<div style="display: none">
|
||||
@@ -59,7 +59,7 @@
|
||||
{if count($files_to_import)}
|
||||
<select name="csv">
|
||||
{foreach $files_to_import AS $filename}
|
||||
<option value="{$filename}"{if $csv_selected == $filename} selected="selected"{/if}>{$filename|escape:'htmlall':'UTF-8'}</option>
|
||||
<option value="{$filename}"{if $csv_selected == $filename} selected="selected"{/if}>{$filename}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
{/if}
|
||||
@@ -67,32 +67,20 @@
|
||||
<a href="#upload_file_import" id="upload_file_import_link" class="button"><img src="../img/admin/add.gif" alt="Uplaod" title="Upload" />{l s='Upload'}</a>
|
||||
</div>
|
||||
<div style="width:50%; margin: 0 auto;">
|
||||
<div style="width:50%; display: inline-block; float :left;">
|
||||
<a href="#" onclick="$('#sample_files_import').slideToggle(); return false;">{l s='Click to view our sample import csv files.'}</a>
|
||||
<ul id="sample_files_import" style="display:none;">
|
||||
<li><a class="_blank" href="../docs/csv_import/categories_import.csv">{l s='Sample Categories file'}</a></li>
|
||||
<li><a class="_blank" href="../docs/csv_import/products_import.csv">{l s='Sample Products file'}</a></li>
|
||||
<li><a class="_blank" href="../docs/csv_import/combinations_import.csv">{l s='Sample Combinations file'}</a></li>
|
||||
<li><a class="_blank" href="../docs/csv_import/customers_import.csv">{l s='Sample Customers file'}</a></li>
|
||||
<li><a class="_blank" href="../docs/csv_import/addresses_import.csv">{l s='Sample Addresses file'}</a></li>
|
||||
<li><a class="_blank" href="../docs/csv_import/manufacturers_import.csv">{l s='Sample Manufacturers file'}</a></li>
|
||||
<li><a class="_blank" href="../docs/csv_import/suppliers_import.csv">{l s='Sample Suppliers file'}</a></li>
|
||||
<li><a class="_blank" href="../docs/csv_import/alias_import.csv">{l s='Sample Alias file'}</a></li>
|
||||
{if $PS_ADVANCED_STOCK_MANAGEMENT}
|
||||
<li><a class="_blank" href="../docs/csv_import/supply_orders_import.csv">{l s='Supply Orders sample file'}</a></li>
|
||||
<li><a class="_blank" href="../docs/csv_import/supply_orders_details_import.csv">{l s='Supply Orders Details sample file'}</a></li>
|
||||
{/if}
|
||||
</ul>
|
||||
</div>
|
||||
<div style="width:50%; float:left;">
|
||||
<a href="#" onclick="$('#csv_files_import').slideToggle(); return false;">{l s='Click to view your csv files.'}</a>
|
||||
<ul id="csv_files_import" style="display:none;">
|
||||
{foreach $files_to_import AS $filename}
|
||||
<li><a href="{$current}&token={$token}&csvfilename={$filename|@base64_encode}">{$filename}</a>
|
||||
<a href="{$current}&token={$token}&csvfilename={$filename|@base64_encode}&delete=1"><img src="../img/admin/delete.gif" /></a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
<a href="#" onclick="$('#sample_files_import').slideToggle(); return false;">{l s='Click to view our sample import csv files.'}</a>
|
||||
<ul id="sample_files_import" style="display:none">
|
||||
<li><a href="../docs/csv_import/categories_import.csv">{l s='Sample Categories file'}</a></li>
|
||||
<li><a href="../docs/csv_import/products_import.csv">{l s='Sample Products file'}</a></li>
|
||||
<li><a href="../docs/csv_import/combinations_import.csv">{l s='Sample Combinations file'}</a></li>
|
||||
<li><a href="../docs/csv_import/customers_import.csv">{l s='Sample Customers file'}</a></li>
|
||||
<li><a href="../docs/csv_import/addresses_import.csv">{l s='Sample Addresses file'}</a></li>
|
||||
<li><a href="../docs/csv_import/manufacturers_import.csv">{l s='Sample Manufacturers file'}</a></li>
|
||||
<li><a href="../docs/csv_import/suppliers_import.csv">{l s='Sample Suppliers file'}</a></li>
|
||||
{if $PS_ADVANCED_STOCK_MANAGEMENT}
|
||||
<li><a href="../docs/csv_import/supply_orders_import.csv">{l s='Supply Orders sample file'}</a></li>
|
||||
<li><a href="../docs/csv_import/supply_orders_details_import.csv">{l s='Supply Orders Details sample file'}</a></li>
|
||||
{/if}
|
||||
</ul>
|
||||
<div class="clear"> </div>
|
||||
</div>
|
||||
<label class="clear">{l s='What kind of entity would you like to import?'} </label>
|
||||
@@ -120,12 +108,12 @@
|
||||
</div>
|
||||
<label class="clear">{l s='Field separator'} </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="2" value="{if isset($separator_selected)}{$separator_selected|escape:'htmlall':'UTF-8'}{else};{/if}" name="separator"/>
|
||||
<input type="text" size="2" value=";" name="separator"/>
|
||||
{l s='e.g. '}"1<span class="bold" style="color: red">;</span>Ipod<span class="bold" style="color: red">;</span>129.90<span class="bold" style="color: red">;</span>5"
|
||||
</div>
|
||||
<label class="clear">{l s='Multiple value separator'} </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="2" value="{if isset($multiple_value_separator_selected)}{$multiple_value_separator_selected|escape:'htmlall':'UTF-8'}{else},{/if}" name="multiple_value_separator"/>
|
||||
<input type="text" size="2" value="," name="multiple_value_separator"/>
|
||||
{l s='e.g. '}"Ipod;red.jpg<span class="bold" style="color: red">,</span>blue.jpg<span class="bold" style="color: red">,</span>green.jpg;129.90"
|
||||
</div>
|
||||
<label for="truncate" class="clear">{l s='Delete all'} <span id="entitie">{l s='categories'}</span> {l s='before import?'} </label>
|
||||
@@ -204,35 +192,30 @@
|
||||
});
|
||||
|
||||
$("select#entity").change(function(){
|
||||
if ($("#entity > option:selected").val() == 8 || $("#entity > option:selected").val() == 9)
|
||||
if ($("#entity > option:selected").val() == 7 || $("#entity > option:selected").val() == 8)
|
||||
$("label[for=truncate],#truncate").hide();
|
||||
else
|
||||
$("label[for=truncate],#truncate").show();
|
||||
|
||||
if ($("#entity > option:selected").val() == 9)
|
||||
if ($("#entity > option:selected").val() == 8)
|
||||
{
|
||||
$(".import_supply_orders_details").show();
|
||||
$('input[name=multiple_value_separator]').val('|');
|
||||
}
|
||||
else
|
||||
{
|
||||
$(".import_supply_orders_details").hide();
|
||||
$('input[name=multiple_value_separator]').val('{if isset($multiple_value_separator_selected)}{$multiple_value_separator_selected}{else},{/if}');
|
||||
$('input[name=multiple_value_separator]').val(',');
|
||||
}
|
||||
if ($("#entity > option:selected").val() == 1)
|
||||
$("label[for=match_ref], #match_ref").show();
|
||||
$("label[for=match_ref], #match_ref, label[for=regenerate], #regenerate").show();
|
||||
else
|
||||
$("label[for=match_ref], #match_ref").hide();
|
||||
|
||||
$("label[for=match_ref], #match_ref, label[for=regenerate], #regenerate").hide();
|
||||
if ($("#entity > option:selected").val() == 1 || $("#entity > option:selected").val() == 0)
|
||||
$(".import_products_categories").show();
|
||||
$(".import_products_categories, label[for=regenerate], #regenerate").show();
|
||||
else
|
||||
$(".import_products_categories").hide();
|
||||
|
||||
if ($("#entity > option:selected").val() == 0 || $("#entity > option:selected").val() == 1 ||
|
||||
$("#entity > option:selected").val() == 5 || $("#entity > option:selected").val() == 6)
|
||||
$("label[for=regenerate], #regenerate").show()
|
||||
else
|
||||
$("label[for=regenerate], #regenerate").hide();
|
||||
|
||||
if ($("#entity > option:selected").val() == 0 || $("#entity > option:selected").val() == 1 || $("#entity > option:selected").val() == 3 || $("#entity > option:selected").val() == 5 || $("#entity > option:selected").val() == 6 || $("#entity > option:selected").val() == 7)
|
||||
$(".import_products_categories, label[for=regenerate], #regenerate").hide();
|
||||
if ($("#entity > option:selected").val() == 0 || $("#entity > option:selected").val() == 1 || $("#entity > option:selected").val() == 3 || $("#entity > option:selected").val() == 5 || $("#entity > option:selected").val() == 6)
|
||||
$("label[for=forceIDs], #forceIDs").show();
|
||||
else
|
||||
$("label[for=forceIDs], #forceIDs").hide();
|
||||
@@ -266,4 +249,4 @@
|
||||
});
|
||||
};
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
@@ -25,7 +25,7 @@
|
||||
{extends file="helpers/view/view.tpl"}
|
||||
{block name="override_tpl"}
|
||||
<script type="text/javascript">
|
||||
var errorEmpty = '{l s='Please name your matching configuration to save.' js=1}';
|
||||
var errorEmpty = '{l s='Please name your matching configuration to save.' js='1'}';
|
||||
var token = '{$token}';
|
||||
var current = 0;
|
||||
function showTable(nb)
|
||||
@@ -126,4 +126,4 @@
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
{/block}
|
||||
{/block}
|
||||
@@ -59,14 +59,14 @@
|
||||
<td>{$module->categoryName}</td>
|
||||
<td>
|
||||
<select name="i_{$module->name}" class="moduleFavorite" style="width:50px">
|
||||
<option value="" selected="selected">-</option>
|
||||
<option value="" selected="selected">---</option>
|
||||
<option value="1" {if isset($module->preferences.interest) && $module->preferences.interest eq '1'}selected="selected"{/if}>{l s='Yes'}</option>
|
||||
<option value="0" {if isset($module->preferences.interest) && $module->preferences.interest eq '0'}selected="selected"{/if}>{l s='No'}</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select name="f_{$module->name}" class="moduleFavorite" style="width:50px">
|
||||
<option value="" selected="selected">-</option>
|
||||
<option value="" selected="selected">---</option>
|
||||
<option value="1" {if isset($module->preferences.favorite) && $module->preferences.favorite eq '1'}selected="selected"{/if}>{l s='Yes'}</option>
|
||||
<option value="0" {if isset($module->preferences.favorite) && $module->preferences.favorite eq '0'}selected="selected"{/if}>{l s='No'}</option>
|
||||
</select>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* @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" src="../js/jquery/plugins/jquery.uitablefilter.js"></script>
|
||||
|
||||
{if $add_permission eq '1'}
|
||||
{if isset($logged_on_addons)}
|
||||
<!--start addons login-->
|
||||
@@ -62,7 +62,10 @@
|
||||
<!--start filter module-->
|
||||
<style>.ac_results { border:1px solid #C2C4D9; }</style>
|
||||
<div class="filter-module">
|
||||
<input style="float: left; margin-right: 15px" placeholder="{l s='Search'}" type="text" value="" name="quicksearch" autocomplete="off" onkeyup="$.uiTableFilter($('#moduleContainer').find('table'), this.value);">
|
||||
<form id="filternameForm" method="post">
|
||||
<input type="text" value="" name="filtername" autocomplete="off" class="ac_input">
|
||||
<input type="submit" class="button" value="{l s='Search'}">
|
||||
</form>
|
||||
<form method="post">
|
||||
<div class="select-filter">
|
||||
<label class="search-filter">{l s='Sort by'}:</label>
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
});
|
||||
|
||||
// Method to check / uncheck all modules checkbox
|
||||
$('#moduleContainer').on("click", "#checkme", function()
|
||||
$('#checkme').click(function()
|
||||
{
|
||||
if ($(this).attr("rel") == 'false')
|
||||
{
|
||||
@@ -321,8 +321,8 @@
|
||||
catch(e){}
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#moduleContainer').on("click", ".toggle_favorite", function()
|
||||
|
||||
$('.toggle_favorite').live('click', function(event)
|
||||
{
|
||||
var el = $(this);
|
||||
var value_pref = el.data('value');
|
||||
|
||||
@@ -46,8 +46,8 @@
|
||||
</td>
|
||||
<td><img class="imgm" alt="" src="{if isset($module->image)}{$module->image}{else}../modules/{$module->name}/{$module->logo}{/if}"></td>
|
||||
<td>
|
||||
<div class="moduleDesc" id="anchor{$module->name|ucfirst}" title="{$module->name}">
|
||||
<h3>{$module->displayName}<span style="display:none">{$module->name}</span>
|
||||
<div class="moduleDesc" id="anchor{$module->name|ucfirst}">
|
||||
<h3>{$module->displayName}
|
||||
{if isset($module->type) && $module->type == 'addonsMustHave'}
|
||||
<span class="setup must-have">{l s='Must Have'}</span>
|
||||
{else}
|
||||
@@ -77,7 +77,7 @@
|
||||
</dl>
|
||||
</div>
|
||||
<p class="desc">{if isset($module->description) && $module->description ne ''}{l s='Description'} : {$module->description}{else} {/if}</p>
|
||||
{if isset($module->message) && (empty($module->name) === false) && (!isset($module->type) || ($module->type != 'addonsMustHave' || $module->type !== 'addonsNative'))}<div class="conf">{$module->message}</div>{/if}
|
||||
{if isset($module->message) && (!isset($module->type) || ($module->type != 'addonsMustHave' || $module->type !== 'addonsNative'))}<div class="conf">{$module->message}</div>{/if}
|
||||
<div class="row-actions-module">
|
||||
{if !isset($module->not_on_disk)}
|
||||
{$module->optionsHtml}
|
||||
@@ -101,7 +101,7 @@
|
||||
<a href="{$module->addons_buy_url}" target="_blank" class="button updated"><span><img src="../img/admin/cart_addons.png"> {if isset($module->id_currency) && isset($module->price)}{displayPrice price=$module->price currency=$module->id_currency}{/if}</span></a>
|
||||
</li>
|
||||
{else}
|
||||
{if isset($module->version_addons) && $module->version_addons}
|
||||
{if $module->id && isset($module->version_addons) && $module->version_addons}
|
||||
<li><a href="{$module->options.update_url}" class="button updated"><span>{l s='Update it!'}</span></a></li>
|
||||
{/if}
|
||||
<li>
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
<td valign="top">
|
||||
<div class="moduleDesc" id="anchor{$module->name|ucfirst}">
|
||||
<h3>
|
||||
<span style="display:none">{$module->name}</span>
|
||||
{$module->displayName|truncate:36:'…'} {$module->version}
|
||||
{if isset($module->id) && $module->id gt 0 }
|
||||
{if $module->active}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
{l s='Show'} :
|
||||
<select id="show_modules" onChange="autoUrl('show_modules', '{$url_show_modules}')">
|
||||
<option value="all">{l s='All modules'} </option>
|
||||
<option>-</option>
|
||||
<option>---------------</option>
|
||||
|
||||
{foreach $modules as $module}
|
||||
<option value="{$module->id|intval}" {if $display_key == $module->id}selected="selected"{/if}>{$module->displayName}</option>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
{* Generate HTML code for printing Invoice Icon with link *}
|
||||
<span style="width:20px; margin-right:5px;">
|
||||
{if ($order_state->invoice || $order->invoice_number)}
|
||||
<a href="{$link->getAdminLink('AdminPdf')|escape:'htmlall':'UTF-8'}&submitAction=generateInvoicePDF&id_order={$order->id}"><img src="../img/admin/tab-invoice.gif" alt="invoice" /></a>
|
||||
<a target="_blank" href="{$link->getAdminLink('AdminPdf')|escape:'htmlall':'UTF-8'}&submitAction=generateInvoicePDF&id_order={$order->id}"><img src="../img/admin/tab-invoice.gif" alt="invoice" /></a>
|
||||
{else}
|
||||
-
|
||||
{/if}
|
||||
@@ -35,7 +35,7 @@
|
||||
{* Generate HTML code for printing Delivery Icon with link *}
|
||||
<span style="width:20px;">
|
||||
{if ($order_state->delivery || $order->delivery_number)}
|
||||
<a href="{$link->getAdminLink('AdminPdf')|escape:'htmlall':'UTF-8'}&submitAction=generateDeliverySlipPDF&id_order={$order->id}"><img src="../img/admin/delivery.gif" alt="delivery" /></a>
|
||||
<a target="_blank" href="{$link->getAdminLink('AdminPdf')|escape:'htmlall':'UTF-8'}&submitAction=generateDeliverySlipPDF&id_order={$order->id}"><img src="../img/admin/delivery.gif" alt="delivery" /></a>
|
||||
{else}
|
||||
-
|
||||
{/if}
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
</span>
|
||||
{/if}
|
||||
</td>
|
||||
{if $display_warehouse}<td align="center">{$product.warehouse_name|escape:'htmlall':'UTF-8'}</td>{/if}
|
||||
{if $display_warehouse}<td>{$product.warehouse_name|escape:'htmlall':'UTF-8'}</td>{/if}
|
||||
{if ($order->hasBeenPaid())}
|
||||
<td align="center" class="productQuantity">
|
||||
{$product['product_quantity_refunded']}
|
||||
|
||||
@@ -38,11 +38,6 @@
|
||||
var defaults_order_state = new Array();
|
||||
var customization_errors = false;
|
||||
var pic_dir = '{$pic_dir}';
|
||||
var currency_format = 5;
|
||||
var currency_sign = '';
|
||||
var currency_blank = false;
|
||||
var priceDisplayPrecision = 2;
|
||||
|
||||
{foreach from=$defaults_order_state key='module' item='id_order_state'}
|
||||
defaults_order_state['{$module}'] = '{$id_order_state}';
|
||||
{/foreach}
|
||||
@@ -510,6 +505,7 @@
|
||||
}
|
||||
displaySummary(res);
|
||||
resetBind();
|
||||
updateCurrencySign();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -656,12 +652,11 @@
|
||||
var id_product = Number(this.id_product);
|
||||
var id_product_attribute = Number(this.id_product_attribute);
|
||||
cart_quantity[Number(this.id_product)+'_'+Number(this.id_product_attribute)+'_'+Number(this.id_customization)] = this.cart_quantity;
|
||||
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><td><input type="text" size="7" rel="'+this.id_product+'_'+this.id_product_attribute+'" class="product_unit_price" value="'+this.numeric_price+'" /></td><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><td><input type="text" size="7" rel="'+this.id_product+'_'+this.id_product_attribute+'" class="product_unit_price" value="'+this.price+'" /> <span class="currency_sign"></span></td><td>';
|
||||
cart_content += (!this.id_customization ? '<div style="float:left;"><a href="#" class="increaseqty_product" rel="'+this.id_product+'_'+this.id_product_attribute+'_'+(this.id_customization ? this.id_customization : 0)+'" ><img src="../img/admin/up.gif" /></a><br /><a href="#" class="decreaseqty_product" rel="'+this.id_product+'_'+this.id_product_attribute+'_'+(this.id_customization ? this.id_customization : 0)+'"><img src="../img/admin/down.gif" /></a></div>' : '');
|
||||
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>' + formatCurrency(this.numeric_total, currency_format, currency_sign, currency_blank) + '</td></tr>';
|
||||
|
||||
cart_content += '</td><td>'+this.total+' <span class="currency_sign"></span></td></tr>';
|
||||
if (this.id_customization && this.id_customization != 0)
|
||||
{
|
||||
$.each(this.customized_datas[this.id_product][this.id_product_attribute][id_address_delivery], function() {
|
||||
@@ -715,23 +710,8 @@
|
||||
$('#payment_list').html(payment_list);
|
||||
}
|
||||
|
||||
function fixPriceFormat(price)
|
||||
{
|
||||
if(price.indexOf(',') > 0 && price.indexOf('.') > 0) // if contains , and .
|
||||
if(price.indexOf(',') < price.indexOf('.')) // if , is before .
|
||||
price = price.replace(',',''); // remove ,
|
||||
price = price.replace(' ',''); // remove any spaces
|
||||
price = price.replace(',','.'); // remove , if price did not cotain both , and .
|
||||
return price;
|
||||
}
|
||||
|
||||
function displaySummary(jsonSummary)
|
||||
{
|
||||
currency_format = jsonSummary.currency.format;
|
||||
currency_sign = jsonSummary.currency.sign;
|
||||
currency_blank = jsonSummary.currency.blank;
|
||||
priceDisplayPrecision = jsonSummary.currency.decimals ? 2 : 0;
|
||||
|
||||
updateCartProducts(jsonSummary.summary.products, jsonSummary.summary.gift_products, jsonSummary.cart.id_address_delivery);
|
||||
updateCartVouchers(jsonSummary.summary.discounts);
|
||||
updateAddressesList(jsonSummary.addresses, jsonSummary.cart.id_address_delivery, jsonSummary.cart.id_address_invoice);
|
||||
@@ -757,19 +737,20 @@
|
||||
$('#free_shipping').removeAttr('checked');
|
||||
|
||||
$('#gift_message').html(jsonSummary.cart.gift_message);
|
||||
if (!changed_shipping_price)
|
||||
$('#shipping_price').html('<b>' + formatCurrency(parseFloat(jsonSummary.summary.total_shipping), currency_format, currency_sign, currency_blank) + '</b>');
|
||||
if(!changed_shipping_price)
|
||||
$('#shipping_price').html('<b>'+jsonSummary.summary.total_shipping+'</b>');
|
||||
shipping_price_selected_carrier = jsonSummary.summary.total_shipping;
|
||||
|
||||
$('#total_vouchers').html(formatCurrency(parseFloat(fixPriceFormat(jsonSummary.summary.total_discounts_tax_exc)), currency_format, currency_sign, currency_blank));
|
||||
$('#total_shipping').html(formatCurrency(parseFloat(fixPriceFormat(jsonSummary.summary.total_shipping_tax_exc)), currency_format, currency_sign, currency_blank));
|
||||
$('#total_taxes').html(formatCurrency(parseFloat(fixPriceFormat(jsonSummary.summary.total_tax)), currency_format, currency_sign, currency_blank));
|
||||
$('#total_without_taxes').html(formatCurrency(parseFloat(fixPriceFormat(jsonSummary.summary.total_price_without_tax)), currency_format, currency_sign, currency_blank));
|
||||
$('#total_with_taxes').html(formatCurrency(parseFloat(fixPriceFormat(jsonSummary.summary.total_price)), currency_format, currency_sign, currency_blank));
|
||||
$('#total_products').html(formatCurrency(parseFloat(fixPriceFormat(jsonSummary.summary.total_products)), currency_format, currency_sign, currency_blank));
|
||||
$('#total_vouchers').html(jsonSummary.summary.total_discounts_tax_exc);
|
||||
$('#total_shipping').html(jsonSummary.summary.total_shipping_tax_exc);
|
||||
$('#total_taxes').html(jsonSummary.summary.total_tax);
|
||||
$('#total_without_taxes').html(jsonSummary.summary.total_price_without_tax);
|
||||
$('#total_with_taxes').html(jsonSummary.summary.total_price);
|
||||
$('#total_products').html(jsonSummary.summary.total_products);
|
||||
id_currency = jsonSummary.cart.id_currency;
|
||||
$('#id_currency option').removeAttr('selected');
|
||||
$('#id_currency option[value="'+id_currency+'"]').attr('selected', true);
|
||||
updateCurrencySign();
|
||||
id_lang = jsonSummary.cart.id_lang;
|
||||
$('#id_lang option').removeAttr('selected');
|
||||
$('#id_lang option[value="'+id_lang+'"]').attr('selected', true);
|
||||
@@ -797,21 +778,21 @@
|
||||
qty: qty,
|
||||
id_customer: id_customer,
|
||||
id_cart: id_cart,
|
||||
},
|
||||
},
|
||||
success : function(res)
|
||||
{
|
||||
displaySummary(res);
|
||||
var errors = '';
|
||||
if (res.errors.length)
|
||||
{
|
||||
$.each(res.errors, function() {
|
||||
errors += this + '<br />';
|
||||
});
|
||||
$('#products_err').show();
|
||||
}
|
||||
else
|
||||
$('#products_err').hide();
|
||||
$('#products_err').html(errors);
|
||||
displaySummary(res);
|
||||
var errors = '';
|
||||
if(res.errors.length)
|
||||
{
|
||||
$.each(res.errors, function() {
|
||||
errors += this+'<br />';
|
||||
});
|
||||
$('#products_err').show();
|
||||
}
|
||||
else
|
||||
$('#products_err').hide();
|
||||
$('#products_err').html(errors);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -907,6 +888,11 @@
|
||||
});
|
||||
}
|
||||
|
||||
function updateCurrencySign()
|
||||
{
|
||||
$('.currency_sign').html(currencies[id_currency]);
|
||||
}
|
||||
|
||||
function sendMailToCustomer()
|
||||
{
|
||||
$.ajax({
|
||||
@@ -939,33 +925,11 @@
|
||||
var addresses_invoice_options = '';
|
||||
var address_invoice_detail = '';
|
||||
var address_delivery_detail = '';
|
||||
var delivery_address_edit_link = '';
|
||||
var invoice_address_edit_link = '';
|
||||
|
||||
$.each(addresses, function() {
|
||||
if (this.id_address == id_address_invoice)
|
||||
{
|
||||
address_invoice_detail = this.company+' '+this.firstname+' '+this.lastname+'<br />'+this.address1+'<br />'+this.address2+'<br />'+this.postcode+' '+this.city;
|
||||
|
||||
if (this.state != null)
|
||||
address_invoice_detail += ' '+this.state;
|
||||
|
||||
address_invoice_detail += '</br>'+this.country;
|
||||
|
||||
invoice_address_edit_link = "{$link->getAdminLink('AdminAddresses')}&id_address="+this.id_address+"&updateaddress&realedit=1&liteDisplaying=1&submitFormAjax=1#";
|
||||
}
|
||||
|
||||
address_invoice_detail = this.company+' '+this.firstname+' '+this.lastname+'<br />'+this.address1+'<br />'+this.address2+'<br />'+this.postcode+' '+this.city+' '+this.country;
|
||||
if(this.id_address == id_address_delivery)
|
||||
{
|
||||
address_delivery_detail = this.company+' '+this.firstname+' '+this.lastname+'<br />'+this.address1+'<br />'+this.address2+'<br />'+this.postcode+' '+this.city;
|
||||
|
||||
if (this.state != null)
|
||||
address_delivery_detail += ' '+this.state;
|
||||
|
||||
address_delivery_detail += '</br>'+this.country;
|
||||
|
||||
delivery_address_edit_link = "{$link->getAdminLink('AdminAddresses')}&id_address="+this.id_address+"&updateaddress&realedit=1&liteDisplaying=1&submitFormAjax=1#";
|
||||
}
|
||||
address_delivery_detail = this.company+' '+this.firstname+' '+this.lastname+'<br />'+this.address1+'<br />'+this.address2+'<br />'+this.postcode+' '+this.city+' '+this.country;
|
||||
|
||||
addresses_delivery_options += '<option value="'+this.id_address+'" '+(this.id_address == id_address_delivery ? 'selected="selected"' : '')+'>'+this.alias+'</option>';
|
||||
addresses_invoice_options += '<option value="'+this.id_address+'" '+(this.id_address == id_address_invoice ? 'selected="selected"' : '')+'>'+this.alias+'</option>';
|
||||
@@ -985,8 +949,6 @@
|
||||
$('#id_address_invoice').html(addresses_invoice_options);
|
||||
$('#address_delivery_detail').html(address_delivery_detail);
|
||||
$('#address_invoice_detail').html(address_invoice_detail);
|
||||
$('#edit_delivery_address').attr('href', delivery_address_edit_link);
|
||||
$('#edit_invoice_address').attr('href', invoice_address_edit_link);
|
||||
}
|
||||
|
||||
function updateAddresses()
|
||||
@@ -1022,7 +984,7 @@
|
||||
<label>{l s='Search customers'}</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" id="customer" value="" />
|
||||
<p>{l s='Search a customer by typing the first letters of his/her name'}</p>
|
||||
<p>{l s='Search a customer by tapping the first letters of his/her name'}</p>
|
||||
<a class="fancybox button" href="{$link->getAdminLink('AdminCustomers')|escape:'htmlall':'UTF-8'}&addcustomer&liteDisplaying=1&submitFormAjax=1#">
|
||||
<img src="../img/admin/add.gif" title="new"/><span>{l s='Add new customer'}</span>
|
||||
</a>
|
||||
@@ -1037,7 +999,7 @@
|
||||
<div class="margin-form">
|
||||
<input type="hidden" value="" id="id_cart" name="id_cart" />
|
||||
<input type="text" id="product" value="" />
|
||||
<p>{l s='Search a product by typing the first letters of his/her name.'}</p>
|
||||
<p>{l s='Search a product by tapping the first letters of his/her name.'}</p>
|
||||
</div>
|
||||
<div id="products_found">
|
||||
<div id="product_list">
|
||||
@@ -1197,14 +1159,14 @@
|
||||
<div id="address_delivery">
|
||||
<h3>{l s='Delivery'}</h3>
|
||||
<select id="id_address_delivery" name="id_address_delivery">
|
||||
</select> <a class="fancybox" id="edit_delivery_address" href="#"><img src="../img/admin/edit.gif" /></a>
|
||||
</select>
|
||||
<div id="address_delivery_detail">
|
||||
</div>
|
||||
</div>
|
||||
<div id="address_invoice">
|
||||
<h3>{l s='Invoice'}</h3>
|
||||
<select id="id_address_invoice" name="id_address_invoice">
|
||||
</select> <a class="fancybox" id="edit_invoice_address" href="#"><img src="../img/admin/edit.gif" /></a>
|
||||
</select>
|
||||
<div id="address_invoice_detail">
|
||||
</div>
|
||||
</div>
|
||||
@@ -1222,7 +1184,7 @@
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="shipping_price">{l s='Shipping price'}</label> <span id="shipping_price" name="shipping_price"></span>
|
||||
<label for="shipping_price">{l s='Shipping price'}</label> <span id="shipping_price" name="shipping_price"></span> <span class="currency_sign"></span>
|
||||
</p>
|
||||
<p>
|
||||
<label for="free_shipping">{l s='Free shipping'}</label>
|
||||
@@ -1246,12 +1208,12 @@
|
||||
<div id="send_email_feedback"></div>
|
||||
<div id="cart_summary" style="clear:both;float:left;">
|
||||
<ul>
|
||||
<li><span class="total_cart">{l s='Total products'}</span><span id="total_products"></span></li>
|
||||
<li><span class="total_cart">{l s='Total vouchers'}</span><span id="total_vouchers"></span></li>
|
||||
<li><span class="total_cart">{l s='Total shipping'}</span><span id="total_shipping"></span></li>
|
||||
<li><span class="total_cart">{l s='Total taxes'}</span><span id="total_taxes"></span></li>
|
||||
<li><span class="total_cart">{l s='Total without taxes'}</span><span id="total_without_taxes"></span></li>
|
||||
<li><span class="total_cart">{l s='Total with taxes'}</span><span id="total_with_taxes"></span></li>
|
||||
<li><span class="total_cart">{l s='Total products'}</span><span id="total_products"></span><span class="currency_sign"></span></li>
|
||||
<li><span class="total_cart">{l s='Total vouchers'}</span><span id="total_vouchers"></span><span class="currency_sign"></span></li>
|
||||
<li><span class="total_cart">{l s='Total shipping'}</span><span id="total_shipping"></span><span class="currency_sign"></span></li>
|
||||
<li><span class="total_cart">{l s='Total taxes'}</span><span id="total_taxes"></span><span class="currency_sign"></span></li>
|
||||
<li><span class="total_cart">{l s='Total without taxes'}</span><span id="total_without_taxes"></span><span class="currency_sign"></span></li>
|
||||
<li><span class="total_cart">{l s='Total with taxes'}</span><span id="total_with_taxes"></span><span class="currency_sign"></span></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="order_message_right">
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
<div class="bloc-command">
|
||||
<div class="button-command">
|
||||
{if (count($invoices_collection))}
|
||||
<a class="button" href="{$link->getAdminLink('AdminPdf')|escape:'htmlall':'UTF-8'}&submitAction=generateInvoicePDF&id_order={$order->id}">
|
||||
<a class="button" href="{$link->getAdminLink('AdminPdf')|escape:'htmlall':'UTF-8'}&submitAction=generateInvoicePDF&id_order={$order->id}" target="_blank">
|
||||
<img src="../img/admin/charged_ok.gif" alt="{l s='View invoice'}" /> {l s='View invoice'}
|
||||
</a>
|
||||
{else}
|
||||
@@ -73,7 +73,7 @@
|
||||
{/if}
|
||||
|
|
||||
{if (($currentState && $currentState->delivery) || $order->delivery_number)}
|
||||
<a class="button" href="{$link->getAdminLink('AdminPdf')|escape:'htmlall':'UTF-8'}&submitAction=generateDeliverySlipPDF&id_order={$order->id}">
|
||||
<a class="button" href="{$link->getAdminLink('AdminPdf')|escape:'htmlall':'UTF-8'}&submitAction=generateDeliverySlipPDF&id_order={$order->id}" target="_blank">
|
||||
<img src="../img/admin/delivery.gif" alt="{l s='View delivery slip'}" /> {l s='View delivery slip'}
|
||||
</a>
|
||||
{else}
|
||||
@@ -124,10 +124,10 @@
|
||||
<!-- History of status -->
|
||||
<table cellspacing="0" cellpadding="0" class="table history-status" style="width: 100%;">
|
||||
<colgroup>
|
||||
<col width="1%"/>
|
||||
<col width=""/>
|
||||
<col width="20%"/>
|
||||
<col width="20%"/>
|
||||
<col width="1%">
|
||||
<col width="">
|
||||
<col width="20%">
|
||||
<col width="20%">
|
||||
</colgroup>
|
||||
{foreach from=$history item=row key=key}
|
||||
{if ($key == 0)}
|
||||
@@ -299,12 +299,12 @@
|
||||
<form id="formAddPayment" method="post" action="{$current_index}&vieworder&id_order={$order->id}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}">
|
||||
<table class="table" width="100%" cellspacing="0" cellpadding="0">
|
||||
<colgroup>
|
||||
<col width="15%"/>
|
||||
<col width=""/>
|
||||
<col width="20%"/>
|
||||
<col width="10%"/>
|
||||
<col width="10%"/>
|
||||
<col width="1%"/>
|
||||
<col width="15%">
|
||||
<col width="">
|
||||
<col width="20%">
|
||||
<col width="10%">
|
||||
<col width="10%">
|
||||
<col width="1%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -751,7 +751,7 @@
|
||||
<a href="{$link->getAdminLink('AdminCustomerThreads')|escape:'htmlall':'UTF-8'}"><b>{l s='Click here'}</b> {l s='to see all messages.'}</a><br>
|
||||
<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>
|
||||
<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}
|
||||
@@ -787,6 +787,8 @@
|
||||
</fieldset>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="clear"> </div>
|
||||
<br /><br /><a href="{$current_index}&token={$smarty.get.token}"><img src="../img/admin/arrow2.gif" /> {l s='Back to list'}</a><br />
|
||||
{/block}
|
||||
{/block}
|
||||
|
||||
@@ -103,11 +103,11 @@
|
||||
<td class="col-left"><label>{l s='Manufacturer:'}</label></td>
|
||||
<td style="padding-bottom:5px;">
|
||||
<select name="id_manufacturer" id="id_manufacturer">
|
||||
<option value="0">- {l s='Choose (optional)'} -</option>
|
||||
<option value="0">-- {l s='Choose (optional)'} --</option>
|
||||
{if $product->id_manufacturer}
|
||||
<option value="{$product->id_manufacturer}" selected="selected">{$product->manufacturer_name}</option>
|
||||
{/if}
|
||||
<option disabled="disabled">-</option>
|
||||
<option disabled="disabled">----------</option>
|
||||
</select>
|
||||
<a class="button bt-icon confirm_leave" style="margin-bottom:0" href="{$link->getAdminLink('AdminManufacturers')|escape:'htmlall':'UTF-8'}&addmanufacturer">
|
||||
<img src="../img/admin/add.gif" alt="{l s='Create new manufacturer'}" title="{l s='Create new manufacturer'}" />
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
</td>
|
||||
<td style="padding-bottom:5px;">
|
||||
<select name="attribute" id="attribute" style="width: 200px;">
|
||||
<option value="0">-</option>
|
||||
<option value="0">---</option>
|
||||
</select>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
@@ -252,7 +252,7 @@
|
||||
<li style="float: left; width: {$imageWidth}px;">
|
||||
<input type="checkbox" name="id_image_attr[]" value="{$image.id_image}" id="id_image_attr_{$image.id_image}" />
|
||||
<label for="id_image_attr_{$image.id_image}" style="float: none;">
|
||||
<img src="{$smarty.const._THEME_PROD_DIR_}{$image.obj->getExistingImgPath()}-{$imageType}.jpg" alt="{$image.legend|escape:'htmlall':'UTF-8'}" title="{$image.legend|escape:'htmlall':'UTF-8'}" />
|
||||
<img src="{$smarty.const._THEME_PROD_DIR_}{$image.obj->getExistingImgPath()}-small_default.jpg" alt="{$image.legend|escape:'htmlall':'UTF-8'}" title="{$image.legend|escape:'htmlall':'UTF-8'}" />
|
||||
</label>
|
||||
</li>
|
||||
{/foreach}
|
||||
|
||||
@@ -106,6 +106,7 @@
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
$('#product-tab-content-wait').show();
|
||||
//product_type = $("input[name=type_product]:checked").val();
|
||||
if (product_type == product_type_pack)
|
||||
{
|
||||
|
||||
@@ -29,19 +29,6 @@
|
||||
<h4>{if isset($id_image)}{l s='Edit this product image'}{else}{l s='Add a new image to this product'}{/if}</h4> <div class="separation"></div><br />
|
||||
|
||||
<table cellpadding="5" style="width:100%">
|
||||
<tr>
|
||||
<td class="col-left">
|
||||
<label>{l s='Legend:'}</label>
|
||||
</td>
|
||||
<td style="padding-bottom:5px;" class="translatable">
|
||||
{foreach from=$languages item=language}
|
||||
<div class="lang_{$language.id_lang}" style="{if !$language.is_default}display: none;{/if} float: left;">
|
||||
<input class="updateCurrentText" size="43" type="text" {if !$product->id}disabled="disabled"{/if} id="legend_{$language.id_lang}" name="legend_{$language.id_lang}" value="{$product->name[$language.id_lang]|escape:'htmlall':'UTF-8'}"/>
|
||||
<span class="hint" name="help_box">{l s='Invalid characters:'} <>;=#{}<span class="hint-pointer"> </span></span>
|
||||
</div>
|
||||
{/foreach}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-left"><label class="file_upload_label">{l s='File:'}</label></td>
|
||||
<td style="padding-bottom:5px;">
|
||||
@@ -70,7 +57,6 @@
|
||||
<thead>
|
||||
<tr class="nodrag nodrop">
|
||||
<th style="width: 100px;">{l s='Image'}</th>
|
||||
<th>{l s='Legend'}</th>
|
||||
<th>{l s='Position'}</th>
|
||||
{if $shops}
|
||||
{foreach from=$shops item=shop}
|
||||
@@ -92,10 +78,9 @@
|
||||
<tr id="image_id">
|
||||
<td style="padding: 4px;">
|
||||
<a href="{$smarty.const._THEME_PROD_DIR_}image_path.jpg" class="fancybox">
|
||||
<img src="{$smarty.const._THEME_PROD_DIR_}{$iso_lang}-default-{$imageType}.jpg" alt="legend" title="legend" />
|
||||
<img src="{$smarty.const._THEME_PROD_DIR_}{$iso_lang}-default-small_default.jpg" alt="image_id" title="image_id" />
|
||||
</a>
|
||||
</td>
|
||||
<td>legend</td>
|
||||
<td id="td_image_id" class="pointer dragHandle center positionImage">
|
||||
image_position
|
||||
</td>
|
||||
@@ -116,6 +101,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<script type="text/javascript">
|
||||
var upbutton = '{l s='Upload an image'}';
|
||||
var token = '{$token}';
|
||||
@@ -142,7 +128,7 @@
|
||||
}
|
||||
else
|
||||
assoc = false;
|
||||
imageLine({$image->id}, "{$image->getExistingImgPath()}", {$image->position}, "{if $image->cover}enabled{else}forbbiden{/if}", assoc, "{$image->legend[$default_language]|@addcslashes:'\"'}");
|
||||
imageLine({$image->id}, "{$image->getExistingImgPath()}", {$image->position}, "{if $image->cover}enabled{else}forbbiden{/if}", assoc);
|
||||
{/foreach}
|
||||
{literal}
|
||||
$("#imageTable").tableDnD(
|
||||
@@ -161,20 +147,20 @@
|
||||
updateImagePosition(image_up);
|
||||
}
|
||||
});
|
||||
|
||||
var filecheck = 1;
|
||||
var params = new Array;
|
||||
params['id_product'] = {/literal}{$id_product|intval}{literal};
|
||||
params['id_category'] = {/literal}{$id_category_default|intval}{literal};
|
||||
params['token'] = "{/literal}{$token}{literal}";
|
||||
params['tab'] = "AdminProducts";
|
||||
params['action'] = "addImage";
|
||||
params['ajax'] = 1;
|
||||
uploader = new qq.FileUploader(
|
||||
var uploader = new qq.FileUploader(
|
||||
{
|
||||
element: document.getElementById("file-uploader"),
|
||||
action: "ajax-tab.php",
|
||||
debug: false,
|
||||
params: {
|
||||
id_product : {/literal}{$id_product}{literal},
|
||||
id_category : {/literal}{$id_category_default}{literal},
|
||||
token : "{/literal}{$token}{literal}",
|
||||
tab : "AdminProducts",
|
||||
action : 'addImage',
|
||||
ajax: 1
|
||||
},
|
||||
onComplete: function(id, fileName, responseJSON)
|
||||
{
|
||||
var percent = ((filecheck * 100) / nbfile);
|
||||
@@ -199,7 +185,7 @@
|
||||
cover = "forbbiden";
|
||||
if (responseJSON.cover == "1")
|
||||
cover = "enabled";
|
||||
imageLine(responseJSON.id, responseJSON.path, responseJSON.position, cover, responseJSON.shops, responseJSON.legend[{/literal}{$default_language|intval}{literal}])
|
||||
imageLine(responseJSON.id, responseJSON.path, responseJSON.position, cover, responseJSON.shops)
|
||||
$("#imageTable tr:last").after(responseJSON.html);
|
||||
$("#countImage").html(parseInt($("#countImage").html()) + 1);
|
||||
$("#img" + id).remove();
|
||||
@@ -212,12 +198,6 @@
|
||||
},
|
||||
onSubmit: function(id, filename)
|
||||
{
|
||||
$('input[id^="legend_"]').each(function()
|
||||
{
|
||||
id = $(this).prop("id").replace("legend_", "legend[") + "]";
|
||||
params[id] = $(this).val();
|
||||
});
|
||||
uploader.setParams(params);
|
||||
$("#imageTable").show();
|
||||
$("#listImage").append("<li id='img"+id+"'><div class=\"float\" >" + filename + "</div></div><a style=\"margin-left:10px\"href=\"javascript:delQueue(" + id +");\"><img src=\"../img/admin/disabled.gif\" alt=\"\" border=\"0\"></a><p class=\"errorImg\"></p></li>");
|
||||
}
|
||||
@@ -329,14 +309,13 @@
|
||||
$("#img" + id).remove();
|
||||
}
|
||||
|
||||
function imageLine(id, path, position, cover, shops, legend)
|
||||
function imageLine(id, path, position, cover, shops)
|
||||
{
|
||||
line = $("#lineType").html();
|
||||
line = line.replace(/image_id/g, id);
|
||||
line = line.replace(/[a-z]{0,2}-default/g, path);
|
||||
line = line.replace(/[a-z]{2}-default/g, path);
|
||||
line = line.replace(/image_path/g, path);
|
||||
line = line.replace(/image_position/g, position);
|
||||
line = line.replace(/legend/g, legend);
|
||||
line = line.replace(/blank/g, cover);
|
||||
line = line.replace(/<tbody>/gi, "");
|
||||
line = line.replace(/<\/tbody>/gi, "");
|
||||
@@ -351,6 +330,7 @@
|
||||
|
||||
$("#imageList").append(line);
|
||||
}
|
||||
|
||||
$('.fancybox').fancybox();
|
||||
});
|
||||
{/literal}
|
||||
|
||||
@@ -375,19 +375,8 @@
|
||||
<td style="padding-bottom:5px;" class="translatable">
|
||||
{foreach from=$languages item=language}
|
||||
<div class="lang_{$language.id_lang}" style="{if !$language.is_default}display: none;{/if}float: left;">
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
$().ready(function () {
|
||||
var input_id = '{/literal}tags_{$language.id_lang}{literal}';
|
||||
$('#'+input_id).tagify({delimiters: [13,44], addTagPrompt: '{/literal}{l s='Add tag' js=1}{literal}'});
|
||||
$({/literal}'#{$table}{literal}_form').submit( function() {
|
||||
$(this).find('#'+input_id).val($('#'+input_id).tagify('serialize'));
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/literal}
|
||||
<input size="55" type="text" id="tags_{$language.id_lang}" name="tags_{$language.id_lang}"
|
||||
value="{$product->getTags($language.id_lang, true)|htmlentitiesUTF8}" class="tagify" />
|
||||
value="{$product->getTags($language.id_lang, true)|htmlentitiesUTF8}" />
|
||||
<span class="hint" name="help_box">{l s='Forbidden characters:'} !<;>;?=+#"°{}_$%<span class="hint-pointer"> </span></span>
|
||||
</div>
|
||||
{/foreach}
|
||||
|
||||
@@ -223,7 +223,7 @@ $(document).ready(function () {
|
||||
<tr>
|
||||
<td class="col-left"><label><b>{l s='Final retail price:'}</b></label></td>
|
||||
<td>
|
||||
<span>
|
||||
<span {if !$country_display_tax_label}style="display:none"{/if} >
|
||||
{$currency->prefix}<span id="finalPrice" style="font-weight: bold;">0.00</span>{$currency->suffix}<span {if $ps_tax}style="display:none;"{/if}> ({l s='tax incl.'})</span>
|
||||
</span>
|
||||
<span {if $ps_tax}style="display:none;"{/if} >
|
||||
@@ -249,7 +249,7 @@ $(document).ready(function () {
|
||||
<script type="text/javascript">
|
||||
var product_prices = new Array();
|
||||
{foreach from=$combinations item='combination'}
|
||||
product_prices['{$combination.id_product_attribute}'] = '{$combination.price|@addcslashes:'\''}';
|
||||
product_prices['{$combination.id_product_attribute}'] = '{$combination.price}';
|
||||
{/foreach}
|
||||
</script>
|
||||
<div id="add_specific_price" style="display: none;">
|
||||
@@ -375,7 +375,7 @@ $(document).ready(function () {
|
||||
<div class="margin-form">
|
||||
<input type="text" name="sp_reduction" value="0.00" size="11" />
|
||||
<select name="sp_reduction_type">
|
||||
<option selected="selected">-</option>
|
||||
<option selected="selected">---</option>
|
||||
<option value="amount">{l s='Amount'}</option>
|
||||
<option value="percentage">{l s='Percentage'}</option>
|
||||
</select>
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
<p>{l s='Click "Save and Stay" after changing selected suppliers to display the associated product references.'}</p>
|
||||
<div id="suppliers_accordion" style="margin-top:10px; display:block;">
|
||||
{foreach from=$associated_suppliers item=supplier}
|
||||
<h3 style="margin-bottom:0;"><a href="#">{if isset($supplier->name)}{$supplier->name}{/if}</a></h3>
|
||||
<h3 style="margin-bottom:0;"><a href="#">{$supplier->name}</a></h3>
|
||||
<div style="display:block;">
|
||||
|
||||
<table cellpadding="10" cellspacing="0" class="table">
|
||||
|
||||
@@ -58,7 +58,6 @@
|
||||
$('#file_missing').hide();
|
||||
$('#virtual_product_name').attr('value', fileName);
|
||||
$("#upload-confirmation .error").remove();
|
||||
$('#upload-confirmation div').find('span').remove();
|
||||
$('#upload-confirmation div').prepend('<span>{l s='The file'} "<a class="link" href="get-file-admin.php?file='+msg+'&filename='+fileName+'">'+fileName+'</a>" {l s='has successfully been uploaded'}' +
|
||||
'<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="' + msg + '" /></span>');
|
||||
$("#upload-confirmation").show();
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
<label>{l s='Filter by product:'}</label>
|
||||
<div class="margin-left">
|
||||
<select id="selectProduct" name="selectProduct" style="width: 200px;" onfocus="fillProducts();" onchange="updateConversionRate(this.value);">
|
||||
<option value="0" selected="selected">- {l s='All'} -</option>
|
||||
<option value="0" selected="selected">-- {l s='All'} --</option>
|
||||
</select>
|
||||
</div>
|
||||
<br class="clear" />
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<div class="margin-form">
|
||||
<select id="id_category" name="id_category">
|
||||
{foreach from=$categories item='category'}
|
||||
<option value="{$category.id_category|intval}">({$category.id_category|intval}) {$category.name}</option>
|
||||
<option value="{$category.id_category}">{$category.name}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<a class="button bt-icon" href="#" id="add_condition_category">
|
||||
|
||||
@@ -54,7 +54,7 @@ $(document).ready(function() {
|
||||
</div>
|
||||
|
||||
<div class="margin-form">
|
||||
<input type="submit" id="{$table}_form_submit_btn" value="{l s='Save'}" name="submitChangestate" class="button" style="display: none;">
|
||||
<input type="submit" id="_form_submit_btn" value="{l s='Save'}" name="submitChangestate" class="button" style="display: none;">
|
||||
</div>
|
||||
{/if}
|
||||
{/block}
|
||||
|
||||
@@ -34,51 +34,54 @@
|
||||
<title>{$meta_title} - PrestaShop™</title>
|
||||
{if $display_header}
|
||||
<script type="text/javascript">
|
||||
var help_class_name = '{$controller_name|@addcslashes:'\''}';
|
||||
var iso_user = '{$iso_user|@addcslashes:'\''}';
|
||||
var country_iso_code = '{$country_iso_code|@addcslashes:'\''}';
|
||||
var _PS_VERSION_ = '{$smarty.const._PS_VERSION_|@addcslashes:'\''}';
|
||||
var helpboxes = {$help_box|intval};
|
||||
var roundMode = {$round_mode|intval};
|
||||
{if isset($shop_context)}
|
||||
{if $shop_context == Shop::CONTEXT_ALL}
|
||||
var youEditFieldFor = '{l s='A modification of this field will be applied for all shops' js=1}';
|
||||
{elseif $shop_context == Shop::CONTEXT_GROUP}
|
||||
var youEditFieldFor = '{l s='A modification of this field will be applied for all shops of group' js=1} <b>{$shop_name|@addcslashes:'\''}</b>';
|
||||
{else}
|
||||
var youEditFieldFor = '{l s='A modification of this field will be applied for the shop' js=1} <b>{$shop_name|@addcslashes:'\''}</b>';
|
||||
{/if}
|
||||
{else}
|
||||
var youEditFieldFor = '';
|
||||
{/if}
|
||||
var autorefresh_notifications = '{$autorefresh_notifications|@addcslashes:'\''}';
|
||||
var new_order_msg = '{l s='A new order has been placed on your shop.' js=1}';
|
||||
var order_number_msg = '{l s='Order number: ' js=1}';
|
||||
var total_msg = '{l s='Total: ' js=1}';
|
||||
var from_msg = '{l s='From: ' js=1}';
|
||||
var see_order_msg = '{l s='View this order' js=1}';
|
||||
var new_customer_msg = '{l s='A new customer registered on your shop.' js=1}';
|
||||
var customer_name_msg = '{l s='Customer name: ' js=1}';
|
||||
var see_customer_msg = '{l s='View this customer' js=1}';
|
||||
var new_msg = '{l s='A new message posted on your shop.' js=1}';
|
||||
var excerpt_msg = '{l s='Excerpt: ' js=1}';
|
||||
var see_msg = '{l s='Read this message' js=1}';
|
||||
var token_admin_orders = '{getAdminToken tab='AdminOrders'}';
|
||||
var token_admin_customers = '{getAdminToken tab='AdminCustomers'}';
|
||||
var token_admin_customer_threads = '{getAdminToken tab='AdminCustomerThreads'}';
|
||||
var currentIndex = '{$currentIndex|@addcslashes:'\''}';
|
||||
var choose_language_translate = '{l s='Choose language' js=1}';
|
||||
var help_class_name = '{$controller_name}';
|
||||
var iso_user = '{$iso_user}';
|
||||
var country_iso_code = '{$country_iso_code}';
|
||||
var _PS_VERSION_ = '{$smarty.const._PS_VERSION_}';
|
||||
|
||||
var helpboxes = {$help_box};
|
||||
var roundMode = {$round_mode};
|
||||
{if isset($shop_context)}
|
||||
{if $shop_context == Shop::CONTEXT_ALL}
|
||||
var youEditFieldFor = "{l s='A modification of this field will be applied for all shops' slashes=1 }";
|
||||
{elseif $shop_context == Shop::CONTEXT_GROUP}
|
||||
var youEditFieldFor = "{l s='A modification of this field will be applied for all shops of group ' slashes=1 }<b>{$shop_name}</b>";
|
||||
{else}
|
||||
var youEditFieldFor = "{l s='A modification of this field will be applied for the shop ' slashes=1 }<b>{$shop_name}</b>";
|
||||
{/if}
|
||||
{else}
|
||||
var youEditFieldFor = '';
|
||||
{/if}
|
||||
{* Notifications vars *}
|
||||
var autorefresh_notifications = '{$autorefresh_notifications}';
|
||||
var new_order_msg = '{l s='A new order has been placed on your shop.' slashes=1}';
|
||||
var order_number_msg = '{l s='Order number: ' slashes=1}';
|
||||
var total_msg = '{l s='Total: ' slashes=1}';
|
||||
var from_msg = '{l s='From: ' slashes=1}';
|
||||
var see_order_msg = '{l s='View this order' slashes=1}';
|
||||
var new_customer_msg = '{l s='A new customer registered on your shop.' slashes=1}';
|
||||
var customer_name_msg = '{l s='Customer name: ' slashes=1}';
|
||||
var see_customer_msg = '{l s='View this customer' slashes=1}';
|
||||
var new_msg = '{l s='A new message posted on your shop.' slashes=1}';
|
||||
var excerpt_msg = '{l s='Excerpt: ' slashes=1}';
|
||||
var see_msg = '{l s='Read this message' slashes=1}';
|
||||
var token_admin_orders = '{getAdminToken tab='AdminOrders' slashes=1}';
|
||||
var token_admin_customers = '{getAdminToken tab='AdminCustomers' slashes=1}';
|
||||
var token_admin_customer_threads = '{getAdminToken tab='AdminCustomerThreads' slashes=1}';
|
||||
var currentIndex = '{$currentIndex}';
|
||||
var choose_language_translate = "{l s='Choose language' slashes=1 }";
|
||||
</script>
|
||||
{/if}
|
||||
|
||||
{if isset($css_files)}
|
||||
{foreach from=$css_files key=css_uri item=media}
|
||||
<link href="{$css_uri}" rel="stylesheet" type="text/css" media="{$media}" />
|
||||
{/foreach}
|
||||
{foreach from=$css_files key=css_uri item=media}
|
||||
<link href="{$css_uri}" rel="stylesheet" type="text/css" media="{$media}" />
|
||||
{/foreach}
|
||||
{/if}
|
||||
{if isset($js_files)}
|
||||
{foreach from=$js_files item=js_uri}
|
||||
<script type="text/javascript" src="{$js_uri}"></script>
|
||||
{/foreach}
|
||||
{foreach from=$js_files item=js_uri}
|
||||
<script type="text/javascript" src="{$js_uri}"></script>
|
||||
{/foreach}
|
||||
{/if}
|
||||
<link rel="icon" type="image/vnd.microsoft.icon" href="{$img_dir}favicon.ico" />
|
||||
<link rel="shortcut icon" type="image/x-icon" href="{$img_dir}favicon.ico" />
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
<script type="text/javascript">
|
||||
$().ready(function () {
|
||||
var input_id = '{/literal}{if isset($input.id)}{$input.id}_{$language.id_lang}{else}{$input.name}_{$language.id_lang}{/if}{literal}';
|
||||
$('#'+input_id).tagify({delimiters: [13,44], addTagPrompt: '{/literal}{l s='Add tag' js=1}{literal}'});
|
||||
$('#'+input_id).tagify({addTagPrompt: '{/literal}{l s='Add tag' js=1}{literal}'});
|
||||
$({/literal}'#{$table}{literal}_form').submit( function() {
|
||||
$(this).find('#'+input_id).val($('#'+input_id).tagify('serialize'));
|
||||
});
|
||||
@@ -97,7 +97,8 @@
|
||||
<script type="text/javascript">
|
||||
$().ready(function () {
|
||||
var input_id = '{/literal}{if isset($input.id)}{$input.id}{else}{$input.name}{/if}{literal}';
|
||||
$('#'+input_id).tagify({delimiters: [13,44], addTagPrompt: '{/literal}{l s='Add tag'}{literal}'});
|
||||
$('#'+input_id).tagify();
|
||||
$('#'+input_id).tagify({addTagPrompt: '{/literal}{l s='Add tag'}{literal}'});
|
||||
$({/literal}'#{$table}{literal}_form').submit( function() {
|
||||
$(this).find('#'+input_id).val($('#'+input_id).tagify('serialize'));
|
||||
});
|
||||
@@ -167,7 +168,7 @@
|
||||
{/if}
|
||||
>{$option->$input.options.name}</option>
|
||||
{elseif $option == "-"}
|
||||
<option value="">-</option>
|
||||
<option value="">--</option>
|
||||
{else}
|
||||
<option value="{$option[$input.options.id]}"
|
||||
{if isset($input.multiple)}
|
||||
@@ -191,7 +192,7 @@
|
||||
{/if}
|
||||
{elseif $input.type == 'radio'}
|
||||
{foreach $input.values as $value}
|
||||
<input type="radio" name="{$input.name}" id="{$value.id}" value="{$value.value|escape:'htmlall':'UTF-8'}"
|
||||
<input type="radio" name="{$input.name}"id="{$value.id}" value="{$value.value|escape:'htmlall':'UTF-8'}"
|
||||
{if $fields_value[$input.name] == $value.value}checked="checked"{/if}
|
||||
{if isset($input.disabled) && $input.disabled}disabled="disabled"{/if} />
|
||||
<label {if isset($input.class)}class="{$input.class}"{/if} for="{$value.id}">
|
||||
@@ -236,7 +237,7 @@
|
||||
{if isset($fields_value[$input.name].image) && $fields_value[$input.name].image}
|
||||
<div id="image">
|
||||
{$fields_value[$input.name].image}
|
||||
<p align="center">{l s='File size'} {$fields_value[$input.name].size}{l s='kb'}</p>
|
||||
<p align="center">{l s='File size'} {$fields_value[$input.name].size}kb</p>
|
||||
<a href="{$current}&{$identifier}={$form_id}&token={$token}&deleteImage=1">
|
||||
<img src="../img/admin/delete.gif" alt="{l s='Delete'}" /> {l s='Delete'}
|
||||
</a>
|
||||
|
||||
@@ -24,11 +24,11 @@
|
||||
*}
|
||||
{if count($categories) && isset($categories)}
|
||||
<script type="text/javascript">
|
||||
var inputName = '{$categories.input_name|@addcslashes:'\''}';
|
||||
var inputName = '{$categories.input_name}';
|
||||
var use_radio = {if $categories.use_radio}1{else}0{/if};
|
||||
var selectedCat = {$categories.selected_cat|@implode|intval};
|
||||
var selectedLabel = '{$categories.trads.selected|@addcslashes:'\''}';
|
||||
var home = '{$categories.trads.Root.name|@addcslashes:'\''}';
|
||||
var selectedCat = '{implode value=$categories.selected_cat}';
|
||||
var selectedLabel = '{$categories.trads.selected}';
|
||||
var home = '{$categories.trads.Root.name}';
|
||||
var use_radio = {if $categories.use_radio}1{else}0{/if};
|
||||
var use_context = {if isset($categories.use_context)}1{else}0{/if};
|
||||
$(document).ready(function(){
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
{/if}
|
||||
class="{if !$no_link}pointer{/if}
|
||||
{if isset($params.position) && $order_by == 'position' && $order_way != 'DESC'} dragHandle{/if}
|
||||
{if isset($params.class)} {$params.class}{/if}
|
||||
{if isset($params.align)} {$params.align}{/if}"
|
||||
{if (!isset($params.position) && !$no_link && !isset($params.remove_onclick))}
|
||||
onclick="document.location = '{$current_index}&{$identifier}={$tr.$identifier}{if $view}&view{else}&update{/if}{$table}&token={$token}'">
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
<select name="{$list_id}_pagination" onchange="submit()">
|
||||
{* Choose number of results per page *}
|
||||
{foreach $pagination AS $value}
|
||||
<option value="{$value|intval}"{if $selected_pagination == $value && $selected_pagination != NULL} selected="selected"{elseif $selected_pagination == NULL && $value == $pagination[1]} selected="selected2"{/if}>{$value|intval}</option>
|
||||
<option value="{$value|intval}"{if $selected_pagination == $value} selected="selected" {elseif $selected_pagination == NULL && $value == $pagination[1]} selected="selected2"{/if}>{$value|intval}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
/ {$list_total} {l s='result(s)'}
|
||||
@@ -187,9 +187,9 @@
|
||||
{else}
|
||||
{if $params.type == 'bool'}
|
||||
<select onchange="$('#submitFilterButton{$list_id}').focus();$('#submitFilterButton{$list_id}').click();" name="{$list_id}Filter_{$key}">
|
||||
<option value="">-</option>
|
||||
<option value="1"{if $params.value == 1} selected="selected"{/if}>{l s='Yes'}</option>
|
||||
<option value="0"{if $params.value == 0 && $params.value != ''} selected="selected"{/if}>{l s='No'}</option>
|
||||
<option value="">--</option>
|
||||
<option value="1" {if $params.value == 1} selected="selected" {/if}>{l s='Yes'}</option>
|
||||
<option value="0" {if $params.value == 0 && $params.value != ''} selected="selected" {/if}>{l s='No'}</option>
|
||||
</select>
|
||||
{elseif $params.type == 'date' || $params.type == 'datetime'}
|
||||
{l s='From'} <input type="text" class="filter datepicker" id="{$params.id_date}_0" name="{$params.name_date}[0]" value="{if isset($params.value.0)}{$params.value.0}{/if}"{if isset($params.width)} style="width:70px"{/if}/><br />
|
||||
@@ -197,10 +197,10 @@
|
||||
{elseif $params.type == 'select'}
|
||||
{if isset($params.filter_key)}
|
||||
<select onchange="$('#submitFilterButton{$list_id}').focus();$('#submitFilterButton{$list_id}').click();" name="{$list_id}Filter_{$params.filter_key}" {if isset($params.width)} style="width:{$params.width}px"{/if}>
|
||||
<option value=""{if $params.value == ''} selected="selected"{/if}>-</option>
|
||||
<option value="" {if $params.value == ''} selected="selected" {/if}>--</option>
|
||||
{if isset($params.list) && is_array($params.list)}
|
||||
{foreach $params.list AS $option_value => $option_display}
|
||||
<option value="{$option_value}" {if $params.value != '' && ($option_display == $params.value || $option_value == $params.value)} selected="selected"{/if}>{$option_display}</option>
|
||||
<option value="{$option_value}" {if $option_display == $params.value || $option_value == $params.value} selected="selected"{/if}>{$option_display}</option>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</select>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
|
||||
<div id="{$table}_toolbar" class="toolbar-placeholder">
|
||||
<div class="toolbar-placeholder">
|
||||
<div class="toolbarBox {if $toolbar_scroll}toolbarHead{/if}">
|
||||
{block name=toolbarBox}
|
||||
<ul class="cc_button">
|
||||
@@ -52,7 +52,7 @@
|
||||
var modules_list_loaded = false;
|
||||
$(function() {
|
||||
//get reference on save link
|
||||
btn_save = $('#{$table}_toolbar span[class~="process-icon-save"]').parent();
|
||||
btn_save = $('span[class~="process-icon-save"]').parent();
|
||||
|
||||
//get reference on form submit button
|
||||
btn_submit = $('#{$table}_form_submit_btn');
|
||||
@@ -87,15 +87,12 @@
|
||||
btn_submit.hide();
|
||||
//bind enter key press to validate form
|
||||
$('#{$table}_form').keypress(function (e) {
|
||||
if (e.which == 13 && e.target.localName != 'textarea' && !e.target.hasClass('tagify'))
|
||||
if (e.which == 13 && e.target.localName != 'textarea')
|
||||
$('#desc-{$table}-save').click();
|
||||
});
|
||||
//submit the form
|
||||
{block name=formSubmit}
|
||||
btn_save.click(function() {
|
||||
// Vars
|
||||
var btn_submit = $('#{$table}_form_submit_btn');
|
||||
|
||||
// Avoid double click
|
||||
if (submited)
|
||||
return false;
|
||||
|
||||
@@ -264,17 +264,13 @@ class AddressCore extends ObjectModel
|
||||
if(!isset($id_address) || empty($id_address))
|
||||
return false;
|
||||
|
||||
$cache_id = 'Address::isCountryActiveById_'.(int)$id_address;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$result = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getvalue('
|
||||
SELECT c.`active`
|
||||
FROM `'._DB_PREFIX_.'address` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'country` c ON c.`id_country` = a.`id_country`
|
||||
WHERE a.`id_address` = '.(int)$id_address);
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT c.`active`
|
||||
FROM `'._DB_PREFIX_.'address` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'country` c ON c.`id_country` = a.`id_country`
|
||||
WHERE a.`id_address` = '.(int)$id_address))
|
||||
return false;
|
||||
return ($result['active']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -328,17 +324,12 @@ class AddressCore extends ObjectModel
|
||||
{
|
||||
if (!$id_customer)
|
||||
return false;
|
||||
$cache_id = 'Address::getFirstCustomerAddressId_'.(int)$id_customer.'-'.(bool)$active;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$result = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT `id_address`
|
||||
FROM `'._DB_PREFIX_.'address`
|
||||
WHERE `id_customer` = '.(int)$id_customer.' AND `deleted` = 0'.($active ? ' AND `active` = 1' : '')
|
||||
);
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT `id_address`
|
||||
FROM `'._DB_PREFIX_.'address`
|
||||
WHERE `id_customer` = '.(int)$id_customer.' AND `deleted` = 0'.($active ? ' AND `active` = 1' : '')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,4 +379,5 @@ class AddressCore extends ObjectModel
|
||||
$query->where('id_warehouse = 0');
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,6 @@ class AddressFormatCore extends ObjectModel
|
||||
'outstanding_allow_amount',
|
||||
'call_prefix',
|
||||
'definition',
|
||||
'debug_list'
|
||||
);
|
||||
|
||||
public static $forbiddenClassList = array(
|
||||
|
||||
@@ -1500,7 +1500,7 @@ abstract class AdminTabCore
|
||||
case 'bool':
|
||||
echo '
|
||||
<select name="'.$this->table.'Filter_'.$key.'">
|
||||
<option value="">-</option>
|
||||
<option value="">--</option>
|
||||
<option value="1"'.($value == 1 ? ' selected="selected"' : '').'>'.$this->l('Yes').'</option>
|
||||
<option value="0"'.(($value == 0 && $value != '') ? ' selected="selected"' : '').'>'.$this->l('No').'</option>
|
||||
</select>';
|
||||
@@ -1524,7 +1524,7 @@ abstract class AdminTabCore
|
||||
if (isset($params['filter_key']))
|
||||
{
|
||||
echo '<select onchange="$(\'#submitFilter'.$this->table.'\').focus();$(\'#submitFilter'.$this->table.'\').click();" name="'.$this->table.'Filter_'.$params['filter_key'].'" '.(isset($params['width']) ? 'style="width: '.$params['width'].'px"' : '').'>
|
||||
<option value=""'.(($value == 0 && $value != '') ? ' selected="selected"' : '').'>-</option>';
|
||||
<option value=""'.(($value == 0 && $value != '') ? ' selected="selected"' : '').'>--</option>';
|
||||
if (isset($params['select']) && is_array($params['select']))
|
||||
foreach ($params['select'] as $optionValue => $optionDisplay)
|
||||
{
|
||||
|
||||
@@ -124,21 +124,5 @@ class AliasCore extends ObjectModel
|
||||
{
|
||||
return Configuration::get('PS_ALIAS_FEATURE_ACTIVE');
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is allow to know if a alias exist for AdminImportController
|
||||
* @since 1.5.6.0
|
||||
* @return bool
|
||||
*/
|
||||
public static function aliasExists($id_alias)
|
||||
{
|
||||
$row = Db::getInstance()->getRow('
|
||||
SELECT `id_alias`
|
||||
FROM '._DB_PREFIX_.'alias a
|
||||
WHERE a.`id_alias` = '.(int)$id_alias
|
||||
);
|
||||
|
||||
return isset($row['id_alias']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ class AttributeCore extends ObjectModel
|
||||
ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)$id_lang.')
|
||||
'.Shop::addSqlAssociation('attribute_group', 'ag').'
|
||||
'.Shop::addSqlAssociation('attribute', 'a').'
|
||||
'.($not_null ? 'WHERE a.`id_attribute` IS NOT NULL AND al.`name` IS NOT NULL AND agl.`id_attribute_group` IS NOT NULL' : '').'
|
||||
'.($not_null ? 'WHERE a.`id_attribute` IS NOT NULL AND al.`name` IS NOT NULL' : '').'
|
||||
ORDER BY agl.`name` ASC, a.`position` ASC
|
||||
');
|
||||
}
|
||||
@@ -343,4 +343,4 @@ class AttributeCore extends ObjectModel
|
||||
|
||||
return (is_numeric($position)) ? $position : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,8 +49,6 @@ class Autoload
|
||||
*/
|
||||
public $index = array();
|
||||
|
||||
public $_include_override_path = true;
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
$this->root_dir = dirname(dirname(__FILE__)).'/';
|
||||
@@ -122,33 +120,33 @@ class Autoload
|
||||
{
|
||||
$classes = array_merge(
|
||||
$this->getClassesFromDir('classes/'),
|
||||
$this->getClassesFromDir('controllers/')
|
||||
$this->getClassesFromDir('override/classes/'),
|
||||
$this->getClassesFromDir('controllers/'),
|
||||
$this->getClassesFromDir('override/controllers/')
|
||||
);
|
||||
|
||||
if ($this->_include_override_path)
|
||||
$classes = array_merge(
|
||||
$classes,
|
||||
$this->getClassesFromDir('override/classes/'),
|
||||
$this->getClassesFromDir('override/controllers/')
|
||||
);
|
||||
|
||||
ksort($classes);
|
||||
$content = '<?php return '.var_export($classes, true).'; ?>';
|
||||
|
||||
// Write classes index on disc to cache it
|
||||
$filename = $this->root_dir.Autoload::INDEX_FILE;
|
||||
$filename_tmp = tempnam(dirname($filename), basename($filename.'.'));
|
||||
if ($filename_tmp !== false && file_put_contents($filename_tmp, $content, LOCK_EX) !== false)
|
||||
if ((file_exists($filename) && !is_writable($filename)) || !is_writable(dirname($filename)))
|
||||
{
|
||||
if (!rename($filename_tmp, $filename))
|
||||
unlink($filename_tmp);
|
||||
else
|
||||
@chmod($filename, 0666);
|
||||
header('HTTP/1.1 503 temporarily overloaded');
|
||||
// Cannot use PrestaShopException in this context
|
||||
die('/cache/class_index.php is not writable, please give write permissions (chmod 666) on this file.');
|
||||
}
|
||||
// $filename_tmp couldn't be written. $filename should be there anyway (even if outdated), no need to die.
|
||||
else
|
||||
error_log('Cannot write temporary file '.$filename_tmp);
|
||||
|
||||
{
|
||||
$filename_tmp = tempnam(dirname($filename), basename($filename.'.'));
|
||||
if($filename_tmp !== FALSE and file_put_contents($filename_tmp, $content, LOCK_EX) !== FALSE)
|
||||
{
|
||||
@rename($filename_tmp, $filename);
|
||||
@chmod($filename, 0666);
|
||||
}
|
||||
else
|
||||
// $filename_tmp couldn't be written. $filename should be there anyway (even if outdated), no need to die.
|
||||
error_log('Cannot write temporary file '.$filename_tmp);
|
||||
}
|
||||
$this->index = $classes;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ class CMSCore extends ObjectModel
|
||||
public $link_rewrite;
|
||||
public $id_cms_category;
|
||||
public $position;
|
||||
public $indexation;
|
||||
public $active;
|
||||
|
||||
/**
|
||||
@@ -47,7 +46,6 @@ class CMSCore extends ObjectModel
|
||||
'fields' => array(
|
||||
'id_cms_category' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
|
||||
'position' => array('type' => self::TYPE_INT),
|
||||
'indexation' => array('type' => self::TYPE_BOOL),
|
||||
'active' => array('type' => self::TYPE_BOOL),
|
||||
|
||||
// Lang fields
|
||||
@@ -190,7 +188,7 @@ class CMSCore extends ObjectModel
|
||||
return (Db::getInstance()->getValue($sql));
|
||||
}
|
||||
|
||||
public static function getCMSPages($id_lang = null, $id_cms_category = null, $active = true, $id_shop = null)
|
||||
public static function getCMSPages($id_lang = null, $id_cms_category = null, $active = true)
|
||||
{
|
||||
$sql = new DbQuery();
|
||||
$sql->select('*');
|
||||
@@ -198,9 +196,6 @@ class CMSCore extends ObjectModel
|
||||
if ($id_lang)
|
||||
$sql->innerJoin('cms_lang', 'l', 'c.id_cms = l.id_cms AND l.id_lang = '.(int)$id_lang);
|
||||
|
||||
if ($id_shop)
|
||||
$sql->innerJoin('cms_shop', 'cs', 'c.id_cms = cs.id_cms AND cs.id_shop = '.(int)$id_shop);
|
||||
|
||||
if ($active)
|
||||
$sql->where('c.active = 1');
|
||||
|
||||
|
||||
@@ -277,20 +277,17 @@ class CarrierCore extends ObjectModel
|
||||
|
||||
public function getMaxDeliveryPriceByWeight($id_zone)
|
||||
{
|
||||
$cache_id = 'Carrier::getMaxDeliveryPriceByWeight_'.(int)$this->id.'-'.(int)$id_zone;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$sql = 'SELECT d.`price`
|
||||
FROM `'._DB_PREFIX_.'delivery` d
|
||||
INNER JOIN `'._DB_PREFIX_.'range_weight` w ON d.`id_range_weight` = w.`id_range_weight`
|
||||
WHERE d.`id_zone` = '.(int)$id_zone.'
|
||||
AND d.`id_carrier` = '.(int)$this->id.'
|
||||
'.Carrier::sqlDeliveryRangeShop('range_weight').'
|
||||
ORDER BY w.`delimiter2` DESC';
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
$sql = 'SELECT d.`price`
|
||||
FROM `'._DB_PREFIX_.'delivery` d
|
||||
INNER JOIN `'._DB_PREFIX_.'range_weight` w ON d.`id_range_weight` = w.`id_range_weight`
|
||||
WHERE d.`id_zone` = '.(int)$id_zone.'
|
||||
AND d.`id_carrier` = '.(int)$this->id.'
|
||||
'.Carrier::sqlDeliveryRangeShop('range_weight').'
|
||||
ORDER BY w.`delimiter2` DESC LIMIT 1';
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
if (!isset($result[0]['price']))
|
||||
return false;
|
||||
return $result[0]['price'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -360,20 +357,17 @@ class CarrierCore extends ObjectModel
|
||||
|
||||
public function getMaxDeliveryPriceByPrice($id_zone)
|
||||
{
|
||||
$cache_id = 'Carrier::getMaxDeliveryPriceByPrice_'.(int)$this->id.'-'.(int)$id_zone;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$sql = 'SELECT d.`price`
|
||||
FROM `'._DB_PREFIX_.'delivery` d
|
||||
INNER JOIN `'._DB_PREFIX_.'range_price` r ON d.`id_range_price` = r.`id_range_price`
|
||||
WHERE d.`id_zone` = '.(int)$id_zone.'
|
||||
AND d.`id_carrier` = '.(int)$this->id.'
|
||||
'.Carrier::sqlDeliveryRangeShop('range_price').'
|
||||
ORDER BY r.`delimiter2` DESC';
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
$sql = 'SELECT d.`price`
|
||||
FROM `'._DB_PREFIX_.'delivery` d
|
||||
INNER JOIN `'._DB_PREFIX_.'range_price` r ON d.`id_range_price` = r.`id_range_price`
|
||||
WHERE d.`id_zone` = '.(int)$id_zone.'
|
||||
AND d.`id_carrier` = '.(int)$this->id.'
|
||||
'.Carrier::sqlDeliveryRangeShop('range_price').'
|
||||
ORDER BY r.`delimiter2` DESC LIMIT 1';
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
if (!isset($result[0]['price']))
|
||||
return false;
|
||||
return $result[0]['price'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -455,13 +449,7 @@ class CarrierCore extends ObjectModel
|
||||
GROUP BY c.`id_carrier`
|
||||
ORDER BY c.`position` ASC';
|
||||
|
||||
$cache_id = 'Carrier::getCarriers_'.md5($sql);
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$carriers = Db::getInstance()->executeS($sql);
|
||||
Cache::store($cache_id, $carriers);
|
||||
}
|
||||
$carriers = Cache::retrieve($cache_id);
|
||||
$carriers = Db::getInstance()->executeS($sql);
|
||||
|
||||
if (is_array($carriers) && count($carriers))
|
||||
{
|
||||
@@ -1211,14 +1199,7 @@ class CarrierCore extends ObjectModel
|
||||
$query->where('pc.id_product = '.(int)$product->id);
|
||||
$query->where('pc.id_shop = '.(int)$id_shop);
|
||||
|
||||
$cache_id = 'Carrier::getAvailableCarrierList_'.(int)$product->id.'-'.(int)$id_shop;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$carriers_for_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
Cache::store($cache_id, $carriers_for_product);
|
||||
}
|
||||
$carriers_for_product = Cache::retrieve($cache_id);
|
||||
|
||||
$carriers_for_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
$carrier_list = array();
|
||||
if (!empty($carriers_for_product))
|
||||
{
|
||||
|
||||
103
classes/Cart.php
103
classes/Cart.php
@@ -325,7 +325,7 @@ class CartCore extends ObjectModel
|
||||
if (!CartRule::isFeatureActive() || !$this->id)
|
||||
return array();
|
||||
|
||||
$cache_key = 'Cart::getCartRules_'.$this->id.'-'.$filter;
|
||||
$cache_key = 'Cart::getCartRules'.$this->id.'-'.$filter;
|
||||
if (!Cache::isStored($cache_key))
|
||||
{
|
||||
$result = Db::getInstance()->executeS('
|
||||
@@ -340,7 +340,6 @@ class CartCore extends ObjectModel
|
||||
'.($filter == CartRule::FILTER_ACTION_SHIPPING ? 'AND free_shipping = 1' : '').'
|
||||
'.($filter == CartRule::FILTER_ACTION_GIFT ? 'AND gift_product != 0' : '').'
|
||||
'.($filter == CartRule::FILTER_ACTION_REDUCTION ? 'AND (reduction_percent != 0 OR reduction_amount != 0)' : '')
|
||||
.' ORDER by cr.priority ASC'
|
||||
);
|
||||
Cache::store($cache_key, $result);
|
||||
}
|
||||
@@ -368,16 +367,12 @@ class CartCore extends ObjectModel
|
||||
{
|
||||
if (!CartRule::isFeatureActive())
|
||||
return 0;
|
||||
$cache_id = 'Cart::getDiscountsCustomer_'.(int)$this->id.'-'.(int)$id_cart_rule;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$result = (int)Db::getInstance()->getValue('
|
||||
SELECT COUNT(*)
|
||||
FROM `'._DB_PREFIX_.'cart_cart_rule`
|
||||
WHERE `id_cart_rule` = '.(int)$id_cart_rule.' AND `id_cart` = '.(int)$this->id);
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
|
||||
return Db::getInstance()->getValue('
|
||||
SELECT COUNT(*)
|
||||
FROM `'._DB_PREFIX_.'cart_cart_rule`
|
||||
WHERE `id_cart_rule` = '.(int)$id_cart_rule.' AND `id_cart` = '.(int)$this->id
|
||||
);
|
||||
}
|
||||
|
||||
public function getLastProduct()
|
||||
@@ -434,7 +429,7 @@ class CartCore extends ObjectModel
|
||||
product_shop.`available_for_order`, product_shop.`price`, product_shop.`active`, product_shop.`unity`, product_shop.`unit_price_ratio`,
|
||||
stock.`quantity` AS quantity_available, p.`width`, p.`height`, p.`depth`, stock.`out_of_stock`, p.`weight`,
|
||||
p.`date_add`, p.`date_upd`, IFNULL(stock.quantity, 0) as quantity, pl.`link_rewrite`, cl.`link_rewrite` AS category,
|
||||
CONCAT(LPAD(cp.`id_product`, 10, 0), LPAD(IFNULL(cp.`id_product_attribute`, 0), 10, 0), IFNULL(cp.`id_address_delivery`, 0)) AS unique_id, cp.id_address_delivery,
|
||||
CONCAT(cp.`id_product`, IFNULL(cp.`id_product_attribute`, 0), IFNULL(cp.`id_address_delivery`, 0)) AS unique_id, cp.id_address_delivery,
|
||||
product_shop.`wholesale_price`, product_shop.advanced_stock_management, ps.product_supplier_reference supplier_reference');
|
||||
|
||||
// Build FROM
|
||||
@@ -636,19 +631,14 @@ class CartCore extends ObjectModel
|
||||
|
||||
if (!isset($row['pai_id_image']) || $row['pai_id_image'] == 0)
|
||||
{
|
||||
$cache_id = 'Cart::getProducts_'.'-pai_id_image-'.(int)$row['id_product'].'-'.(int)$this->id_lang.'-'.(int)$row['id_shop'];
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$row2 = Db::getInstance()->getRow('
|
||||
SELECT image_shop.`id_image` id_image, il.`legend`
|
||||
FROM `'._DB_PREFIX_.'image` i
|
||||
JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (i.id_image = image_shop.id_image AND image_shop.cover=1 AND image_shop.id_shop='.(int)$row['id_shop'].')
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$this->id_lang.')
|
||||
WHERE i.`id_product` = '.(int)$row['id_product'].' AND image_shop.`cover` = 1'
|
||||
);
|
||||
Cache::store($cache_id, $row2);
|
||||
}
|
||||
$row2 = Cache::retrieve($cache_id);
|
||||
$row2 = Db::getInstance()->getRow('
|
||||
SELECT image_shop.`id_image` id_image, il.`legend`
|
||||
FROM `'._DB_PREFIX_.'image` i
|
||||
JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (i.id_image = image_shop.id_image AND image_shop.cover=1 AND image_shop.id_shop='.(int)$row['id_shop'].')
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$this->id_lang.')
|
||||
WHERE i.`id_product` = '.(int)$row['id_product'].' AND image_shop.`cover` = 1'
|
||||
);
|
||||
|
||||
if (!$row2)
|
||||
$row2 = array('id_image' => false, 'legend' => false);
|
||||
else
|
||||
@@ -736,7 +726,7 @@ class CartCore extends ObjectModel
|
||||
*
|
||||
* @result integer Products quantity
|
||||
*/
|
||||
public function nbProducts()
|
||||
public function nbProducts()
|
||||
{
|
||||
if (!$this->id)
|
||||
return 0;
|
||||
@@ -1087,9 +1077,9 @@ class CartCore extends ObjectModel
|
||||
);
|
||||
$id_customization = Db::getInstance()->Insert_ID();
|
||||
}
|
||||
|
||||
|
||||
$query = 'INSERT INTO `'._DB_PREFIX_.'customized_data` (`id_customization`, `type`, `index`, `value`)
|
||||
VALUES ('.(int)$id_customization.', '.(int)$type.', '.(int)$index.', \''.pSQL($field).'\')';
|
||||
VALUES ('.(int)$id_customization.', '.(int)$type.', '.(int)$index.', \''.pSql($field).'\')';
|
||||
|
||||
if (!Db::getInstance()->execute($query))
|
||||
return false;
|
||||
@@ -1103,13 +1093,7 @@ class CartCore extends ObjectModel
|
||||
*/
|
||||
public function orderExists()
|
||||
{
|
||||
$cache_id = 'Cart::orderExists_'.(int)$this->id;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$result = (bool)Db::getInstance()->getValue('SELECT count(*) FROM `'._DB_PREFIX_.'orders` WHERE `id_cart` = '.(int)$this->id);
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
return (bool)Db::getInstance()->getValue('SELECT count(*) FROM `'._DB_PREFIX_.'orders` WHERE `id_cart` = '.(int)$this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1276,7 +1260,7 @@ class CartCore extends ObjectModel
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getTotalCart($id_cart, $use_tax_display = false, $type = Cart::BOTH)
|
||||
public static function getTotalCart($id_cart, $use_tax_display = false, $type = CART::BOTH)
|
||||
{
|
||||
$cart = new Cart($id_cart);
|
||||
if (!Validate::isLoadedObject($cart))
|
||||
@@ -1692,7 +1676,6 @@ class CartCore extends ObjectModel
|
||||
$warehouse_count_by_address[$product['id_address_delivery']][$warehouse['id_warehouse']]++;
|
||||
}
|
||||
}
|
||||
unset($product);
|
||||
|
||||
arsort($warehouse_count_by_address);
|
||||
|
||||
@@ -1710,12 +1693,9 @@ class CartCore extends ObjectModel
|
||||
$id_warehouse = 0;
|
||||
foreach ($warehouse_count_by_address[$product['id_address_delivery']] as $id_war => $val)
|
||||
{
|
||||
if (in_array((int)$id_war, $product['warehouse_list']))
|
||||
{
|
||||
$product['carrier_list'] = array_merge($product['carrier_list'], Carrier::getAvailableCarrierList(new Product($product['id_product']), $id_war, $product['id_address_delivery'], null, $this));
|
||||
if (!$id_warehouse)
|
||||
$id_warehouse = (int)$id_war;
|
||||
}
|
||||
$product['carrier_list'] = array_merge($product['carrier_list'], Carrier::getAvailableCarrierList(new Product($product['id_product']), $id_war, $product['id_address_delivery'], null, $this));
|
||||
if (in_array((int)$id_war, $product['warehouse_list']) && $id_warehouse == 0)
|
||||
$id_warehouse = (int)$id_war;
|
||||
}
|
||||
|
||||
if (!isset($grouped_by_warehouse[$product['id_address_delivery']]['in_stock'][$id_warehouse]))
|
||||
@@ -1734,7 +1714,6 @@ class CartCore extends ObjectModel
|
||||
|
||||
$grouped_by_warehouse[$product['id_address_delivery']][$key][$id_warehouse][] = $product;
|
||||
}
|
||||
unset($product);
|
||||
|
||||
// Step 3 : grouped product from grouped_by_warehouse by available carriers
|
||||
$grouped_by_carriers = array();
|
||||
@@ -1753,6 +1732,7 @@ class CartCore extends ObjectModel
|
||||
{
|
||||
if (!isset($grouped_by_carriers[$id_address_delivery][$key][$id_warehouse]))
|
||||
$grouped_by_carriers[$id_address_delivery][$key][$id_warehouse] = array();
|
||||
|
||||
foreach ($product_list as $product)
|
||||
{
|
||||
$package_carriers_key = implode(',', $product['carrier_list']);
|
||||
@@ -1817,6 +1797,7 @@ class CartCore extends ObjectModel
|
||||
);
|
||||
$package_list[$id_address_delivery][$key][$id_warehouse][$id_carrier]['carrier_list'] =
|
||||
array_intersect($package_list[$id_address_delivery][$key][$id_warehouse][$id_carrier]['carrier_list'], $data['carrier_list']);
|
||||
|
||||
$package_list[$id_address_delivery][$key][$id_warehouse][$id_carrier]['product_list'] =
|
||||
array_merge($package_list[$id_address_delivery][$key][$id_warehouse][$id_carrier]['product_list'], $data['product_list']);
|
||||
|
||||
@@ -2292,23 +2273,18 @@ class CartCore extends ObjectModel
|
||||
public function getAddressCollection()
|
||||
{
|
||||
$collection = array();
|
||||
$cache_id = 'Cart::getAddressCollection'.(int)$this->id;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$result = Db::getInstance()->executeS(
|
||||
'SELECT DISTINCT `id_address_delivery`
|
||||
FROM `'._DB_PREFIX_.'cart_product`
|
||||
WHERE id_cart = '.(int)$this->id
|
||||
);
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
$result = Cache::retrieve($cache_id);
|
||||
$result = Db::getInstance()->executeS(
|
||||
'SELECT DISTINCT `id_address_delivery`
|
||||
FROM `'._DB_PREFIX_.'cart_product`
|
||||
WHERE id_cart = '.(int)$this->id
|
||||
);
|
||||
|
||||
$result[] = array('id_address_delivery' => (int)$this->id_address_delivery);
|
||||
|
||||
foreach ($result as $row)
|
||||
if ((int)$row['id_address_delivery'] != 0)
|
||||
$collection[(int)$row['id_address_delivery']] = new Address((int)$row['id_address_delivery']);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
@@ -3058,6 +3034,7 @@ class CartCore extends ObjectModel
|
||||
*/
|
||||
public function addTextFieldToProduct($id_product, $index, $type, $text_value)
|
||||
{
|
||||
$text_value = str_replace(array("\n", "\r"), '', nl2br($text_value));
|
||||
if (!_PS_MAGIC_QUOTES_GPC_){
|
||||
$text_value = str_replace('\\', '\\\\', $text_value);
|
||||
$text_value = str_replace('\'', '\\\'', $text_value);
|
||||
@@ -3238,7 +3215,7 @@ class CartCore extends ObjectModel
|
||||
public function getWsCartRows()
|
||||
{
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT id_product, id_product_attribute, quantity, id_address_delivery
|
||||
SELECT id_product, id_product_attribute, quantity
|
||||
FROM `'._DB_PREFIX_.'cart_product`
|
||||
WHERE id_cart = '.(int)$this->id.' AND id_shop = '.(int)Context::getContext()->shop->id
|
||||
);
|
||||
@@ -3485,14 +3462,10 @@ class CartCore extends ObjectModel
|
||||
)
|
||||
WHERE `id_cart` = '.(int)$this->id.'
|
||||
'.(Configuration::get('PS_ALLOW_MULTISHIPPING') ? ' AND `id_shop` = '.(int)$this->id_shop : '');
|
||||
|
||||
$cache_id = 'Cart::setNoMultishipping'.(int)$this->id.'-'.(int)$this->id_shop;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
if ($result = (bool)Db::getInstance()->execute($sql))
|
||||
$emptyCache = true;
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
|
||||
$result = Db::getInstance()->execute($sql);
|
||||
if ($result)
|
||||
$emptyCache = true;
|
||||
|
||||
if (Customization::isFeatureActive())
|
||||
Db::getInstance()->execute('
|
||||
|
||||
@@ -254,17 +254,6 @@ class CartRuleCore extends ObjectModel
|
||||
}
|
||||
else
|
||||
$cart_rule['quantity_for_user'] = 0;
|
||||
unset($cart_rule);
|
||||
|
||||
foreach ($result as $cart_rule)
|
||||
if ($cart_rule['shop_restriction'])
|
||||
{
|
||||
$cartRuleShops = Db::getInstance()->executeS('SELECT id_shop FROM '._DB_PREFIX_.'cart_rule_shop WHERE id_cart_rule = '.(int)$cart_rule['id_cart_rule']);
|
||||
foreach ($cartRuleShops as $cartRuleShop)
|
||||
if (Shop::isFeatureActive() && ($cartRuleShop['id_shop'] == Context::getContext()->shop->id))
|
||||
continue 2;
|
||||
unset($result[$key]);
|
||||
}
|
||||
|
||||
// Retrocompatibility with 1.4 discounts
|
||||
foreach ($result as &$cart_rule)
|
||||
|
||||
@@ -107,8 +107,8 @@ class CategoryCore extends ObjectModel
|
||||
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
|
||||
// Lang fields
|
||||
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128),
|
||||
'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 128),
|
||||
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64),
|
||||
'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 64),
|
||||
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
|
||||
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
|
||||
'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
|
||||
@@ -666,9 +666,9 @@ class CategoryCore extends ObjectModel
|
||||
* @param boolean $active return only active categories
|
||||
* @return array categories
|
||||
*/
|
||||
public static function getHomeCategories($id_lang, $active = true, $id_shop = false)
|
||||
public static function getHomeCategories($id_lang, $active = true)
|
||||
{
|
||||
return self::getChildren(Configuration::get('PS_HOME_CATEGORY'), $id_lang, $active, $id_shop);
|
||||
return self::getChildren(Configuration::get('PS_HOME_CATEGORY'), $id_lang, $active);
|
||||
}
|
||||
|
||||
public static function getRootCategory($id_lang = null, Shop $shop = null)
|
||||
@@ -704,22 +704,16 @@ class CategoryCore extends ObjectModel
|
||||
if (!Validate::isBool($active))
|
||||
die(Tools::displayError());
|
||||
|
||||
$cache_id = 'Category::getChildren_'.(int)$id_parent.'-'.(int)$id_lang.'-'.(bool)$active.'-'.(int)$id_shop;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$query = 'SELECT c.`id_category`, cl.`name`, cl.`link_rewrite`, category_shop.`id_shop`
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').')
|
||||
'.Shop::addSqlAssociation('category', 'c').'
|
||||
WHERE `id_lang` = '.(int)$id_lang.'
|
||||
AND c.`id_parent` = '.(int)$id_parent.'
|
||||
'.($active ? 'AND `active` = 1' : '').'
|
||||
GROUP BY c.`id_category`
|
||||
ORDER BY category_shop.`position` ASC';
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
$query = 'SELECT c.`id_category`, cl.`name`, cl.`link_rewrite`, category_shop.`id_shop`
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').')
|
||||
'.Shop::addSqlAssociation('category', 'c').'
|
||||
WHERE `id_lang` = '.(int)$id_lang.'
|
||||
AND c.`id_parent` = '.(int)$id_parent.'
|
||||
'.($active ? 'AND `active` = 1' : '').'
|
||||
GROUP BY c.`id_category`
|
||||
ORDER BY category_shop.`position` ASC';
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1014,20 +1008,14 @@ class CategoryCore extends ObjectModel
|
||||
public function getGroups()
|
||||
{
|
||||
$groups = array();
|
||||
$cache_id = 'Category::getGroups_'.(int)$this->id;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT cg.`id_group`
|
||||
FROM '._DB_PREFIX_.'category_group cg
|
||||
WHERE cg.`id_category` = '.(int)$this->id
|
||||
);
|
||||
$groups = array();
|
||||
foreach ($result as $group)
|
||||
$groups[] = $group['id_group'];
|
||||
Cache::store($cache_id, $groups);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT cg.`id_group`
|
||||
FROM '._DB_PREFIX_.'category_group cg
|
||||
WHERE cg.`id_category` = '.(int)$this->id
|
||||
);
|
||||
foreach ($result as $group)
|
||||
$groups[] = $group['id_group'];
|
||||
return $groups;
|
||||
}
|
||||
|
||||
public function addGroupsIfNoExist($id_group)
|
||||
@@ -1048,23 +1036,24 @@ class CategoryCore extends ObjectModel
|
||||
*/
|
||||
public function checkAccess($id_customer)
|
||||
{
|
||||
$cache_id = 'Category::checkAccess_'.(int)$this->id.'-'.$id_customer.(!$id_customer ? '-'.(int)Group::getCurrent()->id : '');
|
||||
if (!Cache::isStored($cache_id))
|
||||
if (!$id_customer)
|
||||
{
|
||||
if (!$id_customer)
|
||||
$result = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT ctg.`id_group`
|
||||
FROM '._DB_PREFIX_.'category_group ctg
|
||||
WHERE ctg.`id_category` = '.(int)$this->id.' AND ctg.`id_group` = '.(int)Group::getCurrent()->id);
|
||||
else
|
||||
$result = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
WHERE ctg.`id_category` = '.(int)$this->id.' AND ctg.`id_group` = '.(int)Group::getCurrent()->id.'
|
||||
');
|
||||
} else {
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT ctg.`id_group`
|
||||
FROM '._DB_PREFIX_.'category_group ctg
|
||||
INNER JOIN '._DB_PREFIX_.'customer_group cg on (cg.`id_group` = ctg.`id_group` AND cg.`id_customer` = '.(int)$id_customer.')
|
||||
WHERE ctg.`id_category` = '.(int)$this->id);
|
||||
Cache::store($cache_id, $result);
|
||||
WHERE ctg.`id_category` = '.(int)$this->id
|
||||
);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
if ($result && isset($result['id_group']) && $result['id_group'])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1210,16 +1199,12 @@ class CategoryCore extends ObjectModel
|
||||
*/
|
||||
public static function getInterval($id)
|
||||
{
|
||||
$cache_id = 'Category::getInterval_'.(int)$id;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$sql = 'SELECT nleft, nright, level_depth
|
||||
FROM '._DB_PREFIX_.'category
|
||||
WHERE id_category = '.(int)$id;
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
$sql = 'SELECT nleft, nright, level_depth
|
||||
FROM '._DB_PREFIX_.'category
|
||||
WHERE id_category = '.(int)$id;
|
||||
if (!$result = Db::getInstance()->getRow($sql))
|
||||
return false;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1401,17 +1386,11 @@ class CategoryCore extends ObjectModel
|
||||
|
||||
public static function getCategoriesWithoutParent()
|
||||
{
|
||||
$cache_id = 'Category::getCategoriesWithoutParent_'.(int)Context::getContext()->language->id;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT DISTINCT c.*
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
WHERE `level_depth` = 1');
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT DISTINCT c.*
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
WHERE `level_depth` = 1');
|
||||
}
|
||||
|
||||
public function isRootCategoryForAShop()
|
||||
@@ -1430,17 +1409,12 @@ class CategoryCore extends ObjectModel
|
||||
public static function getTopCategory($id_lang = null)
|
||||
{
|
||||
if (is_null($id_lang))
|
||||
$id_lang = (int)Context::getContext()->language->id;
|
||||
$cache_id = 'Category::getTopCategory_'.(int)$id_lang;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$id_category = (int)Db::getInstance()->getValue('
|
||||
SELECT `id_category`
|
||||
FROM `'._DB_PREFIX_.'category`
|
||||
WHERE `id_parent` = 0');
|
||||
Cache::store($cache_id, new Category($id_category, $id_lang));
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
$id_category = Db::getInstance()->getValue('
|
||||
SELECT `id_category`
|
||||
FROM `'._DB_PREFIX_.'category`
|
||||
WHERE `id_parent` = 0');
|
||||
return new Category($id_category, $id_lang);
|
||||
}
|
||||
|
||||
public function addPosition($position, $id_shop = null)
|
||||
|
||||
@@ -73,7 +73,7 @@ class CurrencyCore extends ObjectModel
|
||||
'sign' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 8),
|
||||
'format' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'decimals' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true),
|
||||
'conversion_rate' =>array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat', 'required' => true, 'shop' => true),
|
||||
'conversion_rate' =>array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true, 'shop' => true),
|
||||
'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
),
|
||||
@@ -107,23 +107,14 @@ class CurrencyCore extends ObjectModel
|
||||
$this->suffix = $this->format % 2 == 0 ? ' '.$this->sign : '';
|
||||
}
|
||||
/**
|
||||
* Overriding check if currency rate is not empty and if currency with the same iso code already exists.
|
||||
* If it's true, currency is not added.
|
||||
* Overriding check if currency with the same iso code already exists.
|
||||
* If it's true, currency is doesn't added.
|
||||
*
|
||||
* @see ObjectModelCore::add()
|
||||
*/
|
||||
public function add($autodate = true, $nullValues = false)
|
||||
{
|
||||
if ((float)$this->conversion_rate <= 0)
|
||||
return false;
|
||||
return Currency::exists($this->iso_code, $this->iso_code_num) ? false : parent::add($autodate, $nullValues);
|
||||
}
|
||||
|
||||
public function update($autodate = true, $nullValues = false)
|
||||
{
|
||||
if ((float)$this->conversion_rate <= 0)
|
||||
return false;
|
||||
return parent::update($autodate, $nullValues);
|
||||
return Currency::exists($this->iso_code, $this->iso_code_num) ? false : parent::add();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,9 +188,8 @@ class CurrencyCore extends ObjectModel
|
||||
4 => array('left' => '', 'right' => &$formated_strings['right']),
|
||||
5 => array('left' => '', 'right' => &$formated_strings['right'])
|
||||
);
|
||||
if (isset($formats[$this->format][$side]))
|
||||
return ($formats[$this->format][$side]);
|
||||
return $this->sign;
|
||||
|
||||
return ($formats[$this->format][$side]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -296,16 +286,10 @@ class CurrencyCore extends ObjectModel
|
||||
*/
|
||||
public static function getIdByIsoCode($iso_code, $id_shop = 0)
|
||||
{
|
||||
$cache_id = 'Currency::getIdByIsoCode_'.pSQL($iso_code).'-'.(int)$id_shop;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$query = Currency::getIdByQuery($id_shop);
|
||||
$query->where('iso_code = \''.pSQL($iso_code).'\'');
|
||||
|
||||
$result = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query->build());
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
$query = Currency::getIdByQuery($id_shop);
|
||||
$query->where('iso_code = \''.pSQL($iso_code).'\'');
|
||||
|
||||
return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query->build());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -362,18 +362,15 @@ class CustomerCore extends ObjectModel
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_customer))
|
||||
return true;
|
||||
$cache_id = 'Customer::isBanned_'.(int)$id_customer;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$result = (bool)!Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT `id_customer`
|
||||
FROM `'._DB_PREFIX_.'customer`
|
||||
WHERE `id_customer` = \''.(int)$id_customer.'\'
|
||||
AND active = 1
|
||||
AND `deleted` = 0');
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT `id_customer`
|
||||
FROM `'._DB_PREFIX_.'customer`
|
||||
WHERE `id_customer` = \''.(int)$id_customer.'\'
|
||||
AND active = 1
|
||||
AND `deleted` = 0');
|
||||
if (isset($result['id_customer']))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -416,7 +413,7 @@ class CustomerCore extends ObjectModel
|
||||
public static function customerHasAddress($id_customer, $id_address)
|
||||
{
|
||||
$key = (int)$id_customer.'-'.(int)$id_address;
|
||||
if (!array_key_exists($key, self::$_customerHasAddress))
|
||||
if (!array_key_exists($id_address, self::$_customerHasAddress))
|
||||
{
|
||||
self::$_customerHasAddress[$key] = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT `id_address`
|
||||
@@ -442,22 +439,15 @@ class CustomerCore extends ObjectModel
|
||||
*/
|
||||
public function getAddresses($id_lang)
|
||||
{
|
||||
$share_order = (bool)Context::getContext()->shop->getGroup()->share_order;
|
||||
$cache_id = 'Customer::getAddresses'.(int)$this->id.'-'.(int)$id_lang.'-'.$share_order;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$sql = 'SELECT DISTINCT a.*, cl.`name` AS country, s.name AS state, s.iso_code AS state_iso
|
||||
FROM `'._DB_PREFIX_.'address` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'country` c ON (a.`id_country` = c.`id_country`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_state` = a.`id_state`)
|
||||
'.($share_order ? '' : Shop::addSqlAssociation('country', 'c')).'
|
||||
WHERE `id_lang` = '.(int)$id_lang.' AND `id_customer` = '.(int)$this->id.' AND a.`deleted` = 0';
|
||||
$sql = 'SELECT DISTINCT a.*, cl.`name` AS country, s.name AS state, s.iso_code AS state_iso
|
||||
FROM `'._DB_PREFIX_.'address` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'country` c ON (a.`id_country` = c.`id_country`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_state` = a.`id_state`)
|
||||
'.(Context::getContext()->shop->getGroup()->share_order ? '' : Shop::addSqlAssociation('country', 'c')).'
|
||||
WHERE `id_lang` = '.(int)$id_lang.' AND `id_customer` = '.(int)$this->id.' AND a.`deleted` = 0';
|
||||
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -486,17 +476,12 @@ class CustomerCore extends ObjectModel
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_customer) || !Validate::isMd5($passwd))
|
||||
die (Tools::displayError());
|
||||
$cache_id = 'Customer::checkPassword'.(int)$id_customer.'-'.$passwd;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$sql = 'SELECT `id_customer`
|
||||
FROM `'._DB_PREFIX_.'customer`
|
||||
WHERE `id_customer` = '.$id_customer.'
|
||||
|
||||
$sql = 'SELECT `id_customer`
|
||||
FROM `'._DB_PREFIX_.'customer`
|
||||
WHERE `id_customer` = '.$id_customer.'
|
||||
AND `passwd` = \''.$passwd.'\'';
|
||||
$result = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
return (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -589,16 +574,12 @@ class CustomerCore extends ObjectModel
|
||||
|
||||
public static function customerIdExistsStatic($id_customer)
|
||||
{
|
||||
$cache_id = 'Customer::customerIdExistsStatic'.(int)$id_customer;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$result = (int)Db::getInstance()->getValue('
|
||||
SELECT `id_customer`
|
||||
FROM '._DB_PREFIX_.'customer c
|
||||
WHERE c.`id_customer` = '.(int)$id_customer);
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
$row = Db::getInstance()->getRow('
|
||||
SELECT `id_customer`
|
||||
FROM '._DB_PREFIX_.'customer c
|
||||
WHERE c.`id_customer` = '.(int)$id_customer);
|
||||
|
||||
return isset($row['id_customer']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -608,11 +589,9 @@ class CustomerCore extends ObjectModel
|
||||
*/
|
||||
public function updateGroup($list)
|
||||
{
|
||||
$this->cleanGroups();
|
||||
if ($list && !empty($list))
|
||||
{
|
||||
$this->cleanGroups();
|
||||
$this->addGroups($list);
|
||||
}
|
||||
else
|
||||
$this->addGroups(array($this->id_default_group));
|
||||
}
|
||||
@@ -627,7 +606,7 @@ class CustomerCore extends ObjectModel
|
||||
foreach ($groups as $group)
|
||||
{
|
||||
$row = array('id_customer' => (int)$this->id, 'id_group' => (int)$group);
|
||||
Db::getInstance()->insert('customer_group', $row, false, true, Db::INSERT_IGNORE);
|
||||
Db::getInstance()->insert('customer_group', $row);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class CustomerMessageCore extends ObjectModel
|
||||
'fields' => array(
|
||||
'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'id_customer_thread' => array('type' => self::TYPE_INT),
|
||||
'ip_address' => array('type' => self::TYPE_STRING, 'validate' => 'isIp2Long', 'size' => 15),
|
||||
'ip_address' => array('type' => self::TYPE_INT, 'validate' => 'isIp2Long'),
|
||||
'message' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'required' => true, 'size' => 65000),
|
||||
'file_name' => array('type' => self::TYPE_STRING),
|
||||
'user_agent' => array('type' => self::TYPE_STRING),
|
||||
|
||||
@@ -369,7 +369,7 @@ class DispatcherCore
|
||||
|
||||
// If there are several languages, get language from uri
|
||||
if ($this->use_routes && Language::isMultiLanguageActivated())
|
||||
if (preg_match('#^/([a-z]{2})(?:/.*)?$#', $this->request_uri, $m))
|
||||
if (preg_match('#^/([a-z]{2})/?#', $this->request_uri, $m))
|
||||
{
|
||||
$_GET['isolang'] = $m[1];
|
||||
$this->request_uri = substr($this->request_uri, 3);
|
||||
|
||||
@@ -312,37 +312,16 @@ class FeatureCore extends ObjectModel
|
||||
*/
|
||||
public static function cleanPositions()
|
||||
{
|
||||
//Reordering positions to remove "holes" in them (after delete for instance)
|
||||
$sql = "SELECT id_feature, position FROM "._DB_PREFIX_."feature ORDER BY id_feature";
|
||||
$db = Db::getInstance();
|
||||
$r = $db->executeS($sql, false);
|
||||
$shiftTable = array(); //List of update queries (one query is necessary for each "hole" in the table)
|
||||
$currentDelta = 0;
|
||||
$minId = 0;
|
||||
$maxId = 0;
|
||||
$futurePosition = 1;
|
||||
while ($line = $db->nextRow($r)) {
|
||||
$delta = $futurePosition - $line['position']; //Difference between current position and future position
|
||||
if ($delta != $currentDelta) {
|
||||
$shiftTable[] = array('minId' => $minId, 'maxId' => $maxId, 'delta' => $currentDelta);
|
||||
$currentDelta = $delta;
|
||||
$minId = $line['id_feature'];
|
||||
}
|
||||
$maxId = $line['id_feature'];
|
||||
$futurePosition++;
|
||||
}
|
||||
$shiftTable[] = array('minId' => $minId, 'maxId' => $maxId, 'delta' => $currentDelta);
|
||||
|
||||
//Executing generated queries
|
||||
foreach ($shiftTable as $line) {
|
||||
$delta = $line['delta'];
|
||||
if ($delta == 0) continue;
|
||||
$delta = $delta > 0 ? '+' . (int)$delta : (int)$delta;
|
||||
$minId = (int)$line['minId'];
|
||||
$maxId = (int)$line['maxId'];
|
||||
$sql = "UPDATE "._DB_PREFIX_."feature SET position = position $delta WHERE id_feature >= $minId AND id_feature <= $maxId";
|
||||
Db::getInstance()->execute($sql);
|
||||
}
|
||||
return Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'feature` f
|
||||
LEFT JOIN (
|
||||
SELECT @i := @i +1 AS rank, id_feature, position
|
||||
FROM `'._DB_PREFIX_.'feature`
|
||||
JOIN (SELECT @i :=1) dummy
|
||||
ORDER by position
|
||||
) AS f2
|
||||
USING (id_feature)
|
||||
SET f.position = f2.rank - 1');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -128,50 +128,34 @@ class FeatureValueCore extends ObjectModel
|
||||
return $tab['value'];
|
||||
}
|
||||
|
||||
public static function addFeatureValueImport($id_feature, $value, $id_product = null, $id_lang = null, $custom = false)
|
||||
public static function addFeatureValueImport($id_feature, $name)
|
||||
{
|
||||
$id_feature_value = false;
|
||||
if (!is_null($id_product) && $id_product)
|
||||
{
|
||||
$id_feature_value = Db::getInstance()->getValue('
|
||||
SELECT fp.`id_feature_value`
|
||||
FROM '._DB_PREFIX_.'feature_product fp
|
||||
INNER JOIN '._DB_PREFIX_.'feature_value fv USING (`id_feature_value`)
|
||||
WHERE fp.`id_feature` = '.(int)$id_feature.'
|
||||
AND fv.`custom` = '.(int)$custom.'
|
||||
AND fp.`id_product` = '.(int)$id_product);
|
||||
|
||||
if ($custom && $id_feature_value && !is_null($id_lang) && $id_lang)
|
||||
Db::getInstance()->execute('
|
||||
UPDATE '._DB_PREFIX_.'feature_value_lang
|
||||
SET `value` = \''.pSQL($value).'\'
|
||||
WHERE `id_feature_value` = '.(int)$id_feature_value.'
|
||||
AND `value` != \''.pSQL($value).'\'
|
||||
AND `id_lang` = '.(int)$id_lang);
|
||||
}
|
||||
|
||||
if (!$custom)
|
||||
$id_feature_value = Db::getInstance()->getValue('
|
||||
SELECT fv.`id_feature_value`
|
||||
FROM '._DB_PREFIX_.'feature_value fv
|
||||
LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.`id_feature_value` = fv.`id_feature_value` AND fvl.`id_lang` = '.(int)$id_lang.')
|
||||
WHERE `value` = \''.pSQL($value).'\'
|
||||
$rq = Db::getInstance()->executeS('
|
||||
SELECT fv.`id_feature_value`
|
||||
FROM '._DB_PREFIX_.'feature_value fv
|
||||
LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl
|
||||
ON (fvl.`id_feature_value` = fv.`id_feature_value`)
|
||||
WHERE `value` = \''.pSQL($name).'\'
|
||||
AND fv.`id_feature` = '.(int)$id_feature.'
|
||||
AND fv.`custom` = 0
|
||||
GROUP BY fv.`id_feature_value`');
|
||||
GROUP BY fv.`id_feature_value` LIMIT 1
|
||||
');
|
||||
|
||||
if ($id_feature_value)
|
||||
return (int)$id_feature_value;
|
||||
if (!isset($rq[0]['id_feature_value']) || !$id_feature_value = (int)$rq[0]['id_feature_value'])
|
||||
{
|
||||
// Feature doesn't exist, create it
|
||||
$feature_value = new FeatureValue();
|
||||
|
||||
// Feature doesn't exist, create it
|
||||
$feature_value = new FeatureValue();
|
||||
$feature_value->id_feature = (int)$id_feature;
|
||||
$feature_value->custom = (bool)$custom;
|
||||
foreach (Language::getLanguages() as $language)
|
||||
$feature_value->value[$language['id_lang']] = $value;
|
||||
$feature_value->add();
|
||||
$languages = Language::getLanguages();
|
||||
foreach ($languages as $language)
|
||||
$feature_value->value[$language['id_lang']] = strval($name);
|
||||
|
||||
return (int)$feature_value->id;
|
||||
$feature_value->id_feature = (int)$id_feature;
|
||||
$feature_value->custom = 1;
|
||||
$feature_value->add();
|
||||
|
||||
return (int)$feature_value->id;
|
||||
}
|
||||
return (int)$id_feature_value;
|
||||
}
|
||||
|
||||
public function add($autodate = true, $nullValues = false)
|
||||
|
||||
@@ -102,13 +102,6 @@ class QqUploadedFileForm
|
||||
$image = new Image();
|
||||
$image->id_product = (int)$product->id;
|
||||
$image->position = Image::getHighestPosition($product->id) + 1;
|
||||
$legends = Tools::getValue('legend');
|
||||
if (is_array($legends))
|
||||
foreach ($legends as $key => $legend)
|
||||
if (!empty($legend) && Validate::isGenericName($legend))
|
||||
$image->legend[(int)$key] = $legend;
|
||||
else
|
||||
return array('error' => sprintf(Tools::displayError('Error on image legend "%1s." is not a valid legend.'), Tools::safeOutput($legend)));
|
||||
if (!Image::getCover($image->id_product))
|
||||
$image->cover = 1;
|
||||
else
|
||||
@@ -143,7 +136,7 @@ class QqUploadedFileForm
|
||||
|
||||
if (!$image->update())
|
||||
return array('error' => Tools::displayError('Error while updating status'));
|
||||
$img = array('id_image' => $image->id, 'position' => $image->position, 'cover' => $image->cover, 'name' => $this->getName(), 'legend' => $image->legend);
|
||||
$img = array('id_image' => $image->id, 'position' => $image->position, 'cover' => $image->cover, 'name' => $this->getName());
|
||||
return array('success' => $img);
|
||||
}
|
||||
|
||||
@@ -191,13 +184,6 @@ class QqUploadedFileXhr
|
||||
$image = new Image();
|
||||
$image->id_product = (int)($product->id);
|
||||
$image->position = Image::getHighestPosition($product->id) + 1;
|
||||
$legends = Tools::getValue('legend');
|
||||
if (is_array($legends))
|
||||
foreach ($legends as $key => $legend)
|
||||
if (!empty($legend) && Validate::isGenericName($legend))
|
||||
$image->legend[(int)$key] = $legend;
|
||||
else
|
||||
return array('error' => sprintf(Tools::displayError('Error on image legend "%1s." is not a valid legend.'), Tools::safeOutput($legend)));
|
||||
if (!Image::getCover($image->id_product))
|
||||
$image->cover = 1;
|
||||
else
|
||||
@@ -237,7 +223,7 @@ class QqUploadedFileXhr
|
||||
|
||||
if (!$image->update())
|
||||
return array('error' => Tools::displayError('Error while updating status'));
|
||||
$img = array('id_image' => $image->id, 'position' => $image->position, 'cover' => $image->cover, 'name' => $this->getName(), 'legend' => $image->legend);
|
||||
$img = array('id_image' => $image->id, 'position' => $image->position, 'cover' => $image->cover, 'name' => $this->getName());
|
||||
return array('success' => $img);
|
||||
}
|
||||
|
||||
|
||||
@@ -305,43 +305,17 @@ class GroupCore extends ObjectModel
|
||||
public static function getCurrent()
|
||||
{
|
||||
static $groups = array();
|
||||
|
||||
$customer = Context::getContext()->customer;
|
||||
if (Validate::isLoadedObject($customer))
|
||||
{
|
||||
$id_group = (int)$customer->id_default_group;
|
||||
$group = new Group((int)$id_group);
|
||||
if (!$group->isAssociatedToShop(Context::getContext()->shop->id))
|
||||
$group = new Group((int)Configuration::get('PS_CUSTOMER_GROUP'));
|
||||
}
|
||||
else
|
||||
$id_group = (int)Configuration::get('PS_UNIDENTIFIED_GROUP');
|
||||
|
||||
if (!isset($groups[$id_group]) && isset($group))
|
||||
$groups[$id_group] = $group;
|
||||
|
||||
|
||||
if (!isset($groups[$id_group]))
|
||||
$groups[$id_group] = new Group($id_group);
|
||||
|
||||
return $groups[$id_group];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Light back office search for Group
|
||||
*
|
||||
* @param integer $id_lang Language ID
|
||||
* @param string $query Searched string
|
||||
* @param boolean $unrestricted allows search without lang and includes first group and exact match
|
||||
* @return array Corresponding groupes
|
||||
*/
|
||||
public static function searchByName($query)
|
||||
{
|
||||
return Db::getInstance()->getRow('
|
||||
SELECT g.*, gl.*
|
||||
FROM `'._DB_PREFIX_.'group` g
|
||||
LEFT JOIN `'._DB_PREFIX_.'group_lang` gl
|
||||
ON (g.`id_group` = gl.`id_group`)
|
||||
WHERE `name` LIKE \''.pSQL($query).'\'
|
||||
');
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,6 @@ class GroupReductionCore extends ObjectModel
|
||||
SELECT `reduction`
|
||||
FROM `'._DB_PREFIX_.'product_group_reduction_cache`
|
||||
WHERE `id_product` = '.(int)$id_product.' AND `id_group` = '.(int)$id_group);
|
||||
// Should return string (decimal in database) and not a float
|
||||
return self::$reduction_cache[$id_product.'-'.$id_group];
|
||||
}
|
||||
|
||||
|
||||
@@ -56,8 +56,6 @@ class HookCore extends ObjectModel
|
||||
*/
|
||||
public static $executed_hooks = array();
|
||||
|
||||
public static $native_module;
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
*/
|
||||
@@ -318,7 +316,7 @@ class HookCore extends ObjectModel
|
||||
if (Validate::isLoadedObject($context->country))
|
||||
$sql->where('(h.name = "displayPayment" AND (SELECT id_country FROM '._DB_PREFIX_.'module_country mc WHERE mc.id_module = m.id_module AND id_country = '.(int)$context->country->id.' AND id_shop = '.(int)$context->shop->id.' LIMIT 1) = '.(int)$context->country->id.')');
|
||||
if (Validate::isLoadedObject($context->currency))
|
||||
$sql->where('(h.name = "displayPayment" AND (SELECT id_currency FROM '._DB_PREFIX_.'module_currency mcr WHERE mcr.id_module = m.id_module AND id_currency IN ('.(int)$context->currency->id.', -1, -2) LIMIT 1) IN ('.(int)$context->currency->id.', -1, -2))');
|
||||
$sql->where('(h.name = "displayPayment" AND (SELECT id_currency FROM '._DB_PREFIX_.'module_currency mcr WHERE mcr.id_module = m.id_module AND id_currency IN ('.(int)$context->currency->id.', -2) LIMIT 1) IN ('.(int)$context->currency->id.', -2))');
|
||||
}
|
||||
if (Validate::isLoadedObject($context->shop))
|
||||
$sql->where('hm.id_shop = '.(int)$context->shop->id);
|
||||
@@ -326,10 +324,7 @@ class HookCore extends ObjectModel
|
||||
if ($frontend)
|
||||
{
|
||||
$sql->leftJoin('module_group', 'mg', 'mg.`id_module` = m.`id_module`');
|
||||
if (Validate::isLoadedObject($context->shop))
|
||||
$sql->where('mg.id_shop = '.((int)$context->shop->id).' AND mg.`id_group` IN ('.implode(', ', $groups).')');
|
||||
else
|
||||
$sql->where('mg.`id_group` IN ('.implode(', ', $groups).')');
|
||||
$sql->where('mg.`id_group` IN ('.implode(', ', $groups).')');
|
||||
$sql->groupBy('hm.id_hook, hm.id_module');
|
||||
}
|
||||
|
||||
@@ -393,10 +388,6 @@ class HookCore extends ObjectModel
|
||||
*/
|
||||
public static function exec($hook_name, $hook_args = array(), $id_module = null, $array_return = false, $check_exceptions = true)
|
||||
{
|
||||
static $disable_non_native_modules = null;
|
||||
if ($disable_non_native_modules === null)
|
||||
$disable_non_native_modules = (bool)Configuration::get('PS_DISABLE_NON_NATIVE_MODULE');
|
||||
|
||||
// Check arguments validity
|
||||
if (($id_module && !is_numeric($id_module)) || !Validate::isHookName($hook_name))
|
||||
throw new PrestaShopException('Invalid id_module or hook_name');
|
||||
@@ -425,19 +416,12 @@ class HookCore extends ObjectModel
|
||||
// Look on modules list
|
||||
$altern = 0;
|
||||
$output = '';
|
||||
|
||||
if ($disable_non_native_modules && !isset(Hook::$native_module))
|
||||
Hook::$native_module = Module::getNativeModuleList();
|
||||
|
||||
|
||||
foreach ($module_list as $array)
|
||||
{
|
||||
// Check errors
|
||||
if ($id_module && $id_module != $array['id_module'])
|
||||
continue;
|
||||
|
||||
if ((bool)$disable_non_native_modules && Hook::$native_module && count(Hook::$native_module) && !in_array($array['module'], self::$native_module))
|
||||
continue;
|
||||
|
||||
if (!($moduleInstance = Module::getInstanceByName($array['module'])))
|
||||
continue;
|
||||
|
||||
|
||||
@@ -40,9 +40,6 @@ class ImageCore extends ObjectModel
|
||||
/** @var boolean Image is cover */
|
||||
public $cover;
|
||||
|
||||
/** @var string Legend */
|
||||
public $legend;
|
||||
|
||||
/** @var string image extension */
|
||||
public $image_format = 'jpg';
|
||||
|
||||
@@ -69,7 +66,6 @@ class ImageCore extends ObjectModel
|
||||
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'position' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
|
||||
'cover' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'shop' => true),
|
||||
'legend' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -127,20 +127,16 @@ class ImageTypeCore extends ObjectModel
|
||||
* @param string $name
|
||||
* @param string $type
|
||||
*/
|
||||
public static function getByNameNType($name, $type = null, $order = null)
|
||||
public static function getByNameNType($name, $type = null)
|
||||
{
|
||||
if (!isset(self::$images_types_name_cache[$name.'_'.$type.'_'.$order]))
|
||||
if (!isset(self::$images_types_name_cache[$name.'_'.$type]))
|
||||
{
|
||||
self::$images_types_name_cache[$name.'_'.$type.'_'.$order] = Db::getInstance()->getRow('
|
||||
self::$images_types_name_cache[$name.'_'.$type] = Db::getInstance()->getRow('
|
||||
SELECT `id_image_type`, `name`, `width`, `height`, `products`, `categories`, `manufacturers`, `suppliers`, `scenes`
|
||||
FROM `'._DB_PREFIX_.'image_type`
|
||||
WHERE
|
||||
`name` LIKE \''.pSQL($name).'\''
|
||||
.(!is_null($type) ? ' AND `'.pSQL($type).'` = 1' : '')
|
||||
.(!is_null($order) ? ' ORDER BY `'.bqSQL($order).'` ASC' : '')
|
||||
);
|
||||
WHERE `name` = \''.pSQL($name).'\' '.(!is_null($type) ? 'AND `'.pSQL($type).'` = 1' : ''));
|
||||
}
|
||||
return self::$images_types_name_cache[$name.'_'.$type.'_'.$order];
|
||||
return self::$images_types_name_cache[$name.'_'.$type];
|
||||
}
|
||||
|
||||
public static function getFormatedName($name)
|
||||
|
||||
@@ -619,35 +619,6 @@ class LanguageCore extends ObjectModel
|
||||
return Db::getInstance()->getValue('SELECT `language_code` FROM `'._DB_PREFIX_.'lang` WHERE `iso_code` = \''.pSQL(strtolower($iso_code)).'\'');
|
||||
}
|
||||
|
||||
public static function getLanguageByIETFCode($code)
|
||||
{
|
||||
if (!Validate::isLanguageCode($code))
|
||||
die(sprintf(Tools::displayError('Fatal error: IETF code %s is not correct'), $code));
|
||||
|
||||
// $code is in the form of 'xx-YY' where xx is the language code
|
||||
// and 'YY' a country code identifying a variant of the language.
|
||||
$lang_country = explode('-', $code);
|
||||
// Get the language component of the code
|
||||
$lang = $lang_country[0];
|
||||
|
||||
// Find the id_lang of the language.
|
||||
// We look for anything with the correct language code
|
||||
// and sort on equality with the exact IETF code wanted.
|
||||
// That way using only one query we get either the exact wanted language
|
||||
// or a close match.
|
||||
$id_lang = Db::getInstance()->getValue(
|
||||
'SELECT `id_lang` FROM '
|
||||
.'`'._DB_PREFIX_.'lang` WHERE LEFT(`language_code`,2) = \''.pSQL($lang).'\' '
|
||||
.'ORDER BY language_code = \''.pSQL($code).'\' DESC'
|
||||
);
|
||||
|
||||
// Instantiate the Language object if we found it.
|
||||
if ($id_lang)
|
||||
return new Language($id_lang);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array (id_lang, iso_code)
|
||||
*
|
||||
@@ -717,28 +688,26 @@ class LanguageCore extends ObjectModel
|
||||
if (Language::getIdByIso($iso_code))
|
||||
return true;
|
||||
|
||||
// Initialize the language
|
||||
$lang = new Language();
|
||||
$lang->iso_code = $iso_code;
|
||||
$lang->language_code = $iso_code;
|
||||
$lang->active = true;
|
||||
|
||||
// If the language pack has not been provided, retrieve it from prestashop.com
|
||||
if (!$lang_pack)
|
||||
$lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$iso_code));
|
||||
|
||||
// If a language pack has been found or provided, prefill the language object with the value
|
||||
if ($lang_pack)
|
||||
foreach (get_object_vars($lang_pack) as $key => $value)
|
||||
if ($key != 'iso_code' && isset(Language::$definition['fields'][$key]))
|
||||
$lang->$key = $value;
|
||||
|
||||
// Use the values given in parameters to override the data retrieved automatically
|
||||
if ($params_lang !== null && is_array($params_lang))
|
||||
{
|
||||
if (isset($lang_pack->name)
|
||||
&& isset($lang_pack->version)
|
||||
&& isset($lang_pack->iso_code))
|
||||
$lang->name = $lang_pack->name;
|
||||
}
|
||||
elseif ($params_lang !== null && is_array($params_lang))
|
||||
foreach ($params_lang as $key => $value)
|
||||
if ($key != 'iso_code' && isset(Language::$definition['fields'][$key]))
|
||||
$lang->$key = $value;
|
||||
|
||||
$lang->$key = $value;
|
||||
else
|
||||
return false;
|
||||
|
||||
if (!$lang->add(true, false, $only_add))
|
||||
return false;
|
||||
|
||||
@@ -756,7 +725,7 @@ class LanguageCore extends ObjectModel
|
||||
}
|
||||
else
|
||||
Language::_copyNoneFlag((int)$lang->id);
|
||||
|
||||
|
||||
$files_copy = array(
|
||||
'/en.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('thickbox').'.jpg',
|
||||
@@ -766,7 +735,7 @@ class LanguageCore extends ObjectModel
|
||||
'/en-default-'.ImageType::getFormatedName('small').'.jpg',
|
||||
'/en-default-'.ImageType::getFormatedName('scene').'.jpg'
|
||||
);
|
||||
|
||||
|
||||
foreach (array(_PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_, _PS_PROD_IMG_DIR_, _PS_SUPP_IMG_DIR_) as $to)
|
||||
foreach ($files_copy as $file)
|
||||
@copy(dirname(__FILE__).'/../img/l'.$file, $to.str_replace('/en', '/'.$iso_code, $file));
|
||||
|
||||
@@ -423,15 +423,6 @@ class LinkCore
|
||||
*/
|
||||
public function getPageLink($controller, $ssl = null, $id_lang = null, $request = null, $request_url_encode = false, $id_shop = null)
|
||||
{
|
||||
|
||||
//If $controller contains '&' char, it means that $controller contains request data and must be parsed first
|
||||
$p = strpos($controller, '&');
|
||||
if ($p !== false) {
|
||||
$request = substr($controller, $p + 1);
|
||||
$request_url_encode = false;
|
||||
$controller = substr($controller, 0, $p);
|
||||
}
|
||||
|
||||
$controller = Tools::strReplaceFirst('.php', '', $controller);
|
||||
if (!$id_lang)
|
||||
$id_lang = (int)Context::getContext()->language->id;
|
||||
@@ -510,7 +501,6 @@ class LinkCore
|
||||
|
||||
public function goPage($url, $p)
|
||||
{
|
||||
$url = rtrim(str_replace('?&', '?', $url), '?');
|
||||
return $url.($p == 1 ? '' : (!strstr($url, '?') ? '?' : '&').'p='.(int)$p);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,6 @@ class LocalizationPackCore
|
||||
|
||||
if ($install_mode && $res && isset($this->iso_currency))
|
||||
{
|
||||
Cache::clean('Currency::getIdByIsoCode_*');
|
||||
$res &= Configuration::updateValue('PS_CURRENCY_DEFAULT', (int)Currency::getIdByIsoCode($this->iso_currency));
|
||||
Currency::refreshCurrencies();
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class LoggerCore extends ObjectModel
|
||||
'fields' => array(
|
||||
'severity' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => true),
|
||||
'error_code' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
|
||||
'message' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'required' => true),
|
||||
'message' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'required' => true),
|
||||
'object_id' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
|
||||
'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
|
||||
'object_type' => array('type' => self::TYPE_STRING, 'validate' => 'isName'),
|
||||
|
||||
@@ -133,46 +133,36 @@ class MailCore
|
||||
{
|
||||
foreach ($to as $key => $addr)
|
||||
{
|
||||
$to_name = null;
|
||||
$addr = trim($addr);
|
||||
if (!Validate::isEmail($addr))
|
||||
{
|
||||
Tools::dieOrLog(Tools::displayError('Error: invalid e-mail address'), $die);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_array($to_name))
|
||||
{
|
||||
if ($to_name && is_array($to_name) && Validate::isGenericName($to_name[$key]))
|
||||
$to_name = $to_name[$key];
|
||||
}
|
||||
|
||||
if ($to_name == null || $to_name == $addr)
|
||||
$to_name = '';
|
||||
if ($to_name == null)
|
||||
$to_name = $addr;
|
||||
/* Encode accentuated chars */
|
||||
if (function_exists('mb_encode_mimeheader'))
|
||||
$to_list->addTo($addr, mb_encode_mimeheader($to_name, 'utf-8'));
|
||||
else
|
||||
{
|
||||
if (function_exists('mb_encode_mimeheader'))
|
||||
$to_name = mb_encode_mimeheader($to_name, 'utf-8');
|
||||
else
|
||||
$to_name = self::mimeEncode($to_name);
|
||||
}
|
||||
|
||||
$to_list->addTo($addr, $to_name);
|
||||
$to_list->addTo($addr, self::mimeEncode($to_name));
|
||||
}
|
||||
$to_plugin = $to[0];
|
||||
} else {
|
||||
/* Simple recipient, one address */
|
||||
$to_plugin = $to;
|
||||
if ($to_name == null || $to_name == $to)
|
||||
$to_name = '';
|
||||
if ($to_name == null)
|
||||
$to_name = $to;
|
||||
if (function_exists('mb_encode_mimeheader'))
|
||||
$to_list->addTo($to, mb_encode_mimeheader($to_name, 'utf-8'));
|
||||
else
|
||||
{
|
||||
if (function_exists('mb_encode_mimeheader'))
|
||||
$to_name = mb_encode_mimeheader($to_name, 'utf-8');
|
||||
else
|
||||
$to_name = self::mimeEncode($to_name);
|
||||
}
|
||||
|
||||
$to_list->addTo($to, $to_name);
|
||||
$to_list->addTo($to, self::mimeEncode($to_name));
|
||||
}
|
||||
if(isset($bcc)) {
|
||||
$to_list->addBcc($bcc);
|
||||
@@ -245,13 +235,8 @@ class MailCore
|
||||
include_once($template_path.$iso.'/lang.php');
|
||||
else if ($module_name && file_exists($theme_path.'mails/'.$iso.'/lang.php'))
|
||||
include_once($theme_path.'mails/'.$iso.'/lang.php');
|
||||
else if (file_exists(_PS_MAIL_DIR_.$iso.'/lang.php'))
|
||||
include_once(_PS_MAIL_DIR_.$iso.'/lang.php');
|
||||
else
|
||||
{
|
||||
Tools::dieOrLog(Tools::displayError('Error - The lang file is missing for :').' '.$iso, $die);
|
||||
return false;
|
||||
}
|
||||
include_once(_PS_MAIL_DIR_.$iso.'/lang.php');
|
||||
|
||||
/* Create mail and attach differents parts */
|
||||
$message = new Swift_Message('['.Configuration::get('PS_SHOP_NAME', null, null, $id_shop).'] '.$subject);
|
||||
|
||||
@@ -37,10 +37,9 @@ class MediaCore
|
||||
'ui.selectable' => array('fileName' => 'jquery.ui.selectable.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
|
||||
'ui.sortable' => array('fileName' => 'jquery.ui.sortable.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
|
||||
'ui.accordion' => array('fileName' => 'jquery.ui.accordion.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
|
||||
'ui.autocomplete' => array('fileName' => 'jquery.ui.autocomplete.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position', 'ui.menu'), 'theme' => true),
|
||||
'ui.autocomplete' => array('fileName' => 'jquery.ui.autocomplete.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position'), 'theme' => true),
|
||||
'ui.button' => array('fileName' => 'jquery.ui.button.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
|
||||
'ui.dialog' => array('fileName' => 'jquery.ui.dialog.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position','ui.button'), 'theme' => true),
|
||||
'ui.menu' => array('fileName' => 'jquery.ui.menu.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position'), 'theme' => true),
|
||||
'ui.slider' => array('fileName' => 'jquery.ui.slider.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true),
|
||||
'ui.tabs' => array('fileName' => 'jquery.ui.tabs.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true),
|
||||
'ui.datepicker' => array('fileName' => 'jquery.ui.datepicker.min.js', 'dependencies' => array('ui.core'), 'theme' => true),
|
||||
@@ -110,7 +109,7 @@ class MediaCore
|
||||
|
||||
// If the string is too big preg_replace return an error
|
||||
// In this case, we don't compress the content
|
||||
if (function_exists('preg_last_error') && preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR)
|
||||
if (preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR)
|
||||
{
|
||||
if (_PS_MODE_DEV_)
|
||||
error_log('ERROR: PREG_BACKTRACK_LIMIT_ERROR in function packJSinHTML');
|
||||
|
||||
@@ -85,11 +85,11 @@ class MetaCore extends ObjectModel
|
||||
// Add modules controllers to list (this function is cool !)
|
||||
foreach (glob(_PS_MODULE_DIR_.'*/controllers/front/*.php') as $file)
|
||||
{
|
||||
$filename = Tools::strtolower(basename($file, '.php'));
|
||||
$filename = basename($file, '.php');
|
||||
if ($filename == 'index')
|
||||
continue;
|
||||
|
||||
$module = Tools::strtolower(basename(dirname(dirname(dirname($file)))));
|
||||
$module = basename(dirname(dirname(dirname($file))));
|
||||
$selected_pages[$module.' - '.$filename] = 'module-'.$module.'-'.$filename;
|
||||
}
|
||||
|
||||
@@ -277,31 +277,24 @@ class MetaCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'category_lang` cl
|
||||
WHERE cl.`id_lang` = '.(int)$id_lang.'
|
||||
AND cl.`id_category` = '.(int)$id_category.Shop::addSqlRestrictionOnLang('cl');
|
||||
|
||||
$cache_id = 'Meta::getCategoryMetas'.(int)$id_category.'-'.(int)$id_lang;
|
||||
if (!Cache::isStored($cache_id))
|
||||
if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql))
|
||||
{
|
||||
if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql))
|
||||
{
|
||||
if (empty($row['meta_description']))
|
||||
$row['meta_description'] = strip_tags($row['description']);
|
||||
|
||||
// Paginate title
|
||||
if (!empty($row['meta_title']))
|
||||
$row['meta_title'] = $title.$row['meta_title'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
|
||||
else
|
||||
$row['meta_title'] = $row['name'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
|
||||
|
||||
if (!empty($title))
|
||||
$row['meta_title'] = $title.(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
|
||||
|
||||
$result = Meta::completeMetaTags($row, $row['name']);
|
||||
}
|
||||
if (empty($row['meta_description']))
|
||||
$row['meta_description'] = strip_tags($row['description']);
|
||||
|
||||
// Paginate title
|
||||
if (!empty($row['meta_title']))
|
||||
$row['meta_title'] = $title.$row['meta_title'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
|
||||
else
|
||||
$result = Meta::getHomeMetas($id_lang, $page_name);
|
||||
Cache::store($cache_id, $result);
|
||||
$row['meta_title'] = $row['name'].(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
|
||||
|
||||
if (!empty($title))
|
||||
$row['meta_title'] = $title.(!empty($page_number) ? ' ('.$page_number.')' : '').' - '.Configuration::get('PS_SHOP_NAME');
|
||||
|
||||
return Meta::completeMetaTags($row, $row['name']);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
|
||||
return Meta::getHomeMetas($id_lang, $page_name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -191,7 +191,7 @@ abstract class ObjectModelCore
|
||||
if ($id)
|
||||
{
|
||||
// Load object from database if object id is present
|
||||
$cache_id = 'objectmodel_'.$this->def['classname'].'_'.(int)$id.'_'.(int)$this->id_shop.'_'.(int)$id_lang;
|
||||
$cache_id = 'objectmodel_'.$this->def['classname'].'_'.(int)$id.'_'.(int)$id_shop.'_'.(int)$id_lang;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$sql = new DbQuery();
|
||||
@@ -893,7 +893,7 @@ abstract class ObjectModelCore
|
||||
* @param int $id_lang
|
||||
* @return bool|string
|
||||
*/
|
||||
public function validateField($field, $value, $id_lang = null, $skip = array(), $human_errors = false)
|
||||
public function validateField($field, $value, $id_lang = null)
|
||||
{
|
||||
$this->cacheFieldsRequiredDatabase();
|
||||
$data = $this->def['fields'][$field];
|
||||
@@ -901,12 +901,9 @@ abstract class ObjectModelCore
|
||||
// Check if field is required
|
||||
$required_fields = (isset(self::$fieldsRequiredDatabase[get_class($this)])) ? self::$fieldsRequiredDatabase[get_class($this)] : array();
|
||||
if (!$id_lang || $id_lang == Configuration::get('PS_LANG_DEFAULT'))
|
||||
if (!in_array('required', $skip) && (!empty($data['required']) || in_array($field, $required_fields)))
|
||||
if (!empty($data['required']) || in_array($field, $required_fields))
|
||||
if (Tools::isEmpty($value))
|
||||
if ($human_errors)
|
||||
return sprintf(Tools::displayError('The %s field is required.'), $this->displayFieldName($field, get_class($this)));
|
||||
else
|
||||
return 'Property '.get_class($this).'->'.$field.' is empty';
|
||||
return 'Property '.get_class($this).'->'.$field.' is empty';
|
||||
|
||||
// Default value
|
||||
if (!$value && !empty($data['default']))
|
||||
@@ -916,11 +913,11 @@ abstract class ObjectModelCore
|
||||
}
|
||||
|
||||
// Check field values
|
||||
if (!in_array('values', $skip) && !empty($data['values']) && is_array($data['values']) && !in_array($value, $data['values']))
|
||||
return 'Property '.get_class($this).'->'.$field.' has bad value (allowed values are: '.implode(', ', $data['values']).')';
|
||||
if (!empty($data['values']) && is_array($data['values']) && !in_array($value, $data['values']))
|
||||
return 'Property '.get_class($this).'->'.$field.' has bad value (allowed values are: '.implode(', ', $data['values']).')';
|
||||
|
||||
// Check field size
|
||||
if (!in_array('size', $skip) && !empty($data['size']))
|
||||
if (!empty($data['size']))
|
||||
{
|
||||
$size = $data['size'];
|
||||
if (!is_array($data['size']))
|
||||
@@ -928,24 +925,11 @@ abstract class ObjectModelCore
|
||||
|
||||
$length = Tools::strlen($value);
|
||||
if ($length < $size['min'] || $length > $size['max'])
|
||||
{
|
||||
if ($human_errors)
|
||||
{
|
||||
if (isset($data['lang']) && $data['lang'])
|
||||
{
|
||||
$language = new Language((int)$id_lang);
|
||||
return sprintf(Tools::displayError('The field %1$s (%2$s) is too long (%3$d chars max, html chars including).'), $this->displayFieldName($field, get_class($this)), $language->name, $size['max']);
|
||||
}
|
||||
else
|
||||
return sprintf(Tools::displayError('The %1$s field is too long (%2$d chars max).'), $this->displayFieldName($field, get_class($this)), $size['max']);
|
||||
}
|
||||
else
|
||||
return 'Property '.get_class($this).'->'.$field.' length ('.$length.') must be between '.$size['min'].' and '.$size['max'];
|
||||
}
|
||||
return 'Property '.get_class($this).'->'.$field.' length ('.$length.') must be between '.$size['min'].' and '.$size['max'];
|
||||
}
|
||||
|
||||
// Check field validator
|
||||
if (!in_array('validate', $skip) && !empty($data['validate']))
|
||||
if (!empty($data['validate']))
|
||||
{
|
||||
if (!method_exists('Validate', $data['validate']))
|
||||
throw new PrestaShopException('Validation function not found. '.$data['validate']);
|
||||
@@ -964,12 +948,7 @@ abstract class ObjectModelCore
|
||||
$res = false;
|
||||
}
|
||||
if (!$res)
|
||||
{
|
||||
if ($human_errors)
|
||||
return sprintf(Tools::displayError('The %s field is invalid.'), $this->displayFieldName($field, get_class($this)));
|
||||
else
|
||||
return 'Property '.get_class($this).'->'.$field.' is not valid';
|
||||
}
|
||||
return 'Property '.get_class($this).'->'.$field.' is not valid';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1139,7 +1118,7 @@ abstract class ObjectModelCore
|
||||
{
|
||||
$vars = get_class_vars($class_name);
|
||||
foreach ($vars['shopIDs'] as $id_shop)
|
||||
$or[] = '(main.id_shop = '.(int)$id_shop.(isset($this->def['fields']['id_shop_group']) ? ' OR (id_shop = 0 AND id_shop_group='.(int)Shop::getGroupFromShop((int)$id_shop).')' : '').')';
|
||||
$or[] = ' main.id_shop = '.(int)$id_shop.' ';
|
||||
|
||||
$prepend = '';
|
||||
if (count($or))
|
||||
@@ -1234,16 +1213,11 @@ abstract class ObjectModelCore
|
||||
if ($id_shop === null)
|
||||
$id_shop = Context::getContext()->shop->id;
|
||||
|
||||
$cache_id = 'objectmodel_shop_'.$this->def['classname'].'_'.(int)$this->id.'-'.(int)$id_shop;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$sql = 'SELECT id_shop
|
||||
FROM `'.pSQL(_DB_PREFIX_.$this->def['table']).'_shop`
|
||||
WHERE `'.$this->def['primary'].'` = '.(int)$this->id.'
|
||||
AND id_shop = '.(int)$id_shop;
|
||||
Cache::store($cache_id, (bool)Db::getInstance()->getValue($sql));
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
$sql = 'SELECT id_shop
|
||||
FROM `'.pSQL(_DB_PREFIX_.$this->def['table']).'_shop`
|
||||
WHERE `'.$this->def['primary'].'` = '.(int)$this->id.'
|
||||
AND id_shop = '.(int)$id_shop;
|
||||
return (bool)Db::getInstance()->getValue($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1663,4 +1637,4 @@ abstract class ObjectModelCore
|
||||
{
|
||||
$this->update_fields = $fields;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -399,8 +399,6 @@ abstract class PaymentModuleCore extends Module
|
||||
} // end foreach ($products)
|
||||
|
||||
$cart_rules_list = '';
|
||||
$total_reduction_value_ti = 0;
|
||||
$total_reduction_value_tex = 0;
|
||||
foreach ($cart_rules as $cart_rule)
|
||||
{
|
||||
$package = array('id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list);
|
||||
@@ -421,8 +419,7 @@ abstract class PaymentModuleCore extends Module
|
||||
** THEN
|
||||
** The voucher is cloned with a new value corresponding to the remainder
|
||||
*/
|
||||
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0)
|
||||
if (count($order_list) == 1 && $values['tax_incl'] > $order->total_products_wt && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0)
|
||||
{
|
||||
// Create a new voucher from the original
|
||||
$voucher = new CartRule($cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
|
||||
@@ -435,9 +432,9 @@ abstract class PaymentModuleCore extends Module
|
||||
|
||||
// Set the new voucher value
|
||||
if ($voucher->reduction_tax)
|
||||
$voucher->reduction_amount = $values['tax_incl'] - ($order->total_products_wt - $total_reduction_value_ti) - ($voucher->free_shipping == 1 ? $order->total_shipping_tax_incl : 0);
|
||||
$voucher->reduction_amount = $values['tax_incl'] - $order->total_products_wt - ($voucher->free_shipping == 1 ? $order->total_shipping_tax_incl : 0);
|
||||
else
|
||||
$voucher->reduction_amount = $values['tax_excl'] - ($order->total_products - $total_reduction_value_tex) - ($voucher->free_shipping == 1 ? $order->total_shipping_tax_excl : 0);
|
||||
$voucher->reduction_amount = $values['tax_excl'] - $order->total_products - ($voucher->free_shipping == 1 ? $order->total_shipping_tax_excl : 0);
|
||||
|
||||
$voucher->id_customer = $order->id_customer;
|
||||
$voucher->quantity = 1;
|
||||
@@ -469,10 +466,7 @@ abstract class PaymentModuleCore extends Module
|
||||
|
||||
$values['tax_incl'] -= $values['tax_incl'] - $order->total_products_wt;
|
||||
$values['tax_excl'] -= $values['tax_excl'] - $order->total_products;
|
||||
|
||||
}
|
||||
$total_reduction_value_ti += $values['tax_incl'];
|
||||
$total_reduction_value_tex += $values['tax_excl'];
|
||||
|
||||
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
|
||||
|
||||
@@ -536,13 +530,6 @@ abstract class PaymentModuleCore extends Module
|
||||
if ($order_status->logable)
|
||||
ProductSale::addProductSale((int)$product['id_product'], (int)$product['cart_quantity']);
|
||||
|
||||
// Set the order state
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int)$order->id;
|
||||
$new_history->changeIdOrderState((int)$id_order_state, $order, true);
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
// Switch to back order if needed
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') && $order_detail->getStockState())
|
||||
{
|
||||
$history = new OrderHistory();
|
||||
@@ -551,6 +538,13 @@ abstract class PaymentModuleCore extends Module
|
||||
$history->addWithemail();
|
||||
}
|
||||
|
||||
// Set order state in order history ONLY even if the "out of stock" status has not been yet reached
|
||||
// So you migth have two order states
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int)$order->id;
|
||||
$new_history->changeIdOrderState((int)$id_order_state, $order, true);
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
unset($order_detail);
|
||||
|
||||
// Order is reloaded because the status just changed
|
||||
|
||||
@@ -229,13 +229,7 @@ class ProductCore extends ObjectModel
|
||||
protected static $_prices = array();
|
||||
protected static $_pricesLevel2 = array();
|
||||
protected static $_incat = array();
|
||||
|
||||
/**
|
||||
* @since 1.5.6.1
|
||||
* @var array $_cart_quantity is deprecated since 1.5.6.1
|
||||
*/
|
||||
protected static $_cart_quantity = array();
|
||||
|
||||
protected static $_tax_rules_group = array();
|
||||
protected static $_cacheFeatures = array();
|
||||
protected static $_frontFeaturesCache = array();
|
||||
@@ -525,17 +519,6 @@ class ProductCore extends ObjectModel
|
||||
if (!Validate::isLoadedObject($customer))
|
||||
die(Tools::displayError());
|
||||
self::$_taxCalculationMethod = Group::getPriceDisplayMethod((int)$customer->id_default_group);
|
||||
$cur_cart = Context::getContext()->cart;
|
||||
$id_address = 0;
|
||||
if (Validate::isLoadedObject($cur_cart))
|
||||
$id_address = (int)$cur_cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
|
||||
$address_infos = Address::getCountryAndState($id_address);
|
||||
|
||||
if (self::$_taxCalculationMethod != PS_TAX_EXC
|
||||
&& !empty($address_infos['vat_number'])
|
||||
&& $address_infos['id_country'] != Configuration::get('VATNUMBER_COUNTRY')
|
||||
&& Configuration::get('VATNUMBER_MANAGEMENT'))
|
||||
self::$_taxCalculationMethod = PS_TAX_EXC;
|
||||
}
|
||||
else
|
||||
self::$_taxCalculationMethod = Group::getPriceDisplayMethod(Group::getCurrent()->id);
|
||||
@@ -747,10 +730,10 @@ class ProductCore extends ObjectModel
|
||||
/**
|
||||
* @see ObjectModel::validateField()
|
||||
*/
|
||||
public function validateField($field, $value, $id_lang = null, $skip = array(), $human_errors = false)
|
||||
public function validateField($field, $value, $id_lang = null)
|
||||
{
|
||||
$value = ($field == 'description_short' ? strip_tags($value) : $value);
|
||||
return parent::validateField($field, $value, $id_lang, $skip, $human_errors);
|
||||
return parent::validateField($field, $value, $id_lang);
|
||||
}
|
||||
|
||||
public function toggleStatus()
|
||||
@@ -1385,8 +1368,8 @@ class ProductCore extends ObjectModel
|
||||
}
|
||||
|
||||
$product_supplier->product_supplier_reference = pSQL($supplier_reference);
|
||||
$product_supplier->product_supplier_price_te = !is_null($price) ? (float)$price : (float)$product_supplier->product_supplier_price_te;
|
||||
$product_supplier->id_currency = !is_null($id_currency) ? (int)$id_currency : (int)$product_supplier->id_currency;
|
||||
$product_supplier->product_supplier_price_te = (float)$price;
|
||||
$product_supplier->id_currency = (int)$id_currency;
|
||||
$product_supplier->save();
|
||||
}
|
||||
}
|
||||
@@ -2440,18 +2423,13 @@ class ProductCore extends ObjectModel
|
||||
{
|
||||
if (!$context)
|
||||
$context = Context::getContext();
|
||||
$cache_id = 'Product::getOrderStates_'.(int)$id_product.'-'.(int)$context->shop->id;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$sql = 'SELECT image_shop.`id_image`
|
||||
FROM `'._DB_PREFIX_.'image` i
|
||||
'.Shop::addSqlAssociation('image', 'i').'
|
||||
WHERE i.`id_product` = '.(int)$id_product.'
|
||||
AND image_shop.`cover` = 1';
|
||||
$result = Db::getInstance()->getRow($sql);
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
|
||||
$sql = 'SELECT image_shop.`id_image`
|
||||
FROM `'._DB_PREFIX_.'image` i
|
||||
'.Shop::addSqlAssociation('image', 'i').'
|
||||
WHERE i.`id_product` = '.(int)$id_product.'
|
||||
AND image_shop.`cover` = 1';
|
||||
return Db::getInstance()->getRow($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2513,17 +2491,15 @@ class ProductCore extends ObjectModel
|
||||
$cart_quantity = 0;
|
||||
if ((int)$id_cart)
|
||||
{
|
||||
$cache_id = 'Product::getPriceStatic_'.(int)$id_product.'-'.(int)$id_cart;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$sql = 'SELECT SUM(`quantity`)
|
||||
$condition = '';
|
||||
$cache_name = (int)$id_cart.'_'.(int)$id_product;
|
||||
if (!isset(self::$_cart_quantity[$cache_name]) || self::$_cart_quantity[$cache_name] != (int)$quantity)
|
||||
self::$_cart_quantity[$cache_name] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT SUM(`quantity`)
|
||||
FROM `'._DB_PREFIX_.'cart_product`
|
||||
WHERE `id_product` = '.(int)$id_product.'
|
||||
AND `id_cart` = '.(int)$id_cart;
|
||||
$cart_quantity = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
|
||||
Cache::store($cache_id, $cart_quantity);
|
||||
}
|
||||
$cart_quantity = Cache::retrieve($cache_id);
|
||||
AND `id_cart` = '.(int)$id_cart);
|
||||
$cart_quantity = self::$_cart_quantity[$cache_name];
|
||||
}
|
||||
|
||||
$id_currency = (int)Validate::isLoadedObject($context->currency) ? $context->currency->id : Configuration::get('PS_CURRENCY_DEFAULT');
|
||||
@@ -2533,7 +2509,7 @@ class ProductCore extends ObjectModel
|
||||
$id_state = 0;
|
||||
$zipcode = 0;
|
||||
|
||||
if (!$id_address && Validate::isLoadedObject($cur_cart))
|
||||
if (!$id_address)
|
||||
$id_address = $cur_cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
|
||||
|
||||
if ($id_address)
|
||||
@@ -2744,7 +2720,8 @@ class ProductCore extends ObjectModel
|
||||
if ($use_group_reduction)
|
||||
{
|
||||
$reduction_from_category = GroupReduction::getValueForProduct($id_product, $id_group);
|
||||
if ($reduction_from_category !== false)
|
||||
|
||||
if (!empty($reduction_from_category) && (float)$reduction_from_category == 0)
|
||||
$price -= $price * (float)$reduction_from_category;
|
||||
else // apply group reduction if there is no group reduction for this category
|
||||
$price *= ((100 - Group::getReductionByIdGroup($id_group)) / 100);
|
||||
@@ -3183,9 +3160,8 @@ class ProductCore extends ObjectModel
|
||||
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (p.`id_manufacturer`= m.`id_manufacturer`)
|
||||
'.Product::sqlStock('p', 0).'
|
||||
WHERE `id_product_1` = '.(int)$this->id.
|
||||
($active ? ' AND product_shop.`active` = 1 AND product_shop.`visibility` != \'none\'' : '').'
|
||||
($active ? ' AND product_shop.`active` = 1' : '').'
|
||||
GROUP BY product_shop.id_product';
|
||||
|
||||
if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql))
|
||||
return false;
|
||||
foreach ($result as &$row)
|
||||
@@ -3337,7 +3313,7 @@ class ProductCore extends ObjectModel
|
||||
$context = Context::getContext();
|
||||
|
||||
$sql = new DbQuery();
|
||||
$sql->select('p.`id_product`, pl.`name`, p.`ean13`, p.`upc`, p.`active`, p.`reference`, m.`name` AS manufacturer_name, stock.`quantity`, product_shop.advanced_stock_management, p.`customizable`');
|
||||
$sql->select('p.`id_product`, pl.`name`, p.`active`, p.`reference`, m.`name` AS manufacturer_name, stock.`quantity`, product_shop.advanced_stock_management, p.`customizable`');
|
||||
$sql->from('category_product', 'cp');
|
||||
$sql->leftJoin('product', 'p', 'p.`id_product` = cp.`id_product`');
|
||||
$sql->join(Shop::addSqlAssociation('product', 'p'));
|
||||
@@ -3348,8 +3324,6 @@ class ProductCore extends ObjectModel
|
||||
$sql->leftJoin('manufacturer', 'm', 'm.`id_manufacturer` = p.`id_manufacturer`');
|
||||
|
||||
$where = 'pl.`name` LIKE \'%'.pSQL($query).'%\'
|
||||
OR p.`ean13` LIKE \'%'.pSQL($query).'%\'
|
||||
OR p.`upc` LIKE \'%'.pSQL($query).'%\'
|
||||
OR p.`reference` LIKE \'%'.pSQL($query).'%\'
|
||||
OR p.`supplier_reference` LIKE \'%'.pSQL($query).'%\'
|
||||
OR p.`id_product` IN (SELECT id_product FROM '._DB_PREFIX_.'product_supplier sp WHERE `product_supplier_reference` LIKE \'%'.pSQL($query).'%\')';
|
||||
@@ -3603,7 +3577,6 @@ class ProductCore extends ObjectModel
|
||||
if ($result3)
|
||||
{
|
||||
$result3['id_feature_value'] = $new_id_feature_value;
|
||||
$result3['value'] = pSQL($result3['value']);
|
||||
$return &= Db::getInstance()->insert('feature_value_lang', $result3);
|
||||
}
|
||||
}
|
||||
@@ -4313,25 +4286,19 @@ class ProductCore extends ObjectModel
|
||||
|
||||
public function checkAccess($id_customer)
|
||||
{
|
||||
$cache_id = 'Product::checkAccess_'.(int)$this->id.'-'.(int)$id_customer.(!$id_customer ? '-'.(int)Group::getCurrent()->id : '');
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
if (!$id_customer)
|
||||
$result = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT ctg.`id_group`
|
||||
FROM `'._DB_PREFIX_.'category_product` cp
|
||||
INNER JOIN `'._DB_PREFIX_.'category_group` ctg ON (ctg.`id_category` = cp.`id_category`)
|
||||
WHERE cp.`id_product` = '.(int)$this->id.' AND ctg.`id_group` = '.(int)Group::getCurrent()->id);
|
||||
else
|
||||
$result = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT cg.`id_group`
|
||||
FROM `'._DB_PREFIX_.'category_product` cp
|
||||
INNER JOIN `'._DB_PREFIX_.'category_group` ctg ON (ctg.`id_category` = cp.`id_category`)
|
||||
INNER JOIN `'._DB_PREFIX_.'customer_group` cg ON (cg.`id_group` = ctg.`id_group`)
|
||||
WHERE cp.`id_product` = '.(int)$this->id.' AND cg.`id_customer` = '.(int)$id_customer);
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
if (!$id_customer)
|
||||
return (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT ctg.`id_group`
|
||||
FROM `'._DB_PREFIX_.'category_product` cp
|
||||
INNER JOIN `'._DB_PREFIX_.'category_group` ctg ON (ctg.`id_category` = cp.`id_category`)
|
||||
WHERE cp.`id_product` = '.(int)$this->id.' AND ctg.`id_group` ='.(int)Group::getCurrent()->id);
|
||||
else
|
||||
return (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT cg.`id_group`
|
||||
FROM `'._DB_PREFIX_.'category_product` cp
|
||||
INNER JOIN `'._DB_PREFIX_.'category_group` ctg ON (ctg.`id_category` = cp.`id_category`)
|
||||
INNER JOIN `'._DB_PREFIX_.'customer_group` cg ON (cg.`id_group` = ctg.`id_group`)
|
||||
WHERE cp.`id_product` = '.(int)$this->id.' AND cg.`id_customer` = '.(int)$id_customer);
|
||||
}
|
||||
|
||||
|
||||
@@ -4891,12 +4858,8 @@ class ProductCore extends ObjectModel
|
||||
*/
|
||||
public static function getAttributesParams($id_product, $id_product_attribute)
|
||||
{
|
||||
$id_lang = (int)Context::getContext()->language->id;
|
||||
$id_shop = (int)Context::getContext()->shop->id;
|
||||
$cache_id = 'Product::getAttributesParams_'.(int)$id_product.'-'.(int)$id_product_attribute.'-'.(int)$id_lang.'-'.(int)$id_shop;
|
||||
|
||||
// if blocklayered module is installed we check if user has set custom attribute name
|
||||
if (Module::isInstalled('blocklayered') && Module::isEnabled('blocklayered'))
|
||||
if (Module::isInstalled('blocklayered'))
|
||||
{
|
||||
$nb_custom_values = Db::getInstance()->executeS('
|
||||
SELECT DISTINCT la.`id_attribute`, la.`url_name` as `name`
|
||||
@@ -4907,7 +4870,7 @@ class ProductCore extends ObjectModel
|
||||
ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
|
||||
'.Shop::addSqlAssociation('product_attribute', 'pa').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'layered_indexable_attribute_lang_value` la
|
||||
ON (la.`id_attribute` = a.`id_attribute` AND la.`id_lang` = '.(int)$id_lang.')
|
||||
ON (la.`id_attribute` = a.`id_attribute` AND la.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
WHERE la.`url_name` IS NOT NULL AND la.`url_name` != \'\'
|
||||
AND pa.`id_product` = '.(int)$id_product.'
|
||||
AND pac.`id_product_attribute` = '.(int)$id_product_attribute);
|
||||
@@ -4925,7 +4888,7 @@ class ProductCore extends ObjectModel
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute` a
|
||||
ON (a.`id_attribute_group` = g.`id_attribute_group`)
|
||||
WHERE a.`id_attribute` = '.(int)$attribute['id_attribute'].'
|
||||
AND g.`id_lang` = '.(int)$id_lang.'
|
||||
AND g.`id_lang` = '.(int)Context::getContext()->language->id.'
|
||||
AND g.`url_name` IS NOT NULL AND g.`url_name` != \'\'');
|
||||
if (empty($group))
|
||||
{
|
||||
@@ -4935,7 +4898,7 @@ class ProductCore extends ObjectModel
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute` a
|
||||
ON (a.`id_attribute_group` = g.`id_attribute_group`)
|
||||
WHERE a.`id_attribute` = '.(int)$attribute['id_attribute'].'
|
||||
AND g.`id_lang` = '.(int)$id_lang.'
|
||||
AND g.`id_lang` = '.(int)Context::getContext()->language->id.'
|
||||
AND g.`name` IS NOT NULL');
|
||||
}
|
||||
$result[] = array_merge($attribute, $group[0]);
|
||||
@@ -4944,9 +4907,9 @@ class ProductCore extends ObjectModel
|
||||
SELECT DISTINCT a.`id_attribute_group`, al.`name`, agl.`name` as `group`
|
||||
FROM `'._DB_PREFIX_.'attribute` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
|
||||
ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)$id_lang.')
|
||||
ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
|
||||
ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)$id_lang.')
|
||||
ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
ON (a.`id_attribute` = pac.`id_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
|
||||
@@ -4955,30 +4918,45 @@ class ProductCore extends ObjectModel
|
||||
WHERE pa.`id_product` = '.(int)$id_product.'
|
||||
AND pac.id_product_attribute = '.(int)$id_product_attribute.'
|
||||
AND a.`id_attribute` NOT IN('.implode(', ', $tab_id_attribute).')');
|
||||
return array_merge($values_not_custom, $result);
|
||||
$result = array_merge($values_not_custom, $result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT al.`name`, agl.`name` as `group`
|
||||
FROM `'._DB_PREFIX_.'attribute` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
|
||||
ON (al.`id_attribute` = a.`id_attribute` AND al.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
ON (pac.`id_attribute` = a.`id_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
|
||||
ON (pa.`id_product_attribute` = pac.`id_product_attribute`)
|
||||
'.Shop::addSqlAssociation('product_attribute', 'pa').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
|
||||
ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
WHERE pa.`id_product` = '.(int)$id_product.'
|
||||
AND pac.`id_product_attribute` = '.(int)$id_product_attribute.'
|
||||
AND agl.`id_lang` = '.(int)Context::getContext()->language->id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Cache::isStored($cache_id))
|
||||
else
|
||||
{
|
||||
$result = Db::getInstance()->executeS('
|
||||
SELECT al.`name`, agl.`name` as `group`
|
||||
FROM `'._DB_PREFIX_.'attribute` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
|
||||
ON (al.`id_attribute` = a.`id_attribute` AND al.`id_lang` = '.(int)$id_lang.')
|
||||
ON (al.`id_attribute` = a.`id_attribute` AND al.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
ON (pac.`id_attribute` = a.`id_attribute`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
|
||||
ON (pa.`id_product_attribute` = pac.`id_product_attribute`)
|
||||
'.Shop::addSqlAssociation('product_attribute', 'pa').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
|
||||
ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)$id_lang.')
|
||||
ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)Context::getContext()->language->id.')
|
||||
WHERE pa.`id_product` = '.(int)$id_product.'
|
||||
AND pac.`id_product_attribute` = '.(int)$id_product_attribute.'
|
||||
AND agl.`id_lang` = '.(int)$id_lang);
|
||||
Cache::store($cache_id, $result);
|
||||
AND agl.`id_lang` = '.(int)Context::getContext()->language->id);
|
||||
}
|
||||
$result = Cache::retrieve($cache_id);
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -5278,10 +5256,7 @@ class ProductCore extends ObjectModel
|
||||
WHERE id_product='.(int)$this->id.Shop::addSqlRestriction()
|
||||
);
|
||||
else
|
||||
{
|
||||
$this->setFieldsToUpdate(array('advanced_stock_management' => true));
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,21 +74,11 @@ class ProductSaleCore
|
||||
$groups = FrontController::getCurrentCustomerGroups();
|
||||
$sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');
|
||||
$interval = Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20;
|
||||
|
||||
//Subquery: get product ids in a separate query to (greatly!) improve performances and RAM usage
|
||||
$sql = 'SELECT cp.`id_product`
|
||||
FROM `'._DB_PREFIX_.'category_group` cg
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
|
||||
WHERE cg.`id_group` '.$sql_groups;
|
||||
$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
$ids = array();
|
||||
foreach ($products as $product)
|
||||
$ids[$product['id_product']] = 1;
|
||||
$ids = array_keys($ids);
|
||||
sort($ids);
|
||||
$ids = count($ids) > 0 ? implode(',', $ids) : 'NULL';
|
||||
|
||||
//Main query
|
||||
$prefix = '';
|
||||
if ($order_by == 'date_add')
|
||||
$prefix = 'p.';
|
||||
|
||||
$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity,
|
||||
pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
|
||||
pl.`meta_keywords`, pl.`meta_title`, pl.`name`,
|
||||
@@ -114,7 +104,12 @@ class ProductSaleCore
|
||||
'.Product::sqlStock('p').'
|
||||
WHERE product_shop.`active` = 1
|
||||
AND p.`visibility` != \'none\'
|
||||
AND p.`id_product` IN ('.$ids.')
|
||||
AND p.`id_product` IN (
|
||||
SELECT cp.`id_product`
|
||||
FROM `'._DB_PREFIX_.'category_group` cg
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
|
||||
WHERE cg.`id_group` '.$sql_groups.'
|
||||
)
|
||||
GROUP BY product_shop.id_product
|
||||
ORDER BY '.(!empty($order_table) ? '`'.pSQL($order_table).'`.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way).'
|
||||
LIMIT '.(int)($page_number * $nb_products).', '.(int)$nb_products;
|
||||
@@ -146,27 +141,11 @@ class ProductSaleCore
|
||||
$groups = FrontController::getCurrentCustomerGroups();
|
||||
$sql_groups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');
|
||||
|
||||
//Subquery: get product ids in a separate query to (greatly!) improve performances and RAM usage
|
||||
$sql = 'SELECT cp.`id_product`
|
||||
FROM `'._DB_PREFIX_.'category_group` cg
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
|
||||
WHERE cg.`id_group` '.$sql_groups.' AND cp.`id_product` IS NOT NULL';
|
||||
$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
$ids = array();
|
||||
foreach ($products as $product)
|
||||
$ids[$product['id_product']] = 1;
|
||||
$ids = array_keys($ids);
|
||||
sort($ids);
|
||||
$ids = count($ids) > 0 ? implode(',', $ids) : 'NULL';
|
||||
|
||||
//Main query
|
||||
$sql = 'SELECT p.id_product, pl.`link_rewrite`, pl.`name`, pl.`description_short`, MAX(image_shop.`id_image`) id_image, il.`legend`,
|
||||
ps.`quantity` AS sales, p.`ean13`, p.`upc`, cl.`link_rewrite` AS category, p.show_price, p.available_for_order, p.quantity, p.customizable,
|
||||
IFNULL(pa.minimal_quantity, p.minimal_quantity) as minimal_quantity, p.out_of_stock
|
||||
ps.`quantity` AS sales, p.`ean13`, p.`upc`, cl.`link_rewrite` AS category
|
||||
FROM `'._DB_PREFIX_.'product_sale` ps
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON ps.`id_product` = p.`id_product`
|
||||
'.Shop::addSqlAssociation('product', 'p').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (ps.`id_product` = pa.`id_product` AND pa.default_on = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
ON p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
|
||||
@@ -178,11 +157,15 @@ class ProductSaleCore
|
||||
AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').'
|
||||
WHERE product_shop.`active` = 1
|
||||
AND p.`visibility` != \'none\'
|
||||
AND p.`id_product` IN ('.$ids.')
|
||||
AND p.`id_product` IN (
|
||||
SELECT cp.`id_product`
|
||||
FROM `'._DB_PREFIX_.'category_group` cg
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
|
||||
WHERE cg.`id_group` '.$sql_groups.'
|
||||
)
|
||||
GROUP BY product_shop.id_product
|
||||
ORDER BY sales DESC
|
||||
LIMIT '.(int)($page_number * $nb_products).', '.(int)$nb_products;
|
||||
|
||||
if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql))
|
||||
return false;
|
||||
|
||||
@@ -190,13 +173,6 @@ class ProductSaleCore
|
||||
{
|
||||
$row['link'] = $context->link->getProductLink($row['id_product'], $row['link_rewrite'], $row['category'], $row['ean13']);
|
||||
$row['id_image'] = Product::defineProductImage($row, $id_lang);
|
||||
$row['allow_oosp'] = Product::isAvailableWhenOutOfStock($row['out_of_stock']);
|
||||
$row['price_tax_exc'] = Product::getPriceStatic(
|
||||
(int)$row['id_product'],
|
||||
false,
|
||||
((isset($row['id_product_attribute']) && !empty($row['id_product_attribute'])) ? (int)$row['id_product_attribute'] : null),
|
||||
(Product::$_taxCalculationMethod == PS_TAX_EXC ? 2 : 6)
|
||||
);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -139,22 +139,21 @@ class ReferrerCore extends ObjectModel
|
||||
}
|
||||
|
||||
$sql = 'SELECT COUNT(DISTINCT cs.id_connections_source) AS visits,
|
||||
COUNT(DISTINCT cs.id_connections) as visitors,
|
||||
COUNT(DISTINCT c.id_guest) as uniqs,
|
||||
COUNT(DISTINCT cp.time_start) as pages
|
||||
FROM '._DB_PREFIX_.'referrer_cache rc
|
||||
LEFT JOIN '._DB_PREFIX_.'referrer r ON rc.id_referrer = r.id_referrer
|
||||
LEFT JOIN '._DB_PREFIX_.'referrer_shop rs ON r.id_referrer = rs.id_referrer
|
||||
LEFT JOIN '._DB_PREFIX_.'connections_source cs ON rc.id_connections_source = cs.id_connections_source
|
||||
LEFT JOIN '._DB_PREFIX_.'connections c ON cs.id_connections = c.id_connections
|
||||
LEFT JOIN '._DB_PREFIX_.'connections_page cp ON cp.id_connections = c.id_connections
|
||||
'.$join.'
|
||||
WHERE 1'.
|
||||
((isset($employee->stats_date_from) && isset($employee->stats_date_from))? ' AND cs.date_add BETWEEN \''.pSQL($employee->stats_date_from).' 00:00:00\' AND \''.pSQL($employee->stats_date_to).' 23:59:59\'' : '').
|
||||
Shop::addSqlRestriction(false, 'rs').
|
||||
Shop::addSqlRestriction(false, 'c').
|
||||
' AND rc.id_referrer = '.(int)$this->id.
|
||||
$where;
|
||||
COUNT(DISTINCT cs.id_connections) as visitors,
|
||||
COUNT(DISTINCT c.id_guest) as uniqs,
|
||||
COUNT(DISTINCT cp.time_start) as pages
|
||||
FROM '._DB_PREFIX_.'referrer_cache rc
|
||||
LEFT JOIN '._DB_PREFIX_.'referrer r ON rc.id_referrer = r.id_referrer
|
||||
LEFT JOIN '._DB_PREFIX_.'referrer_shop rs ON r.id_referrer = rs.id_referrer
|
||||
LEFT JOIN '._DB_PREFIX_.'connections_source cs ON rc.id_connections_source = cs.id_connections_source
|
||||
LEFT JOIN '._DB_PREFIX_.'connections c ON cs.id_connections = c.id_connections
|
||||
LEFT JOIN '._DB_PREFIX_.'connections_page cp ON cp.id_connections = c.id_connections
|
||||
'.$join.'
|
||||
WHERE cs.date_add BETWEEN '.ModuleGraph::getDateBetween($employee).'
|
||||
'.Shop::addSqlRestriction(false, 'rs').'
|
||||
'.Shop::addSqlRestriction(false, 'c').'
|
||||
AND rc.id_referrer = '.(int)$this->id
|
||||
.$where;
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
|
||||
}
|
||||
|
||||
@@ -315,7 +314,6 @@ class ReferrerCore extends ObjectModel
|
||||
FROM '._DB_PREFIX_.'referrer r
|
||||
LEFT JOIN '._DB_PREFIX_.'connections_source cs ON ('.self::$_join.')
|
||||
WHERE id_referrer = '.(int)$row['id_referrer'].'
|
||||
AND id_connections_source IS NOT NULL
|
||||
)');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class SpecificPriceCore extends ObjectModel
|
||||
if (parent::add($autodate, $nullValues))
|
||||
{
|
||||
// Flush cache when we adding a new specific price
|
||||
SpecificPrice::$_specificPriceCache = array();
|
||||
self::$_specificPriceCache = array();
|
||||
Product::flushPriceCache();
|
||||
// Set cache of feature detachable to true
|
||||
Configuration::updateGlobalValue('PS_SPECIFIC_PRICE_FEATURE_ACTIVE', '1');
|
||||
@@ -108,7 +108,7 @@ class SpecificPriceCore extends ObjectModel
|
||||
if (parent::update($null_values))
|
||||
{
|
||||
// Flush cache when we updating a new specific price
|
||||
SpecificPrice::$_specificPriceCache = array();
|
||||
self::$_specificPriceCache = array();
|
||||
Product::flushPriceCache();
|
||||
return true;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ class SpecificPriceCore extends ObjectModel
|
||||
if (parent::delete())
|
||||
{
|
||||
// Flush cache when we deletind a new specific price
|
||||
SpecificPrice::$_specificPriceCache = array();
|
||||
self::$_specificPriceCache = array();
|
||||
Product::flushPriceCache();
|
||||
// Refresh cache of feature detachable
|
||||
Configuration::updateGlobalValue('PS_SPECIFIC_PRICE_FEATURE_ACTIVE', SpecificPrice::isCurrentlyUsed($this->def['table']));
|
||||
@@ -169,8 +169,7 @@ class SpecificPriceCore extends ObjectModel
|
||||
|
||||
$priority = SpecificPrice::getPriority($id_product);
|
||||
foreach (array_reverse($priority) as $k => $field)
|
||||
if (!empty($field))
|
||||
$select .= ' IF (`'.bqSQL($field).'` = '.(int)$$field.', '.pow(2, $k + 1).', 0) + ';
|
||||
$select .= ' IF (`'.bqSQL($field).'` = '.(int)$$field.', '.pow(2, $k + 1).', 0) + ';
|
||||
|
||||
return rtrim($select, ' +').') AS `score`';
|
||||
}
|
||||
@@ -180,9 +179,9 @@ class SpecificPriceCore extends ObjectModel
|
||||
if (!SpecificPrice::isFeatureActive())
|
||||
return explode(';', Configuration::get('PS_SPECIFIC_PRICE_PRIORITIES'));
|
||||
|
||||
if (!isset(SpecificPrice::$_cache_priorities[(int)$id_product]))
|
||||
if (!isset(self::$_cache_priorities[(int)$id_product]))
|
||||
{
|
||||
SpecificPrice::$_cache_priorities[(int)$id_product] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
self::$_cache_priorities[(int)$id_product] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT `priority`, `id_specific_price_priority`
|
||||
FROM `'._DB_PREFIX_.'specific_price_priority`
|
||||
WHERE `id_product` = '.(int)$id_product.'
|
||||
@@ -190,7 +189,7 @@ class SpecificPriceCore extends ObjectModel
|
||||
');
|
||||
}
|
||||
|
||||
$priority = SpecificPrice::$_cache_priorities[(int)$id_product];
|
||||
$priority = self::$_cache_priorities[(int)$id_product];
|
||||
|
||||
if (!$priority)
|
||||
$priority = Configuration::get('PS_SPECIFIC_PRICE_PRIORITIES');
|
||||
@@ -209,11 +208,11 @@ class SpecificPriceCore extends ObjectModel
|
||||
*/
|
||||
|
||||
$key = ((int)$id_product.'-'.(int)$id_shop.'-'.(int)$id_currency.'-'.(int)$id_country.'-'.(int)$id_group.'-'.(int)$quantity.'-'.(int)$id_product_attribute.'-'.(int)$id_cart.'-'.(int)$id_customer.'-'.(int)$real_quantity);
|
||||
if (!array_key_exists($key, SpecificPrice::$_specificPriceCache))
|
||||
if (!array_key_exists($key, self::$_specificPriceCache))
|
||||
{
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$query = '
|
||||
SELECT *, '.SpecificPrice::_getScoreQuery($id_product, $id_shop, $id_currency, $id_country, $id_group, $id_customer).'
|
||||
self::$_specificPriceCache[$key] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT *, '.SpecificPrice::_getScoreQuery($id_product, $id_shop, $id_currency, $id_country, $id_group, $id_customer).'
|
||||
FROM `'._DB_PREFIX_.'specific_price`
|
||||
WHERE `id_product` IN (0, '.(int)$id_product.')
|
||||
AND `id_product_attribute` IN (0, '.(int)$id_product_attribute.')
|
||||
@@ -228,22 +227,11 @@ class SpecificPriceCore extends ObjectModel
|
||||
AND
|
||||
(`to` = \'0000-00-00 00:00:00\' OR \''.$now.'\' <= `to`)
|
||||
)
|
||||
AND id_cart IN (0, '.(int)$id_cart.') ';
|
||||
|
||||
if ($real_quantity != 0 && !Configuration::get('PS_QTY_DISCOUNT_ON_COMBINATION'))
|
||||
$query .= ' AND IF(`from_quantity` > 1, `from_quantity`, 0) <= IF(id_product_attribute=0,'.(int)$quantity.' ,'.(int)$real_quantity.')';
|
||||
else
|
||||
{
|
||||
$qty_to_use = $id_cart ? (int)$quantity : (int)$real_quantity;
|
||||
$query .= 'AND `from_quantity` <= '.max(1, $qty_to_use);
|
||||
}
|
||||
|
||||
$query .= ' ORDER BY `id_product_attribute` DESC, `from_quantity` DESC, `id_specific_price_rule` ASC, `score` DESC';
|
||||
|
||||
SpecificPrice::$_specificPriceCache[$key] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query);
|
||||
|
||||
AND id_cart IN (0, '.(int)$id_cart.')'.
|
||||
(($real_quantity != 0 && !Configuration::get('PS_QTY_DISCOUNT_ON_COMBINATION')) ? ' AND IF(`from_quantity` > 1, `from_quantity`, 0) <= IF(id_product_attribute=0,'.(int)$quantity.' ,'.(int)$real_quantity.')' : 'AND `from_quantity` <= '.(int)$real_quantity).'
|
||||
ORDER BY `id_product_attribute` DESC, `from_quantity` DESC, `id_specific_price_rule` ASC, `score` DESC');
|
||||
}
|
||||
return SpecificPrice::$_specificPriceCache[$key];
|
||||
return self::$_specificPriceCache[$key];
|
||||
}
|
||||
|
||||
public static function setPriorities($priorities)
|
||||
@@ -313,7 +301,7 @@ class SpecificPriceCore extends ObjectModel
|
||||
if (!isset($last_quantity[(int)$specific_price['id_product_attribute']]))
|
||||
$last_quantity[(int)$specific_price['id_product_attribute']] = $specific_price['from_quantity'];
|
||||
elseif ($last_quantity[(int)$specific_price['id_product_attribute']] == $specific_price['from_quantity'])
|
||||
continue;
|
||||
break;
|
||||
|
||||
$last_quantity[(int)$specific_price['id_product_attribute']] = $specific_price['from_quantity'];
|
||||
if ($specific_price['from_quantity'] > 1)
|
||||
|
||||
@@ -183,7 +183,7 @@ class SpecificPriceRuleCore extends ObjectModel
|
||||
|
||||
if ($conditions_group)
|
||||
{
|
||||
$where .= ' AND ((';
|
||||
$where .= ' AND (';
|
||||
foreach ($conditions_group as $id_condition_group => $condition_group)
|
||||
{
|
||||
$fields = array(
|
||||
@@ -235,7 +235,7 @@ class SpecificPriceRuleCore extends ObjectModel
|
||||
|
||||
$where = rtrim($where, ' AND ').') OR (';
|
||||
}
|
||||
$where = rtrim($where, 'OR (').')';
|
||||
$where = rtrim($where, 'OR (');
|
||||
}
|
||||
if ($products && count($products))
|
||||
$where .= ' AND p.id_product IN ('.implode(', ', array_map('intval', $products)).')';
|
||||
@@ -267,7 +267,7 @@ class SpecificPriceRuleCore extends ObjectModel
|
||||
public static function applyRuleToProduct($id_rule, $id_product, $id_product_attribute = null)
|
||||
{
|
||||
$rule = new SpecificPriceRule((int)$id_rule);
|
||||
if (!Validate::isLoadedObject($rule) || !$id_product)
|
||||
if (!Validate::isLoadedObject($rule))
|
||||
return false;
|
||||
|
||||
$specific_price = new SpecificPrice();
|
||||
|
||||
@@ -80,19 +80,13 @@ class StateCore extends ObjectModel
|
||||
*/
|
||||
public static function getNameById($id_state)
|
||||
{
|
||||
if (!$id_state)
|
||||
return false;
|
||||
$cache_id = 'State::getNameById_'.(int)$id_state;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT `name`
|
||||
FROM `'._DB_PREFIX_.'state`
|
||||
WHERE `id_state` = '.(int)$id_state
|
||||
);
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT `name`
|
||||
FROM `'._DB_PREFIX_.'state`
|
||||
WHERE `id_state` = '.(int)$id_state
|
||||
);
|
||||
|
||||
return $result['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,19 +97,13 @@ class StateCore extends ObjectModel
|
||||
*/
|
||||
public static function getIdByName($state)
|
||||
{
|
||||
if (empty($state))
|
||||
return false;
|
||||
$cache_id = 'State::getNameById_'.pSQL($state);
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$result = (int)Db::getInstance()->getValue('
|
||||
SELECT `id_state`
|
||||
FROM `'._DB_PREFIX_.'state`
|
||||
WHERE `name` LIKE \''.pSQL($state).'\'
|
||||
');
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
$result = Db::getInstance()->getValue('
|
||||
SELECT `id_state`
|
||||
FROM `'._DB_PREFIX_.'state`
|
||||
WHERE `name` LIKE \''.pSQL($state).'\'
|
||||
');
|
||||
|
||||
return (int)$result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -190,20 +190,14 @@ class TabCore extends ObjectModel
|
||||
*/
|
||||
public static function getTab($id_lang, $id_tab)
|
||||
{
|
||||
$cache_id = 'Tab::getTab_'.(int)$id_lang.'-'.(int)$id_tab;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
/* Tabs selection */
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'tab` t
|
||||
LEFT JOIN `'._DB_PREFIX_.'tab_lang` tl
|
||||
ON (t.`id_tab` = tl.`id_tab` AND tl.`id_lang` = '.(int)$id_lang.')
|
||||
WHERE t.`id_tab` = '.(int)$id_tab
|
||||
);
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
/* Tabs selection */
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'tab` t
|
||||
LEFT JOIN `'._DB_PREFIX_.'tab_lang` tl
|
||||
ON (t.`id_tab` = tl.`id_tab` AND tl.`id_lang` = '.(int)$id_lang.')
|
||||
WHERE t.`id_tab` = '.(int)$id_tab
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,7 +40,7 @@ class TagCore extends ObjectModel
|
||||
'primary' => 'id_tag',
|
||||
'fields' => array(
|
||||
'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32),
|
||||
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -100,24 +100,22 @@ class TagCore extends ObjectModel
|
||||
$tag_list = array_filter(array_unique(array_map('trim', preg_split('#\\'.$separator.'#', $tag_list, null, PREG_SPLIT_NO_EMPTY))));
|
||||
|
||||
$list = array();
|
||||
if (is_array($tag_list))
|
||||
foreach ($tag_list as $tag)
|
||||
foreach ($tag_list as $tag)
|
||||
{
|
||||
if (!Validate::isGenericName($tag))
|
||||
return false;
|
||||
$tag_obj = new Tag(null, trim($tag), (int)$id_lang);
|
||||
|
||||
/* Tag does not exist in database */
|
||||
if (!Validate::isLoadedObject($tag_obj))
|
||||
{
|
||||
if (!Validate::isGenericName($tag))
|
||||
return false;
|
||||
$tag = trim(Tools::substr($tag, 0, self::$definition['fields']['name']['size']));
|
||||
$tag_obj = new Tag(null, $tag, (int)$id_lang);
|
||||
|
||||
/* Tag does not exist in database */
|
||||
if (!Validate::isLoadedObject($tag_obj))
|
||||
{
|
||||
$tag_obj->name = $tag;
|
||||
$tag_obj->id_lang = (int)$id_lang;
|
||||
$tag_obj->add();
|
||||
}
|
||||
if (!in_array($tag_obj->id, $list))
|
||||
$list[] = $tag_obj->id;
|
||||
$tag_obj->name = trim($tag);
|
||||
$tag_obj->id_lang = (int)$id_lang;
|
||||
$tag_obj->add();
|
||||
}
|
||||
if (!in_array($tag_obj->id, $list))
|
||||
$list[] = $tag_obj->id;
|
||||
}
|
||||
$data = '';
|
||||
foreach ($list as $tag)
|
||||
$data .= '('.(int)$tag.','.(int)$id_product.'),';
|
||||
|
||||
@@ -346,20 +346,27 @@ class ToolsCore
|
||||
/* Automatically detect language if not already defined, detect_language is set in Cookie::update */
|
||||
if ((!$cookie->id_lang || isset($cookie->detect_language)) && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
|
||||
{
|
||||
$array = explode(',', Tools::strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
|
||||
$string = $array[0];
|
||||
|
||||
if (Validate::isLanguageCode($string))
|
||||
$array = explode(',', Tools::strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
|
||||
if (Tools::strlen($array[0]) > 2)
|
||||
{
|
||||
$lang = Language::getLanguageByIETFCode($string);
|
||||
if (Validate::isLoadedObject($lang) && $lang->active && $lang->isAssociatedToShop())
|
||||
{
|
||||
Context::getContext()->language = $lang;
|
||||
$tab = explode('-', $array[0]);
|
||||
$string = $tab[0];
|
||||
}
|
||||
else
|
||||
$string = $array[0];
|
||||
if (Validate::isLanguageIsoCode($string))
|
||||
{
|
||||
$lang = new Language(Language::getIdByIso($string));
|
||||
if (Validate::isLoadedObject($lang) && $lang->active)
|
||||
{
|
||||
$language = new Language((int)$lang->id);
|
||||
if (Validate::isLoadedObject($language))
|
||||
Context::getContext()->language = $language;
|
||||
$cookie->id_lang = (int)$lang->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isset($cookie->detect_language))
|
||||
unset($cookie->detect_language);
|
||||
|
||||
@@ -369,7 +376,7 @@ class ToolsCore
|
||||
|
||||
$iso = Language::getIsoById((int)$cookie->id_lang);
|
||||
@include_once(_PS_THEME_DIR_.'lang/'.$iso.'.php');
|
||||
|
||||
|
||||
return $iso;
|
||||
}
|
||||
|
||||
@@ -487,20 +494,6 @@ class ToolsCore
|
||||
if (($is_negative = ($price < 0)))
|
||||
$price *= -1;
|
||||
$price = Tools::ps_round($price, $c_decimals);
|
||||
|
||||
/*
|
||||
* If the language is RTL and the selected currency format contains spaces as thousands separator
|
||||
* then the number will be printed in reverse since the space is interpreted as separating words.
|
||||
* To avoid this we replace the currency format containing a space with the one containing a comma (,) as thousand
|
||||
* separator when the language is RTL.
|
||||
*
|
||||
* TODO: This is not ideal, a currency format should probably be tied to a language, not to a currency.
|
||||
*/
|
||||
if(($c_format == 2) && ($context->language->is_rtl == 1))
|
||||
{
|
||||
$c_format = 4;
|
||||
}
|
||||
|
||||
switch ($c_format)
|
||||
{
|
||||
/* X 0,000.00 */
|
||||
@@ -519,9 +512,9 @@ class ToolsCore
|
||||
case 4:
|
||||
$ret = number_format($price, $c_decimals, '.', ',').$blank.$c_char;
|
||||
break;
|
||||
/* X 0'000.00 Added for the switzerland currency */
|
||||
/* 0 000.00 X Added for the switzerland currency */
|
||||
case 5:
|
||||
$ret = $c_char.$blank.number_format($price, $c_decimals, '.', "'");
|
||||
$ret = number_format($price, $c_decimals, '.', ' ').$blank.$c_char;
|
||||
break;
|
||||
}
|
||||
if ($is_negative)
|
||||
@@ -668,26 +661,21 @@ class ToolsCore
|
||||
{
|
||||
if (is_array($string))
|
||||
return array_map(array('Tools', 'htmlentitiesUTF8'), $string);
|
||||
|
||||
return htmlentities((string)$string, $type, 'utf-8');
|
||||
}
|
||||
|
||||
public static function htmlentitiesDecodeUTF8($string)
|
||||
{
|
||||
if (is_array($string))
|
||||
{
|
||||
$string = array_map(array('Tools', 'htmlentitiesDecodeUTF8'), $string);
|
||||
return (string)array_shift($string);
|
||||
}
|
||||
return array_map(array('Tools', 'htmlentitiesDecodeUTF8'), $string);
|
||||
return html_entity_decode((string)$string, ENT_QUOTES, 'utf-8');
|
||||
}
|
||||
|
||||
public static function safePostVars()
|
||||
{
|
||||
if (!isset($_POST) || !is_array($_POST))
|
||||
$_POST = array();
|
||||
else
|
||||
$_POST = array_map(array('Tools', 'htmlentitiesUTF8'), $_POST);
|
||||
if (!is_array($_POST))
|
||||
return array();
|
||||
$_POST = array_map(array('Tools', 'htmlentitiesUTF8'), $_POST);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -716,21 +704,6 @@ class ToolsCore
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete file
|
||||
*
|
||||
* @param string File path
|
||||
* @param array Excluded files
|
||||
*/
|
||||
public static function deleteFile($file, $exclude_files = array())
|
||||
{
|
||||
if (isset($exclude_files) && !is_array($exclude_files))
|
||||
$exclude_files = array($exclude_files);
|
||||
|
||||
if (file_exists($file) && is_file($file) && array_search(basename($file), $exclude_files) === FALSE)
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear smarty cache folders
|
||||
@@ -1104,94 +1077,63 @@ class ToolsCore
|
||||
/* One source among others:
|
||||
http://www.tachyonsoft.com/uc0000.htm
|
||||
http://www.tachyonsoft.com/uc0001.htm
|
||||
http://www.tachyonsoft.com/uc0004.htm
|
||||
*/
|
||||
$patterns = array(
|
||||
|
||||
/* Lowercase */
|
||||
/* a */ '/[\x{00E0}\x{00E1}\x{00E2}\x{00E3}\x{00E4}\x{00E5}\x{0101}\x{0103}\x{0105}\x{0430}]/u',
|
||||
/* b */ '/[\x{0431}]/u',
|
||||
/* c */ '/[\x{00E7}\x{0107}\x{0109}\x{010D}\x{0446}]/u',
|
||||
/* d */ '/[\x{010F}\x{0111}\x{0434}]/u',
|
||||
/* e */ '/[\x{00E8}\x{00E9}\x{00EA}\x{00EB}\x{0113}\x{0115}\x{0117}\x{0119}\x{011B}\x{0435}\x{044D}]/u',
|
||||
/* f */ '/[\x{0444}]/u',
|
||||
/* g */ '/[\x{011F}\x{0121}\x{0123}\x{0433}\x{0491}]/u',
|
||||
/* h */ '/[\x{0125}\x{0127}]/u',
|
||||
/* i */ '/[\x{00EC}\x{00ED}\x{00EE}\x{00EF}\x{0129}\x{012B}\x{012D}\x{012F}\x{0131}\x{0438}\x{0456}]/u',
|
||||
/* j */ '/[\x{0135}\x{0439}]/u',
|
||||
/* k */ '/[\x{0137}\x{0138}\x{043A}]/u',
|
||||
/* l */ '/[\x{013A}\x{013C}\x{013E}\x{0140}\x{0142}\x{043B}]/u',
|
||||
/* m */ '/[\x{043C}]/u',
|
||||
/* n */ '/[\x{00F1}\x{0144}\x{0146}\x{0148}\x{0149}\x{014B}\x{043D}]/u',
|
||||
/* o */ '/[\x{00F2}\x{00F3}\x{00F4}\x{00F5}\x{00F6}\x{00F8}\x{014D}\x{014F}\x{0151}\x{043E}]/u',
|
||||
/* p */ '/[\x{043F}]/u',
|
||||
/* r */ '/[\x{0155}\x{0157}\x{0159}\x{0440}]/u',
|
||||
/* s */ '/[\x{015B}\x{015D}\x{015F}\x{0161}\x{0441}]/u',
|
||||
/* ss */ '/[\x{00DF}]/u',
|
||||
/* t */ '/[\x{0163}\x{0165}\x{0167}\x{0442}]/u',
|
||||
/* u */ '/[\x{00F9}\x{00FA}\x{00FB}\x{00FC}\x{0169}\x{016B}\x{016D}\x{016F}\x{0171}\x{0173}\x{0443}]/u',
|
||||
/* v */ '/[\x{0432}]/u',
|
||||
/* w */ '/[\x{0175}]/u',
|
||||
/* y */ '/[\x{00FF}\x{0177}\x{00FD}\x{044B}]/u',
|
||||
/* z */ '/[\x{017A}\x{017C}\x{017E}\x{0437}]/u',
|
||||
/* ae */ '/[\x{00E6}]/u',
|
||||
/* ch */ '/[\x{0447}]/u',
|
||||
/* kh */ '/[\x{0445}]/u',
|
||||
/* oe */ '/[\x{0153}]/u',
|
||||
/* sh */ '/[\x{0448}]/u',
|
||||
/* shh*/ '/[\x{0449}]/u',
|
||||
/* ya */ '/[\x{044F}]/u',
|
||||
/* ye */ '/[\x{0454}]/u',
|
||||
/* yi */ '/[\x{0457}]/u',
|
||||
/* yo */ '/[\x{0451}]/u',
|
||||
/* yu */ '/[\x{044E}]/u',
|
||||
/* zh */ '/[\x{0436}]/u',
|
||||
/* a */ '/[\x{00E0}\x{00E1}\x{00E2}\x{00E3}\x{00E4}\x{00E5}\x{0101}\x{0103}\x{0105}]/u',
|
||||
/* c */ '/[\x{00E7}\x{0107}\x{0109}\x{010D}]/u',
|
||||
/* d */ '/[\x{010F}\x{0111}]/u',
|
||||
/* e */ '/[\x{00E8}\x{00E9}\x{00EA}\x{00EB}\x{0113}\x{0115}\x{0117}\x{0119}\x{011B}]/u',
|
||||
/* g */ '/[\x{011F}\x{0121}\x{0123}]/u',
|
||||
/* h */ '/[\x{0125}\x{0127}]/u',
|
||||
/* i */ '/[\x{00EC}\x{00ED}\x{00EE}\x{00EF}\x{0129}\x{012B}\x{012D}\x{012F}\x{0131}]/u',
|
||||
/* j */ '/[\x{0135}]/u',
|
||||
/* k */ '/[\x{0137}\x{0138}]/u',
|
||||
/* l */ '/[\x{013A}\x{013C}\x{013E}\x{0140}\x{0142}]/u',
|
||||
/* n */ '/[\x{00F1}\x{0144}\x{0146}\x{0148}\x{0149}\x{014B}]/u',
|
||||
/* o */ '/[\x{00F2}\x{00F3}\x{00F4}\x{00F5}\x{00F6}\x{00F8}\x{014D}\x{014F}\x{0151}]/u',
|
||||
/* r */ '/[\x{0155}\x{0157}\x{0159}]/u',
|
||||
/* s */ '/[\x{015B}\x{015D}\x{015F}\x{0161}]/u',
|
||||
/* ss*/ '/[\x{00DF}]/u',
|
||||
/* t */ '/[\x{0163}\x{0165}\x{0167}]/u',
|
||||
/* u */ '/[\x{00F9}\x{00FA}\x{00FB}\x{00FC}\x{0169}\x{016B}\x{016D}\x{016F}\x{0171}\x{0173}]/u',
|
||||
/* w */ '/[\x{0175}]/u',
|
||||
/* y */ '/[\x{00FF}\x{0177}\x{00FD}]/u',
|
||||
/* z */ '/[\x{017A}\x{017C}\x{017E}]/u',
|
||||
/* ae*/ '/[\x{00E6}]/u',
|
||||
/* oe*/ '/[\x{0153}]/u',
|
||||
|
||||
/* Uppercase */
|
||||
/* A */ '/[\x{0100}\x{0102}\x{0104}\x{00C0}\x{00C1}\x{00C2}\x{00C3}\x{00C4}\x{00C5}\x{0410}]/u',
|
||||
/* B */ '/[\x{0411}]]/u',
|
||||
/* C */ '/[\x{00C7}\x{0106}\x{0108}\x{010A}\x{010C}\x{0426}]/u',
|
||||
/* D */ '/[\x{010E}\x{0110}\x{0414}]/u',
|
||||
/* E */ '/[\x{00C8}\x{00C9}\x{00CA}\x{00CB}\x{0112}\x{0114}\x{0116}\x{0118}\x{011A}\x{0415}\x{042D}]/u',
|
||||
/* F */ '/[\x{0424}]/u',
|
||||
/* G */ '/[\x{011C}\x{011E}\x{0120}\x{0122}\x{0413}\x{0490}]/u',
|
||||
/* H */ '/[\x{0124}\x{0126}]/u',
|
||||
/* I */ '/[\x{0128}\x{012A}\x{012C}\x{012E}\x{0130}\x{0418}\x{0406}]/u',
|
||||
/* J */ '/[\x{0134}\x{0419}]/u',
|
||||
/* K */ '/[\x{0136}\x{041A}]/u',
|
||||
/* L */ '/[\x{0139}\x{013B}\x{013D}\x{0139}\x{0141}\x{041B}]/u',
|
||||
/* M */ '/[\x{041C}]/u',
|
||||
/* N */ '/[\x{00D1}\x{0143}\x{0145}\x{0147}\x{014A}\x{041D}]/u',
|
||||
/* O */ '/[\x{00D3}\x{014C}\x{014E}\x{0150}\x{041E}]/u',
|
||||
/* P */ '/[\x{041F}]/u',
|
||||
/* R */ '/[\x{0154}\x{0156}\x{0158}\x{0420}]/u',
|
||||
/* S */ '/[\x{015A}\x{015C}\x{015E}\x{0160}\x{0421}]/u',
|
||||
/* T */ '/[\x{0162}\x{0164}\x{0166}\x{0422}]/u',
|
||||
/* U */ '/[\x{00D9}\x{00DA}\x{00DB}\x{00DC}\x{0168}\x{016A}\x{016C}\x{016E}\x{0170}\x{0172}\x{0423}]/u',
|
||||
/* V */ '/[\x{0412}]/u',
|
||||
/* W */ '/[\x{0174}]/u',
|
||||
/* Y */ '/[\x{0176}\x{042B}]/u',
|
||||
/* Z */ '/[\x{0179}\x{017B}\x{017D}\x{0417}]/u',
|
||||
/* AE */ '/[\x{00C6}]/u',
|
||||
/* CH */ '/[\x{0427}]/u',
|
||||
/* KH */ '/[\x{0425}]/u',
|
||||
/* OE */ '/[\x{0152}]/u',
|
||||
/* SH */ '/[\x{0428}]/u',
|
||||
/* SHH*/ '/[\x{0429}]/u',
|
||||
/* YA */ '/[\x{042F}]/u',
|
||||
/* YE */ '/[\x{0404}]/u',
|
||||
/* YI */ '/[\x{0407}]/u',
|
||||
/* YO */ '/[\x{0401}]/u',
|
||||
/* YU */ '/[\x{042E}]/u',
|
||||
/* ZH */ '/[\x{0416}]/u');
|
||||
/* A */ '/[\x{0100}\x{0102}\x{0104}\x{00C0}\x{00C1}\x{00C2}\x{00C3}\x{00C4}\x{00C5}]/u',
|
||||
/* C */ '/[\x{00C7}\x{0106}\x{0108}\x{010A}\x{010C}]/u',
|
||||
/* D */ '/[\x{010E}\x{0110}]/u',
|
||||
/* E */ '/[\x{00C8}\x{00C9}\x{00CA}\x{00CB}\x{0112}\x{0114}\x{0116}\x{0118}\x{011A}]/u',
|
||||
/* G */ '/[\x{011C}\x{011E}\x{0120}\x{0122}]/u',
|
||||
/* H */ '/[\x{0124}\x{0126}]/u',
|
||||
/* I */ '/[\x{0128}\x{012A}\x{012C}\x{012E}\x{0130}]/u',
|
||||
/* J */ '/[\x{0134}]/u',
|
||||
/* K */ '/[\x{0136}]/u',
|
||||
/* L */ '/[\x{0139}\x{013B}\x{013D}\x{0139}\x{0141}]/u',
|
||||
/* N */ '/[\x{00D1}\x{0143}\x{0145}\x{0147}\x{014A}]/u',
|
||||
/* O */ '/[\x{00D3}\x{014C}\x{014E}\x{0150}]/u',
|
||||
/* R */ '/[\x{0154}\x{0156}\x{0158}]/u',
|
||||
/* S */ '/[\x{015A}\x{015C}\x{015E}\x{0160}]/u',
|
||||
/* T */ '/[\x{0162}\x{0164}\x{0166}]/u',
|
||||
/* U */ '/[\x{00D9}\x{00DA}\x{00DB}\x{00DC}\x{0168}\x{016A}\x{016C}\x{016E}\x{0170}\x{0172}]/u',
|
||||
/* W */ '/[\x{0174}]/u',
|
||||
/* Y */ '/[\x{0176}]/u',
|
||||
/* Z */ '/[\x{0179}\x{017B}\x{017D}]/u',
|
||||
/* AE*/ '/[\x{00C6}]/u',
|
||||
/* OE*/ '/[\x{0152}]/u');
|
||||
|
||||
// ö to oe
|
||||
// å to aa
|
||||
// ä to ae
|
||||
|
||||
$replacements = array(
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 'ss', 't', 'u', 'v', 'w', 'y', 'z', 'ae', 'ch', 'kh', 'oe', 'sh', 'shh', 'ya', 'ye', 'yi', 'yo', 'yu', 'zh',
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'V', 'W', 'Y', 'Z', 'AE', 'CH', 'KH', 'OE', 'SH', 'SHH', 'YA', 'YE', 'YI', 'YO', 'YU', 'ZH'
|
||||
'a', 'c', 'd', 'e', 'g', 'h', 'i', 'j', 'k', 'l', 'n', 'o', 'r', 's', 'ss', 't', 'u', 'y', 'w', 'z', 'ae', 'oe',
|
||||
'A', 'C', 'D', 'E', 'G', 'H', 'I', 'J', 'K', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'Z', 'AE', 'OE'
|
||||
);
|
||||
|
||||
return preg_replace($patterns, $replacements, $str);
|
||||
@@ -1215,129 +1157,6 @@ class ToolsCore
|
||||
return (utf8_encode(substr($str, 0, $max_length - Tools::strlen($suffix)).$suffix));
|
||||
}
|
||||
|
||||
/*Copied from CakePHP String utility file*/
|
||||
public static function truncateString($text, $length = 120, $options = array())
|
||||
{
|
||||
$default = array(
|
||||
'ellipsis' => '...', 'exact' => true, 'html' => true
|
||||
);
|
||||
|
||||
$options = array_merge($default, $options);
|
||||
extract($options);
|
||||
|
||||
if ($html)
|
||||
{
|
||||
if (Tools::strlen(preg_replace('/<.*?>/', '', $text)) <= $length)
|
||||
return $text;
|
||||
|
||||
$totalLength = Tools::strlen(strip_tags($ellipsis));
|
||||
$openTags = array();
|
||||
$truncate = '';
|
||||
preg_match_all('/(<\/?([\w+]+)[^>]*>)?([^<>]*)/', $text, $tags, PREG_SET_ORDER);
|
||||
|
||||
foreach ($tags as $tag)
|
||||
{
|
||||
if (!preg_match('/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/s', $tag[2]))
|
||||
{
|
||||
if (preg_match('/<[\w]+[^>]*>/s', $tag[0]))
|
||||
array_unshift($openTags, $tag[2]);
|
||||
elseif (preg_match('/<\/([\w]+)[^>]*>/s', $tag[0], $closeTag))
|
||||
{
|
||||
$pos = array_search($closeTag[1], $openTags);
|
||||
if ($pos !== false)
|
||||
array_splice($openTags, $pos, 1);
|
||||
}
|
||||
}
|
||||
$truncate .= $tag[1];
|
||||
$contentLength = Tools::strlen(preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i', ' ', $tag[3]));
|
||||
|
||||
if ($contentLength + $totalLength > $length)
|
||||
{
|
||||
$left = $length - $totalLength;
|
||||
$entitiesLength = 0;
|
||||
|
||||
if (preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i', $tag[3], $entities, PREG_OFFSET_CAPTURE))
|
||||
{
|
||||
foreach ($entities[0] as $entity)
|
||||
{
|
||||
if ($entity[1] + 1 - $entitiesLength <= $left)
|
||||
{
|
||||
$left--;
|
||||
$entitiesLength += Tools::strlen($entity[0]);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$truncate .= Tools::substr($tag[3], 0, $left + $entitiesLength);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
$truncate .= $tag[3];
|
||||
$totalLength += $contentLength;
|
||||
}
|
||||
|
||||
if ($totalLength >= $length)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Tools::strlen($text) <= $length)
|
||||
return $text;
|
||||
|
||||
$truncate = Tools::substr($text, 0, $length - Tools::strlen($ellipsis));
|
||||
}
|
||||
|
||||
if (!$exact)
|
||||
{
|
||||
$spacepos = mb_strrpos($truncate, ' ');
|
||||
if ($html)
|
||||
{
|
||||
$truncateCheck = Tools::substr($truncate, 0, $spacepos);
|
||||
$lastOpenTag = Tools::strrpos($truncateCheck, '<');
|
||||
$lastCloseTag = Tools::strrpos($truncateCheck, '>');
|
||||
|
||||
if ($lastOpenTag > $lastCloseTag)
|
||||
{
|
||||
preg_match_all('/<[\w]+[^>]*>/s', $truncate, $lastTagMatches);
|
||||
$lastTag = array_pop($lastTagMatches[0]);
|
||||
$spacepos = Tools::strrpos($truncate, $lastTag) + Tools::strlen($lastTag);
|
||||
}
|
||||
|
||||
$bits = Tools::substr($truncate, $spacepos);
|
||||
preg_match_all('/<\/([a-z]+)>/', $bits, $droppedTags, PREG_SET_ORDER);
|
||||
|
||||
if (!empty($droppedTags))
|
||||
{
|
||||
if (!empty($openTags))
|
||||
{
|
||||
foreach ($droppedTags as $closingTag)
|
||||
if (!in_array($closingTag[1], $openTags))
|
||||
array_unshift($openTags, $closingTag[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($droppedTags as $closingTag)
|
||||
$openTags[] = $closingTag[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$truncate = Tools::substr($truncate, 0, $spacepos);
|
||||
}
|
||||
|
||||
$truncate .= $ellipsis;
|
||||
|
||||
if ($html)
|
||||
foreach ($openTags as $tag)
|
||||
$truncate .= '</' . $tag . '>';
|
||||
|
||||
return $truncate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate date form
|
||||
*
|
||||
@@ -1436,13 +1255,6 @@ class ToolsCore
|
||||
return substr($str, $start, ($length === false ? Tools::strlen($str) : (int)$length));
|
||||
}
|
||||
|
||||
public static function strrpos($str, $find, $offset = 0, $encoding = 'utf-8')
|
||||
{
|
||||
if (function_exists('mb_strrpos'))
|
||||
return mb_strrpos($str, $find, $offset, $encoding);
|
||||
return strrpos($str, $find, $offset);
|
||||
}
|
||||
|
||||
public static function ucfirst($str)
|
||||
{
|
||||
return Tools::strtoupper(Tools::substr($str, 0, 1)).Tools::substr($str, 1);
|
||||
@@ -1850,15 +1662,13 @@ class ToolsCore
|
||||
fwrite($write_fd, "# http://www.prestashop.com - http://www.prestashop.com/forums\n\n");
|
||||
|
||||
if ($disable_modsec)
|
||||
fwrite($write_fd, "<IfModule mod_security.c>\nSecFilterEngine Off\nSecFilterScanPOST Off\n</IfModule>\n\n");
|
||||
fwrite($write_fd, "<IfModule mod_security.c>\nSecFilterEngine Off\nSecFilterScanPOST Off\n</IfModule>\n");
|
||||
|
||||
// RewriteEngine
|
||||
fwrite($write_fd, "<IfModule mod_rewrite.c>\n");
|
||||
|
||||
// Ensure HTTP_MOD_REWRITE variable is set in environment
|
||||
fwrite($write_fd, "<IfModule mod_env.c>\n");
|
||||
fwrite($write_fd, "SetEnv HTTP_MOD_REWRITE On\n");
|
||||
fwrite($write_fd, "</IfModule>\n\n");
|
||||
|
||||
// Disable multiviews ?
|
||||
if ($disable_multiviews)
|
||||
|
||||
@@ -44,7 +44,7 @@ class ValidateCore
|
||||
*/
|
||||
public static function isEmail($email)
|
||||
{
|
||||
return !empty($email) && preg_match(Tools::cleanNonUnicodeSupport('/^[a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]+[.a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]*@[a-z\p{L}0-9]+[._a-z\p{L}0-9-]*\.[a-z\p{L}0-9]+$/ui'), $email);
|
||||
return !empty($email) && preg_match(Tools::cleanNonUnicodeSupport('/^[a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]+[.a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]*@[a-z\p{L}0-9]+[._a-z\p{L}0-9-]*\.[a-z0-9]+$/ui'), $email);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1067,4 +1067,4 @@ class ValidateCore
|
||||
{
|
||||
return (preg_match('/^[0-1]\.[0-9]{1,2}(\.[0-9]{1,2}){0,2}$/', $version) && ip2long($version));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,18 +54,12 @@ class ZoneCore extends ObjectModel
|
||||
*/
|
||||
public static function getZones($active = false)
|
||||
{
|
||||
$cache_id = 'Zone::getZones_'.(bool)$active;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'zone`
|
||||
'.($active ? 'WHERE active = 1' : '').'
|
||||
ORDER BY `name` ASC
|
||||
');
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'zone`
|
||||
'.($active ? 'WHERE active = 1' : '').'
|
||||
ORDER BY `name` ASC
|
||||
');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
2
classes/cache/CacheMemcache.php
vendored
2
classes/cache/CacheMemcache.php
vendored
@@ -153,8 +153,6 @@ class CacheMemcacheCore extends Cache
|
||||
*/
|
||||
protected function _writeKeys()
|
||||
{
|
||||
if (!$this->is_connected)
|
||||
return false;
|
||||
$this->memcache->set(_COOKIE_IV_, $this->keys);
|
||||
}
|
||||
|
||||
|
||||
@@ -654,10 +654,73 @@ class AdminControllerCore extends Controller
|
||||
'export_content' => $content
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$this->layout = 'layout-export.tpl';
|
||||
}
|
||||
|
||||
public function processExportExcel()
|
||||
{
|
||||
// clean buffer
|
||||
if (ob_get_level() && ob_get_length() > 0)
|
||||
ob_clean();
|
||||
$this->getList($this->context->language->id);
|
||||
if (!count($this->_list))
|
||||
return;
|
||||
|
||||
if (!extension_loaded('zip')) {
|
||||
$this->displayWarning($this->l('Module php_zip must be enabled in order to use Excel export feature.'));
|
||||
return;
|
||||
}
|
||||
|
||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8');
|
||||
header('Cache-Control: no-store, no-cache');
|
||||
header('Content-disposition: attachment; filename="'.$this->table.'_'.date('Y-m-d_His').'.xlsx"');
|
||||
|
||||
$headers = array();
|
||||
foreach ($this->fields_list as $datas)
|
||||
$headers[] = Tools::htmlentitiesDecodeUTF8($datas['title']);
|
||||
$content = array();
|
||||
foreach ($this->_list as $i => $row)
|
||||
{
|
||||
$content[$i] = array();
|
||||
$path_to_image = false;
|
||||
foreach ($this->fields_list as $key => $params)
|
||||
{
|
||||
$field_value = isset($row[$key]) ? Tools::htmlentitiesDecodeUTF8($row[$key]) : '';
|
||||
if ($key == 'image')
|
||||
{
|
||||
if ($params['image'] != 'p' || Configuration::get('PS_LEGACY_IMAGES'))
|
||||
$path_to_image = Tools::getShopDomain(true)._PS_IMG_.$params['image'].'/'.$row['id_'.$this->table].(isset($row['id_image']) ? '-'.(int)$row['id_image'] : '').'.'.$this->imageType;
|
||||
else
|
||||
$path_to_image = Tools::getShopDomain(true)._PS_IMG_.$params['image'].'/'.Image::getImgFolderStatic($row['id_image']).(int)$row['id_image'].'.'.$this->imageType;
|
||||
if ($path_to_image)
|
||||
$field_value = $path_to_image;
|
||||
}
|
||||
$content[$i][] = $field_value;
|
||||
}
|
||||
}
|
||||
|
||||
require_once(_PS_ROOT_DIR_.'/tools/phpexcel/PHPExcel.php');
|
||||
/** Create a new PHPExcel Object **/
|
||||
$objPHPExcel = new PHPExcel();
|
||||
$worksheet = $objPHPExcel->getSheet(0);
|
||||
|
||||
$worksheet->fromArray(
|
||||
$headers, // The data to set
|
||||
NULL, // Array values with this value will not be set
|
||||
'A1' // Top left coordinate of the worksheet range where
|
||||
// we want to set these values (default is A1)
|
||||
);
|
||||
$worksheet->fromArray(
|
||||
$content,
|
||||
NULL,
|
||||
'A2'
|
||||
);
|
||||
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
|
||||
$objWriter->save('php://output');
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Object Delete
|
||||
*/
|
||||
@@ -693,7 +756,7 @@ class AdminControllerCore extends Controller
|
||||
$this->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token;
|
||||
$this->errors[] = Tools::displayError('An error occurred during deletion.');
|
||||
if ($res)
|
||||
Logger::addLog(sprintf($this->l('%s deletion', 'AdminTab', false, false), $this->className), 1, null, $this->className, (int)$this->object->id, true, (int)$this->context->employee->id);
|
||||
Logger::addLog(sprintf($this->l('%s deletion'), $this->className), 1, null, $this->className, (int)$this->object->id, true, (int)$this->context->employee->id);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -744,7 +807,7 @@ class AdminControllerCore extends Controller
|
||||
/* voluntary do affectation here */
|
||||
elseif (($_POST[$this->identifier] = $this->object->id) && $this->postImage($this->object->id) && !count($this->errors) && $this->_redirect)
|
||||
{
|
||||
Logger::addLog(sprintf($this->l('%s addition', 'AdminTab', false, false), $this->className), 1, null, $this->className, (int)$this->object->id, true, (int)$this->context->employee->id);
|
||||
Logger::addLog(sprintf($this->l('%s addition'), $this->className), 1, null, $this->className, (int)$this->object->id, true, (int)$this->context->employee->id);
|
||||
$parent_id = (int)Tools::getValue('id_parent', 1);
|
||||
$this->afterAdd($this->object);
|
||||
$this->updateAssoShop($this->object->id);
|
||||
@@ -841,10 +904,10 @@ class AdminControllerCore extends Controller
|
||||
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.$parent_id.'&conf=4&token='.$this->token;
|
||||
|
||||
// Default behavior (save and back)
|
||||
if (empty($this->redirect_after) && $this->redirect_after !== false)
|
||||
if (empty($this->redirect_after))
|
||||
$this->redirect_after = self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=4&token='.$this->token;
|
||||
}
|
||||
Logger::addLog(sprintf($this->l('%s edition', 'AdminTab', false, false), $this->className), 1, null, $this->className, (int)$object->id, true, (int)$this->context->employee->id);
|
||||
Logger::addLog(sprintf($this->l('%s edition'), $this->className), 1, null, $this->className, (int)$object->id, true, (int)$this->context->employee->id);
|
||||
}
|
||||
else
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating an object.').
|
||||
@@ -1126,11 +1189,16 @@ class AdminControllerCore extends Controller
|
||||
'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token,
|
||||
'desc' => $this->l('Add new')
|
||||
);
|
||||
if ($this->allow_export)
|
||||
if ($this->allow_export) {
|
||||
$this->toolbar_btn['export'] = array(
|
||||
'href' => self::$currentIndex.'&export'.$this->table.'&token='.$this->token,
|
||||
'desc' => $this->l('Export')
|
||||
);
|
||||
$this->toolbar_btn['export-excel'] = array(
|
||||
'href' => self::$currentIndex.'&export-excel'.$this->table.'&token='.$this->token,
|
||||
'desc' => $this->l('Export (Excel)')
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->addToolBarModulesListButton();
|
||||
}
|
||||
@@ -1542,14 +1610,12 @@ class AdminControllerCore extends Controller
|
||||
if (!$this->isFresh(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 86400))
|
||||
file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, Tools::addonsRequest('native'));
|
||||
|
||||
libxml_use_internal_errors(true);
|
||||
$country_module_list = file_get_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST);
|
||||
if (!empty($country_module_list) && is_string($country_module_list) && $country_module_list_xml = simplexml_load_string($country_module_list))
|
||||
if (!empty($country_module_list) && $country_module_list_xml = simplexml_load_string($country_module_list))
|
||||
{
|
||||
$country_module_list_array = array();
|
||||
if (is_array($country_module_list_xml->module))
|
||||
foreach ($country_module_list_xml->module as $k => $m)
|
||||
$country_module_list_array[] = (string)$m->name;
|
||||
foreach ($country_module_list_xml->module as $k => $m)
|
||||
$country_module_list_array[] = (string)$m->name;
|
||||
$this->tab_modules_list['slider_list'] = array_intersect($this->tab_modules_list['slider_list'], $country_module_list_array);
|
||||
}
|
||||
|
||||
@@ -1942,10 +2008,7 @@ class AdminControllerCore extends Controller
|
||||
$this->context->shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
|
||||
elseif ($this->context->shop->id != $shop_id)
|
||||
$this->context->shop = new Shop($shop_id);
|
||||
|
||||
// Replace current default country
|
||||
$this->context->country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
|
||||
|
||||
$this->initBreadcrumbs();
|
||||
}
|
||||
|
||||
@@ -2062,6 +2125,11 @@ class AdminControllerCore extends Controller
|
||||
if ($this->tabAccess['view'] === '1')
|
||||
$this->action = 'export';
|
||||
}
|
||||
elseif (isset($_GET['export-excel'.$this->table]))
|
||||
{
|
||||
if ($this->tabAccess['view'] === '1')
|
||||
$this->action = 'exportExcel';
|
||||
}
|
||||
/* Cancel all filters for this tab */
|
||||
elseif (isset($_POST['submitReset'.$this->list_id]))
|
||||
$this->action = 'reset_filters';
|
||||
@@ -2117,7 +2185,6 @@ class AdminControllerCore extends Controller
|
||||
*/
|
||||
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
|
||||
{
|
||||
|
||||
if (!isset($this->list_id))
|
||||
$this->list_id = $this->table;
|
||||
|
||||
@@ -2172,20 +2239,12 @@ class AdminControllerCore extends Controller
|
||||
$order_by = $this->fields_list[$order_by]['order_key'];
|
||||
|
||||
/* Determine offset from current page */
|
||||
|
||||
|
||||
if ((isset($_POST['submitFilter'.$this->list_id]) ||
|
||||
isset($_POST['submitFilter'.$this->list_id.'_x']) ||
|
||||
isset($_POST['submitFilter'.$this->list_id.'_y'])) &&
|
||||
!empty($_POST['submitFilter'.$this->list_id]) &&
|
||||
is_numeric($_POST['submitFilter'.$this->list_id]))
|
||||
$start = ((int)$_POST['submitFilter'.$this->list_id] - 1) * $limit;
|
||||
elseif (empty($start) && isset($this->context->cookie->{$this->list_id.'_start'}) && Tools::isSubmit('export'.$this->table))
|
||||
$start = $this->context->cookie->{$this->list_id.'_start'};
|
||||
else
|
||||
$start = 0;
|
||||
|
||||
$this->context->cookie->{$this->list_id.'_start'} = $start;
|
||||
|
||||
/* Cache */
|
||||
$this->_lang = (int)$id_lang;
|
||||
@@ -2194,10 +2253,8 @@ class AdminControllerCore extends Controller
|
||||
if (preg_match('/[.!]/', $order_by))
|
||||
{
|
||||
$order_by_split = preg_split('/[.!]/', $order_by);
|
||||
$order_by = bqSQL($order_by_split[0]).'.`'.bqSQL($order_by_split[1]).'`';
|
||||
$order_by = pSQL($order_by_split[0]).'.`'.pSQL($order_by_split[1]).'`';
|
||||
}
|
||||
elseif ($order_by)
|
||||
$order_by = '`'.bqSQL($order_by).'`';
|
||||
|
||||
$this->_orderWay = Tools::strtoupper($order_way);
|
||||
|
||||
@@ -2257,6 +2314,8 @@ class AdminControllerCore extends Controller
|
||||
$having_clause .= $this->_having.' ';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->_listsql = '
|
||||
SELECT SQL_CALC_FOUND_ROWS
|
||||
'.($this->_tmpTableFilter ? ' * FROM (SELECT ' : '');
|
||||
@@ -2291,7 +2350,7 @@ class AdminControllerCore extends Controller
|
||||
(isset($this->_filter) ? $this->_filter : '').$where_shop.'
|
||||
'.(isset($this->_group) ? $this->_group.' ' : '').'
|
||||
'.$having_clause.'
|
||||
ORDER BY '.((str_replace('`', '', $order_by) == $this->identifier) ? 'a.' : '').$order_by.' '.pSQL($order_way).
|
||||
ORDER BY '.(($order_by == $this->identifier) ? 'a.' : '').pSQL($order_by).' '.pSQL($order_way).
|
||||
($this->_tmpTableFilter ? ') tmpTable WHERE 1'.$this->_tmpTableFilter : '').
|
||||
(($use_limit === true) ? ' LIMIT '.(int)$start.','.(int)$limit : '');
|
||||
|
||||
@@ -2343,20 +2402,22 @@ class AdminControllerCore extends Controller
|
||||
public function getLanguages()
|
||||
{
|
||||
$cookie = $this->context->cookie;
|
||||
$this->allow_employee_form_lang = (int)Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG');
|
||||
$this->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
|
||||
if ($this->allow_employee_form_lang && !$cookie->employee_form_lang)
|
||||
$cookie->employee_form_lang = (int)Configuration::get('PS_LANG_DEFAULT');
|
||||
|
||||
$lang_exists = false;
|
||||
$use_lang_from_cookie = false;
|
||||
$this->_languages = Language::getLanguages(false);
|
||||
foreach ($this->_languages as $lang)
|
||||
if (isset($cookie->employee_form_lang) && $cookie->employee_form_lang == $lang['id_lang'])
|
||||
$lang_exists = true;
|
||||
|
||||
$this->default_form_language = $lang_exists ? (int)$cookie->employee_form_lang : (int)Configuration::get('PS_LANG_DEFAULT');
|
||||
if ($this->allow_employee_form_lang)
|
||||
foreach ($this->_languages as $lang)
|
||||
if ($cookie->employee_form_lang == $lang['id_lang'])
|
||||
$use_lang_from_cookie = true;
|
||||
if (!$use_lang_from_cookie)
|
||||
$this->default_form_language = (int)Configuration::get('PS_LANG_DEFAULT');
|
||||
else
|
||||
$this->default_form_language = (int)$cookie->employee_form_lang;
|
||||
|
||||
foreach ($this->_languages as $k => $language)
|
||||
$this->_languages[$k]['is_default'] = ((int)($language['id_lang'] == $this->default_form_language));
|
||||
$this->_languages[$k]['is_default'] = (int)($language['id_lang'] == $this->default_form_language);
|
||||
|
||||
return $this->_languages;
|
||||
}
|
||||
@@ -2438,65 +2499,102 @@ class AdminControllerCore extends Controller
|
||||
if (!$class_name)
|
||||
$class_name = $this->className;
|
||||
|
||||
$object = new $class_name();
|
||||
/* Class specific validation rules */
|
||||
if (!empty($class_name))
|
||||
$rules = call_user_func(array($class_name, 'getValidationRules'), $class_name);
|
||||
|
||||
if (method_exists($this, 'getValidationRules'))
|
||||
$definition = $this->getValidationRules();
|
||||
else
|
||||
$definition = ObjectModel::getDefinition($class_name);
|
||||
|
||||
$default_language = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
|
||||
|
||||
foreach ($definition['fields'] as $field => $def)
|
||||
if (isset($rules) && count($rules) && (count($rules['requiredLang']) || count($rules['sizeLang']) || count($rules['validateLang'])))
|
||||
{
|
||||
$skip = array();
|
||||
if (in_array($field, array('passwd', 'no-picture')))
|
||||
$skip = array('required');
|
||||
/* Language() instance determined by default language */
|
||||
$default_language = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
|
||||
|
||||
if (isset($def['lang']) && $def['lang'] && isset($def['required']) && $def['required'])
|
||||
{
|
||||
$value = Tools::getValue($field.'_'.$default_language->id);
|
||||
if (Tools::isEmpty($value))
|
||||
$this->errors[$field.'_'.$default_language->id] = sprintf(
|
||||
Tools::displayError('The field %1$s is required at least in %2$s.'),
|
||||
$object->displayFieldName($field, $class_name),
|
||||
$default_language->name
|
||||
);
|
||||
|
||||
foreach (Language::getLanguages(false) as $language)
|
||||
{
|
||||
$value = Tools::getValue($field.'_'.$language['id_lang']);
|
||||
if (!empty($value))
|
||||
if (($error = $object->validateField($field, $value, $language['id_lang'], $skip, true)) !== true)
|
||||
$this->errors[$field.'_'.$language['id_lang']] = $error;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (($error = $object->validateField($field, Tools::getValue($field), null, $skip, true)) !== true)
|
||||
$this->errors[$field] = $error;
|
||||
/* All availables languages */
|
||||
$languages = Language::getLanguages(false);
|
||||
}
|
||||
|
||||
/* Checking for required fields */
|
||||
if (isset($rules['required']) && is_array($rules['required']))
|
||||
foreach ($rules['required'] as $field)
|
||||
if (($value = Tools::getValue($field)) == false && (string)$value != '0')
|
||||
if (!Tools::getValue($this->identifier) || ($field != 'passwd' && $field != 'no-picture'))
|
||||
$this->errors[$field] = sprintf(
|
||||
Tools::displayError('The %s field is required.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name)
|
||||
);
|
||||
|
||||
/* Checking for multilingual required fields */
|
||||
if (isset($rules['requiredLang']) && is_array($rules['requiredLang']))
|
||||
foreach ($rules['requiredLang'] as $field_lang)
|
||||
if (($empty = Tools::getValue($field_lang.'_'.$default_language->id)) === false || $empty !== '0' && empty($empty))
|
||||
$this->errors[$field_lang.'_'.$default_language->id] = sprintf(
|
||||
Tools::displayError('The field %1$s is required at least in %2$s.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||
$default_language->name
|
||||
);
|
||||
|
||||
/* Checking for maximum fields sizes */
|
||||
if (isset($rules['size']) && is_array($rules['size']))
|
||||
foreach ($rules['size'] as $field => $max_length)
|
||||
if (Tools::getValue($field) !== false && Tools::strlen(Tools::getValue($field)) > $max_length)
|
||||
$this->errors[$field] = sprintf(
|
||||
Tools::displayError('The %1$s field is too long (%2$d chars max).'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name),
|
||||
$max_length
|
||||
);
|
||||
|
||||
/* Checking for maximum multilingual fields size */
|
||||
if (isset($rules['sizeLang']) && is_array($rules['sizeLang']))
|
||||
foreach ($rules['sizeLang'] as $field_lang => $max_length)
|
||||
foreach ($languages as $language)
|
||||
{
|
||||
$field_lang_value = Tools::getValue($field_lang.'_'.$language['id_lang']);
|
||||
if ($field_lang_value !== false && Tools::strlen($field_lang_value) > $max_length)
|
||||
$this->errors[$field_lang.'_'.$language['id_lang']] = sprintf(
|
||||
Tools::displayError('The field %1$s (%2$s) is too long (%3$d chars max, html chars including).'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||
$language['name'],
|
||||
$max_length
|
||||
);
|
||||
}
|
||||
/* Overload this method for custom checking */
|
||||
$this->_childValidation();
|
||||
|
||||
/* Checking for fields validity */
|
||||
if (isset($rules['validate']) && is_array($rules['validate']))
|
||||
foreach ($rules['validate'] as $field => $function)
|
||||
if (($value = Tools::getValue($field)) !== false && ($field != 'passwd'))
|
||||
if (!Validate::$function($value) && !empty($value))
|
||||
$this->errors[$field] = sprintf(
|
||||
Tools::displayError('The %s field is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name)
|
||||
);
|
||||
|
||||
/* Checking for passwd_old validity */
|
||||
if (($value = Tools::getValue('passwd')) != false)
|
||||
{
|
||||
if ($class_name == 'Employee' && !Validate::isPasswdAdmin($value))
|
||||
$this->errors['passwd'] = sprintf(
|
||||
Tools::displayError('The %s field is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), 'passwd', $class_name)
|
||||
);
|
||||
elseif ($class_name == 'Customer' && !Validate::isPasswd($value))
|
||||
$this->errors['passwd'] = sprintf(
|
||||
Tools::displayError('The %s field is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), 'passwd', $class_name)
|
||||
);
|
||||
}
|
||||
|
||||
/* Checking for multilingual fields validity */
|
||||
if (isset($rules['validateLang']) && is_array($rules['validateLang']))
|
||||
if (isset($rules['validateLang']) && is_array($rules['validateLang']))
|
||||
foreach ($rules['validateLang'] as $field_lang => $function)
|
||||
foreach ($languages as $language)
|
||||
if (($value = Tools::getValue($field_lang.'_'.$language['id_lang'])) !== false && !empty($value))
|
||||
{
|
||||
if (Tools::strtolower($function) == 'iscleanhtml' && Configuration::get('PS_ALLOW_HTML_IFRAME'))
|
||||
$res = Validate::$function($value, true);
|
||||
else
|
||||
$res = Validate::$function($value);
|
||||
if (!$res)
|
||||
if (!Validate::$function($value))
|
||||
$this->errors[$field_lang.'_'.$language['id_lang']] = sprintf(
|
||||
Tools::displayError('The %1$s field (%2$s) is invalid.'),
|
||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||
$language['name']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2773,7 +2871,7 @@ class AdminControllerCore extends Controller
|
||||
}
|
||||
|
||||
if ($delete_ok)
|
||||
Logger::addLog(sprintf($this->l('%s deletion', 'AdminTab', false, false), $this->className), 1, null, $this->className, (int)$to_delete->id, true, (int)$this->context->employee->id);
|
||||
Logger::addLog(sprintf($this->l('%s deletion'), $this->className), 1, null, $this->className, (int)$to_delete->id, true, (int)$this->context->employee->id);
|
||||
else
|
||||
$this->errors[] = sprintf(Tools::displayError('Can\'t delete #%d'), $id);
|
||||
}
|
||||
@@ -3047,4 +3145,4 @@ class AdminControllerCore extends Controller
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,8 +175,8 @@ abstract class ControllerCore
|
||||
// then using displayAjax[action]
|
||||
if ($this->ajax)
|
||||
{
|
||||
$action = Tools::toCamelCase(Tools::getValue('action'), true);
|
||||
if (!empty($action) && method_exists($this, 'displayAjax'.$action))
|
||||
$action = Tools::getValue('action');
|
||||
if (!empty($action) && method_exists($this, 'displayAjax'.Tools::toCamelCase($action, true)))
|
||||
$this->{'displayAjax'.$action}();
|
||||
elseif (method_exists($this, 'displayAjax'))
|
||||
$this->displayAjax();
|
||||
@@ -334,14 +334,12 @@ abstract class ControllerCore
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugin_path = Media::getJqueryPluginPath($name, $folder);
|
||||
|
||||
if(!empty($plugin_path['css']))
|
||||
$this->addCSS($plugin_path['css']);
|
||||
if(!empty($plugin_path['js']))
|
||||
$this->addJS($plugin_path['js']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -251,8 +251,6 @@ class FrontControllerCore extends Controller
|
||||
$this->context->cart = $cart;
|
||||
CartRule::autoAddToCart($this->context);
|
||||
}
|
||||
else
|
||||
$this->context->cart = $cart;
|
||||
|
||||
/* get page name to display it in body id */
|
||||
|
||||
@@ -327,7 +325,7 @@ class FrontControllerCore extends Controller
|
||||
'currencies' => Currency::getCurrencies(),
|
||||
'languages' => $languages,
|
||||
'meta_language' => implode('-', $meta_language),
|
||||
'priceDisplay' => Product::getTaxCalculationMethod((int)$this->context->cookie->id_customer),
|
||||
'priceDisplay' => Product::getTaxCalculationMethod(),
|
||||
'add_prod_display' => (int)Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
|
||||
'shop_name' => Configuration::get('PS_SHOP_NAME'),
|
||||
'roundMode' => (int)Configuration::get('PS_PRICE_ROUND_MODE'),
|
||||
@@ -580,9 +578,6 @@ class FrontControllerCore extends Controller
|
||||
header('HTTP/1.1 503 temporarily overloaded');
|
||||
|
||||
$this->context->smarty->assign($this->initLogoAndFavicon());
|
||||
$this->context->smarty->assign(array(
|
||||
'HOOK_MAINTENANCE' => Hook::exec('displayMaintenance', array()),
|
||||
));
|
||||
|
||||
$template_dir = ($this->context->getMobileDevice() == true ? _PS_THEME_MOBILE_DIR_ : _PS_THEME_DIR_);
|
||||
$this->smartyOutputContent($template_dir.'maintenance.tpl');
|
||||
@@ -850,7 +845,7 @@ class FrontControllerCore extends Controller
|
||||
if (!is_numeric(Tools::getValue('p', 1)) || Tools::getValue('p', 1) < 0)
|
||||
Tools::redirect(self::$link->getPaginationLink(false, false, $this->n, false, 1, false));
|
||||
|
||||
$current_url = Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']);
|
||||
$current_url = tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']);
|
||||
//delete parameter page
|
||||
$current_url = preg_replace('/(\?)?(&)?p=\d+/', '$1', $current_url);
|
||||
|
||||
@@ -919,7 +914,7 @@ class FrontControllerCore extends Controller
|
||||
$ips = array_map('trim', $ips);
|
||||
if (is_array($ips) && count($ips))
|
||||
foreach ($ips as $ip)
|
||||
if (!empty($ip) && preg_match('/^'.$ip.'.*/', $user_ip))
|
||||
if (!empty($ip) && strpos($user_ip, $ip) === 0)
|
||||
$allowed = true;
|
||||
return $allowed;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class ModuleFrontControllerCore extends FrontController
|
||||
elseif (Tools::file_exists_cache($this->getTemplatePath().$template))
|
||||
$this->template = $this->getTemplatePath().$template;
|
||||
else
|
||||
throw new PrestaShopException("Template '$template' not found");
|
||||
throw new PrestaShopException("Template '$template'' not found");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -523,13 +523,13 @@ abstract class DbCore
|
||||
$this->last_cached = true;
|
||||
return $result;
|
||||
}
|
||||
|
||||
$this->result = $this->query($sql);
|
||||
if (!$this->result)
|
||||
return false;
|
||||
|
||||
$this->last_cached = false;
|
||||
$result = $this->nextRow($this->result);
|
||||
if (is_null($result))
|
||||
$result = false;
|
||||
if ($use_cache && $this->is_cache_enabled)
|
||||
Cache::getInstance()->setQuery($sql, $result);
|
||||
return $result;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
class HelperCore
|
||||
{
|
||||
public $currentIndex;
|
||||
public $table = 'configuration';
|
||||
public $table;
|
||||
public $identifier;
|
||||
public $token;
|
||||
public $toolbar_btn;
|
||||
@@ -213,18 +213,20 @@ class HelperCore
|
||||
|
||||
$html = '
|
||||
<script type="text/javascript">
|
||||
var inputName = \''.addcslashes($input_name, '\'').'\';'."\n";
|
||||
var inputName = "'.$input_name.'";
|
||||
';
|
||||
if (count($selected_cat) > 0)
|
||||
{
|
||||
if (isset($selected_cat[0]))
|
||||
$html .= ' var selectedCat = '.(int)implode(',', $selected_cat).';'."\n";
|
||||
$html .= 'var selectedCat = "'.implode(',', $selected_cat).'";';
|
||||
else
|
||||
$html .= ' var selectedCat = '.(int)implode(',', array_keys($selected_cat)).';'."\n";
|
||||
$html .= 'var selectedCat = "'.implode(',', array_keys($selected_cat)).'";';
|
||||
}
|
||||
else
|
||||
$html .= ' var selectedCat = \'\';'."\n";
|
||||
$html .= ' var selectedLabel = \''.$translations['selected'].'\';
|
||||
var home = \''.addcslashes($root['name'], '\'').'\';
|
||||
$html .= 'var selectedCat = "";';
|
||||
$html .= '
|
||||
var selectedLabel = \''.$translations['selected'].'\';
|
||||
var home = \''.$root['name'].'\';
|
||||
var use_radio = '.(int)$use_radio.';';
|
||||
if (!$use_in_popup)
|
||||
$html .= '
|
||||
|
||||
@@ -37,6 +37,8 @@ class HelperFormCore extends Helper
|
||||
|
||||
/** @var array values of form fields */
|
||||
public $fields_value = array();
|
||||
|
||||
public $table = 'configuration';
|
||||
public $name_controller = '';
|
||||
|
||||
/** @var string if not null, a title will be added on that list */
|
||||
|
||||
@@ -444,13 +444,13 @@ class HelperListCore extends Helper
|
||||
self::$cache_lang['Delete'] = $this->l('Delete', 'Helper');
|
||||
|
||||
if (!array_key_exists('DeleteItem', self::$cache_lang))
|
||||
self::$cache_lang['DeleteItem'] = $this->l('Delete selected item?', 'Helper', true, false);
|
||||
self::$cache_lang['DeleteItem'] = $this->l('Delete selected item?', 'Helper');
|
||||
|
||||
if (!array_key_exists('Name', self::$cache_lang))
|
||||
self::$cache_lang['Name'] = $this->l('Name:', 'Helper', true, false);
|
||||
self::$cache_lang['Name'] = $this->l('Name:', 'Helper');
|
||||
|
||||
if (!is_null($name))
|
||||
$name = addcslashes('\n\n'.self::$cache_lang['Name'].' '.$name, '\'');
|
||||
$name = '\n\n'.self::$cache_lang['Name'].' '.$name;
|
||||
|
||||
$data = array(
|
||||
$this->identifier => $id,
|
||||
@@ -459,7 +459,7 @@ class HelperListCore extends Helper
|
||||
);
|
||||
|
||||
if ($this->specificConfirmDelete !== false)
|
||||
$data['confirm'] = !is_null($this->specificConfirmDelete) ? '\r'.$this->specificConfirmDelete : Tools::safeOutput(self::$cache_lang['DeleteItem'].$name);
|
||||
$data['confirm'] = !is_null($this->specificConfirmDelete) ? '\r'.$this->specificConfirmDelete : Tools::safeOutput(addcslashes(self::$cache_lang['DeleteItem'].$name, '\''));
|
||||
|
||||
$tpl->assign(array_merge($this->tpl_delete_link_vars, $data));
|
||||
|
||||
@@ -513,7 +513,7 @@ class HelperListCore extends Helper
|
||||
if (Tools::getIsset($this->table.'Orderby'))
|
||||
$order = '&'.$this->table.'Orderby='.urlencode($this->orderBy).'&'.$this->table.'Orderway='.urlencode(strtolower($this->orderWay));
|
||||
|
||||
$action = $this->currentIndex.$identifier.'&token='.$token.'#'.$this->table;
|
||||
$action = $this->currentIndex.$identifier.'&token='.$token.$order.'#'.$this->table;
|
||||
|
||||
/* Determine current page number */
|
||||
$page = (int)Tools::getValue('submitFilter'.$this->list_id);
|
||||
|
||||
@@ -203,7 +203,7 @@ abstract class ModuleCore
|
||||
}
|
||||
|
||||
// Check PS version compliancy
|
||||
if (version_compare(_PS_VERSION_, $this->ps_versions_compliancy['min']) < 0 || version_compare(_PS_VERSION_, $this->ps_versions_compliancy['max']) > 0)
|
||||
if (version_compare(_PS_VERSION_, $this->ps_versions_compliancy['min']) < 0 || version_compare(_PS_VERSION_, $this->ps_versions_compliancy['max']) >= 0)
|
||||
{
|
||||
$this->_errors[] = $this->l('The version of your module is not compliant with your PrestaShop version.');
|
||||
return false;
|
||||
@@ -1234,7 +1234,11 @@ abstract class ModuleCore
|
||||
$module->interest = 0;
|
||||
}
|
||||
|
||||
usort($module_list, create_function('$a,$b', 'return strnatcasecmp($a->displayName, $b->displayName);'));
|
||||
usort($module_list, create_function('$a,$b', '
|
||||
if ($a->displayName == $b->displayName)
|
||||
return 0;
|
||||
return ($a->displayName < $b->displayName) ? -1 : 1;
|
||||
'));
|
||||
|
||||
if ($errors)
|
||||
{
|
||||
@@ -1258,7 +1262,7 @@ abstract class ModuleCore
|
||||
$modules = scandir(_PS_MODULE_DIR_);
|
||||
foreach ($modules as $name)
|
||||
{
|
||||
if (is_dir(_PS_MODULE_DIR_.$name.DIRECTORY_SEPARATOR) && Tools::file_exists_cache(_PS_MODULE_DIR_.$name.'/'.$name.'.php'))
|
||||
if (is_dir(_PS_MODULE_DIR_.$name) && Tools::file_exists_cache(_PS_MODULE_DIR_.$name.'/'.$name.'.php'))
|
||||
{
|
||||
if (!Validate::isModuleName($name))
|
||||
throw new PrestaShopException(sprintf('Module %s is not a valid module name', $name));
|
||||
@@ -1293,26 +1297,6 @@ abstract class ModuleCore
|
||||
return $db->executeS('SELECT * FROM `'._DB_PREFIX_.'module` m WHERE `name` NOT IN ('.implode(',', $arr_native_modules).') ');
|
||||
}
|
||||
|
||||
public static function getNativeModuleList()
|
||||
{
|
||||
$module_list_xml = _PS_ROOT_DIR_.self::CACHE_FILE_MODULES_LIST;
|
||||
if (!file_exists($module_list_xml))
|
||||
return false;
|
||||
|
||||
$native_modules = simplexml_load_file($module_list_xml);
|
||||
$native_modules = $native_modules->modules;
|
||||
$modules = array();
|
||||
|
||||
foreach ($native_modules as $native_modules_type)
|
||||
if (in_array($native_modules_type['type'], array('native', 'partner')))
|
||||
{
|
||||
foreach ($native_modules_type->module as $module)
|
||||
$modules[] = $module['name'];
|
||||
}
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return installed modules
|
||||
*
|
||||
@@ -1596,18 +1580,6 @@ abstract class ModuleCore
|
||||
return Cache::retrieve('Module::isInstalled'.$module_name);
|
||||
}
|
||||
|
||||
public function isEnabledForShopContext()
|
||||
{
|
||||
$shop_list = Shop::getContextListShopID();
|
||||
return (bool)Db::getInstance()->getValue('
|
||||
SELECT COUNT(*) n
|
||||
FROM `'._DB_PREFIX_.'module_shop`
|
||||
WHERE id_module='.(int)$this->id.' AND id_shop IN ('.implode(',', array_map('intval', Shop::getContextListShopID())).')
|
||||
GROUP BY id_module
|
||||
HAVING n='.(int)count(Shop::getContextListShopID())
|
||||
);
|
||||
}
|
||||
|
||||
public static function isEnabled($module_name)
|
||||
{
|
||||
if (!Cache::isStored('Module::isEnabled'.$module_name))
|
||||
@@ -1758,7 +1730,7 @@ abstract class ModuleCore
|
||||
{
|
||||
Tools::enableCache();
|
||||
if ($cache_id === null)
|
||||
$cache_id = $this->name;
|
||||
$cache_id = Module::getCacheId($this->name);
|
||||
Tools::clearCache(Context::getContext()->smarty, $this->getTemplatePath($template), $cache_id, $compile_id);
|
||||
Tools::restoreCacheSettings();
|
||||
}
|
||||
@@ -1785,7 +1757,6 @@ abstract class ModuleCore
|
||||
@unlink($file);
|
||||
@file_put_contents($file, $xml);
|
||||
}
|
||||
@chmod($file, 0664);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1864,13 +1835,7 @@ abstract class ModuleCore
|
||||
*/
|
||||
public static function getModuleIdByName($name)
|
||||
{
|
||||
$cache_id = 'Module::getModuleIdByName_'.pSQL($name);
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$result = (int)Db::getInstance()->getValue('SELECT `id_module` FROM `'._DB_PREFIX_.'module` WHERE `name` = "'.pSQL($name).'"');
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
return Db::getInstance()->getValue('SELECT `id_module` FROM `'._DB_PREFIX_.'module` WHERE `name` = "'.pSQL($name).'"');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2117,7 +2082,7 @@ abstract class ModuleCore
|
||||
|
||||
// Remplacer la ligne de declaration par "remove"
|
||||
foreach ($override_file as $line_number => &$line_content)
|
||||
if (preg_match('/(public|private|protected|const)\s+(static\s+)?(\$)?'.$property->getName().'/i', $line_content))
|
||||
if (preg_match('/(public|private|protected)\s+(static\s+)?\$'.$property->getName().'/i', $line_content))
|
||||
{
|
||||
$line_content = '#--remove--#';
|
||||
break;
|
||||
|
||||
@@ -721,17 +721,11 @@ class OrderCore extends ObjectModel
|
||||
|
||||
public static function getDiscountsCustomer($id_customer, $id_cart_rule)
|
||||
{
|
||||
$cache_id = 'Order::getDiscountsCustomer_'.(int)$id_customer.'-'.(int)$id_cart_rule;
|
||||
if (!Cache::isStored($cache_id))
|
||||
{
|
||||
$result = (int)Db::getInstance()->getValue('
|
||||
SELECT COUNT(*) FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN '._DB_PREFIX_.'order_cart_rule ocr ON (ocr.id_order = o.id_order)
|
||||
WHERE o.id_customer = '.(int)$id_customer.'
|
||||
AND ocr.id_cart_rule = '.(int)$id_cart_rule);
|
||||
Cache::store($cache_id, $result);
|
||||
}
|
||||
return Cache::retrieve($cache_id);
|
||||
return Db::getInstance()->getValue('
|
||||
SELECT COUNT(*) FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN '._DB_PREFIX_.'order_cart_rule ocr ON (ocr.id_order = o.id_order)
|
||||
WHERE o.id_customer = '.(int)$id_customer.'
|
||||
AND ocr.id_cart_rule = '.(int)$id_cart_rule);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1092,41 +1086,6 @@ class OrderCore extends ObjectModel
|
||||
');
|
||||
}
|
||||
|
||||
public static function setLastInvoiceNumber($order_invoice_id, $id_shop)
|
||||
{
|
||||
if (!$order_invoice_id)
|
||||
return false;
|
||||
|
||||
$number = Configuration::get('PS_INVOICE_START_NUMBER', null, null, $id_shop);
|
||||
// If invoice start number has been set, you clean the value of this configuration
|
||||
if ($number)
|
||||
Configuration::updateValue('PS_INVOICE_START_NUMBER', false, false, null, $id_shop);
|
||||
|
||||
$sql = 'UPDATE `'._DB_PREFIX_.'order_invoice` SET number =';
|
||||
|
||||
if ($number)
|
||||
$sql .= (int)$number;
|
||||
else
|
||||
$sql .= '(SELECT new_number FROM (SELECT (MAX(`number`) + 1) AS new_number
|
||||
FROM `'._DB_PREFIX_.'order_invoice`) AS result)';
|
||||
|
||||
$sql .=' WHERE `id_order_invoice` = '.(int)$order_invoice_id;
|
||||
|
||||
return Db::getInstance()->execute($sql);
|
||||
}
|
||||
|
||||
public function getInvoiceNumber($order_invoice_id)
|
||||
{
|
||||
if (!$order_invoice_id)
|
||||
return false;
|
||||
|
||||
return Db::getInstance()->getValue('
|
||||
SELECT `number`
|
||||
FROM `'._DB_PREFIX_.'order_invoice`
|
||||
WHERE `id_order_invoice` = '.(int)$order_invoice_id
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows to generate first invoice of the current order
|
||||
*/
|
||||
@@ -1136,7 +1095,13 @@ class OrderCore extends ObjectModel
|
||||
{
|
||||
$order_invoice = new OrderInvoice();
|
||||
$order_invoice->id_order = $this->id;
|
||||
$order_invoice->number = 0;
|
||||
$order_invoice->number = Configuration::get('PS_INVOICE_START_NUMBER', null, null, $this->id_shop);
|
||||
// If invoice start number has been set, you clean the value of this configuration
|
||||
if ($order_invoice->number)
|
||||
Configuration::updateValue('PS_INVOICE_START_NUMBER', false, false, null, $this->id_shop);
|
||||
else
|
||||
$order_invoice->number = Order::getLastInvoiceNumber() + 1;
|
||||
|
||||
$invoice_address = new Address((int)$this->id_address_invoice);
|
||||
$carrier = new Carrier((int)$this->id_carrier);
|
||||
$tax_calculator = $carrier->getTaxCalculator($invoice_address);
|
||||
@@ -1155,7 +1120,6 @@ class OrderCore extends ObjectModel
|
||||
|
||||
// Save Order invoice
|
||||
$order_invoice->add();
|
||||
$this->setLastInvoiceNumber($order_invoice->id, $this->id_shop);
|
||||
|
||||
$order_invoice->saveCarrierTaxCalculator($tax_calculator->getTaxesAmount($order_invoice->total_shipping_tax_excl));
|
||||
|
||||
@@ -1211,46 +1175,11 @@ class OrderCore extends ObjectModel
|
||||
|
||||
// Keep it for backward compatibility, to remove on 1.6 version
|
||||
$this->invoice_date = $order_invoice->date_add;
|
||||
$this->invoice_number = $this->getInvoiceNumber($order_invoice->id);
|
||||
$this->invoice_number = $order_invoice->number;
|
||||
$this->update();
|
||||
}
|
||||
}
|
||||
|
||||
public function setDeliveryNumber($order_invoice_id, $id_shop)
|
||||
{
|
||||
if (!$order_invoice_id)
|
||||
return false;
|
||||
|
||||
$number = Configuration::get('PS_DELIVERY_NUMBER', null, null, $id_shop);
|
||||
// If invoice start number has been set, you clean the value of this configuration
|
||||
if ($number)
|
||||
Configuration::updateValue('PS_DELIVERY_NUMBER', false, false, null, $id_shop);
|
||||
|
||||
$sql = 'UPDATE `'._DB_PREFIX_.'order_invoice` SET delivery_number =';
|
||||
|
||||
if ($number)
|
||||
$sql .= (int)$number;
|
||||
else
|
||||
$sql .= '(SELECT new_number FROM (SELECT (MAX(`delivery_number`) + 1) AS new_number
|
||||
FROM `'._DB_PREFIX_.'order_invoice`) AS result)';
|
||||
|
||||
$sql .=' WHERE `id_order_invoice` = '.(int)$order_invoice_id;
|
||||
|
||||
return Db::getInstance()->execute($sql);
|
||||
}
|
||||
|
||||
public function getDeliveryNumber($order_invoice_id)
|
||||
{
|
||||
if (!$order_invoice_id)
|
||||
return false;
|
||||
|
||||
return Db::getInstance()->getValue('
|
||||
SELECT `delivery_number`
|
||||
FROM `'._DB_PREFIX_.'order_invoice`
|
||||
WHERE `id_order_invoice` = '.(int)$order_invoice_id
|
||||
);
|
||||
}
|
||||
|
||||
public function setDelivery()
|
||||
{
|
||||
// Get all invoice
|
||||
@@ -1259,14 +1188,24 @@ class OrderCore extends ObjectModel
|
||||
{
|
||||
if ($order_invoice->delivery_number)
|
||||
continue;
|
||||
|
||||
$number = (int)Configuration::get('PS_DELIVERY_NUMBER', null, null, $this->id_shop);
|
||||
if (!$number)
|
||||
{
|
||||
//if delivery number is not set or wrong, we set a default one.
|
||||
Configuration::updateValue('PS_DELIVERY_NUMBER', 1, false, null, $this->id_shop);
|
||||
$number = 1;
|
||||
}
|
||||
|
||||
// Set delivery number on invoice
|
||||
$order_invoice->delivery_number = 0;
|
||||
$order_invoice->delivery_number = $number;
|
||||
$order_invoice->delivery_date = date('Y-m-d H:i:s');
|
||||
// Update Order Invoice
|
||||
$order_invoice->update();
|
||||
$this->setDeliveryNumber($order_invoice->id, $this->id_shop);
|
||||
$this->delivery_number = $this->getDeliveryNumber($order_invoice->id);
|
||||
|
||||
// Keep for backward compatibility
|
||||
$this->delivery_number = $number;
|
||||
Configuration::updateValue('PS_DELIVERY_NUMBER', $number + 1, false, null, $this->id_shop);
|
||||
}
|
||||
|
||||
// Keep it for backward compatibility, to remove on 1.6 version
|
||||
@@ -1951,9 +1890,10 @@ class OrderCore extends ObjectModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Return id of carrier
|
||||
* Return a unique reference like : GWJTHMZUN#2
|
||||
*
|
||||
* Get id of the carrier used in order
|
||||
* With multishipping, order reference are the same for all orders made with the same cart
|
||||
* in this case this method suffix the order reference by a # and the order number
|
||||
*
|
||||
* @since 1.5.5.0
|
||||
*/
|
||||
|
||||
@@ -243,7 +243,7 @@ class OrderInvoiceCore extends ObjectModel
|
||||
WHERE od.`id_order` = '.(int)$this->id_order.'
|
||||
AND od.`id_order_invoice` = '.(int)$this->id.'
|
||||
AND od.`tax_computation_method` = '.(int)TaxCalculator::ONE_AFTER_ANOTHER_METHOD
|
||||
) || Configuration::get('PS_INVOICE_TAXES_BREAKDOWN');
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,7 +301,7 @@ class OrderInvoiceCore extends ObjectModel
|
||||
{
|
||||
// sum by order details in order to retrieve real taxes rate
|
||||
$taxes_infos = Db::getInstance()->executeS('
|
||||
SELECT odt.`id_order_detail`, t.`rate` AS `name`, od.`total_price_tax_excl` AS total_price_tax_excl, SUM(t.`rate`) AS rate, SUM(`total_amount`) AS `total_amount`, od.`ecotax`, od.`ecotax_tax_rate`, od.`product_quantity`
|
||||
SELECT odt.`id_order_detail`, t.`rate` AS `name`, SUM(od.`total_price_tax_excl`) AS total_price_tax_excl, SUM(t.`rate`) AS rate, SUM(`total_amount`) AS `total_amount`, od.`ecotax`, od.`ecotax_tax_rate`, od.`product_quantity`
|
||||
FROM `'._DB_PREFIX_.'order_detail_tax` odt
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = odt.`id_tax`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON (od.`id_order_detail` = odt.`id_order_detail`)
|
||||
@@ -466,7 +466,7 @@ class OrderInvoiceCore extends ObjectModel
|
||||
FROM `'._DB_PREFIX_.'order_invoice` oi
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = oi.`id_order`)
|
||||
WHERE DATE_ADD(oi.delivery_date, INTERVAL -1 DAY) <= \''.pSQL($date_to).'\'
|
||||
AND oi.delivery_date >= \''.pSQL($date_from).'\'
|
||||
AND oi.date_add >= \''.pSQL($date_from).'\'
|
||||
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
|
||||
ORDER BY oi.delivery_date ASC
|
||||
');
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user