= 10 ){ echo '

'.$this->l('Association automatique en cours, réessayez plus tard').'


'; } else { $min_id_product = Db::getInstance()->getValue(' SELECT MIN(`id_product`) FROM `'._DB_PREFIX_.'product` WHERE `date_add` > DATE_SUB(NOW(), INTERVAL 10 DAY) '); if ($min_id_product) { Db::getInstance()->ExecuteS(' DELETE FROM `'._DB_PREFIX_.'product_ps_cache` WHERE `id_product` >= '.$min_id_product.' '); Db::getInstance()->ExecuteS(' INSERT IGNORE INTO `'._DB_PREFIX_.'product_ps_cache` ( SELECT p.id_product, IFNULL( ( SELECT s.id_sale FROM `'._DB_PREFIX_.'privatesale_category` s WHERE s.`id_category` = p.`id_category_default` LIMIT 1) , 0 ) FROM `'._DB_PREFIX_.'product` p WHERE p.`id_product` >= '.$min_id_product.' ) '); mail('marion@antadis.com', '[BBB] Re Associate products to sale', 'Date : '.date("d/m/Y H:i").' - Employee : '.$cookie->id_employee); // check for bad behaviour echo '

'.$this->l('Produits associés aux ventes depuis le produit #').$min_id_product.'


'; } else { echo '

'.$this->l('Pas de produit ajouté depuis 10 jours').'


'; } } } elseif(Tools::isSubmit('submitCategorySaleCache')) { $id_sale = Tools::getValue('id_sale'); mail('marion@antadis.com', '[BBB] Re Associate category to sale - buildCategoryCache', 'Date : '.date("d/m/Y H:i").' - Sale : '.$id_sale.' - Employee : '.$cookie->id_employee); // check for bad behaviour if($id_sale) { $sale = new Sale((int)$id_sale); $sale->buildCategoryCache(); echo '

'.$this->l('Categories associés à la vente ').$id_sale.'


'; } else { echo '

'.$this->l('Veuillez choisir une vente').'


'; } } } public function display() { global $cookie, $currentIndex; $base_link = $currentIndex . '&token='.Tools::getAdminTokenLite('AdminAntConfigurations'); $form = ''; $helperForm = new HelperForm(); $helperForm->_forms = array( array( 'action' => $base_link, 'legend' => $this->l('Association Vente - Produits'), 'actions' => array( array( 'type' => 'submit', 'name' => 'submitProductSaleCache', 'label' => $this->l('Associer les produits aux ventes') ) ) ) ); $form .= $helperForm->renderForm(false, NULL, NULL, true); $id_sale_options = array(); foreach(Db::getInstance()->ExecuteS(' SELECT p.`id_sale`, c.`name`, c.`id_category` FROM `'._DB_PREFIX_.'privatesale` p LEFT JOIN `'._DB_PREFIX_.'category_lang` c ON (c.`id_category` = p.`id_category`) WHERE c.`id_lang` = '.$cookie->id_lang.' AND p.`date_start` > "2015-01-01 00:00:00" ORDER BY p.`id_sale` DESC ') as $row) { $extrafields = Category::getSalesInfos(array((int) $row['id_category'])); $id_sale_options[] = array( 'label' => (int) $row['id_sale'].' - '.$row['name'].(empty($extrafields[(int) $row['id_category']]['sales'][1])?'':' - '.$extrafields[(int) $row['id_category']]['sales'][1]) , 'value' => (int) $row['id_sale'] ); } $helperForm = new HelperForm(); $helperForm->_forms = array( array( 'action' => $base_link, 'legend' => $this->l('Association Vente - Categories'), 'inputs' => array( array( 'type' => 'select-styled', 'class-select' => 'bg-purple-light big-select', 'name' => 'id_sale', 'label' => $this->l('Select a sale'), 'options' => $id_sale_options, 'filter' => true, 'filter_text' => $this->l('Filter par vente') ), ), 'actions' => array( array( 'type' => 'submit', 'name' => 'submitCategorySaleCache', 'label' => $this->l('Associer les categories aux ventes') ) ) ) ); $form .= $helperForm->renderForm(false, NULL, NULL, true); echo $form; } }