25 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
61 public $withfromreadonly;
62 public $withreplytoreadonly;
63 public $withtoreadonly;
64 public $withtopicreadonly;
67 public $substit = array();
68 public $param = array();
78 public $errors = array();
95 $this->withfromreadonly = 1;
96 $this->withreplytoreadonly = 1;
97 $this->withtoreadonly = 0;
98 $this->withtopicreadonly = 0;
99 $this->withbodyreadonly = 0;
110 public function show_form($morecss =
'titlefield', $showform = 1)
113 global $conf, $langs, $user, $form;
115 if (!is_object($form)) $form =
new Form($this->
db);
118 $langs->loadLangs(array(
'other',
'mails',
'sms'));
121 if (!empty($this->withtosocid) && $this->withtosocid > 0)
123 $soc->fetch($this->withtosocid);
126 print "\n<!-- Begin form SMS -->\n";
129 <script language="javascript">
130 function limitChars(textarea, limit, infodiv)
132 var text = textarea.value;
133 var textlength = text.length;
134 var info = document.getElementById(infodiv);
136 info.innerHTML = (limit - textlength);
141 if ($showform)
print "<form method=\"POST\" name=\"smsform\" enctype=\"multipart/form-data\" action=\"".$this->param[
"returnurl"].
"\">\n";
143 print '<input type="hidden" name="token" value="'.newToken().
'">';
144 foreach ($this->param as $key=>$value)
146 print "<input type=\"hidden\" name=\"$key\" value=\"$value\">\n";
148 print "<table class=\"border centpercent\">\n";
151 if (!empty($this->withsubstit))
153 print "<tr><td colspan=\"2\">";
155 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";
166 if ($this->withfromreadonly)
168 print '<tr><td class="titlefield '.$morecss.
'">'.$langs->trans(
"SmsFrom");
169 print '<input type="hidden" name="fromsms" value="'.$this->fromsms.
'">';
171 if ($this->fromtype ==
'user')
173 $langs->load(
"users");
174 $fuser =
new User($this->
db);
175 $fuser->fetch($this->fromid);
176 print $fuser->getNomUrl(1);
181 print $this->fromsms;
185 $langs->load(
"errors");
186 print '<font class="warning"> <'.$langs->trans(
"ErrorNoPhoneDefinedForThisUser").
'> </font>';
189 print "</td></tr>\n";
190 print "</td></tr>\n";
192 print '<tr><td class="'.$morecss.
'">'.$langs->trans(
"SmsFrom").
"</td><td>";
194 if ($conf->global->MAIN_SMS_SENDMODE ==
'ovh')
198 $sms =
new OvhSms($this->
db);
199 if (empty($conf->global->OVHSMS_ACCOUNT))
201 $resultsender =
'ErrorOVHSMS_ACCOUNT not defined';
203 $resultsender = $sms->SmsSenderList();
207 dol_print_error(
'',
'Error to get list of senders: '.$e->getMessage());
209 } elseif (!empty($conf->global->MAIN_SMS_SENDMODE))
211 $tmp = explode(
'@', $conf->global->MAIN_SMS_SENDMODE);
212 $classfile = $tmp[0]; $module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]);
215 $classname = ucfirst($classfile);
216 if (class_exists($classname))
218 $sms =
new $classname($this->
db);
219 $resultsender = $sms->SmsSenderList();
221 $sms =
new stdClass();
222 $sms->error =
'The SMS manager "'.$classfile.
'" defined into SMS setup MAIN_SMS_SENDMODE is not found';
226 dol_print_error(
'',
'Error to get list of senders: '.$e->getMessage());
230 dol_syslog(
"Warning: The SMS sending method has not been defined into MAIN_SMS_SENDMODE", LOG_WARNING);
231 $resultsender = array();
232 $resultsender[0]->number = $this->fromsms;
235 if (is_array($resultsender) && count($resultsender) > 0)
237 print '<select name="fromsms" id="fromsms" class="flat">';
238 foreach ($resultsender as $obj)
240 print '<option value="'.$obj->number.
'">'.$obj->number.
'</option>';
244 print '<span class="error">'.$langs->trans(
"SmsNoPossibleSenderFound");
245 if (is_object($sms) && !empty($sms->error))
print ' '.$sms->error;
254 if ($this->withto || is_array($this->withto))
259 print $form->textwithpicto($langs->trans(
"SmsTo"), $moretext);
261 if ($this->withtoreadonly)
263 print (!is_array($this->withto) && !is_numeric($this->withto)) ? $this->withto :
"";
265 print "<input size=\"16\" id=\"sendto\" name=\"sendto\" value=\"".dol_escape_htmltag(!is_array($this->withto) && $this->withto !=
'1' ? (isset($_REQUEST[
"sendto"]) ?
GETPOST(
"sendto") : $this->withto) :
"+").
"\">";
266 if (!empty($this->withtosocid) && $this->withtosocid > 0)
269 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">'.$langs->trans(
"SmsInfoNumero").
'</span>';
279 print "</td></tr>\n";
285 $defaultmessage =
'';
286 if ($this->param[
"models"] ==
'body')
288 $defaultmessage = $this->withbody;
292 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
295 print '<td class="tdtop">'.$langs->trans(
"SmsText").
"</td>";
297 if ($this->withbodyreadonly)
299 print nl2br($defaultmessage);
300 print '<input type="hidden" name="message" value="'.dol_escape_htmltag($defaultmessage).
'">';
302 print '<textarea class="quatrevingtpercent" name="message" id="message" rows="'.ROWS_4.
'" onkeyup="limitChars(this, 160, \'charlimitinfospan\')">'.$defaultmessage.
'</textarea>';
303 print '<div id="charlimitinfo">'.$langs->trans(
"SmsInfoCharRemain").
': <span id="charlimitinfospan">'.(160 -
dol_strlen($defaultmessage)).
'</span></div></td>';
305 print "</td></tr>\n";
310 <td>'.$langs->trans(
"DelayBeforeSending").
':</td>
311 <td> <input name="deferred" id="deferred" size="4" value="0"></td></tr>
313 <tr><td>'.$langs->trans(
"Priority").
' :</td><td>
314 <select name="priority" id="priority" class="flat">
315 <option value="0">high</option>
316 <option value="1">medium</option>
317 <option value="2" selected>low</option>
318 <option value="3">veryLow</option>
321 <tr><td>'.$langs->trans(
"Type").
' :</td><td>
322 <select name="class" id="class" class="flat">
323 <option value="0">Flash</option>
324 <option value="1" selected>Standard</option>
325 <option value="2">SIM</option>
326 <option value="3">ToolKit</option>
329 <tr><td>'.$langs->trans(
"DisableStopIfSupported").
' :</td><td>
330 <select name="disablestop" id="disablestop" class="flat">
331 <option value="0" selected>No</option>
332 <option value="1" selected>Yes</option>
333 </select></td></tr>';
340 print '<div class="center">';
341 print '<input class="button" type="submit" name="sendmail" value="'.dol_escape_htmltag($langs->trans(
"SendSms")).
'">';
342 if ($this->withcancel)
344 print ' ';
345 print '<input class="button button-cancel" type="submit" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
352 print "<!-- End form SMS -->\n";
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage Dolibarr users.
$conf db
API class for accounts.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
print
Draft customers invoices.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...