dolibarr 24.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-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 $langs->trans("Ref").':</td><td><input type="text" class="flat inputsearch" name="sref"></td>';
85print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
86print '<tr class="oddeven nohover"><td class="nowrap">';
87print $langs->trans("Other").':</td><td><input type="text" class="flat inputsearch" name="search_all"></td>';
88
89print "</table></div></form><br>\n";
90
91
92
93
94// Affiche stats de tous les modules de destinataires mailings
95print '<table class="noborder centpercent">';
96print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("TargetsStatistics").'</td></tr>';
97
98$dir = DOL_DOCUMENT_ROOT."/core/modules/mailings";
99$handle = opendir($dir);
100
101if (is_resource($handle)) {
102 while (($file = readdir($handle)) !== false) {
103 if (substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS') {
104 if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg)) {
105 $modulename = $reg[1];
106 if ($modulename == 'example') {
107 continue;
108 }
109
110 // Loading Class
111 $file = $dir."/".$modulename.".modules.php";
112 $classname = "mailing_".$modulename;
113 require_once $file;
114 $mailmodule = new $classname($db);
115 '@phan-var-force MailingTargets $mailmodule';
116
117 $qualified = 1;
118 foreach ($mailmodule->require_module as $key) {
119 if (!isModEnabled($key) || (!$user->admin && !empty($mailmodule->require_admin))) {
120 $qualified = 0;
121 //print "Prerequisites are not not, selector won't be active";
122 break;
123 }
124 }
125
126 // If emailing is qualified for statistic section
127 if ($qualified) {
128 foreach ($mailmodule->getSqlArrayForStats() as $sql) {
129 print '<tr class="oddeven">';
130
131 $result = $db->query($sql);
132 if ($result) {
133 $num = $db->num_rows($result);
134
135 $i = 0;
136 while ($i < $num) {
137 $obj = $db->fetch_object($result);
138 print '<td>'.img_object('', $mailmodule->picto).' '.dol_escape_htmltag($obj->label).'</td>';
139 print '<td class="right">'.$obj->nb.'</td>';
140 $i++;
141 }
142
143 $db->free($result);
144 } else {
146 }
147 print '</tr>';
148 }
149 }
150 }
151 }
152 }
153 closedir($handle);
154}
155
156
157print "</table><br>";
158
159
160print '</div><div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
161
162
163/*
164 * List of last emailings
165 */
166
167$limit = 10;
168$sql = "SELECT m.rowid, m.titre as title, m.nbemail, m.statut as status, m.date_creat, m.messtype";
169$sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
170$sql .= " WHERE m.entity = ".((int) $conf->entity);
171$sql .= " ORDER BY m.date_creat DESC";
172$sql .= $db->plimit($limit);
173
174$result = $db->query($sql);
175if ($result) {
176 print '<div class="div-table-responsive-no-min">';
177 print '<table class="noborder centpercent">';
178 print '<tr class="liste_titre">';
179 print '<td colspan="2">'.$langs->trans("LastMailings", $limit).'</td>';
180 if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
181 print '<td class="center">'.$langs->trans("Type").'</td>';
182 }
183 print '<td class="center">'.$langs->trans("DateCreation").'</td>';
184 print '<td class="center">';
185 print $langs->trans("NbOfEMails");
186 if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
187 print ' | '.$langs->trans("Phone");
188 }
189 print '</td>';
190 print '<td class="right"><a href="'.DOL_URL_ROOT.'/comm/mailing/list.php" title="'.$langs->trans("AllEMailings").'"><span class="badge marginleftonlyshort">...</span></td>';
191 print '</tr>';
192
193 $num = $db->num_rows($result);
194 if ($num > 0) {
195 $i = 0;
196
197 while ($i < $num) {
198 $obj = $db->fetch_object($result);
199 $mailstatic = new Mailing($db);
200 $mailstatic->id = $obj->rowid;
201 $mailstatic->ref = $obj->rowid;
202 $mailstatic->messtype = $obj->messtype;
203
204 print '<tr class="oddeven">';
205 print '<td class="nowrap">'.$mailstatic->getNomUrl(1).'</td>';
206 print '<td class="tdoverflowmax100">'.dol_escape_htmltag($obj->title).'</td>';
207 if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) {
208 print '<td class="center">'.dol_escape_htmltag($obj->messtype).'</td>';
209 }
210 print '<td class="center">'.dol_print_date($db->jdate($obj->date_creat), 'day').'</td>';
211 print '<td class="center">'.($obj->nbemail ? (int) $obj->nbemail : "0").'</td>';
212 print '<td class="right">'.$mailstatic->LibStatut($obj->status, 5).'</td>';
213 print '</tr>';
214 $i++;
215 }
216 } else {
217 print '<tr><td><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
218 }
219 print "</table></div><br>";
220 $db->free($result);
221} else {
223}
224
225
226print '</div></div></div>';
227
228
229$parameters = array('user' => $user);
230$reshook = $hookmanager->executeHooks('dashboardEmailings', $parameters, $object); // Note that $action and $object may have been modified by hook
231
232// End of page
233llxFooter();
234$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.