From 6539f617851b5cffad6aeb71d11989d9f0d7e16a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Dec 2010 18:40:04 +0000 Subject: [PATCH] Fix: Maxi debug of emailing feature --- htdocs/comm/mailing/cibles.php | 6 +-- htdocs/comm/mailing/fiche.php | 53 +++++++++---------- htdocs/core/class/html.form.class.php | 23 +++++--- .../dolibarr_services_expired.modules.php | 2 +- .../modules/mailings/fraise.modules.php | 10 ++-- .../modules/mailings/framboise.modules.php | 5 +- .../install/mysql/migration/2.9.0-3.0.0.sql | 1 + htdocs/langs/en_US/mails.lang | 4 +- htdocs/langs/fr_FR/mails.lang | 2 +- 9 files changed, 59 insertions(+), 47 deletions(-) diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index d591dda1f15..ebd011d9865 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -213,7 +213,7 @@ if ($mil->fetch($_REQUEST["id"]) >= 0) $var=!$var; - // Affiche les listes de selection + // Show email selectors if ($mil->statut == 0) { print_fiche_titre($langs->trans("ToAddRecipientsChooseHere"),($user->admin?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"),1):''),''); @@ -384,14 +384,14 @@ if ($mil->fetch($_REQUEST["id"]) >= 0) print_liste_field_titre($langs->trans("OtherInformations"),$_SERVER["PHP_SELF"],"",$parm,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Source"),$_SERVER["PHP_SELF"],"",$parm,"",'align="center"',$sortfield,$sortorder); - // Date + // Date sendinf if ($mil->statut < 2) { print ' '; } else { - print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"mc.date_envoi",$parm,'','align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DateSending"),$_SERVER["PHP_SELF"],"mc.date_envoi",$parm,'','align="center"',$sortfield,$sortorder); } // Statut diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index 3ef4e369575..ae5e85eca46 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -166,13 +166,13 @@ if ($_REQUEST["action"] == 'sendallconfirmed' && $_REQUEST['confirm'] == 'yes') // sendto en RFC2822 $sendto = str_replace(',',' ',$obj->prenom." ".$obj->nom)." <".$obj->email.">"; - // Make subtsitutions on topic and body + // Make substitutions on topic and body. From (AA=YY;BB=CC;...) we keep YY, CC, ... $other=explode(';',$obj->other); - $other1=$other[0]; - $other2=$other[1]; - $other3=$other[2]; - $other4=$other[3]; - $other5=$other[4]; + $tmpfield=explode('=',$other[0],2); $other1=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[1],2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $substitutionarray=array( '__ID__' => $obj->source_id, '__EMAIL__' => $obj->email, @@ -490,7 +490,7 @@ if ($_POST["action"] == 'update' && empty($_POST["removedfile"]) && empty($_POST } // Action confirmation validation -if ($_REQUEST["action"] == 'confirm_valide') +if ($_REQUEST["action"] == 'confirm_valid') { if ($_REQUEST["confirm"] == 'yes') @@ -646,9 +646,9 @@ else dol_fiche_head($head, 'card', $langs->trans("Mailing"), 0, 'email'); // Confirmation de la validation du mailing - if ($_GET["action"] == 'valide') + if ($_GET["action"] == 'valid') { - $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$mil->id,$langs->trans("ValidMailing"),$langs->trans("ConfirmValidMailing"),"confirm_valide",'','',2); + $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$mil->id,$langs->trans("ValidMailing"),$langs->trans("ConfirmValidMailing"),"confirm_valid",'','',1); if ($ret == 'html') print '
'; } @@ -662,7 +662,7 @@ else // Confirm delete if ($_GET["action"] == 'delete') { - $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$mil->id,$langs->trans("DeleteAMailing"),$langs->trans("ConfirmDeleteMailing"),"confirm_delete",'','',2); + $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$mil->id,$langs->trans("DeleteAMailing"),$langs->trans("ConfirmDeleteMailing"),"confirm_delete",'','',1); if ($ret == 'html') print '
'; } @@ -674,20 +674,28 @@ else */ if ($_GET["action"] == 'sendall') { + // Define message to recommand from command line + + // Pour des raisons de securite, on ne permet pas cette fonction via l'IHM, + // on affiche donc juste un message + if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) { // Pour des raisons de securite, on ne permet pas cette fonction via l'IHM, // on affiche donc juste un message - $message='
'.$langs->trans("MailingNeedCommand").'
'; - $message.='
'; - $message.='

