Fix error management when setting product accounts
This commit is contained in:
parent
d1365c2492
commit
39c4df723a
@ -136,17 +136,25 @@ if ($action == 'update') {
|
|||||||
$accounting = new AccountingAccount($db);
|
$accounting = new AccountingAccount($db);
|
||||||
|
|
||||||
//$msg .= '<div><span class="accountingprocessing">' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '</span></div>';
|
//$msg .= '<div><span class="accountingprocessing">' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '</span></div>';
|
||||||
|
$arrayofdifferentselectedvalues = array();
|
||||||
|
|
||||||
$cpt = 0; $ok = 0; $ko = 0;
|
$cpt = 0; $ok = 0; $ko = 0;
|
||||||
foreach ( $chk_prod as $productid ) {
|
foreach ( $chk_prod as $productid )
|
||||||
|
{
|
||||||
$accounting_account_id = GETPOST('codeventil_' . $productid);
|
$accounting_account_id = GETPOST('codeventil_' . $productid);
|
||||||
|
|
||||||
|
$result = 0;
|
||||||
|
if ($accounting_account_id > 0)
|
||||||
|
{
|
||||||
|
$arrayofdifferentselectedvalues[$accounting_account_id]=$accounting_account_id;
|
||||||
$result = $accounting->fetch($accounting_account_id, null, 1);
|
$result = $accounting->fetch($accounting_account_id, null, 1);
|
||||||
if ($result < 0) {
|
}
|
||||||
|
if ($result <= 0) {
|
||||||
// setEventMessages(null, $accounting->errors, 'errors');
|
// setEventMessages(null, $accounting->errors, 'errors');
|
||||||
$msg .= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : id=' . $accounting_account_id . '<br/> <pre>' . $sql . '</pre></font></div>';
|
$msg .= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : id=' . $accounting_account_id . '<br/> <pre>' . $sql . '</pre></font></div>';
|
||||||
|
$ko++;
|
||||||
} else {
|
} else {
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
$sql = " UPDATE " . MAIN_DB_PREFIX . "product";
|
$sql = " UPDATE " . MAIN_DB_PREFIX . "product";
|
||||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
||||||
@ -158,23 +166,23 @@ if ($action == 'update') {
|
|||||||
$sql .= " WHERE rowid = " . $productid;
|
$sql .= " WHERE rowid = " . $productid;
|
||||||
|
|
||||||
dol_syslog("/accountancy/admin/productaccount.php sql=" . $sql, LOG_DEBUG);
|
dol_syslog("/accountancy/admin/productaccount.php sql=" . $sql, LOG_DEBUG);
|
||||||
if ($db->query($sql)) {
|
if ($db->query($sql))
|
||||||
|
{
|
||||||
$ok++;
|
$ok++;
|
||||||
//$msg .= '<div><font color="green">' . $langs->trans("Product") . ' ' . $productid . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accounting->account_number) . '</font></div>';
|
$db->commit();
|
||||||
} else {
|
} else {
|
||||||
$ko++;
|
$ko++;
|
||||||
//$msg .= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accounting->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>';
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$cpt++;
|
$cpt++;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
//$msg .= '<div><span class="accountingprocessing">' . $langs->trans("AnyLineVentilate") . '</span></div>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ko) setEventMessages($langs->trans("XLineFailedToBeBinded", $ko), null, 'errors');
|
if ($ko) setEventMessages($langs->trans("XLineFailedToBeBinded", $ko), null, 'errors');
|
||||||
if ($ok) setEventMessages($langs->trans("XLineSuccessfullyBinded", $ok), null, 'mesgs');
|
if ($ok) setEventMessages($langs->trans("XLineSuccessfullyBinded", $ok), null, 'mesgs');
|
||||||
//$msg .= '<div><span class="accountingprocessing">' . $langs->trans("EndProcessing") . '</span></div>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -82,7 +82,7 @@ class AccountingAccount extends CommonObject
|
|||||||
* @param int $rowid Id
|
* @param int $rowid Id
|
||||||
* @param string $account_number Account number
|
* @param string $account_number Account number
|
||||||
* @param int $limittocurrentchart 1=Do not load record if it is into another accounting system
|
* @param int $limittocurrentchart 1=Do not load record if it is into another accounting system
|
||||||
* @return int <0 if KO, Id of record if OK and found
|
* @return int <0 if KO, 0 if not found, Id of record if OK and found
|
||||||
*/
|
*/
|
||||||
function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0) {
|
function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0) {
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user