mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
Qual common signed object trait (#30913)
* Moved signed status properties & methods to reusable class trait * Cleaned code * Updated EN localization * Fixed Phan warnings * Fixed Phan warnings * Added type check. Updated PHPDoc. * Refactored class properties * Cleaned PHPDoc * Revert "Refactored class properties" This reverts commit1beb40a7* Reapply "Refactored class properties" This reverts commit9e3d9d554c. * Fixed PHPDoc * Fixed class file name
This commit is contained in:
@@ -10725,56 +10725,6 @@ abstract class CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set signed status & call trigger with context message
|
||||
*
|
||||
* @param User $user Object user that modify
|
||||
* @param int $status New signed status to set (often a constant like self::STATUS_XXX)
|
||||
* @param int $notrigger 1 = Does not execute triggers, 0 = Execute triggers
|
||||
* @param string $triggercode Trigger code to use
|
||||
* @return int 0 < if KO, > 0 if OK
|
||||
*/
|
||||
public function setSignedStatusCommon(User $user, int $status, int $notrigger = 0, string $triggercode = '')
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$statusfield = 'signed_status';
|
||||
|
||||
$sql = "UPDATE ".$this->db->prefix().$this->table_element;
|
||||
$sql .= " SET ".$statusfield." = ".((int) $status);
|
||||
$sql .= " WHERE rowid = ".((int) $this->id);
|
||||
|
||||
if ($this->db->query($sql)) {
|
||||
if (!$error) {
|
||||
$this->oldcopy = clone $this;
|
||||
}
|
||||
|
||||
if (!$error && !$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger($triggercode, $user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$this->signed_status = $status;
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
$this->error = $this->db->error();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialise object with example values
|
||||
* Id must be 0 if object instance is a specimen
|
||||
|
||||
Reference in New Issue
Block a user