27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31 $langs->loadLangs(array(
"companies",
"admin",
"products",
"sms",
"other",
"errors"));
33 $action =
GETPOST(
'action',
'aZ09');
34 $cancel =
GETPOST(
'cancel',
'aZ09');
40 $substitutionarrayfortest = array(
41 '__ID__' =>
'TESTIdRecord',
42 '__PHONEFROM__' =>
'TESTPhoneFrom',
43 '__PHONETO__' =>
'TESTPhoneTo',
44 '__LASTNAME__' =>
'TESTLastname',
45 '__FIRSTNAME__' =>
'TESTFirstname'
53 if ($action ==
'update' && !$cancel) {
54 dolibarr_set_const($db,
"MAIN_DISABLE_ALL_SMS",
GETPOST(
"MAIN_DISABLE_ALL_SMS",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
56 dolibarr_set_const($db,
"MAIN_SMS_SENDMODE",
GETPOST(
"MAIN_SMS_SENDMODE",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
58 dolibarr_set_const($db,
"MAIN_MAIL_SMS_FROM",
GETPOST(
"MAIN_MAIL_SMS_FROM",
'alphanohtml'),
'chaine', 0,
'', $conf->entity);
60 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
66 if ($action ==
'send' && !$cancel) {
70 if (
GETPOST(
"fromsms",
'alphanohtml')) {
71 $smsfrom =
GETPOST(
"fromsms",
'alphanohtml');
73 if (empty($smsfrom)) {
74 $smsfrom =
GETPOST(
"fromname",
'alphanohtml');
76 $sendto =
GETPOST(
"sendto",
'alphanohtml');
77 $body =
GETPOST(
'message',
'alphanohtml');
78 $deliveryreceipt =
GETPOST(
"deliveryreceipt",
'alphanohtml');
79 $deferred =
GETPOST(
'deferred',
'alphanohtml');
80 $priority =
GETPOST(
'priority',
'alphanohtml');
81 $class =
GETPOST(
'class',
'alphanohtml');
82 $errors_to =
GETPOST(
"errorstosms",
'alphanohtml');
85 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formsms.class.php';
88 if (!empty($formsms->error)) {
94 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Message")),
null,
'errors');
98 if (empty($smsfrom) || !str_replace(
'+',
'', $smsfrom)) {
99 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"SmsFrom")),
null,
'errors');
103 if (empty($sendto) || !str_replace(
'+',
'', $sendto)) {
104 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"SmsTo")),
null,
'errors');
113 require_once DOL_DOCUMENT_ROOT.
'/core/class/CSMSFile.class.php';
115 $smsfile =
new CSMSFile($sendto, $smsfrom, $body, $deliveryreceipt, $deferred, $priority, $class);
116 $result = $smsfile->sendfile();
119 setEventMessages($langs->trans(
"SmsSuccessfulySent", $smsfrom, $sendto),
null,
'mesgs');
139 if (preg_match(
'/^win/i', PHP_OS)) {
142 if (preg_match(
'/^mac/i', PHP_OS)) {
146 $wikihelp =
'EN:Setup Sms|FR:Paramétrage Sms|ES:Configuración Sms';
151 print
'<span class="opacitymedium">'.$langs->trans(
"SmsDesc").
"</span><br>\n";
155 $listofmethods = (is_array($conf->modules_parts[
'sms']) ? $conf->modules_parts[
'sms'] : array());
156 asort($listofmethods);
158 if (!count($listofmethods)) {
159 $descnosms = $langs->trans(
"NoSmsEngine",
'{Dolistore}');
160 $descnosms = str_replace(
'{Dolistore}',
'<a href="https://www.dolistore.com/search.php?orderby=position&orderway=desc&search_query=smsmanager">DoliStore</a>', $descnosms);
161 print
'<div class="warning">'.$descnosms.
'</div>';
164 if ($action ==
'edit') {
165 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
166 print
'<input type="hidden" name="token" value="'.newToken().
'">';
167 print
'<input type="hidden" name="action" value="update">';
171 print
'<table class="noborder centpercent">';
172 print
'<tr class="liste_titre"><td>'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
175 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_SMS").
'</td><td>';
180 print
'<tr class="oddeven"><td colspan="2"> </td></tr>';
183 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_SMS_SENDMODE").
'</td><td>';
184 if (count($listofmethods)) {
185 print
$form->selectarray(
'MAIN_SMS_SENDMODE', $listofmethods, $conf->global->MAIN_SMS_SENDMODE, 1);
187 print
'<span class="error">'.$langs->trans(
"None").
'</span>';
192 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMS_FROM", $langs->transnoentities(
"Undefined")).
'</td>';
193 print
'<td><input class="flat" name="MAIN_MAIL_SMS_FROM" size="32" value="'.getDolGlobalString(
'MAIN_MAIL_SMS_FROM');
194 print
'"></td></tr>';
204 print
'<br><div class="center">';
205 print
'<input class="button button-save" type="submit" name="save" value="'.$langs->trans(
"Save").
'"'.(!count($listofmethods) ?
' disabled' :
'').
'>';
206 print
' ';
207 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
213 print
'<table class="noborder centpercent">';
214 print
'<tr class="liste_titre"><td>'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
217 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_SMS").
'</td><td>'.
yn(
getDolGlobalString(
'MAIN_DISABLE_ALL_SMS')).
'</td></tr>';
220 print
'<tr class="oddeven"><td colspan="2"> </td></tr>';
223 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_SMS_SENDMODE").
'</td><td>';
226 $text = $langs->trans(
"Undefined").
' '.
img_warning();
232 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_MAIL_SMS_FROM", $langs->transnoentities(
"Undefined")).
'</td>';
233 print
'<td>'.getDolGlobalString(
'MAIN_MAIL_SMS_FROM');
234 if (!empty($conf->global->MAIN_MAIL_SMS_FROM) && !
isValidPhone($conf->global->MAIN_MAIL_SMS_FROM)) {
235 print
' '.img_warning($langs->trans(
"ErrorBadPhone"));
252 print
'<div class="tabsAction">';
254 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit">'.$langs->trans(
"Modify").
'</a>';
268 if (count($listofmethods) && !empty($conf->global->MAIN_SMS_SENDMODE)) {
269 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init">'.$langs->trans(
"DoTestSend").
'</a>';
271 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"DoTestSend").
'</a>';
276 if ($action ==
'test') {
281 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formsms.class.php';
283 $formsms->fromtype =
'user';
284 $formsms->fromid = $user->id;
285 $formsms->fromsms = (
GETPOSTISSET(
'fromsms') ?
GETPOST(
'fromsms') : ($conf->global->MAIN_MAIL_SMS_FROM ? $conf->global->MAIN_MAIL_SMS_FROM : $user->user_mobile));
286 $formsms->withfromreadonly = 0;
287 $formsms->withsubstit = 0;
288 $formsms->withfrom = 1;
289 $formsms->withto = (
GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto') : ($user->user_mobile ? $user->user_mobile : 1));
290 $formsms->withbody = (
GETPOSTISSET(
'message') ? (!
GETPOST(
'message') ? 1 :
GETPOST(
'message')) : $langs->trans(
"ThisIsATestMessage"));
291 $formsms->withbodyreadonly = 0;
292 $formsms->withcancel = 1;
294 $formsms->substit = $substitutionarrayfortest;
296 $formsms->param[
"action"] =
"send";
297 $formsms->param[
"models"] =
"body";
298 $formsms->param[
"smsid"] = 0;
299 $formsms->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
301 $formsms->show_form();
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).
if($actionsave) if(!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $wikihelp
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to send SMS Usage: $smsfile = new CSMSFile($subject,$sendto,$replyto,$message,...
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.