dolibarr/htdocs/compta/paiement/tovalidate.php

144 lines
4.4 KiB
PHP
Raw Normal View History

2005-03-10 14:56:14 +01:00
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
2005-03-10 14:56:14 +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-03-10 14:56:14 +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/>.
2005-03-10 14:56:14 +01:00
*/
2010-03-27 03:35:08 +01:00
2005-03-10 14:56:14 +01:00
/**
* \file htdocs/compta/paiement/tovalidate.php
* \ingroup compta
* \brief Page list payment to validate. Visible in menu when option BILL_ADD_PAYMENT_VALIDATION is on.
*/
2005-03-10 14:56:14 +01:00
require '../../main.inc.php';
2005-03-10 14:56:14 +01:00
2018-05-27 09:27:09 +02:00
// Load translation files required by the page
2005-11-19 03:38:29 +01:00
$langs->load("bills");
2005-10-08 21:13:58 +02:00
2010-03-27 03:35:08 +01:00
// Security check
2005-10-08 21:13:58 +02:00
if (! $user->rights->facture->lire)
accessforbidden();
$socid=0;
2010-03-27 03:35:08 +01:00
if ($user->societe_id > 0)
2005-03-10 14:56:14 +01:00
{
2005-10-08 21:13:58 +02:00
$action = '';
$socid = $user->societe_id;
2005-03-10 14:56:14 +01:00
}
2005-10-08 21:13:58 +02:00
2018-04-21 12:16:12 +02:00
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
2017-01-22 13:27:17 +01:00
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
2017-06-06 10:53:53 +02:00
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
2017-01-22 13:27:17 +01:00
$offset = $limit * $page;
2010-11-20 14:08:44 +01:00
$pageprev = $page - 1;
$pagenext = $page + 1;
2005-03-10 14:56:14 +01:00
if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="p.rowid";
2017-01-22 13:27:17 +01:00
/*
* Actions
*/
/*
* View
*/
llxHeader();
2010-03-27 03:35:08 +01:00
2010-05-08 21:31:43 +02:00
$sql = "SELECT p.rowid, p.datep as dp, p.amount, p.statut";
2012-02-01 18:29:06 +01:00
$sql.=", c.libelle as paiement_type, p.num_paiement";
$sql.= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
if ($socid)
2005-10-08 21:13:58 +02:00
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid";
}
$sql.= " WHERE p.entity IN (" . getEntity('facture') . ')';
if ($socid)
2005-10-08 21:13:58 +02:00
{
$sql.= " AND f.fk_soc = ".$socid;
2005-10-08 21:13:58 +02:00
}
2012-02-01 18:29:06 +01:00
$sql.= " AND p.statut = 0";
2005-03-10 14:56:14 +01:00
2017-01-22 13:27:17 +01:00
$sql.= $db->order($sortfield,$sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0;
$offset = 0;
}
2017-01-22 13:27:17 +01:00
}
$sql.= $db->plimit($limit + 1,$offset);
$resql = $db->query($sql);
2005-10-08 21:13:58 +02:00
if ($resql)
2005-03-10 14:56:14 +01:00
{
2005-10-08 21:13:58 +02:00
$num = $db->num_rows($resql);
$i = 0;
2014-09-18 20:13:38 +02:00
print_barre_liste($langs->trans("ReceivedCustomersPaymentsToValid"), $page, $_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num);
2005-10-08 21:13:58 +02:00
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"p.rowid","","",'width="60"',$sortfield,$sortorder);
print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"dp","","",'width="80" align="center"',$sortfield,$sortorder);
print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"c.libelle","","","",$sortfield,$sortorder);
print_liste_field_titre("AmountTTC",$_SERVER["PHP_SELF"],"c.libelle","","",'align="right"',$sortfield,$sortorder);
2015-06-26 06:23:29 +02:00
print_liste_field_titre('');
2005-10-08 21:13:58 +02:00
print "</tr>\n";
while ($i < min($num,$limit))
2005-03-10 14:56:14 +01:00
{
2005-10-08 21:13:58 +02:00
$objp = $db->fetch_object($resql);
2017-06-09 09:25:15 +02:00
print '<tr class="oddeven">';
print '<td><a href="'.DOL_URL_ROOT.'/compta/paiement/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowPayment"),"payment").' '.$objp->rowid.'</a></td>';
2010-05-08 21:31:43 +02:00
print '<td width="80" align="center">'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
2005-10-08 21:13:58 +02:00
print "<td>$objp->paiement_type $objp->num_paiement</td>\n";
print '<td align="right">'.price($objp->amount).'</td>';
print '<td align="center">';
if ($objp->statut == 0)
{
print '<a href="card.php?id='.$objp->rowid.'&amp;action=valide">'.$langs->trans("PaymentStatusToValidShort").'</a>';
2005-10-08 21:13:58 +02:00
}
else
{
print "-";
}
print '</td>';
print "</tr>";
$i++;
2005-03-10 14:56:14 +01:00
}
2005-10-08 21:13:58 +02:00
print "</table>";
2005-03-10 14:56:14 +01:00
}
llxFooter();
$db->close();