update braderie with category
This commit is contained in:
parent
67264249a5
commit
4905fc1e86
@ -16,14 +16,38 @@ class AdminBraderie extends AdminTab
|
||||
$id_product = Tools::getValue('id_product', false);
|
||||
|
||||
$db = Db::getInstance();
|
||||
$sql_category = '
|
||||
/*$sql_category = '
|
||||
SELECT * FROM `'._DB_PREFIX_.'privatesale` ps
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ps.`id_category` = cl.`id_category`
|
||||
WHERE ps.`braderie` = 1
|
||||
AND cl.`id_lang` = '.(int) $cookie->id_lang;
|
||||
AND cl.`id_lang` = '.(int) $cookie->id_lang;*/
|
||||
$sql_category = '
|
||||
SELECT c.`id_category`, cl.`name` FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`
|
||||
WHERE c.`id_parent` = 1
|
||||
AND cl.`id_lang` = '.(int) $cookie->id_lang.'
|
||||
ORDER BY c.`id_category` DESC';
|
||||
$categories = $db->ExecuteS($sql_category);
|
||||
|
||||
$this->_html .= $this->_buildHtmlCategoryBlock($categories);
|
||||
$ids_categories = array();
|
||||
foreach ($categories as $key => $category) {
|
||||
$ids_categories[] = (int) $category["id_category"];
|
||||
}
|
||||
|
||||
$small_titles = array();
|
||||
foreach (Db::getInstance()->executeS('
|
||||
SELECT ex.`value`, ps.`id_category`
|
||||
FROM `'._DB_PREFIX_.'privatesale_extrafield_sale` ex
|
||||
LEFT JOIN `'._DB_PREFIX_.'privatesale` ps on ex.`id_sale` = ps.`id_sale`
|
||||
LEFT JOIN `'._DB_PREFIX_.'category` c on c.`id_category` = ps.`id_category`
|
||||
WHERE ex.`id_field` = 1
|
||||
AND ex.`id_lang` = '. (int) $cookie->id_lang.'
|
||||
AND c.`id_category` IN ('.implode(',', $ids_categories).')
|
||||
') as $key => $data) {
|
||||
$small_titles[(int) $data['id_category']] = $data['value'];
|
||||
}
|
||||
|
||||
$this->_html .= $this->_buildHtmlCategoryBlock($categories, $small_titles);
|
||||
|
||||
$this->_html .= '<link type="text/css" rel="stylesheet" href="'._MODULE_DIR_.'bulkupdate/chosen.min.css" />';
|
||||
$this->_html .= '<script type="text/javascript" src="'._MODULE_DIR_.'bulkupdate/chosen.jquery.min.js"></script>';
|
||||
@ -151,7 +175,7 @@ class AdminBraderie extends AdminTab
|
||||
},
|
||||
success: function(response) {
|
||||
$("#error").empty().append(response);
|
||||
$("#input_ean, #input_storage, #input_quantity").val("");
|
||||
$("#input_ean, #input_storage").val("");
|
||||
},
|
||||
error: function(xhr) {
|
||||
$("#error").empty().append(JSON.parse(xhr.responseText));
|
||||
@ -169,14 +193,12 @@ class AdminBraderie extends AdminTab
|
||||
window.open("?tab=AdminCatalog&viewcategory&id_category=" + $category + "&token=" + $token, "_blank");
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
</script>';
|
||||
echo $this->_html;
|
||||
}
|
||||
|
||||
private function _buildHtmlCategoryBlock($categories)
|
||||
private function _buildHtmlCategoryBlock($categories, $small_titles)
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
@ -203,7 +225,7 @@ class AdminBraderie extends AdminTab
|
||||
<option value=""></option>';
|
||||
|
||||
foreach ($categories as $key => $value) {
|
||||
$html .= '<option value="'.$value['id_sale'].'">'.$value['id_sale'].' - '.$value['name'].'</option>';
|
||||
$html .= '<option value="'.$value['id_category'].'">'.$value['id_category'].' - '.$value['name'].(!empty($small_titles[(int)$value['id_category']])?' - '.$small_titles[(int)$value['id_category']]:'').'</option>';
|
||||
}
|
||||
|
||||
$html .= ' </select>
|
||||
@ -228,7 +250,7 @@ class AdminBraderie extends AdminTab
|
||||
</div>
|
||||
<div class="margin-form" id="quantity_input_group" style="display: none;">
|
||||
<label>'.$this->l('Quantité').' : </label>
|
||||
<input type="number" name="quantity" id="input_quantity">
|
||||
<input type="number" name="quantity" id="input_quantity" value="1">
|
||||
</div>
|
||||
<div class="margin-form button-container" id="button_input_group" style="display: none;">
|
||||
<input type="submit" class="button" name="adminbraderie" value="'.$this->l('Ajouter').'" style="margin-left: 200px;" id="add_button">
|
||||
|
@ -34,9 +34,16 @@ function getCategories()
|
||||
return Tools::displayError('Catégorie invalide');
|
||||
}
|
||||
|
||||
$db = Db::getInstance();
|
||||
$sql = 'SELECT * FROM `'._DB_PREFIX_.'privatesale_category` pc LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON pc.`id_category` = cl.`id_category` WHERE pc.`id_sale` = '.$id_sale.' AND cl.`id_lang` = '.(int)$cookie->id_lang;
|
||||
return $db->ExecuteS($sql);
|
||||
//$db = Db::getInstance();
|
||||
//$sql = 'SELECT * FROM `'._DB_PREFIX_.'privatesale_category` pc LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON pc.`id_category` = cl.`id_category` WHERE pc.`id_sale` = '.$id_sale.' AND cl.`id_lang` = '.(int)$cookie->id_lang;
|
||||
|
||||
return Db::getInstance()->ExecuteS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'category` c
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`
|
||||
WHERE c.`id_parent` = '.$id_sale.'
|
||||
AND cl.`id_lang` = '.(int)$cookie->id_lang
|
||||
);
|
||||
}
|
||||
|
||||
function getProductId()
|
||||
@ -111,7 +118,7 @@ function addToSellout()
|
||||
unset($product->id_product);
|
||||
$product->active = 1;
|
||||
$product->quantity = $quantity;
|
||||
$product->reference = $storage.'_'.$product->reference;
|
||||
$product->reference = $storage.'-'.$product->reference;
|
||||
$product->id_category_default = (int)$category;
|
||||
|
||||
if ($product->add()) {
|
||||
|
Loading…
Reference in New Issue
Block a user