dolibarr/htdocs/compta/prelevement/demandes.php

163 lines
5.3 KiB
PHP
Raw Normal View History

2005-01-11 10:37:35 +01:00
<?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2010 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) 2011-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/demandes.php
2012-08-05 14:37:45 +02:00
* \ingroup prelevement
* \brief Page to list withdraw requests
2008-11-05 23:34:14 +01:00
*/
2012-08-05 14:37:45 +02:00
require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/core/modules/modPrelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.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");
2005-05-23 13:16:28 +02:00
$langs->load("widthdrawals");
2008-11-04 17:58:26 +01:00
$langs->load("companies");
2005-05-23 13:16:28 +02:00
2008-02-25 17:30:43 +01:00
// Security check
2012-02-27 22:26:22 +01:00
$socid = GETPOST('socid','int');
2008-02-25 21:03:21 +01:00
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'prelevement','','','bons');
2008-02-25 17:30:43 +01:00
2011-05-06 15:49:34 +02:00
// Get supervariables
2012-02-29 18:56:54 +01:00
$page = GETPOST('page','int');
$sortorder = GETPOST('sortorder','alpha');
$sortfield = GETPOST('sortfield','alpha');
2005-01-11 10:37:35 +01:00
/*
2008-11-05 23:34:14 +01:00
* View
2005-01-11 10:37:35 +01:00
*/
2008-11-05 23:34:14 +01:00
llxHeader();
$thirdpartystatic=new Societe($db);
$invoicestatic=new Facture($db);
2005-01-11 11:18:24 +01:00
if ($page == -1) $page = 0 ;
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
2005-05-23 13:16:28 +02:00
if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="f.facnumber";
2005-01-11 11:18:24 +01:00
2005-01-11 10:37:35 +01:00
2005-01-11 11:18:24 +01:00
/*
* Liste de demandes
2005-01-11 11:18:24 +01:00
*/
$sql= "SELECT f.facnumber, f.rowid, f.total_ttc,";
$sql.= " s.nom, s.rowid as socid,";
$sql.= " pfd.date_demande as date_demande,";
$sql.= " pfd.fk_user_demande";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f,";
$sql.= " ".MAIN_DB_PREFIX."societe as s,";
$sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.rowid = f.fk_soc";
$sql.= " AND f.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
if (!$statut) $sql.= " AND pfd.traite = 0";
if ($statut) $sql.= " AND pfd.traite = ".$statut;
$sql.= " AND pfd.fk_facture = f.rowid";
2012-02-29 18:56:54 +01:00
if (dol_strlen(trim(GETPOST('search_societe','alpha'))))
2005-01-11 10:37:35 +01:00
{
2012-02-29 18:56:54 +01:00
$sql.= " AND s.nom LIKE '%".GETPOST('search_societe','alpha')."%'";
2005-01-11 10:37:35 +01:00
}
$sql.= " ORDER BY $sortfield $sortorder ";
$sql.= $db->plimit($conf->liste_limit+1, $offset);
2005-01-11 10:37:35 +01:00
2010-06-14 21:18:21 +02:00
$resql=$db->query($sql);
if ($resql)
2005-01-11 10:37:35 +01:00
{
2010-06-14 21:18:21 +02:00
$num = $db->num_rows($resql);
2008-11-05 23:34:14 +01:00
$i = 0;
if (!$statut)
2008-11-05 23:34:14 +01:00
{
print_barre_liste($langs->trans("RequestStandingOrderToTreat"), $page, "demandes.php", $urladd, $sortfield, $sortorder, '', $num);
}
else
2005-01-11 10:37:35 +01:00
{
2008-11-05 23:34:14 +01:00
print_barre_liste($langs->trans("RequestStandingOrderTreated"), $page, "demandes.php", $urladd, $sortfield, $sortorder, '', $num);
2005-01-11 10:37:35 +01:00
}
2008-11-05 23:34:14 +01:00
print '<table class="liste" width="100%">';
2008-11-05 23:34:14 +01:00
print '<tr class="liste_titre">';
print '<td class="liste_titre">'.$langs->trans("Bill").'</td><td class="liste_titre">'.$langs->trans("Company").'</td>';
print '<td class="liste_titre" align="right">'.$langs->trans("Amount").'</td>';
print '<td class="liste_titre" align="right">'.$langs->trans("DateRequest").'</td>';
2008-11-05 23:34:14 +01:00
print '</tr>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="GET">';
2012-02-29 18:56:54 +01:00
print '<td class="liste_titre"><input type="text" class="flat" name="search_facture" size="12" value="'.GETPOST('search_facture','alpha').'"></td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_societe" size="18" value="'.GETPOST('search_societe','alpha').'"></td>';
print '<td colspan="2" class="liste_titre" align="right"><input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'"></td>';
2008-11-05 23:34:14 +01:00
print '</tr>';
print '</form>';
$var = True;
2008-11-05 23:34:14 +01:00
$users = array();
while ($i < min($num,$conf->liste_limit))
{
2010-06-14 21:18:21 +02:00
$obj = $db->fetch_object($resql);
2008-11-05 23:34:14 +01:00
$var=!$var;
print '<tr '.$bc[$var].'>';
// Ref facture
print '<td>';
$invoicestatic->id=$obj->rowid;
$invoicestatic->ref=$obj->facnumber;
print $invoicestatic->getNomUrl(1,'withdraw');
print '</td>';
print '<td>';
$thirdpartystatic->id=$obj->socid;
$thirdpartystatic->nom=$obj->nom;
print $thirdpartystatic->getNomUrl(1,'customer');
print '</td>';
print '<td align="right">'.price($obj->total_ttc).'</td>';
2008-11-05 23:34:14 +01:00
print '<td align="right">'.dol_print_date($db->jdate($obj->date_demande),'day').'</td>';
2008-11-05 23:34:14 +01:00
print '</tr>';
$i++;
}
2010-03-16 00:54:37 +01:00
print "</table><br>";
2005-01-24 09:34:00 +01:00
2005-01-11 10:37:35 +01:00
}
else
{
dol_print_error($db);
2008-11-05 23:34:14 +01:00
}
2005-01-11 10:37:35 +01:00
2005-05-23 13:16:28 +02:00
llxFooter();
2005-01-11 10:37:35 +01:00
?>