Пример #1
0
 public static function init()
 {
     $controller = new DpdGroupCSVController();
     if (Tools::isSubmit(DpdGroupCSVController::SETTINGS_SAVE_CSV_ACTION)) {
         $csv_data = $controller->readCSVData();
         if ($csv_data === false) {
             DpdGroup::addFlashError($controller->l('Wrong CSV file'));
             Tools::redirectAdmin($controller->module_instance->module_url . '&menu=csv');
         }
         $message = $controller->validateCSVData($csv_data);
         if ($message !== true) {
             return $controller->module_instance->outputHTML($controller->module_instance->displayError(implode('<br />', $message)));
         }
         if ($controller->saveCSVData($csv_data)) {
             DpdGroup::addFlashMessage($controller->l('CSV data was successfully saved'));
             Tools::redirectAdmin($controller->module_instance->module_url . '&menu=csv');
         } else {
             DpdGroup::addFlashError($controller->l('CSV data could not be saved'));
             Tools::redirectAdmin($controller->module_instance->module_url . '&menu=csv');
         }
     }
     if (Tools::isSubmit(DpdGroupCSVController::SETTINGS_DOWNLOAD_CSV_ACTION)) {
         $controller->generateCSV();
     }
     if (Tools::isSubmit(DpdGroupCSVController::SETTINGS_DELETE_CSV_ACTION)) {
         $controller->deleteCSV();
     }
     return null;
 }