34trait CommonSignedObject
40 public $signed_status = 0;
47 public static $SIGNED_STATUSES = [
48 'STATUS_NO_SIGNATURE' => 0,
49 'STATUS_SIGNED_SENDER' => 1,
50 'STATUS_SIGNED_RECEIVER' => 2,
51 'STATUS_SIGNED_RECEIVER_ONLINE' => 3,
52 'STATUS_SIGNED_ALL' => 9
63 $langs->load(
"commercial");
65 $l10n_signed_status_labels = [
66 self::$SIGNED_STATUSES[
'STATUS_NO_SIGNATURE'] =>
'NoSignature',
67 self::$SIGNED_STATUSES[
'STATUS_SIGNED_SENDER'] =>
'SignedSender',
68 self::$SIGNED_STATUSES[
'STATUS_SIGNED_RECEIVER'] =>
'SignedReceiver',
69 self::$SIGNED_STATUSES[
'STATUS_SIGNED_RECEIVER_ONLINE'] =>
'SignedReceiverOnline',
70 self::$SIGNED_STATUSES[
'STATUS_SIGNED_ALL'] =>
'SignedAll'
73 $l10n_signed_status = [];
74 foreach (self::$SIGNED_STATUSES as $signed_status_code) {
75 $l10n_signed_status[$signed_status_code] = $langs->transnoentitiesnoconv($l10n_signed_status_labels[$signed_status_code]);
77 return $l10n_signed_status;
89 public function setSignedStatus(
User $user,
int $status = 0,
int $notrigger = 0,
string $triggercode =
''): int
92 $langs->loadLangs(array(
'commercial'));
93 $this->signed_status = $status;
94 $this->context[
'signature'] = $status;
97 $this->context[
'actionmsg2'] = $langs->transnoentitiesnoconv(
'UnsignedInDolibarr');
100 $this->context[
'actionmsg2'] = $langs->transnoentitiesnoconv(
'SignedSender');
103 $this->context[
'actionmsg2'] = $langs->transnoentitiesnoconv(
'SignedReceiver');
106 $this->context[
'actionmsg2'] = $langs->transnoentitiesnoconv(
'SignedReceiverOnline');
109 $this->context[
'actionmsg2'] = $langs->transnoentitiesnoconv(
'SignedAll');
127 $langs->loadLangs(array(
'commercial'));
133 $statusfield =
'signed_status';
135 $sql =
"UPDATE ".$this->db->prefix().$this->table_element;
136 $sql .=
" SET ".$statusfield.
" = ".((int) $status);
137 $sql .=
" WHERE rowid = ".((int) $this->
id);
139 if ($this->db->query($sql)) {
141 $this->oldcopy = clone $this;
144 if (!$error && !$notrigger) {
146 $result = $this->call_trigger($triggercode, $user);
153 $this->signed_status = $status;
155 setEventMessages($langs->transnoentitiesnoconv(
'DocumentSigned'),
null,
'warnings');
158 $this->db->rollback();
162 $this->error = $this->db->error();
163 $this->db->rollback();
180 $langs->load(
"commercial");
182 $signed_status_label = $this->signed_status !=
'' ? $list_signed_status[$this->signed_status] :
'';
183 $signed_status_label_short = $this->signed_status !=
'' ? $list_signed_status[$this->signed_status] :
'';
184 $signed_status_code =
'status'.$this->signed_status;
185 return dolGetStatus($signed_status_label, $signed_status_label_short,
'', $signed_status_code, $mode);
Parent class of all other business classes (invoices, contracts, proposals, orders,...
Class to manage Dolibarr users.
setSignedStatusCommon(User $user, int $status, int $notrigger=0, string $triggercode='')
Set signed status & call trigger with context message.
setSignedStatus(User $user, int $status=0, int $notrigger=0, string $triggercode='')
Set signed status & object context.
getSignedStatusLocalisedArray()
Returns an array of signed statuses with associated localized labels.
getLibSignedStatus(int $mode=0)
Returns the label for signed status.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.