Debug v17

This commit is contained in:
Laurent Destailleur 2023-02-19 16:28:04 +01:00
parent 93927cceff
commit c3da1554a7
3 changed files with 49 additions and 37 deletions

View File

@ -958,7 +958,14 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) {
foreach ($toselect as $toselectid) { foreach ($toselect as $toselectid) {
$result = $objecttmp->fetch($toselectid); $result = $objecttmp->fetch($toselectid);
if ($result > 0) { if ($result > 0) {
if (method_exists($objecttmp, 'validate')) {
$result = $objecttmp->validate($user); $result = $objecttmp->validate($user);
} elseif (method_exists($objecttmp, 'setValid')) {
$result = $objecttmp->setValid($user);
} else {
$objecttmp->error = 'No method validate or setValid on this object';
$result = -1;
}
if ($result == 0) { if ($result == 0) {
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref), null, 'errors'); setEventMessages($langs->trans("ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref), null, 'errors');

View File

@ -1098,7 +1098,7 @@ class Project extends CommonObject
* *
* @param User $user User that validate * @param User $user User that validate
* @param int $notrigger 1=Disable triggers * @param int $notrigger 1=Disable triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, 0=Nothing done, >0 if KO
*/ */
public function setValid($user, $notrigger = 0) public function setValid($user, $notrigger = 0)
{ {
@ -1106,7 +1106,12 @@ class Project extends CommonObject
$error = 0; $error = 0;
if ($this->statut != 1) { // Protection
if ($this->status == self::STATUS_VALIDATED) {
dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
return 0;
}
// Check parameters // Check parameters
if (preg_match('/^'.preg_quote($langs->trans("CopyOf").' ').'/', $this->title)) { if (preg_match('/^'.preg_quote($langs->trans("CopyOf").' ').'/', $this->title)) {
$this->error = $langs->trans("ErrorFieldFormat", $langs->transnoentities("Label")).'. '.$langs->trans('RemoveString', $langs->transnoentitiesnoconv("CopyOf")); $this->error = $langs->trans("ErrorFieldFormat", $langs->transnoentities("Label")).'. '.$langs->trans('RemoveString', $langs->transnoentitiesnoconv("CopyOf"));
@ -1116,7 +1121,7 @@ class Project extends CommonObject
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."projet"; $sql = "UPDATE ".MAIN_DB_PREFIX."projet";
$sql .= " SET fk_statut = 1"; $sql .= " SET fk_statut = ".self::STATUS_VALIDATED;
$sql .= " WHERE rowid = ".((int) $this->id); $sql .= " WHERE rowid = ".((int) $this->id);
$sql .= " AND entity = ".((int) $conf->entity); $sql .= " AND entity = ".((int) $conf->entity);
@ -1148,7 +1153,6 @@ class Project extends CommonObject
return -1; return -1;
} }
} }
}
/** /**
* Close a project * Close a project

View File

@ -888,6 +888,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// List of mass actions available // List of mass actions available
$arrayofmassactions = array( $arrayofmassactions = array(
'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),