dolibarr/htdocs/comm/action/rapport/index.php

162 lines
4.6 KiB
PHP
Raw Normal View History

<?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>
* Copyright (C) 2004-2009 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
* 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
*/
/**
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
*/
require '../../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
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
$langs->load("agenda");
$langs->load("commercial");
2012-07-13 11:40:06 +02:00
$action=GETPOST('action','alpha');
$month=GETPOST('month');
$year=GETPOST('year');
$mesg='';
$mesgs=array();
2010-11-20 14:08:44 +01:00
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0 ; }
$limit = $conf->liste_limit;
$offset = $limit * $page ;
if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="a.datep";
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
/*
* Actions
2004-03-01 11:51:02 +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)
{
$mesg=$cat->error;
}
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
*/
llxHeader();
$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";
$sql.= " WHERE a.fk_user_author = u.rowid";
$sql.= " AND a.entity = ".$conf->entity;
//$sql.= " AND percent = 100";
$sql.= " GROUP BY year, month, df";
$sql.= " ORDER BY year DESC, month DESC, df DESC";
$sql.= $db->plimit($limit+1,$offset);
2006-03-25 14:04:35 +01:00
2009-07-08 15:35:00 +02:00
//print $sql;
2010-08-19 03:39:21 +02:00
dol_syslog("select sql=".$sql);
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);
print_barre_liste($langs->trans("Actions"), $page, "index.php",'',$sortfield,$sortorder,'',$num);
2006-03-25 14:04:35 +01:00
2012-07-13 11:40:06 +02:00
dol_htmloutput_mesg($mesg,$mesgs);
2010-08-19 03:39:21 +02:00
2006-03-25 14:04:35 +01:00
$i = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Date").'</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>';
2006-03-25 14:04:35 +01:00
print '<td align="center">'.$langs->trans("PDF").'</td>';
print '<td align="center">'.$langs->trans("Date").'</td>';
print '<td align="center">'.$langs->trans("Size").'</td>';
print "</tr>\n";
$var=true;
while ($i < min($num,$limit))
2004-03-01 11:51:02 +01:00
{
$obj=$db->fetch_object($resql);
if ($obj)
2006-03-25 14:04:35 +01:00
{
$var=!$var;
2010-08-19 03:39:21 +02:00
print "<tr ".$bc[$var].">";
2010-08-19 03:39:21 +02:00
print "<td>".$obj->df."</td>\n";
print '<td align="center">'.$obj->cc.'</td>';
2013-02-20 21:58:13 +01:00
print '<td align="center">';
2012-12-29 02:21:00 +01:00
print '<a href="'.$_SERVER["PHP_SELF"].'?action=builddoc&amp;page='.$page.'&amp;month='.$obj->month.'&amp;year='.$obj->year.'">'.img_picto($langs->trans('GenerateReport'),'filenew').'</a>';
print '</td>';
$name = "actions-".$obj->month."-".$obj->year.".pdf";
$relativepath= $name;
$file = $conf->agenda->dir_temp."/".$name;
if (file_exists($file))
{
2013-04-20 20:30:18 +02:00
print '<td align="center"><a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?page='.$page.'&amp;file='.urlencode($relativepath).'&amp;modulepart=actionsreport">'.img_pdf().'</a></td>';
print '<td align="center">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>';
print '<td align="center">'.dol_print_size(dol_filesize($file)).'</td>';
}
else {
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
}
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>";
2010-08-19 03:39:21 +02:00
$db->free($resql);
2004-03-01 11:51:02 +01:00
}
else
{
dol_print_error($db);
2004-03-01 11:51:02 +01:00
}
$db->close();
llxFooter();
2004-03-01 11:51:02 +01:00
?>