dolibarr 19.0.3
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 <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
31require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
32require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/modules/action/rapport.class.php';
34
35// Load translation files required by the page
36$langs->loadLangs(array("agenda", "commercial"));
37
38$action = GETPOST('action', 'aZ09');
39$month = GETPOST('month', 'int');
40$year = GETPOST('year', 'int');
41
42$optioncss = GETPOST('optioncss', 'alpha');
43$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
44$sortfield = GETPOST('sortfield', 'aZ09comma');
45$sortorder = GETPOST('sortorder', 'aZ09comma');
46$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
47if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
48 // If $page is not defined, or '' or -1 or if we click on clear filters
49 $page = 0;
50}
51$offset = $limit * $page;
52if (!$sortorder) {
53 $sortorder = "DESC";
54}
55if (!$sortfield) {
56 $sortfield = "a.datep";
57}
58
59// Security check
60//$result = restrictedArea($user, 'agenda', 0, '', 'myactions');
61if (!$user->hasRight("agenda", "allactions", "read")) {
62 accessForbidden();
63}
64
65
66/*
67 * Actions
68 */
69
70if ($action == 'builddoc') {
71 $cat = new CommActionRapport($db, $month, $year);
72 $result = $cat->write_file(GETPOST('id', 'int'));
73 if ($result < 0) {
74 setEventMessages($cat->error, $cat->errors, 'errors');
75 }
76}
77
78
79/*
80 * View
81 */
82
83$formfile = new FormFile($db);
84
85llxHeader();
86
87$sql = "SELECT count(*) as cc,";
88$sql .= " date_format(a.datep, '%m/%Y') as df,";
89$sql .= " date_format(a.datep, '%m') as month,";
90$sql .= " date_format(a.datep, '%Y') as year";
91$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a,";
92$sql .= " ".MAIN_DB_PREFIX."user as u";
93$sql .= " WHERE a.fk_user_author = u.rowid";
94$sql .= ' AND a.entity IN ('.getEntity('agenda').')';
95//$sql.= " AND percent = 100";
96$sql .= " GROUP BY year, month, df";
97$sql .= " ORDER BY year DESC, month DESC, df DESC";
98
99$nbtotalofrecords = '';
100if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
101 $result = $db->query($sql);
102 $nbtotalofrecords = $db->num_rows($result);
103 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
104 $page = 0;
105 $offset = 0;
106 }
107}
108
109$sql .= $db->plimit($limit + 1, $offset);
110
111//print $sql;
112dol_syslog("select", LOG_DEBUG);
113$resql = $db->query($sql);
114if ($resql) {
115 $num = $db->num_rows($resql);
116
117 $param = '';
118 if ($limit > 0 && $limit != $conf->liste_limit) {
119 $param .= '&limit='.$limit;
120 }
121
122 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
123 if ($optioncss != '') {
124 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
125 }
126 print '<input type="hidden" name="token" value="'.newToken().'">';
127 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
128 print '<input type="hidden" name="action" value="list">';
129 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
130 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
131
132 print_barre_liste($langs->trans("EventReports"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit, 0, 0, 1);
133
134 $moreforfilter = '';
135
136 $i = 0;
137 print '<div class="div-table-responsive">';
138 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
139
140 print '<tr class="liste_titre">';
141 print '<td>'.$langs->trans("Period").'</td>';
142 print '<td class="center">'.$langs->trans("EventsNb").'</td>';
143 print '<td class="center">'.$langs->trans("Action").'</td>';
144 print '<td>'.$langs->trans("PDF").'</td>';
145 print '<td class="center">'.$langs->trans("Date").'</td>';
146 print '<td class="center">'.$langs->trans("Size").'</td>';
147 print "</tr>\n";
148
149 while ($i < min($num, $limit)) {
150 $obj = $db->fetch_object($resql);
151
152 if ($obj) {
153 print '<tr class="oddeven">';
154
155 // Date
156 print "<td>".$obj->df."</td>\n";
157
158 // Nb of events
159 print '<td class="center">'.$obj->cc.'</td>';
160
161 // Button to build doc
162 print '<td class="center">';
163 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=builddoc&token='.newToken().'&page='.((int) $page).'&month='.((int) $obj->month).'&year='.((int) $obj->year).'">'.img_picto($langs->trans('BuildDoc'), 'filenew').'</a>';
164 print '</td>';
165
166 $name = "actions-".$obj->month."-".$obj->year.".pdf";
167 $relativepath = $name;
168 $file = $conf->agenda->dir_temp."/".$name;
169 $modulepart = 'actionsreport';
170 $documenturl = DOL_URL_ROOT.'/document.php';
171 if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) {
172 $documenturl = $conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper
173 }
174
175 if (file_exists($file)) {
176 print '<td class="tdoverflowmax300">';
177 //print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?page='.$page.'&amp;file='.urlencode($relativepath).'&amp;modulepart=actionsreport">'.img_pdf().'</a>';
178
179 $filearray = array('name'=>basename($file), 'fullname'=>$file, 'type'=>'file');
180 $out = '';
181
182 // Show file name with link to download
183 $out .= '<a href="'.$documenturl.'?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).($param ? '&'.$param : '').'"';
184 $mime = dol_mimetype($relativepath, '', 0);
185 $out .= ' target="_blank" rel="noopener noreferrer">';
186 $out .= img_mime($filearray["name"], $langs->trans("File").': '.$filearray["name"]);
187 $out .= $filearray["name"];
188 $out .= '</a>'."\n";
189 $out .= $formfile->showPreview($filearray, $modulepart, $relativepath, 0, $param);
190 print $out;
191
192 print '</td>';
193 print '<td class="center">'.dol_print_date(dol_filemtime($file), 'dayhour').'</td>';
194 print '<td class="center">'.dol_print_size(dol_filesize($file)).'</td>';
195 } else {
196 print '<td>&nbsp;</td>';
197 print '<td>&nbsp;</td>';
198 print '<td>&nbsp;</td>';
199 }
200
201 print "</tr>\n";
202 }
203 $i++;
204 }
205 print "</table>";
206 print '</div>';
207 print '</form>';
208
209 $db->free($resql);
210} else {
211 dol_print_error($db);
212}
213
214// End of page
215llxFooter();
216$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to generate event report.
Class to offer components to list and upload files.
dol_filemtime($pathoffile)
Return time of a file.
dol_filesize($pathoffile)
Return size of a file.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.