113 $this->withtopic = 1;
116 $this->withfromreadonly = 1;
117 $this->withreplytoreadonly = 1;
118 $this->withtoreadonly = 0;
119 $this->withtopicreadonly = 0;
120 $this->withbodyreadonly = 0;
131 public function show_form($morecss =
'titlefield', $showform = 1)
134 global $conf, $langs, $form;
136 if (!is_object($form)) {
137 $form =
new Form($this->db);
141 $langs->loadLangs(array(
'other',
'mails',
'sms'));
144 if (!empty($this->withtosocid) && $this->withtosocid > 0) {
145 $soc->fetch($this->withtosocid);
148 print
"\n<!-- Begin form SMS -->\n";
151<script nonce="'.getNonce().
'" type="text/javascript">
152function limitChars(textarea, limit, infodiv)
154 var text = textarea.value;
155 var textlength = text.length;
156 var info = document.getElementById(infodiv);
158 info.innerHTML = (limit - textlength);
164 print
"<form method=\"POST\" name=\"smsform\" enctype=\"multipart/form-data\" action=\"".$this->param[
"returnurl"].
"\">\n";
167 print
'<input type="hidden" name="token" value="'.newToken().
'">';
168 foreach ($this->param as $key => $value) {
169 print
"<input type=\"hidden\" name=\"$key\" value=\"$value\">\n";
171 print
"<table class=\"border centpercent\">\n";
174 if (!empty($this->withsubstit)) {
175 print
"<tr><td colspan=\"2\">";
177 foreach ($this->substit as $key => $val) {
178 $help .= $key.
' -> '.$langs->trans($val).
'<br>';
180 print $form->textwithpicto($langs->trans(
"SmsTestSubstitutionReplacedByGenericValues"), $help);
181 print
"</td></tr>\n";
185 if ($this->withfrom) {
186 if ($this->withfromreadonly) {
187 print
'<tr><td class="titlefield '.$morecss.
'">'.$langs->trans(
"SmsFrom");
188 print
'<input type="hidden" name="fromsms" value="'.$this->fromsms.
'">';
190 if ($this->fromtype ==
'user') {
191 $langs->load(
"users");
192 $fuser =
new User($this->db);
193 $fuser->fetch($this->fromid);
194 print $fuser->getNomUrl(1);
197 if ($this->fromsms) {
198 print $this->fromsms;
200 if ($this->fromtype) {
201 $langs->load(
"errors");
202 print
'<span class="warning"> <'.$langs->trans(
"ErrorNoPhoneDefinedForThisUser").
'> </span>';
205 print
"</td></tr>\n";
206 print
"</td></tr>\n";
208 print
'<tr><td class="'.$morecss.
'">'.$langs->trans(
"SmsFrom").
"</td><td>";
211 $classmoduleofsender =
getDolGlobalString(
'MAIN_MODULE_'.strtoupper($sendmode).
'_SMS', $sendmode);
212 if ($classmoduleofsender ==
'ovh') {
213 $classmoduleofsender =
'ovhsms@ovh';
216 $tmp = explode(
'@', $classmoduleofsender);
217 $classfile = $tmp[0];
218 $module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]);
221 $classname = ucfirst($classfile);
222 if (class_exists($classname)) {
223 $sms =
new $classname($this->db);
224 $resultsender = $sms->SmsSenderList();
227 $sms->error =
'The SMS manager "'.$classfile.
'" defined into SMS setup MAIN_MODULE_'.strtoupper($sendmode).
'_SMS is not found';
230 dol_print_error(
null,
'Error to get list of senders: '.$e->getMessage());
234 dol_syslog(
"Warning: The SMS sending method has not been defined into MAIN_SMS_SENDMODE", LOG_WARNING);
235 $resultsender = array();
236 $resultsender[0]->number = $this->fromsms;
239 if (is_array($resultsender) && count($resultsender) > 0) {
240 print
'<select name="fromsms" id="fromsms" class="flat">';
241 foreach ($resultsender as $obj) {
242 print
'<option value="'.$obj->number.
'">'.$obj->number.
'</option>';
246 print
'<span class="error wordbreak">'.$langs->trans(
"SmsNoPossibleSenderFound");
247 if (is_object($sms) && !empty($sms->error)) {
248 print
' '.$sms->error;
258 if ($this->withto || is_array($this->withto)) {
262 print $form->textwithpicto($langs->trans(
"SmsTo"), $moretext);
264 if ($this->withtoreadonly) {
265 print (!is_array($this->withto) && !is_numeric($this->withto)) ? $this->withto :
"";
267 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) :
"+").
'">';
268 if (!empty($this->withtosocid) && $this->withtosocid > 0) {
270 foreach ($soc->thirdparty_and_contact_phone_array() as $key => $value) {
271 $liste[$key] = $value;
273 print
" ".$langs->trans(
"or").
" ";
275 print $form->selectarray(
"receiver", $liste,
GETPOST(
"receiver"), 1);
277 print
'<span class="opacitymedium hideonsmartphone"> '.$langs->trans(
"SmsInfoNumero").
'</span>';
279 print
"</td></tr>\n";
283 if ($this->withbody) {
284 $defaultmessage =
'';
285 if ($this->param[
"models"] ==
'body') {
286 $defaultmessage = $this->withbody;
289 if (GETPOSTISSET(
"message")) {
290 $defaultmessage =
GETPOST(
"message",
'restricthtml');
292 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
295 print
'<td class="tdtop">'.$langs->trans(
"SmsText").
"</td>";
297 if ($this->withbodyreadonly) {
298 print nl2br($defaultmessage);
299 print
'<input type="hidden" name="message" value="'.dol_escape_htmltag($defaultmessage).
'">';
301 print
'<textarea class="quatrevingtpercent" name="message" id="message" rows="'.ROWS_4.
'" onkeyup="limitChars(this, 160, \'charlimitinfospan\')">'.$defaultmessage.
'</textarea>';
302 print
'<div id="charlimitinfo" class="opacitymedium">'.$langs->trans(
"SmsInfoCharRemain").
': <span id="charlimitinfospan">'.(160 -
dol_strlen($defaultmessage)).
'</span></div></td>';
304 print
"</td></tr>\n";
309 <td>'.$langs->trans(
"DelayBeforeSending").
':</td>
310 <td> <input name="deferred" id="deferred" size="4" value="0"></td></tr>
312 <tr><td>'.$langs->trans(
"Priority").
' :</td><td>
313 <select name="priority" id="priority" class="flat">
314 <option value="0">high</option>
315 <option value="1">medium</option>
316 <option value="2" selected>low</option>
317 <option value="3">veryLow</option>
320 <tr><td>'.$langs->trans(
"Type").
' :</td><td>
321 <select name="class" id="class" class="flat">
322 <option value="0">Flash</option>
323 <option value="1" selected>Standard</option>
324 <option value="2">SIM</option>
325 <option value="3">ToolKit</option>
328 <tr><td>'.$langs->trans(
"DisableStopIfSupported").
' :</td><td>
329 <select name="disablestop" id="disablestop" class="flat">
330 <option value="0" selected>No</option>
331 <option value="1" selected>Yes</option>
332 </select></td></tr>';
338 print
'<div class="center">';
339 print
'<input type="submit" class="button" name="sendmail" value="'.dol_escape_htmltag($langs->trans(
"SendSms")).
'">';
340 if ($this->withcancel) {
341 print
' ';
342 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
349 print
"<!-- End form SMS -->\n";