NEW Support tag {ccc} on payment ref
This commit is contained in:
parent
afd53a99c2
commit
4b77b3ff23
@ -43,9 +43,9 @@ $action = GETPOST('action','alpha');
|
||||
$confirm = GETPOST('confirm');
|
||||
|
||||
$facid = GETPOST('facid','int');
|
||||
$socname = GETPOST('socname');
|
||||
$accountid = GETPOST('accountid');
|
||||
$paymentnum = GETPOST('num_paiement');
|
||||
$accountid = GETPOST('accountid','int');
|
||||
$paymentnum = GETPOST('num_paiement','alpha');
|
||||
$socid=GETPOST('socid','int');
|
||||
|
||||
$sortfield = GETPOST('sortfield','alpha');
|
||||
$sortorder = GETPOST('sortorder','alpha');
|
||||
@ -59,7 +59,6 @@ $multicurrency_amounts=array();
|
||||
$multicurrency_amountsresttopay=array();
|
||||
|
||||
// Security check
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socid = $user->societe_id;
|
||||
@ -219,6 +218,9 @@ if (empty($reshook))
|
||||
|
||||
$db->begin();
|
||||
|
||||
$thirdparty = new Societe($db);
|
||||
if ($socid > 0) $thirdparty->fetch($socid);
|
||||
|
||||
// Clean parameters amount if payment is for a credit note
|
||||
if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE)
|
||||
{
|
||||
@ -238,7 +240,7 @@ if (empty($reshook))
|
||||
if (! empty($conf->banque->enabled))
|
||||
{
|
||||
// Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement
|
||||
if (GETPOST('accountid') <= 0)
|
||||
if (GETPOST('accountid','int') <= 0)
|
||||
{
|
||||
setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), null, 'errors');
|
||||
$error++;
|
||||
@ -256,7 +258,7 @@ if (empty($reshook))
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0)); // This include closing invoices and regenerating documents
|
||||
$paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0), $thirdparty); // This include closing invoices and regenerating documents
|
||||
if ($paiement_id < 0)
|
||||
{
|
||||
setEventMessages($paiement->error, $paiement->errors, 'errors');
|
||||
@ -280,7 +282,7 @@ if (empty($reshook))
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
// If payment dispatching on more than one invoice, we keep on summary page, otherwise jump on invoice card
|
||||
// If payment dispatching on more than one invoice, we stay on summary page, otherwise jump on invoice card
|
||||
$invoiceid=0;
|
||||
foreach ($paiement->amounts as $key => $amount)
|
||||
{
|
||||
|
||||
@ -216,15 +216,16 @@ class Paiement extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Create payment of invoices into database.
|
||||
* Use this->amounts to have list of invoices for the payment.
|
||||
* For payment of a customer invoice, amounts are positive, for payment of credit note, amounts are negative
|
||||
* Create payment of invoices into database.
|
||||
* Use this->amounts to have list of invoices for the payment.
|
||||
* For payment of a customer invoice, amounts are positive, for payment of credit note, amounts are negative
|
||||
*
|
||||
* @param User $user Object user
|
||||
* @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more
|
||||
* @return int id of created payment, < 0 if error
|
||||
* @param User $user Object user
|
||||
* @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more
|
||||
* @param Societe $thirdparty Thirdparty
|
||||
* @return int id of created payment, < 0 if error
|
||||
*/
|
||||
function create($user, $closepaidinvoices = 0)
|
||||
function create($user, $closepaidinvoices = 0, $thirdparty = null)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
@ -274,7 +275,7 @@ class Paiement extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$this->ref = $this->getNextNumRef('');
|
||||
$this->ref = $this->getNextNumRef(is_object($thirdparty)?$thirdparty:'');
|
||||
|
||||
if ($way == 'dolibarr')
|
||||
{
|
||||
@ -424,6 +425,7 @@ class Paiement extends CommonObject
|
||||
// Regenerate documents of invoices
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
{
|
||||
$newlang='';
|
||||
$outputlangs = $langs;
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
|
||||
@ -141,11 +141,12 @@ class PaiementFourn extends Paiement
|
||||
/**
|
||||
* Create payment in database
|
||||
*
|
||||
* @param User $user Object of creating user
|
||||
* @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more
|
||||
* @param User $user Object of creating user
|
||||
* @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more
|
||||
* @param Societe $thirdparty Thirdparty
|
||||
* @return int id of created payment, < 0 if error
|
||||
*/
|
||||
function create($user, $closepaidinvoices = 0)
|
||||
function create($user, $closepaidinvoices = 0, $thirdparty = null)
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
@ -186,7 +187,7 @@ class PaiementFourn extends Paiement
|
||||
|
||||
if ($totalamount <> 0) // On accepte les montants negatifs
|
||||
{
|
||||
$ref = $this->getNextNumRef('');
|
||||
$ref = $this->getNextNumRef(is_object($thirdparty)?$thirdparty:'');
|
||||
$now=dol_now();
|
||||
|
||||
if ($way == 'dolibarr')
|
||||
@ -245,7 +246,8 @@ class PaiementFourn extends Paiement
|
||||
// Regenerate documents of invoices
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||
{
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
$outputlangs = $langs;
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang;
|
||||
if (! empty($newlang)) {
|
||||
$outputlangs = new Translate("", $conf);
|
||||
|
||||
@ -253,6 +253,9 @@ if (empty($reshook))
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$thirdparty = new Societe($db);
|
||||
if ($socid > 0) $thirdparty->fetch($socid);
|
||||
|
||||
// Creation de la ligne paiement
|
||||
$paiement = new PaiementFourn($db);
|
||||
$paiement->datepaye = $datepaye;
|
||||
@ -263,7 +266,7 @@ if (empty($reshook))
|
||||
$paiement->note = $_POST['comment'];
|
||||
if (! $error)
|
||||
{
|
||||
$paiement_id = $paiement->create($user,(GETPOST('closepaidinvoices')=='on'?1:0));
|
||||
$paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0), $thirdparty);
|
||||
if ($paiement_id < 0)
|
||||
{
|
||||
setEventMessages($paiement->error, $paiement->errors, 'errors');
|
||||
@ -285,7 +288,7 @@ if (empty($reshook))
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
// If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card
|
||||
// If payment dispatching on more than one invoice, we stay on summary page, otherwise go on invoice card
|
||||
$invoiceid=0;
|
||||
foreach ($paiement->amounts as $key => $amount)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user