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');
|
$confirm = GETPOST('confirm');
|
||||||
|
|
||||||
$facid = GETPOST('facid','int');
|
$facid = GETPOST('facid','int');
|
||||||
$socname = GETPOST('socname');
|
$accountid = GETPOST('accountid','int');
|
||||||
$accountid = GETPOST('accountid');
|
$paymentnum = GETPOST('num_paiement','alpha');
|
||||||
$paymentnum = GETPOST('num_paiement');
|
$socid=GETPOST('socid','int');
|
||||||
|
|
||||||
$sortfield = GETPOST('sortfield','alpha');
|
$sortfield = GETPOST('sortfield','alpha');
|
||||||
$sortorder = GETPOST('sortorder','alpha');
|
$sortorder = GETPOST('sortorder','alpha');
|
||||||
@ -59,7 +59,6 @@ $multicurrency_amounts=array();
|
|||||||
$multicurrency_amountsresttopay=array();
|
$multicurrency_amountsresttopay=array();
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$socid=0;
|
|
||||||
if ($user->societe_id > 0)
|
if ($user->societe_id > 0)
|
||||||
{
|
{
|
||||||
$socid = $user->societe_id;
|
$socid = $user->societe_id;
|
||||||
@ -219,6 +218,9 @@ if (empty($reshook))
|
|||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
|
$thirdparty = new Societe($db);
|
||||||
|
if ($socid > 0) $thirdparty->fetch($socid);
|
||||||
|
|
||||||
// Clean parameters amount if payment is for a credit note
|
// Clean parameters amount if payment is for a credit note
|
||||||
if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE)
|
if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE)
|
||||||
{
|
{
|
||||||
@ -238,7 +240,7 @@ if (empty($reshook))
|
|||||||
if (! empty($conf->banque->enabled))
|
if (! empty($conf->banque->enabled))
|
||||||
{
|
{
|
||||||
// Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement
|
// 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');
|
setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
@ -256,7 +258,7 @@ if (empty($reshook))
|
|||||||
|
|
||||||
if (! $error)
|
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)
|
if ($paiement_id < 0)
|
||||||
{
|
{
|
||||||
setEventMessages($paiement->error, $paiement->errors, 'errors');
|
setEventMessages($paiement->error, $paiement->errors, 'errors');
|
||||||
@ -280,7 +282,7 @@ if (empty($reshook))
|
|||||||
{
|
{
|
||||||
$db->commit();
|
$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;
|
$invoiceid=0;
|
||||||
foreach ($paiement->amounts as $key => $amount)
|
foreach ($paiement->amounts as $key => $amount)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -222,9 +222,10 @@ class Paiement extends CommonObject
|
|||||||
*
|
*
|
||||||
* @param User $user Object user
|
* @param User $user Object user
|
||||||
* @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more
|
* @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
|
* @return int id of created payment, < 0 if error
|
||||||
*/
|
*/
|
||||||
function create($user, $closepaidinvoices = 0)
|
function create($user, $closepaidinvoices = 0, $thirdparty = null)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
@ -274,7 +275,7 @@ class Paiement extends CommonObject
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$this->ref = $this->getNextNumRef('');
|
$this->ref = $this->getNextNumRef(is_object($thirdparty)?$thirdparty:'');
|
||||||
|
|
||||||
if ($way == 'dolibarr')
|
if ($way == 'dolibarr')
|
||||||
{
|
{
|
||||||
@ -424,6 +425,7 @@ class Paiement extends CommonObject
|
|||||||
// Regenerate documents of invoices
|
// Regenerate documents of invoices
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||||
{
|
{
|
||||||
|
$newlang='';
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang;
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang;
|
||||||
if (! empty($newlang)) {
|
if (! empty($newlang)) {
|
||||||
|
|||||||
@ -143,9 +143,10 @@ class PaiementFourn extends Paiement
|
|||||||
*
|
*
|
||||||
* @param User $user Object of creating user
|
* @param User $user Object of creating user
|
||||||
* @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more
|
* @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
|
* @return int id of created payment, < 0 if error
|
||||||
*/
|
*/
|
||||||
function create($user, $closepaidinvoices = 0)
|
function create($user, $closepaidinvoices = 0, $thirdparty = null)
|
||||||
{
|
{
|
||||||
global $langs,$conf;
|
global $langs,$conf;
|
||||||
|
|
||||||
@ -186,7 +187,7 @@ class PaiementFourn extends Paiement
|
|||||||
|
|
||||||
if ($totalamount <> 0) // On accepte les montants negatifs
|
if ($totalamount <> 0) // On accepte les montants negatifs
|
||||||
{
|
{
|
||||||
$ref = $this->getNextNumRef('');
|
$ref = $this->getNextNumRef(is_object($thirdparty)?$thirdparty:'');
|
||||||
$now=dol_now();
|
$now=dol_now();
|
||||||
|
|
||||||
if ($way == 'dolibarr')
|
if ($way == 'dolibarr')
|
||||||
@ -245,6 +246,7 @@ class PaiementFourn extends Paiement
|
|||||||
// Regenerate documents of invoices
|
// Regenerate documents of invoices
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||||
{
|
{
|
||||||
|
$newlang='';
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang;
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang;
|
||||||
if (! empty($newlang)) {
|
if (! empty($newlang)) {
|
||||||
|
|||||||
@ -253,6 +253,9 @@ if (empty($reshook))
|
|||||||
{
|
{
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
|
$thirdparty = new Societe($db);
|
||||||
|
if ($socid > 0) $thirdparty->fetch($socid);
|
||||||
|
|
||||||
// Creation de la ligne paiement
|
// Creation de la ligne paiement
|
||||||
$paiement = new PaiementFourn($db);
|
$paiement = new PaiementFourn($db);
|
||||||
$paiement->datepaye = $datepaye;
|
$paiement->datepaye = $datepaye;
|
||||||
@ -263,7 +266,7 @@ if (empty($reshook))
|
|||||||
$paiement->note = $_POST['comment'];
|
$paiement->note = $_POST['comment'];
|
||||||
if (! $error)
|
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)
|
if ($paiement_id < 0)
|
||||||
{
|
{
|
||||||
setEventMessages($paiement->error, $paiement->errors, 'errors');
|
setEventMessages($paiement->error, $paiement->errors, 'errors');
|
||||||
@ -285,7 +288,7 @@ if (empty($reshook))
|
|||||||
{
|
{
|
||||||
$db->commit();
|
$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;
|
$invoiceid=0;
|
||||||
foreach ($paiement->amounts as $key => $amount)
|
foreach ($paiement->amounts as $key => $amount)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user