dolibarr  9.0.0
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  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
26 require '../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT .'/comm/mailing/class/mailing.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
29 
30 // Load translation files required by the page
31 $langs->loadLangs(array('commercial', 'orders'));
32 
33 
34 // Security check
35 $result=restrictedArea($user,'mailing');
36 
37 
38 /*
39  * View
40  */
41 
42 $help_url='EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing';
43 llxHeader('','EMailing',$help_url);
44 
45 print load_fiche_titre($langs->trans("MailingArea"));
46 
47 //print '<table class="notopnoleftnoright" width="100%">';
48 //print '<tr><td valign="top" width="30%" class="notopnoleft">';
49 print '<div class="fichecenter"><div class="fichethirdleft">';
50 
51 
52 //if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
53 //{
54  // Recherche emails
55  print '<form method="post" action="'.DOL_URL_ROOT.'/comm/mailing/list.php">';
56  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
57  print '<table class="noborder nohover" width="100%">';
58  print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAMailing").'</td></tr>';
59  print '<tr class="oddeven"><td class="nowrap">';
60  print $langs->trans("Ref").':</td><td><input type="text" class="flat inputsearch" name="sref"></td>';
61  print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
62  print '<tr class="oddeven"><td class="nowrap">';
63  print $langs->trans("Other").':</td><td><input type="text" class="flat inputsearch" name="sall"></td>';
64 
65  print "</table></form><br>\n";
66 //}
67 
68 
69 // Affiche stats de tous les modules de destinataires mailings
70 print '<table class="noborder" width="100%">';
71 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("TargetsStatistics").'</td></tr>';
72 
73 $dir=DOL_DOCUMENT_ROOT."/core/modules/mailings";
74 $handle=opendir($dir);
75 
76 if (is_resource($handle))
77 {
78  while (($file = readdir($handle))!==false)
79  {
80  if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
81  {
82  if (preg_match("/(.*)\.(.*)\.(.*)/i",$file,$reg))
83  {
84  $modulename=$reg[1];
85  if ($modulename == 'example') continue;
86 
87  // Loading Class
88  $file = $dir."/".$modulename.".modules.php";
89  $classname = "mailing_".$modulename;
90  require_once $file;
91  $mailmodule = new $classname($db);
92 
93  $qualified=1;
94  foreach ($mailmodule->require_module as $key)
95  {
96  if (! $conf->$key->enabled || (! $user->admin && $mailmodule->require_admin))
97  {
98  $qualified=0;
99  //print "Les pr�requis d'activation du module mailing ne sont pas respect�s. Il ne sera pas actif";
100  break;
101  }
102  }
103 
104  // Si le module mailing est qualifi�
105  if ($qualified)
106  {
107  foreach ($mailmodule->getSqlArrayForStats() as $sql)
108  {
109  print '<tr class="oddeven">';
110 
111  $result=$db->query($sql);
112  if ($result)
113  {
114  $num = $db->num_rows($result);
115 
116  $i = 0;
117 
118  while ($i < $num )
119  {
120  $obj = $db->fetch_object($result);
121  print '<td>'.img_object('',$mailmodule->picto).' '.$obj->label.'</td><td align="right">'.$obj->nb.'<td>';
122  $i++;
123  }
124 
125  $db->free($result);
126  }
127  else
128  {
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 '</td><td valign="top" width="70%" class="notopnoleftnoright">';
145 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
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.= " ORDER BY m.date_creat DESC";
155 $sql.= " LIMIT ".$limit;
156 $result=$db->query($sql);
157 if ($result)
158 {
159  print '<table class="noborder" width="100%">';
160  print '<tr class="liste_titre">';
161  print '<td colspan="2">'.$langs->trans("LastMailings",$limit).'</td>';
162  print '<td align="center">'.$langs->trans("DateCreation").'</td>';
163  print '<td align="center">'.$langs->trans("NbOfEMails").'</td>';
164  print '<td align="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  {
169  $i = 0;
170 
171  while ($i < $num )
172  {
173  $obj = $db->fetch_object($result);
174 
175  print '<tr class="oddeven">';
176  print '<td class="nowrap"><a href="card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowEMail"),"email").' '.$obj->rowid.'</a></td>';
177  print '<td>'.dol_trunc($obj->titre,38).'</td>';
178  print '<td align="center">'.dol_print_date($db->jdate($obj->date_creat),'day').'</td>';
179  print '<td align="center">'.($obj->nbemail?$obj->nbemail:"0").'</td>';
180  $mailstatic=new Mailing($db);
181  print '<td align="right">'.$mailstatic->LibStatut($obj->statut,5).'</td>';
182  print '</tr>';
183  $i++;
184  }
185  }
186  else
187  {
188  print '<tr><td class="opacitymedium">'.$langs->trans("None").'</td></tr>';
189  }
190  print "</table><br>";
191  $db->free($result);
192 }
193 else
194 {
195  dol_print_error($db);
196 }
197 
198 
199 //print '</td></tr></table>';
200 print '</div></div></div>';
201 
202 
203 if ($langs->file_exists("html/spam.html",0)) {
204  print "<br><br><br><br>".$langs->trans("Note")."<br>";
205  print '<div style="padding: 4px; background: #FAFAFA; border: 1px solid #BBBBBB;" >';
206  dol_print_file($langs,"html/spam.html",0);
207  print '</div>';
208 
209  print '<br>';
210  }
211 
212 // End of page
213 llxFooter();
214 $db->close();
llxFooter()
Footer empty.
Definition: index.php:44
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
print
Draft customers invoices.
Definition: index.php:91
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
llxHeader()
Header empty.
Definition: index.php:36
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.
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)