dolibarr  9.0.0
index.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2003 Eric Seigne <erics@rycks.com>
4  * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.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 <http://www.gnu.org/licenses/>.
19  */
20 
27 require '../../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/modules/action/rapport.pdf.php';
33 
34 // Load translation files required by the page
35 $langs->loadLangs(array("agenda", "commercial"));
36 
37 $action=GETPOST('action','alpha');
38 $month=GETPOST('month');
39 $year=GETPOST('year');
40 
41 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
42 $sortfield = GETPOST("sortfield",'alpha');
43 $sortorder = GETPOST("sortorder",'alpha');
44 $page = GETPOST("page",'int');
45 if ($page == -1 || $page == null) { $page = 0 ; }
46 $offset = $limit * $page ;
47 if (! $sortorder) $sortorder="DESC";
48 if (! $sortfield) $sortfield="a.datep";
49 
50 // Security check
51 $socid = GETPOST('socid','int');
52 if ($user->societe_id) $socid=$user->societe_id;
53 $result = restrictedArea($user, 'agenda', $socid, '', 'myactions');
54 
55 
56 /*
57  * Actions
58  */
59 
60 if ($action == 'builddoc')
61 {
62  $cat = new CommActionRapport($db, $month, $year);
63  $result=$cat->write_file(GETPOST('id','int'));
64  if ($result < 0)
65  {
66  setEventMessages($cat->error, $cat->errors, 'errors');
67  }
68 }
69 
70 
71 /*
72  * View
73  */
74 
75 $formfile=new FormFile($db);
76 
77 llxHeader();
78 
79 $sql = "SELECT count(*) as cc,";
80 $sql.= " date_format(a.datep, '%m/%Y') as df,";
81 $sql.= " date_format(a.datep, '%m') as month,";
82 $sql.= " date_format(a.datep, '%Y') as year";
83 $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a,";
84 $sql.= " ".MAIN_DB_PREFIX."user as u";
85 $sql.= " WHERE a.fk_user_author = u.rowid";
86 $sql.= ' AND a.entity IN ('.getEntity('agenda').')';
87 //$sql.= " AND percent = 100";
88 $sql.= " GROUP BY year, month, df";
89 $sql.= " ORDER BY year DESC, month DESC, df DESC";
90 
91 $nbtotalofrecords = '';
92 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
93 {
94  $result = $db->query($sql);
95  $nbtotalofrecords = $db->num_rows($result);
96  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
97  {
98  $page = 0;
99  $offset = 0;
100  }
101 }
102 
103 $sql.= $db->plimit($limit+1,$offset);
104 
105 //print $sql;
106 dol_syslog("select", LOG_DEBUG);
107 $resql=$db->query($sql);
108 if ($resql)
109 {
110  $num = $db->num_rows($resql);
111 
112  $param='';
113  if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
114 
115  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
116  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
117  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
118  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
119  print '<input type="hidden" name="action" value="list">';
120  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
121  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
122  print '<input type="hidden" name="page" value="'.$page.'">';
123 
124  print_barre_liste($langs->trans("EventReports"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit);
125 
126  $moreforfilter='';
127 
128  $i = 0;
129  print '<div class="div-table-responsive">';
130  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
131 
132  print '<tr class="liste_titre">';
133  print '<td>'.$langs->trans("Period").'</td>';
134  print '<td align="center">'.$langs->trans("EventsNb").'</td>';
135  print '<td align="center">'.$langs->trans("Action").'</td>';
136  print '<td>'.$langs->trans("PDF").'</td>';
137  print '<td align="center">'.$langs->trans("Date").'</td>';
138  print '<td align="center">'.$langs->trans("Size").'</td>';
139  print "</tr>\n";
140 
141  while ($i < min($num,$limit))
142  {
143  $obj=$db->fetch_object($resql);
144 
145  if ($obj)
146  {
147 
148  print '<tr class="oddeven">';
149 
150  // Date
151  print "<td>".$obj->df."</td>\n";
152 
153  // Nb of events
154  print '<td align="center">'.$obj->cc.'</td>';
155 
156  // Button to build doc
157  print '<td align="center">';
158  print '<a href="'.$_SERVER["PHP_SELF"].'?action=builddoc&amp;page='.$page.'&amp;month='.$obj->month.'&amp;year='.$obj->year.'">'.img_picto($langs->trans('BuildDoc'),'filenew').'</a>';
159  print '</td>';
160 
161  $name = "actions-".$obj->month."-".$obj->year.".pdf";
162  $relativepath= $name;
163  $file = $conf->agenda->dir_temp."/".$name;
164  $modulepart = 'actionsreport';
165  $documenturl= DOL_URL_ROOT.'/document.php';
166  if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper
167 
168  if (file_exists($file))
169  {
170  print '<td class="tdoverflowmax300">';
171  //print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?page='.$page.'&amp;file='.urlencode($relativepath).'&amp;modulepart=actionsreport">'.img_pdf().'</a>';
172 
173  $filearray=array('name'=>basename($file),'fullname'=>$file,'type'=>'file');
174  $out='';
175 
176  // Show file name with link to download
177  $out.= '<a href="'.$documenturl.'?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).($param?'&'.$param:'').'"';
178  $mime=dol_mimetype($relativepath,'',0);
179  if (preg_match('/text/',$mime)) $out.= ' target="_blank"';
180  $out.= ' target="_blank">';
181  $out.= img_mime($filearray["name"],$langs->trans("File").': '.$filearray["name"]);
182  $out.= $filearray["name"];
183  $out.= '</a>'."\n";
184  $out.= $formfile->showPreview($filearray,$modulepart,$relativepath,0,$param);
185  print $out;
186 
187  print '</td>';
188  print '<td align="center">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>';
189  print '<td align="center">'.dol_print_size(dol_filesize($file)).'</td>';
190  }
191  else {
192  print '<td>&nbsp;</td>';
193  print '<td>&nbsp;</td>';
194  print '<td>&nbsp;</td>';
195  }
196 
197  print "</tr>\n";
198  }
199  $i++;
200  }
201  print "</table>";
202  print '</div>';
203  print '</form>';
204 
205  $db->free($resql);
206 }
207 else
208 {
209  dol_print_error($db);
210 }
211 
212 // End of page
213 llxFooter();
214 $db->close();
llxFooter()
Footer empty.
Definition: index.php:44
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return mime type of a file.
dol_filesize($pathoffile)
Return size of a file.
Definition: files.lib.php:552
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
Print a title with navigation controls for pagination.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
llxHeader()
Header empty.
Definition: index.php:36
if(GETPOST('cancel', 'alpha')) if(! GETPOST( 'confirmmassaction', 'alpha') &&$massaction !='presend' &&$massaction !='confirm_presend')
Draft customers invoices.
Definition: list.php:156
Class to offer components to list and upload files.
dol_filemtime($pathoffile)
Return time of a file.
Definition: files.lib.php:564
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.
Class to generate event report.
Definition: rapport.pdf.php:36
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.