dolibarr  7.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@capnetworks.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 $langs->load("commercial");
31 $langs->load("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  $var=false;
56  print '<form method="post" action="'.DOL_URL_ROOT.'/comm/mailing/list.php">';
57  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
58  print '<table class="noborder nohover" width="100%">';
59  print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAMailing").'</td></tr>';
60  print '<tr class="oddeven"><td class="nowrap">';
61  print $langs->trans("Ref").':</td><td><input type="text" class="flat inputsearch" name="sref"></td>';
62  print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
63  print '<tr class="oddeven"><td class="nowrap">';
64  print $langs->trans("Other").':</td><td><input type="text" class="flat inputsearch" name="sall"></td>';
65 
66  print "</table></form><br>\n";
67 //}
68 
69 
70 // Affiche stats de tous les modules de destinataires mailings
71 print '<table class="noborder" width="100%">';
72 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("TargetsStatistics").'</td></tr>';
73 
74 $dir=DOL_DOCUMENT_ROOT."/core/modules/mailings";
75 $handle=opendir($dir);
76 
77 $var=True;
78 if (is_resource($handle))
79 {
80  while (($file = readdir($handle))!==false)
81  {
82  if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
83  {
84  if (preg_match("/(.*)\.(.*)\.(.*)/i",$file,$reg))
85  {
86  $modulename=$reg[1];
87  if ($modulename == 'example') continue;
88 
89  // Loading Class
90  $file = $dir."/".$modulename.".modules.php";
91  $classname = "mailing_".$modulename;
92  require_once $file;
93  $mailmodule = new $classname($db);
94 
95  $qualified=1;
96  foreach ($mailmodule->require_module as $key)
97  {
98  if (! $conf->$key->enabled || (! $user->admin && $mailmodule->require_admin))
99  {
100  $qualified=0;
101  //print "Les pr�requis d'activation du module mailing ne sont pas respect�s. Il ne sera pas actif";
102  break;
103  }
104  }
105 
106  // Si le module mailing est qualifi�
107  if ($qualified)
108  {
109  $var = !$var;
110 
111  foreach ($mailmodule->getSqlArrayForStats() as $sql)
112  {
113  print '<tr class="oddeven">';
114 
115  $result=$db->query($sql);
116  if ($result)
117  {
118  $num = $db->num_rows($result);
119 
120  $i = 0;
121 
122  while ($i < $num )
123  {
124  $obj = $db->fetch_object($result);
125  print '<td>'.img_object('',$mailmodule->picto).' '.$obj->label.'</td><td align="right">'.$obj->nb.'<td>';
126  $i++;
127  }
128 
129  $db->free($result);
130  }
131  else
132  {
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.= " ORDER BY m.date_creat DESC";
159 $sql.= " LIMIT ".$limit;
160 $result=$db->query($sql);
161 if ($result)
162 {
163  print '<table class="noborder" width="100%">';
164  print '<tr class="liste_titre">';
165  print '<td colspan="2">'.$langs->trans("LastMailings",$limit).'</td>';
166  print '<td align="center">'.$langs->trans("DateCreation").'</td>';
167  print '<td align="center">'.$langs->trans("NbOfEMails").'</td>';
168  print '<td align="right"><a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("AllEMailings").'</a></td></tr>';
169 
170  $num = $db->num_rows($result);
171  if ($num > 0)
172  {
173  $var = true;
174  $i = 0;
175 
176  while ($i < $num )
177  {
178  $obj = $db->fetch_object($result);
179 
180 
181  print '<tr class="oddeven">';
182  print '<td class="nowrap"><a href="card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowEMail"),"email").' '.$obj->rowid.'</a></td>';
183  print '<td>'.dol_trunc($obj->titre,38).'</td>';
184  print '<td align="center">'.dol_print_date($db->jdate($obj->date_creat),'day').'</td>';
185  print '<td align="center">'.($obj->nbemail?$obj->nbemail:"0").'</td>';
186  $mailstatic=new Mailing($db);
187  print '<td align="right">'.$mailstatic->LibStatut($obj->statut,5).'</td>';
188  print '</tr>';
189  $i++;
190  }
191 
192  }
193  else
194  {
195  print '<tr><td class="opacitymedium">'.$langs->trans("None").'</td></tr>';
196  }
197  print "</table><br>";
198  $db->free($result);
199 }
200 else
201 {
202  dol_print_error($db);
203 }
204 
205 
206 //print '</td></tr></table>';
207 print '</div></div></div>';
208 
209 
210 if ($langs->file_exists("html/spam.html",0)) {
211  print "<br><br><br><br>".$langs->trans("Note")."<br>";
212  print '<div style="padding: 4px; background: #FAFAFA; border: 1px solid #BBBBBB;" >';
213  dol_print_file($langs,"html/spam.html",0);
214  print '</div>';
215 
216  print '<br>';
217  }
218 
219 
220 llxFooter();
221 
222 $db->close();
llxFooter()
Footer empty.
Definition: index.php:43
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:37
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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:91
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.