dolibarr/htdocs/compta/prelevement/bons.php

189 lines
6.7 KiB
PHP
Raw Normal View History

2012-08-22 23:27:53 +02:00
<?php
2008-11-05 23:34:14 +01:00
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
2017-06-07 16:44:04 +02:00
* Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
2018-10-27 14:43:12 +02:00
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
2012-02-29 18:56:54 +01:00
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
2005-01-11 10:37:35 +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-11 10:37:35 +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-11 10:37:35 +01:00
*/
2005-05-23 13:16:28 +02:00
/**
* \file htdocs/compta/prelevement/bons.php
* \ingroup prelevement
* \brief Page liste des bons de prelevements
*/
2005-05-23 13:16:28 +02:00
2018-07-26 11:57:25 +02:00
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.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', 'widthdrawals'));
// Security check
2012-02-27 22:26:22 +01:00
$socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'prelevement','','','bons');
2005-08-03 18:05:00 +02:00
2018-04-21 12:16:12 +02:00
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
2017-01-22 13:19:07 +01:00
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
2012-02-29 18:56:54 +01:00
$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:19:07 +01:00
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="p.datec";
// Get supervariables
2012-02-29 18:56:54 +01:00
$statut = GETPOST('statut','int');
2017-01-22 13:19:07 +01:00
$search_ref = GETPOST('search_ref','alpha');
$search_amount = GETPOST('search_amount','alpha');
$bon=new BonPrelevement($db,"");
2005-05-23 13:16:28 +02:00
2005-01-11 10:37:35 +01:00
2017-01-22 13:19:07 +01:00
/*
* Actions
*/
2005-01-11 10:37:35 +01:00
2017-07-13 00:35:10 +02:00
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
2017-01-22 13:19:07 +01:00
{
$search_ref="";
$search_amount="";
2017-01-22 13:19:07 +01:00
}
2005-01-11 10:37:35 +01:00
2011-01-05 10:57:55 +01:00
2005-01-11 10:37:35 +01:00
/*
2017-01-22 13:19:07 +01:00
* View
2005-01-11 10:37:35 +01:00
*/
2017-01-22 13:19:07 +01:00
llxHeader('',$langs->trans("WithdrawalsReceipts"));
2018-02-06 10:57:53 +01:00
$sql = "SELECT p.rowid, p.ref, p.amount, p.statut, p.datec";
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql.= " WHERE p.entity IN (".getEntity('invoice').")";
2017-01-22 13:19:07 +01:00
if ($search_ref) $sql.=natural_search("p.ref", $search_ref);
if ($search_amount) $sql.=natural_search("p.amount", $search_amount, 1);
2017-01-22 13:19:07 +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:19:07 +01:00
}
$sql.= $db->plimit($limit + 1,$offset);
2005-01-11 10:37:35 +01:00
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
2005-01-11 10:37:35 +01:00
$i = 0;
2010-03-27 15:40:39 +01:00
2011-05-06 18:56:53 +02:00
$urladd= "&amp;statut=".$statut;
2005-01-11 10:37:35 +01:00
$selectedfields='';
2018-04-15 17:37:49 +02:00
$newcardbutton='';
if ($user->rights->prelevement->bons->creer)
{
2018-06-13 22:57:41 +02:00
$newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/compta/prelevement/create.php"><span class="valignmiddle">'.$langs->trans('NewStandingOrder').'</span>';
$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
$newcardbutton.= '</a>';
2018-04-15 17:37:49 +02:00
}
2017-01-22 13:19:07 +01:00
// Lines of title fields
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
2017-05-21 02:43:51 +02:00
print '<input type="hidden" name="page" value="'.$page.'">';
2017-01-22 13:19:07 +01:00
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
2017-06-07 16:44:04 +02:00
print_barre_liste($langs->trans("WithdrawalsReceipts"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, $newcardbutton, '', $limit);
2017-01-22 13:19:07 +01:00
$moreforfilter='';
2017-06-07 16:44:04 +02:00
2017-01-22 13:19:07 +01:00
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
2005-01-11 10:37:35 +01:00
print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_ref" value="'. dol_escape_htmltag($search_ref).'"></td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre right"><input type="text" class="flat maxwidth100" name="search_amount" value="'. dol_escape_htmltag($search_amount).'"></td>';
print '<td class="liste_titre">&nbsp;</td>';
2017-01-22 13:19:07 +01:00
print '<td class="liste_titre" align="right">';
2017-06-07 16:44:04 +02:00
$searchpicto=$form->showFilterButtons();
2017-05-14 21:06:33 +02:00
print $searchpicto;
2017-01-22 13:19:07 +01:00
print '</td>';
2005-01-11 10:37:35 +01:00
print '</tr>';
2017-06-07 16:44:04 +02:00
print '<tr class="liste_titre">';
print_liste_field_titre("WithdrawalsReceipts",$_SERVER["PHP_SELF"],"p.ref",'','','class="liste_titre"',$sortfield,$sortorder);
print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"p.datec","","",'class="liste_titre" align="center"',$sortfield,$sortorder);
print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"p.amount","","",'align="right"',$sortfield,$sortorder);
print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"","","",'align="right"',$sortfield,$sortorder);
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
2017-06-07 16:44:04 +02:00
print "</tr>\n";
2005-01-11 10:37:35 +01:00
2017-01-22 13:19:07 +01:00
while ($i < min($num,$limit))
{
2017-06-07 16:44:04 +02:00
$obj = $db->fetch_object($result);
2005-01-11 10:37:35 +01:00
2017-05-10 16:41:19 +02:00
print '<tr class="oddeven"><td>';
2012-08-05 14:37:45 +02:00
print '<a href="card.php?id='.$obj->rowid.'">'.$obj->ref."</a></td>\n";
2005-01-11 10:37:35 +01:00
2010-05-08 21:49:29 +02:00
print '<td align="center">'.dol_print_date($db->jdate($obj->datec),'day')."</td>\n";
2005-01-11 10:37:35 +01:00
2008-11-05 23:34:14 +01:00
print '<td align="right">'.price($obj->amount)."</td>\n";
2005-01-11 10:37:35 +01:00
print '<td align="right">';
print $bon->LibStatut($obj->statut, 3);
print '</td>';
print '<td align="right"></td>'."\n";
2005-01-11 10:37:35 +01:00
print "</tr>\n";
$i++;
}
print "</table>";
2017-01-22 13:19:07 +01:00
print '</div>';
2017-06-07 16:44:04 +02:00
2017-01-22 13:19:07 +01:00
print '</form>';
2017-06-07 16:44:04 +02:00
$db->free($result);
2005-01-11 10:37:35 +01:00
}
2010-03-27 15:40:39 +01:00
else
2005-01-11 10:37:35 +01:00
{
dol_print_error($db);
2005-01-11 10:37:35 +01:00
}
2018-08-08 12:29:36 +02:00
// End of page
llxFooter();
2015-06-21 17:05:49 +02:00
$db->close();