2004-10-19 22:19:58 +02:00
|
|
|
<?php
|
2004-03-01 11:51:02 +01:00
|
|
|
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2008-03-01 15:30:06 +01:00
|
|
|
* Copyright (C) 2003 Eric Seigne <erics@rycks.com>
|
2016-02-11 20:24:15 +01:00
|
|
|
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
2012-12-30 15:13:49 +01:00
|
|
|
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
2004-03-01 11:51:02 +01:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2013-01-16 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2004-03-01 11:51:02 +01:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2011-08-03 02:45:22 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2004-03-01 11:51:02 +01:00
|
|
|
*/
|
2004-11-03 21:28:20 +01:00
|
|
|
|
2005-08-19 19:26:57 +02:00
|
|
|
/**
|
2009-07-08 15:35:00 +02:00
|
|
|
* \file htdocs/comm/action/rapport/index.php
|
|
|
|
|
* \ingroup commercial
|
2012-07-13 11:40:06 +02:00
|
|
|
* \brief Page with reports of actions
|
2009-07-08 15:35:00 +02:00
|
|
|
*/
|
2004-11-03 21:28:20 +01:00
|
|
|
|
2012-08-22 23:24:21 +02:00
|
|
|
require '../../../main.inc.php';
|
2012-08-22 23:11:24 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
2017-06-10 13:44:20 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
2012-08-22 23:11:24 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/modules/action/rapport.pdf.php';
|
2004-03-01 11:51:02 +01:00
|
|
|
|
2018-05-26 23:52:52 +02:00
|
|
|
// Load translation files required by the page
|
2018-05-12 10:46:17 +02:00
|
|
|
$langs->loadLangs(array("agenda", "commercial"));
|
2012-07-13 11:40:06 +02:00
|
|
|
|
|
|
|
|
$action=GETPOST('action','alpha');
|
|
|
|
|
$month=GETPOST('month');
|
|
|
|
|
$year=GETPOST('year');
|
|
|
|
|
|
2018-04-21 12:16:12 +02:00
|
|
|
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
|
2010-11-20 14:08:44 +01:00
|
|
|
$sortfield = GETPOST("sortfield",'alpha');
|
|
|
|
|
$sortorder = GETPOST("sortorder",'alpha');
|
|
|
|
|
$page = GETPOST("page",'int');
|
2017-06-24 16:45:45 +02:00
|
|
|
if ($page == -1 || $page == null) { $page = 0 ; }
|
2006-02-25 01:38:31 +01:00
|
|
|
$offset = $limit * $page ;
|
|
|
|
|
if (! $sortorder) $sortorder="DESC";
|
2008-05-07 03:10:27 +02:00
|
|
|
if (! $sortfield) $sortfield="a.datep";
|
2006-02-25 01:38:31 +01:00
|
|
|
|
2008-05-27 02:31:56 +02:00
|
|
|
// Security check
|
2012-02-27 22:26:22 +01:00
|
|
|
$socid = GETPOST('socid','int');
|
2008-05-27 02:31:56 +02:00
|
|
|
if ($user->societe_id) $socid=$user->societe_id;
|
|
|
|
|
$result = restrictedArea($user, 'agenda', $socid, '', 'myactions');
|
2004-03-01 11:51:02 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2005-07-10 04:05:09 +02:00
|
|
|
* Actions
|
2004-03-01 11:51:02 +01:00
|
|
|
*/
|
2014-12-06 14:41:56 +01:00
|
|
|
|
2012-07-13 11:40:06 +02:00
|
|
|
if ($action == 'builddoc')
|
2004-03-01 11:51:02 +01:00
|
|
|
{
|
2012-07-13 11:40:06 +02:00
|
|
|
$cat = new CommActionRapport($db, $month, $year);
|
2012-02-27 22:26:22 +01:00
|
|
|
$result=$cat->write_file(GETPOST('id','int'));
|
2009-05-10 08:00:28 +02:00
|
|
|
if ($result < 0)
|
|
|
|
|
{
|
2015-11-06 09:36:16 +01:00
|
|
|
setEventMessages($cat->error, $cat->errors, 'errors');
|
2009-05-10 08:00:28 +02:00
|
|
|
}
|
2004-03-01 11:51:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2010-08-19 03:39:21 +02:00
|
|
|
* View
|
2004-03-01 11:51:02 +01:00
|
|
|
*/
|
|
|
|
|
|
2017-06-10 13:44:20 +02:00
|
|
|
$formfile=new FormFile($db);
|
|
|
|
|
|
2006-05-14 04:51:11 +02:00
|
|
|
llxHeader();
|
|
|
|
|
|
2009-10-28 19:08:35 +01:00
|
|
|
$sql = "SELECT count(*) as cc,";
|
|
|
|
|
$sql.= " date_format(a.datep, '%m/%Y') as df,";
|
|
|
|
|
$sql.= " date_format(a.datep, '%m') as month,";
|
|
|
|
|
$sql.= " date_format(a.datep, '%Y') as year";
|
|
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a,";
|
|
|
|
|
$sql.= " ".MAIN_DB_PREFIX."user as u";
|
2009-05-08 18:31:11 +02:00
|
|
|
$sql.= " WHERE a.fk_user_author = u.rowid";
|
2017-05-30 18:50:54 +02:00
|
|
|
$sql.= ' AND a.entity IN ('.getEntity('agenda').')';
|
2011-05-17 12:06:45 +02:00
|
|
|
//$sql.= " AND percent = 100";
|
2009-10-28 19:08:35 +01:00
|
|
|
$sql.= " GROUP BY year, month, df";
|
|
|
|
|
$sql.= " ORDER BY year DESC, month DESC, df DESC";
|
2016-02-11 20:24:15 +01:00
|
|
|
|
2017-01-15 20:49:20 +01:00
|
|
|
$nbtotalofrecords = '';
|
2016-02-11 20:24:15 +01:00
|
|
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
|
|
|
|
{
|
|
|
|
|
$result = $db->query($sql);
|
|
|
|
|
$nbtotalofrecords = $db->num_rows($result);
|
2018-04-24 11:37:57 +02:00
|
|
|
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
|
|
|
|
{
|
|
|
|
|
$page = 0;
|
|
|
|
|
$offset = 0;
|
|
|
|
|
}
|
2016-02-11 20:24:15 +01:00
|
|
|
}
|
|
|
|
|
|
2006-05-14 04:51:11 +02:00
|
|
|
$sql.= $db->plimit($limit+1,$offset);
|
2006-03-25 14:04:35 +01:00
|
|
|
|
2009-07-08 15:35:00 +02:00
|
|
|
//print $sql;
|
2014-06-12 11:31:53 +02:00
|
|
|
dol_syslog("select", LOG_DEBUG);
|
2006-03-25 14:04:35 +01:00
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
if ($resql)
|
2004-03-01 11:51:02 +01:00
|
|
|
{
|
2006-03-25 14:04:35 +01:00
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
|
2016-02-11 20:24:15 +01:00
|
|
|
$param='';
|
|
|
|
|
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
2017-06-10 13:44:20 +02:00
|
|
|
|
2016-02-11 20:24:15 +01:00
|
|
|
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
|
|
|
|
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
|
|
|
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
|
|
|
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
|
|
|
|
print '<input type="hidden" name="action" value="list">';
|
|
|
|
|
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
|
|
|
|
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
2017-05-21 02:43:51 +02:00
|
|
|
print '<input type="hidden" name="page" value="'.$page.'">';
|
2017-06-10 13:44:20 +02:00
|
|
|
|
2017-10-04 12:58:13 +02:00
|
|
|
print_barre_liste($langs->trans("EventReports"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit);
|
2006-03-25 14:04:35 +01:00
|
|
|
|
2016-11-27 13:49:46 +01:00
|
|
|
$moreforfilter='';
|
2017-06-10 13:44:20 +02:00
|
|
|
|
2006-03-25 14:04:35 +01:00
|
|
|
$i = 0;
|
2016-11-27 13:49:46 +01:00
|
|
|
print '<div class="div-table-responsive">';
|
|
|
|
|
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
|
|
|
|
|
|
|
|
|
print '<tr class="liste_titre">';
|
2017-06-10 13:44:20 +02:00
|
|
|
print '<td>'.$langs->trans("Period").'</td>';
|
2012-12-29 02:21:00 +01:00
|
|
|
print '<td align="center">'.$langs->trans("EventsNb").'</td>';
|
2013-02-20 21:58:13 +01:00
|
|
|
print '<td align="center">'.$langs->trans("Action").'</td>';
|
2017-06-10 13:44:20 +02:00
|
|
|
print '<td>'.$langs->trans("PDF").'</td>';
|
2006-03-25 14:04:35 +01:00
|
|
|
print '<td align="center">'.$langs->trans("Date").'</td>';
|
|
|
|
|
print '<td align="center">'.$langs->trans("Size").'</td>';
|
|
|
|
|
print "</tr>\n";
|
2017-06-10 13:44:20 +02:00
|
|
|
|
2006-03-25 14:04:35 +01:00
|
|
|
while ($i < min($num,$limit))
|
2004-03-01 11:51:02 +01:00
|
|
|
{
|
2006-05-14 04:51:11 +02:00
|
|
|
$obj=$db->fetch_object($resql);
|
2009-05-04 13:40:00 +02:00
|
|
|
|
2006-05-14 04:51:11 +02:00
|
|
|
if ($obj)
|
2006-03-25 14:04:35 +01:00
|
|
|
{
|
2017-06-10 13:44:20 +02:00
|
|
|
|
2017-04-14 11:22:48 +02:00
|
|
|
print '<tr class="oddeven">';
|
2009-05-04 13:40:00 +02:00
|
|
|
|
2017-06-10 13:44:20 +02:00
|
|
|
// Date
|
2010-08-19 03:39:21 +02:00
|
|
|
print "<td>".$obj->df."</td>\n";
|
2017-06-10 13:44:20 +02:00
|
|
|
|
|
|
|
|
// Nb of events
|
2006-05-14 04:51:11 +02:00
|
|
|
print '<td align="center">'.$obj->cc.'</td>';
|
2009-05-04 13:40:00 +02:00
|
|
|
|
2017-06-10 13:44:20 +02:00
|
|
|
// Button to build doc
|
2013-02-20 21:58:13 +01:00
|
|
|
print '<td align="center">';
|
2017-06-10 13:44:20 +02:00
|
|
|
print '<a href="'.$_SERVER["PHP_SELF"].'?action=builddoc&page='.$page.'&month='.$obj->month.'&year='.$obj->year.'">'.img_picto($langs->trans('BuildDoc'),'filenew').'</a>';
|
2007-12-02 17:15:53 +01:00
|
|
|
print '</td>';
|
2009-05-04 13:40:00 +02:00
|
|
|
|
2006-08-19 17:50:48 +02:00
|
|
|
$name = "actions-".$obj->month."-".$obj->year.".pdf";
|
2006-05-14 04:51:11 +02:00
|
|
|
$relativepath= $name;
|
2009-05-04 13:40:00 +02:00
|
|
|
$file = $conf->agenda->dir_temp."/".$name;
|
2017-06-10 13:44:20 +02:00
|
|
|
$modulepart = 'actionsreport';
|
|
|
|
|
$documenturl= DOL_URL_ROOT.'/document.php';
|
|
|
|
|
if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP; // To use another wrapper
|
2009-05-04 13:40:00 +02:00
|
|
|
|
2006-05-14 04:51:11 +02:00
|
|
|
if (file_exists($file))
|
|
|
|
|
{
|
2017-06-10 13:44:20 +02:00
|
|
|
print '<td class="tdoverflowmax300">';
|
|
|
|
|
//print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?page='.$page.'&file='.urlencode($relativepath).'&modulepart=actionsreport">'.img_pdf().'</a>';
|
|
|
|
|
|
|
|
|
|
$filearray=array('name'=>basename($file),'fullname'=>$file,'type'=>'file');
|
|
|
|
|
$out='';
|
|
|
|
|
|
|
|
|
|
// Show file name with link to download
|
|
|
|
|
$out.= '<a href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param?'&'.$param:'').'"';
|
|
|
|
|
$mime=dol_mimetype($relativepath,'',0);
|
|
|
|
|
if (preg_match('/text/',$mime)) $out.= ' target="_blank"';
|
|
|
|
|
$out.= ' target="_blank">';
|
2017-11-11 01:10:17 +01:00
|
|
|
$out.= img_mime($filearray["name"],$langs->trans("File").': '.$filearray["name"]);
|
|
|
|
|
$out.= $filearray["name"];
|
2017-06-10 13:44:20 +02:00
|
|
|
$out.= '</a>'."\n";
|
2017-11-11 01:10:17 +01:00
|
|
|
$out.= $formfile->showPreview($filearray,$modulepart,$relativepath,0,$param);
|
|
|
|
|
print $out;
|
2017-06-10 13:44:20 +02:00
|
|
|
|
|
|
|
|
print '</td>';
|
2009-10-04 20:01:30 +02:00
|
|
|
print '<td align="center">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>';
|
|
|
|
|
print '<td align="center">'.dol_print_size(dol_filesize($file)).'</td>';
|
2006-05-14 04:51:11 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
print '<td> </td>';
|
|
|
|
|
print '<td> </td>';
|
|
|
|
|
print '<td> </td>';
|
|
|
|
|
}
|
2009-05-04 13:40:00 +02:00
|
|
|
|
2006-05-14 04:51:11 +02:00
|
|
|
print "</tr>\n";
|
2006-03-25 14:04:35 +01:00
|
|
|
}
|
|
|
|
|
$i++;
|
2004-03-01 11:51:02 +01:00
|
|
|
}
|
2006-03-25 14:04:35 +01:00
|
|
|
print "</table>";
|
2016-11-27 13:49:46 +01:00
|
|
|
print '</div>';
|
2016-02-11 20:24:15 +01:00
|
|
|
print '</form>';
|
2017-06-10 13:44:20 +02:00
|
|
|
|
2010-08-19 03:39:21 +02:00
|
|
|
$db->free($resql);
|
2004-03-01 11:51:02 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-02-20 23:53:15 +01:00
|
|
|
dol_print_error($db);
|
2004-03-01 11:51:02 +01:00
|
|
|
}
|
|
|
|
|
|
2011-08-27 16:24:16 +02:00
|
|
|
llxFooter();
|
2015-12-11 14:19:38 +01:00
|
|
|
$db->close();
|