From a2d242356a600b8e1557e8c04def6868053c0971 Mon Sep 17 00:00:00 2001 From: jcp Date: Tue, 20 Oct 2020 10:17:42 +0200 Subject: [PATCH 1/5] Fix BankTransfer (V12.0.2) --- htdocs/compta/prelevement/card.php | 6 ++-- .../class/bonprelevement.class.php | 7 +++-- .../class/rejetprelevement.class.php | 28 ++++++++++++++----- htdocs/compta/prelevement/index.php | 0 htdocs/compta/prelevement/line.php | 13 +++++---- 5 files changed, 35 insertions(+), 19 deletions(-) mode change 100644 => 100755 htdocs/compta/prelevement/card.php mode change 100644 => 100755 htdocs/compta/prelevement/class/bonprelevement.class.php mode change 100644 => 100755 htdocs/compta/prelevement/class/rejetprelevement.class.php mode change 100644 => 100755 htdocs/compta/prelevement/index.php mode change 100644 => 100755 htdocs/compta/prelevement/line.php diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php old mode 100644 new mode 100755 index 00bcd088e27..7fce5fb306e --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -225,7 +225,7 @@ if ($id > 0 || $ref) print ''; $acc = new Account($db); - $result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT); + $result = $acc->fetch(($object->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT));//v20 print ''; @@ -430,7 +430,7 @@ if ($id > 0 || $ref) if ($user->rights->prelevement->bons->credit) { //print ''.$langs->trans("StandingOrderReject").''; - print ''.$langs->trans("StandingOrderReject").''; + print ''.$langs->trans("StandingOrderReject").''; } else { diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php old mode 100644 new mode 100755 index b1e7e29a698..b125b9075d4 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -469,7 +469,7 @@ class BonPrelevement extends CommonObject $message = $langs->trans("InfoCreditMessage", $this->ref, dol_print_date($date, 'dayhour')); //Add payment of withdrawal into bank - $bankaccount = $conf->global->PRELEVEMENT_ID_BANKACCOUNT; + $bankaccount = ($this->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT); //V20 $facs = array(); $amounts = array(); $amountsperthirdparty = array(); @@ -1766,7 +1766,7 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.$conf->global->PRELEVEMENT_ICS.''.$CrLf); + fputs($this->file, ' '.$conf->global->PAYMENTBYBANKTRANSFER_ICS.''.$CrLf);//v20 fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); @@ -2185,7 +2185,8 @@ class BonPrelevement extends CommonObject $dateTime_YMDHMS = dol_print_date($ladate, '%Y-%m-%dT%H:%M:%S'); // Get data of bank account - $id = $configuration->global->PRELEVEMENT_ID_BANKACCOUNT; + //$id = $configuration->global->PRELEVEMENT_ID_BANKACCOUNT; + $id=($type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT); //V20 $account = new Account($this->db); if ($account->fetch($id) > 0) { diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php old mode 100644 new mode 100755 index 8c033353637..aae73718d79 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -39,6 +39,8 @@ class RejetPrelevement * @var DoliDB Database handler. */ public $db; + + public $type; //prelevement or bank transfer. v20 /** @@ -47,12 +49,13 @@ class RejetPrelevement * @param DoliDb $db Database handler * @param User $user Objet user */ - public function __construct($db, $user) + public function __construct($db, $user, $type) { global $langs; $this->db = $db; $this->user = $user; + $this->type = $type;//v20 $this->motifs = array(); $this->facturer = array(); @@ -92,7 +95,7 @@ class RejetPrelevement $now = dol_now(); dol_syslog("RejetPrelevement::Create id $id"); - $bankaccount = $conf->global->PRELEVEMENT_ID_BANKACCOUNT; + $bankaccount = ($this->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT); //V20 $facs = $this->getListInvoices(1); $this->db->begin(); @@ -137,11 +140,19 @@ class RejetPrelevement $num = count($facs); for ($i = 0; $i < $num; $i++) { - $fac = new Facture($this->db); + if($this->type == 'bank-transfer'){ + $fac = new FactureFournisseur($this->db); //v20 + $pai = new PaiementFourn($this->db); + } + else{ + $fac = new Facture($this->db); + $pai = new Paiement($this->db); + } + $fac->fetch($facs[$i][0]); // Make a negative payment - $pai = new Paiement($this->db); + //$pai = new Paiement($this->db); $pai->amounts = array(); @@ -150,7 +161,7 @@ class RejetPrelevement * PHP installs sends only the part integer negative */ - $pai->amounts[$facs[$i][0]] = price2num($facs[$i][1] * -1); + $pai->amounts[$facs[$i][0]] = price2num($facs[$i][1] * ($this->type == 'bank-transfer' ? 1: -1));//v20 $pai->datepaye = $date_rejet; $pai->paiementid = 3; // type of payment: withdrawal $pai->num_paiement = $fac->ref; @@ -216,7 +227,7 @@ class RejetPrelevement $sql = "SELECT fk_user_demande"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql .= " WHERE pfd.fk_prelevement_bons = ".$this->bon_id; - $sql .= " AND pfd.fk_facture = ".$fac->id; + $sql .= " AND pfd.fk_facture".($this->type == 'bank-transfer' ? '_fourn=': '=').$fac->id;//v20 $resql = $this->db->query($sql); if ($resql) @@ -293,7 +304,10 @@ class RejetPrelevement //Returns all invoices of a withdrawal $sql = "SELECT f.rowid as facid, pl.amount"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture as pf"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON (pf.fk_facture = f.rowid)"; + //$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON (pf.fk_facture = f.rowid)";//v20 + if($this->type == 'bank-transfer') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON (pf.fk_facture_fourn = f.rowid)"; + else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON (pf.fk_facture = f.rowid)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_lignes as pl ON (pf.fk_prelevement_lignes = pl.rowid)"; $sql .= " WHERE pf.fk_prelevement_lignes = ".$this->id; $sql .= " AND f.entity IN (".getEntity('invoice').")"; diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php old mode 100644 new mode 100755 diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php old mode 100644 new mode 100755 index d6124113321..cbe51e89891 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -97,11 +97,11 @@ if ($action == 'confirm_rejet') if ($lipre->fetch($id) == 0) { - $rej = new RejetPrelevement($db, $user); + $rej = new RejetPrelevement($db, $user,$type); $rej->create($user, $id, GETPOST('motif', 'alpha'), $daterej, $lipre->bon_rowid, GETPOST('facturer', 'int')); - header("Location: line.php?id=".$id); + header("Location: line.php?id=".$id.'&type='.$type);//v20 exit; } } @@ -112,7 +112,7 @@ if ($action == 'confirm_rejet') } else { - header("Location: line.php?id=".$id); + header("Location: line.php?id=".$id.'&type='.$type);//v20 exit; } } @@ -134,7 +134,7 @@ llxHeader('', $title); $head = array(); $h = 0; -$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$id; +$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$id.'&type='.$type;//v20 $head[$h][1] = $title; $hselected = $h; $h++; @@ -203,11 +203,12 @@ if ($id) $soc = new Societe($db); $soc->fetch($lipre->socid); - $rej = new RejetPrelevement($db, $user); + $rej = new RejetPrelevement($db, $user,$type);//V20 print ''; print ''; print ''; + print ''; //v20 print '
'; $labelofbankfield = "BankToReceiveWithdraw"; @@ -404,7 +404,7 @@ if ($id > 0 || $ref) print ""; print $ligne->LibStatut($obj->statut, 2); print " "; - print ''; + print '';//v20 print sprintf("%06s", $obj->rowid); print '
'; print ''; @@ -258,7 +259,7 @@ if ($id) if ($lipre->statut == 2) { if ($user->rights->prelevement->bons->credit) { - print ''.$langs->trans("StandingOrderReject").''; + print ''.$langs->trans("StandingOrderReject").'';//v20 } else { From b09a618f38286aa72b5e140d7fc45d70ed5790d6 Mon Sep 17 00:00:00 2001 From: jcp Date: Tue, 20 Oct 2020 12:15:06 +0200 Subject: [PATCH 2/5] Fix Bank Transfer --- htdocs/compta/prelevement/card.php | 4 ++-- .../prelevement/class/bonprelevement.class.php | 6 +++--- .../prelevement/class/rejetprelevement.class.php | 14 +++++++------- htdocs/compta/prelevement/line.php | 12 ++++++------ 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 7fce5fb306e..959fc7f161d 100755 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -225,7 +225,7 @@ if ($id > 0 || $ref) print '
'; $acc = new Account($db); - $result = $acc->fetch(($object->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT));//v20 + $result = $acc->fetch(($object->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT)); print ''; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index b125b9075d4..16d8e89bf6b 100755 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -469,7 +469,7 @@ class BonPrelevement extends CommonObject $message = $langs->trans("InfoCreditMessage", $this->ref, dol_print_date($date, 'dayhour')); //Add payment of withdrawal into bank - $bankaccount = ($this->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT); //V20 + $bankaccount = ($this->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT); $facs = array(); $amounts = array(); $amountsperthirdparty = array(); @@ -1766,7 +1766,7 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.$conf->global->PAYMENTBYBANKTRANSFER_ICS.''.$CrLf);//v20 + fputs($this->file, ' '.$conf->global->PAYMENTBYBANKTRANSFER_ICS.''.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); @@ -2186,7 +2186,7 @@ class BonPrelevement extends CommonObject // Get data of bank account //$id = $configuration->global->PRELEVEMENT_ID_BANKACCOUNT; - $id=($type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT); //V20 + $id=($type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT); $account = new Account($this->db); if ($account->fetch($id) > 0) { diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index aae73718d79..00e43b4793c 100755 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -40,7 +40,7 @@ class RejetPrelevement */ public $db; - public $type; //prelevement or bank transfer. v20 + public $type; //prelevement or bank transfer /** @@ -55,7 +55,7 @@ class RejetPrelevement $this->db = $db; $this->user = $user; - $this->type = $type;//v20 + $this->type = $type; $this->motifs = array(); $this->facturer = array(); @@ -95,7 +95,7 @@ class RejetPrelevement $now = dol_now(); dol_syslog("RejetPrelevement::Create id $id"); - $bankaccount = ($this->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT); //V20 + $bankaccount = ($this->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT); $facs = $this->getListInvoices(1); $this->db->begin(); @@ -141,7 +141,7 @@ class RejetPrelevement for ($i = 0; $i < $num; $i++) { if($this->type == 'bank-transfer'){ - $fac = new FactureFournisseur($this->db); //v20 + $fac = new FactureFournisseur($this->db); $pai = new PaiementFourn($this->db); } else{ @@ -161,7 +161,7 @@ class RejetPrelevement * PHP installs sends only the part integer negative */ - $pai->amounts[$facs[$i][0]] = price2num($facs[$i][1] * ($this->type == 'bank-transfer' ? 1: -1));//v20 + $pai->amounts[$facs[$i][0]] = price2num($facs[$i][1] * ($this->type == 'bank-transfer' ? 1: -1)); $pai->datepaye = $date_rejet; $pai->paiementid = 3; // type of payment: withdrawal $pai->num_paiement = $fac->ref; @@ -227,7 +227,7 @@ class RejetPrelevement $sql = "SELECT fk_user_demande"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql .= " WHERE pfd.fk_prelevement_bons = ".$this->bon_id; - $sql .= " AND pfd.fk_facture".($this->type == 'bank-transfer' ? '_fourn=': '=').$fac->id;//v20 + $sql .= " AND pfd.fk_facture".($this->type == 'bank-transfer' ? '_fourn=': '=').$fac->id; $resql = $this->db->query($sql); if ($resql) @@ -304,7 +304,7 @@ class RejetPrelevement //Returns all invoices of a withdrawal $sql = "SELECT f.rowid as facid, pl.amount"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture as pf"; - //$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON (pf.fk_facture = f.rowid)";//v20 + //$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON (pf.fk_facture = f.rowid)"; if($this->type == 'bank-transfer') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON (pf.fk_facture_fourn = f.rowid)"; else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON (pf.fk_facture = f.rowid)"; diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php index cbe51e89891..abffc07880b 100755 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -101,7 +101,7 @@ if ($action == 'confirm_rejet') $rej->create($user, $id, GETPOST('motif', 'alpha'), $daterej, $lipre->bon_rowid, GETPOST('facturer', 'int')); - header("Location: line.php?id=".$id.'&type='.$type);//v20 + header("Location: line.php?id=".$id.'&type='.$type); exit; } } @@ -112,7 +112,7 @@ if ($action == 'confirm_rejet') } else { - header("Location: line.php?id=".$id.'&type='.$type);//v20 + header("Location: line.php?id=".$id.'&type='.$type); exit; } } @@ -134,7 +134,7 @@ llxHeader('', $title); $head = array(); $h = 0; -$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$id.'&type='.$type;//v20 +$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$id.'&type='.$type; $head[$h][1] = $title; $hselected = $h; $h++; @@ -203,12 +203,12 @@ if ($id) $soc = new Societe($db); $soc->fetch($lipre->socid); - $rej = new RejetPrelevement($db, $user,$type);//V20 + $rej = new RejetPrelevement($db, $user,$type); print ''; print ''; print ''; - print ''; //v20 + print ''; print '
'; $labelofbankfield = "BankToReceiveWithdraw"; @@ -404,7 +404,7 @@ if ($id > 0 || $ref) print ""; print $ligne->LibStatut($obj->statut, 2); print " "; - print '';//v20 + print ''; print sprintf("%06s", $obj->rowid); print '
'; print ''; @@ -259,7 +259,7 @@ if ($id) if ($lipre->statut == 2) { if ($user->rights->prelevement->bons->credit) { - print ''.$langs->trans("StandingOrderReject").'';//v20 + print ''.$langs->trans("StandingOrderReject").''; } else { From 10a8ce82a9743b28db8275482e38223273820c1d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Oct 2020 15:57:25 +0200 Subject: [PATCH 3/5] Update bonprelevement.class.php --- htdocs/compta/prelevement/class/bonprelevement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 16d8e89bf6b..483df326566 100755 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -2186,7 +2186,7 @@ class BonPrelevement extends CommonObject // Get data of bank account //$id = $configuration->global->PRELEVEMENT_ID_BANKACCOUNT; - $id=($type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT); + $id = ($type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT); $account = new Account($this->db); if ($account->fetch($id) > 0) { From b9e6b188bcc494a03fb32e933bf43b9e2119873b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Oct 2020 15:58:24 +0200 Subject: [PATCH 4/5] Update rejetprelevement.class.php --- htdocs/compta/prelevement/class/rejetprelevement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index 00e43b4793c..c831d4f3e0f 100755 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -305,7 +305,7 @@ class RejetPrelevement $sql = "SELECT f.rowid as facid, pl.amount"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture as pf"; //$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON (pf.fk_facture = f.rowid)"; - if($this->type == 'bank-transfer') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON (pf.fk_facture_fourn = f.rowid)"; + if ($this->type == 'bank-transfer') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON (pf.fk_facture_fourn = f.rowid)"; else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON (pf.fk_facture = f.rowid)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_lignes as pl ON (pf.fk_prelevement_lignes = pl.rowid)"; From ca93f732c8e74d633b2ae47b58e22ee67cb64cc2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Oct 2020 15:59:04 +0200 Subject: [PATCH 5/5] Update line.php --- htdocs/compta/prelevement/line.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php index abffc07880b..78a0723aef2 100755 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -203,7 +203,7 @@ if ($id) $soc = new Societe($db); $soc->fetch($lipre->socid); - $rej = new RejetPrelevement($db, $user,$type); + $rej = new RejetPrelevement($db, $user, $type); print ''; print '';