From 5a75f346ff578c47060732b6aa3b8062af2163c3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 May 2016 00:02:22 +0200 Subject: [PATCH] Debug advanced selector --- htdocs/comm/mailing/advtargetemailing.php | 208 +++--------------- .../html.formadvtargetemailing.class.php | 6 +- htdocs/core/lib/emailing.lib.php | 28 +-- .../plugins}/multiselect/MIT-LICENSE.txt | 0 .../multiselect/css/ui.multiselect.css | 0 .../plugins}/multiselect/js/ui.multiselect.js | 0 6 files changed, 52 insertions(+), 190 deletions(-) rename htdocs/includes/{ => jquery/plugins}/multiselect/MIT-LICENSE.txt (100%) rename htdocs/includes/{ => jquery/plugins}/multiselect/css/ui.multiselect.css (100%) rename htdocs/includes/{ => jquery/plugins}/multiselect/js/ui.multiselect.js (100%) diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index 4076217cf88..be8a63225fe 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -1,20 +1,27 @@ -* -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ +/* Copyright (C) 2014 Florian Henry + * Copyright (C) 2016 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/comm/mailing/advtargetemailing.php + * \ingroup mailing + * \brief Page to define emailing targets + */ + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/comm/mailing/class/mailing.class.php'; @@ -84,8 +91,9 @@ if ($result < 0) { } } + /* - * Action + * Actions */ if ($action == 'loadfilter') { @@ -387,15 +395,16 @@ if ($_POST["button_removefilter"]) { $search_email = ''; } + /* * View */ + $extrajs = array ( - '/includes/multiselect/js/ui.multiselect.js' + '/includes/jquery/plugins/multiselect/js/ui.multiselect.js' ); $extracss = array ( - '/includes/multiselect/css/ui.multiselect.css', - '/advtargetemailing/css/advtargetemailing.css' + '/includes/jquery/plugins/multiselect/css/ui.multiselect.css', ); llxHeader('', $langs->trans("MailAdvTargetRecipients"), '', '', '', '', $extrajs, $extracss); @@ -958,162 +967,11 @@ if ($object->fetch($id) >= 0) { print ''; print '
'; } - if (empty($conf->mailchimp->enabled) || (! empty($conf->mailchimp->enabled) && $object->statut != 3)) { - // List of selected targets - print "\n\n"; - print '
'; - print ''; - print ''; - print ''; - print ''; + - $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut, mc.date_envoi, mc.source_url, mc.source_id, mc.source_type"; - $sql .= " FROM " . MAIN_DB_PREFIX . "mailing_cibles as mc"; - $sql .= " WHERE mc.fk_mailing=" . $object->id; - if ($search_nom) - $sql .= " AND mc.lastname LIKE '%" . $db->escape($search_nom) . "%'"; - if ($search_prenom) - $sql .= " AND mc.firstname LIKE '%" . $db->escape($search_prenom) . "%'"; - if ($search_email) - $sql .= " AND mc.email LIKE '%" . $db->escape($search_email) . "%'"; - $sql .= $db->order($sortfield, $sortorder); - $sql .= $db->plimit($conf->liste_limit + 1, $offset); - - dol_syslog('advtargetemailing.php:: sql=' . $sql); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - - $parm = "&id=" . $object->id; - if ($search_nom) - $parm .= "&search_nom=" . urlencode($search_nom); - if ($search_prenom) - $parm .= "&search_prenom=" . urlencode($search_prenom); - if ($search_email) - $parm .= "&search_email=" . urlencode($search_email); - - print_barre_liste($langs->trans("MailSelectedRecipients"), $page, $_SERVER["PHP_SELF"], $parm, $sortfield, $sortorder, "", $num, $object->nbemail, ''); - - if ($page) - $parm .= "&page=" . $page; - print ''; - print ''; - print_liste_field_titre($langs->trans("EMail"), $_SERVER["PHP_SELF"], "mc.email", $parm, "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Lastname"), $_SERVER["PHP_SELF"], "mc.lastname", $parm, "", "", $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Firstname"), $_SERVER["PHP_SELF"], "mc.firstname", $parm, "", "", $sortfield, $sortorder); - 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 sendinf - if ($object->statut < 2) { - print ''; - } else { - print_liste_field_titre($langs->trans("DateSending"), $_SERVER["PHP_SELF"], "mc.date_envoi", $parm, '', 'align="center"', $sortfield, $sortorder); - } - - // Statut - print_liste_field_titre($langs->trans("Status"), $_SERVER["PHP_SELF"], "mc.statut", $parm, '', 'align="right"', $sortfield, $sortorder); - - print ''; - - // Ligne des champs de filtres - print ''; - // EMail - print ''; - // Name - print ''; - // Firstname - print ''; - // Other - print ''; - // SendDate - print ''; - // Source - print ''; - print ''; - - $var = true; - $i = 0; - - if ($num) { - while ( $i < min($num, $conf->liste_limit) ) { - $obj = $db->fetch_object($resql); - $var = ! $var; - - print ""; - print ''; - print ''; - print ''; - print ''; - print ''; - - // Statut pour l'email destinataire (Attentioon != statut du mailing) - if ($obj->statut == 0) { - print ''; - print ''; - } else { - print ''; - print ''; - } - print ''; - - $i ++; - } - } else { - print ''; - } - print "
 
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ' '; - print ''; - print ' '; - print ''; - print ''; - print '  '; - print ''; - print '
' . $obj->email . '' . $obj->lastname . '' . $obj->firstname . '' . $obj->other . ''; - if (empty($obj->source_id) || empty($obj->source_type)) { - print $obj->source_url; // For backward compatibility - } else { - - if ($obj->source_type == 'thirdparty') { - include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; - $m = new Societe($db); - $m->fetch($obj->source_id); - print $m->getNomUrl(1); - } elseif ($obj->source_type == 'contact') { - include_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; - $m = new Contact($db); - $m->fetch($obj->source_id); - print $m->getNomUrl(1); - } - } - print ' ' . $langs->trans("MailingStatusNotSent"); - if ($user->rights->mailing->creer) { - print '' . img_delete($langs->trans("RemoveRecipient")); - } - print '' . $obj->date_envoi . ''; - if ($obj->statut == - 1) - print $langs->trans("MailingStatusError") . ' ' . img_error(); - if ($obj->statut == 1) - print $langs->trans("MailingStatusSent") . ' ' . img_picto($langs->trans("MailingStatusSent"), 'statut4'); - if ($obj->statut == 2) - print $langs->trans("MailingStatusRead") . ' ' . img_picto($langs->trans("MailingStatusRead"), 'statut6'); - if ($obj->statut == 3) - print $langs->trans("MailingStatusNotContact") . ' ' . img_picto($langs->trans("MailingStatusNotContact"), 'statut8'); - print '
' . $langs->trans("NoTargetYet") . '

