dolibarr/htdocs/compta/prelevement/factures.php

220 lines
6.9 KiB
PHP
Raw Normal View History

2012-08-22 23:27:53 +02:00
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
2012-12-30 15:13:49 +01:00
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
2012-02-29 18:56:54 +01:00
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
2005-01-18 18:12:30 +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-18 18:12:30 +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-18 18:12:30 +01:00
*/
/**
2010-04-29 10:38:58 +02:00
* \file htdocs/compta/prelevement/factures.php
* \ingroup prelevement
* \brief Page liste des factures prelevees
*/
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/rejetprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.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");
2008-11-05 23:34:14 +01:00
$langs->load("companies");
$langs->load('withdrawals');
$langs->load('bills');
2008-11-05 23:34:14 +01:00
// Securite acces client
2005-01-18 18:12:30 +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');
$socid = GETPOST('socid','int');
2012-02-29 18:56:54 +01:00
$page = GETPOST('page','int');
$sortorder = ((GETPOST('sortorder','alpha')=="")) ? "DESC" : GETPOST('sortorder','alpha');
$sortfield = ((GETPOST('sortfield','alpha')=="")) ? "p.ref" : GETPOST('sortfield','alpha');
2011-05-06 15:49:34 +02:00
2013-11-14 21:02:33 +01:00
llxHeader('',$langs->trans("WithdrawalReceipts"));
2005-01-18 18:12:30 +01:00
2011-05-06 15:49:34 +02:00
if ($prev_id)
2005-01-18 18:12:30 +01:00
{
2010-11-18 18:10:31 +01:00
$bon = new BonPrelevement($db,"");
2005-01-18 18:12:30 +01:00
2011-05-06 15:49:34 +02:00
if ($bon->fetch($prev_id) == 0)
2005-01-18 18:12:30 +01:00
{
2012-08-05 14:37:45 +02:00
$head = prelevement_prepare_head($bon);
2013-11-14 21:02:33 +01:00
dol_fiche_head($head, 'invoices', $langs->trans("WithdrawalReceipts"), '', 'payment');
2005-01-18 18:12:30 +01:00
2010-11-18 18:10:31 +01:00
print '<table class="border" width="100%">';
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>';
}
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();
2005-01-18 18:12:30 +01:00
}
2010-11-18 18:10:31 +01:00
else
2005-01-18 18:12:30 +01:00
{
2010-11-18 18:10:31 +01:00
dol_print_error($db);
2005-01-18 18:12:30 +01:00
}
}
$offset = $conf->liste_limit * $page ;
/*
* Liste des factures
*/
2005-03-01 14:26:20 +01:00
$sql = "SELECT pf.rowid";
$sql.= ",f.rowid as facid, f.facnumber as ref, f.total_ttc";
2011-01-30 00:09:36 +01:00
$sql.= ", s.rowid as socid, s.nom, pl.statut";
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql.= ", ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql.= ", ".MAIN_DB_PREFIX."prelevement_facture as pf";
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE pf.fk_prelevement_lignes = pl.rowid";
$sql.= " AND pl.fk_prelevement_bons = p.rowid";
$sql.= " AND f.fk_soc = s.rowid";
$sql.= " AND pf.fk_facture = f.rowid";
$sql.= " AND f.entity = ".$conf->entity;
2011-05-06 15:49:34 +02:00
if ($prev_id) $sql.= " AND p.rowid=".$prev_id;
if ($socid) $sql.= " AND s.rowid = ".$socid;
$sql.= " ORDER BY $sortfield $sortorder ";
$sql.= $db->plimit($conf->liste_limit+1, $offset);
2005-01-18 18:12:30 +01:00
$result = $db->query($sql);
2005-03-01 14:26:20 +01:00
2005-01-18 18:12:30 +01:00
if ($result)
{
2010-11-18 18:10:31 +01:00
$num = $db->num_rows($result);
$i = 0;
2010-03-27 15:40:39 +01:00
2011-05-06 15:49:34 +02:00
$urladd = "&amp;id=".$prev_id;
2005-01-18 18:12:30 +01:00
2010-11-18 18:10:31 +01:00
print_barre_liste("", $page, "factures.php", $urladd, $sortfield, $sortorder, '', $num);
2010-11-18 18:10:31 +01:00
print"\n<!-- debut table -->\n";
print '<table class="liste" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Bill"),"factures.php","p.ref",'',$urladd,'class="liste_titre"',$sortfield,$sortorder);
2011-01-30 00:09:36 +01:00
print_liste_field_titre($langs->trans("ThirdParty"),"factures.php","s.nom",'',$urladd,'class="liste_titre"',$sortfield,$sortorder);
2010-11-18 18:10:31 +01:00
print_liste_field_titre($langs->trans("Amount"),"factures.php","f.total_ttc","",$urladd,'class="liste_titre" align="center"',$sortfield,$sortorder);
print '<td class="liste_titre" colspan="2">&nbsp;</td></tr>';
2005-01-18 18:12:30 +01:00
2010-11-18 18:10:31 +01:00
$var=false;
2005-01-18 18:12:30 +01:00
2010-11-18 18:10:31 +01:00
$total = 0;
2005-01-18 18:12:30 +01:00
2010-11-18 18:10:31 +01:00
while ($i < min($num,$conf->liste_limit))
2005-01-18 18:12:30 +01:00
{
2010-11-18 18:10:31 +01:00
$obj = $db->fetch_object($result);
2005-01-18 18:12:30 +01:00
2013-06-20 09:18:12 +02:00
print "<tr ".$bc[$var]."><td>";
2005-01-18 18:12:30 +01:00
2010-11-18 18:10:31 +01:00
print '<a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$obj->facid.'">';
print img_object($langs->trans("ShowBill"),"bill");
print '</a>&nbsp;';
2005-01-18 18:12:30 +01:00
2010-11-18 18:10:31 +01:00
print '<a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$obj->facid.'">'.$obj->ref."</a></td>\n";
2005-01-18 18:12:30 +01:00
2011-01-30 00:09:36 +01:00
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->socid.'">';
2010-11-18 18:10:31 +01:00
print img_object($langs->trans("ShowCompany"),"company"). ' '.stripslashes($obj->nom)."</a></td>\n";
2005-01-18 18:12:30 +01:00
2010-11-18 18:10:31 +01:00
print '<td align="center">'.price($obj->total_ttc)."</td>\n";
2005-01-18 18:12:30 +01:00
2010-11-18 18:10:31 +01:00
print '<td>';
2005-01-24 09:34:00 +01:00
2010-11-18 18:10:31 +01:00
if ($obj->statut == 0)
{
print '-';
}
2011-01-30 00:09:36 +01:00
elseif ($obj->statut == 2)
2010-11-18 18:10:31 +01:00
{
2011-01-30 00:09:36 +01:00
print $langs->trans("StatusCredited");
2010-11-18 18:10:31 +01:00
}
2011-01-30 00:09:36 +01:00
elseif ($obj->statut == 3)
2010-11-18 18:10:31 +01:00
{
2011-01-30 00:09:36 +01:00
print '<b>'.$langs->trans("StatusRefused").'</b>';
2010-11-18 18:10:31 +01:00
}
2005-01-24 09:34:00 +01:00
2010-11-18 18:10:31 +01:00
print "</td></tr>\n";
2005-01-18 18:12:30 +01:00
2010-11-18 18:10:31 +01:00
$total += $obj->total_ttc;
$var=!$var;
$i++;
2005-01-18 18:12:30 +01:00
}
2011-05-06 15:49:34 +02:00
if($socid)
2005-01-18 18:12:30 +01:00
{
2013-06-20 09:18:12 +02:00
print "<tr ".$bc[$var]."><td>";
2005-01-18 18:12:30 +01:00
2011-01-30 00:09:36 +01:00
print '<td>'.$langs->trans("Total").'</td>';
2005-01-18 18:12:30 +01:00
2010-11-18 18:10:31 +01:00
print '<td align="center">'.price($total)."</td>\n";
2005-01-18 18:12:30 +01:00
2010-11-18 18:10:31 +01:00
print '<td>&nbsp;</td>';
2005-01-18 18:12:30 +01:00
2010-11-18 18:10:31 +01:00
print "</tr>\n";
2005-01-18 18:12:30 +01:00
}
2010-11-18 18:10:31 +01:00
print "</table>";
$db->free($result);
2005-01-18 18:12:30 +01:00
}
2010-03-27 15:40:39 +01:00
else
2005-01-18 18:12:30 +01:00
{
2010-11-18 18:10:31 +01:00
dol_print_error($db);
2005-01-18 18:12:30 +01:00
}
$db->close();
llxFooter();
2005-01-18 18:12:30 +01:00
?>