Merge branch 'ticket-newImport' into develop
This commit is contained in:
commit
89f5c51bcb
@ -12,7 +12,43 @@ class AdminBulkUpdate extends AdminTab {
|
||||
|
||||
set_time_limit(300);
|
||||
|
||||
if (Tools::isSubmit('submitUploadQuantities')) {
|
||||
if (Tools::isSubmit('submitUploadProductCustoms')) {
|
||||
$process = (int) Tools::getValue('customs_process');
|
||||
if(isset($_FILES['csvfile']) && $_FILES['csvfile']['name'] != '') {
|
||||
$f = fopen($_FILES['csvfile']['tmp_name'], 'r');
|
||||
fgetcsv($f, 0, ';');
|
||||
|
||||
$products = array();
|
||||
|
||||
while($line = fgetcsv($f, 0, ';')) {
|
||||
if($line[0] == '' || $line[1] == '' || $line[2] == '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$products[(int)$line[0]] = $line;
|
||||
}
|
||||
if($process == 1) {
|
||||
Db::getInstance()->ExecuteS('
|
||||
DELETE FROM `'._DB_PREFIX_.'product_customs`
|
||||
WHERE `id_product` IN ('.implode(', ', array_keys($products)).')
|
||||
');
|
||||
|
||||
}
|
||||
|
||||
foreach($products as $line) {
|
||||
Db::getInstance()->ExecuteS('
|
||||
INSERT INTO `'._DB_PREFIX_.'product_customs` VALUES (
|
||||
'.(int) $line[0].',
|
||||
"'.pSQL($line[1]).'",
|
||||
"'.pSQL($line[2]).'"
|
||||
)
|
||||
');
|
||||
}
|
||||
|
||||
fclose($f);
|
||||
$output .= '<p class="conf">'.$this->l('Product customs updated').'</p>';
|
||||
}
|
||||
}elseif (Tools::isSubmit('submitUploadQuantities')) {
|
||||
$process = (int) Tools::getValue('qty_process');
|
||||
if(isset($_FILES['csvfile']) && $_FILES['csvfile']['name'] != '') {
|
||||
$f = fopen($_FILES['csvfile']['tmp_name'], 'r');
|
||||
@ -2095,6 +2131,26 @@ class AdminBulkUpdate extends AdminTab {
|
||||
</fieldset>
|
||||
</form>';
|
||||
|
||||
$output .= '
|
||||
<p><br /></p>
|
||||
<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post" enctype="multipart/form-data">
|
||||
<fieldset><legend><img src="/modules/bulkupdate/logo.gif" alt="" title="" />'.$this->l('Update product customs').'</legend>
|
||||
<label>'.$this->l('Product customs process:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" id="customs_process_0" name="customs_process" value="0" /> <label style="float: none;" for="qty_process_0">'.$this->l('Update').'</label>
|
||||
<input type="radio" id="customs_process_1" name="customs_process" value="1" /> <label style="float: none;" for="qty_process_1">'.$this->l('Replace').'</label>
|
||||
</div>
|
||||
<p> </p>
|
||||
<label>'.$this->l('File:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="file" name="csvfile" />
|
||||
<p>'.$this->l('Format: id_product;nc8;country -- the subsequent columns and the first line are ignored').'</p>
|
||||
</div>
|
||||
<p> </p>
|
||||
<center><input type="submit" name="submitUploadProductCustoms" value="'.$this->l('Upload').'" class="button" /></center>
|
||||
</fieldset>
|
||||
</form>';
|
||||
|
||||
|
||||
echo '<link type="text/css" rel="stylesheet" href="'._MODULE_DIR_.'bulkupdate/chosen.min.css" />';
|
||||
echo '<script type="text/javascript" src="'._MODULE_DIR_.'bulkupdate/chosen.jquery.min.js"></script>';
|
||||
|
Loading…
Reference in New Issue
Block a user