dolibarr  16.0.5
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 require '../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
30 
31 $hookmanager = new HookManager($db);
32 
33 // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
34 $hookmanager->initHooks(array('mailingindex'));
35 
36 // Load translation files required by the page
37 $langs->loadLangs(array('commercial', 'orders', 'mails'));
38 
39 $object = new Mailing($db);
40 
41 // Security check
42 $result = restrictedArea($user, 'mailing');
43 
44 
45 /*
46  * View
47  */
48 
49 $help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing';
50 $title = $langs->trans('MailingArea');
51 
52 llxHeader('', $title, $help_url);
53 
54 print load_fiche_titre($title);
55 
56 //print '<table class="notopnoleftnoright" width="100%">';
57 //print '<tr><td valign="top" width="30%" class="notopnoleft">';
58 print '<div class="fichecenter"><div class="fichethirdleft">';
59 
60 
61 //if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
62 //{
63  // Search into emailings
64  print '<form method="post" action="'.DOL_URL_ROOT.'/comm/mailing/list.php">';
65  print '<input type="hidden" name="token" value="'.newToken().'">';
66  print '<div class="div-table-responsive-no-min">';
67  print '<table class="noborder nohover centpercent">';
68  print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAMailing").'</td></tr>';
69  print '<tr class="oddeven"><td class="nowrap">';
70  print $langs->trans("Ref").':</td><td><input type="text" class="flat inputsearch" name="sref"></td>';
71  print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
72  print '<tr class="oddeven"><td class="nowrap">';
73  print $langs->trans("Other").':</td><td><input type="text" class="flat inputsearch" name="sall"></td>';
74 
75  print "</table></div></form><br>\n";
76 //}
77 
78 
79 // Affiche stats de tous les modules de destinataires mailings
80 print '<table class="noborder centpercent">';
81 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("TargetsStatistics").'</td></tr>';
82 
83 $dir = DOL_DOCUMENT_ROOT."/core/modules/mailings";
84 $handle = opendir($dir);
85 
86 if (is_resource($handle)) {
87  while (($file = readdir($handle)) !== false) {
88  if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') {
89  if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg)) {
90  $modulename = $reg[1];
91  if ($modulename == 'example') {
92  continue;
93  }
94 
95  // Loading Class
96  $file = $dir."/".$modulename.".modules.php";
97  $classname = "mailing_".$modulename;
98  require_once $file;
99  $mailmodule = new $classname($db);
100 
101  $qualified = 1;
102  foreach ($mailmodule->require_module as $key) {
103  if (!$conf->$key->enabled || (!$user->admin && $mailmodule->require_admin)) {
104  $qualified = 0;
105  //print "Les pr�requis d'activation du module mailing ne sont pas respect�s. Il ne sera pas actif";
106  break;
107  }
108  }
109 
110  // Si le module mailing est qualifi�
111  if ($qualified) {
112  foreach ($mailmodule->getSqlArrayForStats() as $sql) {
113  print '<tr class="oddeven">';
114 
115  $result = $db->query($sql);
116  if ($result) {
117  $num = $db->num_rows($result);
118 
119  $i = 0;
120 
121  while ($i < $num) {
122  $obj = $db->fetch_object($result);
123  print '<td>'.img_object('', $mailmodule->picto).' '.$obj->label.'</td><td class="right">'.$obj->nb.'<td>';
124  $i++;
125  }
126 
127  $db->free($result);
128  } else {
129  dol_print_error($db);
130  }
131  print '</tr>';
132  }
133  }
134  }
135  }
136  }
137  closedir($handle);
138 }
139 
140 
141 print "</table><br>";
142 
143 
144 print '</div><div class="fichetwothirdright">';
145 
146 
147 /*
148  * List of last emailings
149  */
150 $limit = 10;
151 $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat";
152 $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
153 $sql .= " WHERE m.entity = ".$conf->entity;
154 $sql .= " ORDER BY m.date_creat DESC";
155 $sql .= " LIMIT ".$limit;
156 $result = $db->query($sql);
157 if ($result) {
158  print '<div class="div-table-responsive-no-min">';
159  print '<table class="noborder centpercent">';
160  print '<tr class="liste_titre">';
161  print '<td colspan="2">'.$langs->trans("LastMailings", $limit).'</td>';
162  print '<td class="center">'.$langs->trans("DateCreation").'</td>';
163  print '<td class="center">'.$langs->trans("NbOfEMails").'</td>';
164  print '<td class="right"><a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("AllEMailings").'</a></td></tr>';
165 
166  $num = $db->num_rows($result);
167  if ($num > 0) {
168  $i = 0;
169 
170  while ($i < $num) {
171  $obj = $db->fetch_object($result);
172  $mailstatic = new Mailing($db);
173  $mailstatic->id = $obj->rowid;
174  $mailstatic->ref = $obj->rowid;
175 
176  print '<tr class="oddeven">';
177  print '<td class="nowrap">'.$mailstatic->getNomUrl(1).'</td>';
178  print '<td>'.dol_trunc($obj->title, 38).'</td>';
179  print '<td class="center">'.dol_print_date($db->jdate($obj->date_creat), 'day').'</td>';
180  print '<td class="center">'.($obj->nbemail ? $obj->nbemail : "0").'</td>';
181  print '<td class="right">'.$mailstatic->LibStatut($obj->statut, 5).'</td>';
182  print '</tr>';
183  $i++;
184  }
185  } else {
186  print '<tr><td><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
187  }
188  print "</table></div><br>";
189  $db->free($result);
190 } else {
191  dol_print_error($db);
192 }
193 
194 
195 print '</div></div>';
196 
197 
198 $parameters = array('user' => $user);
199 $reshook = $hookmanager->executeHooks('dashboardEmailings', $parameters, $object); // Note that $action and $object may have been modified by hook
200 
201 // End of page
202 llxFooter();
203 $db->close();
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
llxFooter
llxFooter()
Footer empty.
Definition: index.php:71
Mailing
Class to manage emailings module.
Definition: mailing.class.php:32
llxHeader
if(!defined('NOTOKENRENEWAL')) if(!defined('NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined('NOIPCHECK')) if(!defined('NOBROWSERNOTIF')) llxHeader()
Header empty.
Definition: index.php:63
HookManager
Class to manage hooks.
Definition: hookmanager.class.php:30