dolibarr 21.0.0-beta
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 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
7 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
33
42$hookmanager = new HookManager($db);
43
44// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array
45$hookmanager->initHooks(array('mailingindex'));
46
47// Load translation files required by the page
48$langs->loadLangs(array('commercial', 'orders', 'mails'));
49
50$object = new Mailing($db);
51
52// Security check
53$result = restrictedArea($user, 'mailing');
54
55
56/*
57 * View
58 */
59
60$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing';
61$title = $langs->trans('MailingArea');
62
63llxHeader('', $title, $help_url);
64
65print load_fiche_titre($title);
66
67
68print '<div class="fichecenter">';
69
70print '<div class="twocolumns">';
71
72print '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
73
74
75$titlesearch = $langs->trans("SearchAMailing");
76if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
77 $titlesearch .= ' | '.$langs->trans("smsing");
78}
79
80// Search into emailings
81print '<form method="post" action="'.DOL_URL_ROOT.'/comm/mailing/list.php">';
82print '<input type="hidden" name="token" value="'.newToken().'">';
83print '<div class="div-table-responsive-no-min">';
84print '<table class="noborder nohover centpercent">';
85print '<tr class="liste_titre"><td colspan="3">'.$titlesearch.'</td></tr>';
86print '<tr class="oddeven"><td class="nowrap">';
87print $langs->trans("Ref").':</td><td><input type="text" class="flat inputsearch" name="sref"></td>';
88print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
89print '<tr class="oddeven"><td class="nowrap">';
90print $langs->trans("Other").':</td><td><input type="text" class="flat inputsearch" name="sall"></td>';
91
92print "</table></div></form><br>\n";
93
94
95
96
97// Affiche stats de tous les modules de destinataires mailings
98print '<table class="noborder centpercent">';
99print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("TargetsStatistics").'</td></tr>';
100
101$dir = DOL_DOCUMENT_ROOT."/core/modules/mailings";
102$handle = opendir($dir);
103
104if (is_resource($handle)) {
105 while (($file = readdir($handle)) !== false) {
106 if (substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS') {
107 if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg)) {
108 $modulename = $reg[1];
109 if ($modulename == 'example') {
110 continue;
111 }
112
113 // Loading Class
114 $file = $dir."/".$modulename.".modules.php";
115 $classname = "mailing_".$modulename;
116 require_once $file;
117 $mailmodule = new $classname($db);
118 '@phan-var-force MailingTargets $mailmodule';
119
120 $qualified = 1;
121 foreach ($mailmodule->require_module as $key) {
122 if (!isModEnabled($key) || (!$user->admin && !empty($mailmodule->require_admin))) {
123 $qualified = 0;
124 //print "Prerequisites are not not, selector won't be active";
125 break;
126 }
127 }
128
129 // If emailing is qualified for statistic section
130 if ($qualified) {
131 foreach ($mailmodule->getSqlArrayForStats() as $sql) {
132 print '<tr class="oddeven">';
133
134 $result = $db->query($sql);
135 if ($result) {
136 $num = $db->num_rows($result);
137
138 $i = 0;
139 while ($i < $num) {
140 $obj = $db->fetch_object($result);
141 print '<td>'.img_object('', $mailmodule->picto).' '.dol_escape_htmltag($obj->label).'</td>';
142 print '<td class="right">'.$obj->nb.'</td>';
143 $i++;
144 }
145
146 $db->free($result);
147 } else {
148 dol_print_error($db);
149 }
150 print '</tr>';
151 }
152 }
153 }
154 }
155 }
156 closedir($handle);
157}
158
159
160print "</table><br>";
161
162
163print '</div><div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
164
165
166/*
167 * List of last emailings
168 */
169
170$limit = 10;
171$sql = "SELECT m.rowid, m.titre as title, m.nbemail, m.statut as status, m.date_creat, m.messtype";
172$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
173$sql .= " WHERE m.entity = ".$conf->entity;
174$sql .= " ORDER BY m.date_creat DESC";
175$sql .= " LIMIT ".$limit;
176$result = $db->query($sql);
177if ($result) {
178 print '<div class="div-table-responsive-no-min">';
179 print '<table class="noborder centpercent">';
180 print '<tr class="liste_titre">';
181 print '<td colspan="2">'.$langs->trans("LastMailings", $limit).'</td>';
182 if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
183 print '<td class="center">'.$langs->trans("Type").'</td>';
184 }
185 print '<td class="center">'.$langs->trans("DateCreation").'</td>';
186 print '<td class="center">';
187 print $langs->trans("NbOfEMails");
188 if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
189 print ' | '.$langs->trans("Phone");
190 }
191 print '</td>';
192 print '<td class="right"><a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("AllEMailings").'</a></td>';
193 print '</tr>';
194
195 $num = $db->num_rows($result);
196 if ($num > 0) {
197 $i = 0;
198
199 while ($i < $num) {
200 $obj = $db->fetch_object($result);
201 $mailstatic = new Mailing($db);
202 $mailstatic->id = $obj->rowid;
203 $mailstatic->ref = $obj->rowid;
204 $mailstatic->messtype = $obj->messtype;
205
206 print '<tr class="oddeven">';
207 print '<td class="nowrap">'.$mailstatic->getNomUrl(1).'</td>';
208 print '<td class="tdoverflowmax100">'.dol_escape_htmltag($obj->title).'</td>';
209 if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
210 print '<td class="center">'.dol_escape_htmltag($obj->messtype).'</td>';
211 }
212 print '<td class="center">'.dol_print_date($db->jdate($obj->date_creat), 'day').'</td>';
213 print '<td class="center">'.($obj->nbemail ? (int) $obj->nbemail : "0").'</td>';
214 print '<td class="right">'.$mailstatic->LibStatut($obj->status, 5).'</td>';
215 print '</tr>';
216 $i++;
217 }
218 } else {
219 print '<tr><td><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
220 }
221 print "</table></div><br>";
222 $db->free($result);
223} else {
224 dol_print_error($db);
225}
226
227
228print '</div></div></div>';
229
230
231$parameters = array('user' => $user);
232$reshook = $hookmanager->executeHooks('dashboardEmailings', $parameters, $object); // Note that $action and $object may have been modified by hook
233
234// End of page
235llxFooter();
236$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage hooks.
Class to manage emailings module.
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.