From 0ef249ea524057547d07cefd6333f162701938fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Nov 2019 18:06:33 +0100 Subject: [PATCH] Debug module BOM --- htdocs/bom/bom_list.php | 58 +++++++++++++++++++++++++++++++++- htdocs/langs/en_US/errors.lang | 2 ++ htdocs/main.inc.php | 3 +- 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 40899c56fa7..c61efc84591 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -177,7 +177,7 @@ if (empty($reshook)) if ($objecttmp->status != $objecttmp::STATUS_VALIDATED) { $langs->load("errors"); - setEventMessages($langs->trans("ErrorObjectMustHaveStatusValidatedToBeDisabled", $objecttmp->ref), null, 'errors'); + setEventMessages($langs->trans("ErrorObjectMustHaveStatusActiveToBeDisabled", $objecttmp->ref), null, 'errors'); $error++; break; } @@ -213,6 +213,61 @@ if (empty($reshook)) //var_dump($listofobjectthirdparties);exit; } } + + // Validate records + if (! $error && $massaction == 'enable' && $permissiontoadd) + { + $objecttmp=new $objectclass($db); + + if (! $error) + { + $db->begin(); + + $nbok = 0; + foreach($toselect as $toselectid) + { + $result=$objecttmp->fetch($toselectid); + if ($result > 0) + { + if ($objecttmp->status != $objecttmp::STATUS_DRAFT && $objecttmp->status != $objecttmp::STATUS_CANCELED) + { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorObjectMustHaveStatusDraftOrDisabledToBeActivated", $objecttmp->ref), null, 'errors'); + $error++; + break; + } + + // Can be 'cancel()' or 'close()' + $result = $objecttmp->validate($user); + if ($result < 0) + { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + else $nbok++; + } + else + { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } + + if (! $error) + { + if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + $db->commit(); + } + else + { + $db->rollback(); + } + //var_dump($listofobjectthirdparties);exit; + } + } } @@ -360,6 +415,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), + 'enable'=>$langs->trans("Enable"), 'disable'=>$langs->trans("Disable"), ); if ($user->rights->bom->delete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 0b4b9b61746..96eedb296a3 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -220,6 +220,8 @@ ErrorURLMustStartWithHttp=URL %s must start with http:// or https:// ErrorNewRefIsAlreadyUsed=Error, the new reference is already used ErrorDeletePaymentLinkedToAClosedInvoiceNotPossible=Error, delete payment linked to a closed invoice is not possible. ErrorSearchCriteriaTooSmall=Search criteria too small. +ErrorObjectMustHaveStatusActiveToBeDisabled=Objects must have status 'Active' to be disabled +ErrorObjectMustHaveStatusDraftOrDisabledToBeActivated=Objects must have status 'Draft' or 'Disabled' to be enabled # Warnings WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup. WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user. diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index efbe1a03a5e..858f73afa05 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2567,12 +2567,13 @@ if (! function_exists("llxFooter")) print "\n".''."\n"; print "\n\n"; $hash_unique_id = md5('dolibarr'.$conf->file->instance_unique_id); + $url_for_ping = "https://ping.dolibarr.org/"; ?>