forked from Wavyzz/dolibarr
Debut de gestion des bordereaux de remise de cheque
This commit is contained in:
329
htdocs/compta/paiement/cheque/fiche.php
Normal file
329
htdocs/compta/paiement/cheque/fiche.php
Normal file
@@ -0,0 +1,329 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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 2 of the License, or
|
||||
* (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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/compta/paiement/fiche.php
|
||||
\ingroup facture
|
||||
\brief Onglet paiement d'un paiement client
|
||||
\remarks Fichier presque identique a fournisseur/paiement/fiche.php
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require('./pre.inc.php');
|
||||
require_once(DOL_DOCUMENT_ROOT.'/paiement.class.php');
|
||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php");
|
||||
if ($conf->banque->enabled) require_once(DOL_DOCUMENT_ROOT.'/compta/bank/account.class.php');
|
||||
|
||||
$user->getrights('banque');
|
||||
|
||||
$langs->load('bills');
|
||||
$langs->load('banks');
|
||||
$langs->load('companies');
|
||||
|
||||
$mesg='';
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($_GET['action'] == 'create' && $_GET["accountid"] > 0 && $user->rights->banque)
|
||||
{
|
||||
$remise = new RemiseCheque($db);
|
||||
$result = $remise->Create($user, $_GET["accountid"]);
|
||||
if ($result === 0)
|
||||
{
|
||||
Header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$paiement->error.'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($_GET['action'] == 'remove' && $_GET["id"] > 0 && $_GET["lineid"] > 0 && $user->rights->banque)
|
||||
{
|
||||
$remise = new RemiseCheque($db);
|
||||
$remise->id = $_GET["id"];
|
||||
$result = $remise->RemoveCheck($_GET["lineid"]);
|
||||
if ($result === 0)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$paiement->error.'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->banque)
|
||||
{
|
||||
$remise = new RemiseCheque($db);
|
||||
$remise->id = $_GET["id"];
|
||||
$result = $remise->Delete();
|
||||
if ($result == 0)
|
||||
{
|
||||
Header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$paiement->error.'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Visualisation de la fiche
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
$html = new Form($db);
|
||||
|
||||
if ($_GET['action'] == 'new')
|
||||
{
|
||||
$h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/cheque/fiche.php?action=new';
|
||||
$head[$h][1] = $langs->trans("NewCheckReceipt");
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("CheckReceipt"));
|
||||
}
|
||||
else
|
||||
{
|
||||
$remise = new RemiseCheque($db);
|
||||
$result = $remise->Fetch($_GET["id"]);
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/cheque/fiche.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("CheckReceipt");
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
// $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$_GET["id"];
|
||||
// $head[$h][1] = $langs->trans("Info");
|
||||
// $h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("CheckReceipt"));
|
||||
|
||||
|
||||
/*
|
||||
* Confirmation de la suppression du bordereau
|
||||
*/
|
||||
if ($_GET['action'] == 'delete')
|
||||
{
|
||||
$html->form_confirm('fiche.php?id='.$remise->id, $langs->trans("DeleteCheckReceipt"), 'Etes-vous s<>r de vouloir supprimer ce bordereau ?', 'confirm_delete');
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Confirmation de la validation du bordereau
|
||||
*/
|
||||
if ($_GET['action'] == 'valide')
|
||||
{
|
||||
$facid = $_GET['facid'];
|
||||
$html->form_confirm('fiche.php?id='.$paiement->id.'&facid='.$facid, $langs->trans("ValidatePayment"), 'Etes-vous s<>r de vouloir valider ce r<>glement, auncune modification n\'est possible une fois le r<>glement valid<69> ?', 'confirm_valide');
|
||||
print '<br>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($mesg) print $mesg.'<br>';
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
if ($_GET['action'] == 'new')
|
||||
{
|
||||
$accounts = array();
|
||||
$lines = array();
|
||||
$sql = "SELECT ba.rowid as bid, ".$db->pdate("b.dateo")." as date,";
|
||||
$sql.= " b.amount, ba.label, b.emetteur";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b ";
|
||||
$sql.= ",".MAIN_DB_PREFIX."bank_account as ba ";
|
||||
$sql.= " WHERE b.fk_type = 'CHQ' AND b.fk_account = ba.rowid";
|
||||
$sql.= " AND b.fk_bordereau = 0 AND b.amount > 0";
|
||||
$sql.= " ORDER BY ba.rowid ASC, b.dateo ASC;";
|
||||
|
||||
|
||||
$resql = $db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
while ( $obj = $db->fetch_object($resql) )
|
||||
{
|
||||
$accounts[$obj->bid] = $obj->label;
|
||||
$lines[$obj->bid][$i]["date"] = $obj->date;
|
||||
$lines[$obj->bid][$i]["amount"] = $obj->amount;
|
||||
$lines[$obj->bid][$i]["emetteur"] = $obj->emetteur;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($accounts as $bid => $account_label)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="10%">'.$langs->trans("Date")."</td>\n";
|
||||
print '<td width="50%">'.$langs->trans("CheckTransmitter")."</td>\n";
|
||||
print '<td align="right">'.$langs->trans("Amount")."</td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
$var=true;
|
||||
|
||||
foreach ($lines[$bid] as $lid => $value)
|
||||
{
|
||||
$var=!$var;
|
||||
|
||||
$account_id = $objp->bid;
|
||||
$accounts[$objp->bid] += 1;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td>'.dolibarr_print_date($value["date"]).'</td>';
|
||||
print '<td>'.stripslashes($value["emetteur"])."</td>\n";
|
||||
print '<td align="right">'.price($value["amount"]).'</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
print '<a class="tabAction" href="fiche.php?action=create&accountid='.$bid.'">';
|
||||
print $langs->trans('NewCheckReceipt');
|
||||
print ' : '.stripslashes($account_label).'</a>';
|
||||
print '</div><br />';
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="30%">'.$langs->trans('Numero').'</td><td width="70%">'.$remise->number.'</td></tr>';
|
||||
print '<tr><td width="30%">'.$langs->trans('Date').'</td><td width="70%">'.dolibarr_print_date($remise->date_bordereau).'</td></tr>';
|
||||
print '<tr><td width="30%">'.$langs->trans('Account').'</td><td width="70%">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/bank/account.php?account='.$remise->account_id.'">'.img_object($langs->trans("ShowAccount"),'account').' '.$remise->account_label.'</a>';
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table><br />';
|
||||
|
||||
$sql = "SELECT p.rowid,".$db->pdate("p.datep")." as dp, p.amount,b.banque,b.emetteur,";
|
||||
$sql.= " p.statut, p.num_paiement,";
|
||||
$sql.= " c.code as paiement_code,";
|
||||
$sql.= " ba.rowid as bid, ba.label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_paiement as c,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."paiement as p";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank = b.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
|
||||
$sql.= " WHERE p.fk_paiement = c.id AND c.code = 'CHQ'";
|
||||
$sql.= " AND b.fk_bordereau = ".$remise->id;
|
||||
$sql.= " AND p.statut = 1";
|
||||
$sql.= " ORDER BY p.datep ASC;";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
$total = 0;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("Date"),"liste.php","dp","",$paramlist,'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Type"),"liste.php","c.libelle","",$paramlist,"",$sortfield);
|
||||
print_liste_field_titre($langs->trans("Amount"),"liste.php","p.amount","",$paramlist,'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Bank"),"liste.php","p.amount","",$paramlist,'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("CheckTransmitter"),"liste.php","p.amount","",$paramlist,'align="right"',$sortfield);
|
||||
print "</tr>\n";
|
||||
|
||||
$var=true;
|
||||
while ( $objp = $db->fetch_object($resql) )
|
||||
{
|
||||
$account_id = $objp->bid;
|
||||
$accounts[$objp->bid] += 1;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td align="center">'.dolibarr_print_date($objp->dp).'</td>';
|
||||
print '<td>'.$langs->trans("PaymentTypeShort".$objp->paiement_code).' '.$objp->num_paiement.'</td>';
|
||||
print '<td align="right">'.price($objp->amount).'</td>';
|
||||
print '<td>'.stripslashes($objp->banque).'</td>';
|
||||
print '<td>'.stripslashes($objp->emetteur).'</td>';
|
||||
print '</tr>';
|
||||
$total += $objp->amount;
|
||||
$i++;
|
||||
$var=!$var;
|
||||
}
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td align="center"> </td>';
|
||||
print '<td align="right">'.$langs->trans("Total").'</td>';
|
||||
print '<td align="right">'.price($total).'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
|
||||
print "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
/*
|
||||
* Boutons Actions
|
||||
*/
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->societe_id == 0 && sizeof($accounts) == 1 && $_GET['action'] == 'new')
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?action=create&accountid='.$account_id.'">'.$langs->trans('NewCheckReceipt').'</a>';
|
||||
}
|
||||
|
||||
if ($user->societe_id == 0 && $remise->statut == 0 && $_GET['action'] == '')
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?id='.$_GET['id'].'&facid='.$objp->facid.'&action=valide">'.$langs->trans('Valid').'</a>';
|
||||
}
|
||||
|
||||
if ($user->societe_id == 0 && $remise->statut == 0 && $_GET['action'] == '')
|
||||
{
|
||||
print '<a class="butDelete" href="fiche.php?id='.$_GET['id'].'&action=delete">'.$langs->trans('Delete').'</a>';
|
||||
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
169
htdocs/compta/paiement/cheque/index.php
Normal file
169
htdocs/compta/paiement/cheque/index.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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 2 of the License, or
|
||||
* (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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/compta/paiement/cheque/liste.php
|
||||
\ingroup compta
|
||||
\brief Page liste des bordereau de remise de cheque
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
|
||||
$langs->load("banks");
|
||||
|
||||
$user->getrights("facture");
|
||||
|
||||
// S<>curit<69> acc<63>s client
|
||||
if (! $user->rights->facture->lire)
|
||||
accessforbidden();
|
||||
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
/*
|
||||
* Affichage
|
||||
*/
|
||||
|
||||
llxHeader('',$langs->trans("CheckReceipt"));
|
||||
|
||||
print_titre($langs->trans("CheckReceipt") );
|
||||
|
||||
print '<table width="100%"><tr><td width="40%" valign="top">';
|
||||
|
||||
$sql = "SELECT bc.rowid,".$db->pdate("bc.date_bordereau")." as db, bc.amount,";
|
||||
$sql.= " bc.statut, ba.label, ba.rowid as bid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc";
|
||||
$sql.= ",".MAIN_DB_PREFIX."bank_account as ba";
|
||||
$sql.= " WHERE ba.rowid=bc.fk_bank_account";
|
||||
$sql.= " ORDER BY bc.rowid DESC LIMIT 10;";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Date")."</td>";
|
||||
print '<td>'.$langs->trans("Account").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Amount").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$var=true;
|
||||
while ( $objp = $db->fetch_object($resql) )
|
||||
{
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>\n";
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/paiement/cheque/fiche.php?id='.$objp->rowid.'">';
|
||||
print dolibarr_print_date($objp->db,'%d/%m').'</a></td>';
|
||||
|
||||
print '<td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/bank/account.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"),'account').' '.$objp->label.'</a>';
|
||||
|
||||
print '</td>';
|
||||
print '<td align="right">'.price($objp->amount).'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
print "</td>\n";
|
||||
print '<td width="60%" valign="top">';
|
||||
|
||||
$page=$_GET["page"];
|
||||
$sortorder=$_GET["sortorder"];
|
||||
$sortfield=$_GET["sortfield"];
|
||||
|
||||
$limit = $conf->liste_limit;
|
||||
$offset = $limit * $page ;
|
||||
if (! $sortorder) $sortorder="DESC";
|
||||
if (! $sortfield) $sortfield="p.rowid";
|
||||
|
||||
$sql = "SELECT b.amount,b.emetteur,".$db->pdate("b.dateo")." as date,";
|
||||
$sql.= " c.code as paiement_code,";
|
||||
$sql.= " ba.rowid as bid, ba.label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_paiement as c";
|
||||
$sql.= ",".MAIN_DB_PREFIX."bank as b";
|
||||
$sql.= ",".MAIN_DB_PREFIX."bank_account as ba";
|
||||
$sql.= " WHERE c.code = 'CHQ' AND c.code = b.fk_type AND b.fk_bordereau = 0 AND b.fk_account = ba.rowid";
|
||||
$sql.= " AND b.amount > 0";
|
||||
//$sql .= " ORDER BY $sortfield $sortorder";
|
||||
$sql .= $db->plimit( $limit+1 ,$offset);
|
||||
//print "$sql";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
$paramlist=($_GET["orphelins"]?"&orphelins=1":"");
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Date")."</td>\n";
|
||||
print '<td>'.$langs->trans("Account")."</td>\n";
|
||||
print '<td align="right">'.$langs->trans("Amount")."</td>\n";
|
||||
print '<td>'.$langs->trans("CheckTransmitter")."</td>\n";
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
$var=true;
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td>'.dolibarr_print_date($objp->date).'</td><td>';
|
||||
|
||||
if ($objp->bid) print '<a href="'.DOL_URL_ROOT.'/compta/bank/account.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"),'account').' '.$objp->label.'</a>';
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
print '<td align="right">'.price($objp->amount).'</td>';
|
||||
print '<td>'.$objp->emetteur.'</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
print "</td></tr>\n";
|
||||
print "</table>\n";
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
163
htdocs/compta/paiement/cheque/liste.php
Normal file
163
htdocs/compta/paiement/cheque/liste.php
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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 2 of the License, or
|
||||
* (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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/compta/paiement/cheque/liste.php
|
||||
\ingroup compta
|
||||
\brief Page liste des bordereau de remise de cheque
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
|
||||
$langs->load("bills");
|
||||
|
||||
$user->getrights("facture");
|
||||
|
||||
// S<>curit<69> acc<63>s client
|
||||
if (! $user->rights->facture->lire)
|
||||
accessforbidden();
|
||||
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Affichage
|
||||
*/
|
||||
|
||||
llxHeader('',$langs->trans("CheckReceipt"));
|
||||
|
||||
$page=$_GET["page"];
|
||||
$sortorder=$_GET["sortorder"];
|
||||
$sortfield=$_GET["sortfield"];
|
||||
|
||||
$limit = $conf->liste_limit;
|
||||
$offset = $limit * $page ;
|
||||
if (! $sortorder) $sortorder="DESC";
|
||||
if (! $sortfield) $sortfield="p.rowid";
|
||||
|
||||
$sql = "SELECT p.rowid,".$db->pdate("p.datep")." as dp, p.amount,";
|
||||
$sql.= " p.statut, p.num_paiement,";
|
||||
$sql.= " c.code as paiement_code,";
|
||||
$sql.= " ba.rowid as bid, ba.label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_paiement as c,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."paiement as p";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank = b.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
|
||||
if ($socid)
|
||||
{
|
||||
$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.fk_paiement = c.id AND c.code = 'CHQ'";
|
||||
if ($socid)
|
||||
{
|
||||
$sql.= " AND f.fk_soc = ".$socid;
|
||||
}
|
||||
if ($_GET["search_montant"])
|
||||
{
|
||||
$sql .=" AND p.amount=".price2num($_GET["search_montant"]);
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY $sortfield $sortorder";
|
||||
$sql .= $db->plimit( $limit+1 ,$offset);
|
||||
//print "$sql";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
$paramlist=($_GET["orphelins"]?"&orphelins=1":"");
|
||||
print_barre_liste($langs->trans("CheckReceipt"), $page, "liste.php",$paramlist,$sortfield,$sortorder,'',$num);
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("Ref"),"liste.php","p.rowid","",$paramlist,"",$sortfield);
|
||||
print_liste_field_titre($langs->trans("Date"),"liste.php","dp","",$paramlist,'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Type"),"liste.php","c.libelle","",$paramlist,"",$sortfield);
|
||||
print_liste_field_titre($langs->trans("Account"),"liste.php","ba.label","",$paramlist,"",$sortfield);
|
||||
print_liste_field_titre($langs->trans("Amount"),"liste.php","p.amount","",$paramlist,'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans("Status"),"liste.php","p.statut","",$paramlist,'align="center"',$sortfield);
|
||||
print "</tr>\n";
|
||||
|
||||
// Lignes des champs de filtre
|
||||
print '<form method="get" action="liste.php">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="4"> </td>';
|
||||
print '<td align="right">';
|
||||
print '<input class="fat" type="text" size="6" name="search_montant" value="'.$_GET["search_montant"].'">';
|
||||
print '</td><td align="right">';
|
||||
print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">';
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
print '</form>';
|
||||
|
||||
$var=true;
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td width="40"><a href="'.DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowPayment"),"payment").'</a>';
|
||||
|
||||
print ' <a href="'.DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$objp->rowid.'">'.$objp->rowid.'</a></td>';
|
||||
|
||||
print '<td align="center">'.dolibarr_print_date($objp->dp).'</td>';
|
||||
//print '<td>'.$objp->paiement_type.' '.$objp->num_paiement.'</td>';
|
||||
print '<td>'.$langs->trans("PaymentTypeShort".$objp->paiement_code).' '.$objp->num_paiement.'</td>';
|
||||
print '<td>';
|
||||
if ($objp->bid) print '<a href="'.DOL_URL_ROOT.'/compta/bank/account.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"),'account').' '.$objp->label.'</a>';
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
print '<td align="right">'.price($objp->amount).'</td>';
|
||||
print '<td align="center">';
|
||||
|
||||
if ($objp->statut == 0)
|
||||
{
|
||||
print '<a href="fiche.php?id='.$objp->rowid.'&action=valide">'.$langs->trans("ToValidate").'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print img_tick();
|
||||
}
|
||||
|
||||
print '</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
?>
|
||||
54
htdocs/compta/paiement/cheque/pre.inc.php
Normal file
54
htdocs/compta/paiement/cheque/pre.inc.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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 2 of the License, or
|
||||
* (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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
require("../../../main.inc.php");
|
||||
|
||||
$langs->load("bills");
|
||||
$langs->load("compta");
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/remisecheque.class.php');
|
||||
|
||||
function llxHeader($head = "", $title="")
|
||||
{
|
||||
global $user, $langs;
|
||||
$langs->load("bills");
|
||||
|
||||
top_menu($head, $title);
|
||||
|
||||
$menu = new Menu();
|
||||
|
||||
$menu->add("/compta/paiement/liste.php",$langs->trans("Payments"));
|
||||
|
||||
$menu->add(DOL_URL_ROOT."/compta/paiement/cheque/index.php",$langs->trans("CheckReceipt"));
|
||||
$menu->add_submenu(DOL_URL_ROOT."/compta/paiement/cheque/fiche.php?action=new",$langs->trans("New"));
|
||||
$menu->add_submenu(DOL_URL_ROOT."/compta/paiement/cheque/liste.php",$langs->trans("List"));
|
||||
|
||||
$menu->add("rapport.php",$langs->trans("Reportings"));
|
||||
|
||||
$menu->add(DOL_URL_ROOT."/compta/facture.php",$langs->trans("Bills"));
|
||||
$menu->add_submenu(DOL_URL_ROOT."/compta/facture/impayees.php",$langs->trans("Unpayed"));
|
||||
|
||||
$menu->add_submenu("avalider.php",$langs->trans("MenuToValid"));
|
||||
|
||||
left_menu($menu->liste);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -94,7 +94,7 @@ class RemiseCheque
|
||||
\param user utilisateur qui effectue l'operation
|
||||
\param account_id Compte bancaire concerne
|
||||
*/
|
||||
function create($user, $account_id)
|
||||
function Create($user, $account_id)
|
||||
{
|
||||
$this->errno = 0;
|
||||
$this->db->begin();
|
||||
@@ -122,7 +122,7 @@ class RemiseCheque
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
$this->errno = -19;
|
||||
$this->errno = -25;
|
||||
dolibarr_syslog("RemiseCheque::Create ERREUR UPDATE ($this->errno)");
|
||||
}
|
||||
}
|
||||
@@ -133,7 +133,7 @@ class RemiseCheque
|
||||
$sql = "SELECT b.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||
$sql.= " WHERE b.fk_type = 'CHQ'";
|
||||
$sql.= " AND b.fk_bordereau = 0";
|
||||
$sql.= " AND b.fk_bordereau = 0 AND b.fk_account='$account_id';";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
@@ -169,6 +169,14 @@ class RemiseCheque
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->id > 0 && $this->errno === 0)
|
||||
{
|
||||
if ($this->UpdateAmount() <> 0)
|
||||
{
|
||||
$this->errno = -19;
|
||||
dolibarr_syslog("RemiseCheque::Create ERREUR ($this->errno)");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -239,8 +247,54 @@ class RemiseCheque
|
||||
}
|
||||
|
||||
return $this->errno;
|
||||
}
|
||||
/**
|
||||
\brief Mets a jour le montant total
|
||||
\return int, 0 en cas de succes
|
||||
*/
|
||||
function UpdateAmount()
|
||||
{
|
||||
$this->errno = 0;
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "SELECT sum(amount) ";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank";
|
||||
$sql.= " WHERE fk_bordereau = $this->id;";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ( $resql )
|
||||
{
|
||||
$row = $this->db->fetch_row($resql);
|
||||
$total = $row[0];
|
||||
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque";
|
||||
$sql.= " SET amount='$total'";
|
||||
$sql.= " WHERE rowid='".$this->id."';";
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
$this->errno = -31;
|
||||
dolibarr_syslog("RemiseCheque::UpdateAmount ERREUR UPDATE ($this->errno)");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errno = -33;
|
||||
dolibarr_syslog("RemiseCheque::UpdateAmount ERREUR SELECT ($this->errno)");
|
||||
}
|
||||
|
||||
if ($this->errno === 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
dolibarr_syslog("RemiseCheque::UpdateAmount ROLLBACK ($this->errno)");
|
||||
}
|
||||
|
||||
return $this->errno;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user