WIP SMSing

This commit is contained in:
Laurent Destailleur
2024-02-03 17:57:12 +01:00
parent 0dad676f16
commit 021fb83ec6
10 changed files with 296 additions and 204 deletions

View File

@@ -459,7 +459,7 @@ if ($object->fetch($id) >= 0) {
print "</div>";
// Show email selectors
if ($object->statut == 0 && $user->hasRight('mailing', 'creer')) {
if ($object->status == 0 && $user->hasRight('mailing', 'creer')) {
include DOL_DOCUMENT_ROOT.'/core/tpl/advtarget.tpl.php';
}
}

View File

@@ -162,7 +162,7 @@ if (empty($reshook)) {
setEventMessages($langs->trans("NotEnoughPermissions"), null, 'warnings');
$action = '';
} else {
if ($object->statut == 0) {
if ($object->status == 0) {
dol_print_error(null, 'ErrorMailIsNotValidated');
exit;
}
@@ -547,6 +547,7 @@ if (empty($reshook)) {
if ($action == 'add') {
$mesgs = array();
$object->messtype = (string) GETPOST("messtype");
$object->email_from = (string) GETPOST("from", 'alphawithlgt'); // Must allow 'name <email>'
$object->email_replyto = (string) GETPOST("replyto", 'alphawithlgt'); // Must allow 'name <email>'
$object->email_errorsto = (string) GETPOST("errorsto", 'alphawithlgt'); // Must allow 'name <email>'
@@ -559,7 +560,7 @@ if (empty($reshook)) {
if (!$object->title) {
$mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle"));
}
if (!$object->sujet) {
if ($object->messtype != 'sms' && !$object->sujet) {
$mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTopic"));
}
if (!$object->body) {
@@ -645,12 +646,14 @@ if (empty($reshook)) {
if (!$isupload) {
$mesgs = array();
//$object->messtype = (string) GETPOST("messtype"); // We must not be able to change the messtype
$object->sujet = (string) GETPOST("sujet");
$object->body = (string) GETPOST("bodyemail", 'restricthtml');
$object->bgcolor = preg_replace('/^#/', '', (string) GETPOST("bgcolor"));
$object->bgimage = (string) GETPOST("bgimage");
if (!$object->sujet) {
if ($object->messtype != 'sms' && !$object->sujet) {
$mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTopic"));
}
if (!$object->body) {
@@ -777,7 +780,7 @@ if ($action == 'create') {
$htmltext .= '</span></i>';
$availablelink = $form->textwithpicto('<span class="opacitymedium">'.$langs->trans("AvailableVariables").'</span>', $htmltext, 1, 'help', '', 0, 2, 'availvar');
$availablelink = $form->textwithpicto('<span class="opacitymedium">'.$langs->trans("AvailableVariables").'</span>', $htmltext, 1, 'helpclickable', '', 0, 2, 'availvar');
//print '<a href="javascript:document_preview(\''.DOL_URL_ROOT.'/admin/modulehelp.php?id='.$objMod->numero.'\',\'text/html\',\''.dol_escape_js($langs->trans("Module")).'\')">'.img_picto($langs->trans("ClickToShowDescription"), $imginfo).'</a>';
@@ -790,9 +793,40 @@ if ($action == 'create') {
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("MailTitle").'</td><td><input class="flat minwidth300" name="title" value="'.dol_escape_htmltag(GETPOST('title')).'" autofocus="autofocus"></td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("MailFrom").'</td><td><input class="flat minwidth200" name="from" value="'.getDolGlobalString('MAILING_EMAIL_FROM').'"></td></tr>';
if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
$arrayoftypes = array("email" => "Email", "sms" => "SMS");
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Type").'</td><td>';
print $form->selectarray('messtype', $arrayoftypes, (GETPOSTISSET('messtype') ? GETPOST('messtype') : 'email'), 0, 0);
print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td><input class="flat minwidth200" name="errorsto" value="'.getDolGlobalString('MAILING_EMAIL_ERRORSTO', getDolGlobalString('MAIN_MAIL_ERRORS_TO')).'"></td></tr>';
print '<script>
$( document ).ready(function() {
jQuery("#messtype").on("change", function() {
console.log("We change the message ttpe");
if (jQuery("#messtype").val() == "email") {
jQuery(".fieldsforsms").hide();
jQuery(".fieldsforemail").show();
}
if (jQuery("#messtype").val() == "sms") {
jQuery(".fieldsforsms").show();
jQuery(".fieldsforemail").hide();
}
});
jQuery("#messtype").change();
})
</script>';
print '</td></tr>';
}
print '</table>';
print '<br><br>';
print '<table class="border centpercent">';
print '<tr class="fieldsforemail"><td class="fieldrequired titlefieldcreate">'.$langs->trans("MailFrom").'</td><td><input class="flat minwidth200" name="from" value="'.(GETPOSTISSET('from') ? GETPOST('from') : getDolGlobalString('MAILING_EMAIL_FROM')).'"></td></tr>';
print '<tr class="fieldsforsms hidden"><td class="fieldrequired titlefieldcreate">'.$langs->trans("PhoneFrom").'</td><td><input class="flat minwidth200" name="from" value="'.(GETPOSTISSET('from') ? GETPOST('from') : getDolGlobalString('MAILING_SMS_FROM')).'" placeholder="+123..."></td></tr>';
print '<tr class="fieldsforemail"><td>'.$langs->trans("MailErrorsTo").'</td><td><input class="flat minwidth200" name="errorsto" value="'.getDolGlobalString('MAILING_EMAIL_ERRORSTO', getDolGlobalString('MAIN_MAIL_ERRORS_TO')).'"></td></tr>';
// Other attributes
$parameters = array();
@@ -806,8 +840,8 @@ if ($action == 'create') {
print '<br><br>';
print '<table class="border centpercent">';
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("MailTopic").'</td><td><input class="flat minwidth200 quatrevingtpercent" name="sujet" value="'.dol_escape_htmltag(GETPOST('sujet', 'alphanohtml')).'"></td></tr>';
print '<tr><td>'.$langs->trans("BackgroundColorByDefault").'</td><td colspan="3">';
print '<tr class="fieldsforemail"><td class="fieldrequired titlefieldcreate">'.$langs->trans("MailTopic").'</td><td><input class="flat minwidth200 quatrevingtpercent" name="sujet" value="'.dol_escape_htmltag(GETPOST('sujet', 'alphanohtml')).'"></td></tr>';
print '<tr class="fieldsforemail"><td>'.$langs->trans("BackgroundColorByDefault").'</td><td colspan="3">';
print $htmlother->selectColor(GETPOST('bgcolor'), 'bgcolor', '', 0);
print '</td></tr>';
@@ -822,7 +856,7 @@ if ($action == 'create') {
print dol_get_fiche_end();
print $form->buttonsSaveCancel("CreateMailing", 'Cancel');
print $form->buttonsSaveCancel("Create", 'Cancel');
print '</form>';
} else {
@@ -845,7 +879,7 @@ if ($action == 'create') {
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.(!empty($urlfrom) ? '&urlfrom='.urlencode($urlfrom) : ''), $langs->trans("DeleteAMailing"), $langs->trans("ConfirmDeleteMailing"), "confirm_delete", '', '', 1);
}
if ($action != 'edit' && $action != 'edithtml') {
if ($action != 'edit' && $action != 'edittxt' &&$action != 'edithtml') {
print dol_get_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email');
/*
@@ -934,7 +968,7 @@ if ($action == 'create') {
$morehtmlright = '';
$nbtry = $nbok = 0;
if ($object->statut == 2 || $object->statut == 3) {
if ($object->status == 2 || $object->status == 3) {
$nbtry = $object->countNbOfTargets('alreadysent');
$nbko = $object->countNbOfTargets('alreadysentko');
@@ -954,9 +988,9 @@ if ($action == 'create') {
// From
print '<tr><td class="titlefield">';
print $form->editfieldkey("MailFrom", 'email_from', $object->email_from, $object, $user->hasRight('mailing', 'creer') && $object->statut < 3, 'string');
print $form->editfieldkey("MailFrom", 'email_from', $object->email_from, $object, $user->hasRight('mailing', 'creer') && $object->status < 3, 'string');
print '</td><td>';
print $form->editfieldval("MailFrom", 'email_from', $object->email_from, $object, $user->hasRight('mailing', 'creer') && $object->statut < 3, 'string');
print $form->editfieldval("MailFrom", 'email_from', $object->email_from, $object, $user->hasRight('mailing', 'creer') && $object->status < 3, 'string');
$email = CMailFile::getValidAddress($object->email_from, 2);
if ($email && !isValidEmail($email)) {
$langs->load("errors");
@@ -969,19 +1003,21 @@ if ($action == 'create') {
print '</td></tr>';
// Errors to
print '<tr><td>';
print $form->editfieldkey("MailErrorsTo", 'email_errorsto', $object->email_errorsto, $object, $user->hasRight('mailing', 'creer') && $object->statut < 3, 'string');
print '</td><td>';
print $form->editfieldval("MailErrorsTo", 'email_errorsto', $object->email_errorsto, $object, $user->hasRight('mailing', 'creer') && $object->statut < 3, 'string');
$email = CMailFile::getValidAddress($object->email_errorsto, 2);
if ($email && !isValidEmail($email)) {
$langs->load("errors");
print img_warning($langs->trans("ErrorBadEMail", $email));
} elseif ($email && !isValidMailDomain($email)) {
$langs->load("errors");
print img_warning($langs->trans("ErrorBadMXDomain", $email));
if ($object->messtype != 'sms') {
print '<tr><td>';
print $form->editfieldkey("MailErrorsTo", 'email_errorsto', $object->email_errorsto, $object, $user->hasRight('mailing', 'creer') && $object->status < 3, 'string');
print '</td><td>';
print $form->editfieldval("MailErrorsTo", 'email_errorsto', $object->email_errorsto, $object, $user->hasRight('mailing', 'creer') && $object->status < 3, 'string');
$email = CMailFile::getValidAddress($object->email_errorsto, 2);
if ($email && !isValidEmail($email)) {
$langs->load("errors");
print img_warning($langs->trans("ErrorBadEMail", $email));
} elseif ($email && !isValidMailDomain($email)) {
$langs->load("errors");
print img_warning($langs->trans("ErrorBadMXDomain", $email));
}
print '</td></tr>';
}
print '</td></tr>';
print '</table>';
print '</div>';
@@ -992,13 +1028,13 @@ if ($action == 'create') {
print '<table class="border centpercent tableforfield">';
// Number of distinct emails
print '<tr><td class="titlefield">';
print '<tr><td>';
print $langs->trans("TotalNbOfDistinctRecipients");
print '</td><td>';
$nbemail = ($object->nbemail ? $object->nbemail : 0);
if (is_numeric($nbemail)) {
$text = '';
if ((getDolGlobalString('MAILING_LIMIT_SENDBYWEB') && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) {
if ((getDolGlobalString('MAILING_LIMIT_SENDBYWEB') && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->status == 1 || ($object->status == 2 && $nbtry < $nbemail))) {
if (getDolGlobalInt('MAILING_LIMIT_SENDBYWEB') > 0) {
$text .= $langs->trans('LimitSendingEmailing', getDolGlobalString('MAILING_LIMIT_SENDBYWEB'));
} else {
@@ -1064,19 +1100,21 @@ if ($action == 'create') {
if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test', 'editevenunsubscribe'))) {
print "\n\n<div class=\"tabsAction\">\n";
if (($object->statut == 1) && ($user->hasRight('mailing', 'valider') || $object->user_validation_id == $user->id)) {
if (($object->status == 1) && ($user->hasRight('mailing', 'valider') || $object->user_validation_id == $user->id)) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=settodraft&token='.newToken().'&id='.$object->id.'">'.$langs->trans("SetToDraft").'</a>';
}
if (($object->statut == 0 || $object->statut == 1 || $object->statut == 2) && $user->hasRight('mailing', 'creer')) {
if (isModEnabled('fckeditor') && getDolGlobalString('FCKEDITOR_ENABLE_MAILING')) {
if (($object->status == 0 || $object->status == 1 || $object->status == 2) && $user->hasRight('mailing', 'creer')) {
if (isModEnabled('fckeditor') && getDolGlobalString('FCKEDITOR_ENABLE_MAILING') && $object->messtype != 'sms') {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&token='.newToken().'&id='.$object->id.'">'.$langs->trans("EditWithEditor").'</a>';
} else {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&token='.newToken().'&id='.$object->id.'">'.$langs->trans("EditWithTextEditor").'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edittxt&token='.newToken().'&id='.$object->id.'">'.$langs->trans("EditWithTextEditor").'</a>';
}
if (!empty($conf->use_javascript_ajax)) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edithtml&token='.newToken().'&id='.$object->id.'">'.$langs->trans("EditHTMLSource").'</a>';
if (!getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
if (!empty($conf->use_javascript_ajax)) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edithtml&token='.newToken().'&id='.$object->id.'">'.$langs->trans("EditHTMLSource").'</a>';
}
}
}
@@ -1088,17 +1126,17 @@ if ($action == 'create') {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=test&token='.newToken().'&id='.$object->id.'">'.$langs->trans("TestMailing").'</a>';
}
if ($object->statut == 0) {
if ($object->status == 0) {
if ($object->nbemail <= 0) {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NoTargetYet")).'">'.$langs->trans("ValidMailing").'</a>';
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NoTargetYet")).'">'.$langs->trans("Validate").'</a>';
} elseif (!$user->hasRight('mailing', 'valider')) {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("ValidMailing").'</a>';
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("Validate").'</a>';
} else {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=valid&amp;id='.$object->id.'">'.$langs->trans("ValidMailing").'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=valid&amp;id='.$object->id.'">'.$langs->trans("Validate").'</a>';
}
}
if (($object->statut == 1 || $object->statut == 2) && $object->nbemail > 0 && $user->hasRight('mailing', 'valider')) {
if (($object->status == 1 || $object->status == 2) && $object->nbemail > 0 && $user->hasRight('mailing', 'valider')) {
if (getDolGlobalInt('MAILING_LIMIT_SENDBYWEB') < 0) {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("SendingFromWebInterfaceIsNotAllowed")).'">'.$langs->trans("SendMailing").'</a>';
} elseif (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('mailing', 'mailing_advance', 'send')) {
@@ -1112,7 +1150,7 @@ if ($action == 'create') {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=clone&amp;object=emailing&amp;id='.$object->id.'">'.$langs->trans("ToClone").'</a>';
}
if (($object->statut == 2 || $object->statut == 3) && $user->hasRight('mailing', 'valider')) {
if (($object->status == 2 || $object->status == 3) && $user->hasRight('mailing', 'valider')) {
if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('mailing', 'mailing_advance', 'send')) {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("ResetMailing").'</a>';
} else {
@@ -1120,11 +1158,11 @@ if ($action == 'create') {
}
}
if (($object->statut <= 1 && $user->hasRight('mailing', 'creer')) || $user->hasRight('mailing', 'supprimer')) {
if ($object->statut > 0 && (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('mailing', 'mailing_advance', 'delete'))) {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("DeleteMailing").'</a>';
if (($object->status <= 1 && $user->hasRight('mailing', 'creer')) || $user->hasRight('mailing', 'supprimer')) {
if ($object->status > 0 && (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('mailing', 'mailing_advance', 'delete'))) {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("Delete").'</a>';
} else {
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id.(!empty($urlfrom) ? '&urlfrom='.$urlfrom : '').'">'.$langs->trans("DeleteMailing").'</a>';
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id.(!empty($urlfrom) ? '&urlfrom='.$urlfrom : '').'">'.$langs->trans("Delete").'</a>';
}
}
@@ -1187,21 +1225,25 @@ if ($action == 'create') {
print '<table class="bordernooddeven tableforfield centpercent">';
// Subject
print '<tr><td class="titlefield">'.$langs->trans("MailTopic").'</td><td colspan="3">'.$object->sujet.'</td></tr>';
if ($object->messtype != 'sms') {
print '<tr><td class="titlefield">'.$langs->trans("MailTopic").'</td><td colspan="3">'.$object->sujet.'</td></tr>';
}
// Joined files
print '<tr><td>'.$langs->trans("MailFile").'</td><td colspan="3">';
// List of files
$listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0);
if (count($listofpaths)) {
foreach ($listofpaths as $key => $val) {
print img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name'];
print '<br>';
if ($object->messtype != 'sms') {
print '<tr><td>'.$langs->trans("MailFile").'</td><td colspan="3">';
// List of files
$listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0);
if (count($listofpaths)) {
foreach ($listofpaths as $key => $val) {
print img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name'];
print '<br>';
}
} else {
print '<span class="opacitymedium">'.$langs->trans("NoAttachedFiles").'</span><br>';
}
} else {
print '<span class="opacitymedium">'.$langs->trans("NoAttachedFiles").'</span><br>';
print '</td></tr>';
}
print '</td></tr>';
// Background color
/*print '<tr><td width="15%">'.$langs->trans("BackgroundColorByDefault").'</td><td colspan="3">';
@@ -1241,7 +1283,7 @@ if ($action == 'create') {
$morehtmlright = '';
$nbtry = $nbok = 0;
if ($object->statut == 2 || $object->statut == 3) {
if ($object->status == 2 || $object->status == 3) {
$nbtry = $object->countNbOfTargets('alreadysent');
$nbko = $object->countNbOfTargets('alreadysentko');
@@ -1268,9 +1310,13 @@ if ($action == 'create') {
*/
// From
print '<tr><td class="titlefield">'.$langs->trans("MailFrom").'</td><td>'.dol_print_email($object->email_from, 0, 0, 0, 0, 1).'</td></tr>';
print '<tr><td class="titlefield">';
print $langs->trans("MailFrom");
print '</td><td>'.dol_print_email($object->email_from, 0, 0, 0, 0, 1).'</td></tr>';
// To
print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>'.dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1).'</td></tr>';
if ($object->messtype != 'sms') {
print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>'.dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1).'</td></tr>';
}
print '</table>';
print '</div>';
@@ -1288,7 +1334,7 @@ if ($action == 'create') {
$nbemail = ($object->nbemail ? $object->nbemail : 0);
if (is_numeric($nbemail)) {
$text = '';
if ((getDolGlobalString('MAILING_LIMIT_SENDBYWEB') && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2)) {
if ((getDolGlobalString('MAILING_LIMIT_SENDBYWEB') && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->status == 1 || $object->status == 2)) {
if (getDolGlobalInt('MAILING_LIMIT_SENDBYWEB') > 0) {
$text .= $langs->trans('LimitSendingEmailing', getDolGlobalString('MAILING_LIMIT_SENDBYWEB'));
} else {
@@ -1365,54 +1411,60 @@ if ($action == 'create') {
print '<table class="bordernooddeven centpercent">';
// Subject
print '<tr><td class="fieldrequired titlefield">'.$langs->trans("MailTopic").'</td><td colspan="3"><input class="flat quatrevingtpercent" type="text" name="sujet" value="'.$object->sujet.'"></td></tr>';
if ($object->messtype != 'sms') {
print '<tr><td class="fieldrequired titlefield">';
print $langs->trans("MailTopic");
print '</td><td colspan="3"><input class="flat quatrevingtpercent" type="text" name="sujet" value="'.$object->sujet.'"></td></tr>';
}
$trackid = ''; // TODO To avoid conflicts with 2 mass emailing, we should set a trackid here, even if we use another one into email header.
dol_init_file_process($upload_dir, $trackid);
// Joined files
$addfileaction = 'addfile';
print '<tr><td>'.$langs->trans("MailFile").'</td>';
print '<td colspan="3">';
// List of files
$listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0);
if ($object->messtype != 'sms') {
$addfileaction = 'addfile';
print '<tr><td>'.$langs->trans("MailFile").'</td>';
print '<td colspan="3">';
// List of files
$listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0);
// TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript
$out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">'."\n";
$out .= '<script type="text/javascript">';
$out .= 'jQuery(document).ready(function () {';
$out .= ' jQuery(".removedfile").click(function() {';
$out .= ' jQuery(".removedfilehidden").val(jQuery(this).val());';
$out .= ' });';
$out .= '})';
$out .= '</script>'."\n";
if (count($listofpaths)) {
foreach ($listofpaths as $key => $val) {
$out .= '<div id="attachfile_'.$key.'">';
$out .= img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name'];
$out .= ' <input type="image" style="border: 0px;" src="'.img_picto($langs->trans("Search"), 'delete.png', '', '', 1).'" value="'.($key + 1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />';
$out .= '<br></div>';
// TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript
$out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">'."\n";
$out .= '<script type="text/javascript">';
$out .= 'jQuery(document).ready(function () {';
$out .= ' jQuery(".removedfile").click(function() {';
$out .= ' jQuery(".removedfilehidden").val(jQuery(this).val());';
$out .= ' });';
$out .= '})';
$out .= '</script>'."\n";
if (count($listofpaths)) {
foreach ($listofpaths as $key => $val) {
$out .= '<div id="attachfile_'.$key.'">';
$out .= img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name'];
$out .= ' <input type="image" style="border: 0px;" src="'.img_picto($langs->trans("Search"), 'delete.png', '', '', 1).'" value="'.($key + 1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />';
$out .= '<br></div>';
}
} else {
//$out .= '<span class="opacitymedium">'.$langs->trans("NoAttachedFiles").'</span><br>';
}
} else {
//$out .= '<span class="opacitymedium">'.$langs->trans("NoAttachedFiles").'</span><br>';
}
// Add link to add file
$maxfilesizearray = getMaxFileSizeArray();
$maxmin = $maxfilesizearray['maxmin'];
if ($maxmin > 0) {
$out .= '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file
}
$out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />';
$out .= ' ';
$out .= '<input type="submit" class="button smallpaddingimp" id="'.$addfileaction.'" name="'.$addfileaction.'" value="'.$langs->trans("MailingAddFile").'" />';
print $out;
print '</td></tr>';
// Add link to add file
$maxfilesizearray = getMaxFileSizeArray();
$maxmin = $maxfilesizearray['maxmin'];
if ($maxmin > 0) {
$out .= '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file
}
$out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />';
$out .= ' ';
$out .= '<input type="submit" class="button smallpaddingimp" id="'.$addfileaction.'" name="'.$addfileaction.'" value="'.$langs->trans("MailingAddFile").'" />';
print $out;
print '</td></tr>';
// Background color
print '<tr><td>'.$langs->trans("BackgroundColorByDefault").'</td><td colspan="3">';
print $htmlother->selectColor($object->bgcolor, 'bgcolor', '', 0);
print '</td></tr>';
// Background color
print '<tr><td>'.$langs->trans("BackgroundColorByDefault").'</td><td colspan="3">';
print $htmlother->selectColor($object->bgcolor, 'bgcolor', '', 0);
print '</td></tr>';
}
print '</table>';
@@ -1426,6 +1478,12 @@ if ($action == 'create') {
$doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, getDolGlobalInt('FCKEDITOR_ENABLE_MAILING'), 20, '90%');
$doleditor->Create();
}
if ($action == 'edittxt') {
// wysiwyg editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, 0, 20, '90%');
$doleditor->Create();
}
if ($action == 'edithtml') {
// HTML source editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@@ -275,7 +275,7 @@ if ($object->fetch($id) >= 0) {
$morehtmlright = '';
$nbtry = $nbok = 0;
if ($object->statut == $object::STATUS_SENTPARTIALY || $object->statut == $object::STATUS_SENTCOMPLETELY) {
if ($object->status == $object::STATUS_SENTPARTIALY || $object->status == $object::STATUS_SENTCOMPLETELY) {
$nbtry = $object->countNbOfTargets('alreadysent');
$nbko = $object->countNbOfTargets('alreadysentko');
$nbok = ($nbtry - $nbko);
@@ -314,21 +314,23 @@ if ($object->fetch($id) >= 0) {
print '</td></tr>';
// Errors to
print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
$emailarray = CMailFile::getArrayAddress($object->email_errorsto);
foreach ($emailarray as $email => $name) {
if ($name != $email) {
print dol_escape_htmltag($name).' &lt;'.$email;
print '&gt;';
if (!isValidEmail($email)) {
$langs->load("errors");
print img_warning($langs->trans("ErrorBadEMail", $email));
if ($object->messtype != 'sms') {
print '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
$emailarray = CMailFile::getArrayAddress($object->email_errorsto);
foreach ($emailarray as $email => $name) {
if ($name != $email) {
print dol_escape_htmltag($name).' &lt;'.$email;
print '&gt;';
if (!isValidEmail($email)) {
$langs->load("errors");
print img_warning($langs->trans("ErrorBadEMail", $email));
}
} else {
print dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1);
}
} else {
print dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1);
}
print '</td></tr>';
}
print '</td></tr>';
print '</table>';
print '</div>';
@@ -340,13 +342,13 @@ if ($object->fetch($id) >= 0) {
print '<table class="border centpercent tableforfield">';
// Number of distinct emails
print '<tr><td class="titlefield">';
print '<tr><td>';
print $langs->trans("TotalNbOfDistinctRecipients");
print '</td><td>';
$nbemail = ($object->nbemail ? $object->nbemail : 0);
if (is_numeric($nbemail)) {
$text = '';
if ((getDolGlobalString('MAILING_LIMIT_SENDBYWEB') && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) {
if ((getDolGlobalString('MAILING_LIMIT_SENDBYWEB') && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->status == 1 || ($object->status == 2 && $nbtry < $nbemail))) {
if (getDolGlobalInt('MAILING_LIMIT_SENDBYWEB') > 0) {
$text .= $langs->trans('LimitSendingEmailing', getDolGlobalString('MAILING_LIMIT_SENDBYWEB'));
} else {
@@ -398,7 +400,7 @@ if ($object->fetch($id) >= 0) {
print '<br>';
$allowaddtarget = ($object->statut == $object::STATUS_DRAFT);
$allowaddtarget = ($object->status == $object::STATUS_DRAFT);
// Show email selectors
if ($allowaddtarget && $user->hasRight('mailing', 'creer')) {
@@ -410,11 +412,19 @@ if ($object->fetch($id) >= 0) {
print '<div class="tagtr liste_titre">';
print '<div class="tagtd"></div>';
print '<div class="tagtd">'.$langs->trans("RecipientSelectionModules").'</div>';
print '<div class="tagtd center maxwidth150">'.$langs->trans("NbOfUniqueEMails").'</div>';
print '<div class="tagtd left"><div class="inline-block">'.$langs->trans("Filters").'</div>';
print ' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div class=" inline-block">'.$langs->trans("EvenUnsubscribe").' ';
print ajax_object_onoff($object, 'evenunsubscribe', 'evenunsubscribe', 'EvenUnsubscribe:switch_on:warning', 'EvenUnsubscribe', array(), 'small valignmiddle', '', 1);
print '<div class="tagtd center maxwidth150">';
if ($object->messtype != 'sms') {
print $langs->trans("NbOfUniqueEMails");
} else {
print $langs->trans("NbOfUniquePhones");
}
print '</div>';
print '<div class="tagtd left"><div class="inline-block">'.$langs->trans("Filters").'</div>';
if ($object->messtype != 'sms') {
print ' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div class=" inline-block">'.$langs->trans("EvenUnsubscribe").' ';
print ajax_object_onoff($object, 'evenunsubscribe', 'evenunsubscribe', 'EvenUnsubscribe:switch_on:warning', 'EvenUnsubscribe', array(), 'small valignmiddle', '', 1);
print '</div>';
}
print '</div>';
print '<div class="tagtd">&nbsp;</div>';
print '</div>'; // End tr
@@ -776,12 +786,12 @@ if ($object->fetch($id) >= 0) {
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="center">';
print '<!-- ID mailing_cibles = '.$obj->rowid.' -->';
if ($obj->statut == $object::STATUS_DRAFT) { // Not sent yet
if ($obj->status == $object::STATUS_DRAFT) { // Not sent yet
if ($user->hasRight('mailing', 'creer')) {
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&rowid='.((int) $obj->rowid).$param.'">'.img_delete($langs->trans("RemoveRecipient")).'</a>';
}
}
/*if ($obj->statut == -1) // Sent with error
/*if ($obj->status == -1) // Sent with error
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=retry&rowid='.$obj->rowid.$param.'">'.$langs->trans("Retry").'</a>';
}*/
@@ -834,7 +844,7 @@ if ($object->fetch($id) >= 0) {
// Date sent
print '<td class="center nowraponall">';
if ($obj->statut != $object::STATUS_DRAFT) {
if ($obj->status != $object::STATUS_DRAFT) {
// Date sent
print $obj->date_envoi;
}
@@ -842,10 +852,10 @@ if ($object->fetch($id) >= 0) {
// Status of recipient sending email (Warning != status of emailing)
print '<td class="nowrap center">';
if ($obj->statut == $object::STATUS_DRAFT) {
print $object::libStatutDest($obj->statut, 2, '');
if ($obj->status == $object::STATUS_DRAFT) {
print $object::libStatutDest($obj->status, 2, '');
} else {
print $object::libStatutDest($obj->statut, 2, $obj->error_text);
print $object::libStatutDest($obj->status, 2, $obj->error_text);
}
print '</td>';
@@ -853,12 +863,12 @@ if ($object->fetch($id) >= 0) {
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="center">';
print '<!-- ID mailing_cibles = '.$obj->rowid.' -->';
if ($obj->statut == $object::STATUS_DRAFT) { // Not sent yet
if ($obj->status == $object::STATUS_DRAFT) { // Not sent yet
if ($user->hasRight('mailing', 'creer')) {
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&rowid='.((int) $obj->rowid).$param.'">'.img_delete($langs->trans("RemoveRecipient")).'</a>';
}
}
/*if ($obj->statut == -1) // Sent with error
/*if ($obj->status == -1) // Sent with error
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=retry&rowid='.$obj->rowid.$param.'">'.$langs->trans("Retry").'</a>';
}*/
@@ -869,7 +879,7 @@ if ($object->fetch($id) >= 0) {
$i++;
}
} else {
if ($object->statut < $object::STATUS_SENTPARTIALY) {
if ($object->status < $object::STATUS_SENTPARTIALY) {
print '<tr><td colspan="9">';
print '<span class="opacitymedium">'.$langs->trans("NoTargetYet").'</span>';
print '</td></tr>';

View File

@@ -88,9 +88,15 @@ class Mailing extends CommonObject
/**
* @var int status
* @deprecated
*/
public $statut; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely
/**
* @var int status
*/
public $status; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely
/**
* @var string email from
*/
@@ -131,47 +137,11 @@ class Mailing extends CommonObject
*/
public $joined_file4;
/**
* @var int id of user create
* @deprecated
*/
public $user_creation;
/**
* @var int id of user create
* @deprecated
*/
public $user_creat;
/**
* @var int id of user validate
* @deprecated
*/
public $user_validation;
/**
* @var int id of user validate
* @deprecated
*/
public $user_valid;
/**
* @var integer|string date_creation
* @deprecated
*/
public $date_creat;
/**
* @var integer|string date_creation
*/
public $date_creation;
/**
* @var int date validate
* @deprecated
*/
public $date_valid;
/**
* @var int date validate
*/
@@ -220,8 +190,6 @@ class Mailing extends CommonObject
*/
public function __construct($db)
{
global $langs;
$this->db = $db;
// List of language codes for status
@@ -258,12 +226,13 @@ class Mailing extends CommonObject
$this->email_from = trim($this->email_from);
if (!$this->email_from) {
$this->error = $langs->trans("ErrorMailFromRequired");
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("From"));
return -1;
}
$error = 0;
$now = dol_now();
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing";
@@ -275,6 +244,7 @@ class Mailing extends CommonObject
}
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."mailing");
@@ -328,6 +298,7 @@ class Mailing extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing ";
$sql .= " SET titre = '".$this->db->escape($this->title)."'";
$sql .= ", messtype = '".$this->db->escape($this->messtype)."'";
$sql .= ", sujet = '".$this->db->escape($this->sujet)."'";
$sql .= ", body = '".$this->db->escape($this->body)."'";
$sql .= ", email_from = '".$this->db->escape($this->email_from)."'";
@@ -375,11 +346,9 @@ class Mailing extends CommonObject
*/
public function fetch($rowid, $ref = '')
{
global $conf;
$sql = "SELECT m.rowid, m.titre as title, m.sujet, m.body, m.bgcolor, m.bgimage, m.evenunsubscribe";
$sql = "SELECT m.rowid, m.messtype, m.titre as title, m.sujet, m.body, m.bgcolor, m.bgimage, m.evenunsubscribe";
$sql .= ", m.email_from, m.email_replyto, m.email_errorsto";
$sql .= ", m.statut, m.nbemail";
$sql .= ", m.statut as status, m.nbemail";
$sql .= ", m.fk_user_creat, m.fk_user_valid";
$sql .= ", m.date_creat";
$sql .= ", m.date_valid";
@@ -401,9 +370,13 @@ class Mailing extends CommonObject
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->statut = $obj->statut;
$this->nbemail = $obj->nbemail;
$this->title = $obj->title;
$this->messtype = $obj->messtype;
$this->statut = $obj->status; // deprecated
$this->status = $obj->status;
$this->nbemail = $obj->nbemail;
$this->sujet = $obj->sujet;
if (getDolGlobalString('FCKEDITOR_ENABLE_MAILING') && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5))) {
@@ -423,14 +396,16 @@ class Mailing extends CommonObject
$this->user_creation_id = $obj->fk_user_creat;
$this->user_validation_id = $obj->fk_user_valid;
$this->date_creat = $this->db->jdate($obj->date_creat);
$this->date_creation = $this->db->jdate($obj->date_creat);
$this->date_valid = $this->db->jdate($obj->date_valid);
$this->date_validation = $this->db->jdate($obj->date_valid);
$this->date_envoi = $this->db->jdate($obj->date_envoi);
$this->extraparams = (array) json_decode($obj->extraparams, true);
if ($this->messtype == 'sms') {
$this->picto = 'phone';
}
return 1;
} else {
dol_syslog(get_class($this)."::fetch Erreur -1");
@@ -465,6 +440,7 @@ class Mailing extends CommonObject
// Load source object
$object->fetch($fromid);
$object->id = 0;
$object->status = 0;
$object->statut = 0;
// Clear fields
@@ -487,9 +463,7 @@ class Mailing extends CommonObject
$object->user_creation_id = $user->id;
$object->user_validation_id = '';
$object->date_creat = '';
$object->date_valid = '';
$object->date_envoi = '';
$object->date_envoi = null;
}
// Create clone
@@ -728,7 +702,8 @@ class Mailing extends CommonObject
*/
public function refreshNbOfTargets()
{
$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
$sql = "SELECT COUNT(rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles";
$sql .= " WHERE fk_mailing = ".((int) $this->id);
$resql = $this->db->query($sql);
@@ -765,14 +740,14 @@ class Mailing extends CommonObject
*/
public function getTooltipContentArray($params)
{
global $conf, $langs;
global $langs;
$nofetch = !empty($params['nofetch']);
//$nofetch = !empty($params['nofetch']);
$langs->load('mails');
$datas = array();
$datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("ShowEMailing").'</u>';
if (isset($this->statut)) {
if (isset($this->status)) {
$datas['picto'] .= ' '.$this->getLibStatut(5);
}
$datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
@@ -881,7 +856,7 @@ class Mailing extends CommonObject
*/
public function getLibStatut($mode = 0)
{
return $this->LibStatut($this->statut, $mode);
return $this->LibStatut($this->status, $mode);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

View File

@@ -66,7 +66,7 @@ if ($object->fetch($id) >= 0) {
$morehtmlright = '';
$nbtry = $nbok = 0;
if ($object->statut == 2 || $object->statut == 3) {
if ($object->status == 2 || $object->status == 3) {
$nbtry = $object->countNbOfTargets('alreadysent');
$nbko = $object->countNbOfTargets('alreadysentko');

View File

@@ -57,6 +57,7 @@ $pagenext = $page + 1;
// Search Fields
$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
$search_ref = GETPOST("search_ref", "alpha") ? GETPOST("search_ref", "alpha") : GETPOST("sref", "alpha");
$search_messtype = GETPOST("search_messtype", "alpha");
$filteremail = GETPOST('filteremail', 'alpha');
// Initialize technical objects
@@ -122,6 +123,7 @@ if (empty($reshook)) {
$search[$key]='';
}*/
$search_ref = '';
$search_messtype = '';
$search_all = '';
$toselect = array();
$search_array_options = array();
@@ -155,7 +157,7 @@ $morecss = array();
// Build and execute select
// --------------------------------------------------------------------
if ($filteremail) {
$sql = "SELECT m.rowid, m.titre as title, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi,";
$sql = "SELECT m.rowid, m.messtype, m.titre as title, m.nbemail, m.statut as status, m.date_creat as datec, m.date_envoi as date_envoi,";
$sql .= " mc.statut as sendstatut";
$sqlfields = $sql; // $sql fields to remove for count total
@@ -166,8 +168,11 @@ if ($filteremail) {
if ($search_ref) {
$sql .= " AND m.rowid = '".$db->escape($search_ref)."'";
}
if ($search_messtype) {
$sql .= " AND m.messtype LIKE '".$db->escape($search_messtype)."'";
}
if ($search_all) {
$sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')";
$sql .= " AND (m.titre LIKE '%".$db->escape($search_all)."%' OR m.sujet LIKE '%".$db->escape($search_all)."%' OR m.body LIKE '%".$db->escape($search_all)."%')";
}
if (!$sortorder) {
$sortorder = "ASC";
@@ -176,17 +181,20 @@ if ($filteremail) {
$sortfield = "m.rowid";
}
} else {
$sql = "SELECT m.rowid, m.titre as title, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi";
$sql = "SELECT m.rowid, m.messtype, m.titre as title, m.nbemail, m.statut as status, m.date_creat as datec, m.date_envoi as date_envoi";
$sqlfields = $sql; // $sql fields to remove for count total
$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
$sql .= " WHERE m.entity = ".$conf->entity;
$sql .= " WHERE m.entity = ".((int) $conf->entity);
if ($search_ref) {
$sql .= " AND m.rowid = '".$db->escape($search_ref)."'";
}
if ($search_messtype) {
$sql .= " AND m.messtype LIKE '".$db->escape($search_messtype)."'";
}
if ($search_all) {
$sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')";
$sql .= " AND (m.titre LIKE '%".$db->escape($search_all)."%' OR m.sujet LIKE '%".$db->escape($search_all)."%' OR m.body LIKE '%".$db->escape($search_all)."%')";
}
if (!$sortorder) {
$sortorder = "ASC";
@@ -276,6 +284,16 @@ if ($limit > 0 && $limit != $conf->liste_limit) {
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
if ($search_ref != '') {
$param .= '&search_ref='.urlencode($search_ref);
}
if ($search_messtype != '') {
$param .= '&search_type='.urlencode($search_messtype);
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
if ($filteremail) {
$param .= '&filteremail='.urlencode($filteremail);
}
@@ -378,6 +396,12 @@ if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="liste_titre">';
print '<input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
// Message type
if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
print '<td class="liste_titre">';
print '<input type="text" class="flat maxwidth50" name="search_messtype" value="'.dol_escape_htmltag($search_messtype).'">';
print '</td>';
}
// Title
print '<td class="liste_titre">';
print '<input type="text" class="flat maxwidth100 maxwidth50onsmartphone" name="search_all" value="'.dol_escape_htmltag($search_all).'">';
@@ -415,19 +439,28 @@ if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
}
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "m.rowid", $param, "", "", $sortfield, $sortorder);
$totalarray['nbfield']++;
// Message type
if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "m.messtype", $param, "", "", $sortfield, $sortorder);
$totalarray['nbfield']++;
}
print_liste_field_titre("Title", $_SERVER["PHP_SELF"], "m.titre", $param, "", "", $sortfield, $sortorder);
$totalarray['nbfield']++;
print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "m.date_creat", $param, "", 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "m.date_creat", $param, "", '', $sortfield, $sortorder, 'center ');
$totalarray['nbfield']++;
if (!$filteremail) {
print_liste_field_titre("NbOfEMails", $_SERVER["PHP_SELF"], "m.nbemail", $param, "", 'align="center"', $sortfield, $sortorder);
$title = $langs->trans("NbOfEMails");
if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
$title .= ' | '.$langs->trans("SMS");
}
print_liste_field_titre($title, $_SERVER["PHP_SELF"], "m.nbemail", $param, "", '', $sortfield, $sortorder, 'center ');
$totalarray['nbfield']++;
}
if (!$filteremail) {
print_liste_field_titre("DateLastSend", $_SERVER["PHP_SELF"], "m.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("DateLastSend", $_SERVER["PHP_SELF"], "m.date_envoi", $param, "", '', $sortfield, $sortorder, 'center ');
$totalarray['nbfield']++;
} else {
print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", $param, "", '', $sortfield, $sortorder, 'center ');
$totalarray['nbfield']++;
}
// Extra fields
@@ -484,10 +517,18 @@ while ($i < $imaxinloop) {
}
}
// Ref
print '<td>';
print $object->getNomUrl(1);
print '</td>';
// Message type
if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
print '<td>';
print dol_escape_htmltag($obj->messtype);
print '</td>';
}
// Title
print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->title).'">'.dol_escape_htmltag($obj->title).'</td>';
@@ -500,7 +541,7 @@ while ($i < $imaxinloop) {
if (!$filteremail) {
print '<td class="center nowraponall">';
$nbemail = $obj->nbemail;
/*if ($obj->statut != 3 && !empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail)
/*if ($obj->status != 3 && !empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail)
{
$text=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB);
print $form->textwithpicto($nbemail,$text,1,'warning');
@@ -514,7 +555,7 @@ while ($i < $imaxinloop) {
}
// Last send
print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->date_envoi), 'day').'</td>';
print '<td class="nowrap center">'.dol_print_date($db->jdate($obj->date_envoi), 'day').'</td>';
print '</td>';
// Status
@@ -522,7 +563,7 @@ while ($i < $imaxinloop) {
if ($filteremail) {
print $object::libStatutDest($obj->sendstatut, 2);
} else {
print $object->LibStatut($obj->statut, 5);
print $object->LibStatut($obj->status, 5);
}
print '</td>';

View File

@@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("mailing", "companies"));
$langs->loadLangs(array("mails", "mailing", "companies"));
// Get parameters
$id = GETPOST('id', 'int');

View File

@@ -124,8 +124,6 @@ class CSMSFile
*/
public function sendfile()
{
global $conf;
$errorlevel = error_reporting();
error_reporting($errorlevel ^ E_WARNING); // Disable warnings
@@ -155,8 +153,12 @@ class CSMSFile
dol_include_once('/'.$module.'/class/'.strtolower($classfile).'.class.php');
try {
$classname = ucfirst($classfile);
dol_syslog("CSMSFile::sendfile: try to include class ".$classname);
if (class_exists($classname)) {
$sms = new $classname($this->db);
$sms->expe = $this->addr_from;
$sms->dest = $this->addr_to;
$sms->deferred = $this->deferred;
@@ -177,6 +179,10 @@ class CSMSFile
$this->errors = $sms->errors;
if ($res <= 0) {
dol_syslog("CSMSFile::sendfile: sms send error=".$this->error, LOG_ERR);
if (getDolGlobalString('MAIN_SMS_DEBUG')) {
$this->dump_sms_result($res);
}
$res = false;
} else {
dol_syslog("CSMSFile::sendfile: sms send success with id=".$res, LOG_DEBUG);
//var_dump($res); // 1973128
@@ -194,8 +200,8 @@ class CSMSFile
} else {
// Send sms method not correctly defined
// --------------------------------------
return 'Bad value for MAIN_SMS_SENDMODE constant';
$sms->error = 'Bad value for MAIN_SMS_SENDMODE constant';
$res = false;
}
} else {
$this->error = 'No sms sent. Feature is disabled by option MAIN_DISABLE_ALL_SMS';
@@ -249,13 +255,13 @@ class CSMSFile
public function dump_sms_result($result)
{
// phpcs:enable
global $conf, $dolibarr_main_data_root;
global $dolibarr_main_data_root;
if (@is_writeable($dolibarr_main_data_root)) { // Avoid fatal error on fopen with open_basedir
$outputfile = $dolibarr_main_data_root."/dolibarr_sms.log";
$fp = fopen($outputfile, "a+");
fputs($fp, "\nResult id=".$result);
fputs($fp, "\nResult of SmsSend = ".$result);
fclose($fp);
dolChmod($outputfile);

View File

@@ -302,7 +302,7 @@ MAIN_DISABLE_ALL_MAILS=Disable all email sending (for test purposes or demos)
MAIN_MAIL_FORCE_SENDTO=Send all emails to (instead of real recipients, for test purposes)
MAIN_MAIL_ENABLED_USER_DEST_SELECT=Suggest emails of employees (if defined) into the list of predefined recipient when writing a new email
MAIN_MAIL_NO_WITH_TO_SELECTED=Do not select a default recipient even if there is only 1 possible choice
MAIN_MAIL_SENDMODE=Email sending method
MAIN_MAIL_SENDMODE=Sending method
MAIN_MAIL_SMTPS_ID=SMTP ID (if sending server requires authentication)
MAIN_MAIL_SMTPS_PW=SMTP Password (if sending server requires authentication)
MAIN_MAIL_EMAIL_TLS=Use TLS (SSL) encryption

View File

@@ -9,6 +9,7 @@ MailRecipients=Recipients
MailRecipient=Recipient
MailTitle=Description
MailFrom=From
PhoneFrom=From
MailErrorsTo=Errors to
MailReply=Reply to
MailTo=To
@@ -32,7 +33,7 @@ DeleteMailing=Delete emailing
DeleteAMailing=Delete an emailing
PreviewMailing=Preview emailing
CreateMailing=Create emailing
TestMailing=Test email
TestMailing=Test
ValidMailing=Valid emailing
MailingStatusDraft=Draft
MailingStatusValidated=Validated
@@ -52,6 +53,7 @@ ConfirmValidMailing=Are you sure you want to validate this emailing?
ConfirmResetMailing=Warning, by re-initializing emailing <b>%s</b>, you will allow the re-sending this email in a bulk mailing. Are you sure you want to do this?
ConfirmDeleteMailing=Are you sure you want to delete this emailing?
NbOfUniqueEMails=No. of unique emails
NbOfUniquePhones=No. of unique phones
NbOfEMails=No. of EMails
TotalNbOfDistinctRecipients=Number of distinct recipients
NoTargetYet=No recipients defined yet (Go on tab 'Recipients')