dolibarr 18.0.6
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2010 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
31
32$hookmanager = new HookManager($db);
33
34// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
35$hookmanager->initHooks(array('mailingindex'));
36
37// Load translation files required by the page
38$langs->loadLangs(array('commercial', 'orders', 'mails'));
39
40$object = new Mailing($db);
41
42// Security check
43$result = restrictedArea($user, 'mailing');
44
45
46/*
47 * View
48 */
49
50$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing';
51$title = $langs->trans('MailingArea');
52
53llxHeader('', $title, $help_url);
54
55print load_fiche_titre($title);
56
57//print '<table class="notopnoleftnoright" width="100%">';
58//print '<tr><td valign="top" width="30%" class="notopnoleft">';
59print '<div class="fichecenter"><div class="fichethirdleft">';
60
61
62//if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
63//{
64 // Search into emailings
65 print '<form method="post" action="'.DOL_URL_ROOT.'/comm/mailing/list.php">';
66 print '<input type="hidden" name="token" value="'.newToken().'">';
67 print '<div class="div-table-responsive-no-min">';
68 print '<table class="noborder nohover centpercent">';
69 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAMailing").'</td></tr>';
70 print '<tr class="oddeven"><td class="nowrap">';
71 print $langs->trans("Ref").':</td><td><input type="text" class="flat inputsearch" name="sref"></td>';
72 print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
73 print '<tr class="oddeven"><td class="nowrap">';
74 print $langs->trans("Other").':</td><td><input type="text" class="flat inputsearch" name="sall"></td>';
75
76 print "</table></div></form><br>\n";
77//}
78
79
80// Affiche stats de tous les modules de destinataires mailings
81print '<table class="noborder centpercent">';
82print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("TargetsStatistics").'</td></tr>';
83
84$dir = DOL_DOCUMENT_ROOT."/core/modules/mailings";
85$handle = opendir($dir);
86
87if (is_resource($handle)) {
88 while (($file = readdir($handle)) !== false) {
89 if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') {
90 if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg)) {
91 $modulename = $reg[1];
92 if ($modulename == 'example') {
93 continue;
94 }
95
96 // Loading Class
97 $file = $dir."/".$modulename.".modules.php";
98 $classname = "mailing_".$modulename;
99 require_once $file;
100 $mailmodule = new $classname($db);
101
102 $qualified = 1;
103 foreach ($mailmodule->require_module as $key) {
104 if (empty($conf->$key->enabled) || (!$user->admin && $mailmodule->require_admin)) {
105 $qualified = 0;
106 //print "Les pr�requis d'activation du module mailing ne sont pas respect�s. Il ne sera pas actif";
107 break;
108 }
109 }
110
111 // Si le module mailing est qualifi�
112 if ($qualified) {
113 foreach ($mailmodule->getSqlArrayForStats() as $sql) {
114 print '<tr class="oddeven">';
115
116 $result = $db->query($sql);
117 if ($result) {
118 $num = $db->num_rows($result);
119
120 $i = 0;
121
122 while ($i < $num) {
123 $obj = $db->fetch_object($result);
124 print '<td>'.img_object('', $mailmodule->picto).' '.$obj->label.'</td><td class="right">'.$obj->nb.'<td>';
125 $i++;
126 }
127
128 $db->free($result);
129 } else {
130 dol_print_error($db);
131 }
132 print '</tr>';
133 }
134 }
135 }
136 }
137 }
138 closedir($handle);
139}
140
141
142print "</table><br>";
143
144
145print '</div><div class="fichetwothirdright">';
146
147
148/*
149 * List of last emailings
150 */
151$limit = 10;
152$sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat";
153$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
154$sql .= " WHERE m.entity = ".$conf->entity;
155$sql .= " ORDER BY m.date_creat DESC";
156$sql .= " LIMIT ".$limit;
157$result = $db->query($sql);
158if ($result) {
159 print '<div class="div-table-responsive-no-min">';
160 print '<table class="noborder centpercent">';
161 print '<tr class="liste_titre">';
162 print '<td colspan="2">'.$langs->trans("LastMailings", $limit).'</td>';
163 print '<td class="center">'.$langs->trans("DateCreation").'</td>';
164 print '<td class="center">'.$langs->trans("NbOfEMails").'</td>';
165 print '<td class="right"><a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("AllEMailings").'</a></td></tr>';
166
167 $num = $db->num_rows($result);
168 if ($num > 0) {
169 $i = 0;
170
171 while ($i < $num) {
172 $obj = $db->fetch_object($result);
173 $mailstatic = new Mailing($db);
174 $mailstatic->id = $obj->rowid;
175 $mailstatic->ref = $obj->rowid;
176
177 print '<tr class="oddeven">';
178 print '<td class="nowrap">'.$mailstatic->getNomUrl(1).'</td>';
179 print '<td>'.(!empty($obj->title) ? dol_trunc($obj->title, 38) : '').'</td>';
180 print '<td class="center">'.dol_print_date($db->jdate($obj->date_creat), 'day').'</td>';
181 print '<td class="center">'.($obj->nbemail ? $obj->nbemail : "0").'</td>';
182 print '<td class="right">'.$mailstatic->LibStatut($obj->statut, 5).'</td>';
183 print '</tr>';
184 $i++;
185 }
186 } else {
187 print '<tr><td><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
188 }
189 print "</table></div><br>";
190 $db->free($result);
191} else {
192 dol_print_error($db);
193}
194
195
196print '</div></div>';
197
198
199$parameters = array('user' => $user);
200$reshook = $hookmanager->executeHooks('dashboardEmailings', $parameters, $object); // Note that $action and $object may have been modified by hook
201
202// End of page
203llxFooter();
204$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
Class to manage hooks.
Class to manage emailings module.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.