Merge branch '12.0' of git@github.com:Dolibarr/dolibarr.git into develop
Conflicts: htdocs/compta/prelevement/line.php
This commit is contained in:
commit
254da6923b
@ -414,16 +414,35 @@ if (empty($reshook))
|
|||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->cond_reglement_code = 0; // To clean property
|
$object->cond_reglement_code = 0; // To clean property
|
||||||
$object->cond_reglement_id = 0; // To clean property
|
$object->cond_reglement_id = 0; // To clean property
|
||||||
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
|
|
||||||
if ($result < 0) dol_print_error($db, $object->error);
|
|
||||||
|
|
||||||
$old_date_lim_reglement = $object->date_lim_reglement;
|
$error = 0;
|
||||||
$new_date_lim_reglement = $object->calculate_date_lim_reglement();
|
|
||||||
if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement;
|
$db->begin();
|
||||||
if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date;
|
|
||||||
$result = $object->update($user);
|
if (! $error) {
|
||||||
if ($result < 0) {
|
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
|
||||||
dol_print_error($db, $object->error);
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error) {
|
||||||
|
$old_date_lim_reglement = $object->date_lim_reglement;
|
||||||
|
$new_date_lim_reglement = $object->calculate_date_lim_reglement();
|
||||||
|
if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement;
|
||||||
|
if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date;
|
||||||
|
$result = $object->update($user);
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($error) {
|
||||||
|
$db->rollback();
|
||||||
|
} else {
|
||||||
|
$db->commit();
|
||||||
}
|
}
|
||||||
} elseif ($action == 'setpaymentterm' && $usercancreate)
|
} elseif ($action == 'setpaymentterm' && $usercancreate)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -449,7 +449,7 @@ class BonPrelevement extends CommonObject
|
|||||||
$message = $langs->trans("InfoCreditMessage", $this->ref, dol_print_date($date, 'dayhour'));
|
$message = $langs->trans("InfoCreditMessage", $this->ref, dol_print_date($date, 'dayhour'));
|
||||||
|
|
||||||
//Add payment of withdrawal into bank
|
//Add payment of withdrawal into bank
|
||||||
$bankaccount = ($this->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
|
$bankaccount = ($this->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
|
||||||
$facs = array();
|
$facs = array();
|
||||||
$amounts = array();
|
$amounts = array();
|
||||||
$amountsperthirdparty = array();
|
$amountsperthirdparty = array();
|
||||||
@ -2115,7 +2115,7 @@ class BonPrelevement extends CommonObject
|
|||||||
|
|
||||||
// Get data of bank account
|
// 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);
|
$id = ($type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
|
||||||
$account = new Account($this->db);
|
$account = new Account($this->db);
|
||||||
if ($account->fetch($id) > 0)
|
if ($account->fetch($id) > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -15,7 +15,6 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,7 +38,7 @@ class RejetPrelevement
|
|||||||
* @var DoliDB Database handler.
|
* @var DoliDB Database handler.
|
||||||
*/
|
*/
|
||||||
public $db;
|
public $db;
|
||||||
|
|
||||||
public $type; //prelevement or bank transfer
|
public $type; //prelevement or bank transfer
|
||||||
|
|
||||||
|
|
||||||
@ -95,7 +94,7 @@ class RejetPrelevement
|
|||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
|
|
||||||
dol_syslog("RejetPrelevement::Create id $id");
|
dol_syslog("RejetPrelevement::Create id $id");
|
||||||
$bankaccount = ($this->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
|
$bankaccount = ($this->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
|
||||||
$facs = $this->getListInvoices(1);
|
$facs = $this->getListInvoices(1);
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
@ -141,14 +140,14 @@ class RejetPrelevement
|
|||||||
for ($i = 0; $i < $num; $i++)
|
for ($i = 0; $i < $num; $i++)
|
||||||
{
|
{
|
||||||
if($this->type == 'bank-transfer'){
|
if($this->type == 'bank-transfer'){
|
||||||
$fac = new FactureFournisseur($this->db);
|
$fac = new FactureFournisseur($this->db);
|
||||||
$pai = new PaiementFourn($this->db);
|
$pai = new PaiementFourn($this->db);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$fac = new Facture($this->db);
|
$fac = new Facture($this->db);
|
||||||
$pai = new Paiement($this->db);
|
$pai = new Paiement($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fac->fetch($facs[$i][0]);
|
$fac->fetch($facs[$i][0]);
|
||||||
|
|
||||||
// Make a negative payment
|
// Make a negative payment
|
||||||
@ -296,7 +295,7 @@ class RejetPrelevement
|
|||||||
//$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)";
|
||||||
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)";
|
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 .= " 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 .= " WHERE pf.fk_prelevement_lignes = ".$this->id;
|
||||||
$sql .= " AND f.entity IN (".getEntity('invoice').")";
|
$sql .= " AND f.entity IN (".getEntity('invoice').")";
|
||||||
|
|||||||
@ -99,14 +99,14 @@ if ($action == 'confirm_rejet')
|
|||||||
|
|
||||||
$rej->create($user, $id, GETPOST('motif', 'alpha'), $daterej, $lipre->bon_rowid, GETPOST('facturer', 'int'));
|
$rej->create($user, $id, GETPOST('motif', 'alpha'), $daterej, $lipre->bon_rowid, GETPOST('facturer', 'int'));
|
||||||
|
|
||||||
header("Location: line.php?id=".$id.'&type='.$type);
|
header("Location: line.php?id=".urlencode($id).'&type='.urlencode($type));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$action = "rejet";
|
$action = "rejet";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
header("Location: line.php?id=".$id.'&type='.$type);
|
header("Location: line.php?id=".urlencode($id).'&type='.urlencode($type));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -317,7 +317,39 @@ if (empty($reshook))
|
|||||||
// payments conditions
|
// payments conditions
|
||||||
if ($action == 'setconditions' && $usercancreate)
|
if ($action == 'setconditions' && $usercancreate)
|
||||||
{
|
{
|
||||||
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
|
$object->fetch($id);
|
||||||
|
$object->cond_reglement_code = 0; // To clean property
|
||||||
|
$object->cond_reglement_id = 0; // To clean property
|
||||||
|
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
|
if (! $error) {
|
||||||
|
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error) {
|
||||||
|
$old_date_echeance = $object->date_echeance;
|
||||||
|
$new_date_echeance = $object->calculate_date_lim_reglement();
|
||||||
|
if ($new_date_echeance > $old_date_echeance) $object->date_echeance = $new_date_echeance;
|
||||||
|
if ($object->date_echeance < $object->date) $object->date_echeance = $object->date;
|
||||||
|
$result = $object->update($user);
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($error) {
|
||||||
|
$db->rollback();
|
||||||
|
} else {
|
||||||
|
$db->commit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set incoterm
|
// Set incoterm
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user