dolibarr  17.0.4
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
28 require '../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php';
30 require_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 
53 llxHeader('', $title, $help_url);
54 
55 print load_fiche_titre($title);
56 
57 //print '<table class="notopnoleftnoright" width="100%">';
58 //print '<tr><td valign="top" width="30%" class="notopnoleft">';
59 print '<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
81 print '<table class="noborder centpercent">';
82 print '<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 
87 if (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 (!$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 
142 print "</table><br>";
143 
144 
145 print '</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);
158 if ($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>'.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 
196 print '</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
203 llxFooter();
204 $db->close();
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:118
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...
llxFooter()
Footer empty.
Definition: index.php:71
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
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.