"; - - $db->free($resql); - } else { - setEventMessage($db->lasterror(), 'errors'); - } - - print '
'; + if (empty($conf->mailchimp->enabled) || (! empty($conf->mailchimp->enabled) && $object->statut != 3)) + { + // List of recipients (TODO Move code of page cibles.php into a .tpl.php file and make an include here to avoid duplicate content) } } diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 9c340e1e33b..ac6b5727c58 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -333,7 +333,8 @@ class FormAdvTargetEmailing extends Form function advMultiselectarray($htmlname, $options_array = array(), $selected_array = array(), $showempty = 0) { global $conf, $langs; - $return = ''; - $return .= ''; + if ($showempty) $return .= ''; diff --git a/htdocs/core/lib/emailing.lib.php b/htdocs/core/lib/emailing.lib.php index 257f2829704..443b9b6156a 100644 --- a/htdocs/core/lib/emailing.lib.php +++ b/htdocs/core/lib/emailing.lib.php @@ -39,20 +39,22 @@ function emailing_prepare_head(Mailing $object) $head[$h][2] = 'card'; $h++; - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! $user->rights->mailing->mailing_advance->recipient) { - return $head; + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->mailing->mailing_advance->recipient)) + { + $head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$object->id; + $head[$h][1] = $langs->trans("MailRecipients"); + $head[$h][2] = 'targets'; + $h++; + + if (! empty($conf->global->EMAILING_USE_ADVANCED_SELECTOR)) // Still need debug + { + $head[$h][0] = DOL_URL_ROOT."/comm/mailing/advtargetemailing.php?id=".$object->id; + $head[$h][1] = $langs->trans("MailAdvTargetRecipients"); + $head[$h][2] = 'advtargets'; + $h++; + } } - - $head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$object->id; - $head[$h][1] = $langs->trans("MailRecipients"); - $head[$h][2] = 'targets'; - $h++; - - $head[$h][0] = DOL_URL_ROOT."/comm/mailing/advtargetemailing.php?id=".$object->id; - $head[$h][1] = $langs->trans("MailAdvTargetRecipients"); - $head[$h][2] = 'advtargets'; - $h++; - + $head[$h][0] = DOL_URL_ROOT."/comm/mailing/info.php?id=".$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; diff --git a/htdocs/includes/multiselect/MIT-LICENSE.txt b/htdocs/includes/jquery/plugins/multiselect/MIT-LICENSE.txt similarity index 100% rename from htdocs/includes/multiselect/MIT-LICENSE.txt rename to htdocs/includes/jquery/plugins/multiselect/MIT-LICENSE.txt diff --git a/htdocs/includes/multiselect/css/ui.multiselect.css b/htdocs/includes/jquery/plugins/multiselect/css/ui.multiselect.css similarity index 100% rename from htdocs/includes/multiselect/css/ui.multiselect.css rename to htdocs/includes/jquery/plugins/multiselect/css/ui.multiselect.css diff --git a/htdocs/includes/multiselect/js/ui.multiselect.js b/htdocs/includes/jquery/plugins/multiselect/js/ui.multiselect.js similarity index 100% rename from htdocs/includes/multiselect/js/ui.multiselect.js rename to htdocs/includes/jquery/plugins/multiselect/js/ui.multiselect.js