private function importCSVFile() { $this->csv_file = isset($_FILES['csv_file']) ? $_FILES['csv_file'] : false; if (empty($this->csv_file['tmp_name'])) { $this->errors[] = Tools::displayError('No file has been specified.'); return false; } if (!empty($this->csv_file) && !empty($this->csv_file['tmp_name'])) { if (!EMTools::importFileSelectColumn($_FILES['csv_file'], 'sms', $this->campaign_id, $this->module->name)) { $this->errors[] = Tools::displayError('Cannot read the .CSV file'); } } }
public function postProcess() { if (Tools::isSubmit('importCsvStep3')) { $this->csv_file = isset($_FILES['csv_file']) ? $_FILES['csv_file'] : false; if (empty($this->csv_file['tmp_name'])) { $this->errors[] = Tools::displayError('No file has been specified.'); } else { if (!empty($this->csv_file) && !empty($this->csv_file['tmp_name'])) { if (!EMTools::importFileSelectColumn($_FILES['csv_file'], 'fax', $this->campaign_id, $this->module->name)) { $this->errors[] = Tools::displayError('Cannot read the .CSV file'); } } } } if (Tools::isSubmit('clearRecipients')) { if (Db::getInstance()->delete('expressmailing_fax_recipients', 'campaign_id = ' . $this->campaign_id)) { $this->confirmations[] = $this->module->l('Clear succeed !', 'adminmarketingfstep3'); } return Db::getInstance()->update('expressmailing_fax', array('campaign_date_update' => date('Y-m-d H:i:s'), 'recipients_modified' => 1), 'campaign_id = ' . $this->campaign_id); } if (Tools::isSubmit('indexCol')) { $index_col = (int) Tools::getValue('indexCol'); $prefix = EMTools::getShopPrefixeCountry(); return EMTools::importFile($index_col, 'fax', $this->campaign_id, $prefix); } if (Tools::isSubmit('clearDuplicate')) { $request = 'DELETE source FROM `' . _DB_PREFIX_ . 'expressmailing_fax_recipients` AS source LEFT OUTER JOIN ( SELECT MIN(id) as id, target FROM `' . _DB_PREFIX_ . 'expressmailing_fax_recipients` WHERE campaign_id = ' . $this->campaign_id . ' GROUP BY target ) AS duplicates ON source.id = duplicates.id WHERE duplicates.id IS NULL'; if (Db::getInstance()->execute($request)) { $this->confirmations[] = $this->module->l('Clear succeed !', 'adminmarketingfstep3'); } Db::getInstance()->update('expressmailing_fax', array('campaign_date_update' => date('Y-m-d H:i:s'), 'recipients_modified' => '1'), 'campaign_id = ' . $this->campaign_id); return; } if (Tools::isSubmit('submitFaxStep3')) { // Selection must contain recipients // --------------------------------- if (count($this->getRecipientsDB())) { Tools::redirectAdmin('index.php?controller=AdminMarketingFStep5&campaign_id=' . $this->campaign_id . '&token=' . Tools::getAdminTokenLite('AdminMarketingFStep5')); exit; } else { $this->errors[] = $this->module->l('Your recipients selection is empty !', 'adminmarketingfstep3'); return false; } } }