dolibarr  13.0.2
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'));
38 
39 
40 // Security check
41 $result = restrictedArea($user, 'mailing');
42 
43 
44 /*
45  * View
46  */
47 
48 $help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing';
49 llxHeader('', 'EMailing', $help_url);
50 
51 print load_fiche_titre($langs->trans("MailingArea"));
52 
53 //print '<table class="notopnoleftnoright" width="100%">';
54 //print '<tr><td valign="top" width="30%" class="notopnoleft">';
55 print '<div class="fichecenter"><div class="fichethirdleft">';
56 
57 
58 //if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
59 //{
60  // Recherche emails
61  print '<form method="post" action="'.DOL_URL_ROOT.'/comm/mailing/list.php">';
62  print '<input type="hidden" name="token" value="'.newToken().'">';
63  print '<div class="div-table-responsive-no-min">';
64  print '<table class="noborder nohover centpercent">';
65  print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAMailing").'</td></tr>';
66  print '<tr class="oddeven"><td class="nowrap">';
67  print $langs->trans("Ref").':</td><td><input type="text" class="flat inputsearch" name="sref"></td>';
68  print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
69  print '<tr class="oddeven"><td class="nowrap">';
70  print $langs->trans("Other").':</td><td><input type="text" class="flat inputsearch" name="sall"></td>';
71 
72  print "</table></div></form><br>\n";
73 //}
74 
75 
76 // Affiche stats de tous les modules de destinataires mailings
77 print '<table class="noborder centpercent">';
78 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("TargetsStatistics").'</td></tr>';
79 
80 $dir = DOL_DOCUMENT_ROOT."/core/modules/mailings";
81 $handle = opendir($dir);
82 
83 if (is_resource($handle))
84 {
85  while (($file = readdir($handle)) !== false)
86  {
87  if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
88  {
89  if (preg_match("/(.*)\.(.*)\.(.*)/i", $file, $reg))
90  {
91  $modulename = $reg[1];
92  if ($modulename == 'example') continue;
93 
94  // Loading Class
95  $file = $dir."/".$modulename.".modules.php";
96  $classname = "mailing_".$modulename;
97  require_once $file;
98  $mailmodule = new $classname($db);
99 
100  $qualified = 1;
101  foreach ($mailmodule->require_module as $key)
102  {
103  if (!$conf->$key->enabled || (!$user->admin && $mailmodule->require_admin))
104  {
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  {
114  foreach ($mailmodule->getSqlArrayForStats() as $sql)
115  {
116  print '<tr class="oddeven">';
117 
118  $result = $db->query($sql);
119  if ($result) {
120  $num = $db->num_rows($result);
121 
122  $i = 0;
123 
124  while ($i < $num)
125  {
126  $obj = $db->fetch_object($result);
127  print '<td>'.img_object('', $mailmodule->picto).' '.$obj->label.'</td><td class="right">'.$obj->nb.'<td>';
128  $i++;
129  }
130 
131  $db->free($result);
132  } else {
133  dol_print_error($db);
134  }
135  print '</tr>';
136  }
137  }
138  }
139  }
140  }
141  closedir($handle);
142 }
143 
144 
145 print "</table><br>";
146 
147 
148 //print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
149 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
150 
151 
152 /*
153  * List of last emailings
154  */
155 $limit = 10;
156 $sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat";
157 $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
158 $sql .= " WHERE m.entity = ".$conf->entity;
159 $sql .= " ORDER BY m.date_creat DESC";
160 $sql .= " LIMIT ".$limit;
161 $result = $db->query($sql);
162 if ($result) {
163  print '<div class="div-table-responsive-no-min">';
164  print '<table class="noborder centpercent">';
165  print '<tr class="liste_titre">';
166  print '<td colspan="2">'.$langs->trans("LastMailings", $limit).'</td>';
167  print '<td class="center">'.$langs->trans("DateCreation").'</td>';
168  print '<td class="center">'.$langs->trans("NbOfEMails").'</td>';
169  print '<td class="right"><a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("AllEMailings").'</a></td></tr>';
170 
171  $num = $db->num_rows($result);
172  if ($num > 0)
173  {
174  $i = 0;
175 
176  while ($i < $num)
177  {
178  $obj = $db->fetch_object($result);
179  $mailstatic = new Mailing($db);
180  $mailstatic->id = $obj->rowid;
181  $mailstatic->ref = $obj->rowid;
182 
183  print '<tr class="oddeven">';
184  print '<td class="nowrap">'.$mailstatic->getNomUrl(1).'</td>';
185  print '<td>'.dol_trunc($obj->title, 38).'</td>';
186  print '<td class="center">'.dol_print_date($db->jdate($obj->date_creat), 'day').'</td>';
187  print '<td class="center">'.($obj->nbemail ? $obj->nbemail : "0").'</td>';
188  print '<td class="right">'.$mailstatic->LibStatut($obj->statut, 5).'</td>';
189  print '</tr>';
190  $i++;
191  }
192  } else {
193  print '<tr><td class="opacitymedium">'.$langs->trans("None").'</td></tr>';
194  }
195  print "</table></div><br>";
196  $db->free($result);
197 } else {
198  dol_print_error($db);
199 }
200 
201 
202 //print '</td></tr></table>';
203 print '</div></div></div>';
204 
205 
206 if ($langs->file_exists("html/spam.html", 0)) {
207  print "<br><br><br><br>".$langs->trans("Note")."<br>";
208  print '<div style="padding: 4px; background: #FAFAFA; border: 1px solid #BBBBBB;" >';
209  dol_print_file($langs, "html/spam.html", 0);
210  print '</div>';
211 
212  print '<br>';
213 }
214 
215 $parameters = array('user' => $user);
216 $reshook = $hookmanager->executeHooks('dashboardEmailings', $parameters, $object); // Note that $action and $object may have been modified by hook
217 
218 // End of page
219 llxFooter();
220 $db->close();
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage hooks.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_print_file($langs, $filename, $searchalt=0)
Output content of a file $filename in version of current language (otherwise may use an alternate lan...
Class to manage emailings module.
print
Draft customers invoices.
Definition: index.php:89
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
llxFooter()
Empty footer.
Definition: wrapper.php:59