110 public function show_form($morecss =
'titlefield', $showform = 1)
113 global $conf, $langs, $user, $form;
115 if (!is_object($form)) {
116 $form =
new Form($this->db);
120 $langs->loadLangs(array(
'other',
'mails',
'sms'));
123 if (!empty($this->withtosocid) && $this->withtosocid > 0) {
124 $soc->fetch($this->withtosocid);
127 print
"\n<!-- Begin form SMS -->\n";
130<script nonce="'.getNonce().
'" type="text/javascript">
131function limitChars(textarea, limit, infodiv)
133 var text = textarea.value;
134 var textlength = text.length;
135 var info = document.getElementById(infodiv);
137 info.innerHTML = (limit - textlength);
143 print
"<form method=\"POST\" name=\"smsform\" enctype=\"multipart/form-data\" action=\"".$this->param[
"returnurl"].
"\">\n";
146 print
'<input type="hidden" name="token" value="'.newToken().
'">';
147 foreach ($this->param as $key => $value) {
148 print
"<input type=\"hidden\" name=\"$key\" value=\"$value\">\n";
150 print
"<table class=\"border centpercent\">\n";
153 if (!empty($this->withsubstit)) {
154 print
"<tr><td colspan=\"2\">";
156 foreach ($this->substit as $key => $val) {
157 $help .= $key.
' -> '.$langs->trans($val).
'<br>';
159 print $form->textwithpicto($langs->trans(
"SmsTestSubstitutionReplacedByGenericValues"), $help);
160 print
"</td></tr>\n";
164 if ($this->withfrom) {
165 if ($this->withfromreadonly) {
166 print
'<tr><td class="titlefield '.$morecss.
'">'.$langs->trans(
"SmsFrom");
167 print
'<input type="hidden" name="fromsms" value="'.$this->fromsms.
'">';
169 if ($this->fromtype ==
'user') {
170 $langs->load(
"users");
171 $fuser =
new User($this->db);
172 $fuser->fetch($this->fromid);
173 print $fuser->getNomUrl(1);
176 if ($this->fromsms) {
177 print $this->fromsms;
179 if ($this->fromtype) {
180 $langs->load(
"errors");
181 print
'<span class="warning"> <'.$langs->trans(
"ErrorNoPhoneDefinedForThisUser").
'> </span>';
184 print
"</td></tr>\n";
185 print
"</td></tr>\n";
187 print
'<tr><td class="'.$morecss.
'">'.$langs->trans(
"SmsFrom").
"</td><td>";
189 if ($conf->global->MAIN_SMS_SENDMODE ==
'ovh') {
192 $sms =
new OvhSms($this->db);
193 if (empty($conf->global->OVHSMS_ACCOUNT)) {
194 $resultsender =
'ErrorOVHSMS_ACCOUNT not defined';
196 $resultsender = $sms->SmsSenderList();
199 dol_print_error(
'',
'Error to get list of senders: '.$e->getMessage());
201 } elseif (!empty($conf->global->MAIN_SMS_SENDMODE)) {
202 $tmp = explode(
'@', $conf->global->MAIN_SMS_SENDMODE);
203 $classfile = $tmp[0];
204 $module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]);
207 $classname = ucfirst($classfile);
208 if (class_exists($classname)) {
209 $sms =
new $classname($this->db);
210 $resultsender = $sms->SmsSenderList();
212 $sms =
new stdClass();
213 $sms->error =
'The SMS manager "'.$classfile.
'" defined into SMS setup MAIN_SMS_SENDMODE is not found';
216 dol_print_error(
'',
'Error to get list of senders: '.$e->getMessage());
220 dol_syslog(
"Warning: The SMS sending method has not been defined into MAIN_SMS_SENDMODE", LOG_WARNING);
221 $resultsender = array();
222 $resultsender[0]->number = $this->fromsms;
225 if (is_array($resultsender) && count($resultsender) > 0) {
226 print
'<select name="fromsms" id="fromsms" class="flat">';
227 foreach ($resultsender as $obj) {
228 print
'<option value="'.$obj->number.
'">'.$obj->number.
'</option>';
232 print
'<span class="error">'.$langs->trans(
"SmsNoPossibleSenderFound");
233 if (is_object($sms) && !empty($sms->error)) {
234 print
' '.$sms->error;
244 if ($this->withto || is_array($this->withto)) {
248 print $form->textwithpicto($langs->trans(
"SmsTo"), $moretext);
250 if ($this->withtoreadonly) {
251 print (!is_array($this->withto) && !is_numeric($this->withto)) ? $this->withto :
"";
253 print
'<input size="16" id="sendto" name="sendto" value="'.dol_escape_htmltag(!is_array($this->withto) && $this->withto !=
'1' ? (GETPOSTISSET(
"sendto") ?
GETPOST(
"sendto") : $this->withto) :
"+").
'">';
254 if (!empty($this->withtosocid) && $this->withtosocid > 0) {
256 foreach ($soc->thirdparty_and_contact_phone_array() as $key => $value) {
257 $liste[$key] = $value;
259 print
" ".$langs->trans(
"or").
" ";
261 print $form->selectarray(
"receiver", $liste,
GETPOST(
"receiver"), 1);
263 print
' <span class="opacitymedium">'.$langs->trans(
"SmsInfoNumero").
'</span>';
265 print
"</td></tr>\n";
269 if ($this->withbody) {
270 $defaultmessage =
'';
271 if ($this->param[
"models"] ==
'body') {
272 $defaultmessage = $this->withbody;
275 if (GETPOSTISSET(
"message")) {
276 $defaultmessage =
GETPOST(
"message",
'restricthtml');
278 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
281 print
'<td class="tdtop">'.$langs->trans(
"SmsText").
"</td>";
283 if ($this->withbodyreadonly) {
284 print nl2br($defaultmessage);
285 print
'<input type="hidden" name="message" value="'.dol_escape_htmltag($defaultmessage).
'">';
287 print
'<textarea class="quatrevingtpercent" name="message" id="message" rows="'.ROWS_4.
'" onkeyup="limitChars(this, 160, \'charlimitinfospan\')">'.$defaultmessage.
'</textarea>';
288 print
'<div id="charlimitinfo" class="opacitymedium">'.$langs->trans(
"SmsInfoCharRemain").
': <span id="charlimitinfospan">'.(160 -
dol_strlen($defaultmessage)).
'</span></div></td>';
290 print
"</td></tr>\n";
295 <td>'.$langs->trans(
"DelayBeforeSending").
':</td>
296 <td> <input name="deferred" id="deferred" size="4" value="0"></td></tr>
298 <tr><td>'.$langs->trans(
"Priority").
' :</td><td>
299 <select name="priority" id="priority" class="flat">
300 <option value="0">high</option>
301 <option value="1">medium</option>
302 <option value="2" selected>low</option>
303 <option value="3">veryLow</option>
306 <tr><td>'.$langs->trans(
"Type").
' :</td><td>
307 <select name="class" id="class" class="flat">
308 <option value="0">Flash</option>
309 <option value="1" selected>Standard</option>
310 <option value="2">SIM</option>
311 <option value="3">ToolKit</option>
314 <tr><td>'.$langs->trans(
"DisableStopIfSupported").
' :</td><td>
315 <select name="disablestop" id="disablestop" class="flat">
316 <option value="0" selected>No</option>
317 <option value="1" selected>Yes</option>
318 </select></td></tr>';
324 print
'<div class="center">';
325 print
'<input type="submit" class="button" name="sendmail" value="'.dol_escape_htmltag($langs->trans(
"SendSms")).
'">';
326 if ($this->withcancel) {
327 print
' ';
328 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
335 print
"<!-- End form SMS -->\n";