public function postProcess()
 {
     //ADD
     if (Tools::isSubmit('submitAddcampaign')) {
         parent::validateRules();
         if (count($this->errors)) {
             return false;
         }
         // ADD WAY
         if (!($id_campaign = (int) Tools::getValue('id_campaign')) && empty($this->errors)) {
             $defaultLanguage = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
             // Include voucher :
             if (Tools::getValue('include_voucher') == '1') {
                 // Check values for voucher :
                 $voucher_name = Tools::getValue('voucher_name');
                 $voucher_code = Tools::getValue('voucher_code');
                 $voucher_amount_type = Tools::getValue('voucher_amount_type');
                 $voucher_amount_value = Tools::getValue('voucher_amount_value');
                 $voucher_date = Tools::getValue('voucher_date_to');
                 $new_voucher = new CartRule(null, $defaultLanguage->id);
                 $new_voucher->name = $voucher_name;
                 $new_voucher->date_from = date('Y-m-d');
                 $new_voucher->date_to = $voucher_date;
                 $new_voucher->description = 'Campaign : ' . $voucher_name;
                 $new_voucher->code = $voucher_code;
                 $new_voucher->quantity = 1000;
                 // Todo : Update when campaign is lunch to number of concerned people
                 // Si percent :
                 if ($voucher_amount_type == 'percent') {
                     $new_voucher->reduction_percent = $voucher_amount_value;
                 } else {
                     $new_voucher->reduction_amount = $voucher_amount_value;
                 }
                 $new_voucher->save();
             }
             // Create campaign :
             $campaign = new Campaign();
             $campaign->name = Tools::getValue('name');
             $campaign->email_tpl = Tools::getValue('email_tpl');
             $campaign->execution_time_day = Tools::getValue('execution_time_day');
             $campaign->execution_time_hour = Tools::getValue('execution_time_hour');
             $campaign->voucher_amount_type = Tools::getValue('voucher_amount_type');
             if (isset($new_voucher->id)) {
                 $campaign->id_voucher = $new_voucher->id;
             } else {
                 $campaign->id_voucher = 0;
             }
             $campaign->active = Tools::getValue('active');
             // Create email files :
             $path = _PS_ROOT_DIR_ . '/modules/superabandonedcart/mails/' . $defaultLanguage->iso_code . '/';
             if (!file_exists($path)) {
                 if (!mkdir($path, 0777, true)) {
                     $this->errors[] = Tools::displayError('Mails directory could not be created. Please check system permissions');
                 }
             }
             $tpl_file_name = $campaign->getFileName('html');
             // create html files
             $f = fopen($path . $tpl_file_name, 'w');
             fwrite($f, $campaign->email_tpl);
             fwrite($f, PHP_EOL);
             fclose($f);
             $tpl_file_name = $campaign->getFileName('txt');
             // create txt files
             $f = fopen($path . $tpl_file_name, 'w');
             fwrite($f, strip_tags($campaign->email_tpl));
             fwrite($f, PHP_EOL);
             fclose($f);
             if (!$campaign->save()) {
                 $this->errors[] = Tools::displayError('An error has occurred: Can\'t save the current object');
             }
             // UPDATE WAY
         } elseif ($id_campaign = Tools::getValue('id_campaign')) {
             $defaultLanguage = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
             $campaign = new Campaign($id_campaign);
             // Include voucher :
             if (Tools::getValue('include_voucher') == '1') {
                 $voucher_name = Tools::getValue('voucher_name');
                 $voucher_code = Tools::getValue('voucher_code');
                 $voucher_amount_type = Tools::getValue('voucher_amount_type');
                 $voucher_amount_value = Tools::getValue('voucher_amount_value');
                 $voucher_date = Tools::getValue('voucher_date_to');
                 $new_voucher = new CartRule($campaign->id_voucher, $defaultLanguage->id);
                 $new_voucher->name = $voucher_name;
                 $new_voucher->date_from = date('Y-m-d');
                 $new_voucher->date_to = $voucher_date;
                 $new_voucher->description = 'Campaign : ' . $voucher_name;
                 $new_voucher->code = $voucher_code;
                 $new_voucher->quantity = 1000;
                 // Todo : Update when campaign is lunch to number of concerned people
                 // Si percent :
                 if ($voucher_amount_type == 'percent') {
                     $new_voucher->reduction_percent = $voucher_amount_value;
                 } else {
                     $new_voucher->reduction_amount = $voucher_amount_value;
                 }
                 //	d($new_voucher);
                 if (!$new_voucher->save()) {
                     $this->errors[] = Tools::displayError('An error has occured : when saved voucher');
                 }
             }
             $campaign->name = Tools::getValue('name');
             $campaign->email_tpl = Tools::getValue('email_tpl');
             $campaign->execution_time_day = Tools::getValue('execution_time_day');
             $campaign->execution_time_hour = Tools::getValue('execution_time_hour');
             $campaign->voucher_amount_type = Tools::getValue('voucher_amount_type');
             if (isset($new_voucher->id)) {
                 $campaign->id_voucher = $new_voucher->id;
             } else {
                 $campaign->id_voucher = 0;
             }
             $campaign->active = Tools::getValue('active');
             $path = _PS_ROOT_DIR_ . '/modules/superabandonedcart/mails/' . $defaultLanguage->iso_code . '/';
             if (!file_exists($path)) {
                 if (!mkdir($path, 0777, true)) {
                     $this->errors[] = Tools::displayError('Mails directory could not be created. Please check system permissions');
                 }
             }
             $tpl_file_name = $campaign->getFileName('html');
             // create html files
             $f = fopen($path . $tpl_file_name, 'w');
             fwrite($f, $campaign->email_tpl);
             fwrite($f, PHP_EOL);
             fclose($f);
             $tpl_file_name = $campaign->getFileName('txt');
             // create txt files
             $f = fopen($path . $tpl_file_name, 'w');
             fwrite($f, strip_tags($campaign->email_tpl));
             fwrite($f, PHP_EOL);
             fclose($f);
             if (!$campaign->save()) {
                 $this->errors[] = Tools::displayError('An error has occurred: Can\'t save the current object');
             }
         }
     } elseif (Tools::isSubmit('statuscampaign') && Tools::getValue($this->identifier)) {
         if ($this->tabAccess['edit'] === '1') {
             if (Validate::isLoadedObject($object = $this->loadObject())) {
                 if ($object->toggleStatus()) {
                     $identifier = (int) $object->id_parent ? '&id_campaign=' . (int) $object->id_parent : '';
                     Tools::redirectAdmin($this->context->link->getAdminLink('AdminSuperAbandonedCart'));
                 } else {
                     $this->errors[] = Tools::displayError('An error occurred while updating the status.');
                 }
             } else {
                 $this->errors[] = Tools::displayError('An error occurred while updating the status for an object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
             }
         } else {
             $this->errors[] = Tools::displayError('You do not have permission to edit this.');
         }
     } elseif (Tools::getIsset('submitBulkdeletecampaign') && Tools::getValue('campaignBox')) {
         $ids_banner_deleted = Tools::getValue('campaignBox');
         // remove each banner
         foreach ($ids_banner_deleted as $id) {
             $b = new Campaign($id);
             $b->delete();
             unset($b);
         }
     } elseif (Tools::getIsset('submitBulkenableSelectioncampaign') && Tools::getValue('campaignBox')) {
         $ids_banner_deleted = Tools::getValue('campaignBox');
         // remove each banner
         foreach ($ids_banner_deleted as $id) {
             $b = new Campaign($id);
             $b->toggleStatus();
             unset($b);
         }
     } elseif (Tools::getIsset('submitBulkdisableSelectioncampaign') && Tools::getValue('campaignBox')) {
         $ids_banner_deleted = Tools::getValue('campaignBox');
         // remove each banner
         foreach ($ids_banner_deleted as $id) {
             $b = new Campaign($id);
             $b->toggleStatus();
             unset($b);
         }
     }
 }