Merge branch '12.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/compta/prelevement/line.php
This commit is contained in:
Laurent Destailleur 2020-10-23 04:00:45 +02:00
commit 254da6923b
5 changed files with 70 additions and 20 deletions

View File

@ -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);
$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_lim_reglement = $object->date_lim_reglement; $old_date_lim_reglement = $object->date_lim_reglement;
$new_date_lim_reglement = $object->calculate_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 ($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; if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date;
$result = $object->update($user); $result = $object->update($user);
if ($result < 0) { if ($result < 0) {
dol_print_error($db, $object->error); $error++;
setEventMessages($object->error, $object->errors, 'errors');
}
}
if ($error) {
$db->rollback();
} else {
$db->commit();
} }
} elseif ($action == 'setpaymentterm' && $usercancreate) } elseif ($action == 'setpaymentterm' && $usercancreate)
{ {

View File

@ -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/>.
*
*/ */
/** /**

View File

@ -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;
} }
} }

View File

@ -317,7 +317,39 @@ if (empty($reshook))
// payments conditions // payments conditions
if ($action == 'setconditions' && $usercancreate) if ($action == 'setconditions' && $usercancreate)
{ {
$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')); $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