96 $this->withfromreadonly = 1;
97 $this->withreplytoreadonly = 1;
98 $this->withtoreadonly = 0;
99 $this->withtopicreadonly = 0;
100 $this->withbodyreadonly = 0;
111 public function show_form($morecss =
'titlefield', $showform = 1)
114 global $conf, $langs, $form;
116 if (!is_object($form)) {
117 $form =
new Form($this->db);
121 $langs->loadLangs(array(
'other',
'mails',
'sms'));
124 if (!empty($this->withtosocid) && $this->withtosocid > 0) {
125 $soc->fetch($this->withtosocid);
128 print
"\n<!-- Begin form SMS -->\n";
131<script nonce="'.getNonce().
'" type="text/javascript">
132function limitChars(textarea, limit, infodiv)
134 var text = textarea.value;
135 var textlength = text.length;
136 var info = document.getElementById(infodiv);
138 info.innerHTML = (limit - textlength);
144 print
"<form method=\"POST\" name=\"smsform\" enctype=\"multipart/form-data\" action=\"".$this->param[
"returnurl"].
"\">\n";
147 print
'<input type="hidden" name="token" value="'.newToken().
'">';
148 foreach ($this->param as $key => $value) {
149 print
"<input type=\"hidden\" name=\"$key\" value=\"$value\">\n";
151 print
"<table class=\"border centpercent\">\n";
154 if (!empty($this->withsubstit)) {
155 print
"<tr><td colspan=\"2\">";
157 foreach ($this->substit as $key => $val) {
158 $help .= $key.
' -> '.$langs->trans($val).
'<br>';
160 print $form->textwithpicto($langs->trans(
"SmsTestSubstitutionReplacedByGenericValues"), $help);
161 print
"</td></tr>\n";
165 if ($this->withfrom) {
166 if ($this->withfromreadonly) {
167 print
'<tr><td class="titlefield '.$morecss.
'">'.$langs->trans(
"SmsFrom");
168 print
'<input type="hidden" name="fromsms" value="'.$this->fromsms.
'">';
170 if ($this->fromtype ==
'user') {
171 $langs->load(
"users");
172 $fuser =
new User($this->db);
173 $fuser->fetch($this->fromid);
174 print $fuser->getNomUrl(1);
177 if ($this->fromsms) {
178 print $this->fromsms;
180 if ($this->fromtype) {
181 $langs->load(
"errors");
182 print
'<span class="warning"> <'.$langs->trans(
"ErrorNoPhoneDefinedForThisUser").
'> </span>';
185 print
"</td></tr>\n";
186 print
"</td></tr>\n";
188 print
'<tr><td class="'.$morecss.
'">'.$langs->trans(
"SmsFrom").
"</td><td>";
191 $classmoduleofsender =
getDolGlobalString(
'MAIN_MODULE_'.strtoupper($sendmode).
'_SMS', $sendmode);
192 if ($classmoduleofsender ==
'ovh') {
193 $classmoduleofsender =
'ovhsms@ovh';
196 $tmp = explode(
'@', $classmoduleofsender);
197 $classfile = $tmp[0];
198 $module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]);
201 $classname = ucfirst($classfile);
202 if (class_exists($classname)) {
203 $sms =
new $classname($this->db);
204 $resultsender = $sms->SmsSenderList();
207 $sms->error =
'The SMS manager "'.$classfile.
'" defined into SMS setup MAIN_MODULE_'.strtoupper($sendmode).
'_SMS is not found';
210 dol_print_error(
'',
'Error to get list of senders: '.$e->getMessage());
214 dol_syslog(
"Warning: The SMS sending method has not been defined into MAIN_SMS_SENDMODE", LOG_WARNING);
215 $resultsender = array();
216 $resultsender[0]->number = $this->fromsms;
219 if (is_array($resultsender) && count($resultsender) > 0) {
220 print
'<select name="fromsms" id="fromsms" class="flat">';
221 foreach ($resultsender as $obj) {
222 print
'<option value="'.$obj->number.
'">'.$obj->number.
'</option>';
226 print
'<span class="error wordbreak">'.$langs->trans(
"SmsNoPossibleSenderFound");
227 if (is_object($sms) && !empty($sms->error)) {
228 print
' '.$sms->error;
238 if ($this->withto || is_array($this->withto)) {
242 print $form->textwithpicto($langs->trans(
"SmsTo"), $moretext);
244 if ($this->withtoreadonly) {
245 print (!is_array($this->withto) && !is_numeric($this->withto)) ? $this->withto :
"";
247 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) :
"+").
'">';
248 if (!empty($this->withtosocid) && $this->withtosocid > 0) {
250 foreach ($soc->thirdparty_and_contact_phone_array() as $key => $value) {
251 $liste[$key] = $value;
253 print
" ".$langs->trans(
"or").
" ";
255 print $form->selectarray(
"receiver", $liste,
GETPOST(
"receiver"), 1);
257 print
'<span class="opacitymedium hideonsmartphone"> '.$langs->trans(
"SmsInfoNumero").
'</span>';
259 print
"</td></tr>\n";
263 if ($this->withbody) {
264 $defaultmessage =
'';
265 if ($this->param[
"models"] ==
'body') {
266 $defaultmessage = $this->withbody;
269 if (GETPOSTISSET(
"message")) {
270 $defaultmessage =
GETPOST(
"message",
'restricthtml');
272 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
275 print
'<td class="tdtop">'.$langs->trans(
"SmsText").
"</td>";
277 if ($this->withbodyreadonly) {
278 print nl2br($defaultmessage);
279 print
'<input type="hidden" name="message" value="'.dol_escape_htmltag($defaultmessage).
'">';
281 print
'<textarea class="quatrevingtpercent" name="message" id="message" rows="'.ROWS_4.
'" onkeyup="limitChars(this, 160, \'charlimitinfospan\')">'.$defaultmessage.
'</textarea>';
282 print
'<div id="charlimitinfo" class="opacitymedium">'.$langs->trans(
"SmsInfoCharRemain").
': <span id="charlimitinfospan">'.(160 -
dol_strlen($defaultmessage)).
'</span></div></td>';
284 print
"</td></tr>\n";
289 <td>'.$langs->trans(
"DelayBeforeSending").
':</td>
290 <td> <input name="deferred" id="deferred" size="4" value="0"></td></tr>
292 <tr><td>'.$langs->trans(
"Priority").
' :</td><td>
293 <select name="priority" id="priority" class="flat">
294 <option value="0">high</option>
295 <option value="1">medium</option>
296 <option value="2" selected>low</option>
297 <option value="3">veryLow</option>
300 <tr><td>'.$langs->trans(
"Type").
' :</td><td>
301 <select name="class" id="class" class="flat">
302 <option value="0">Flash</option>
303 <option value="1" selected>Standard</option>
304 <option value="2">SIM</option>
305 <option value="3">ToolKit</option>
308 <tr><td>'.$langs->trans(
"DisableStopIfSupported").
' :</td><td>
309 <select name="disablestop" id="disablestop" class="flat">
310 <option value="0" selected>No</option>
311 <option value="1" selected>Yes</option>
312 </select></td></tr>';
318 print
'<div class="center">';
319 print
'<input type="submit" class="button" name="sendmail" value="'.dol_escape_htmltag($langs->trans(
"SendSms")).
'">';
320 if ($this->withcancel) {
321 print
' ';
322 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
329 print
"<!-- End form SMS -->\n";