dolibarr/htdocs/compta/prelevement/fiche-stat.php

165 lines
4.5 KiB
PHP
Raw Normal View History

2012-08-22 23:27:53 +02:00
<?php
2005-01-19 15:38:59 +01:00
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
2012-02-29 18:56:54 +01:00
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
2005-01-19 15:38:59 +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
2005-01-19 15:38:59 +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/>.
2008-11-05 23:34:14 +01:00
*/
2010-04-29 10:38:58 +02:00
/**
* \file htdocs/compta/prelevement/fiche-stat.php
2012-08-05 14:37:45 +02:00
* \ingroup prelevement
* \brief Prelevement statistics
2005-01-19 15:38:59 +01:00
*/
require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
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';
$langs->load("banks");
$langs->load("categories");
$langs->load("withdrawals");
2005-01-19 15:38:59 +01:00
2010-03-27 15:40:39 +01:00
// Security check
2005-01-19 15:38:59 +01:00
if ($user->societe_id > 0) accessforbidden();
2011-05-06 15:49:34 +02:00
// Get supervariables
2012-02-27 22:26:22 +01:00
$prev_id = GETPOST('id','int');
2012-02-29 18:56:54 +01:00
$page = GETPOST('page','int');
2008-11-05 23:34:14 +01:00
/*
* View
*/
2014-05-16 15:50:38 +02:00
llxHeader('',$langs->trans("WithdrawalsReceipts"));
2005-01-19 15:38:59 +01:00
if ($prev_id)
{
2010-08-09 18:07:23 +02:00
$bon = new BonPrelevement($db,"");
2005-01-19 15:38:59 +01:00
2011-05-06 15:49:34 +02:00
if ($bon->fetch($prev_id) == 0)
2010-08-09 18:07:23 +02:00
{
2010-11-18 18:10:31 +01:00
$head = prelevement_prepare_head($bon);
2014-05-16 15:50:38 +02:00
dol_fiche_head($head, 'statistics', $langs->trans("WithdrawalsReceipts"), '', 'payment');
2010-03-27 15:40:39 +01:00
2010-08-09 18:07:23 +02:00
print '<table class="border" width="100%">';
2010-03-27 15:40:39 +01:00
2010-08-09 18:07:23 +02:00
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td>'.$bon->getNomUrl(1).'</td></tr>';
2011-01-08 09:18:29 +01:00
print '<tr><td width="20%">'.$langs->trans("Date").'</td><td>'.dol_print_date($bon->datec,'day').'</td></tr>';
2011-01-05 10:57:55 +01:00
print '<tr><td width="20%">'.$langs->trans("Amount").'</td><td>'.price($bon->amount).'</td></tr>';
2011-01-05 10:57:55 +01:00
// Status
print '<tr><td width="20%">'.$langs->trans('Status').'</td>';
print '<td>'.$bon->getLibStatut(1).'</td>';
print '</tr>';
2011-01-05 10:57:55 +01:00
if($bon->date_trans <> 0)
{
$muser = new User($db);
$muser->fetch($bon->user_trans);
2011-01-05 10:57:55 +01:00
print '<tr><td width="20%">'.$langs->trans("TransData").'</td><td>';
2011-01-08 09:18:29 +01:00
print dol_print_date($bon->date_trans,'day');
print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'</td></tr>';
2011-01-05 10:57:55 +01:00
print '<tr><td width="20%">'.$langs->trans("TransMetod").'</td><td>';
print $bon->methodes_trans[$bon->method_trans];
print '</td></tr>';
}
if($bon->date_credit <> 0)
{
print '<tr><td width="20%">'.$langs->trans('CreditDate').'</td><td>';
2011-01-08 09:18:29 +01:00
print dol_print_date($bon->date_credit,'day');
2011-01-05 10:57:55 +01:00
print '</td></tr>';
}
2010-08-09 18:07:23 +02:00
print '</table>';
print '<br>';
print '<table class="border" width="100%"><tr><td width="20%">';
print $langs->trans("WithdrawalFile").'</td><td>';
$relativepath = 'receipts/'.$bon->ref;
2013-04-20 20:30:18 +02:00
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
print '</td></tr></table>';
dol_fiche_end();
2010-08-09 18:07:23 +02:00
}
else
2005-01-19 15:38:59 +01:00
{
2011-05-06 15:49:34 +02:00
$langs->load("errors");
print $langs->trans("Error");
2005-01-19 15:38:59 +01:00
}
2010-03-27 15:40:39 +01:00
2010-08-09 18:07:23 +02:00
/*
* Stats
*/
2011-01-05 10:57:55 +01:00
$ligne=new LignePrelevement($db,$user);
2012-08-05 14:37:45 +02:00
2010-08-09 18:07:23 +02:00
$sql = "SELECT sum(pl.amount), pl.statut";
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql.= " WHERE pl.fk_prelevement_bons = ".$prev_id;
$sql.= " GROUP BY pl.statut";
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
print_fiche_titre($langs->trans("StatisticsByLineStatus"),'','');
2010-08-09 18:07:23 +02:00
print"\n<!-- debut table -->\n";
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Status").'</td><td align="right">'.$langs->trans("Amount").'</td><td align="right">%</td></tr>';
$var=false;
while ($i < $num)
{
$row = $db->fetch_row($resql);
2013-06-20 09:18:12 +02:00
print "<tr ".$bc[$var]."><td>";
2012-08-05 14:37:45 +02:00
2011-01-05 10:57:55 +01:00
print $ligne->LibStatut($row[1],1);
2010-08-09 18:07:23 +02:00
print '</td><td align="right">';
print price($row[0]);
print '</td><td align="right">';
print round($row[0]/$bon->amount*100,2)." %";
print '</td>';
print "</tr>\n";
$var=!$var;
$i++;
}
print "</table>";
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
2005-01-19 15:38:59 +01:00
}
$db->close();
llxFooter();