* Copyright (C) 2005 Laurent Destailleur * Copyright (C) 2010-2012 Juanjo Menent * * 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 * (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 * along with this program. If not, see . */ /** * \file htdocs/compta/prelevement/fiche-stat.php * \ingroup prelevement * \brief Prelevement statistics */ 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'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array("banks","categories",'withdrawals','bills')); // Security check if ($user->societe_id > 0) accessforbidden(); // Get supervariables $prev_id = GETPOST('id','int'); $ref = GETPOST('ref', 'alpha'); // Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; $object = new BonPrelevement($db,""); /* * View */ llxHeader('',$langs->trans("WithdrawalsReceipts")); if ($prev_id > 0 || $ref) { if ($object->fetch($prev_id, $ref) >= 0) { $head = prelevement_prepare_head($object); dol_fiche_head($head, 'statistics', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref'); print '
'; print '
'; print ''."\n"; //print ''; print ''; print ''; // Status /* print ''; print ''; print ''; */ if($object->date_trans <> 0) { $muser = new User($db); $muser->fetch($object->user_trans); print ''; print ''; } if($object->date_credit <> 0) { print ''; } print '
'.$langs->trans("Ref").''.$object->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($object->datec,'day').'
'.$langs->trans("Amount").''.price($object->amount).'
'.$langs->trans('Status').''.$object->getLibStatut(1).'
'.$langs->trans("TransData").''; print dol_print_date($object->date_trans,'day'); print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'
'.$langs->trans("TransMetod").''; print $object->methodes_trans[$object->method_trans]; print '
'.$langs->trans('CreditDate').''; print dol_print_date($object->date_credit,'day'); print '
'; print '
'; print '
'; print ''; $acc = new Account($db); $result=$acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); print ''; print ''; print ''; print '
'; print $langs->trans("BankToReceiveWithdraw"); print ''; if ($acc->id > 0) print $acc->getNomUrl(1); print '
'; print $langs->trans("WithdrawalFile").''; $relativepath = 'receipts/'.$object->ref.'.xml'; print ''.$relativepath.''; print '
'; print '
'; dol_fiche_end(); } else { $langs->load("errors"); print $langs->trans("Error"); } /* * Stats */ $ligne=new LignePrelevement($db,$user); $sql = "SELECT sum(pl.amount), pl.statut"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; $sql.= " WHERE pl.fk_prelevement_bons = ".$object->id; $sql.= " GROUP BY pl.statut"; $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; print load_fiche_titre($langs->trans("StatisticsByLineStatus"),'',''); print"\n\n"; print ''; print ''; print ''; while ($i < $num) { $row = $db->fetch_row($resql); print ''; print "\n"; $i++; } print "
'.$langs->trans("Status").''.$langs->trans("Amount").'%
'; print $ligne->LibStatut($row[1],1); print ''; print price($row[0]); print ''; if ($object->amount) print round($row[0]/$object->amount*100,2)." %"; print '
"; $db->free($resql); } else { print $db->error() . ' ' . $sql; } } llxFooter(); $db->close();