manage errors (#37958)

* manage errors

* manage errors

* manage errors

* manage errors

* manage errors
This commit is contained in:
Frédéric FRANCE 2026-04-23 15:29:10 +02:00 committed by GitHub
parent 138056be91
commit 3cffd2739e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 50 additions and 36 deletions

View file

@ -211,14 +211,14 @@ if ($reshook < 0) {
}
if (empty($reshook)) {
$backurlforlist = DOL_URL_ROOT.'/compta/facture/list.php';
$backurlforlist = dolBuildUrl(DOL_URL_ROOT.'/compta/facture/list.php');
if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
$backtopage = $backurlforlist;
} else {
$backtopage = DOL_URL_ROOT.'/compta/facture/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
$backtopage = dolBuildUrl(DOL_URL_ROOT.'/compta/facture/card.php', ['id' => ((!empty($id) && $id > 0) ? $id : '__ID__')]);
}
}
}
@ -473,26 +473,29 @@ if (empty($reshook)) {
} elseif ($action == 'classin' && $usercancreate) {
$object->fetch($id);
$object->setProject(GETPOSTINT('projectid'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'setposinfo' && $usercancreate) {
$object->fetch($id);
$object->module_source = GETPOST('posmodule');
$object->pos_source = GETPOST('posterminal');
$result = $object->update($user);
if ($result < 0) {
dol_print_error($db, $object->error);
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'setmode' && $usercancreate) {
$object->fetch($id);
$result = $object->setPaymentMethods(GETPOSTINT('mode_reglement_id'));
if ($result < 0) {
dol_print_error($db, $object->error);
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'setretainedwarrantyconditions' && $usercancreate) {
$object->fetch($id);
$object->retained_warranty_fk_cond_reglement = 0; // To clean property
$result = $object->setRetainedWarrantyPaymentTerms(GETPOSTINT('retained_warranty_fk_cond_reglement'));
if ($result < 0) {
dol_print_error($db, $object->error);
setEventMessages($object->error, $object->errors, 'errors');
}
$old_rw_date_lim_reglement = $object->retained_warranty_date_limit;
@ -505,19 +508,19 @@ if (empty($reshook)) {
}
$result = $object->update($user);
if ($result < 0) {
dol_print_error($db, $object->error);
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'setretainedwarranty' && $usercancreate) {
$object->fetch($id);
$result = $object->setRetainedWarranty(GETPOSTFLOAT('retained_warranty'));
if ($result < 0) {
dol_print_error($db, $object->error);
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'setretainedwarrantydatelimit' && $usercancreate) {
$object->fetch($id);
$result = $object->setRetainedWarrantyDateLimit(GETPOSTDATE('retained_warranty_date_limit'));
if ($result < 0) {
dol_print_error($db, $object->error);
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'setmulticurrencycode' && $usercancreate) { // Multicurrency Code
$result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha'));
@ -561,7 +564,7 @@ if (empty($reshook)) {
$object->date_pointoftax = $date_pointoftax;
$result = $object->update($user);
if ($result < 0) {
dol_print_error($db, $object->error);
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'setconditions' && $usercancreate) {
$object->fetch($id);
@ -608,7 +611,7 @@ if (empty($reshook)) {
}
$result = $object->update($user);
if ($result < 0) {
dol_print_error($db, $object->error);
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'setrevenuestamp' && $usercancreate) {
$object->fetch($id);
@ -616,7 +619,7 @@ if (empty($reshook)) {
$result = $object->update($user);
$object->update_price(1);
if ($result < 0) {
dol_print_error($db, $object->error);
setEventMessages($object->error, $object->errors, 'errors');
} else {
// Define output language
if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
@ -644,15 +647,30 @@ if (empty($reshook)) {
}
} elseif ($action == 'set_incoterms' && isModEnabled('incoterm') && $usercancreate) { // Set incoterm
$result = $object->setIncoterms(GETPOSTINT('incoterm_id'), GETPOST('location_incoterms'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'set_dispute_status' && $usercancreate) { // Set dispute status
$result = $object->setStatut(GETPOSTINT('dispute_status'), null, 'facture', 'FACTURE_MODIFY', 'dispute_status');
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'settags' && isModEnabled('category') && $usercancreate) { // Set tags
$result = $object->setCategories(GETPOST('categories', 'array'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'setbankaccount' && $usercancreate) { // Bank account
$result = $object->setBankAccount(GETPOSTINT('fk_account'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'setremisepercent' && $usercancreate) {
$object->fetch($id);
$result = $object->setDiscount($user, (float) price2num(GETPOST('remise_percent'), '', 2));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'setabsolutediscount' && $usercancreate) {
// We have POST[remise_id] (common case) xor POST[remise_id_for_payment] (with unstable oldoption)
$db->begin();
@ -738,9 +756,15 @@ if (empty($reshook)) {
} elseif ($action == 'setref' && $usercancreate) {
$object->fetch($id);
$object->setValueFrom('ref', GETPOST('ref'), '', 0, '', '', $user, 'BILL_MODIFY');
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'setref_client' && $usercancreate) {
$object->fetch($id);
$object->set_ref_client(GETPOST('ref_client', 'alpha'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'setdemandreason' && $usercancreate) {
$result = $object->setInputReason($inputReasonId);
if ($result < 0) {

View file

@ -9,7 +9,7 @@
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014-2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2018-2026 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2019 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2022 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2023 Nick Fragoulis
@ -166,14 +166,14 @@ if ($reshook < 0) {
}
if (empty($reshook)) {
$backurlforlist = DOL_URL_ROOT.'/fourn/facture/list.php';
$backurlforlist = dolBuildUrl(DOL_URL_ROOT.'/fourn/facture/list.php');
if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
$backtopage = $backurlforlist;
} else {
$backtopage = DOL_URL_ROOT.'/fourn/facture/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
$backtopage = dolBuildUrl(DOL_URL_ROOT.'/fourn/facture/card.php', ['id' => ((!empty($id) && $id > 0) ? $id : '__ID__')]);
}
}
}
@ -281,7 +281,7 @@ if (empty($reshook)) {
$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) {
dol_print_error($db, $object->error, $object->errors);
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
@ -497,7 +497,7 @@ if (empty($reshook)) {
$object->label = GETPOST('label');
$result = $object->update($user);
if ($result < 0) {
dol_print_error($db);
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'setdatef' && $usercancreate) {
$newdate = dol_mktime(0, 0, 0, GETPOSTINT('datefmonth'), GETPOSTINT('datefday'), GETPOSTINT('datefyear'), 'tzserver');
@ -522,7 +522,7 @@ if (empty($reshook)) {
$result = $object->update($user);
if ($result < 0) {
dol_print_error($db, $object->error);
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'setdate_lim_reglement' && $usercancreate) {
$object->fetch($id);
@ -533,7 +533,7 @@ if (empty($reshook)) {
}
$result = $object->update($user);
if ($result < 0) {
dol_print_error($db, $object->error);
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == "setabsolutediscount" && $usercancreate) {
$db->begin();
@ -1918,7 +1918,7 @@ if (empty($reshook)) {
$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) {
dol_print_error($db, $object->error, $object->errors);
setEventMessages($object->error, $object->errors, 'errors');
}
}

View file

@ -91,16 +91,6 @@ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
print dol_get_fiche_end();
// Buttons
if ((float) DOL_VERSION < 17) { // On v17+, the "New Attribute" button is included into tpl. @phpstan-ignore-line
if ($action != 'create' && $action != 'edit') {
print '<div class="tabsAction">';
print '<a class="butAction reposition" href="'.$_SERVER["PHP_SELF"].'?action=create">'.$langs->trans("NewAttribute").'</a>';
print "</div>";
}
}
/*
* Creation of an optional field
*/

View file

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2023-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2023-2026 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2026 John BOTELLA
*
* This program is free software; you can redistribute it and/or modify
@ -1110,7 +1110,7 @@ class Memo extends CommonObject
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
//$langs->load("quickmemo@quickmemo");
//$langs->load("quickmemo");
$this->labelStatus[self::STATUS_TPL] = $langs->transnoentitiesnoconv('Template');
$this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
$this->labelStatus[self::STATUS_ARCHIVED] = $langs->transnoentitiesnoconv('Archived');

View file

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2026 John BOTELLA
* Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025-2026 Frédéric France <frederic.france@free.fr>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -35,12 +35,12 @@ function quickmemoAdminPrepareHead()
// $extrafields = new ExtraFields($db);
// $extrafields->fetch_name_optionals_label('myobject');
$langs->load("quickmemo@quickmemo");
$langs->load("quickmemo");
$h = 0;
$head = array();
$head[$h][0] = dolBuildUrl(dol_buildpath("/quickmemo/admin/setup.php", 1));
$head[$h][0] = dolBuildUrl(DOL_DOCUMENT_ROOT."/quickmemo/admin/setup.php");
$head[$h][1] = $langs->trans("Settings");
$head[$h][2] = 'settings';
$h++;

View file

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2026 John BOTELLA
* Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025-2026 Frédéric France <frederic.france@free.fr>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -32,7 +32,7 @@ function memoPrepareHead($object)
{
global $db, $langs, $conf;
$langs->load("quickmemo@quickmemo");
$langs->load("quickmemo");
$showtabofpagecontact = getDolGlobalInt('MAIN_QUICKMEMO_SHOW_PAGE_OF_CONTACT');
$showtabofpagenote = getDolGlobalInt('MAIN_QUICKMEMO_SHOW_PAGE_OF_NOTE');