public function postProcess() { if (Tools::isSubmit('submitSmsTest')) { $number = (string) Tools::getValue('campaign_last_tester'); if (empty($number) || !Validate::isPhoneNumber($number)) { $this->errors[] = $this->module->l('Invalid gsm number !', 'adminmarketingsstep6'); return false; } $prefixe = EMTools::getShopPrefixeCountry(); $number = EMTools::cleanNumber($number, $prefixe); if ($number[0] != '0' && $number[0] != '+') { $this->errors[] = $this->module->l('Invalid gsm number !', 'adminmarketingsstep6'); return false; } $response_array = array(); $parameters = array('campaign_id' => $this->campaign_api_message_id, 'recipient' => $number, 'text' => $this->module->l('[TEST]', 'adminmarketingsstep6') . ' ' . $this->campaign_sms_text); if ($this->session_api->call('sms', 'campaign', 'send_test', $parameters, $response_array)) { // We store the last fax number // ---------------------------- Db::getInstance()->update('expressmailing_sms', array('campaign_last_tester' => pSQL($number)), 'campaign_id = ' . $this->campaign_id); $this->confirmations[] = sprintf($this->module->l('Please wait, your sms is processing to %s ...', 'adminmarketingsstep6'), $number); return true; } $this->errors[] = sprintf($this->module->l('Error while sending sms to the API : %s', 'adminmarketingsstep6'), $this->session_api->getError()); return false; } }
public function postProcess() { if (Tools::isSubmit('submitFaxTest')) { $number_or_email = (string) Tools::getValue('campaign_last_tester'); if (empty($number_or_email)) { $this->errors[] = $this->module->l('Invalid fax number !', 'adminmarketingfstep7'); return false; } if (Tools::strpos($number_or_email, '@')) { if (!Validate::isEmail($number_or_email)) { $this->errors[] = $this->module->l('Invalid email address !', 'adminmarketingfstep7'); return false; } } else { $prefixe = EMTools::getShopPrefixeCountry(); $number_or_email = EMTools::cleanNumber($number_or_email, $prefixe); if (!Validate::isPhoneNumber($number_or_email)) { $this->errors[] = $this->module->l('Invalid fax number !', 'adminmarketingfstep7'); return false; } if ($number_or_email[0] != '0' && $number_or_email[0] != '+') { $this->errors[] = $this->module->l('Invalid fax number !', 'adminmarketingfstep7'); return false; } } $response_array = array(); $parameters = array('campaign_id' => $this->campaign_api_message_id, 'recipient' => $number_or_email); if ($this->session_api->call('fax', 'campaign', 'send_test', $parameters, $response_array)) { // We store the last fax number // ---------------------------- Db::getInstance()->update('expressmailing_fax', array('campaign_last_tester' => pSQL($number_or_email)), 'campaign_id = ' . $this->campaign_id); $this->confirmations[] = sprintf($this->module->l('Please wait, your fax is processing to %s ...', 'adminmarketingfstep7'), $number_or_email); return true; } $this->errors[] = sprintf($this->module->l('Error while sending fax to the API : %s', 'adminmarketingfstep7'), $this->session_api->getError()); return false; } }
public static function getCSVInsertRequest($file_name, $campaign_id, $table, $idx_col, $code_iso_country) { // Load all countries prefixes // // ------------------------ EMTools::loadPrefixesCountries(); // Creatre the INSERT request // -------------------------- $str_fields = ' campaign_id, target, col_0, col_1, col_2, col_3, col_4, col_5, col_6, col_7, col_8, col_9, col_10, col_11, col_12, col_13, col_14, col_15, col_16, col_17, col_18, col_19'; $request = 'INSERT INTO ' . bqSQL($table) . ' (' . $str_fields . ') VALUES '; $data = EMTools::readCSV($file_name); foreach ($data as $line) { $data_sql = ''; $data_value = ''; $col_count = count($line); $data_num = $line[(int) $idx_col]; $number = EMTools::cleanNumber($data_num, $code_iso_country); if (!empty($number)) { $ligne = "('" . (int) $campaign_id . "', '" . pSQL($number) . "', "; for ($i = 0; $i <= 19; $i++) { if ($i < $col_count) { $data_value = $line[$i]; } else { $data_value = ''; } $data_sql .= "'" . pSQL($data_value) . "', "; } $data_sql = rtrim($data_sql, ', ') . "),\r\n"; $request .= $ligne . $data_sql; } } $request = rtrim($request, " ,\r\n") . ';'; unlink($file_name); return $request; }