dolibarr  13.0.2
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 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', 'aZ09');
38 $month = GETPOST('month', 'int');
39 $year = GETPOST('year', 'int');
40 
41 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
42 $sortfield = GETPOST("sortfield", 'alpha');
43 $sortorder = GETPOST("sortorder", 'alpha');
44 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : 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->socid) $socid = $user->socid;
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="'.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 
123  print_barre_liste($langs->trans("EventReports"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit, 0, 0, 1);
124 
125  $moreforfilter = '';
126 
127  $i = 0;
128  print '<div class="div-table-responsive">';
129  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
130 
131  print '<tr class="liste_titre">';
132  print '<td>'.$langs->trans("Period").'</td>';
133  print '<td class="center">'.$langs->trans("EventsNb").'</td>';
134  print '<td class="center">'.$langs->trans("Action").'</td>';
135  print '<td>'.$langs->trans("PDF").'</td>';
136  print '<td class="center">'.$langs->trans("Date").'</td>';
137  print '<td class="center">'.$langs->trans("Size").'</td>';
138  print "</tr>\n";
139 
140  while ($i < min($num, $limit))
141  {
142  $obj = $db->fetch_object($resql);
143 
144  if ($obj)
145  {
146  print '<tr class="oddeven">';
147 
148  // Date
149  print "<td>".$obj->df."</td>\n";
150 
151  // Nb of events
152  print '<td class="center">'.$obj->cc.'</td>';
153 
154  // Button to build doc
155  print '<td class="center">';
156  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=builddoc&amp;page='.$page.'&amp;month='.$obj->month.'&amp;year='.$obj->year.'">'.img_picto($langs->trans('BuildDoc'), 'filenew').'</a>';
157  print '</td>';
158 
159  $name = "actions-".$obj->month."-".$obj->year.".pdf";
160  $relativepath = $name;
161  $file = $conf->agenda->dir_temp."/".$name;
162  $modulepart = 'actionsreport';
163  $documenturl = DOL_URL_ROOT.'/document.php';
164  if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl = $conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper
165 
166  if (file_exists($file))
167  {
168  print '<td class="tdoverflowmax300">';
169  //print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?page='.$page.'&amp;file='.urlencode($relativepath).'&amp;modulepart=actionsreport">'.img_pdf().'</a>';
170 
171  $filearray = array('name'=>basename($file), 'fullname'=>$file, 'type'=>'file');
172  $out = '';
173 
174  // Show file name with link to download
175  $out .= '<a href="'.$documenturl.'?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).($param ? '&'.$param : '').'"';
176  $mime = dol_mimetype($relativepath, '', 0);
177  if (preg_match('/text/', $mime)) $out .= ' target="_blank"';
178  $out .= ' target="_blank">';
179  $out .= img_mime($filearray["name"], $langs->trans("File").': '.$filearray["name"]);
180  $out .= $filearray["name"];
181  $out .= '</a>'."\n";
182  $out .= $formfile->showPreview($filearray, $modulepart, $relativepath, 0, $param);
183  print $out;
184 
185  print '</td>';
186  print '<td class="center">'.dol_print_date(dol_filemtime($file), 'dayhour').'</td>';
187  print '<td class="center">'.dol_print_size(dol_filesize($file)).'</td>';
188  } else {
189  print '<td>&nbsp;</td>';
190  print '<td>&nbsp;</td>';
191  print '<td>&nbsp;</td>';
192  }
193 
194  print "</tr>\n";
195  }
196  $i++;
197  }
198  print "</table>";
199  print '</div>';
200  print '</form>';
201 
202  $db->free($resql);
203 } else {
204  dol_print_error($db);
205 }
206 
207 // End of page
208 llxFooter();
209 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_filesize($pathoffile)
Return size of a file.
Definition: files.lib.php:555
img_mime($file, $titlealt= '', $morecss= '')
Show MIME img of a file.
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
dol_mimetype($file, $default= 'application/octet-stream', $mode=0)
Return mime type of a file.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
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 offer components to list and upload files.
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
Definition: index.php:89
dol_filemtime($pathoffile)
Return time of a file.
Definition: files.lib.php:567
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->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)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Class to generate event report.
Definition: rapport.pdf.php:36
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.