26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30 $langs->loadLangs(array(
"companies",
"admin",
"products",
"sms",
"other",
"errors"));
32 $action =
GETPOST(
'action',
'aZ09');
33 $cancel =
GETPOST(
'cancel',
'aZ09');
39 $substitutionarrayfortest = array(
40 '__ID__' =>
'TESTIdRecord',
41 '__PHONEFROM__' =>
'TESTPhoneFrom',
42 '__PHONETO__' =>
'TESTPhoneTo',
43 '__LASTNAME__' =>
'TESTLastname',
44 '__FIRSTNAME__' =>
'TESTFirstname'
52 if ($action ==
'update' && !$cancel) {
53 dolibarr_set_const($db,
"MAIN_DISABLE_ALL_SMS",
GETPOST(
"MAIN_DISABLE_ALL_SMS",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
55 dolibarr_set_const($db,
"MAIN_SMS_SENDMODE",
GETPOST(
"MAIN_SMS_SENDMODE",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
57 dolibarr_set_const($db,
"MAIN_MAIL_SMS_FROM",
GETPOST(
"MAIN_MAIL_SMS_FROM",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
59 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
65 if ($action ==
'send' && !$_POST[
'cancel']) {
69 if (!empty($_POST[
"fromsms"])) {
70 $smsfrom =
GETPOST(
"fromsms",
'alphanohtml');
72 if (empty($smsfrom)) {
73 $smsfrom =
GETPOST(
"fromname",
'alphanohtml');
75 $sendto =
GETPOST(
"sendto",
'alphanohtml');
76 $body =
GETPOST(
'message',
'alphanohtml');
77 $deliveryreceipt =
GETPOST(
"deliveryreceipt",
'alphanohtml');
78 $deferred =
GETPOST(
'deferred',
'alphanohtml');
79 $priority =
GETPOST(
'priority',
'alphanohtml');
80 $class =
GETPOST(
'class',
'alphanohtml');
81 $errors_to =
GETPOST(
"errorstosms",
'alphanohtml');
84 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formsms.class.php';
87 if (!empty($formsms->error)) {
93 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Message")), null,
'errors');
97 if (empty($smsfrom) || !str_replace(
'+',
'', $smsfrom)) {
98 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"SmsFrom")), null,
'errors');
102 if (empty($sendto) || !str_replace(
'+',
'', $sendto)) {
103 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"SmsTo")), null,
'errors');
112 require_once DOL_DOCUMENT_ROOT.
'/core/class/CSMSFile.class.php';
114 $smsfile =
new CSMSFile($sendto, $smsfrom, $body, $deliveryreceipt, $deferred, $priority, $class);
115 $result = $smsfile->sendfile();
118 setEventMessages($langs->trans(
"SmsSuccessfulySent", $smsfrom, $sendto), null,
'mesgs');
135 $form =
new Form($db);
138 if (preg_match(
'/^win/i', PHP_OS)) {
141 if (preg_match(
'/^mac/i', PHP_OS)) {
145 $wikihelp =
'EN:Setup Sms|FR:Paramétrage Sms|ES:Configuración Sms';
150 print '<span class="opacitymedium">'.$langs->trans(
"SmsDesc").
"</span><br>\n";
154 $listofmethods = (is_array($conf->modules_parts[
'sms']) ? $conf->modules_parts[
'sms'] : array());
155 asort($listofmethods);
157 if (!count($listofmethods)) {
158 $descnosms = $langs->trans(
"NoSmsEngine",
'{Dolistore}');
159 $descnosms = str_replace(
'{Dolistore}',
'<a href="http://www.dolistore.com/search.php?orderby=position&orderway=desc&search_query=smsmanager">DoliStore</a>', $descnosms);
160 print '<div class="warning">'.$descnosms.
'</div>';
163 if ($action ==
'edit') {
164 print '<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
165 print '<input type="hidden" name="token" value="'.newToken().
'">';
166 print '<input type="hidden" name="action" value="update">';
170 print '<table class="noborder centpercent">';
171 print '<tr class="liste_titre"><td>'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
174 print '<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_SMS").
'</td><td>';
175 print $form->selectyesno(
'MAIN_DISABLE_ALL_SMS', $conf->global->MAIN_DISABLE_ALL_SMS, 1);
179 print '<tr class="oddeven"><td colspan="2"> </td></tr>';
182 print '<tr class="oddeven"><td>'.$langs->trans(
"MAIN_SMS_SENDMODE").
'</td><td>';
183 if (count($listofmethods)) {
184 print $form->selectarray(
'MAIN_SMS_SENDMODE', $listofmethods, $conf->global->MAIN_SMS_SENDMODE, 1);
186 print '<font class="error">'.$langs->trans(
"None").
'</font>';
191 print '<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMS_FROM", $langs->transnoentities(
"Undefined")).
'</td>';
192 print '<td><input class="flat" name="MAIN_MAIL_SMS_FROM" size="32" value="'.$conf->global->MAIN_MAIL_SMS_FROM;
193 print '"></td></tr>';
203 print '<br><div class="center">';
204 print '<input class="button button-save" type="submit" name="save" value="'.$langs->trans(
"Save").
'"'.(!count($listofmethods) ?
' disabled' :
'').
'>';
205 print ' ';
206 print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
212 print '<table class="noborder centpercent">';
213 print '<tr class="liste_titre"><td>'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
216 print '<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_SMS").
'</td><td>'.
yn($conf->global->MAIN_DISABLE_ALL_SMS).
'</td></tr>';
219 print '<tr class="oddeven"><td colspan="2"> </td></tr>';
222 print '<tr class="oddeven"><td>'.$langs->trans(
"MAIN_SMS_SENDMODE").
'</td><td>';
223 $text = $listofmethods[$conf->global->MAIN_SMS_SENDMODE];
225 $text = $langs->trans(
"Undefined").
' '.
img_warning();
231 print '<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMS_FROM", $langs->transnoentities(
"Undefined")).
'</td>';
232 print '<td>'.$conf->global->MAIN_MAIL_SMS_FROM;
233 if (!empty($conf->global->MAIN_MAIL_SMS_FROM) && !
isValidPhone($conf->global->MAIN_MAIL_SMS_FROM)) {
234 print ' '.img_warning($langs->trans(
"ErrorBadPhone"));
251 print '<div class="tabsAction">';
253 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit">'.$langs->trans(
"Modify").
'</a>';
267 if (count($listofmethods) && !empty($conf->global->MAIN_SMS_SENDMODE)) {
268 print '<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init">'.$langs->trans(
"DoTestSend").
'</a>';
270 print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"DoTestSend").
'</a>';
275 if ($action ==
'test') {
280 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formsms.class.php';
282 $formsms->fromtype =
'user';
283 $formsms->fromid = $user->id;
284 $formsms->fromsms = (
GETPOSTISSET(
'fromsms') ?
GETPOST(
'fromsms') : ($conf->global->MAIN_MAIL_SMS_FROM ? $conf->global->MAIN_MAIL_SMS_FROM : $user->user_mobile));
285 $formsms->withfromreadonly = 0;
286 $formsms->withsubstit = 0;
287 $formsms->withfrom = 1;
288 $formsms->withto = (
GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto') : ($user->user_mobile ? $user->user_mobile : 1));
289 $formsms->withbody = (
GETPOSTISSET(
'message') ? (!
GETPOST(
'message') ? 1 :
GETPOST(
'message')) : $langs->trans(
"ThisIsATestMessage"));
290 $formsms->withbodyreadonly = 0;
291 $formsms->withcancel = 1;
293 $formsms->substit = $substitutionarrayfortest;
295 $formsms->param[
"action"] =
"send";
296 $formsms->param[
"models"] =
"body";
297 $formsms->param[
"smsid"] = 0;
298 $formsms->param[
"returnurl"] =
$_SERVER[
"PHP_SELF"];
300 $formsms->show_form();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to send SMS Usage: $smsfile = new CSMSFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to); $smsfile->sendfile();.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dolibarr_set_const($db, $name, $value, $type= 'chaine', $visible=0, $note= '', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $wikihelp
View.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
isValidPhone($phone)
Return true if phone number syntax is ok TODO Decide what to do with this.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...