Debug v17
This commit is contained in:
parent
93927cceff
commit
c3da1554a7
@ -958,7 +958,14 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) {
|
||||
foreach ($toselect as $toselectid) {
|
||||
$result = $objecttmp->fetch($toselectid);
|
||||
if ($result > 0) {
|
||||
$result = $objecttmp->validate($user);
|
||||
if (method_exists($objecttmp, 'validate')) {
|
||||
$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) {
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref), null, 'errors');
|
||||
|
||||
@ -1098,7 +1098,7 @@ class Project extends CommonObject
|
||||
*
|
||||
* @param User $user User that validate
|
||||
* @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)
|
||||
{
|
||||
@ -1106,47 +1106,51 @@ class Project extends CommonObject
|
||||
|
||||
$error = 0;
|
||||
|
||||
if ($this->statut != 1) {
|
||||
// Check parameters
|
||||
if (preg_match('/^'.preg_quote($langs->trans("CopyOf").' ').'/', $this->title)) {
|
||||
$this->error = $langs->trans("ErrorFieldFormat", $langs->transnoentities("Label")).'. '.$langs->trans('RemoveString', $langs->transnoentitiesnoconv("CopyOf"));
|
||||
return -1;
|
||||
// Protection
|
||||
if ($this->status == self::STATUS_VALIDATED) {
|
||||
dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check parameters
|
||||
if (preg_match('/^'.preg_quote($langs->trans("CopyOf").' ').'/', $this->title)) {
|
||||
$this->error = $langs->trans("ErrorFieldFormat", $langs->transnoentities("Label")).'. '.$langs->trans('RemoveString', $langs->transnoentitiesnoconv("CopyOf"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."projet";
|
||||
$sql .= " SET fk_statut = ".self::STATUS_VALIDATED;
|
||||
$sql .= " WHERE rowid = ".((int) $this->id);
|
||||
$sql .= " AND entity = ".((int) $conf->entity);
|
||||
|
||||
dol_syslog(get_class($this)."::setValid", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
// Call trigger
|
||||
if (empty($notrigger)) {
|
||||
$result = $this->call_trigger('PROJECT_VALIDATE', $user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."projet";
|
||||
$sql .= " SET fk_statut = 1";
|
||||
$sql .= " WHERE rowid = ".((int) $this->id);
|
||||
$sql .= " AND entity = ".((int) $conf->entity);
|
||||
|
||||
dol_syslog(get_class($this)."::setValid", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
// Call trigger
|
||||
if (empty($notrigger)) {
|
||||
$result = $this->call_trigger('PROJECT_VALIDATE', $user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$this->statut = 1;
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
$this->error = join(',', $this->errors);
|
||||
dol_syslog(get_class($this)."::setValid ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
if (!$error) {
|
||||
$this->statut = 1;
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->error = join(',', $this->errors);
|
||||
dol_syslog(get_class($this)."::setValid ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -888,6 +888,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
|
||||
// List of mass actions available
|
||||
$arrayofmassactions = array(
|
||||
'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
|
||||
'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
|
||||
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
|
||||
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user