89 lines
2.6 KiB
PHP
89 lines
2.6 KiB
PHP
<?php
|
|
if(!defined('_PS_VERSION_')) {
|
|
exit;
|
|
}
|
|
|
|
class AdminBraderie extends AdminTab
|
|
{
|
|
private $_html = '';
|
|
|
|
public function display()
|
|
{
|
|
global $cookie;
|
|
|
|
$id_category = Tools::getValue('id_category', 1);
|
|
$id_product = Tools::getValue('id_product', false);
|
|
|
|
$db = Db::getInstance();
|
|
$sql_category = 'SELECT * FROM `ps_privatesale` ps LEFT JOIN `ps_category_lang` cl ON ps.`id_category` = cl.`id_category` WHERE ps.`braderie` = 1 AND cl.`id_lang` = '.$cookie->id_lang;
|
|
$categories = $db->ExecuteS($sql_category);
|
|
|
|
$this->_html .= $this->_buildHtmlCategoryBlock($categories);
|
|
|
|
$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>';
|
|
$this->_html .= '<script type="text/javascript">
|
|
$(function() {
|
|
$(".chosen-select").chosen(
|
|
{
|
|
allow_single_deselect:true,
|
|
placeholder_text_single : "Choisir une vente",
|
|
no_results_text : "Aucun résultat",
|
|
enable_split_word_search : true,
|
|
search_contains : true,
|
|
}
|
|
);
|
|
|
|
|
|
$(\'#sale\').change(function() {
|
|
$.ajax({
|
|
type: \'POST\',
|
|
url: \''._MODULE_DIR_.'braderie/ajax.php?action=getCategories'.'\',
|
|
dataType: \'json\',
|
|
data: { sale: $(this).val() },
|
|
success: function(response) {
|
|
for (var i in response) {
|
|
$(\'#category\').append(response[i].id_category + \' - \' + response[i].meta_title);
|
|
}
|
|
},
|
|
error: function(xhr) {
|
|
console.log(xhr.responseText);
|
|
}
|
|
});
|
|
});
|
|
|
|
});
|
|
</script>';
|
|
echo $this->_html;
|
|
}
|
|
|
|
private function _buildHtmlCategoryBlock($categories)
|
|
{
|
|
$html = '
|
|
<style> .chosen-container{ width: 315px !important; } </style>
|
|
<fieldset>
|
|
<legend>'.$this->l('Ventes privée').'</legend>
|
|
<div>
|
|
<label>Ventes : </label>
|
|
<select class="chosen-select" id="sale" name="sale">
|
|
<option value=""></option>';
|
|
|
|
foreach ($categories as $key => $value) {
|
|
$html .= '<option value="'.$value['id_sale'].'">'.$value['id_sale'].' - '.$value['name'].'</option>';
|
|
}
|
|
|
|
$html .= ' </select>
|
|
</div>
|
|
<br>
|
|
<div>
|
|
<label>Catégories : </label>
|
|
<select class="chosen-select" id="category" name="category">
|
|
<option value=""></option>
|
|
</select>
|
|
</div>
|
|
<hr>
|
|
</fieldset>';
|
|
return $html;
|
|
}
|
|
}
|