dolibarr 24.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@inodbox.com>
6 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../../../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
39require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
40require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
41
42
43// Load translation files required by the page
44$langs->loadLangs(array("agenda", "commercial"));
45
46$action = GETPOST('action', 'aZ09');
47$month = GETPOSTINT('month');
48$year = GETPOSTINT('year');
49
50$optioncss = GETPOST('optioncss', 'alpha');
51$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
52$sortfield = GETPOST('sortfield', 'aZ09comma');
53$sortorder = GETPOST('sortorder', 'aZ09comma');
54$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
55if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
56 // If $page is not defined, or '' or -1 or if we click on clear filters
57 $page = 0;
58}
59$offset = $limit * $page;
60if (!$sortorder) {
61 $sortorder = "DESC";
62}
63if (!$sortfield) {
64 $sortfield = "a.datep";
65}
66
67// Security check
68//restrictedArea($user, 'agenda', 0, '', 'myactions');
69if (!$user->hasRight("agenda", "allactions", "read")) {
71}
72
73
74/*
75 * Actions
76 */
77
78if ($action == 'builddoc' && $user->hasRight("agenda", "allactions", "read")) {
79 require_once DOL_DOCUMENT_ROOT.'/core/modules/action/doc/pdf_standard_actions.class.php';
80
81 $cat = new pdf_standard_actions($db, $month, $year);
82 $result = $cat->write_file(null, $langs);
83 if ($result < 0) {
84 setEventMessages($cat->error, $cat->errors, 'errors');
85 }
86}
87
88
89/*
90 * View
91 */
92
93$formfile = new FormFile($db);
94
95llxHeader();
96
97$sql = "SELECT count(*) as cc,";
98$sql .= " date_format(a.datep, '%Y-%m') as yearmonth";
99$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
100//$sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON a.fk_user_author = u.rowid";
101$sql .= " WHERE a.entity IN (".getEntity('agenda').")";
102//$sql.= " AND percent = 100";
103$sql .= " GROUP BY yearmonth";
104$sql .= " ORDER BY yearmonth DESC";
105
106$nbtotalofrecords = '';
107if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
108 $result = $db->query($sql);
109 $nbtotalofrecords = $db->num_rows($result);
110 if (($page * $limit) > (int) $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
111 $page = 0;
112 $offset = 0;
113 }
114}
115
116$sql .= $db->plimit($limit + 1, $offset);
117
118//print $sql;
119dol_syslog("select", LOG_DEBUG);
120$resql = $db->query($sql);
121if ($resql) {
122 $num = $db->num_rows($resql);
123
124 $param = '';
125 if ($limit > 0 && $limit != $conf->liste_limit) {
126 $param .= '&limit='.$limit;
127 }
128
129 print '<form method="POST" id="searchFormList" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
130 if ($optioncss != '') {
131 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
132 }
133 print '<input type="hidden" name="token" value="'.newToken().'">';
134 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
135 print '<input type="hidden" name="action" value="list">';
136 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
137 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
138
139 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
140 print_barre_liste($langs->trans("EventReports"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit, 0, 0, 1);
141
142 $moreforfilter = '';
143
144 $i = 0;
145 print '<div class="div-table-responsive">';
146 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
147
148 print '<tr class="liste_titre">';
149 print '<td>'.$langs->trans("Period").'</td>';
150 print '<td class="center">'.$langs->trans("EventsNb").'</td>';
151 print '<td></td>';
152 print '<td></td>';
153 print '<td class="center">'.$langs->trans("Date").'</td>';
154 print '<td class="center">'.$langs->trans("Size").'</td>';
155 print "</tr>\n";
156
157 while ($i < min($num, $limit)) {
158 $obj = $db->fetch_object($resql);
159
160 if ($obj) {
161 $reg = array();
162 preg_match('/(\d+)\-(\d+)/', $obj->yearmonth, $reg);
163 $year = (int) $reg[1];
164 $month = (int) $reg[2];
165
166 print '<tr class="oddeven">';
167
168 // Date
169 print "<td>".sprintf("%04d", $year)."-".sprintf("%02d", $month)."</td>\n";
170
171 // Nb of events
172 print '<td class="center">'.($obj->cc ? (int) $obj->cc : '').'</td>';
173
174 // Button to build doc
175 print '<td class="right">';
176 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=builddoc&token='.newToken().'&page='.((int) $page).'&month='.$month.'&year='.$year.'">';
177 print img_picto($langs->trans('BuildDoc'), 'filenew.png');
178 print '</a>';
179 print '</td>';
180
181 $name = "actions-".sprintf("%04d", $year)."-".sprintf("%02d", $month).".pdf";
182 $relativepath = $name;
183 $file = $conf->agenda->dir_temp."/".$name;
184 $modulepart = 'actionsreport';
185 $documenturl = DOL_URL_ROOT.'/document.php';
186 if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) {
187 $documenturl = getDolGlobalString('DOL_URL_ROOT_DOCUMENT_PHP'); // To use another wrapper
188 }
189
190 if (file_exists($file)) {
191 print '<td class="tdoverflowmax300">';
192
193 $filearray = array('name' => basename($file), 'fullname' => $file, 'type' => 'file');
194 $out = '';
195
196 // Show file name with link to download
197 $out .= '<a href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param ? '&'.$param : '').'"';
198 $mime = dol_mimetype($relativepath, '', 0);
199 $out .= ' target="_blank" rel="noopener noreferrer">';
200 $out .= img_mime($filearray["name"], $langs->trans("File").': '.$filearray["name"]);
201 $out .= $filearray["name"];
202 $out .= '</a>'."\n";
203 $out .= $formfile->showPreview($filearray, $modulepart, $relativepath, 0, $param);
204 print $out;
205
206 print '</td>';
207 print '<td class="center">'.dol_print_date(dol_filemtime($file), 'dayhour').'</td>';
208 print '<td class="center">'.dol_print_size(dol_filesize($file)).'</td>';
209 } else {
210 print '<td>&nbsp;</td>';
211 print '<td>&nbsp;</td>';
212 print '<td>&nbsp;</td>';
213 }
214
215 print "</tr>\n";
216 }
217 $i++;
218 }
219 print "</table>";
220 print '</div>';
221 print '</form>';
222
223 $db->free($resql);
224} else {
226}
227
228// End of page
229llxFooter();
230$db->close();
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to offer components to list and upload files.
Class to generate event report.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_filemtime($pathoffile)
Return time of a file.
dol_filesize($pathoffile)
Return size of a file.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.