dolibarr/htdocs/compta/prelevement/index.php

227 lines
6.7 KiB
PHP
Raw Normal View History

<?php
2005-01-07 16:11:07 +01:00
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
2018-10-27 14:43:12 +02:00
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
2004-09-28 17:30:02 +02: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
2004-09-28 17:30:02 +02: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/>.
2004-09-28 17:30:02 +02:00
*/
2005-01-30 02:00:40 +01:00
/**
2008-11-05 23:34:14 +01:00
* \file htdocs/compta/prelevement/index.php
2012-08-05 14:37:45 +02:00
* \ingroup prelevement
* \brief Prelevement index page
2008-11-05 23:34:14 +01:00
*/
2004-09-28 17:30:02 +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';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.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', 'withdrawals'));
2007-06-14 10:17:05 +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;
2008-03-01 02:26:41 +01:00
$result = restrictedArea($user, 'prelevement','','');
2007-06-14 10:17:05 +02:00
2015-05-15 20:10:17 +02:00
/*
* Actions
*/
2005-05-23 13:16:28 +02:00
2004-09-28 17:30:02 +02:00
2005-07-25 15:08:19 +02:00
/*
2008-11-05 23:34:14 +01:00
* View
2005-07-25 15:08:19 +02:00
*/
2005-08-13 19:11:27 +02:00
llxHeader('',$langs->trans("CustomersStandingOrdersArea"));
2005-08-13 19:11:27 +02:00
if (prelevement_check_config() < 0)
{
$langs->load("errors");
2017-02-06 12:03:20 +01:00
setEventMessages($langs->trans("ErrorModuleSetupNotComplete"), null, 'errors');
}
print load_fiche_titre($langs->trans("CustomersStandingOrdersArea"));
2005-08-13 19:11:27 +02:00
print '<div class="fichecenter"><div class="fichethirdleft">';
2005-08-13 19:11:27 +02:00
2008-11-05 23:34:14 +01:00
$thirdpartystatic=new Societe($db);
$invoicestatic=new Facture($db);
2005-07-25 15:08:19 +02:00
$bprev = new BonPrelevement($db);
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("NbOfInvoiceToWithdraw").'</td>';
2005-07-25 15:08:19 +02:00
print '<td align="right">';
print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/demandes.php?status=0">';
2005-07-25 15:08:19 +02:00
print $bprev->NbFactureAPrelever();
print '</a>';
2005-07-25 15:08:19 +02:00
print '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("AmountToWithdraw").'</td>';
2005-07-25 15:08:19 +02:00
print '<td align="right">';
2014-03-17 20:43:01 +01:00
print price($bprev->SommeAPrelever(),'','',1,-1,-1,'auto');
2005-07-25 15:08:19 +02:00
print '</td></tr></table><br>';
2005-01-30 02:00:40 +01:00
2005-01-07 16:11:07 +01:00
/*
* Invoices waiting for withdraw
2005-01-07 16:11:07 +01:00
*/
2018-12-02 14:31:45 +01:00
$sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,";
$sql.= " pfd.date_demande, pfd.amount,";
$sql.= " s.nom as name, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f,";
$sql.= " ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
$sql.= " WHERE s.rowid = f.fk_soc";
$sql.= " AND f.entity = ".$conf->entity;
$sql.= " AND pfd.traite = 0 AND pfd.fk_facture = f.rowid";
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;
2008-11-05 23:34:14 +01:00
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<th colspan="5">'.$langs->trans("InvoiceWaitingWithdraw").' ('.$num.')</th></tr>';
if ($num)
{
while ($i < $num && $i < 20)
{
$obj = $db->fetch_object($resql);
$invoicestatic->id=$obj->rowid;
2018-12-02 14:31:45 +01:00
$invoicestatic->ref=$obj->ref;
$invoicestatic->statut=$obj->fk_statut;
$invoicestatic->paye=$obj->paye;
$invoicestatic->type=$obj->type;
$alreadypayed=$invoicestatic->getSommePaiement();
2017-06-07 16:44:04 +02:00
print '<tr class="oddeven"><td>';
print $invoicestatic->getNomUrl(1,'withdraw');
print '</td>';
print '<td>';
$thirdpartystatic->id=$obj->socid;
$thirdpartystatic->name=$obj->name;
print $thirdpartystatic->getNomUrl(1,'customer');
print '</td>';
print '<td align="right">';
print price($obj->amount);
print '</td>';
print '<td align="right">';
print dol_print_date($db->jdate($obj->date_demande),'day');
print '</td>';
print '<td align="right">';
print $invoicestatic->getLibStatut(3,$alreadypayed);
print '</td>';
print '</tr>';
$i++;
}
}
else
{
2017-06-07 16:44:04 +02:00
print '<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("NoInvoiceToWithdraw", $langs->transnoentitiesnoconv("StandingOrders")).'</td></tr>';
}
print "</table><br>";
2008-11-05 23:34:14 +01:00
}
else
2005-01-07 16:11:07 +01:00
{
dol_print_error($db);
2004-09-28 17:30:02 +02:00
}
2008-11-05 23:34:14 +01:00
2014-03-17 20:43:01 +01:00
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
/*
* Withdraw receipts
*/
$limit=5;
$sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut";
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql.= " ORDER BY datec DESC";
$sql.= $db->plimit($limit);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
print"\n<!-- debut table -->\n";
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><th>'.$langs->trans("LastWithdrawalReceipt",$limit).'</th>';
print '<th>'.$langs->trans("Date").'</th>';
print '<th align="right">'.$langs->trans("Amount").'</th>';
print '<th align="right">'.$langs->trans("Status").'</th>';
2014-03-17 20:43:01 +01:00
print '</tr>';
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($result);
2017-06-07 16:44:04 +02:00
2014-03-17 20:43:01 +01:00
print '<tr class="oddeven">';
2014-03-17 20:43:01 +01:00
print "<td>";
$bprev->id=$obj->rowid;
$bprev->ref=$obj->ref;
$bprev->statut=$obj->statut;
print $bprev->getNomUrl(1);
print "</td>\n";
print '<td>'.dol_print_date($db->jdate($obj->datec),"dayhour")."</td>\n";
print '<td align="right">'.price($obj->amount)."</td>\n";
print '<td align="right">'.$bprev->getLibStatut(3)."</td>\n";
print "</tr>\n";
$i++;
}
print "</table><br>";
$db->free($result);
}
else
{
dol_print_error($db);
}
2013-03-30 19:40:52 +01:00
print '</div></div></div>';
2004-09-28 17:30:02 +02:00
2018-08-08 12:29:36 +02:00
// End of page
llxFooter();
$db->close();