'.$langs->trans("MailingNeedCommand2").'
'; + $mesg.='
'.$langs->trans("MailingNeedCommand").'
'; + $mesg.='
'; + $mesg.='

'.$langs->trans("MailingNeedCommand2").'
'; $_GET["action"]=''; } else { - $text=$langs->trans('ConfirmSendingEmailing').'
'; + $text=$langs->trans("MailingNeedCommand"); + $text.='
'; + $text.='

'; + $text.=$langs->trans('ConfirmSendingEmailing').'
'; $text.=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB); - $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?id='.$_REQUEST['id'],$langs->trans('SendMailing'),$text,'sendallconfirmed','','',2); + $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?id='.$_REQUEST['id'],$langs->trans('SendMailing'),$text,'sendallconfirmed',$formquestion,'',1,260); if ($ret == 'html') print '
'; } } @@ -756,21 +764,12 @@ else if ($mesg) print $mesg; - if ($_GET["action"] == 'sendall') - { - // Pour des raisons de securite, on ne permet pas cette fonction via l'IHM, - // on affiche donc juste un message - $message='
'.$langs->trans("MailingNeedCommand").'
'; - $message.='
'; - } - - if ($message) print $message; - /* * Boutons d'action */ - if ($_GET["action"] == '') + if (GETPOST("cancel") || GETPOST("confirm")=='no' || GETPOST("action") == '' + || in_array(GETPOST('action'),array('valid','delete','sendall'))) { print "\n\n
\n"; @@ -795,7 +794,7 @@ else } else { - print ''.$langs->trans("ValidMailing").''; + print ''.$langs->trans("ValidMailing").''; } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0181a09dcbc..dc8034ede73 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1791,11 +1791,12 @@ class Form * @param formquestion an array with forms complementary inputs * @param selectedchoice "" or "no" or "yes" * @param useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No + * @param height Force height of box * @return string 'ajax' if a confirm ajax popup is shown, 'html' if it's an html form */ - function form_confirm($page, $title, $question, $action, $formquestion='', $selectedchoice="", $useajax=0) + function form_confirm($page, $title, $question, $action, $formquestion='', $selectedchoice="", $useajax=0, $height=0) { - print $this->formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax); + print $this->formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax, $height); } /** @@ -1807,18 +1808,20 @@ class Form * @param formquestion an array with forms complementary inputs * @param selectedchoice "" or "no" or "yes" * @param useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No + * @param height Force height of box * @return string 'ajax' if a confirm ajax popup is shown, 'html' if it's an html form */ - function formconfirm($page, $title, $question, $action, $formquestion='', $selectedchoice="", $useajax=0) + function formconfirm($page, $title, $question, $action, $formquestion='', $selectedchoice="", $useajax=0, $height=0) { global $langs,$conf; $more=''; $formconfirm=''; + if (empty($height)) $height=170; + if ($formquestion) { - $more.=''."\n"; $more.=''."\n"; $more.=''."\n"; foreach ($formquestion as $key => $input) @@ -1867,7 +1870,6 @@ class Form } } $more.='
'.$formquestion['text'].'
'."\n"; - $more.=''."\n"; } $formconfirm.= "\n\n"; @@ -1886,8 +1888,8 @@ class Form jQuery("#dialog-confirm").dialog({ autoOpen: true, resizable: false, - height:170, - width:590, + height:'.$height.', + width:600, modal: true, closeOnEscape: false, close: function(event, ui) { @@ -1921,7 +1923,12 @@ class Form $formconfirm.= ''.img_picto('','recent').' '.$title.''."\n"; // Ligne formulaire - $formconfirm.= $more; + if ($more) + { + $formconfirm.=''."\n"; + $formconfirm.=$more; + $formconfirm.=''."\n"; + } // Ligne message $formconfirm.= ''; diff --git a/htdocs/includes/modules/mailings/dolibarr_services_expired.modules.php b/htdocs/includes/modules/mailings/dolibarr_services_expired.modules.php index 86e75b12550..bb1b6d5b802 100644 --- a/htdocs/includes/modules/mailings/dolibarr_services_expired.modules.php +++ b/htdocs/includes/modules/mailings/dolibarr_services_expired.modules.php @@ -112,7 +112,7 @@ class mailing_dolibarr_services_expired extends MailingTargets $num = $this->db->num_rows($result); $i = 0; - dolibarr_syslog("dolibarr_services_expired.modules.php:add_to_target ".$num." targets found"); + dolibarr_syslog(get_class($this)."::add_to_target ".$num." targets found"); $old = ''; while ($i < $num) diff --git a/htdocs/includes/modules/mailings/fraise.modules.php b/htdocs/includes/modules/mailings/fraise.modules.php index fb638de29a3..1e030a78072 100644 --- a/htdocs/includes/modules/mailings/fraise.modules.php +++ b/htdocs/includes/modules/mailings/fraise.modules.php @@ -139,6 +139,7 @@ class mailing_fraise extends MailingTargets { global $langs,$_POST; $langs->load("members"); + $langs->load("companies"); $cibles = array(); $now=dol_now(); @@ -149,7 +150,7 @@ class mailing_fraise extends MailingTargets // La requete doit retourner: id, email, fk_contact, name, firstname $sql = "SELECT a.rowid as id, a.email as email, null as fk_contact, "; $sql.= " a.nom as name, a.prenom as firstname,"; - $sql.= " a.datefin"; // Other fields + $sql.= " a.datefin, a.civilite, a.login, a.societe"; // Other fields $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a"; $sql.= " WHERE a.email IS NOT NULL"; if (isset($_POST["filter"]) && $_POST["filter"] == '-1') $sql.= " AND a.statut=-1"; @@ -162,7 +163,7 @@ class mailing_fraise extends MailingTargets //print $sql; // Add targets into table - dol_syslog("fraise.modules.php sql=".$sql); + dol_syslog(get_class($this)."::add_to_target sql=".$sql); $result=$this->db->query($sql); if ($result) { @@ -183,7 +184,10 @@ class mailing_fraise extends MailingTargets 'fk_contact' => $obj->fk_contact, 'name' => $obj->name, 'firstname' => $obj->firstname, - 'other' => $obj->datefin?($langs->transnoentities("DateEnd").'='.dol_print_date($this->db->jdate($obj->datefin),'day')):'', + 'other' => ($langs->transnoentities("DateEnd").'='.dol_print_date($this->db->jdate($obj->datefin),'day')).';'. + ($langs->transnoentities("Civility").'='.$obj->civilite).';'. + ($langs->transnoentities("Login").'='.$obj->login).';'. + ($langs->transnoentities("Company").'='.$obj->societe), 'source_url' => $this->url($obj->id), 'source_id' => $obj->id, 'source_type' => 'member' diff --git a/htdocs/includes/modules/mailings/framboise.modules.php b/htdocs/includes/modules/mailings/framboise.modules.php index 555247dbacb..84c62b14cee 100644 --- a/htdocs/includes/modules/mailings/framboise.modules.php +++ b/htdocs/includes/modules/mailings/framboise.modules.php @@ -161,6 +161,7 @@ class mailing_framboise extends MailingTargets global $conf, $langs; $langs->load("companies"); + $langs->load("categories"); $s=''; $s.='