diff --git a/classes/Cart.php b/classes/Cart.php index 0e703b3..fcdb8fe 100755 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -1670,6 +1670,7 @@ class CartCore extends ObjectModel $warehouse_count_by_address[$product['id_address_delivery']][$warehouse['id_warehouse']]++; } } + unset($product); arsort($warehouse_count_by_address); @@ -1879,13 +1880,14 @@ class CartCore extends ObjectModel public function getDeliveryOptionList(Country $default_country = null, $flush = false) { static $cache = null; - if ($cache !== null && !$flush) + if ($cache !== null && !$flush){ return $cache; + } $delivery_option_list = array(); $carriers_price = array(); $carrier_collection = array(); - $package_list = $this->getPackageList(); + $package_list = $this->getPackageList($flush); // Foreach addresses foreach ($package_list as $id_address => $packages) @@ -2093,8 +2095,10 @@ class CartCore extends ObjectModel } // Sort delivery option list - foreach ($delivery_option_list as &$array) + foreach ($delivery_option_list as &$array){ uasort ($array, array('Cart', 'sortDeliveryOptionList')); + } + unset($array); $cache = $delivery_option_list; return $delivery_option_list; diff --git a/modules/training/controllers/admin/AdminPharmacy.php b/modules/training/controllers/admin/AdminPharmacy.php deleted file mode 100644 index cba08de..0000000 --- a/modules/training/controllers/admin/AdminPharmacy.php +++ /dev/null @@ -1,36 +0,0 @@ -table = 'training_pharmacy'; - $this->className = 'TrainingPharmacy'; - $this->identifier = 'id_training_pharmacy'; - $this->lang = FALSE; - $this->deleted = FALSE; - $this->bootstrap = TRUE; - $this->_defaultOrderBy = 'codeclient'; - $this->toolbar_btn = array(); - - parent::__construct(); - - $this->actions = array(); - - $this->fields_list = array( - 'id_training_pharmacy' => array( - 'title' => 'ID', - 'width' => 25 - ), - 'codeclient' => array( - 'title' => $this->module->l('Code client'), - 'width' => 60, - ), - ); - } - - public function renderView() - { - return $this->renderList(); - } -} \ No newline at end of file diff --git a/modules/training/controllers/admin/AdminTraining.php b/modules/training/controllers/admin/AdminTraining.php deleted file mode 100644 index e1e1ed4..0000000 --- a/modules/training/controllers/admin/AdminTraining.php +++ /dev/null @@ -1,278 +0,0 @@ -path_files = __DIR__.'/../../upload/'; - $this->url_upload_path = '/modules/training/upload/'; - $this->path_output_files = __DIR__.'/../../output/'; - $this->url_output_path = '/modules/training/output/'; - } - - function display() - { - $this->setTemplate('home.tpl'); - - $this->context->smarty->assign(array( - 'link_training_modules' => Context::getContext()->link->getAdminLink('AdminTrainingModules', true), - 'link_self' => Context::getContext()->link->getAdminLink('AdminTraining', true), - )); - - parent::display(); - } - - function initContent() - { - $this->context->smarty->assign('url_upload_path', $this->url_upload_path); - $this->context->smarty->assign('url_output_path', $this->url_output_path); - - $this->context->smarty->assign('used_module_file', Configuration::get('TRAINING_USED_MODULE_FILE')); - $this->context->smarty->assign('used_pharmacy_file', Configuration::get('TRAINING_USED_PHARMACY_FILE')); - $this->context->smarty->assign('used_results_file', Configuration::get('TRAINING_USED_RESULT_FILE')); - $this->context->smarty->assign('used_fixedcodes_file', Configuration::get('TRAINING_FIXEDCODES_FILE')); - $this->context->smarty->assign('bilan_file', Configuration::get('TRAINING_BILAN_FILE')); - $this->context->smarty->assign('corrected_results_file', Configuration::get('TRAINING_CORRECTED_RESULT_FILE')); - $this->context->smarty->assign('corrected_codes_file', Configuration::get('TRAINING_CORRECTED_CODES_FILE')); - - if (Tools::isSubmit('submitFileModules')) { - $this->submitFileModules(); - } - elseif (Tools::isSubmit('submitFilePharmacies')) { - $this->submitFilePharmacies(); - } - elseif (Tools::isSubmit('submitFileResults')) { - $this->submitFileResults(); - } - elseif (Tools::isSubmit('generateBilan')) { - $this->generateBilan(); - } - elseif (Tools::isSubmit('submitFileFixedCodes')) { - $this->submitFileFixedCodes(); - } - } - - function submitFileModules() - { - $file = $this->moveUploadedCsvFile('module_filename'); - - if ($file!==null) { - $ok = TrainingModule::importFromCsvFile($file->path); - - if ($ok) { - Configuration::updateValue('TRAINING_USED_MODULE_FILE', $file->name); - $this->context->smarty->assign('used_module_file', $file->name); - $this->confirmations[] = $this->l(sprintf('Importation des modules et catégories réussie.')); - } - else { - $this->errors[] = $this->l('Echec de l\'importation des modules et catégories. Il est possible de les éditer manuellement.'); - } - } - } - - function submitFilePharmacies() - { - $file = $this->moveUploadedCsvFile('pharmacy_filename'); - - if ($file!==null) { - $ok = TrainingPharmacy::importFromCsvFile($file->path); - - if ($ok) { - Configuration::updateValue('TRAINING_USED_PHARMACY_FILE', $file->name); - $this->context->smarty->assign('used_pharmacy_file', $file->name); - $this->confirmations[] = $this->l(sprintf('Importation des pharmacies réussie.')); - } - else { - $this->errors[] = $this->l(sprintf('Echec de l\'importation des pharmacies.')); - } - } - } - - function submitFileResults() - { - $file = $this->moveUploadedCsvFile('results_filename'); - - if ($file!==null) { - Configuration::updateValue('TRAINING_USED_RESULT_FILE', $file->name); - $this->context->smarty->assign('used_results_file', $file->name); - } - } - - function submitFileFixedCodes() - { - $file = $this->moveUploadedCsvFile('fixed_codes_filename'); - - if ($file!==null) { - $ok = TrainingFixedCodeClient::importFromCsvFile($file->path); - - if ($ok) { - Configuration::updateValue('TRAINING_FIXEDCODES_FILE', $file->name); - $this->context->smarty->assign('used_fixedcodes_file', $file->name); - $this->confirmations[] = $this->l(sprintf('Importation des codes clients corrigés réussie.')); - } - else { - $this->errors[] = $this->l(sprintf('Echec de l\'importation des codes clients corrigés.')); - } - } - } - - function generateBilan() - { - // check all required data are defined - if (!TrainingPharmacy::hasAnyRow()) { - $this->errors[] = $this->l(sprintf('Merci d\'importer un fichier csv pharmacies.')); - } - - if (!TrainingModule::hasAnyRow()) { - $this->errors[] = $this->l(sprintf('Merci d\'ajouter les modules/catégories.')); - } - - $result_filename = Configuration::get('TRAINING_USED_RESULT_FILE'); - if (empty($result_filename)) { - $this->errors[] = $this->l(sprintf('Merci d\'importer un fichier de résultats.')); - } - - if (0 == count($this->errors)) { - - $d = new DateTime(); - $corrected_results_file = 'RESULTAT_CORRIGE_'.$d->format('Y-m-d_His').'.csv'; - $corrected_codes_file = 'CODES_CORRIGE_'.$d->format('Y-m-d_His').'.csv'; - $bilan_file = 'BILAN_'.$d->format('Y-m-d_His').'.csv'; - - $ok = TrainingBilan::generate( - $this->path_files.$result_filename, - $this->path_output_files.$corrected_results_file, - $this->path_output_files.$bilan_file, - $this->path_output_files.$corrected_codes_file - ); - if ($ok) { - Configuration::updateValue('TRAINING_BILAN_FILE', $bilan_file); - Configuration::updateValue('TRAINING_CORRECTED_RESULT_FILE', $corrected_results_file); - Configuration::updateValue('TRAINING_CORRECTED_CODES_FILE', $corrected_codes_file); - - $this->context->smarty->assign('bilan_file', Configuration::get('TRAINING_BILAN_FILE')); - $this->context->smarty->assign('corrected_results_file', Configuration::get('TRAINING_CORRECTED_RESULT_FILE')); - $this->context->smarty->assign('corrected_codes_file', Configuration::get('TRAINING_CORRECTED_CODES_FILE')); - - $this->confirmations[] = 'Génération des fichiers "bilan", "résultats corrigés" et "codes corrigés" réussie : -
-
- -
- Retrouvez les liens vers ces fichiers depuis l\'encadré BILAN / RESULTAT CORRIGÉ. - '; - } - else { - $this->errors[] = $this->l(sprintf('Echec du traitement du fichier résultat.')); - - } - } - } - - private function moveUploadedCsvFile($input_name) - { - if (!isset($_FILES[$input_name])) { - return null; - } - - $f = (object)$_FILES[$input_name]; - $f->name = basename($f->name); - $f->path = $this->path_files.$f->name; - - $max_file_size = $this->getFileSizeMax(); - - if ($f->error === UPLOAD_ERR_OK) { - if ($f->size > $max_file_size) { - $f->error = UPLOAD_ERR_FORM_SIZE; - } - } - - if ($f->error !== UPLOAD_ERR_OK) { - $this->errors[] = $this->codeToMessage($f, $max_file_size); - return null; - } - - // ensure it is a CSV - $path_parts = pathinfo($f->path); - if (strtolower($path_parts['extension'])!='csv') { - $this->errors[] = $this->l('Seul un fichier CSV est accepté (extension ".csv").'); - return null; - } - - $success = move_uploaded_file($f->tmp_name,$f->path); - - if (!$success) { - $this->errors[] = $this->l(sprintf('Echec lors l\'envoi du fichier %s.', $f->name)); - return null; - } - - $this->confirmations[] = $this->l(sprintf('Envoi du fichier "%s" réussi.', $f->name)); - - return $f; - } - - private function getFileSizeMax() - { - $max_ini_file_size = ini_get('upload_max_filesize'); - if (preg_match('/G/i', $max_ini_file_size)) { - $max_ini_file_size *= 1000000000; - } - if (preg_match('/M/i', $max_ini_file_size)) { - $max_ini_file_size *= 1000000; - } - if (preg_match('/K/i', $max_ini_file_size)) { - $max_ini_file_size *= 1000; - } - - $max_file_size = Tools::getValue('MAX_FILE_SIZE', $max_ini_file_size); - if ($max_file_size > $max_ini_file_size) { - $max_file_size = $max_ini_file_size; - } - - return $max_file_size; - } - - private function codeToMessage($file, $max_file_size) - { - switch ($file->error) { - case UPLOAD_ERR_INI_SIZE: - $message = $this->l(sprintf('Erreur - Le fichier dépasse la taille maximale autorisée par le serveur : %d octets.', $max_file_size)); - break; - case UPLOAD_ERR_FORM_SIZE: - $message = $this->l(sprintf('Erreur - Le fichier dépasse la taille maximale autorisée : %d octets.', $max_file_size)); - break; - case UPLOAD_ERR_PARTIAL: - $message = $this->l('Erreur - Le fichier a été envoyé partiellement.'); - break; - case UPLOAD_ERR_NO_FILE: - $message = $this->l('Erreur - Merci de sélectionner un fichier.'); - break; - case UPLOAD_ERR_NO_TMP_DIR: - $message = $this->l("Erreur serveur - répertoire temporaire manquant."); - break; - case UPLOAD_ERR_CANT_WRITE: - $message = $this->l("Erreur serveur - répertoire non autorisé en écriture."); - break; - case UPLOAD_ERR_EXTENSION: - $message = $this->l("Erreur - Type de fichier refusé."); - break; - - default: - $message = $this->l("Erreur serveur - Erreur inconnue."); - break; - } - return $message; - } -} diff --git a/modules/training/controllers/admin/AdminTrainingFixedCodeClient.php b/modules/training/controllers/admin/AdminTrainingFixedCodeClient.php deleted file mode 100644 index 0803668..0000000 --- a/modules/training/controllers/admin/AdminTrainingFixedCodeClient.php +++ /dev/null @@ -1,69 +0,0 @@ -table = 'training_fixedcodeclient'; - $this->className = 'TrainingFixedCodeClient'; - $this->identifier = 'id_training_fixedcodeclient'; - $this->lang = FALSE; - $this->deleted = FALSE; - $this->bootstrap = TRUE; - $this->_defaultOrderBy = 'codeclient_from_results'; - - parent::__construct(); - - $this->actions = array('edit'); - - $this->fields_list = array( - 'id_training_fixedcodeclient' => array( - 'title' => 'ID', - 'width' => 40 - ), - 'codeclient_from_results' => array( - 'title' => $this->module->l('Code client trouvé dans les résultats'), - 'width' => 200, - ), - 'codeclient_fixed' => array( - 'title' => $this->module->l('Code client corrigé'), - 'width' => 150, - ), - ); - } - - public function renderView() - { - return $this->renderList(); - } - - public function renderForm() - { - $this->fields_form = array( - 'submit' => array( - 'name' => 'submitTrainingFixedCodeClient', - 'title' => $this->l('Save'), - ), - 'input' => array( - array( - 'type' => 'text', - 'label' => $this->l('Code client trouvé dans les résultats'), - 'name' => 'codeclient_from_results', - 'required' => TRUE, - 'lang' => FALSE, - 'size' => 128 - ), - array( - 'type' => 'text', - 'label' => $this->l('Code client corrigé'), - 'name' => 'codeclient_fixed', - 'required' => TRUE, - 'lang' => FALSE, - 'size' => 128 - ), - ) - ); - - return parent::renderForm(); - } -} \ No newline at end of file diff --git a/modules/training/controllers/admin/AdminTrainingModules.php b/modules/training/controllers/admin/AdminTrainingModules.php deleted file mode 100644 index 26ec8b1..0000000 --- a/modules/training/controllers/admin/AdminTrainingModules.php +++ /dev/null @@ -1,69 +0,0 @@ -table = 'training_module'; - $this->className = 'TrainingModule'; - $this->identifier = 'id_training_module'; - $this->lang = FALSE; - $this->deleted = FALSE; - $this->bootstrap = TRUE; - $this->_defaultOrderBy = 'category_name'; - - parent::__construct(); - - $this->actions = array('edit', 'delete'); - - $this->fields_list = array( - 'id_training_module' => array( - 'title' => 'ID', - 'width' => 40 - ), - 'module_name' => array( - 'title' => $this->module->l('Module'), - 'width' => 150, - ), - 'category_name' => array( - 'title' => $this->module->l('Catégorie'), - 'width' => 150, - ), - ); - } - - public function renderView() - { - return $this->renderList(); - } - - public function renderForm() - { - $this->fields_form = array( - 'submit' => array( - 'name' => 'submitTrainingModule', - 'title' => $this->l('Save'), - ), - 'input' => array( - array( - 'type' => 'text', - 'label' => $this->l('Libellé module'), - 'name' => 'module_name', - 'required' => TRUE, - 'lang' => FALSE, - 'size' => 128 - ), - array( - 'type' => 'text', - 'label' => $this->l('Libellé catégorie'), - 'name' => 'category_name', - 'required' => TRUE, - 'lang' => FALSE, - 'size' => 128 - ), - ) - ); - - return parent::renderForm(); - } -} \ No newline at end of file diff --git a/modules/training/controllers/admin/AdminTrainingPharmacy.php b/modules/training/controllers/admin/AdminTrainingPharmacy.php deleted file mode 100644 index 2bff340..0000000 --- a/modules/training/controllers/admin/AdminTrainingPharmacy.php +++ /dev/null @@ -1,35 +0,0 @@ -table = 'training_pharmacy'; - $this->className = 'TrainingPharmacy'; - $this->identifier = 'id_training_pharmacy'; - $this->lang = FALSE; - $this->deleted = FALSE; - $this->bootstrap = TRUE; - $this->_defaultOrderBy = 'codeclient'; - - parent::__construct(); - - $this->actions = array(); - - $this->fields_list = array( - 'id_training_pharmacy' => array( - 'title' => 'ID', - 'width' => 40 - ), - 'codeclient' => array( - 'title' => $this->module->l('Code client'), - 'width' => 150, - ), - ); - } - - public function renderView() - { - return $this->renderList(); - } -} \ No newline at end of file diff --git a/modules/training/index.php b/modules/training/index.php deleted file mode 100644 index 52b4e5c..0000000 --- a/modules/training/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/modules/training/logo.gif b/modules/training/logo.gif deleted file mode 100644 index 12cd1ae..0000000 Binary files a/modules/training/logo.gif and /dev/null differ diff --git a/modules/training/logo.png b/modules/training/logo.png deleted file mode 100644 index c6b7e8c..0000000 Binary files a/modules/training/logo.png and /dev/null differ diff --git a/modules/training/models/ArrayExtended.php b/modules/training/models/ArrayExtended.php deleted file mode 100644 index ebeba71..0000000 --- a/modules/training/models/ArrayExtended.php +++ /dev/null @@ -1,46 +0,0 @@ -collection = $ar; - } - - function toArray() - { - return $this->collection; - } - - function getIterator() - { - return new ArrayIterator($this->collection); - } - - function offsetExists($offset) - { - return isset($this->collection[$offset]); - } - - function offsetSet($offset, $value) - { - if (is_null($offset)) { - $this->collection[] = $value; - } - elseif (!empty($offset)) { - $this->collection[$offset] = $value; - } - } - - function offsetUnset($offset) - { - unset($this->collection[$offset]); - } - - function offsetGet($offset) - { - return isset($this->collection[$offset])?$this->collection[$offset]:null; - } -} - diff --git a/modules/training/models/CSVReader.php b/modules/training/models/CSVReader.php deleted file mode 100644 index cd4a933..0000000 --- a/modules/training/models/CSVReader.php +++ /dev/null @@ -1,140 +0,0 @@ - false, 'auto_detect'=>true, 'separator' => ',', 'enclosure' => '"', 'expected_header' => array()); - private $handlers = array('start' => null, 'error' => null); - private $current_num_line = 0; - private $expected_cols_index = array(); - - function __construct($file_path) - { - $this->file_path = $file_path; - $this->handlers = array( - 'start' => function() {}, - 'error' => function($failed_line_number) {}, - 'readline' => function(ArrayExtended $cols) { return true; } - ); - } - - function setExpectedHeader(array $expected_header) - { - $this->params['expected_header'] = $expected_header; - return $this; - } - - function enableSkipHeader() - { - $this->params['enable_skip_line'] = true; - return $this; - } - - // func : function() - function setOnStart(callable $func) - { - $this->handlers['start'] = $func; - return $this; - } - - // func : function(ArrayExtended $columns) - function setOnEachLine(callable $func) - { - $this->handlers['readline'] = $func; - return $this; - } - - // func : function(int failed_line_number) - function setOnError(callable $func) - { - $this->handlers['error'] = $func; - return $this; - } - - function readLines() - { - $ok = false; - $this->current_num_line = 0; - - if ($this->params['auto_detect']) { - $this->autoDetect($this->file_path); - } - - $f = fopen($this->file_path, 'r'); - if ($f) { - call_user_func($this->handlers['start']); - - $ok = true; - if ($this->params['enable_skip_line'] || count($this->params['expected_header'])>0) { - $ok = $this->checkHeader(fgetcsv($f, 0, $this->params['separator'], $this->params['enclosure'])); - } - - while ($ok && ($cols = fgetcsv($f, 0, $this->params['separator'], $this->params['enclosure']))) { - $real_cols = array(); - - foreach($this->expected_cols_index as $real_index => $index) { - $real_cols[$index] = $cols[$real_index]; - } - $ok = call_user_func($this->handlers['readline'], new ArrayExtended($real_cols)); - $this->current_num_line++; - } - - fclose($f); - } - - if (!$ok) { - call_user_func($this->handlers['error'], $this->current_num_line); - } - - return $ok; - } - - private function checkHeader(array $cols) - { - $ok = true; - - foreach($this->params['expected_header'] as $expected_col => $expected_pos) { - $found = false; - foreach($cols as $index => $col) { - if (strtolower($col) == strtolower($expected_col)) { - $this->expected_cols_index[$index] = $expected_pos; - $found = true; - break; - } - } - $ok = $ok && $found; - } - - return $ok; - } - - private function autoDetect($file_path) - { - if ($f = fopen($file_path, 'r')) { - $line = fgets($f); - - if ($line[0] == '"') { - $line[0] = ''; - $line = str_replace("\\\"", '', $line); - $line = str_replace("\"\"", '', $line); - $line = strstr($line, '"'); - if (strlen($line)>1) { - $this->params['separator'] = $line[1]; - } - } - else { - if (strpos($line, ';')!==false) { - $this->params['separator'] = ';'; - } - elseif (strpos($line, ',')!==false) { - $this->params['separator'] = ','; - } - elseif (strpos($line, '|')!==false) { - $this->params['separator'] = '|'; - } - } - - fclose($f); - } - } -} diff --git a/modules/training/models/CSVWriter.php b/modules/training/models/CSVWriter.php deleted file mode 100644 index a2fda79..0000000 --- a/modules/training/models/CSVWriter.php +++ /dev/null @@ -1,107 +0,0 @@ -file_path = $file_path; - } - - function setHeader(array $line) - { - $this->header = $line; - return $this; - } - - function addLine(array $line) - { - $this->lines[] = $line; - return $this; - } - - function setFooter(array $line) - { - $this->footer = $line; - return $this; - } - - function sortBy($index_column, $ascendant=true) - { - usort($this->lines, - function(array $a, array $b) use ($index_column, $ascendant) { - if ($a[$index_column] < $b[$index_column]) { - return $ascendant?-1:1; - } - else if ($a[$index_column] > $b[$index_column]) { - return $ascendant?1:-1; - } - else { - return 0; - } - }); - return $this; - } - - function save() - { - if (empty($this->buffer)) { - $this->flush(); - } - - $f = fopen($this->file_path, 'w'); - if ($f) { - fwrite($f, $this->buffer); - fclose($f); - } - - return $this; - } - - function outputForDownload() - { - if (empty($this->buffer)) { - $this->flush(); - } - - header("Pragma: public"); - header("Expires: 0"); - header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); - header("Cache-Control: private",false); - header("Content-Type: text/csv"); - header("Content-Disposition: attachment; filename=\"".basename($this->file_path)."\";" ); - header("Content-Transfer-Encoding: binary"); - exit($this->buffer); - } - - private function flush() - { - $output = fopen('php://output', 'w'); - - ob_start(); - - if (is_array($this->header)) { - fwrite($output, implode(',', $this->header).PHP_EOL); - } - - foreach($this->lines as $line) { - fwrite($output, implode(',', $line).PHP_EOL); - } - - if (is_array($this->footer)) { - fwrite($output, implode(',', $this->footer).PHP_EOL); - } - - $this->buffer = ob_get_clean(); - - return $this; - } - -} diff --git a/modules/training/models/TrainingBilan.php b/modules/training/models/TrainingBilan.php deleted file mode 100644 index 0b8c496..0000000 --- a/modules/training/models/TrainingBilan.php +++ /dev/null @@ -1,207 +0,0 @@ - self::COL_MODULE_NAME, - 'Code Client' => self::COL_CODE_CLIENT, - 'Prenom' => self::COL_FIRSTNAME, - 'NOM' => self::COL_LASTNAME, - 'Telephone' => self::COL_TEL, - 'Nom pharmacie' => self::COL_PHARMACY, - 'Ville' => self::COL_CITY, - 'Date' => self::COL_ATTEMPT_DATE, - 'Slides Vues' => self::COL_TOTAL_VIEWED, - 'Total Slides' => self::COL_TOTAL_SLIDES, - ); - - self::$bilan = array(); - self::$pharmacies_notfound = array(); - - self::$modules = TrainingModule::loadAll(); - self::$pharmacies = TrainingPharmacy::loadAll(); - self::$pharmacies_fixeds = TrainingFixedCodeClient::loadOnlyFixed(); - - - // Read the imported result file - $reader = new CSVReader($result_file_path); - $ok = $reader->enableSkipHeader() - ->setExpectedHeader($expectedHeader) - ->setOnEachLine("TrainingBilan::computeLineResult") - ->readLines(); - - if (!$ok) { - return false; - } - - // Add all (maybe new) incorrect codes - TrainingFixedCodeClient::addIfNotExist(self::$pharmacies_notfound); - - // Export the correct result file in the same format (with 1 additionnal column) - $newHeader = $expectedHeader + array('Validé' => self::COL_VALIDE); - $csv_output = new CSVWriter($output_corrected_result_file_path); - self::exportCorrectedResults($newHeader, $csv_output); - $csv_output->save(); - - // Export the corrected codes file in the same format of the codes clients file imported in class TrainingFixedCodeClient - TrainingFixedCodeClient::exportIntoCsvFile($output_corrected_codes_file_path); - - // Export the "bilan" - $csv_output = new CSVWriter($output_bilan_file_path); - self::exportResults($csv_output); - $csv_output->sortBy(self::OUTPUT_COLUMN_CODECLIENT); - $csv_output->save(); - - return true; - } - - static function computeLineResult(ArrayExtended $cols) - { - $code_client = strtolower($cols[self::COL_CODE_CLIENT]); - $low_module_name = strtolower($cols[self::COL_MODULE_NAME]); - - if (empty($code_client)) { - $code_client = TrainingFixedCodeClient::CODE_EMPTY; - } - - // for the current code found in result file, - // retrive the corrected one if any - // or add it in the list of not found ones - if (!isset(self::$pharmacies[$code_client])) { - - if (!isset(self::$pharmacies_fixeds[$code_client])) { - self::$pharmacies_notfound[$code_client] = 1; - // continue reading CSV - // don't add this code into the corrected result list - return true; - } - - $code_client = self::$pharmacies_fixeds[$code_client]; - } - - // create the line in the bilan - if (!isset(self::$bilan[$code_client])) { - self::$bilan[$code_client] = array(); - } - - if (!isset(self::$bilan[$code_client][$low_module_name])) { - self::$bilan[$code_client][$low_module_name] = 0; - } - - // update the "success" total for the current code - if (($cols[self::COL_TOTAL_SLIDES] - $cols[self::COL_TOTAL_VIEWED]) <= self::TOTAL_MARGIN) { - self::$bilan[$code_client][$low_module_name]++; - $cols[self::COL_VALIDE] = 'oui'; - } - else { - $cols[self::COL_VALIDE] = 'non'; - } - - // add the result line in the corrected results list (with the corrected code) - $cols[self::COL_CODE_CLIENT] = $code_client; - self::$results_corrected[] = $cols->toArray(); - - // continue reading CSV - return true; - } - - static function exportCorrectedResults(array $header, CSVWriter $csv_output) - { - $csv_output->setHeader(array_keys($header)); - foreach(self::$results_corrected as $row) { - $csv_output->addLine($row); - } - } - - static function exportResults(CSVWriter $csv_output) - { - // init total and export header - $total = array(); - $row = array('Codes clients'); - foreach (self::$modules as $category_name => $category_modules) { - foreach ($category_modules as $module_name) { - $row[] = $module_name; - $total[$module_name] = 0; - } - $row[] = 'Module '.$category_name; - $total[$category_name] = 0; - } - $csv_output->setHeader($row); - - // export lines - foreach (self::$bilan as $code_client => $results) { - $row = array($code_client); - foreach (self::$modules as $category_name => $category_modules) { - - $result_min = -1; - foreach ($category_modules as $module_name) { - - $low_module_name = strtolower($module_name); - if (!isset($results[$low_module_name])) { - $result_min = 0; - $result = 0; - } - else { - if ($result_min == -1 || $result_min > $results[$low_module_name]) { - $result_min = $results[$low_module_name]; - } - $result = $results[$low_module_name]; - } - $row[] = $result; - $total[$module_name] += $result; - } - - $row[] = $result_min; - $total[$category_name] += $result_min; - } - $csv_output->addLine($row); - } - - // export total - $row = array('Total général'); - foreach (self::$modules as $category_name => $category_modules) { - foreach ($category_modules as $module_name) { - $row[] = $total[$module_name]; - } - $row[] = $total[$category_name]; - } - $csv_output->setFooter($row); - } -} diff --git a/modules/training/models/TrainingFixedCodeClient.php b/modules/training/models/TrainingFixedCodeClient.php deleted file mode 100644 index d6451d6..0000000 --- a/modules/training/models/TrainingFixedCodeClient.php +++ /dev/null @@ -1,158 +0,0 @@ -self::CODE_CLIENT_WRONG, - 'CC bon'=>self::CODE_CLIENT_RIGHT - ); - - public static $definition = array( - 'table' => 'training_fixedcodeclient', - 'primary' => 'id_training_fixedcodeclient', - 'multilang' => false, - 'fields' => array( - 'id_training_fixedcodeclient' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), - 'codeclient_from_results' => array('type' => self::TYPE_STRING, 'lang' => false, 'validate' => 'isString'), - 'codeclient_fixed' => array('type' => self::TYPE_STRING, 'lang' => false, 'validate' => 'isString'), - ), - ); - - static function exportIntoCsvFile($file_path) - { - $csv_output = new CSVWriter($file_path); - - $csv_output->setHeader(array_keys(self::$header)); - - $sql = 'SELECT `codeclient_from_results`, `codeclient_fixed` - FROM `'._DB_PREFIX_.'training_fixedcodeclient` - '; - foreach (Db::getInstance()->executeS($sql) as $row) { - $csv_output->addLine(array($row['codeclient_from_results'], $row['codeclient_fixed'])); - } - - $csv_output->save(); - } - - static function importFromCsvFile($file_path) - { - $imported_codes = array(); - - $reader = new CSVReader($file_path); - $ok = $reader - ->setExpectedHeader(self::$header) - ->setOnEachLine(function(ArrayExtended $cols) use (&$imported_codes) { - $wrong_code = strtolower((string)$cols[self::CODE_CLIENT_WRONG]); - $right_code = strtolower((string)$cols[self::CODE_CLIENT_RIGHT]); - - if (empty($wrong_code)) { - $wrong_code = self::CODE_EMPTY; - } - $imported_codes[$wrong_code] = $right_code; - return true; - }) - ->readLines(); - - if ($ok && count($imported_codes)>0) { - - $existing_codes = array(); - - // load all already saved codes - foreach (Db::getInstance()->executeS(' - SELECT `codeclient_from_results`, `codeclient_fixed` - FROM `'._DB_PREFIX_.'training_fixedcodeclient` - ') as $row) { - $existing_codes[$row['codeclient_from_results']] = $row['codeclient_fixed']; - } - - // insert new wrong codes with their correction - $values = array(); - foreach(array_diff_key($imported_codes, $existing_codes) as $wrong_code => $right_code) { - $values[] = '(\''.pSql($wrong_code).'\', \''.pSql($right_code).'\')'; - } - - if (count($values)>0) { - $ok = Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'training_fixedcodeclient` - (`codeclient_from_results`, `codeclient_fixed`) - VALUES - '.implode(',', $values).' - '); - } - - // replace existing uncorrected code with their correction - foreach(array_intersect_key($imported_codes, $existing_codes) as $wrong_code => $right_code) { - $ok = $ok && Db::getInstance()->execute(' - UPDATE `'._DB_PREFIX_.'training_fixedcodeclient` - SET `codeclient_fixed` = \''.pSql($right_code).'\' - WHERE `codeclient_from_results` = \''.pSql($wrong_code).'\' - '); - } - } - unset($imported_codes); - - return $ok; - } - - static function loadOnlyFixed() - { - $result = new ArrayExtended(); - - $sql = 'SELECT `codeclient_from_results`, `codeclient_fixed` - FROM `'._DB_PREFIX_.'training_fixedcodeclient` - WHERE codeclient_fixed <> \'\''; - foreach (Db::getInstance()->executeS($sql) as $row) { - $result[$row['codeclient_from_results']] = $row['codeclient_fixed']; - } - - return $result; - } - - static function addIfNotExist(array $pharmacies_not_found) - { - // get already saved codes to correct - $existing_codes = array(); - - $sql = 'SELECT LOWER(`codeclient_from_results`) as `codeclient_from_results` - FROM `'._DB_PREFIX_.'training_fixedcodeclient`'; - foreach (Db::getInstance()->executeS($sql) as $row) { - $existing_codes[] = $row['codeclient_from_results']; - } - - // remove duplicate keys - $unique_pharmacies_not_found = array(); - foreach ($pharmacies_not_found as $key => $val) { - $key = strtolower($key); - if (!isset($unique_pharmacies_not_found[$key])) { - $unique_pharmacies_not_found[$key] = $val; - } - } - - $unique_pharmacies_not_found = array_keys($unique_pharmacies_not_found); - - // filter new codes not already present in DB (and create the SQL value string) - $values = array(); - foreach(array_diff($unique_pharmacies_not_found, $existing_codes) as $code_client) { - $values[] = '\''.pSql((string)$code_client).'\', \'\''; - } - - // if any new codes, add them - if (count($values)>0) { - Db::getInstance()->execute( - 'INSERT INTO `'._DB_PREFIX_.'training_fixedcodeclient` - (codeclient_from_results, codeclient_fixed) - VALUES - ('.implode('),(', $values).')' - ); - } - } -} \ No newline at end of file diff --git a/modules/training/models/TrainingModule.php b/modules/training/models/TrainingModule.php deleted file mode 100644 index d74174d..0000000 --- a/modules/training/models/TrainingModule.php +++ /dev/null @@ -1,88 +0,0 @@ - 'training_module', - 'primary' => 'id_training_module', - 'multilang' => false, - 'fields' => array( - 'id_training_module' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), - 'module_name' => array('type' => self::TYPE_STRING, 'lang' => false, 'validate' => 'isString'), - 'category_name' => array('type' => self::TYPE_STRING, 'lang' => false, 'validate' => 'isString'), - ), - ); - - private static $failed_line_number = 0; - - static function importFromCsvFile($file_path) - { - $values = array(); - - $reader = new CSVReader($file_path); - $ok = $reader - ->enableSkipHeader() - ->setExpectedHeader(array( - 'Modules' => self::MODULE_NAME, - 'Catégories'=>self::CATEGORY_NAME - )) - ->setOnStart(function() { - self::deleteAll(); - }) - ->setOnEachLine(function(ArrayExtended $cols) use (&$values) { - $values[] = '\''.pSql((string)$cols[self::MODULE_NAME]).'\', \''.pSql((string)$cols[self::CATEGORY_NAME]).'\''; - return true; - }) - ->setOnError(function($failed_line_number) { - self::$failed_line_number = $failed_line_number; - self::deleteAll(); - }) - ->readLines(); - - if ($ok && count($values)>0) { - $ok = Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'training_module` - (`module_name`, `category_name`) - VALUES - ('.implode('),(', $values).') - '); - } - unset($values); - return $ok; - } - - static function deleteAll() - { - Db::getInstance()->execute('TRUNCATE `'._DB_PREFIX_.'training_module`'); - } - - static function hasAnyRow() - { - return Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'training_module`') > 0; - } - - static function loadAll() - { - $result = array(); - - $sql = 'SELECT `module_name`, `category_name` - FROM `'._DB_PREFIX_.'training_module` - ORDER BY `category_name` ASC, `module_name` ASC'; - foreach (Db::getInstance()->executeS($sql) as $row) { - if (!isset($result[$row['category_name']])) { - $result[$row['category_name']] = array(); - } - $result[$row['category_name']][] = $row['module_name']; - } - - return new ArrayExtended($result); - } -} \ No newline at end of file diff --git a/modules/training/models/TrainingPharmacy.php b/modules/training/models/TrainingPharmacy.php deleted file mode 100644 index 476dc75..0000000 --- a/modules/training/models/TrainingPharmacy.php +++ /dev/null @@ -1,81 +0,0 @@ - 'training_pharmacy', - 'primary' => 'id_training_pharmacy', - 'multilang' => false, - 'fields' => array( - 'id_training_pharmacy' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), - 'codeclient' => array('type' => self::TYPE_STRING, 'lang' => false, 'validate' => 'isString'), - ), - ); - - private static $failed_line_number = 0; - - static function importFromCsvFile($file_path) - { - $values = array(); - - $reader = new CSVReader($file_path); - $ok = $reader - ->enableSkipHeader() - ->setExpectedHeader(array( - 'CodeClt'=>self::CODE_CLIENT - )) - ->setOnStart(function() { - self::deleteAll(); - }) - ->setOnEachLine(function(ArrayExtended $cols) use (&$values) { - $values[] = '\''.pSql((string)$cols[self::CODE_CLIENT]).'\''; - return true; - }) - ->setOnError(function($failed_line_number) { - self::$failed_line_number = $failed_line_number; - self::deleteAll(); - }) - ->readLines(); - - if ($ok && count($values)>0) { - $ok = Db::getInstance()->execute(' - INSERT INTO `'._DB_PREFIX_.'training_pharmacy` - (`codeclient`) - VALUES - ('.implode('),(', $values).') - '); - } - unset($values); - - return $ok; - } - - static function deleteAll() - { - Db::getInstance()->execute('TRUNCATE `'._DB_PREFIX_.'training_pharmacy`'); - } - - static function hasAnyRow() - { - return Db::getInstance()->getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'training_pharmacy`') > 0; - } - - static function loadAll() - { - $result = new ArrayExtended(); - - $sql = 'SELECT `codeclient`, `id_training_pharmacy` - FROM `'._DB_PREFIX_.'training_pharmacy`'; - foreach (Db::getInstance()->executeS($sql) as $row) { - $result[$row['codeclient']] = $row['id_training_pharmacy']; - } - - return $result; - } -} \ No newline at end of file diff --git a/modules/training/output/index.php b/modules/training/output/index.php deleted file mode 100644 index 52b4e5c..0000000 --- a/modules/training/output/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/modules/training/test.php b/modules/training/test.php deleted file mode 100644 index 5dffd1b..0000000 --- a/modules/training/test.php +++ /dev/null @@ -1,68 +0,0 @@ -"; - print_r($var); - echo ""; -} - -$original = new ArrayExtended(); -$original_score = new ArrayExtended(); - -$reader = new CSVReader(__DIR__.'/upload/Bilan_original.csv'); -$reader ->skipHeader() - ->onEachLine(function(ArrayExtended $cols) use($original, $original_score) { - $original[] = $cols[0]; - $original_score[] = $cols[1]; - return true; - }) - ->onError(function($failed_num_line) { - debug($failed_num_line); - }) - ->read(); - -$new_version = new ArrayExtended(); -$new_version_score = new ArrayExtended(); - -$reader = new CSVReader(__DIR__.'/upload/BILAN.csv'); -$reader ->skipHeader() - ->setDelimiter("\"") - ->onEachLine(function(ArrayExtended $cols) use($new_version, $new_version_score) { - $new_version[] = $cols[0]; - $new_version_score[] = $cols[1]; - return true; - }) - ->onError(function($failed_num_line) { - debug($failed_num_line); - }) - ->read(); - -$original = $original->toArray(); -$original_score = $original_score->toArray(); -$new_version = $new_version->toArray(); -$new_version_score = $new_version_score->toArray(); - -//debug($new_version); - -//debug(array_diff_assoc($new_version, $original)); -//debug(array_diff_assoc($original, $new_version)); -$diff = array(); -foreach(array_diff($original, $new_version) as $i => $code_client) { - $diff[$code_client] = $original_score[$i]; -} - -debug($diff); -/* -$diff = array(); -foreach(array_diff($new_version, $original) as $i => $code_client) { - $diff[$code_client] = $new_version_score[$i]; -} - -debug($diff); -*/ \ No newline at end of file diff --git a/modules/training/training.php b/modules/training/training.php deleted file mode 100644 index 4aef069..0000000 --- a/modules/training/training.php +++ /dev/null @@ -1,167 +0,0 @@ -name = 'training'; - $this->tab = 'administration'; - $this->version = '1.0'; - $this->author = 'Antadis'; - $this->need_instance = 0; - - parent::__construct(); - - $this->displayName = $this->l('Analyse formation en ligne'); - $this->description = $this->l('Permet d\'importer les résultats de la formation en ligne et d\'en extraire un bilan'); - $this->confirmUninstall = $this->l('Etes vous sur de vouloir désinstaller ce module ?'); - } - - public function install() - { - if (!parent::install()) { - return false; - } - - - $queries = array( - 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'training_module` ( - `id_training_module` int(11) NOT NULL AUTO_INCREMENT, - `module_name` VARCHAR(255) NOT NULL, - `category_name` VARCHAR(255) NOT NULL, - PRIMARY KEY (`id_training_module`), - UNIQUE(`module_name`) - - ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8', - - 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'training_pharmacy` ( - `id_training_pharmacy` int(11) NOT NULL AUTO_INCREMENT, - `codeclient` VARCHAR(255) NOT NULL, - PRIMARY KEY (`id_training_pharmacy`) - - ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8', - - 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'training_fixedcodeclient` ( - `id_training_fixedcodeclient` int(11) NOT NULL AUTO_INCREMENT, - `codeclient_from_results` VARCHAR(255) NOT NULL, - `codeclient_fixed` VARCHAR(255) NOT NULL, - PRIMARY KEY (`id_training_fixedcodeclient`), - UNIQUE(`codeclient_from_results`) - - ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8' - ); - - if (!self::dbExecute($queries)) { - $this->uninstall(); - return false; - } - - $tab = new Tab(); - $tab->class_name = 'AdminTrainingRoot'; - $tab->id_parent = 0; - $tab->module = $this->name; - $tab->name[(int)Configuration::get('PS_LANG_DEFAULT')] = $this->l('Analyse formation en ligne'); - - if (!$tab->add()) { - $this->uninstall(); - return false; - } - - $tab = new Tab(); - $tab->class_name = 'AdminTraining'; - $tab->id_parent = (int)Tab::getIdFromClassName('AdminTrainingRoot'); - $tab->module = $this->name; - $tab->name[(int)Configuration::get('PS_LANG_DEFAULT')] = $this->l('Analyse formation en ligne'); - - if (!$tab->add()) { - $this->uninstall(); - return false; - } - - $tab = new Tab(); - $tab->class_name = 'AdminTrainingModules'; - $tab->id_parent = (int)Tab::getIdFromClassName('AdminTrainingRoot'); - $tab->module = $this->name; - $tab->name[(int)Configuration::get('PS_LANG_DEFAULT')] = $this->l('Modules/Catégories formation'); - - if (!$tab->add()) { - $this->uninstall(); - return false; - } - - $tab = new Tab(); - $tab->class_name = 'AdminTrainingPharmacy'; - $tab->id_parent = (int)Tab::getIdFromClassName('AdminTrainingRoot'); - $tab->module = $this->name; - $tab->name[(int)Configuration::get('PS_LANG_DEFAULT')] = $this->l('Pharmacies'); - - if (!$tab->add()) { - $this->uninstall(); - return false; - } - - $tab = new Tab(); - $tab->class_name = 'AdminTrainingFixedCodeClient'; - $tab->id_parent = (int)Tab::getIdFromClassName('AdminTrainingRoot'); - $tab->module = $this->name; - $tab->name[(int)Configuration::get('PS_LANG_DEFAULT')] = $this->l('Correction codes clients'); - - if (!$tab->add()) { - $this->uninstall(); - return false; - } - - - return true; - } - - public function uninstall() - { - self::dbExecute(array( - 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'training_module`', - 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'training_pharmacy`', - 'DROP TABLE IF EXISTS `'._DB_PREFIX_.'training_fixedcodeclient`' - )); - - Configuration::deleteByName('TRAINING_USED_MODULE_FILE'); - Configuration::deleteByName('TRAINING_USED_PHARMACY_FILE'); - Configuration::deleteByName('TRAINING_USED_RESULT_FILE'); - Configuration::deleteByName('TRAINING_FIXEDCODES_FILE'); - Configuration::deleteByName('TRAINING_BILAN_FILE'); - Configuration::deleteByName('TRAINING_CORRECTED_RESULT_FILE'); - Configuration::deleteByName('TRAINING_CORRECTED_CODES_FILE'); - - - - $tab = new Tab(Tab::getIdFromClassName('AdminTrainingFixedCodeClient')); - $tab->delete(); - - $tab = new Tab(Tab::getIdFromClassName('AdminTrainingPharmacy')); - $tab->delete(); - - $tab = new Tab(Tab::getIdFromClassName('AdminTrainingModules')); - $tab->delete(); - - $tab = new Tab(Tab::getIdFromClassName('AdminTraining')); - $tab->delete(); - - $tab = new Tab(Tab::getIdFromClassName('AdminTrainingRoot')); - $tab->delete(); - - return parent::uninstall(); - } - - private static function dbExecute(array $queries){ - foreach($queries as $query){ - if( !Db::getInstance()->execute($query)){ - return false; - } - } - return true; - } -} diff --git a/modules/training/upload/index.php b/modules/training/upload/index.php deleted file mode 100644 index 52b4e5c..0000000 --- a/modules/training/upload/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2013 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/modules/training/views/templates/admin/training/home.tpl b/modules/training/views/templates/admin/training/home.tpl deleted file mode 100644 index ee8ee49..0000000 --- a/modules/training/views/templates/admin/training/home.tpl +++ /dev/null @@ -1,172 +0,0 @@ -

{l s='Analyse de formations en ligne' mod='training'}

- -
-- L'intitulé des colonnes des fichiers doit être identique à ce qui est indiqué dans les commentaires "Entête/colonnes obligatoires" (à l'espace près entre les termes).
-La casse n'a pas d'importante (majuscules / minuscules). -

