dolibarr 18.0.6
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$socid = GETPOST('socid', 'int');
61if ($user->socid) {
62 $socid = $user->socid;
63}
64$result = restrictedArea($user, 'agenda', 0, '', 'myactions');
65if ($user->socid && $socid) {
66 $result = restrictedArea($user, 'societe', $socid);
67}
68
69
70/*
71 * Actions
72 */
73
74if ($action == 'builddoc') {
75 $cat = new CommActionRapport($db, $month, $year);
76 $result = $cat->write_file(GETPOST('id', 'int'));
77 if ($result < 0) {
78 setEventMessages($cat->error, $cat->errors, 'errors');
79 }
80}
81
82
83/*
84 * View
85 */
86
87$formfile = new FormFile($db);
88
89llxHeader();
90
91$sql = "SELECT count(*) as cc,";
92$sql .= " date_format(a.datep, '%m/%Y') as df,";
93$sql .= " date_format(a.datep, '%m') as month,";
94$sql .= " date_format(a.datep, '%Y') as year";
95$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a,";
96$sql .= " ".MAIN_DB_PREFIX."user as u";
97$sql .= " WHERE a.fk_user_author = u.rowid";
98$sql .= ' AND a.entity IN ('.getEntity('agenda').')';
99//$sql.= " AND percent = 100";
100$sql .= " GROUP BY year, month, df";
101$sql .= " ORDER BY year DESC, month DESC, df DESC";
102
103$nbtotalofrecords = '';
104if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
105 $result = $db->query($sql);
106 $nbtotalofrecords = $db->num_rows($result);
107 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
108 $page = 0;
109 $offset = 0;
110 }
111}
112
113$sql .= $db->plimit($limit + 1, $offset);
114
115//print $sql;
116dol_syslog("select", LOG_DEBUG);
117$resql = $db->query($sql);
118if ($resql) {
119 $num = $db->num_rows($resql);
120
121 $param = '';
122 if ($limit > 0 && $limit != $conf->liste_limit) {
123 $param .= '&limit='.$limit;
124 }
125
126 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
127 if ($optioncss != '') {
128 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
129 }
130 print '<input type="hidden" name="token" value="'.newToken().'">';
131 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
132 print '<input type="hidden" name="action" value="list">';
133 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
134 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
135
136 print_barre_liste($langs->trans("EventReports"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit, 0, 0, 1);
137
138 $moreforfilter = '';
139
140 $i = 0;
141 print '<div class="div-table-responsive">';
142 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
143
144 print '<tr class="liste_titre">';
145 print '<td>'.$langs->trans("Period").'</td>';
146 print '<td class="center">'.$langs->trans("EventsNb").'</td>';
147 print '<td class="center">'.$langs->trans("Action").'</td>';
148 print '<td>'.$langs->trans("PDF").'</td>';
149 print '<td class="center">'.$langs->trans("Date").'</td>';
150 print '<td class="center">'.$langs->trans("Size").'</td>';
151 print "</tr>\n";
152
153 while ($i < min($num, $limit)) {
154 $obj = $db->fetch_object($resql);
155
156 if ($obj) {
157 print '<tr class="oddeven">';
158
159 // Date
160 print "<td>".$obj->df."</td>\n";
161
162 // Nb of events
163 print '<td class="center">'.$obj->cc.'</td>';
164
165 // Button to build doc
166 print '<td class="center">';
167 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>';
168 print '</td>';
169
170 $name = "actions-".$obj->month."-".$obj->year.".pdf";
171 $relativepath = $name;
172 $file = $conf->agenda->dir_temp."/".$name;
173 $modulepart = 'actionsreport';
174 $documenturl = DOL_URL_ROOT.'/document.php';
175 if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) {
176 $documenturl = $conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper
177 }
178
179 if (file_exists($file)) {
180 print '<td class="tdoverflowmax300">';
181 //print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?page='.$page.'&amp;file='.urlencode($relativepath).'&amp;modulepart=actionsreport">'.img_pdf().'</a>';
182
183 $filearray = array('name'=>basename($file), 'fullname'=>$file, 'type'=>'file');
184 $out = '';
185
186 // Show file name with link to download
187 $out .= '<a href="'.$documenturl.'?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).($param ? '&'.$param : '').'"';
188 $mime = dol_mimetype($relativepath, '', 0);
189 $out .= ' target="_blank" rel="noopener noreferrer">';
190 $out .= img_mime($filearray["name"], $langs->trans("File").': '.$filearray["name"]);
191 $out .= $filearray["name"];
192 $out .= '</a>'."\n";
193 $out .= $formfile->showPreview($filearray, $modulepart, $relativepath, 0, $param);
194 print $out;
195
196 print '</td>';
197 print '<td class="center">'.dol_print_date(dol_filemtime($file), 'dayhour').'</td>';
198 print '<td class="center">'.dol_print_size(dol_filesize($file)).'</td>';
199 } else {
200 print '<td>&nbsp;</td>';
201 print '<td>&nbsp;</td>';
202 print '<td>&nbsp;</td>';
203 }
204
205 print "</tr>\n";
206 }
207 $i++;
208 }
209 print "</table>";
210 print '</div>';
211 print '</form>';
212
213 $db->free($resql);
214} else {
215 dol_print_error($db);
216}
217
218// End of page
219llxFooter();
220$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:56
llxFooter()
Empty footer.
Definition wrapper.php:70
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 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.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.