New: Ajout des triggers sur les paiements (PAYEMENT_CUSTOMER_CREATE et PAYMENT_SUPPLIER_CREATE) en prevision de la compta expert.
Qual: La facture fournisseur hrite de facture (factorisation de code)
This commit is contained in:
parent
234e7b227a
commit
1870434b2a
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2006 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
|
||||
@ -119,7 +119,7 @@ if ($_POST['action'] == 'add_paiement')
|
||||
if ($conf->banque->enabled)
|
||||
{
|
||||
// Insertion dans llx_bank
|
||||
$label = 'Règlement facture';
|
||||
$label = "(CustomerInvoicePayment)";
|
||||
$acc = new Account($db, $_POST['accountid']);
|
||||
//paiementid contient "CHQ ou VIR par exemple"
|
||||
$bank_line_id = $acc->addline($paiement->datepaye,
|
||||
@ -171,6 +171,7 @@ if ($_POST['action'] == 'add_paiement')
|
||||
$loc = DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$paiement_id;
|
||||
$db->commit();
|
||||
Header('Location: '.$loc);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -24,7 +24,8 @@
|
||||
/**
|
||||
\file htdocs/compta/paiement/fiche.php
|
||||
\ingroup facture
|
||||
\brief Onglet paiement d'un paiement
|
||||
\brief Onglet paiement d'un paiement client
|
||||
\remarks Fichier presque identique a fournisseur/paiement/fiche.php
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
@ -183,14 +184,18 @@ if ($resql)
|
||||
$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 '<td>'.$langs->trans('Bill').'</td>';
|
||||
print '<td align="center">'.$langs->trans('Status').'</td>';
|
||||
print '<td>'.$langs->trans('Company').'</td>';
|
||||
print '<td align="right">'.$langs->trans('AmountTTC').'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
$var=True;
|
||||
|
||||
$facturestatic=new Facture($db);
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
@ -199,10 +204,9 @@ if ($resql)
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">'.img_object($langs->trans('ShowBill'),'bill').' ';
|
||||
print $objp->facnumber;
|
||||
print "</a></td>\n";
|
||||
print '<td align="center">'.$facturestatic->LibStatut($objp->paye,$objp->fk_statut,2,1).'</td>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/compta/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 Facture($db);
|
||||
print '<td align="center">'.$fac->LibStatut($objp->paye,$objp->fk_statut).'</td>';
|
||||
print "</tr>\n";
|
||||
if ($objp->paye == 1)
|
||||
{
|
||||
|
||||
@ -1326,6 +1326,7 @@ class Facture
|
||||
* \param paye Etat paye
|
||||
* \param statut Id statut
|
||||
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto
|
||||
* \param alreadypayed Montant deja payé
|
||||
* \return string Libellé du statut
|
||||
*/
|
||||
function LibStatut($paye,$statut,$mode=0,$alreadypayed=-1)
|
||||
|
||||
@ -120,7 +120,7 @@ if ($action == 'add_paiement')
|
||||
if ($conf->banque->enabled)
|
||||
{
|
||||
// Insertion dans llx_bank
|
||||
$label = 'Règlement fournisseur';
|
||||
$label = "(SupplierInvoicePayment)";
|
||||
$acc = new Account($db, $_POST['accountid']);
|
||||
//paiementid contient "CHQ ou VIR par exemple"
|
||||
$bank_line_id = $acc->addline($paiement->datepaye,
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
\file htdocs/fourn/facture/paiementfourn.class.php
|
||||
\ingroup fournisseur, facture
|
||||
\brief Page de création de paiement factures fournisseurs
|
||||
\remarks Cette classe est presque identique à paiement.class.php
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
@ -120,23 +121,23 @@ class PaiementFourn
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
$sql_err = 0;
|
||||
$error = 0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$this->total = 0.0;
|
||||
// Nettoyage parametres
|
||||
$value = price2num($value);
|
||||
$this->total = 0;
|
||||
foreach ($this->amounts as $key => $value)
|
||||
{
|
||||
$val = price2num($value);
|
||||
if (is_numeric($val))
|
||||
{
|
||||
$val = price2num(round($val, 2));
|
||||
$this->total += $val;
|
||||
}
|
||||
$val = round($value, 2);
|
||||
$this->amounts[$key] = $val;
|
||||
$this->total += $val;
|
||||
}
|
||||
$this->total = price2num($this->total);
|
||||
if ($this->total <> 0) /* On accepte les montants négatifs pour les avoirs ??? */
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if ($this->total <> 0) // On accepte les montants négatifs
|
||||
{
|
||||
$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.')';
|
||||
@ -144,6 +145,8 @@ class PaiementFourn
|
||||
if ($resql)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'paiementfourn');
|
||||
|
||||
// Insere tableau des montants / factures
|
||||
foreach ($this->amounts as $key => $amount)
|
||||
{
|
||||
$facid = $key;
|
||||
@ -154,7 +157,7 @@ class PaiementFourn
|
||||
if (! $this->db->query($sql) )
|
||||
{
|
||||
dolibarr_syslog('Paiement::Create Erreur INSERT dans paiement_facture '.$facid);
|
||||
$sql_err++;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -162,15 +165,25 @@ class PaiementFourn
|
||||
dolibarr_syslog('PaiementFourn::Create Montant non numérique');
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers('PAYMENT_SUPPLIER_CREATE',$this,$user,$lang,$conf);
|
||||
if ($result < 0) $error++;
|
||||
// Fin appel triggers
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog('PaiementFourn::Create Erreur INSERT dans paiementfourn');
|
||||
$sql_err++;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->total <> 0 && $sql_err == 0 ) // On accepte les montants négatifs
|
||||
if ( $this->total <> 0 && $error == 0 ) // On accepte les montants négatifs
|
||||
{
|
||||
$this->db->commit();
|
||||
dolibarr_syslog('PaiementFourn::Create Ok Total = '.$this->total);
|
||||
|
||||
@ -29,13 +29,15 @@
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
include_once(DOL_DOCUMENT_ROOT."/facture.class.php");
|
||||
|
||||
|
||||
/**
|
||||
\class FactureFournisseur
|
||||
\brief Classe permettant la gestion des factures fournisseurs
|
||||
*/
|
||||
|
||||
class FactureFournisseur
|
||||
class FactureFournisseur extends Facture
|
||||
{
|
||||
var $id;
|
||||
var $db;
|
||||
@ -504,144 +506,6 @@ class FactureFournisseur
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne le libellé du statut d'une facture (brouillon, validée, abandonnée, payée)
|
||||
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long
|
||||
* \return string Libelle
|
||||
*/
|
||||
function getLibStatut($mode=0)
|
||||
{
|
||||
return $this->LibStatut($this->paye,$this->statut,$mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi le libellé d'un statut donné
|
||||
* \param paye Etat paye
|
||||
* \param statut Id statut
|
||||
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto
|
||||
* \return string Libellé du statut
|
||||
*/
|
||||
function LibStatut($paye,$statut,$mode=0)
|
||||
{
|
||||
global $langs;
|
||||
$langs->load('bills');
|
||||
|
||||
if ($mode == 0)
|
||||
{
|
||||
$prefix='';
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return $langs->trans('Bill'.$prefix.'StatusDraft');
|
||||
if ($statut == 3) return $langs->trans('Bill'.$prefix.'StatusCanceled');
|
||||
if ($alreadypayed <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPayed');
|
||||
return $langs->trans('Bill'.$prefix.'StatusStarted');
|
||||
}
|
||||
else
|
||||
{
|
||||
return $langs->trans('Bill'.$prefix.'StatusPayed');
|
||||
}
|
||||
}
|
||||
if ($mode == 1)
|
||||
{
|
||||
$prefix='Short';
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return $langs->trans('Bill'.$prefix.'StatusDraft');
|
||||
if ($statut == 3) return $langs->trans('Bill'.$prefix.'StatusCanceled');
|
||||
if ($alreadypayed <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPayed');
|
||||
return $langs->trans('Bill'.$prefix.'StatusStarted');
|
||||
}
|
||||
else
|
||||
{
|
||||
return $langs->trans('Bill'.$prefix.'StatusPayed');
|
||||
}
|
||||
}
|
||||
if ($mode == 2)
|
||||
{
|
||||
$prefix='Short';
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return img_picto($langs->trans('Bill'.$prefix.'StatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft');
|
||||
if ($statut == 3) return img_picto($langs->trans('Bill'.$prefix.'StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled');
|
||||
if ($alreadypayed <= 0) return img_picto($langs->trans('Bill'.$prefix.'StatusNotPayed'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPayed');
|
||||
return img_picto($langs->trans('Bill'.$prefix.'StatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted');
|
||||
}
|
||||
else
|
||||
{
|
||||
return img_picto($langs->trans('Bill'.$prefix.'StatusPayed'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPayed');
|
||||
}
|
||||
}
|
||||
if ($mode == 3)
|
||||
{
|
||||
$prefix='Short';
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return img_picto($langs->trans('Bill'.$prefix.'StatusDraft'),'statut0');
|
||||
if ($statut == 3) return img_picto($langs->trans('Bill'.$prefix.'StatusCanceled'),'statut5');
|
||||
if ($alreadypayed <= 0) return img_picto($langs->trans('Bill'.$prefix.'StatusNotPayed'),'statut1');
|
||||
return img_picto($langs->trans('Bill'.$prefix.'StatusStarted'),'statut3');
|
||||
}
|
||||
else
|
||||
{
|
||||
return img_picto($langs->trans('Bill'.$prefix.'StatusPayed'),'statut6');
|
||||
}
|
||||
}
|
||||
if ($mode == 4)
|
||||
{
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft');
|
||||
if ($statut == 3) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('BillStatusCanceled');
|
||||
if ($alreadypayed <= 0) return img_picto($langs->trans('BillStatusNotPayed'),'statut1').' '.$langs->trans('BillStatusNotPayed');
|
||||
return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted');
|
||||
}
|
||||
else
|
||||
{
|
||||
return img_picto($langs->trans('BillStatusPayed'),'statut6').' '.$langs->trans('BillStatusPayed');
|
||||
}
|
||||
}
|
||||
if ($mode == 5)
|
||||
{
|
||||
$prefix='Short';
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return $langs->trans('Bill'.$prefix.'StatusDraft').' '.img_picto($langs->trans('Bill'.$prefix.'StatusDraft'),'statut0');
|
||||
if ($statut == 3) return $langs->trans('Bill'.$prefix.'StatusCanceled').' '.img_picto($langs->trans('Bill'.$prefix.'StatusCanceled'),'statut5');
|
||||
if ($alreadypayed <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPayed').' '.img_picto($langs->trans('Bill'.$prefix.'StatusNotPayed'),'statut1');
|
||||
return $langs->trans('Bill'.$prefix.'StatusStarted').' '.img_picto($langs->trans('Bill'.$prefix.'StatusStarted'),'statut3');
|
||||
}
|
||||
else
|
||||
{
|
||||
return $langs->trans('Bill'.$prefix.'StatusPayed').' '.img_picto($langs->trans('Bill'.$prefix.'StatusPayed'),'statut6');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi le libellé court d'un statut donné
|
||||
* \param paye etat paye
|
||||
* \param statut id statut
|
||||
* \param amount amount already payed
|
||||
* \return string Libellé court du statut
|
||||
*/
|
||||
function PayedLibStatut($paye,$statut,$amount=0)
|
||||
{
|
||||
global $langs;
|
||||
$langs->load('bills');
|
||||
if (! $paye)
|
||||
{
|
||||
if ($statut == 0) return $langs->trans('BillShortStatusDraft');
|
||||
if ($statut == 3) return $langs->trans('BillStatusCanceled');
|
||||
if ($amount) return $langs->trans('BillStatusStarted');
|
||||
return $langs->trans('BillStatusNotPayed');
|
||||
}
|
||||
else
|
||||
{
|
||||
return $langs->trans('BillStatusPayed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Charge indicateurs this->nbtodo et this->nbtodolate de tableau de bord
|
||||
|
||||
@ -23,8 +23,9 @@
|
||||
|
||||
/**
|
||||
\file htdocs/fourn/paiement/fiche.php
|
||||
\ingroup facture
|
||||
\brief Onglet paiement d'un paiement
|
||||
\ingroup facture, fournisseur
|
||||
\brief Onglet paiement d'un paiement fournisseur
|
||||
\remarks Fichier presque identique a compta/paiement/fiche.php
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
@ -193,7 +194,8 @@ if ($resql)
|
||||
{
|
||||
$var=True;
|
||||
|
||||
$fac_static=new FactureFournisseur($db);
|
||||
$facturestatic=new FactureFournisseur($db);
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
@ -202,7 +204,7 @@ if ($resql)
|
||||
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 align="center">'.$fac_static->LibStatut($objp->paye,$objp->fk_statut).'</td>';
|
||||
print '<td align="center">'.$facturestatic->LibStatut($objp->paye,$objp->fk_statut,2,1).'</td>';
|
||||
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>';
|
||||
print "</tr>\n";
|
||||
|
||||
@ -127,6 +127,31 @@ class InterfaceDemo
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched. id=".$object->id);
|
||||
}
|
||||
// Products
|
||||
elseif ($action == 'PRODUCT_CREATE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched");
|
||||
}
|
||||
elseif ($action == 'PRODUCT_MODIFY')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched");
|
||||
}
|
||||
elseif ($action == 'PRODUCT_DELETE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched");
|
||||
}
|
||||
elseif ($action == 'ORDER_CREATE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched");
|
||||
}
|
||||
elseif ($action == 'ORDER_MODIFY')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched");
|
||||
}
|
||||
elseif ($action == 'ORDER_DELETE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched");
|
||||
}
|
||||
// Proposals
|
||||
elseif ($action == 'PROPAL_CREATE')
|
||||
{
|
||||
@ -194,28 +219,12 @@ class InterfaceDemo
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched");
|
||||
}
|
||||
// Products
|
||||
elseif ($action == 'PRODUCT_CREATE')
|
||||
// Payments
|
||||
elseif ($action == 'PAYMENT_CUSTOMER_CREATE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched");
|
||||
}
|
||||
elseif ($action == 'PRODUCT_MODIFY')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched");
|
||||
}
|
||||
elseif ($action == 'PRODUCT_DELETE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched");
|
||||
}
|
||||
elseif ($action == 'ORDER_CREATE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched");
|
||||
}
|
||||
elseif ($action == 'ORDER_MODIFY')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched");
|
||||
}
|
||||
elseif ($action == 'ORDER_DELETE')
|
||||
elseif ($action == 'PAYMENT_SUPPLIER_CREATE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched");
|
||||
}
|
||||
|
||||
@ -275,6 +275,31 @@ class InterfaceWebCal
|
||||
$this->desc=$langs->trans("InvoiceCanceledInDolibarr",$object->ref);
|
||||
$this->desc.="\n".$langs->trans("Author").': '.$user->code;
|
||||
}
|
||||
// Payments
|
||||
elseif ($action == 'PAYMENT_CUSTOMER_CREATE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched");
|
||||
$langs->load("other");
|
||||
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->trans("CustomerPaymentDoneInDolibarr",$object->ref);
|
||||
$this->desc=$langs->trans("CustomerPaymentDoneInDolibarr",$object->ref);
|
||||
$this->desc.="\n".$langs->trans("AmountTTC").': '.$object->total;
|
||||
$this->desc.="\n".$langs->trans("Author").': '.$user->code;
|
||||
}
|
||||
elseif ($action == 'PAYMENT_SUPPLIER_CREATE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched");
|
||||
$langs->load("other");
|
||||
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->trans("SupplierPaymentDoneInDolibarr",$object->ref);
|
||||
$this->desc=$langs->trans("SupplierPaymentDoneInDolibarr",$object->ref);
|
||||
$this->desc.="\n".$langs->trans("AmountTTC").': '.$object->total;
|
||||
$this->desc.="\n".$langs->trans("Author").': '.$user->code;
|
||||
}
|
||||
|
||||
// Ajoute entrée dans webcal
|
||||
if ($this->date)
|
||||
|
||||
@ -61,6 +61,7 @@ PropalValidatedInDolibarr=Proposal %s validated in Dolibarr
|
||||
InvoiceValidatedInDolibarr=Invoice %s validated in Dolibarr
|
||||
InvoicePayedInDolibarr=Invoice %s changed to payed in Dolibarr
|
||||
InvoiceCanceledInDolibarr=Invoice %s canceled in Dolibarr
|
||||
PaymentDoneInDolibarr=Payment %s done in Dolibarr
|
||||
##### Export #####
|
||||
ExportsArea=Exports area
|
||||
AvailableFormats=Available formats
|
||||
|
||||
@ -61,6 +61,9 @@ PropalValidatedInDolibarr=Proposition %s valid
|
||||
InvoiceValidatedInDolibarr=Facture %s validée dans Dolibarr
|
||||
InvoicePayedInDolibarr=Facture %s passée à payée dans Dolibarr
|
||||
InvoiceCanceledInDolibarr=Facture %s annulée dans Dolibarr
|
||||
PaymentDoneInDolibarr=Paiement %s réalisé dans Dolibarr
|
||||
CustomerPaymentDoneInDolibarr=Paiement client %s dans Dolibarr
|
||||
SupplierPaymentDoneInDolibarr=Paiement fournisseur %s dans Dolibarr
|
||||
##### Export #####
|
||||
ExportsArea=Espace exports
|
||||
AvailableFormats=Formats disponibles
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2006 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
|
||||
@ -25,6 +25,7 @@
|
||||
\file htdocs/paiement.class.php
|
||||
\ingroup facture
|
||||
\brief Fichier de la classe des paiement de factures clients
|
||||
\remarks Cette classe est presque identique à paiementfourn.class.php
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
@ -40,6 +41,7 @@ class Paiement
|
||||
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
|
||||
@ -53,13 +55,12 @@ class Paiement
|
||||
|
||||
var $db;
|
||||
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
* \param DB handler accès base de données
|
||||
* \param soc_idp id societe ('' par defaut)
|
||||
*/
|
||||
|
||||
function Paiement($DB, $soc_idp='')
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
* \param DB handler accès base de données
|
||||
*/
|
||||
function Paiement($DB)
|
||||
{
|
||||
$this->db = $DB ;
|
||||
}
|
||||
@ -109,41 +110,39 @@ class Paiement
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Création du paiement en base
|
||||
* \param user object utilisateur qui crée
|
||||
* \return int id du paiement crée, < 0 si erreur
|
||||
*/
|
||||
|
||||
/**
|
||||
* \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;
|
||||
$error = 0;
|
||||
|
||||
// Nettoyage parametres
|
||||
$value = price2num($value);
|
||||
$this->total = 0;
|
||||
foreach ($this->amounts as $key => $value)
|
||||
{
|
||||
$val = round($value, 2);
|
||||
$this->amounts[$key] = $val;
|
||||
$this->total += $val;
|
||||
}
|
||||
$this->total = price2num($this->total);
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$total = 0.0;
|
||||
foreach ($this->amounts as $key => $value)
|
||||
{
|
||||
$val = $value;
|
||||
$val = str_replace(' ','',$val);
|
||||
$val = str_replace(',','.',$val);
|
||||
$val = round($val, 2);
|
||||
$val = str_replace(',','.',$val);
|
||||
if (is_numeric($val))
|
||||
{
|
||||
$total += $val;
|
||||
}
|
||||
$this->amounts[$key] = $val;
|
||||
}
|
||||
$total = str_replace(',','.',$total);
|
||||
if ($total <> 0) /* On accepte les montants négatifs pour les rejets de prélèvement */
|
||||
if ($this->total <> 0) // On accepte les montants négatifs pour les rejets de prélèvement
|
||||
{
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement (datec, datep, amount, fk_paiement, num_paiement, note, fk_user_creat)';
|
||||
$sql .= ' VALUES (now(), '.$this->datepaye.', \''.$total.'\', '.$this->paiementid.', \''.$this->num_paiement.'\', \''.$this->note.'\', '.$user->id.')';
|
||||
$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.'paiement');
|
||||
|
||||
// Insere tableau des montants / factures
|
||||
foreach ($this->amounts as $key => $amount)
|
||||
{
|
||||
$facid = $key;
|
||||
@ -154,7 +153,7 @@ class Paiement
|
||||
if (! $this->db->query($sql) )
|
||||
{
|
||||
dolibarr_syslog('Paiement::Create Erreur INSERT dans paiement_facture '.$facid);
|
||||
$sql_err++;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -162,18 +161,28 @@ class Paiement
|
||||
dolibarr_syslog('Paiement::Create Montant non numérique');
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers('PAYMENT_CUSTOMER_CREATE',$this,$user,$lang,$conf);
|
||||
if ($result < 0) $error++;
|
||||
// Fin appel triggers
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog('Paiement::Create Erreur INSERT dans paiement');
|
||||
$sql_err++;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $total <> 0 && $sql_err == 0 ) // On accepte les montants négatifs
|
||||
if ( $this->total <> 0 && $error == 0 ) // On accepte les montants négatifs
|
||||
{
|
||||
$this->db->commit();
|
||||
dolibarr_syslog('Paiement::Create Ok Total = '.$total);
|
||||
dolibarr_syslog('Paiement::Create Ok Total = '.$this->total);
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user