Task #4773 : Gestion des paiements fournisseur
This commit is contained in:
parent
b33e5285a0
commit
cc0939ecde
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,9 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
|
||||
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
|
||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||
*
|
||||
* 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
|
||||
@ -31,242 +32,409 @@
|
||||
*/
|
||||
|
||||
|
||||
require("./pre.inc.php");
|
||||
require("./paiementfourn.class.php");
|
||||
require('./pre.inc.php');
|
||||
require('./paiementfourn.class.php');
|
||||
|
||||
$langs->load("bills");
|
||||
$langs->load("banks");
|
||||
$langs->load('bills');
|
||||
$langs->load('banks');
|
||||
|
||||
$facid=isset($_GET['facid'])?$_GET['facid']:$_POST['facid'];
|
||||
$action=isset($_GET['action'])?$_GET['action']:$_POST['action'];
|
||||
|
||||
$facid=isset($_GET["facid"])?$_GET["facid"]:$_POST["facid"];
|
||||
$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
|
||||
|
||||
$page=$_GET["page"];
|
||||
$sortorder=$_GET["sortorder"];
|
||||
$sortfield=$_GET["sortfield"];
|
||||
$sortfield = isset($_GET['sortfield'])?$_GET['sortfield']:$_POST['sortfield'];
|
||||
$sortorder = isset($_GET['sortorder'])?$_GET['sortorder']:$_POST['sortorder'];
|
||||
$page=isset($_GET['page'])?$_GET['page']:$_POST['page'];
|
||||
|
||||
|
||||
/*
|
||||
* Sécurité accés client
|
||||
*/
|
||||
if ($user->societe_id > 0)
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
$action = '';
|
||||
$socidp = $user->societe_id;
|
||||
}
|
||||
/*
|
||||
*
|
||||
* Actions
|
||||
*/
|
||||
if ($action == 'add') {
|
||||
$paiementfourn = new PaiementFourn($db);
|
||||
if ($action == 'add_paiement')
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
$paiementfourn->facid = $facid;
|
||||
$paiementfourn->facnumber = $_POST['facnumber'];
|
||||
$paiementfourn->datepaye = $db->idate(mktime(12, 0 , 0,
|
||||
$_POST["remonth"],
|
||||
$_POST["reday"],
|
||||
$_POST["reyear"]));
|
||||
$paiementfourn->amount = $_POST['amount'];
|
||||
$paiementfourn->accountid = $_POST['accountid'];
|
||||
$paiementfourn->societe = $_POST['societe'];
|
||||
$paiementfourn->paiementid = $_POST['paiementid'];
|
||||
$paiementfourn->num_paiement = $_POST['num_paiement'];
|
||||
$paiementfourn->note = $_POST['note'];
|
||||
$datepaye = $db->idate(mktime(12, 0 , 0,
|
||||
$_POST['remonth'],
|
||||
$_POST['reday'],
|
||||
$_POST['reyear']));
|
||||
$paiement_id = 0;
|
||||
$total = 0;
|
||||
// Génère tableau des montants amounts
|
||||
$amounts = array();
|
||||
foreach ($_POST as $key => $value)
|
||||
{
|
||||
if (substr($key,0,7) == 'amount_')
|
||||
{
|
||||
$other_facid = substr($key,7);
|
||||
$amounts[$other_facid] = $_POST[$key];
|
||||
$total = $total + $amounts[$other_facid];
|
||||
}
|
||||
}
|
||||
|
||||
if ( $paiementfourn->create($user) )
|
||||
{
|
||||
Header("Location: fiche.php?facid=$facid");
|
||||
}
|
||||
// Effectue les vérifications des parametres
|
||||
if ($_POST['paiementid'] <= 0)
|
||||
{
|
||||
$fiche_erreur_message = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->trans('PaymentMode')).'</div>';
|
||||
$error++;
|
||||
}
|
||||
|
||||
$action = '';
|
||||
if ($conf->banque->enabled)
|
||||
{
|
||||
// Si module bank actif, un compte est obligatoire lors de la saisie
|
||||
// d'un paiement
|
||||
if (! $_POST['accountid'])
|
||||
{
|
||||
$fiche_erreur_message = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->trans('AccountToCredit')).'</div>';
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($total <= 0)
|
||||
{
|
||||
$fiche_erreur_message = '<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->trans('Amount')).'</div>';
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
// Creation de la ligne paiement
|
||||
$paiement = new PaiementFourn($db);
|
||||
$paiement->datepaye = $datepaye;
|
||||
$paiement->amounts = $amounts; // Tableau de montant
|
||||
$paiement->paiementid = $_POST['paiementid'];
|
||||
$paiement->num_paiement = $_POST['num_paiement'];
|
||||
$paiement->note = $_POST['comment'];
|
||||
|
||||
$paiement_id = $paiement->create($user);
|
||||
if ($paiement_id > 0)
|
||||
{
|
||||
if ($conf->banque->enabled)
|
||||
{
|
||||
// Insertion dans llx_bank
|
||||
$label = 'Règlement fournisseur';
|
||||
$acc = new Account($db, $_POST['accountid']);
|
||||
//paiementid contient "CHQ ou VIR par exemple"
|
||||
$bank_line_id = $acc->addline($paiement->datepaye,
|
||||
$paiement->paiementid,
|
||||
$label,
|
||||
0.0 - $paiement->total,
|
||||
$paiement->num_paiement,
|
||||
'',
|
||||
$user);
|
||||
|
||||
// Mise a jour fk_bank dans llx_paiement.
|
||||
// On connait ainsi le paiement qui a généré l'écriture bancaire
|
||||
if ($bank_line_id > 0)
|
||||
{
|
||||
$paiement->update_fk_bank($bank_line_id);
|
||||
// Mise a jour liens (pour chaque facture concernées par le paiement)
|
||||
foreach ($paiement->amounts as $key => $value)
|
||||
{
|
||||
$facid = $key;
|
||||
$fac = new FactureFournisseur($db);
|
||||
$fac->fetch($facid);
|
||||
$fac->fetch_fournisseur();
|
||||
$acc->add_url_line($bank_line_id,
|
||||
$paiement_id,
|
||||
DOL_URL_ROOT.'/fourn/paiement/fiche.php?id=',
|
||||
'(paiement)',
|
||||
'payment');
|
||||
$acc->add_url_line($bank_line_id,
|
||||
$fac->fournisseur->id,
|
||||
DOL_URL_ROOT.'/fourn/fiche.php?socid=',
|
||||
$fac->fournisseur->nom,
|
||||
'company');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$paiement->error;
|
||||
$error++;
|
||||
}
|
||||
|
||||
if ($error == 0)
|
||||
{
|
||||
$loc = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$paiement_id;
|
||||
$db->commit();
|
||||
Header('Location: '.$loc);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Affichage
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
if ($action == 'create')
|
||||
$html=new Form($db);
|
||||
|
||||
if ($fiche_erreur_message)
|
||||
{
|
||||
print '<tr><td colspan="3" align="center">'.$fiche_erreur_message.'</td></tr>';
|
||||
}
|
||||
|
||||
$sql = "SELECT s.nom,s.idp, f.amount, f.total_ttc, f.facnumber";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as f WHERE f.fk_soc = s.idp";
|
||||
$sql .= " AND f.rowid = $facid";
|
||||
if ($action == 'create' || $action == 'add_paiement')
|
||||
{
|
||||
$facture = new FactureFournisseur($db);
|
||||
$facture->fetch($facid);
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
if ($num)
|
||||
$sql = 'SELECT s.nom,s.idp, f.amount, f.total_ttc as total, f.facnumber';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f WHERE f.fk_soc = s.idp';
|
||||
$sql .= ' AND f.rowid = '.$facid;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$total = $obj->total_ttc;
|
||||
|
||||
print_titre($langs->trans("DoPayment"));
|
||||
print '<form action="paiement.php?facid='.$facid.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print "<tr class=\"liste_titre\"><td colspan=\"3\">".$langs->trans("Bill")."</td>";
|
||||
|
||||
print '<tr><td>'.$langs->trans("Ref").' :</td><td colspan="2">';
|
||||
print '<a href="fiche.php?facid='.$facid.'">'.$obj->facnumber.'</a></td></tr>';
|
||||
print "<tr><td>".$langs->trans("Company")." :</td><td colspan=\"2\">$obj->nom</td></tr>";
|
||||
|
||||
print "<tr><td>".$langs->trans("AmountTTC")." :</td><td colspan=\"2\">".price($obj->total_ttc).' '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
|
||||
$sql = "SELECT sum(p.amount) FROM ".MAIN_DB_PREFIX."paiementfourn as p WHERE p.fk_facture_fourn = $facid;";
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$sumpayed = $db->result(0,0);
|
||||
$db->free();
|
||||
}
|
||||
print '<tr><td>'.$langs->trans("AlreadyPayed").' :</td><td colspan="2"><b>'.price($sumpayed).'</b> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
|
||||
print "<tr class=\"liste_titre\"><td colspan=\"3\">".$langs->trans("Payment")."</td>";
|
||||
|
||||
print "<input type=\"hidden\" name=\"facid\" value=\"$facid\">";
|
||||
print "<input type=\"hidden\" name=\"facnumber\" value=\"$obj->facnumber\">";
|
||||
print "<input type=\"hidden\" name=\"socid\" value=\"$obj->idp\">";
|
||||
print "<input type=\"hidden\" name=\"societe\" value=\"$obj->nom\">";
|
||||
|
||||
$html = new Form($db);
|
||||
|
||||
print "<tr><td>".$langs->trans("Date")." :</td><td>";
|
||||
$html->select_date();
|
||||
print "</td>";
|
||||
|
||||
print '<td>'.$langs->trans("Comments").' :</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Type").' :</td>';
|
||||
print '<td><select name="paiementid">';
|
||||
|
||||
$sql = "SELECT id, libelle FROM ".MAIN_DB_PREFIX."c_paiement ORDER BY id";
|
||||
|
||||
if ($db->query($sql))
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objopt = $db->fetch_object();
|
||||
print "<option value=\"$objopt->id\">$objopt->libelle</option>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
print "</select><br>";
|
||||
print "</td>\n";
|
||||
|
||||
print "<td rowspan=\"4\">";
|
||||
print '<textarea name="comment" wrap="soft" cols="40" rows="4"></textarea></td></tr>';
|
||||
|
||||
print "<tr><td>".$langs->trans("Number").":</td><td><input name=\"num_paiement\" type=\"text\"><br><em>N° du chèque ou du virement</em></td></tr>\n";
|
||||
|
||||
print "<tr><td>".$langs->trans("Account").":</td><td><select name=\"accountid\"><option value=\"\">-</option>\n";
|
||||
$sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."bank_account ORDER BY rowid";
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objopt = $db->fetch_object();
|
||||
print '<option value="'.$objopt->rowid.'"';
|
||||
if (defined("FACTURE_RIB_NUMBER") && FACTURE_RIB_NUMBER == $objopt->rowid)
|
||||
$num = $db->num_rows($resql);
|
||||
if ($num)
|
||||
{
|
||||
print ' selected="true"';
|
||||
$obj = $db->fetch_object($resql);
|
||||
$total = $obj->total;
|
||||
|
||||
print_titre($langs->trans('DoPayment'));
|
||||
print '<form action="paiement.php" method="post">';
|
||||
print '<input type="hidden" name="action" value="add_paiement">';
|
||||
print '<input type="hidden" name="facid" value="'.$facid.'">';
|
||||
print '<input type="hidden" name="facnumber" value="'.$obj->facnumber.'">';
|
||||
print '<input type="hidden" name="socid" value="'.$obj->idp.'">';
|
||||
print '<input type="hidden" name="societe" value="'.$obj->nom.'">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans('Payment').'</td>';
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.$obj->nom.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Date').'</td><td>';
|
||||
if (!empty($_POST['remonth']) && !empty($_POST['reday']) && !empty($_POST['reyear']))
|
||||
$sel_date=mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
|
||||
else
|
||||
$sel_date='';
|
||||
$html->select_date($sel_date);
|
||||
print '</td>';
|
||||
print '<td>'.$langs->trans('Comments').'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>';
|
||||
$html->select_types_paiements(empty($_POST['paiementid'])?'':$_POST['paiementid'],'paiementid');
|
||||
print '</td>';
|
||||
print '<td rowspan="3" valign="top">';
|
||||
print '<textarea name="comment" wrap="soft" cols="40" rows="4">'.(empty($_POST['comment'])?'':$_POST['comment']).'</textarea></td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Numero').'</td><td><input name="num_paiement" type="text" value="'.(empty($_POST['num_paiement'])?'':$_POST['num_paiement']).'"><br><em>Numéro du chèque / virement</em></td></tr>';
|
||||
if ($conf->banque->enabled)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans('Account').'</td><td>';
|
||||
$html->select_comptes(empty($_POST['accountid'])?(defined('FACTURE_RIB_NUMBER')?FACTURE_RIB_NUMBER:''):$_POST['accountid'],'accountid',0,'',1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td colspan="2"> </td></tr>';
|
||||
}
|
||||
/*
|
||||
* Autres factures impayées
|
||||
*/
|
||||
$sql = 'SELECT f.rowid as facid,f.facnumber,f.total_ttc,'.$db->pdate('f.datef').' as df';
|
||||
$sql .= ', sum(pf.amount) as am';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
|
||||
$sql .= ' WHERE f.fk_soc = '.$facture->socidp;
|
||||
$sql .= ' AND f.paye = 0';
|
||||
$sql .= ' AND f.fk_statut = 1'; // Statut=0 => non validée, Statut=2 => annulée
|
||||
$sql .= ' GROUP BY f.facnumber';
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
if ($num > 0)
|
||||
{
|
||||
$i = 0;
|
||||
print '<tr><td colspan="3">';
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans('Bill').'</td><td align="center">'.$langs->trans('Date').'</td>';
|
||||
print '<td align="right">'.$langs->trans('AmountTTC').'</td>';
|
||||
print '<td align="right">'.$langs->trans('Paied').'</td>';
|
||||
print '<td align="right">'.$langs->trans('RemainderToPay').'</td>';
|
||||
print '<td align="center">'.$langs->trans('Amount').'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$var=True;
|
||||
$total=0;
|
||||
$totalrecu=0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td><a href="fiche.php?facid='.$objp->facid.'">'.img_object($langs->trans('ShowBill'),'bill').' '.$objp->facnumber;
|
||||
print '</a></td>';
|
||||
if ($objp->df > 0 )
|
||||
{
|
||||
print '<td align="center">';
|
||||
print dolibarr_print_date($objp->df).'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center"><b>!!!</b></td>';
|
||||
}
|
||||
print '<td align="right">'.price($objp->total_ttc).'</td>';
|
||||
print '<td align="right">'.price($objp->am).'</td>';
|
||||
print '<td align="right">'.price($objp->total_ttc - $objp->am).'</td>';
|
||||
print '<td align="center">';
|
||||
$namef = 'amount_'.$objp->facid;
|
||||
print '<input type="text" size="8" name="'.$namef.'">';
|
||||
print "</td></tr>\n";
|
||||
$total+=$objp->total;
|
||||
$total_ttc+=$objp->total_ttc;
|
||||
$totalrecu+=$objp->am;
|
||||
$i++;
|
||||
}
|
||||
if ($i > 1)
|
||||
{
|
||||
// Print total
|
||||
print '<tr class="liste_total">';
|
||||
print '<td colspan="2" align="left">'.$langs->trans('TotalTTC').':</td>';
|
||||
print '<td align="right"><b>'.price($total_ttc).'</b></td>';
|
||||
print '<td align="right"><b>'.price($totalrecu).'</b></td>';
|
||||
print '<td align="right"><b>'.price($total_ttc - $totalrecu).'</b></td>';
|
||||
print '<td align="center"> </td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
print "</table></td></tr>\n";
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
print '>'.$objopt->label.'</option>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
print "</select>";
|
||||
print "</td></tr>\n";
|
||||
|
||||
print "<tr><td valign=\"top\">".$langs->trans("RemainderToPay")." :</td><td><b>".price($total - $sumpayed).'</b> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("AmountTTC").' :</td>';
|
||||
print '<td><input name="amount" type="text" value="'.price($total - $sumpayed).'"></td></tr>';
|
||||
print '<tr><td colspan="3" align="center"><input type="submit" value="'.$langs->trans("Save").'"></td></tr>';
|
||||
print "</form>\n";
|
||||
print "</table>\n";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Affichage liste
|
||||
*/
|
||||
if ($action == '') {
|
||||
if (! $_GET['action'] && ! $_POST['action'])
|
||||
{
|
||||
if ($page == -1) $page = 0 ;
|
||||
$limit = $conf->liste_limit;
|
||||
$offset = $limit * $page ;
|
||||
|
||||
if ($page == -1)
|
||||
{
|
||||
$page = 0 ;
|
||||
}
|
||||
$limit = $conf->liste_limit;
|
||||
$offset = $limit * $page ;
|
||||
if (! $sortorder) $sortorder='DESC';
|
||||
if (! $sortfield) $sortfield='p.datep';
|
||||
|
||||
$sql = "SELECT p.rowid, ".$db->pdate("p.datep")." as dp, p.amount, f.amount as fa_amount, f.facnumber, s.nom";
|
||||
$sql .=", f.rowid as facid, c.libelle as paiement_type, p.num_paiement";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p, ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."c_paiement as c, ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " WHERE p.fk_facture_fourn = f.rowid AND p.fk_paiement = c.id AND s.idp = f.fk_soc";
|
||||
|
||||
if ($socidp)
|
||||
{
|
||||
$sql .= " AND f.fk_soc = $socidp";
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY datep DESC";
|
||||
$sql .= $db->plimit($limit + 1 ,$offset);
|
||||
$result = $db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$i = 0;
|
||||
$var=True;
|
||||
|
||||
print_barre_liste($langs->trans("Payments"), $page, "paiement.php","&socidp=$socidp",$sortfield,$sortorder,'',$num);
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Ref").'</td>';
|
||||
print '<td>'.$langs->trans("Bill").'</td>';
|
||||
print '<td>'.$langs->trans("Company").'</td>';
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.$langs->trans("Type").'</td>';
|
||||
print '<td align="right">'.$langs->trans("AmountTTC").'</td>';
|
||||
print "<td> </td></tr>";
|
||||
|
||||
while ($i < min($num,$limit))
|
||||
$sql = 'SELECT p.rowid, '.$db->pdate('p.datep').' as dp, p.amount';
|
||||
$sql .= ', f.amount as fa_amount, f.facnumber, s.nom';
|
||||
$sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement';
|
||||
$sql .= ', ba.rowid as bid, ba.label';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn ';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.idp = f.fk_soc';
|
||||
$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 ($socidp)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print "<td><a href=\"".DOL_URL_ROOT."/fourn/paiement/fiche.php?id=$objp->rowid\">".img_object($langs->trans("ShowPayment"),"payment").'</a>';
|
||||
|
||||
print " <a href=\"".DOL_URL_ROOT."/fourn/paiement/fiche.php?id=$objp->rowid\">".$objp->rowid.'</a></td>';
|
||||
|
||||
|
||||
print "<td><a href=\"".DOL_URL_ROOT."/fourn/facture/fiche.php?facid=$objp->facid\">".img_object($langs->trans("ShowBill"),"bill").' '.$objp->facnumber.'</a></td>';
|
||||
print '<td>'.$objp->nom.'</td>';
|
||||
print "<td>".dolibarr_print_date($objp->dp)."</td>\n";
|
||||
print "<td>$objp->paiement_type $objp->num_paiement</td>\n";
|
||||
print '<td align="right">'.price($objp->amount).'</td><td> </td>';
|
||||
print "</tr>";
|
||||
$i++;
|
||||
$sql .= ' WHERE f.fk_soc = '.$socidp;
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
$sql .= ' ORDER BY '.$sortfield.' '.$sortorder;
|
||||
$sql .= $db->plimit($limit + 1 ,$offset);
|
||||
/*
|
||||
$sql = "SELECT p.rowid,".$db->pdate("p.datep")." as dp, p.amount,";
|
||||
$sql.= " p.statut, p.num_paiement,";
|
||||
$sql.= " c.libelle as paiement_type,";
|
||||
$sql.= " ba.rowid as bid, ba.label";
|
||||
$sql.= " FROM ".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 ($socidp)
|
||||
{
|
||||
$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";
|
||||
if ($socidp)
|
||||
{
|
||||
$sql.= " AND f.fk_soc = ".$socidp;
|
||||
}
|
||||
if ($_GET["search_montant"])
|
||||
{
|
||||
$sql .=" AND p.amount=".ereg_replace(",",".",$_GET["search_montant"]);
|
||||
}
|
||||
*/
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
$var=True;
|
||||
|
||||
print_barre_liste($langs->trans('Payments'), $page, 'paiement.php','',$sortfield,$sortorder,'',$num);
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans('Ref').'</td>';
|
||||
print_liste_field_titre($langs->trans('Bill'),'paiement.php','facnumber','','','',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Company'),'paiement.php','s.nom','','','',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Date'),'paiement.php','dp','','','',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Type'),'paiement.php','libelle','','','',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Account'),'paiement.php','ba.label','','','',$sortfield);
|
||||
print_liste_field_titre($langs->trans('AmountTTC'),'paiement.php','fa_amount','','','align="right"',$sortfield);
|
||||
print '<td> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans('ShowPayment'),'payment').'</a>';
|
||||
print ' <a href="'.DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$objp->rowid.'">'.$objp->rowid.'</a></td>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$objp->facid.'">'.img_object($langs->trans('ShowBill'),'bill').' '.$objp->facnumber.'</a></td>';
|
||||
print '<td>'.$objp->nom.'</td>';
|
||||
print '<td>'.dolibarr_print_date($objp->dp)."</td>\n";
|
||||
print '<td>'.$objp->paiement_type.' '.$objp->num_paiement."</td>\n";
|
||||
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><td> </td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||
*
|
||||
* 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
|
||||
@ -18,215 +19,393 @@
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file htdocs/fourn/facture/paiementfourn.class.php
|
||||
/*!
|
||||
\file htdocs/fourn/facture/paiementfourn.class.php
|
||||
\ingroup fournisseur, facture
|
||||
\brief Page de création de paiement factures fournisseurs
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/compta/bank/account.class.php');
|
||||
|
||||
/**
|
||||
\class PaiementFourn
|
||||
\brief Classe permettant la gestion des paiements des factures fournisseurs
|
||||
*/
|
||||
|
||||
class PaiementFourn
|
||||
{
|
||||
var $id;
|
||||
var $db;
|
||||
var $facid;
|
||||
var $facnumber;
|
||||
var $datepaye;
|
||||
var $amount;
|
||||
var $accountid;
|
||||
var $paiementid; // Cette variable contient le type de paiement, 7 pour CHQ, etc... (nom pas tres bien choisi)
|
||||
var $num_paiement;
|
||||
var $note;
|
||||
var $societe;
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function PaiementFourn($DB)
|
||||
{
|
||||
$this->db = $DB ;
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function fetch($id,$user)
|
||||
{
|
||||
/*
|
||||
*/
|
||||
$error = 0;
|
||||
var $id;
|
||||
var $ref;
|
||||
var $facid;
|
||||
var $datepaye;
|
||||
var $amount;
|
||||
var $total;
|
||||
var $author;
|
||||
var $paiementid; // Type de paiement. Stocké dans fk_paiement
|
||||
// de llx_paiement qui est lié aux types de
|
||||
//paiement de llx_c_paiement
|
||||
var $num_paiement; // Numéro du CHQ, VIR, etc...
|
||||
var $bank_account; // Id compte bancaire du paiement
|
||||
var $bank_line; // Id de la ligne d'écriture bancaire
|
||||
var $note;
|
||||
// fk_paiement dans llx_paiement est l'id du type de paiement (7 pour CHQ, ...)
|
||||
// fk_paiement dans llx_paiement_facture est le rowid du paiement
|
||||
|
||||
|
||||
$sql = "SELECT fk_facture_fourn, datec, datep, amount, fk_user_author, fk_paiement, num_paiement, note";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn";
|
||||
$sql .= " WHERE rowid = ".$id.";";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
var $db;
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resl);
|
||||
if ($num > 0)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
* \param DB handler accès base de données
|
||||
*/
|
||||
|
||||
$this->facture_id = $obj->fk_facture_fourn;
|
||||
$this->date = $obj->datep;
|
||||
$this->montant = $obj->amount;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "$sql";
|
||||
$error = 1;
|
||||
}
|
||||
|
||||
return $error;
|
||||
|
||||
}
|
||||
/*
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* \brief Information sur l'objet
|
||||
* \param id id du paiement dont il faut afficher les infos
|
||||
*/
|
||||
|
||||
function info($id)
|
||||
{
|
||||
$sql = "SELECT c.rowid, ".$this->db->pdate("datec")." as datec, fk_user_author";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as c";
|
||||
$sql .= " WHERE c.rowid = $id";
|
||||
|
||||
if ($this->db->query($sql))
|
||||
function PaiementFourn($DB)
|
||||
{
|
||||
if ($this->db->num_rows())
|
||||
{
|
||||
$obj = $this->db->fetch_object();
|
||||
|
||||
$this->id = $obj->idp;
|
||||
|
||||
if ($obj->fk_user_creat) {
|
||||
$cuser = new User($this->db, $obj->fk_user_creat);
|
||||
$cuser->fetch();
|
||||
$this->user_creation = $cuser;
|
||||
}
|
||||
|
||||
if ($obj->fk_user_modif) {
|
||||
$muser = new User($this->db, $obj->fk_user_modif);
|
||||
$muser->fetch();
|
||||
$this->user_modification = $muser;
|
||||
}
|
||||
|
||||
$this->date_creation = $obj->datec;
|
||||
$this->date_modification = $obj->tms;
|
||||
|
||||
}
|
||||
$this->db->free();
|
||||
|
||||
$this->db = $DB ;
|
||||
}
|
||||
else
|
||||
|
||||
/**
|
||||
* \brief Récupère l'objet paiement
|
||||
* \param id id du paiement a récupérer
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function fetch($id)
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
$sql = 'SELECT p.rowid,'.$this->db->pdate('p.datep').' as dp, p.amount, p.statut, p.fk_bank';
|
||||
$sql .=', c.libelle as paiement_type';
|
||||
$sql .= ', p.num_paiement, p.note, b.fk_account';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as p, '.MAIN_DB_PREFIX.'c_paiement as c ';
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid ';
|
||||
$sql .= ' WHERE p.fk_paiement = c.id';
|
||||
$sql .= ' AND p.rowid = '.$id;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
if ($num > 0)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
$this->date = $obj->dp;
|
||||
$this->numero = $obj->num_paiement;
|
||||
$this->bank_account = $obj->fk_account;
|
||||
$this->bank_line = $obj->fk_bank;
|
||||
$this->montant = $obj->amount;
|
||||
$this->note = $obj->note;
|
||||
$this->type_libelle = $obj->paiement_type;
|
||||
$this->statut = $obj->statut;
|
||||
$error = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = -2;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
$error = -1;
|
||||
}
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
/*
|
||||
* Insertion dans la base
|
||||
*/
|
||||
|
||||
$this->amount = ereg_replace(",",".",$this->amount);
|
||||
$this->amount = ereg_replace(" ","",$this->amount);
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiementfourn (fk_facture_fourn, datec, datep, amount, fk_user_author, fk_paiement, num_paiement, note)";
|
||||
$sql .= " VALUES ('$this->facid', now(), '$this->datepaye', '$this->amount', '$user->id', '$this->paiementid', '$this->num_paiement', '$this->note')";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
/**
|
||||
* \brief Création du paiement en base
|
||||
* \param user object utilisateur qui crée
|
||||
* \return int id du paiement crée, < 0 si erreur
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
$sql_err = 0;
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiementfourn");
|
||||
|
||||
$label = "Règlement facture $this->facnumber - $this->societe";
|
||||
|
||||
$account = new Account($this->db, $this->accountid);
|
||||
$this->db->begin();
|
||||
|
||||
$result = $account->addline($this->datepaye,
|
||||
$this->paiementid,
|
||||
$label,
|
||||
-$this->amount,
|
||||
$this->num_paiement);
|
||||
$this->total = 0.0;
|
||||
foreach ($this->amounts as $key => $value)
|
||||
{
|
||||
$val = price2num($value);
|
||||
if (is_numeric($val))
|
||||
{
|
||||
$val = price2num(round($val, 2));
|
||||
$this->total += $val;
|
||||
}
|
||||
$this->amounts[$key] = $val;
|
||||
}
|
||||
$this->total = price2num($this->total);
|
||||
if ($this->total <> 0) /* On accepte les montants négatifs pour les avoirs ??? */
|
||||
{
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn (datec, datep, amount, fk_paiement, num_paiement, note, fk_user_author)';
|
||||
$sql .= ' VALUES (now(), '.$this->datepaye.', \''.$this->total.'\', '.$this->paiementid.', \''.$this->num_paiement.'\', \''.$this->note.'\', '.$user->id.')';
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'paiementfourn');
|
||||
foreach ($this->amounts as $key => $amount)
|
||||
{
|
||||
$facid = $key;
|
||||
if (is_numeric($amount) && $amount <> 0)
|
||||
{
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn_facturefourn (fk_facturefourn, fk_paiementfourn, amount)';
|
||||
$sql .= ' VALUES ('.$facid.','. $this->id.',\''.$amount.'\')';
|
||||
if (! $this->db->query($sql) )
|
||||
{
|
||||
dolibarr_syslog('Paiement::Create Erreur INSERT dans paiement_facture '.$facid);
|
||||
$sql_err++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog('PaiementFourn::Create Montant non numérique');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog('PaiementFourn::Create Erreur INSERT dans paiementfourn');
|
||||
$sql_err++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Mise a jour fk_bank dans llx_paiement_fourn
|
||||
if ($result)
|
||||
{
|
||||
$this->bankid = $this->db->last_insert_id(MAIN_DB_PREFIX."bank");
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."paiementfourn SET fk_bank=$this->bankid WHERE rowid=$this->id";
|
||||
$result = $this->db->query($sql);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "$sql";
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
if ( $this->total <> 0 && $sql_err == 0 ) // On accepte les montants négatifs
|
||||
{
|
||||
$this->db->commit();
|
||||
dolibarr_syslog('PaiementFourn::Create Ok Total = '.$this->total);
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
dolibarr_syslog('PaiementFourn::Create Erreur');
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Affiche la liste des modes de paiement possible
|
||||
* \param name nom du champ select
|
||||
* \param filtre filtre sur un sens de paiement particulier, norme ISO (CRDT=Mode propre à un crédit, DBIT=mode propre à un débit)
|
||||
* \param id ???
|
||||
*/
|
||||
function select($name, $filtre='', $id='')
|
||||
{
|
||||
$form = new Form($this->db);
|
||||
/**
|
||||
* \brief Affiche la liste des modes de paiement possible
|
||||
* \param name nom du champ select
|
||||
* \param filtre filtre sur un sens de paiement particulier, norme ISO (CRDT=Mode propre à un crédit, DBIT=mode propre à un débit)
|
||||
* \param id ???
|
||||
*/
|
||||
function select($name, $filtre='', $id='')
|
||||
{
|
||||
$form = new Form($this->db);
|
||||
|
||||
if ($filtre == 'CRDT' || $filtre == 'crédit')
|
||||
{
|
||||
$sql = "SELECT id, libelle FROM ".MAIN_DB_PREFIX."c_paiement WHERE active=1 AND type IN (0,2) ORDER BY libelle";
|
||||
}
|
||||
elseif ($filtre == 'DBIT' || $filtre == 'débit')
|
||||
{
|
||||
$sql = "SELECT id, libelle FROM ".MAIN_DB_PREFIX."c_paiement WHERE active=1 AND type IN (1,2) ORDER BY libelle";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT id, libelle FROM ".MAIN_DB_PREFIX."c_paiement WHERE active=1 ORDER BY libelle";
|
||||
}
|
||||
$form->select($name, $sql, $id);
|
||||
}
|
||||
if ($filtre == 'CRDT' || $filtre == 'crédit')
|
||||
{
|
||||
$sql = 'SELECT id, libelle FROM '.MAIN_DB_PREFIX.'c_paiement WHERE active=1 AND type IN (0,2) ORDER BY libelle';
|
||||
}
|
||||
elseif ($filtre == 'DBIT' || $filtre == 'débit')
|
||||
{
|
||||
$sql = 'SELECT id, libelle FROM '.MAIN_DB_PREFIX.'c_paiement WHERE active=1 AND type IN (1,2) ORDER BY libelle';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'SELECT id, libelle FROM '.MAIN_DB_PREFIX.'c_paiement WHERE active=1 ORDER BY libelle';
|
||||
}
|
||||
$form->select($name, $sql, $id);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function delete($id)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementfourn WHERE rowid = $id";
|
||||
|
||||
return $this->db->query($sql);
|
||||
}
|
||||
/**
|
||||
* \brief Supprime un paiement ainsi que les lignes qu'il a généré dans comptes
|
||||
* Si le paiement porte sur un écriture compte qui est rapprochée, on refuse
|
||||
* Si le paiement porte sur au moins une facture à "payée", on refuse
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function delete()
|
||||
{
|
||||
$bank_line_id = $this->bank_line;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Vérifier si paiement porte pas sur une facture à l'état payée
|
||||
// Si c'est le cas, on refuse la suppression
|
||||
$billsarray=$this->getBillsArray('paye=1');
|
||||
if (is_array($billsarray))
|
||||
{
|
||||
if (sizeof($billsarray))
|
||||
{
|
||||
$this->error='Impossible de supprimer un paiement portant sur au moins une facture à l\'état payé';
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
|
||||
// Vérifier si paiement ne porte pas sur ecriture bancaire rapprochée
|
||||
// Si c'est le cas, on refuse le paiement
|
||||
if ($bank_line_id)
|
||||
{
|
||||
$accline = new AccountLine($this->db,$bank_line_id);
|
||||
$accline->fetch($bank_line_id);
|
||||
if ($accline->rappro)
|
||||
{
|
||||
$this->error='Impossible de supprimer un paiement qui a généré une écriture qui a été rapprochée';
|
||||
$this->db->rollback();
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
|
||||
// Efface la ligne de paiement (dans paiement_facture et paiement)
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn';
|
||||
$sql.= ' WHERE fk_paiementfourn = '.$this->id;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiementfourn';
|
||||
$sql.= ' WHERE rowid = '.$this->id;
|
||||
$result = $this->db->query($sql);
|
||||
if (! $result)
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->db->rollback();
|
||||
return -3;
|
||||
}
|
||||
|
||||
// Supprimer l'écriture bancaire si paiement lié à écriture
|
||||
if ($bank_line_id)
|
||||
{
|
||||
$acc = new Account($this->db);
|
||||
$result=$acc->deleteline($bank_line_id);
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->error=$acc->error;
|
||||
$this->db->rollback();
|
||||
return -4;
|
||||
}
|
||||
}
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error;
|
||||
$this->db->rollback();
|
||||
return -5;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Mise a jour du lien entre le paiement et la ligne générée dans llx_bank
|
||||
* \param id_bank Id compte bancaire
|
||||
*/
|
||||
function update_fk_bank($id_bank)
|
||||
{
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'paiementfourn set fk_bank = '.$id_bank;
|
||||
$sql.= ' WHERE rowid = '.$this->id;
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Valide le paiement
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function valide()
|
||||
{
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'paiementfourn SET statut = 1 WHERE rowid = '.$this->id;
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog('Paiement::Valide Error -1');
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Information sur l'objet
|
||||
* \param id id du paiement dont il faut afficher les infos
|
||||
*/
|
||||
function info($id)
|
||||
{
|
||||
$sql = 'SELECT c.rowid, '.$this->db->pdate('datec').' as datec, fk_user_author';
|
||||
$sql .= ', '.$this->db->pdate('tms').' as tms';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as c';
|
||||
$sql .= ' WHERE c.rowid = '.$id;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
if ($num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$this->id = $obj->idp;
|
||||
if ($obj->fk_user_creat)
|
||||
{
|
||||
$cuser = new User($this->db, $obj->fk_user_creat);
|
||||
$cuser->fetch();
|
||||
$this->user_creation = $cuser;
|
||||
}
|
||||
if ($obj->fk_user_modif)
|
||||
{
|
||||
$muser = new User($this->db, $obj->fk_user_modif);
|
||||
$muser->fetch();
|
||||
$this->user_modification = $muser;
|
||||
}
|
||||
$this->date_creation = $obj->datec;
|
||||
$this->date_modification = $obj->tms;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Retourne la liste des factures sur lesquels porte le paiement
|
||||
* \param filter Critere de filtre
|
||||
* \return array Tableau des id de factures
|
||||
*/
|
||||
function getBillsArray($filter='')
|
||||
{
|
||||
$sql = 'SELECT fk_facturefourn';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.'facture_fourn as f';
|
||||
$sql.= ' WHERE pf.fk_facturefourn = f.rowid AND fk_paiementfourn = '.$this->id;
|
||||
if ($filter) $sql.= ' AND '.$filter;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$i=0;
|
||||
$num=$this->db->num_rows($resql);
|
||||
$billsarray=array();
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$billsarray[$i]=$obj->fk_facture;
|
||||
$i++;
|
||||
}
|
||||
|
||||
return $billsarray;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dolibarr_syslog('PaiementFourn::getBillsArray Error '.$this->error.' - sql='.$sql);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@ -28,15 +28,15 @@
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require('./pre.inc.php');
|
||||
|
||||
$langs->load("suppliers");
|
||||
$langs->load("products");
|
||||
$langs->load("bills");
|
||||
$langs->load("orders");
|
||||
$langs->load("companies");
|
||||
$langs->load('suppliers');
|
||||
$langs->load('products');
|
||||
$langs->load('bills');
|
||||
$langs->load('orders');
|
||||
$langs->load('companies');
|
||||
|
||||
$socid = $_GET["socid"];
|
||||
$socid = $_GET['socid'];
|
||||
/*
|
||||
* Sécurité accés client
|
||||
*/
|
||||
@ -57,7 +57,7 @@ if ( $societe->fetch($socid) )
|
||||
$addons[0][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$socid;
|
||||
$addons[0][1] = $societe->nom;
|
||||
|
||||
llxHeader('',$langs->trans("SupplierCard").' : '.$societe->nom, $addons);
|
||||
llxHeader('',$langs->trans('SupplierCard').' : '.$societe->nom, $addons);
|
||||
|
||||
/*
|
||||
* Affichage onglets
|
||||
@ -65,49 +65,49 @@ if ( $societe->fetch($socid) )
|
||||
$h = 0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$socid;
|
||||
$head[$h][1] = $langs->trans("Company");
|
||||
$head[$h][1] = $langs->trans('Company');
|
||||
$h++;
|
||||
|
||||
if ($societe->client==1)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$socid;
|
||||
$head[$h][1] = $langs->trans("Customer");
|
||||
$head[$h][1] = $langs->trans('Customer');
|
||||
$h++;
|
||||
}
|
||||
if ($societe->client==2)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$socid;
|
||||
$head[$h][1] = $langs->trans("Prospect");
|
||||
$head[$h][1] = $langs->trans('Prospect');
|
||||
$h++;
|
||||
}
|
||||
if ($societe->fournisseur)
|
||||
{
|
||||
$hselected=$h;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$socid;
|
||||
$head[$h][1] = $langs->trans("Supplier");
|
||||
$head[$h][1] = $langs->trans('Supplier');
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ($conf->compta->enabled) {
|
||||
$langs->load("compta");
|
||||
$langs->load('compta');
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$socid;
|
||||
$head[$h][1] = $langs->trans("Accountancy");
|
||||
$head[$h][1] = $langs->trans('Accountancy');
|
||||
$h++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/socnote.php?socid='.$societe->id;
|
||||
$head[$h][1] = $langs->trans("Note");
|
||||
$head[$h][1] = $langs->trans('Note');
|
||||
$h++;
|
||||
|
||||
if ($user->societe_id == 0)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/docsoc.php?socid='.$societe->id;
|
||||
$head[$h][1] = $langs->trans("Documents");
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
$h++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$societe->id;
|
||||
$head[$h][1] = $langs->trans("Notifications");
|
||||
$head[$h][1] = $langs->trans('Notifications');
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $societe->nom);
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
/**
|
||||
\file htdocs/fourn/fournisseur.class.php
|
||||
\ingroup societe
|
||||
\ingroup fournisseur,societe
|
||||
\brief Fichier de la classe des fournisseurs
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||
*
|
||||
* 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
|
||||
@ -20,121 +21,226 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file htdocs/compta/paiement/fiche.php
|
||||
/**
|
||||
\file htdocs/fourn/paiement/fiche.php
|
||||
\ingroup facture
|
||||
\brief Onglet paiement d'un paiement
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
|
||||
require("./pre.inc.php");
|
||||
require('./pre.inc.php');
|
||||
|
||||
require(DOL_DOCUMENT_ROOT."/fourn/facture/paiementfourn.class.php");
|
||||
require(DOL_DOCUMENT_ROOT.'/fourn/facture/paiementfourn.class.php');
|
||||
|
||||
$user->getrights('facture');
|
||||
|
||||
$langs->load("bills");
|
||||
$langs->load("banks");
|
||||
$langs->load("companies");
|
||||
$langs->load('bills');
|
||||
$langs->load('banks');
|
||||
$langs->load('companies');
|
||||
|
||||
$mesg='';
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes' && $user->rights->facture->creer)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$paiement = new PaiementFourn($db);
|
||||
$paiement->fetch($_GET['id']);
|
||||
$result = $paiement->delete();
|
||||
if ($result > 0)
|
||||
{
|
||||
$db->commit();
|
||||
Header('Location: /fourn/facture/paiement.php');
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$paiement->error.'</div>';
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user->rights->facture->creer)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$paiement = new PaiementFourn($db);
|
||||
$paiement->id = $_GET['id'];
|
||||
if ( $paiement->valide() == 0 )
|
||||
{
|
||||
$db->commit();
|
||||
Header('Location: fiche.php?id='.$paiement->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$paiement->error.'</div>';
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Visualisation de la fiche
|
||||
*
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
$paiement = new PaiementFourn($db);
|
||||
$paiement->fetch($_GET['id']);
|
||||
|
||||
$html = new Form($db);
|
||||
|
||||
$h=0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$_GET['id'];
|
||||
$head[$h][1] = $langs->trans('Card');
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$_GET["id"];
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$h++;
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Payment").": ".$_GET["id"]);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$_GET['id'];
|
||||
$head[$h][1] = $langs->trans('Info');
|
||||
$h++;
|
||||
|
||||
|
||||
$facture = new FactureFournisseur($db);
|
||||
$paiement = new PaiementFourn($db);
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans('Payment').': '.$paiement->ref);
|
||||
|
||||
if ($paiement->fetch($_GET["id"], $user) == 0)
|
||||
/*
|
||||
* Confirmation de la suppression du paiement
|
||||
*/
|
||||
if ($_GET['action'] == 'delete')
|
||||
{
|
||||
$html = new Form($db);
|
||||
$html->form_confirm('fiche.php?id='.$paiement->id, 'Supprimer le paiement', 'Etes-vous sûr de vouloir supprimer ce paiement ?', 'confirm_delete');
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
$facture->fetch($paiement->facture_id);
|
||||
|
||||
/*
|
||||
* Confirmation de la suppression du paiement
|
||||
*
|
||||
*/
|
||||
if ($_GET["action"] == 'delete')
|
||||
{
|
||||
$html->form_confirm("fiche.php?id=$paiement->id","Supprimer le paiement","Etes-vous sûr de vouloir supprimer ce paiement ?","confirm_delete");
|
||||
print '<br>';
|
||||
|
||||
}
|
||||
|
||||
if ($_GET["action"] == 'valide')
|
||||
{
|
||||
$html->form_confirm("fiche.php?id=$paiement->id","Valider le paiement","Etes-vous sûr de vouloir valider ce paiment, auncune modification n'est possible une fois le paiement validé ?","confirm_valide");
|
||||
print '<br>';
|
||||
|
||||
}
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
print '<tr><td valign="top">';
|
||||
|
||||
if ($paiement->bank_account) {
|
||||
// Si compte renseigné, on affiche libelle
|
||||
$bank=new Account($db);
|
||||
$bank->fetch($paiement->bank_account);
|
||||
print $langs->trans("BankAccount").' : '.$bank->label.'<br>';
|
||||
}
|
||||
print $langs->trans("Date").' : '.dolibarr_print_date($paiement->date)."<br>";
|
||||
print $langs->trans("Bill").' : <a href="../facture/fiche.php?facid='.$facture->id.'">'.$facture->ref."</a><br>";
|
||||
print $langs->trans("Type").' : '.$paiement->type_libelle."<br>";
|
||||
if ($paiement->numero) { print $langs->trans("Numero").' : '.$paiement->numero."<br>"; }
|
||||
print $langs->trans("Amount").' : '.$paiement->montant." ".$conf->monnaie."<br>";
|
||||
print '</td></tr>';
|
||||
print "</table>";
|
||||
|
||||
print nl2br($paiement->note);
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
|
||||
print "<br></div>";
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET["action"] == '')
|
||||
/*
|
||||
* Confirmation de la validation du paiement
|
||||
*/
|
||||
if ($_GET['action'] == 'valide')
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?id='.$_GET["id"].'&action=valide">'.$langs->trans("Valid").'</a>';
|
||||
$html->form_confirm('fiche.php?id='.$paiement->id, 'Valider le paiement', 'Etes-vous sûr de vouloir valider ce paiment, auncune modification n\'est possible une fois le paiement validé ?', 'confirm_valide');
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
|
||||
if ($user->societe_id == 0 && $allow_delete && $paiement->statut == 0 && $_GET["action"] == '')
|
||||
if ($mesg) print $mesg.'<br>';
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td valign="top" width="140">'.$langs->trans('Ref').'</td><td colspan="3">'.$paiement->id.'</td></tr>';
|
||||
if ($conf->banque->enabled)
|
||||
{
|
||||
print '<a class="butDelete" href="fiche.php?id='.$_GET["id"].'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||
|
||||
if ($paiement->bank_account)
|
||||
{
|
||||
// Si compte renseigné, on affiche libelle
|
||||
$bank=new Account($db);
|
||||
$bank->fetch($paiement->bank_account);
|
||||
|
||||
$bankline=new AccountLine($db);
|
||||
$bankline->fetch($paiement->bank_line);
|
||||
|
||||
print '<tr>';
|
||||
print '<td valign="top" width="140">'.$langs->trans('BankAccount').'</td>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/compta/bank/account.php?account='.$bank->id.'">'.img_object($langs->trans('ShowAccount'),'account').' '.$bank->label.'</a></td>';
|
||||
print '<td>'.$langs->trans('BankLineConciliated').'</td><td>'.yn($bankline->rappro).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
print "</div>";
|
||||
print '<tr><td valign="top" width="140">'.$langs->trans('Date').'</td><td colspan="3">'.dolibarr_print_date($paiement->date).'</td></tr>';
|
||||
print '<tr><td valign="top">'.$langs->trans('Type').'</td><td colspan="3">'.$paiement->type_libelle.'</td></tr>';
|
||||
if ($paiement->numero)
|
||||
{
|
||||
print '<tr><td valign="top">'.$langs->trans('Numero').'</td><td colspan="3">'.$paiement->numero.'</td></tr>';
|
||||
}
|
||||
print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.price($paiement->montant).' '.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||
print '<tr><td valign="top">'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($paiement->note).'</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
$allow_delete = 1 ;
|
||||
$sql = 'SELECT f.facnumber, f.total_ttc, pf.amount, f.rowid as facid, f.paye, f.fk_statut, s.nom, s.idp';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s';
|
||||
$sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.idp';
|
||||
$sql .= ' AND pf.fk_paiementfourn = '.$paiement->id;
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$i = 0;
|
||||
$total = 0;
|
||||
print '<br><table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans('Bill').'</td><td>'.$langs->trans('Company').'</td>';
|
||||
print '<td align="right">'.$langs->trans('AmountTTC').'</td><td align="center">'.$langs->trans('Status').'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
$var=True;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$objp->facid.'">'.img_object($langs->trans('ShowBill'),'bill').' ';
|
||||
print $objp->facnumber;
|
||||
print "</a></td>\n";
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$objp->idp.'">'.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.'</a></td>';
|
||||
print '<td align="right">'.price($objp->amount).'</td>';
|
||||
$fac=new FactureFournisseur($db);
|
||||
print '<td align="center">'.$fac->LibStatut($objp->paye,$objp->fk_statut).'</td>';
|
||||
print "</tr>\n";
|
||||
if ($objp->paye == 1)
|
||||
{
|
||||
$allow_delete = 0;
|
||||
}
|
||||
$total = $total + $objp->amount;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$var=!$var;
|
||||
|
||||
print "</table>\n";
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Erreur de lecture";
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
/*
|
||||
* Boutons Actions
|
||||
*/
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET['action'] == '')
|
||||
{
|
||||
print '<a class="tabAction" href="fiche.php?id='.$_GET['id'].'&action=valide">'.$langs->trans('Valid').'</a>';
|
||||
}
|
||||
|
||||
if ($user->societe_id == 0 && $allow_delete && $paiement->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("<em>Dernière modification $Date$ révision $Revision$</em>");
|
||||
|
||||
@ -1948,3 +1948,16 @@ alter table llx_facture add model varchar(50) after note;
|
||||
alter table llx_facturedet modify fk_product integer NULL;
|
||||
alter table llx_contratdet modify fk_product integer NULL;
|
||||
update llx_facturedet set fk_product = null where fk_product=0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `llx_paiementfourn_facturefourn`
|
||||
(
|
||||
`rowid` int(11) NOT NULL auto_increment,
|
||||
`fk_paiementfourn` int(11) default NULL,
|
||||
`fk_facturefourn` int(11) default NULL,
|
||||
`amount` double default '0',
|
||||
PRIMARY KEY (`rowid`),
|
||||
KEY `idx_fk_facture` (`fk_facturefourn`),
|
||||
KEY `idx_fk_paiement` (`fk_paiementfourn`)
|
||||
) TYPE=innodb;
|
||||
|
||||
ALTER TABLE `llx_paiementfourn` ADD `statut` SMALLINT( 6 ) NOT NULL ;
|
||||
|
||||
32
mysql/tables/llx_paiementfourn_facturefourn.sql
Normal file
32
mysql/tables/llx_paiementfourn_facturefourn.sql
Normal file
@ -0,0 +1,32 @@
|
||||
-- ============================================================================
|
||||
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2005 Marc Barilley / Océbo <marc@ocebo.com>
|
||||
--
|
||||
-- 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$
|
||||
--
|
||||
-- ===========================================================================
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `llx_paiementfourn_facturefourn` (
|
||||
`rowid` int(11) NOT NULL auto_increment,
|
||||
`fk_paiementfourn` int(11) default NULL,
|
||||
`fk_facturefourn` int(11) default NULL,
|
||||
`amount` double default '0',
|
||||
PRIMARY KEY (`rowid`),
|
||||
KEY `idx_fk_facture` (`fk_facturefourn`),
|
||||
KEY `idx_fk_paiement` (`fk_paiementfourn`)
|
||||
) TYPE=innodb;
|
||||
Loading…
Reference in New Issue
Block a user