Modulebuildarisation of the emailing list
This commit is contained in:
parent
788ec8b7c2
commit
a8cd8853f4
@ -49,8 +49,9 @@ $confirm = GETPOST('confirm', 'alpha');
|
|||||||
$urlfrom = GETPOST('urlfrom');
|
$urlfrom = GETPOST('urlfrom');
|
||||||
|
|
||||||
$object = new Mailing($db);
|
$object = new Mailing($db);
|
||||||
|
if ($id > 0) {
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
|
}
|
||||||
|
|
||||||
$extrafields = new ExtraFields($db);
|
$extrafields = new ExtraFields($db);
|
||||||
|
|
||||||
@ -673,7 +674,7 @@ if (empty($reshook)) {
|
|||||||
|
|
||||||
// Action of delete confirmation
|
// Action of delete confirmation
|
||||||
if ($action == 'confirm_delete' && $confirm == 'yes') {
|
if ($action == 'confirm_delete' && $confirm == 'yes') {
|
||||||
if ($object->delete($object->id)) {
|
if ($object->delete($user)) {
|
||||||
$url = (!empty($urlfrom) ? $urlfrom : 'list.php');
|
$url = (!empty($urlfrom) ? $urlfrom : 'list.php');
|
||||||
header("Location: ".$url);
|
header("Location: ".$url);
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
@ -556,15 +556,14 @@ class Mailing extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Delete emailing
|
* Delete emailing
|
||||||
*
|
*
|
||||||
* @param int $rowid Id if emailing to delete
|
* @param User $user User that delete
|
||||||
* @param int $notrigger Disable triggers
|
* @param int $notrigger Disable triggers
|
||||||
* @return int >0 if OK, <0 if KO
|
* @return int >0 if OK, <0 if KO
|
||||||
*/
|
*/
|
||||||
public function delete($rowid, $notrigger = 0)
|
public function delete($user, $notrigger = 0)
|
||||||
{
|
{
|
||||||
global $user;
|
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
if (!$notrigger) {
|
if (!$notrigger) {
|
||||||
@ -576,7 +575,7 @@ class Mailing extends CommonObject
|
|||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "mailing";
|
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "mailing";
|
||||||
$sql .= " WHERE rowid = " . ((int) $rowid);
|
$sql .= " WHERE rowid = " . ((int) $this->id);
|
||||||
|
|
||||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2005-2023 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
|
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -30,21 +30,46 @@ require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
|
|||||||
$langs->load('mails');
|
$langs->load('mails');
|
||||||
|
|
||||||
// Get Parameters
|
// Get Parameters
|
||||||
$massaction = GETPOST('massaction', 'alpha');
|
$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ...
|
||||||
$optioncss = GETPOST('optioncss', 'alpha');
|
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
|
||||||
|
$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
|
||||||
|
$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
|
||||||
|
$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
|
||||||
|
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
|
||||||
|
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
|
||||||
|
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
|
||||||
|
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
|
||||||
|
$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
|
||||||
|
|
||||||
// Pagination
|
// Load variable for pagination
|
||||||
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||||
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
|
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
|
||||||
|
// If $page is not defined, or '' or -1 or if we click on clear filters
|
||||||
$page = 0;
|
$page = 0;
|
||||||
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
}
|
||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$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");
|
||||||
|
$filteremail = GETPOST('filteremail', 'alpha');
|
||||||
|
|
||||||
|
// Initialize technical objects
|
||||||
|
$object = new Mailing($db);
|
||||||
|
$extrafields = new ExtraFields($db);
|
||||||
|
$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array of activated contexes
|
||||||
|
|
||||||
|
// Fetch optionals attributes and labels
|
||||||
|
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||||
|
|
||||||
|
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
|
||||||
|
|
||||||
|
// Default sort order (if not yet defined by previous GETPOST)
|
||||||
if (!$sortorder) {
|
if (!$sortorder) {
|
||||||
$sortorder = "DESC";
|
$sortorder = "DESC";
|
||||||
}
|
}
|
||||||
@ -52,28 +77,15 @@ if (!$sortfield) {
|
|||||||
$sortfield = "m.date_creat";
|
$sortfield = "m.date_creat";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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");
|
|
||||||
$filteremail = GETPOST('filteremail', 'alpha');
|
|
||||||
|
|
||||||
// Initialize objects
|
|
||||||
$object = new Mailing($db);
|
|
||||||
|
|
||||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
|
||||||
$hookmanager->initHooks(array('mailinglist'));
|
|
||||||
$extrafields = new ExtraFields($db);
|
|
||||||
|
|
||||||
// fetch optionals attributes and labels
|
|
||||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
|
||||||
|
|
||||||
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
|
|
||||||
|
|
||||||
// List of fields to search into when doing a "search in all"
|
// List of fields to search into when doing a "search in all"
|
||||||
$fieldstosearchall = array(
|
$fieldstosearchall = array(
|
||||||
'm.titre'=>'Ref',
|
'm.titre'=>'Ref',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$permissiontoread = $user->hasRight('mailing', 'lire');
|
||||||
|
$permissiontoadd = $user->hasRight('mailing', 'creer');
|
||||||
|
$permissiontodelete = $user->hasRight('mailing', 'delete');
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if (!$user->rights->mailing->lire || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) {
|
if (!$user->rights->mailing->lire || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) {
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
@ -81,13 +93,13 @@ if (!$user->rights->mailing->lire || (empty($conf->global->EXTERNAL_USERS_ARE_AU
|
|||||||
//$result = restrictedArea($user, 'mailing');
|
//$result = restrictedArea($user, 'mailing');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (GETPOST('cancel', 'alpha')) {
|
if (GETPOST('cancel', 'alpha')) {
|
||||||
$action = 'list'; $massaction = '';
|
$action = 'list';
|
||||||
|
$massaction = '';
|
||||||
}
|
}
|
||||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
||||||
$massaction = '';
|
$massaction = '';
|
||||||
@ -120,13 +132,10 @@ if (empty($reshook)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mass actions
|
// Mass actions
|
||||||
/*$objectclass='MyObject';
|
$objectclass = 'Mailing';
|
||||||
$objectlabel='MyObject';
|
$objectlabel = 'Mailing';
|
||||||
$permissiontoread = $user->rights->mymodule->read;
|
$uploaddir = $conf->mailing->dir_output;
|
||||||
$permissiontodelete = $user->rights->mymodule->delete;
|
|
||||||
$uploaddir = $conf->mymodule->dir_output;
|
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -134,15 +143,23 @@ if (empty($reshook)) {
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Page Header
|
|
||||||
$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
|
|
||||||
llxHeader('', $langs->trans("Mailing"), $help_url);
|
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
|
$now = dol_now();
|
||||||
|
|
||||||
|
$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
|
||||||
|
$title = $langs->trans("Mailing");
|
||||||
|
$morejs = array();
|
||||||
|
$morecss = array();
|
||||||
|
|
||||||
|
// Build and execute select
|
||||||
|
// --------------------------------------------------------------------
|
||||||
if ($filteremail) {
|
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.titre as title, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi,";
|
||||||
$sql .= " mc.statut as sendstatut";
|
$sql .= " mc.statut as sendstatut";
|
||||||
|
|
||||||
|
$sqlfields = $sql; // $sql fields to remove for count total
|
||||||
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc";
|
$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc";
|
||||||
$sql .= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity;
|
$sql .= " WHERE m.rowid = mc.fk_mailing AND m.entity = ".$conf->entity;
|
||||||
$sql .= " AND mc.email = '".$db->escape($filteremail)."'";
|
$sql .= " AND mc.email = '".$db->escape($filteremail)."'";
|
||||||
@ -160,6 +177,9 @@ if ($filteremail) {
|
|||||||
}
|
}
|
||||||
} else {
|
} 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.titre as title, m.nbemail, m.statut, 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 .= " FROM ".MAIN_DB_PREFIX."mailing as m";
|
||||||
$sql .= " WHERE m.entity = ".$conf->entity;
|
$sql .= " WHERE m.entity = ".$conf->entity;
|
||||||
if ($search_ref) {
|
if ($search_ref) {
|
||||||
@ -175,176 +195,381 @@ if ($filteremail) {
|
|||||||
$sortfield = "m.rowid";
|
$sortfield = "m.rowid";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($search_all) {
|
||||||
|
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
|
||||||
|
}
|
||||||
|
//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
|
||||||
|
// Add where from extra fields
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
||||||
|
// Add where from hooks
|
||||||
|
$parameters = array();
|
||||||
|
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
|
$sql .= $hookmanager->resPrint;
|
||||||
|
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
// Count total nb of records
|
||||||
|
|
||||||
$nbtotalofrecords = '';
|
$nbtotalofrecords = '';
|
||||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||||
$resql = $db->query($sql);
|
/* The fast and low memory method to get and count full list converts the sql into a sql count */
|
||||||
$nbtotalofrecords = $db->num_rows($resql);
|
$sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
|
||||||
|
$sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
|
||||||
|
$resql = $db->query($sqlforcount);
|
||||||
|
if ($resql) {
|
||||||
|
$objforcount = $db->fetch_object($resql);
|
||||||
|
$nbtotalofrecords = $objforcount->nbtotalofrecords;
|
||||||
|
} else {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
|
||||||
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||||
$page = 0;
|
$page = 0;
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
}
|
}
|
||||||
|
$db->free($resql);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql .= $db->plimit($limit + 1, $offset);
|
// Complete request and execute it with limit
|
||||||
//print $sql;
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
|
if ($limit) {
|
||||||
|
$sql .= $db->plimit($limit + 1, $offset);
|
||||||
|
}
|
||||||
|
|
||||||
dol_syslog("comm/mailing/list.php", LOG_DEBUG);
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql) {
|
if (!$resql) {
|
||||||
$num = $db->num_rows($resql);
|
dol_print_error($db);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
$title = $langs->trans("EMailings");
|
$num = $db->num_rows($resql);
|
||||||
if ($filteremail) {
|
|
||||||
$title .= ' ('.$langs->trans("SentTo", $filteremail).')';
|
|
||||||
|
// Direct jump if only one record found
|
||||||
|
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
$id = $obj->rowid;
|
||||||
|
header("Location: ".dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$id);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Output page
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
$title = $langs->trans("EMailings");
|
||||||
|
if ($filteremail) {
|
||||||
|
$title .= ' ('.$langs->trans("SentTo", $filteremail).')';
|
||||||
|
}
|
||||||
|
|
||||||
|
llxHeader('', $title, $help_url);
|
||||||
|
|
||||||
|
$arrayofselected = is_array($toselect) ? $toselect : array();
|
||||||
|
|
||||||
|
$param = "&search_all=".urlencode($search_all);
|
||||||
|
if (!empty($mode)) {
|
||||||
|
$param .= '&mode='.urlencode($mode);
|
||||||
|
}
|
||||||
|
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||||
|
$param .= '&contextpage='.urlencode($contextpage);
|
||||||
|
}
|
||||||
|
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||||
|
$param .= '&limit='.urlencode($limit);
|
||||||
|
}
|
||||||
|
if ($optioncss != '') {
|
||||||
|
$param .= '&optioncss='.urlencode($optioncss);
|
||||||
|
}
|
||||||
|
if ($filteremail) {
|
||||||
|
$param .= '&filteremail='.urlencode($filteremail);
|
||||||
|
}
|
||||||
|
// Add $param from extra fields
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||||
|
// Add $param from hooks
|
||||||
|
$parameters = array();
|
||||||
|
$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
|
||||||
|
$param .= $hookmanager->resPrint;
|
||||||
|
|
||||||
|
// List of mass actions available
|
||||||
|
$arrayofmassactions = array(
|
||||||
|
//'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
|
||||||
|
//'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
|
||||||
|
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
|
||||||
|
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
|
||||||
|
);
|
||||||
|
if (!empty($permissiontodelete)) {
|
||||||
|
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
|
||||||
|
}
|
||||||
|
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
|
||||||
|
$arrayofmassactions = array();
|
||||||
|
}
|
||||||
|
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
||||||
|
|
||||||
|
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||||
|
if ($optioncss != '') {
|
||||||
|
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||||
|
}
|
||||||
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||||
|
print '<input type="hidden" name="action" value="list">';
|
||||||
|
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||||
|
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||||
|
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||||
|
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||||
|
print '<input type="hidden" name="page_y" value="">';
|
||||||
|
print '<input type="hidden" name="mode" value="'.$mode.'">';
|
||||||
|
|
||||||
|
$newcardbutton = '';
|
||||||
|
if ($user->rights->mailing->creer) {
|
||||||
|
$newcardbutton .= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create');
|
||||||
|
}
|
||||||
|
|
||||||
|
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_email', 0, $newcardbutton, '', $limit, 0, 0, 1);
|
||||||
|
|
||||||
|
// Add code for pre mass action (confirmation or email presend form)
|
||||||
|
$topicmail = "SendMailingRef";
|
||||||
|
$modelmail = "mailing";
|
||||||
|
$objecttmp = new Mailing($db);
|
||||||
|
$trackid = 'mailing'.$object->id;
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||||
|
|
||||||
|
if ($search_all) {
|
||||||
|
$setupstring = '';
|
||||||
|
foreach ($fieldstosearchall as $key => $val) {
|
||||||
|
$fieldstosearchall[$key] = $langs->trans($val);
|
||||||
|
$setupstring .= $key."=".$val.";";
|
||||||
}
|
}
|
||||||
|
print '<!-- Search done like if MYOBJECT_QUICKSEARCH_ON_FIELDS = '.$setupstring.' -->'."\n";
|
||||||
|
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
$newcardbutton = '';
|
$moreforfilter = '';
|
||||||
if ($user->rights->mailing->creer) {
|
|
||||||
$newcardbutton .= dolGetButtonTitle($langs->trans('NewMailing'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/mailing/card.php?action=create');
|
|
||||||
}
|
|
||||||
|
|
||||||
$i = 0;
|
$parameters = array();
|
||||||
|
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
|
if (empty($reshook)) {
|
||||||
|
$moreforfilter .= $hookmanager->resPrint;
|
||||||
|
} else {
|
||||||
|
$moreforfilter = $hookmanager->resPrint;
|
||||||
|
}
|
||||||
|
|
||||||
$param = "&search_all=".urlencode($search_all);
|
if (!empty($moreforfilter)) {
|
||||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||||
$param .= '&contextpage='.urlencode($contextpage);
|
print $moreforfilter;
|
||||||
}
|
$parameters = array('type'=>$type);
|
||||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
$param .= '&limit='.urlencode($limit);
|
print $hookmanager->resPrint;
|
||||||
}
|
print '</div>';
|
||||||
if ($filteremail) {
|
}
|
||||||
$param .= '&filteremail='.urlencode($filteremail);
|
|
||||||
}
|
|
||||||
|
|
||||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
||||||
if ($optioncss != '') {
|
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
|
||||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
|
||||||
}
|
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
|
||||||
print '<input type="hidden" name="action" value="list">';
|
|
||||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
|
||||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
|
||||||
|
|
||||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_email', 0, $newcardbutton, '', $limit, 0, 0, 1);
|
print '<div class="div-table-responsive">';
|
||||||
|
print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||||
|
|
||||||
$moreforfilter = '';
|
// Fields title search
|
||||||
|
// --------------------------------------------------------------------
|
||||||
print '<div class="div-table-responsive">';
|
print '<tr class="liste_titre_filter">';
|
||||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
// Action column
|
||||||
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
||||||
print '<tr class="liste_titre_filter">';
|
print '<td class="liste_titre maxwidthsearch center">';
|
||||||
print '<td class="liste_titre">';
|
$searchpicto = $form->showFilterButtons('left');
|
||||||
print '<input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
|
|
||||||
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).'">';
|
|
||||||
print '</td>';
|
|
||||||
print '<td class="liste_titre"> </td>';
|
|
||||||
if (!$filteremail) {
|
|
||||||
print '<td class="liste_titre"> </td>';
|
|
||||||
}
|
|
||||||
print '<td class="liste_titre"> </td>';
|
|
||||||
print '<td class="liste_titre"> </td>';
|
|
||||||
print '<td class="liste_titre maxwidthsearch">';
|
|
||||||
$searchpicto = $form->showFilterAndCheckAddButtons(0);
|
|
||||||
print $searchpicto;
|
print $searchpicto;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "m.rowid", $param, "", "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("Title", $_SERVER["PHP_SELF"], "m.titre", $param, "", "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "m.date_creat", $param, "", 'align="center"', $sortfield, $sortorder);
|
|
||||||
if (!$filteremail) {
|
|
||||||
print_liste_field_titre("NbOfEMails", $_SERVER["PHP_SELF"], "m.nbemail", $param, "", 'align="center"', $sortfield, $sortorder);
|
|
||||||
}
|
|
||||||
if (!$filteremail) {
|
|
||||||
print_liste_field_titre("DateLastSend", $_SERVER["PHP_SELF"], "m.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder);
|
|
||||||
} else {
|
|
||||||
print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder);
|
|
||||||
}
|
|
||||||
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], ($filteremail ? "mc.statut" : "m.statut"), $param, "", 'class="right"', $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', 'class="right"', $sortfield, $sortorder, 'maxwidthsearch ');
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
|
|
||||||
$email = new Mailing($db);
|
|
||||||
|
|
||||||
while ($i < min($num, $limit)) {
|
|
||||||
$obj = $db->fetch_object($resql);
|
|
||||||
|
|
||||||
$email->id = $obj->rowid;
|
|
||||||
$email->ref = $obj->rowid;
|
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
|
||||||
|
|
||||||
print '<td>';
|
|
||||||
print $email->getNomUrl(1);
|
|
||||||
print '</td>';
|
|
||||||
|
|
||||||
// Title
|
|
||||||
print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->title).'">'.dol_escape_htmltag($obj->title).'</td>';
|
|
||||||
|
|
||||||
// Date creation
|
|
||||||
print '<td class="center">';
|
|
||||||
print dol_print_date($db->jdate($obj->datec), 'day');
|
|
||||||
print '</td>';
|
|
||||||
|
|
||||||
// Nb of email
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
$text=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB);
|
|
||||||
print $form->textwithpicto($nbemail,$text,1,'warning');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print $nbemail;
|
|
||||||
}*/
|
|
||||||
print $nbemail;
|
|
||||||
print '</td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Last send
|
|
||||||
print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->date_envoi), 'day').'</td>';
|
|
||||||
print '</td>';
|
|
||||||
|
|
||||||
// Status
|
|
||||||
print '<td class="nowrap right">';
|
|
||||||
if ($filteremail) {
|
|
||||||
print $email::libStatutDest($obj->sendstatut, 2);
|
|
||||||
} else {
|
|
||||||
print $email->LibStatut($obj->statut, 5);
|
|
||||||
}
|
|
||||||
print '</td>';
|
|
||||||
|
|
||||||
print '<td></td>';
|
|
||||||
|
|
||||||
print "</tr>\n";
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
if (empty($num)) {
|
|
||||||
$colspan = 6;
|
|
||||||
if (!$filteremail) {
|
|
||||||
$colspan++;
|
|
||||||
}
|
|
||||||
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</table>';
|
|
||||||
print '</div>';
|
|
||||||
print '</form>';
|
|
||||||
|
|
||||||
$db->free($resql);
|
|
||||||
} else {
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
}
|
||||||
|
print '<td class="liste_titre">';
|
||||||
|
print '<input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
|
||||||
|
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).'">';
|
||||||
|
print '</td>';
|
||||||
|
print '<td class="liste_titre"> </td>';
|
||||||
|
if (!$filteremail) {
|
||||||
|
print '<td class="liste_titre"> </td>';
|
||||||
|
}
|
||||||
|
print '<td class="liste_titre"> </td>';
|
||||||
|
print '<td class="liste_titre"> </td>';
|
||||||
|
// Extra fields
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
|
||||||
|
// Fields from hook
|
||||||
|
$parameters = array('arrayfields'=>$arrayfields);
|
||||||
|
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
|
print $hookmanager->resPrint;
|
||||||
|
// Action column
|
||||||
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
||||||
|
print '<td class="liste_titre center maxwidthsearch">';
|
||||||
|
$searchpicto = $form->showFilterButtons();
|
||||||
|
print $searchpicto;
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
print '</tr>'."\n";
|
||||||
|
|
||||||
|
$totalarray = array();
|
||||||
|
$totalarray['nbfield'] = 0;
|
||||||
|
|
||||||
|
// Fields title label
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
||||||
|
print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "m.rowid", $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);
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
if (!$filteremail) {
|
||||||
|
print_liste_field_titre("NbOfEMails", $_SERVER["PHP_SELF"], "m.nbemail", $param, "", 'align="center"', $sortfield, $sortorder);
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
if (!$filteremail) {
|
||||||
|
print_liste_field_titre("DateLastSend", $_SERVER["PHP_SELF"], "m.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder);
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
} else {
|
||||||
|
print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder);
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
// Extra fields
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
||||||
|
// Hook fields
|
||||||
|
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
|
||||||
|
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
|
print $hookmanager->resPrint;
|
||||||
|
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], ($filteremail ? "mc.statut" : "m.statut"), $param, "", '', $sortfield, $sortorder, 'center ');
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
// Action column
|
||||||
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
||||||
|
print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
print '</tr>'."\n";
|
||||||
|
|
||||||
|
$totalarray = array();
|
||||||
|
$totalarray['nbfield'] = 0;
|
||||||
|
|
||||||
|
|
||||||
|
// Loop on record
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
$i = 0;
|
||||||
|
$savnbfield = $totalarray['nbfield'];
|
||||||
|
$totalarray = array();
|
||||||
|
$totalarray['nbfield'] = 0;
|
||||||
|
$imaxinloop = ($limit ? min($num, $limit) : $num);
|
||||||
|
while ($i < $imaxinloop) {
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
if (empty($obj)) {
|
||||||
|
break; // Should not happen
|
||||||
|
}
|
||||||
|
|
||||||
|
$object->id = $obj->rowid;
|
||||||
|
$object->ref = $obj->rowid;
|
||||||
|
|
||||||
|
// Show here line of result
|
||||||
|
$j = 0;
|
||||||
|
print '<tr data-rowid="'.$object->id.'" class="oddeven">';
|
||||||
|
// Action column
|
||||||
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
||||||
|
print '<td class="nowrap center">';
|
||||||
|
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||||
|
$selected = 0;
|
||||||
|
if (in_array($object->id, $arrayofselected)) {
|
||||||
|
$selected = 1;
|
||||||
|
}
|
||||||
|
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<td>';
|
||||||
|
print $object->getNomUrl(1);
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
// Title
|
||||||
|
print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->title).'">'.dol_escape_htmltag($obj->title).'</td>';
|
||||||
|
|
||||||
|
// Date creation
|
||||||
|
print '<td class="center">';
|
||||||
|
print dol_print_date($db->jdate($obj->datec), 'day');
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
// Nb of email
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
$text=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB);
|
||||||
|
print $form->textwithpicto($nbemail,$text,1,'warning');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $nbemail;
|
||||||
|
}*/
|
||||||
|
print $nbemail;
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Last send
|
||||||
|
print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->date_envoi), 'day').'</td>';
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
// Status
|
||||||
|
print '<td class="nowrap center">';
|
||||||
|
if ($filteremail) {
|
||||||
|
print $object::libStatutDest($obj->sendstatut, 2);
|
||||||
|
} else {
|
||||||
|
print $object->LibStatut($obj->statut, 5);
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
// Action column
|
||||||
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
||||||
|
print '<td class="nowrap center">';
|
||||||
|
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||||
|
$selected = 0;
|
||||||
|
if (in_array($object->id, $arrayofselected)) {
|
||||||
|
$selected = 1;
|
||||||
|
}
|
||||||
|
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
if (!$i) {
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</tr>'."\n";
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show total line
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
|
||||||
|
|
||||||
|
// If no record found
|
||||||
|
if (empty($num)) {
|
||||||
|
$colspan = 6;
|
||||||
|
if (!$filteremail) {
|
||||||
|
$colspan++;
|
||||||
|
}
|
||||||
|
print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$db->free($resql);
|
||||||
|
|
||||||
|
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
|
||||||
|
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
|
print $hookmanager->resPrint;
|
||||||
|
|
||||||
|
print '</table>'."\n";
|
||||||
|
print '</div>'."\n";
|
||||||
|
|
||||||
|
print '</form>'."\n";
|
||||||
|
|
||||||
// End of page
|
// End of page
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user