27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
39$langs->loadLangs(array(
"companies",
"admin",
"products",
"sms",
"other",
"errors"));
41$action =
GETPOST(
'action',
'aZ09');
42$cancel =
GETPOST(
'cancel',
'aZ09');
48$substitutionarrayfortest = array(
49 '__ID__' =>
'TESTIdRecord',
50 '__PHONEFROM__' =>
'TESTPhoneFrom',
51 '__PHONETO__' =>
'TESTPhoneTo',
52 '__LASTNAME__' =>
'TESTLastname',
53 '__FIRSTNAME__' =>
'TESTFirstname'
61if ($action ==
'update' && !$cancel) {
68 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?mainmenu=home&leftmenu=setup");
74if ($action ==
'send' && !$cancel) {
78 if (
GETPOST(
"fromsms",
'alphanohtml')) {
79 $smsfrom =
GETPOST(
"fromsms",
'alphanohtml');
81 if (empty($smsfrom)) {
82 $smsfrom =
GETPOST(
"fromname",
'alphanohtml');
84 $sendto =
GETPOST(
"sendto",
'alphanohtml');
85 $body =
GETPOST(
'message',
'alphanohtml');
86 $deliveryreceipt =
GETPOST(
"deliveryreceipt",
'alphanohtml');
87 $deferred =
GETPOST(
'deferred',
'alphanohtml');
88 $priority =
GETPOST(
'priority',
'alphanohtml');
89 $class =
GETPOST(
'class',
'alphanohtml');
90 $errors_to =
GETPOST(
"errorstosms",
'alphanohtml');
93 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formsms.class.php';
96 if (!empty($formsms->error)) {
102 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Message")),
null,
'errors');
106 if (empty($smsfrom) || !str_replace(
'+',
'', $smsfrom)) {
107 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"SmsFrom")),
null,
'errors');
111 if (empty($sendto) || !str_replace(
'+',
'', $sendto)) {
112 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"SmsTo")),
null,
'errors');
121 require_once DOL_DOCUMENT_ROOT.
'/core/class/CSMSFile.class.php';
123 $smsfile =
new CSMSFile($sendto, $smsfrom, $body, $deliveryreceipt, $deferred, $priority, $class);
127 $result = $smsfile->sendfile();
130 setEventMessages($langs->trans(
"SmsSuccessfulySent", $smsfrom, $sendto),
null,
'mesgs');
147$form =
new Form($db);
150if (preg_match(
'/^win/i', PHP_OS)) {
153if (preg_match(
'/^mac/i', PHP_OS)) {
157$wikihelp =
'EN:Setup Sms|FR:Paramétrage Sms|ES:Configuración Sms';
158llxHeader(
'', $langs->trans(
"Setup"), $wikihelp,
'', 0, 0,
'',
'',
'',
'mod-admin page-sms');
162print
'<span class="opacitymedium">'.$langs->trans(
"SmsDesc").
"</span><br>\n";
167$listofmethods = (is_array(
$conf->modules_parts[
'sms']) ?
$conf->modules_parts[
'sms'] : array());
168asort($listofmethods);
170if (!count($listofmethods)) {
171 $descnosms = $langs->trans(
"NoSmsEngine",
'{Dolistore}');
172 $descnosms = str_replace(
'{Dolistore}',
'<a href="https://www.dolistore.com/search.php?orderby=position&orderway=desc&search_query=smsmanager">DoliStore</a>', $descnosms);
173 print
'<div class="warning">'.$descnosms.
'</div>';
176if ($action ==
'edit') {
177 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'">';
178 print
'<input type="hidden" name="token" value="'.newToken().
'">';
179 print
'<input type="hidden" name="action" value="update">';
183 print
'<table class="noborder centpercent">';
184 print
'<tr class="liste_titre"><td>'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
187 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_SMS").
'</td><td>';
188 print $form->selectyesno(
'MAIN_DISABLE_ALL_SMS',
getDolGlobalString(
'MAIN_DISABLE_ALL_SMS'), 1);
192 print
'<tr class="oddeven"><td colspan="2"> </td></tr>';
195 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_SMS_SENDMODE").
'</td><td>';
196 if (count($listofmethods)) {
197 print $form->selectarray(
'MAIN_SMS_SENDMODE', $listofmethods,
getDolGlobalString(
'MAIN_SMS_SENDMODE'), 1);
199 print
'<span class="error">'.$langs->trans(
"None").
'</span>';
204 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_SMS_FROM", $langs->transnoentities(
"Undefined")).
'</td>';
205 print
'<td><input class="flat" name="MAIN_SMS_FROM" size="32" value="'.getDolGlobalString(
'MAIN_SMS_FROM');
206 print
'"></td></tr>';
210 print
'<div class="center">';
211 print
'<input class="button button-save" type="submit" name="save" value="'.$langs->trans(
"Save").
'"'.(!count($listofmethods) ?
' disabled' :
'').
'>';
212 print
' ';
213 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
219 print
'<table class="noborder centpercent">';
220 print
'<tr class="liste_titre"><td>'.$langs->trans(
"Parameter").
'</td><td>'.$langs->trans(
"Value").
'</td></tr>';
223 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_DISABLE_ALL_SMS").
'</td><td>'.
yn(
getDolGlobalString(
'MAIN_DISABLE_ALL_SMS')).
'</td></tr>';
226 print
'<tr class="oddeven"><td colspan="2"> </td></tr>';
229 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_SMS_SENDMODE").
'</td><td>';
232 $text = $langs->trans(
"Undefined").
' '.
img_warning();
238 print
'<tr class="oddeven"><td>'.$langs->trans(
"MAIN_SMS_FROM", $langs->transnoentities(
"Undefined")).
'</td>';
239 print
'<td>'.getDolGlobalString(
'MAIN_SMS_FROM');
241 print
' '.img_warning($langs->trans(
"ErrorBadPhone"));
250 print
'<div class="tabsAction">';
252 if ($action !=
'test') {
253 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit">'.$langs->trans(
"Modify").
'</a>';
256 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=test&mode=init&token='.
newToken().
'">'.$langs->trans(
"DoTestSend").
'</a>';
258 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
"DoTestSend").
'</a>';
266 if ($action ==
'test') {
271 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formsms.class.php';
273 $formsms->fromtype =
'user';
274 $formsms->fromid = $user->id;
275 $formsms->fromsms = (GETPOSTISSET(
'fromsms') ?
GETPOST(
'fromsms') :
getDolGlobalString(
'MAIN_SMS_FROM', $user->user_mobile));
276 $formsms->withfromreadonly = 0;
277 $formsms->withsubstit = 0;
278 $formsms->withfrom = 1;
279 $formsms->withto = (GETPOSTISSET(
'sendto') ?
GETPOST(
'sendto') : ($user->user_mobile ? $user->user_mobile : 1));
280 $formsms->withbody = (GETPOSTISSET(
'message') ? (!
GETPOST(
'message') ? 1 :
GETPOST(
'message')) : $langs->trans(
"ThisIsATestMessage"));
281 $formsms->withbodyreadonly = 0;
282 $formsms->withcancel = 1;
284 $formsms->substit = $substitutionarrayfortest;
286 $formsms->param[
"action"] =
"send";
287 $formsms->param[
"models"] =
"body";
288 $formsms->param[
"smsid"] = 0;
289 $formsms->param[
"returnurl"] = $_SERVER[
"PHP_SELF"];
291 $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(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to send SMS Usage: $smsfile = new CSMSFile($subject,$sendto,$replyto,$message,...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
isValidPhone($phone)
Return true if phone number syntax is ok TODO Decide what to do with this.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.