dolibarr  7.0.0-beta
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@capnetworks.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 $langs->load("agenda");
35 $langs->load("commercial");
36 
37 $action=GETPOST('action','alpha');
38 $month=GETPOST('month');
39 $year=GETPOST('year');
40 
41 $limit = GETPOST('limit')?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 }
97 
98 $sql.= $db->plimit($limit+1,$offset);
99 
100 //print $sql;
101 dol_syslog("select", LOG_DEBUG);
102 $resql=$db->query($sql);
103 if ($resql)
104 {
105  $num = $db->num_rows($resql);
106 
107  $param='';
108  if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
109 
110  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
111  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
112  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
113  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
114  print '<input type="hidden" name="action" value="list">';
115  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
116  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
117  print '<input type="hidden" name="page" value="'.$page.'">';
118 
119  print_barre_liste($langs->trans("EventReports"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit);
120 
121  $moreforfilter='';
122 
123  $i = 0;
124  print '<div class="div-table-responsive">';
125  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
126 
127  print '<tr class="liste_titre">';
128  print '<td>'.$langs->trans("Period").'</td>';
129  print '<td align="center">'.$langs->trans("EventsNb").'</td>';
130  print '<td align="center">'.$langs->trans("Action").'</td>';
131  print '<td>'.$langs->trans("PDF").'</td>';
132  print '<td align="center">'.$langs->trans("Date").'</td>';
133  print '<td align="center">'.$langs->trans("Size").'</td>';
134  print "</tr>\n";
135 
136  $var=true;
137  while ($i < min($num,$limit))
138  {
139  $obj=$db->fetch_object($resql);
140 
141  if ($obj)
142  {
143 
144  print '<tr class="oddeven">';
145 
146  // Date
147  print "<td>".$obj->df."</td>\n";
148 
149  // Nb of events
150  print '<td align="center">'.$obj->cc.'</td>';
151 
152  // Button to build doc
153  print '<td align="center">';
154  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>';
155  print '</td>';
156 
157  $name = "actions-".$obj->month."-".$obj->year.".pdf";
158  $relativepath= $name;
159  $file = $conf->agenda->dir_temp."/".$name;
160  $modulepart = 'actionsreport';
161  $documenturl= DOL_URL_ROOT.'/document.php';
162  if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper
163 
164  if (file_exists($file))
165  {
166  print '<td class="tdoverflowmax300">';
167  //print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?page='.$page.'&amp;file='.urlencode($relativepath).'&amp;modulepart=actionsreport">'.img_pdf().'</a>';
168 
169  $filearray=array('name'=>basename($file),'fullname'=>$file,'type'=>'file');
170  $out='';
171 
172  // Show file name with link to download
173  $out.= '<a href="'.$documenturl.'?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).($param?'&'.$param:'').'"';
174  $mime=dol_mimetype($relativepath,'',0);
175  if (preg_match('/text/',$mime)) $out.= ' target="_blank"';
176  $out.= ' target="_blank">';
177  $out.= img_mime($filearray["name"],$langs->trans("File").': '.$filearray["name"]);
178  $out.= $filearray["name"];
179  $out.= '</a>'."\n";
180  $out.= $formfile->showPreview($filearray,$modulepart,$relativepath,0,$param);
181  print $out;
182 
183  print '</td>';
184  print '<td align="center">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>';
185  print '<td align="center">'.dol_print_size(dol_filesize($file)).'</td>';
186  }
187  else {
188  print '<td>&nbsp;</td>';
189  print '<td>&nbsp;</td>';
190  print '<td>&nbsp;</td>';
191  }
192 
193  print "</tr>\n";
194  }
195  $i++;
196  }
197  print "</table>";
198  print '</div>';
199  print '</form>';
200 
201  $db->free($resql);
202 }
203 else
204 {
205  dol_print_error($db);
206 }
207 
208 llxFooter();
209 $db->close();
llxFooter()
Footer empty.
Definition: index.php:43
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
img_mime($file, $titlealt= '', $morecss='')
Show MIME img of a file.
if(GETPOST('cancel','alpha')) if(!GETPOST('confirmmassaction','alpha')&&$massaction!= 'presend'&&$massaction!= 'confirm_presend')
Draft customers invoices.
Definition: list.php:147
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:516
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
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:37
Class to offer components to list and upload files.
print
Draft customers invoices.
Definition: index.php:91
dol_filemtime($pathoffile)
Return time of a file.
Definition: files.lib.php:528
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:1013
Class to generate event report.
Definition: rapport.pdf.php:36
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.