dolibarr 25.0.0-alpha
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-2026 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';
38require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
40
41// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array
42$hookmanager->initHooks(array('mailingindex'));
43
44// Load translation files required by the page
45$langs->loadLangs(array('commercial', 'orders', 'mails'));
46
47$object = new Mailing($db);
48
49// Security check
50$result = restrictedArea($user, 'mailing');
51
52
53/*
54 * View
55 */
56
57$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing';
58$title = $langs->trans('MailingArea');
59
60llxHeader('', $title, $help_url);
61
62print load_fiche_titre($title);
63
64
65print '<div class="fichecenter">';
66
67print '<div class="twocolumns">';
68
69print '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
70
71
72$titlesearch = $langs->trans("SearchAMailing");
73if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
74 $titlesearch .= ' | '.$langs->trans("smsing");
75}
76
77// Search into emailings
78print '<form method="post" action="'.DOL_URL_ROOT.'/comm/mailing/list.php">';
79print '<input type="hidden" name="token" value="'.newToken().'">';
80print '<div class="div-table-responsive-no-min">';
81print '<table class="noborder nohover centpercent">';
82print '<tr class="liste_titre"><td colspan="3">'.$titlesearch.'</td></tr>';
83print '<tr class="oddeven nohover"><td class="nowrap">';
84print '<table class="noborderbottom centpercent">';
85print '<tr class="noborderbottom"><td>'.$langs->trans("Ref").':</td><td><input type="text" class="flat inputsearch maxwidth200" name="sref"></td>';
86print '<tr class="noborderbottom"><td>'.$langs->trans("Other").':</td><td><input type="text" class="flat inputsearch maxwidth200" name="search_all"></td></tr>';
87print '</table>';
88print '</td>';
89print '<td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
90print "</table></div></form><br>\n";
91
92
93
94
95// Affiche stats de tous les modules de destinataires mailings
96print '<table class="noborder centpercent">';
97print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("TargetsStatistics").'</td></tr>';
98
99$dir = DOL_DOCUMENT_ROOT."/core/modules/mailings";
100$handle = opendir($dir);
101
102if (is_resource($handle)) {
103 while (($file = readdir($handle)) !== false) {
104 if (substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS') {
105 if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg)) {
106 $modulename = $reg[1];
107 if ($modulename == 'example') {
108 continue;
109 }
110
111 // Loading Class
112 $file = $dir."/".$modulename.".modules.php";
113 $classname = "mailing_".$modulename;
114 require_once $file;
115 $mailmodule = new $classname($db);
116 '@phan-var-force MailingTargets $mailmodule';
117
118 $qualified = 1;
119 foreach ($mailmodule->require_module as $key) {
120 if (!isModEnabled($key) || (!$user->admin && !empty($mailmodule->require_admin))) {
121 $qualified = 0;
122 //print "Prerequisites are not not, selector won't be active";
123 break;
124 }
125 }
126
127 // If emailing is qualified for statistic section
128 if ($qualified) {
129 foreach ($mailmodule->getSqlArrayForStats() as $sql) {
130 print '<tr class="oddeven">';
131
132 $result = $db->query($sql);
133 if ($result) {
134 $num = $db->num_rows($result);
135
136 $i = 0;
137 while ($i < $num) {
138 $obj = $db->fetch_object($result);
139 print '<td>'.img_object('', $mailmodule->picto).' '.dol_escape_htmltag($obj->label).'</td>';
140 print '<td class="right">'.$obj->nb.'</td>';
141 $i++;
142 }
143
144 $db->free($result);
145 } else {
147 }
148 print '</tr>';
149 }
150 }
151 }
152 }
153 }
154 closedir($handle);
155}
156
157
158print "</table><br>";
159
160
161print '</div><div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
162
163
164/*
165 * List of last emailings
166 */
167
168$limit = 10;
169$sql = "SELECT m.rowid, m.titre as title, m.nbemail, m.statut as status, m.date_creat, m.messtype";
170$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
171$sql .= " WHERE m.entity = ".((int) $conf->entity);
172$sql .= " ORDER BY m.date_creat DESC";
173$sql .= $db->plimit($limit);
174
175$result = $db->query($sql);
176if ($result) {
177 print '<div class="div-table-responsive-no-min">';
178 print '<table class="noborder centpercent">';
179 print '<tr class="liste_titre">';
180 print '<td colspan="2">'.$langs->trans("LastMailings", $limit).'</td>';
181 if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
182 print '<td class="center">'.$langs->trans("Type").'</td>';
183 }
184 print '<td class="center">'.$langs->trans("DateCreation").'</td>';
185 print '<td class="center">';
186 print $langs->trans("NbOfEMails");
187 if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
188 print ' | '.$langs->trans("Phone");
189 }
190 print '</td>';
191 print '<td class="right"><a href="'.DOL_URL_ROOT.'/comm/mailing/list.php" title="'.$langs->trans("AllEMailings").'"><span class="badge marginleftonlyshort">...</span></td>';
192 print '</tr>';
193
194 $num = $db->num_rows($result);
195 if ($num > 0) {
196 $i = 0;
197
198 while ($i < $num) {
199 $obj = $db->fetch_object($result);
200 $mailstatic = new Mailing($db);
201 $mailstatic->id = $obj->rowid;
202 $mailstatic->ref = $obj->rowid;
203 $mailstatic->messtype = $obj->messtype;
204
205 print '<tr class="oddeven">';
206 print '<td class="nowrap">'.$mailstatic->getNomUrl(1).'</td>';
207 print '<td class="tdoverflowmax100">'.dol_escape_htmltag($obj->title).'</td>';
208 if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
209 print '<td class="center">'.dol_escape_htmltag($obj->messtype).'</td>';
210 }
211 print '<td class="center">'.dol_print_date($db->jdate($obj->date_creat), 'day').'</td>';
212 print '<td class="center">'.($obj->nbemail ? (int) $obj->nbemail : "0").'</td>';
213 print '<td class="right">'.$mailstatic->LibStatut($obj->status, 5).'</td>';
214 print '</tr>';
215 $i++;
216 }
217 } else {
218 print '<tr><td><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
219 }
220 print "</table></div><br>";
221 $db->free($result);
222} else {
224}
225
226
227print '</div></div></div>';
228
229
230$parameters = array('user' => $user);
231$reshook = $hookmanager->executeHooks('dashboardEmailings', $parameters, $object); // Note that $action and $object may have been modified by hook
232
233// End of page
234llxFooter();
235$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
Class to manage emailings module.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
isModEnabled($module)
Is Dolibarr module enabled.
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.