-- Les noms de catégories et modules doivent être identiques entre le fichier "modules/catégories" et le fichier "résultats" -sinon le générateur de bilan ne pourra pas retrouver ces informations. -
-La casse n'a pas d'importante ici aussi (majuscules / minuscules). -
-
-
- -
-
- {l s='1 - Modules/Catégories' mod='training'} - - -
- - - Modules
- - Catégories -
-
- - -
- -
- -
- -
- - - {if isset($used_module_file) && $used_module_file!=''} - - {else} -
aucun
- {/if} -
-
-
- -
-
- {l s='2 - Pharmacies' mod='training'} - - -
- - - CodeClt
-
-
- - -
- -
- -
- -
- - - {if isset($used_pharmacy_file) && $used_pharmacy_file!=''} - - {else} -
- aucun -
- {/if} -
-
- -
- -
-
- {l s='3 - Codes corrigés (facultatif)' mod='training'} - - -
- - - CC faux
- - CC bon -
-
- - -
- -
- -
- -
- - - {if isset($used_fixedcodes_file) && $used_fixedcodes_file!=''} - - {else} -
- aucun -
- {/if} -
-
- -
- -
- {l s='LE BILAN' mod='training'} -
- - -
- - - Module
- - Code Client
- - Prenom
- - NOM
- - Telephone
- - Nom pharmacie
- - Ville
- - Date
- - Slides Vues
- - Total Slides
-
-
- - -
- - (taille max : 16 Mo) -
- -
- -
- - - {if isset($used_results_file) && $used_results_file!=''} - - {else} -
- aucun -
- {/if} - -
-
-
- -
-
- -
- - -
-
diff --git a/override/classes/Cart.php b/override/classes/Cart.php index a1852e6..4161547 100755 --- a/override/classes/Cart.php +++ b/override/classes/Cart.php @@ -579,11 +579,23 @@ class Cart extends CartCore { $UPS_ids_reference = array('34', '49'); + $current_id_address_delivery = $this->id_address_delivery; + + // in case tho delivery is already selected, check for the default adress of the customer + if (empty($current_id_address_delivery)) { + $current_id_address_delivery = Address::getFirstCustomerAddressId($this->id_customer); + } + + // in case no adresse has been specified + if (empty($current_id_address_delivery)) { + return ''; + } + // get all carrier reference for the current select address' zone delivery $sql = 'SELECT `id_reference` FROM `'._DB_PREFIX_.'carrier` c JOIN `'._DB_PREFIX_.'carrier_zone` cz ON cz.`id_carrier` = c.`id_carrier` - WHERE cz.`id_zone` = '.(int)Address::getZoneById($this->id_address_delivery).' + WHERE cz.`id_zone` = '.(int)Address::getZoneById($current_id_address_delivery).' AND c.`active` = 1 AND c.`deleted` = 0'; $rows = Db::getInstance()->executeS($sql); @@ -608,7 +620,7 @@ class Cart extends CartCore // we exclude this product when UPS is not in its limited list of carriers if (0 == count(array_intersect($UPS_ids_reference, array_column($rows, 'id_carrier_reference')))) { - return trim($product['name']); + return $product; } } } diff --git a/override/controllers/front/OrderController.php b/override/controllers/front/OrderController.php index 4b2b7e9..2f78d92 100755 --- a/override/controllers/front/OrderController.php +++ b/override/controllers/front/OrderController.php @@ -26,32 +26,93 @@ class OrderController extends OrderControllerCore { + private function noticeWhenContainProductToExclude() + { + $restricted_product = $this->context->cart->getExcludedUPSProductNameForUPSDelivery(); + if (is_array($restricted_product)) { + if ($this->context->language->id == 1) { + $txt = sprintf('"%s" est un soin qui ne peut malheureusement pas être transporté par voie aérienne. Afin de poursuivre votre commande, il sera retiré de votre panier à l\'étape "Ma livraison".', trim($restricted_product['name'])); + } + else { + $txt = sprintf('"%s" cannot be carried by plane. In order to continue your order, it will be removed from your basket at the step "My Delivery".', trim($restricted_product['name'])); + } + $this->context->smarty->assign('restricted_product_txt', $txt); + $this->context->smarty->assign('restricted_product_id', $restricted_product['id_product']); + } + } + + private function updateCartWhenContainProductToExclude() + { + $restricted_product = $this->context->cart->getExcludedUPSProductNameForUPSDelivery(); + if (is_array($restricted_product)) { + if ($this->context->language->id == 1) { + $txt = sprintf('"%s" est un soin qui ne peut malheureusement pas être transporté par voie aérienne. Afin de poursuivre votre commande, nous l\'avons retiré de votre panier. Si vous changez de pays de livraison, il vous faudra remettre "%s" dans votre panier.', trim($restricted_product['name']), trim($restricted_product['name'])); + } + else { + $txt = sprintf('"%s" cannot be carried by plane. We remove the product from your basket so that you can resume your order. If you change the delivery country, you have to include again "%s" in your basket.', trim($restricted_product['name']), trim($restricted_product['name'])); + } + $this->addCookieRestrictedProductText($txt); + $this->context->smarty->assign('restricted_product_txt', $txt); + $this->context->cart->deleteProduct($restricted_product['id_product']); + } + } + + private function getCookieRestrictedProductText() + { + if (isset($this->context->cookie->restricted_product_txt)) { + return $this->context->cookie->restricted_product_txt; + } + return ''; + } + + private function addCookieRestrictedProductText($txt) + { + $this->context->cookie->restricted_product_txt = $txt; + } + + private function removeCookieRestrictedProductText() + { + if (isset($this->context->cookie->restricted_product_txt)) { + unset($this->context->cookie->restricted_product_txt); + } + } + public function postProcess() { // Update carrier selected on preProccess in order to fix a bug of // block cart when it's hooked on leftcolumn - if(Tools::isSubmit('submitPanier')){ + if(Tools::isSubmit('submitPanier')) { $echantillons_ids_product=$_POST['echantillon']; // Rajouter les échantillons dans le panier if (!$this->context->cart->saveEchantillons($echantillons_ids_product)) { - Tools::redirect('index.php?controller=order&step=0&error_echantillons=1'); } } - if ((int)(Tools::getValue('gift'))) - { + + if ((int)(Tools::getValue('gift'))) { $this->context->cart->gift = (int)(Tools::getValue('gift')); } - if (Tools::getValue('message')) - { + + if (Tools::getValue('message')) { $this->context->cart->gift_message = strip_tags($_POST['message']); // die(); } - + + if ((int)Tools::getValue('step', '0')<1 && !Tools::isSubmit('ajax')) { + $this->noticeWhenContainProductToExclude(); + $this->removeCookieRestrictedProductText(); + } + else { + $this->updateCartWhenContainProductToExclude(); + } + + // force option list to be refreshed + $this->context->smarty->assign('delivery_option_list', $this->context->cart->getDeliveryOptionList(null, true)); + // if ($this->step == 2 && Tools::isSubmit('processCarrier')) // if ($this->step == 1 || ($this->step == 2 && Tools::isSubmit('processAddress'))) - $this->processCarrier(); + //$this->processCarrier(); } /** @@ -89,6 +150,9 @@ class OrderController extends OrderControllerCore { global $isVirtualCart; + ParentOrderController::initContent(); + + $this->context->smarty->assign('step', Tools::getValue('step',-2)); $this->context->cart->checkProductForEchantillon(); @@ -193,13 +257,17 @@ class OrderController extends OrderControllerCore // Wrapping fees $wrapping_fees = $this->context->cart->getGiftWrappingPrice(false); $wrapping_fees_tax_inc = $wrapping_fees = $this->context->cart->getGiftWrappingPrice(); + $result = array_merge($result, array( + 'restricted_product_txt' => $this->getCookieRestrictedProductText(), 'HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods(), 'gift_price' => Tools::displayPrice(Tools::convertPrice(Product::getTaxCalculationMethod() == 1 ? $wrapping_fees : $wrapping_fees_tax_inc, new Currency((int)($this->context->cookie->id_currency)))), 'carrier_data' => $this->_getCarrierList()), $this->getFormatedSummaryDetail() ); + + $this->removeCookieRestrictedProductText(); die(Tools::jsonEncode($result)); } } @@ -225,8 +293,6 @@ class OrderController extends OrderControllerCore $this->_assignEchantillons(); $this->_assignCarrier(); // $this->processCarrier(); - // echo $this->step; - // die(); $this->setTemplate(_PS_THEME_DIR_.'shopping-cart.tpl'); break; @@ -235,11 +301,8 @@ class OrderController extends OrderControllerCore Tools::redirect('index.php?controller=order&step=0&error_echantillons=1'); } - // echo "test"; - // die(); - // $this->processCarrier(); $this->_assignSummaryInformations(); - $this->_assignCarrier(); + //$this->_assignCarrier(); $this->_assignAddress(); $this->autoStep(); $this->processAddressFormat(); @@ -250,17 +313,17 @@ class OrderController extends OrderControllerCore // $this->context->smarty->assign('product_list', $this->context->cart->getProducts()); // $this->setTemplate(_PS_THEME_DIR_.'order-address-multishipping.tpl'); // } - // else - // echo "test"; - // die(); - $this->setTemplate(_PS_THEME_DIR_.'order-address.tpl'); + $this->setTemplate(_PS_THEME_DIR_.'order-address.tpl'); + break; case 2: - if (count($this->context->cart->getDeliveryAddressesWithoutCarriers(true))>0) { + if (is_array($this->context->cart->getExcludedUPSProductNameForUPSDelivery())) { Tools::redirect('index.php?controller=order&step=1'); } +// if (count($this->context->cart->getDeliveryAddressesWithoutCarriers(true))>0) { +// } if (!$this->context->cart->isNbEchantillonsInCartAllowed()) { Tools::redirect('index.php?controller=order&step=0&error_echantillons=1'); @@ -272,7 +335,7 @@ class OrderController extends OrderControllerCore // $this->processAddress(); $this->_assignAddress(); $this->autoStep(); - $this->_assignCarrier(); + //$this->_assignCarrier(); // $this->setTemplate(_PS_THEME_DIR_.'order-carrier.tpl'); // break; @@ -388,7 +451,7 @@ class OrderController extends OrderControllerCore 'currencyFormat' => $this->context->currency->format, 'currencyBlank' => $this->context->currency->blank, )); - parent::initContent(); + //parent::initContent(); } protected function _getCarrierList() @@ -566,9 +629,6 @@ class OrderController extends OrderControllerCore if ($delivery->deleted || $invoice->deleted) { -// echo $delivery->deleted; -// echo $invoice->deleted; - // die(); if ($delivery->deleted) unset($this->context->cart->id_address_delivery); if ($invoice->deleted) @@ -716,17 +776,8 @@ class OrderController extends OrderControllerCore // return true; - if (count($this->errors)) - { - // print_r($this->errors); + if (count($this->errors)) { $this->context->smarty->assign('errors', $this->errors); - // $this->_assignCarrier(); - // $this->step = 2; - // echo $this->step; - // die(); - // $this->displayContent(); - // include(dirname(__FILE__).'/../footer.php'); - // exit; } $orderTotal = $this->context->cart->getOrderTotal(); } @@ -742,7 +793,8 @@ class OrderController extends OrderControllerCore $this->context->cart->autosetProductAddress(); $this->context->smarty->assign('cart', $this->context->cart); - parent::_assignCarrier(); + //parent::_assignCarrier(); + $this->_assignCarrier(); // Assign wrapping and TOS $this->_assignWrappingAndTOS(); @@ -760,10 +812,8 @@ class OrderController extends OrderControllerCore $list_ids_carrier_mondial_relay[] = $row['id_carrier']; } - // if (!isset($this->context->customer->id)) - // die(Tools::displayError('Fatal error: No customer')); // Assign carrier - // parent::_assignCarrier(); + //parent::_assignCarrier(); // Assign wrapping and TOS $this->_assignWrappingAndTOS(); diff --git a/themes/default/img/mavap/header_2.jpg b/themes/default/img/mavap/header_2.jpg index a80bc6a..55d075b 100644 Binary files a/themes/default/img/mavap/header_2.jpg and b/themes/default/img/mavap/header_2.jpg differ diff --git a/themes/default/img/mavap/zone3_2.jpg b/themes/default/img/mavap/zone3_2.jpg index 93c3123..3e13aec 100644 Binary files a/themes/default/img/mavap/zone3_2.jpg and b/themes/default/img/mavap/zone3_2.jpg differ diff --git a/themes/default/img/mavap/zone4_2.jpg b/themes/default/img/mavap/zone4_2.jpg index cd33649..74c5c0d 100644 Binary files a/themes/default/img/mavap/zone4_2.jpg and b/themes/default/img/mavap/zone4_2.jpg differ diff --git a/themes/default/js/cart-summary.js b/themes/default/js/cart-summary.js index 519fa01..99b6136 100755 --- a/themes/default/js/cart-summary.js +++ b/themes/default/js/cart-summary.js @@ -450,7 +450,12 @@ function deleteProductFromSummary(id) } else { - $('#product_'+ id).fadeOut('slow', function() { + $('#product_' + productId + '_' + productAttributeId + '_0_' + id_address_delivery).fadeOut('slow', function() { + if ($('#restricted_product_txt').hasClass('restricted_product_'+productId)) { + location.reload(); + return; + } + $(this).remove(); cleanSelectAddressDelivery(); if (!customizationId) diff --git a/themes/default/js/order-address.js b/themes/default/js/order-address.js index 2a30c63..11c507c 100755 --- a/themes/default/js/order-address.js +++ b/themes/default/js/order-address.js @@ -61,9 +61,13 @@ $(document).ready(function() }); //update the display of the addresses +var is_from_clicked = false; function updateAddressesDisplay(first_view) { - // alert(first_view); + if (first_view!=true) { + is_from_clicked = true; + } + //alert(first_view); // alert('test'); // update content of delivery address // updateAddressDisplay('delivery'); @@ -199,6 +203,10 @@ function updateCarrierList(json) function updateAddressSelection(deliveryAddress) { + if (is_from_clicked==true) { + $('#restricted_product_txt').removeClass('restricted_initial'); + } + var idAddress_delivery = $('#id_address_delivery').val(); var idAddress_invoice = ($('#id_address_invoice').length == 1 ? $('#id_address_invoice').val() : ($('#addressesAreEquals:checked').length == 1 ? idAddress_delivery : ($('#id_address_invoice').length == 1 ? $('#id_address_invoice').val() : deliveryAddress))); // alert(refreshAddress); @@ -232,6 +240,16 @@ function updateAddressSelection(deliveryAddress) } else { + if (!$('#restricted_product_txt').hasClass('restricted_initial')){ + $('#restricted_product_txt').html(jsonData.restricted_product_txt); + if (jsonData.restricted_product_txt == '') { + $('#restricted_product_txt').hide(); + } + else { + $('#restricted_product_txt').show(); + } + } + // Update all product keys with the new address id $('#cart_summary .address_'+deliveryAddress).each(function() { $(this) diff --git a/themes/default/order-address.tpl b/themes/default/order-address.tpl index d52f0d5..7677c8c 100755 --- a/themes/default/order-address.tpl +++ b/themes/default/order-address.tpl @@ -242,7 +242,7 @@

- {foreach from=$addresses key=k item=address} diff --git a/themes/default/order-carrier-simple.tpl b/themes/default/order-carrier-simple.tpl index 9bfe567..3a64eba 100755 --- a/themes/default/order-carrier-simple.tpl +++ b/themes/default/order-carrier-simple.tpl @@ -87,6 +87,16 @@

{/if} +
+{if isset($restricted_product_txt) && $restricted_product_txt!=''} +

+ {$restricted_product_txt} +

+{else} + +{/if} +
+
{if isset($carriers) && isset($HOOK_BEFORECARRIER)} @@ -132,26 +142,21 @@ {/foreach}
{if isset($HOOK_EXTRACARRIER_ADDR) && isset($HOOK_EXTRACARRIER_ADDR.$id_address)}{$HOOK_EXTRACARRIER_ADDR.$id_address}{/if}
- {foreachelse} + {foreachelse} + {if !isset($restricted_product_txt)}

- {$restricted_product_name = $cart->getExcludedUPSProductNameForUPSDelivery()} - {if $restricted_product_name!=''} - {l s='"%s" est un soin qui ne peut malheureusement pas être transporté par voie aérienne.' sprintf=$restricted_product_name} + {foreach $cart->getDeliveryAddressesWithoutCarriers(true) as $address} + {if empty($address->alias)} + {l s='No carriers available.'} + {else} + {l s='No carriers available for the address "%s".' sprintf=$address->alias} + {/if} + {if !$address@last}
- {l s='Afin de poursuivre votre commande, nous vous conseillons de le retirer de votre panier ou de choisir une autre adresse de livraison.'} - {else} - {foreach $cart->getDeliveryAddressesWithoutCarriers(true) as $address} - {if empty($address->alias)} - {l s='No carriers available.'} - {else} - {l s='No carriers available for the address "%s".' sprintf=$address->alias} - {/if} - {if !$address@last} -
- {/if} - {/foreach} - {/if} + {/if} + {/foreach}

+ {/if} {/foreach} {/if} diff --git a/themes/default/order-carrier.tpl b/themes/default/order-carrier.tpl index c4cc5ef..9568ee3 100755 --- a/themes/default/order-carrier.tpl +++ b/themes/default/order-carrier.tpl @@ -86,6 +86,15 @@
{/if} +
+{if isset($restricted_product_txt) && $restricted_product_txt!=''} +

+ {$restricted_product_txt} +

+{else} + +{/if} +
@@ -132,26 +141,21 @@ {/foreach}
{if isset($HOOK_EXTRACARRIER_ADDR) && isset($HOOK_EXTRACARRIER_ADDR.$id_address)}{$HOOK_EXTRACARRIER_ADDR.$id_address}{/if}
- {foreachelse} + {foreachelse} + {if !isset($restricted_product_txt)}

- {$restricted_product_name = $cart->getExcludedUPSProductNameForUPSDelivery()} - {if $restricted_product_name!=''} - {l s='"%s" est un soin qui ne peut malheureusement pas être transporté par voie aérienne.' sprintf=$restricted_product_name} + {foreach $cart->getDeliveryAddressesWithoutCarriers(true) as $address} + {if empty($address->alias)} + {l s='No carriers available.'} + {else} + {l s='No carriers available for the address "%s".' sprintf=$address->alias} + {/if} + {if !$address@last}
- {l s='Afin de poursuivre votre commande, nous vous conseillons de le retirer de votre panier ou de choisir une autre adresse de livraison.'} - {else} - {foreach $cart->getDeliveryAddressesWithoutCarriers(true) as $address} - {if empty($address->alias)} - {l s='No carriers available.'} - {else} - {l s='No carriers available for the test address "%s".' sprintf=$address->alias} - {/if} - {if !$address@last} -
- {/if} - {/foreach} - {/if} + {/if} + {/foreach}

+ {/if} {/foreach} {/if} diff --git a/themes/default/shopping-cart.tpl b/themes/default/shopping-cart.tpl index d2c711b..8992beb 100755 --- a/themes/default/shopping-cart.tpl +++ b/themes/default/shopping-cart.tpl @@ -57,6 +57,11 @@ {elseif $PS_CATALOG_MODE}

{l s='This store has not accepted your new order.'}

{else} +{if isset($restricted_product_txt) && $restricted_product_txt!=''} +

+ {$restricted_product_txt} +

+{/if}