2012-08-22 23:27:53 +02:00
|
|
|
<?php
|
2009-04-27 22:37:50 +02:00
|
|
|
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2012-08-05 14:37:45 +02:00
|
|
|
* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
2012-12-30 15:13:49 +01:00
|
|
|
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
|
2011-01-05 10:57:55 +01:00
|
|
|
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
|
2005-01-19 15:49:54 +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
|
2005-01-19 15:49:54 +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-01 00:21:57 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2005-01-19 15:49:54 +01:00
|
|
|
*/
|
2005-08-13 18:44:52 +02:00
|
|
|
|
|
|
|
|
/**
|
2012-08-05 14:37:45 +02:00
|
|
|
* \file htdocs/compta/prelevement/stats.php
|
|
|
|
|
* \ingroup prelevement
|
2014-12-09 11:19:16 +01:00
|
|
|
* \brief Page with statistics on withdrawals
|
2010-08-09 18:07:24 +02:00
|
|
|
*/
|
2005-08-13 18:44:52 +02:00
|
|
|
|
2013-05-07 15:34:40 +02:00
|
|
|
require('../../main.inc.php');
|
2012-08-22 23:11:24 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
|
2013-06-05 16:24:32 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
|
|
|
|
|
2018-05-27 09:27:09 +02:00
|
|
|
// Load translation files required by the page
|
|
|
|
|
$langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies'));
|
2005-08-13 18:44:52 +02:00
|
|
|
|
2009-04-27 22:37:50 +02:00
|
|
|
// Security check
|
2012-02-27 22:26:22 +01:00
|
|
|
$socid = GETPOST('socid','int');
|
2009-04-27 22:37:50 +02:00
|
|
|
if ($user->societe_id) $socid=$user->societe_id;
|
|
|
|
|
$result = restrictedArea($user, 'prelevement','','','bons');
|
2005-01-19 15:49:54 +01:00
|
|
|
|
2005-08-13 18:44:52 +02:00
|
|
|
|
2005-03-02 11:07:20 +01:00
|
|
|
/*
|
2009-08-17 19:46:59 +02:00
|
|
|
* View
|
2005-03-02 11:07:20 +01:00
|
|
|
*/
|
|
|
|
|
|
2009-08-17 19:46:59 +02:00
|
|
|
llxHeader('',$langs->trans("WithdrawStatistics"));
|
|
|
|
|
|
2015-09-24 18:33:48 +02:00
|
|
|
print load_fiche_titre($langs->trans("Statistics"));
|
2005-01-19 15:49:54 +01:00
|
|
|
|
2010-09-05 03:20:53 +02:00
|
|
|
// Define total and nbtotal
|
2005-03-03 15:03:50 +01:00
|
|
|
$sql = "SELECT sum(pl.amount), count(pl.amount)";
|
2009-04-27 22:37:50 +02:00
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
|
2012-02-01 11:32:55 +01:00
|
|
|
$sql.= ", ".MAIN_DB_PREFIX."prelevement_bons as pb";
|
|
|
|
|
$sql.= " WHERE pl.fk_prelevement_bons = pb.rowid";
|
|
|
|
|
$sql.= " AND pb.entity = ".$conf->entity;
|
2010-08-09 18:07:24 +02:00
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
if ($resql)
|
2005-01-19 15:49:54 +01:00
|
|
|
{
|
2010-09-05 03:20:53 +02:00
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
|
|
|
|
if ( $num > 0 )
|
|
|
|
|
{
|
|
|
|
|
$row = $db->fetch_row($resql);
|
|
|
|
|
$total = $row[0];
|
|
|
|
|
$nbtotal = $row[1];
|
|
|
|
|
}
|
2005-01-19 15:49:54 +01:00
|
|
|
}
|
|
|
|
|
|
2010-09-05 03:20:53 +02:00
|
|
|
|
2005-01-19 15:49:54 +01:00
|
|
|
/*
|
|
|
|
|
* Stats
|
|
|
|
|
*/
|
2011-06-12 20:05:30 +02:00
|
|
|
|
|
|
|
|
print '<br>';
|
2016-01-01 23:44:23 +01:00
|
|
|
print load_fiche_titre($langs->trans("WithdrawStatistics"), '', '');
|
2011-06-12 20:05:30 +02:00
|
|
|
|
2011-01-05 10:57:55 +01:00
|
|
|
$ligne=new LignePrelevement($db,$user);
|
|
|
|
|
|
2005-03-03 15:03:50 +01:00
|
|
|
$sql = "SELECT sum(pl.amount), count(pl.amount), pl.statut";
|
2009-04-27 22:37:50 +02:00
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
|
2012-02-01 11:32:55 +01:00
|
|
|
$sql.= ", ".MAIN_DB_PREFIX."prelevement_bons as pb";
|
|
|
|
|
$sql.= " WHERE pl.fk_prelevement_bons = pb.rowid";
|
|
|
|
|
$sql.= " AND pb.entity = ".$conf->entity;
|
2009-04-27 22:37:50 +02:00
|
|
|
$sql.= " GROUP BY pl.statut";
|
2005-01-19 15:49:54 +01:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
if ($resql)
|
2005-01-19 15:49:54 +01:00
|
|
|
{
|
2010-08-09 18:07:24 +02:00
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
$i = 0;
|
2009-08-17 19:46:59 +02:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
print"\n<!-- debut table -->\n";
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
print '<td width="30%">'.$langs->trans("Status").'</td><td align="center">'.$langs->trans("Number").'</td><td align="right">%</td>';
|
|
|
|
|
print '<td align="right">'.$langs->trans("Amount").'</td><td align="right">%</td></tr>';
|
2009-08-17 19:46:59 +02:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
while ($i < $num)
|
|
|
|
|
{
|
|
|
|
|
$row = $db->fetch_row($resql);
|
2009-08-17 19:46:59 +02:00
|
|
|
|
2017-05-10 16:41:19 +02:00
|
|
|
print '<tr class="oddeven"><td>';
|
2005-03-03 15:03:50 +01:00
|
|
|
|
2011-01-05 10:57:55 +01:00
|
|
|
print $ligne->LibStatut($row[2],1);
|
|
|
|
|
//print $st[$row[2]];
|
2010-08-09 18:07:24 +02:00
|
|
|
print '</td><td align="center">';
|
|
|
|
|
print $row[1];
|
2005-03-03 15:03:50 +01:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
print '</td><td align="right">';
|
|
|
|
|
print round($row[1]/$nbtotal*100,2)." %";
|
2005-03-03 15:03:50 +01:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
print '</td><td align="right">';
|
2005-03-03 15:03:50 +01:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
print price($row[0]);
|
2009-08-17 19:46:59 +02:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
print '</td><td align="right">';
|
|
|
|
|
print round($row[0]/$total*100,2)." %";
|
|
|
|
|
print '</td></tr>';
|
2017-04-14 11:22:48 +02:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
$i++;
|
|
|
|
|
}
|
2005-01-19 15:49:54 +01:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
print '<tr class="liste_total"><td align="right">'.$langs->trans("Total").'</td>';
|
|
|
|
|
print '<td align="center">'.$nbtotal.'</td><td> </td><td align="right">';
|
|
|
|
|
print price($total);
|
|
|
|
|
print '</td><td align="right"> </td>';
|
|
|
|
|
print "</tr></table>";
|
|
|
|
|
$db->free();
|
2005-03-02 11:07:20 +01:00
|
|
|
}
|
2009-08-17 19:46:59 +02:00
|
|
|
else
|
2005-03-02 11:07:20 +01:00
|
|
|
{
|
2010-08-09 18:07:24 +02:00
|
|
|
dol_print_error($db);
|
2009-08-17 19:46:59 +02:00
|
|
|
}
|
2008-11-04 17:58:26 +01:00
|
|
|
|
|
|
|
|
|
2005-03-02 11:07:20 +01:00
|
|
|
/*
|
2016-01-01 23:44:23 +01:00
|
|
|
* Stats on errors
|
2005-03-02 11:07:20 +01:00
|
|
|
*/
|
2016-01-01 23:44:23 +01:00
|
|
|
|
2010-03-16 00:54:37 +01:00
|
|
|
print '<br>';
|
2016-01-01 23:44:23 +01:00
|
|
|
print load_fiche_titre($langs->trans("WithdrawRejectStatistics"), '', '');
|
2005-03-02 11:07:20 +01:00
|
|
|
|
2011-06-12 20:05:30 +02:00
|
|
|
|
2010-09-05 03:20:53 +02:00
|
|
|
// Define total and nbtotal
|
2005-03-02 11:07:20 +01:00
|
|
|
$sql = "SELECT sum(pl.amount), count(pl.amount)";
|
2009-04-27 22:37:50 +02:00
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
|
2012-02-01 11:32:55 +01:00
|
|
|
$sql.= ", ".MAIN_DB_PREFIX."prelevement_bons as pb";
|
|
|
|
|
$sql.= " WHERE pl.fk_prelevement_bons = pb.rowid";
|
|
|
|
|
$sql.= " AND pb.entity = ".$conf->entity;
|
2010-09-05 03:20:53 +02:00
|
|
|
$sql.= " AND pl.statut = 3";
|
2010-08-09 18:07:24 +02:00
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
if ($resql)
|
2005-03-02 11:07:20 +01:00
|
|
|
{
|
2010-09-05 03:20:53 +02:00
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
|
|
|
|
if ( $num > 0 )
|
|
|
|
|
{
|
|
|
|
|
$row = $db->fetch_row($resql);
|
|
|
|
|
$total = $row[0];
|
|
|
|
|
$nbtotal = $row[1];
|
|
|
|
|
}
|
2005-03-02 11:07:20 +01:00
|
|
|
}
|
2005-01-19 15:49:54 +01:00
|
|
|
|
2005-03-02 11:07:20 +01:00
|
|
|
/*
|
|
|
|
|
* Stats sur les rejets
|
|
|
|
|
*/
|
2005-03-03 14:56:28 +01:00
|
|
|
$sql = "SELECT sum(pl.amount), count(pl.amount) as cc, pr.motif";
|
2009-04-27 22:37:50 +02:00
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
|
2012-02-01 11:32:55 +01:00
|
|
|
$sql.= ", ".MAIN_DB_PREFIX."prelevement_bons as pb";
|
|
|
|
|
$sql.= ", ".MAIN_DB_PREFIX."prelevement_rejet as pr";
|
|
|
|
|
$sql.= " WHERE pl.fk_prelevement_bons = pb.rowid";
|
|
|
|
|
$sql.= " AND pb.entity = ".$conf->entity;
|
2009-04-27 22:37:50 +02:00
|
|
|
$sql.= " AND pl.statut = 3";
|
|
|
|
|
$sql.= " AND pr.fk_prelevement_lignes = pl.rowid";
|
|
|
|
|
$sql.= " GROUP BY pr.motif";
|
|
|
|
|
$sql.= " ORDER BY cc DESC";
|
2005-03-02 11:07:20 +01:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
if ($resql)
|
2005-03-02 11:07:20 +01:00
|
|
|
{
|
2010-08-09 18:07:24 +02:00
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
$i = 0;
|
2009-08-17 19:46:59 +02:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
print"\n<!-- debut table -->\n";
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
print '<td width="30%">'.$langs->trans("Status").'</td><td align="center">'.$langs->trans("Number").'</td>';
|
|
|
|
|
print '<td align="right">%</td><td align="right">'.$langs->trans("Amount").'</td><td align="right">%</td></tr>';
|
2009-08-17 19:46:59 +02:00
|
|
|
|
2012-08-22 23:11:24 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
|
2010-08-09 18:07:24 +02:00
|
|
|
$Rejet = new RejetPrelevement($db, $user);
|
2009-08-17 19:46:59 +02:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
while ($i < $num)
|
|
|
|
|
{
|
|
|
|
|
$row = $db->fetch_row($resql);
|
2009-08-17 19:46:59 +02:00
|
|
|
|
2017-05-10 16:41:19 +02:00
|
|
|
print '<tr class="oddeven"><td>';
|
2010-08-09 18:07:24 +02:00
|
|
|
print $Rejet->motifs[$row[2]];
|
2005-03-02 11:07:20 +01:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
print '</td><td align="center">'.$row[1];
|
2005-01-19 15:49:54 +01:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
print '</td><td align="right">';
|
|
|
|
|
print round($row[1]/$nbtotal*100,2)." %";
|
2005-01-19 15:49:54 +01:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
print '</td><td align="right">';
|
|
|
|
|
print price($row[0]);
|
2005-01-19 15:49:54 +01:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
print '</td><td align="right">';
|
|
|
|
|
print round($row[0]/$total*100,2)." %";
|
2005-03-02 11:07:20 +01:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
print '</td></tr>';
|
2017-04-14 11:22:48 +02:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
$i++;
|
|
|
|
|
}
|
2005-01-19 15:49:54 +01:00
|
|
|
|
2010-08-09 18:07:24 +02:00
|
|
|
print '<tr class="liste_total"><td align="right">'.$langs->trans("Total").'</td><td align="center">'.$nbtotal.'</td>';
|
|
|
|
|
print '<td> </td><td align="right">';
|
|
|
|
|
print price($total);
|
|
|
|
|
print '</td><td align="right"> </td>';
|
|
|
|
|
print "</tr></table>";
|
2010-09-05 03:20:53 +02:00
|
|
|
$db->free($resql);
|
2005-01-19 15:49:54 +01:00
|
|
|
}
|
2009-08-17 19:46:59 +02:00
|
|
|
else
|
2005-01-19 15:49:54 +01:00
|
|
|
{
|
2010-08-09 18:07:24 +02:00
|
|
|
dol_print_error($db);
|
2009-08-17 19:46:59 +02:00
|
|
|
}
|
2005-01-19 15:49:54 +01:00
|
|
|
|
2012-02-01 11:32:55 +01:00
|
|
|
llxFooter();
|
2005-01-19 15:49:54 +01:00
|
|
|
|
|
|
|
|
$db->close();
|
|
|
|
|
|