161 $this->withtopic = 1;
164 $this->withfromreadonly = 1;
165 $this->withreplytoreadonly = 1;
166 $this->withtoreadonly = 0;
167 $this->withtopicreadonly = 0;
168 $this->withbodyreadonly = 0;
179 public function show_form($morecss =
'titlefield', $showform = 1)
182 global
$conf, $langs, $form;
184 if (!is_object($form)) {
185 $form =
new Form($this->db);
189 $langs->loadLangs(array(
'other',
'mails',
'sms'));
192 if (!empty($this->withtosocid) && $this->withtosocid > 0) {
193 $soc->fetch($this->withtosocid);
196 print
"\n<!-- Begin form SMS -->\n";
199<script nonce="'.getNonce().
'" type="text/javascript">
200function limitChars(textarea, limit, infodiv)
202 var text = textarea.value;
203 var textlength = text.length;
204 var info = document.getElementById(infodiv);
206 info.innerHTML = (limit - textlength);
212 print
"<form method=\"POST\" name=\"smsform\" enctype=\"multipart/form-data\" action=\"".$this->param[
"returnurl"].
"\">\n";
215 print
'<input type="hidden" name="token" value="'.newToken().
'">';
216 foreach ($this->param as $key => $value) {
217 print
"<input type=\"hidden\" name=\"$key\" value=\"$value\">\n";
219 print
"<table class=\"border centpercent\">\n";
222 if (!empty($this->withsubstit)) {
223 print
"<tr><td colspan=\"2\">";
225 foreach ($this->substit as $key => $val) {
226 $help .= $key.
' -> '.$langs->trans($val).
'<br>';
228 print $form->textwithpicto($langs->trans(
"SmsTestSubstitutionReplacedByGenericValues"), $help);
229 print
"</td></tr>\n";
233 if ($this->withfrom) {
234 if ($this->withfromreadonly) {
235 print
'<tr><td class="titlefield '.$morecss.
'">'.$langs->trans(
"SmsFrom");
236 print
'<input type="hidden" name="fromsms" value="'.$this->fromsms.
'">';
238 if ($this->fromtype ==
'user') {
239 $langs->load(
"users");
240 $fuser =
new User($this->db);
241 $fuser->fetch($this->fromid);
242 print $fuser->getNomUrl(1);
245 if ($this->fromsms) {
246 print $this->fromsms;
248 if ($this->fromtype) {
249 $langs->load(
"errors");
250 print
'<span class="warning"> <'.$langs->trans(
"ErrorNoPhoneDefinedForThisUser").
'> </span>';
253 print
"</td></tr>\n";
254 print
"</td></tr>\n";
256 print
'<tr><td class="'.$morecss.
'">'.$langs->trans(
"SmsFrom").
"</td><td>";
257 $resultsender = array();
261 $classmoduleofsender =
getDolGlobalString(
'MAIN_MODULE_'.strtoupper($sendmode).
'_SMS', $sendmode);
262 if ($classmoduleofsender ==
'ovh') {
263 $classmoduleofsender =
'ovhsms@ovh';
266 $tmp = explode(
'@', $classmoduleofsender);
267 $classfile = $tmp[0];
268 $module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]);
271 $classname = ucfirst($classfile);
272 if (class_exists($classname)) {
273 $sms =
new $classname($this->db);
274 '@phan-var-force CommonObject $sms';
275 $resultsender = $sms->SmsSenderList();
278 $sms->error =
'The SMS manager "'.$classfile.
'" defined into SMS setup MAIN_MODULE_'.strtoupper($sendmode).
'_SMS is not found';
281 dol_print_error(
null,
'Error to get list of senders: '.$e->getMessage());
285 dol_syslog(
"Warning: The SMS sending method has not been defined into MAIN_SMS_SENDMODE", LOG_WARNING);
286 $resultsender = array(0 =>
new stdClass());
287 $resultsender[0]->number = $this->fromsms;
290 if (is_array($resultsender) && count($resultsender) > 0) {
291 print
'<select name="fromsms" id="fromsms" class="flat">';
292 foreach ($resultsender as $obj) {
293 print
'<option value="'.$obj->number.
'">'.$obj->number.
'</option>';
297 print
'<span class="error wordbreak">'.$langs->trans(
"SmsNoPossibleSenderFound");
298 if (is_object($sms) && !empty($sms->error)) {
299 print
' '.$sms->error;
309 if ($this->withto || is_array($this->withto)) {
313 print $form->textwithpicto($langs->trans(
"SmsTo"), $moretext);
315 if ($this->withtoreadonly) {
316 print (!is_array($this->withto) && !is_numeric($this->withto)) ? $this->withto :
"";
318 print
'<input class="width150" id="sendto" name="sendto" value="'.dol_escape_htmltag(!is_array($this->withto) && $this->withto !=
'1' ? (GETPOSTISSET(
"sendto") ?
GETPOST(
"sendto") : $this->withto) :
"+").
'">';
319 if (!empty($this->withtosocid) && $this->withtosocid > 0) {
321 foreach ($soc->thirdparty_and_contact_phone_array() as $key => $value) {
322 $liste[$key] = $value;
324 print
" ".$langs->trans(
"or").
" ";
326 print $form->selectarray(
"receiver", $liste,
GETPOST(
"receiver"), 1);
328 print
'<span class="opacitymedium hideonsmartphone"> '.$langs->trans(
"SmsInfoNumero").
'</span>';
330 print
"</td></tr>\n";
334 if ($this->withbody) {
335 $defaultmessage =
'';
336 if ($this->param[
"models"] ==
'body') {
337 $defaultmessage = $this->withbody;
340 if (GETPOSTISSET(
"message")) {
341 $defaultmessage =
GETPOST(
"message",
'restricthtml');
343 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
346 print
'<td class="tdtop">'.$langs->trans(
"SmsText").
"</td>";
348 if ($this->withbodyreadonly) {
349 print nl2br($defaultmessage);
350 print
'<input type="hidden" name="message" value="'.dol_escape_htmltag($defaultmessage).
'">';
352 print
'<textarea class="quatrevingtpercent" name="message" id="message" rows="'.ROWS_4.
'" onkeyup="limitChars(this, 160, \'charlimitinfospan\')">'.$defaultmessage.
'</textarea>';
353 print
'<div id="charlimitinfo" class="opacitymedium">'.$langs->trans(
"SmsInfoCharRemain").
': <span id="charlimitinfospan">'.(160 -
dol_strlen($defaultmessage)).
'</span></div></td>';
355 print
"</td></tr>\n";
360 <td>'.$langs->trans(
"DelayBeforeSending").
':</td>
361 <td> <input name="deferred" id="deferred" size="4" value="0"></td></tr>
363 <tr><td>'.$langs->trans(
"Priority").
' :</td><td>
364 <select name="priority" id="priority" class="flat">
365 <option value="0">high</option>
366 <option value="1">medium</option>
367 <option value="2" selected>low</option>
368 <option value="3">veryLow</option>
371 <tr><td>'.$langs->trans(
"Type").
' :</td><td>
372 <select name="class" id="class" class="flat">
373 <option value="0">Flash</option>
374 <option value="1" selected>Standard</option>
375 <option value="2">SIM</option>
376 <option value="3">ToolKit</option>
379 <tr><td>'.$langs->trans(
"DisableStopIfSupported").
' :</td><td>
380 <select name="disablestop" id="disablestop" class="flat">
381 <option value="0" selected>No</option>
382 <option value="1" selected>Yes</option>
383 </select></td></tr>';
389 print
'<div class="center">';
390 print
'<input type="submit" class="button" name="sendmail" value="'.dol_escape_htmltag($langs->trans(
"SendSms")).
'">';
391 if ($this->withcancel) {
392 print
' ';
393 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
400 print
"<!-- End form SMS -->\n";