deprecate statut (#33691)

* deprecate statut

* Update fichinter.class.php

* clean code

* clean code

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Frédéric FRANCE
2025-04-02 11:27:17 +02:00
committed by GitHub
parent 91fa444129
commit 51624f8a50
3 changed files with 39 additions and 33 deletions

View File

@@ -7,7 +7,7 @@
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 Nick Fragoulis
* Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
*
@@ -152,7 +152,7 @@ class pdf_soleil extends ModelePDFFicheinter
$outputlangs->loadLangs(array("main", "interventions", "dict", "companies", "compta"));
// Show Draft Watermark
if ($object->statut == $object::STATUS_DRAFT && (getDolGlobalString('FICHINTER_DRAFT_WATERMARK'))) {
if ($object->status == $object::STATUS_DRAFT && (getDolGlobalString('FICHINTER_DRAFT_WATERMARK'))) {
$this->watermark = getDolGlobalString('FICHINTER_DRAFT_WATERMARK');
}

View File

@@ -118,7 +118,7 @@ $result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$permissionnote = $user->hasRight('ficheinter', 'creer'); // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->hasRight('ficheinter', 'creer'); // Used by the include of actions_dellink.inc.php
$permissiontodelete = (($object->statut == Fichinter::STATUS_DRAFT && $user->hasRight('ficheinter', 'creer')) || $user->hasRight('ficheinter', 'supprimer'));
$permissiontodelete = (($object->status == Fichinter::STATUS_DRAFT && $user->hasRight('ficheinter', 'creer')) || $user->hasRight('ficheinter', 'supprimer'));
$permissiontoadd = $user->hasRight('ficheinter', 'creer');
$permissiontoeditextra = $permissiontoadd;
if (GETPOST('attribute', 'aZ09') && isset($extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')])) {
@@ -1555,7 +1555,7 @@ if ($action == 'create') {
print "</td>\n";
// Icon to edit and delete
if ($object->statut == 0 && $user->hasRight('ficheinter', 'creer')) {
if ($object->status == 0 && $user->hasRight('ficheinter', 'creer')) {
print '<td class="center">';
print '<a class="editfielda marginrightonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=editline&token='.newToken().'&line_id='.$objp->rowid.'#'.$objp->rowid.'">';
print img_edit();
@@ -1585,7 +1585,7 @@ if ($action == 'create') {
}
// Line in update mode
if ($object->statut == 0 && $action == 'editline' && $user->hasRight('ficheinter', 'creer') && GETPOSTINT('line_id') == $objp->rowid) {
if ($object->status == 0 && $action == 'editline' && $user->hasRight('ficheinter', 'creer') && GETPOSTINT('line_id') == $objp->rowid) {
print '<tr class="oddeven nohover">';
// No.
@@ -1648,7 +1648,7 @@ if ($action == 'create') {
$db->free($resql);
// Add new line
if ($object->statut == 0 && $user->hasRight('ficheinter', 'creer') && $action != 'editline' && (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') || getDolGlobalString('FICHINTER_DISABLE_DETAILS') == '2')) {
if ($object->status == 0 && $user->hasRight('ficheinter', 'creer') && $action != 'editline' && (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') || getDolGlobalString('FICHINTER_DISABLE_DETAILS') == '2')) {
if (!$num) {
print '<br>';
print '<table class="noborder centpercent">';
@@ -1766,7 +1766,7 @@ if ($action == 'create') {
if ($user->socid == 0) {
if ($action != 'editdescription' && ($action != 'presend')) {
// Validate
if ($object->statut == Fichinter::STATUS_DRAFT && (count($object->lines) > 0 || getDolGlobalString('FICHINTER_DISABLE_DETAILS') == '1')) {
if ($object->status == Fichinter::STATUS_DRAFT && (count($object->lines) > 0 || getDolGlobalString('FICHINTER_DISABLE_DETAILS') == '1')) {
if ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('ficheinter', 'creer')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('ficheinter', 'ficheinter_advance', 'validate'))) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=validate&token='.newToken().'">'.$langs->trans("Validate").'</a></div>';
} else {
@@ -1775,7 +1775,7 @@ if ($action == 'create') {
}
// Modify
if ($object->statut == Fichinter::STATUS_VALIDATED && ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('ficheinter', 'creer')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('ficheinter', 'ficheinter_advance', 'unvalidate')))) {
if ($object->status == Fichinter::STATUS_VALIDATED && ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('ficheinter', 'creer')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('ficheinter', 'ficheinter_advance', 'unvalidate')))) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=modify&token='.newToken().'">';
if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') || getDolGlobalString('FICHINTER_DISABLE_DETAILS') == '2') {
print $langs->trans("Modify");
@@ -1786,7 +1786,7 @@ if ($action == 'create') {
}
// Reopen
if ($object->statut >= Fichinter::STATUS_CLOSED) {
if ($object->status >= Fichinter::STATUS_CLOSED) {
if ($user->hasRight('ficheinter', 'creer')) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken().'">'.$langs->trans('ReOpen').'</a></div>';
} else {
@@ -1796,7 +1796,7 @@ if ($action == 'create') {
// Send
if (empty($user->socid)) {
if ($object->statut > Fichinter::STATUS_DRAFT) {
if ($object->status > Fichinter::STATUS_DRAFT) {
if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || $user->hasRight('ficheinter', 'ficheinter_advance', 'send')) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>';
} else {
@@ -1806,7 +1806,7 @@ if ($action == 'create') {
}
// Create intervention model
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1 && $object->statut == Fichinter::STATUS_DRAFT && $user->hasRight('ficheinter', 'creer') && (count($object->lines) > 0)) {
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1 && $object->status == Fichinter::STATUS_DRAFT && $user->hasRight('ficheinter', 'creer') && (count($object->lines) > 0)) {
print '<div class="inline-block divButAction">';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$object->id.'&action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id).'">'.$langs->trans("ChangeIntoRepeatableIntervention").'</a>';
print '</div>';
@@ -1814,9 +1814,9 @@ if ($action == 'create') {
$arrayofcreatebutton = array();
// Proposal
if (isModEnabled("service") && isModEnabled("propal") && $object->statut > Fichinter::STATUS_DRAFT) {
if (isModEnabled("service") && isModEnabled("propal") && $object->status > Fichinter::STATUS_DRAFT) {
$langs->load("propal");
if ($object->statut < Fichinter::STATUS_BILLED) {
if ($object->status < Fichinter::STATUS_BILLED) {
$arrayofcreatebutton[] = array(
'url' => '/comm/propal/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid,
'label' => $langs->trans('AddProp'),
@@ -1828,9 +1828,9 @@ if ($action == 'create') {
}
// Invoicing
if (isModEnabled('invoice') && $object->statut > Fichinter::STATUS_DRAFT) {
if (isModEnabled('invoice') && $object->status > Fichinter::STATUS_DRAFT) {
$langs->load("bills");
if ($object->statut < Fichinter::STATUS_BILLED) {
if ($object->status < Fichinter::STATUS_BILLED) {
$arrayofcreatebutton[] = array(
'url' => '/compta/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid,
'label' => $langs->trans('AddBill'),
@@ -1841,7 +1841,7 @@ if ($action == 'create') {
}
if (getDolGlobalString('FICHINTER_CLASSIFY_BILLED')) { // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
if ($object->statut != Fichinter::STATUS_BILLED) {
if ($object->status != Fichinter::STATUS_BILLED) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifybilled&token='.newToken().'">'.$langs->trans("InterventionClassifyBilled").'</a></div>';
} else {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifyunbilled&token='.newToken().'">'.$langs->trans("InterventionClassifyUnBilled").'</a></div>';
@@ -1854,7 +1854,7 @@ if ($action == 'create') {
}
// Sign
if ($object->statut > Fichinter::STATUS_DRAFT) {
if ($object->status > Fichinter::STATUS_DRAFT) {
if ($object->signed_status != Fichinter::$SIGNED_STATUSES['STATUS_SIGNED_ALL']) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=sign&token=' . newToken() . '">' . $langs->trans("InterventionSign") . '</a></div>';
} else {
@@ -1863,7 +1863,7 @@ if ($action == 'create') {
}
// Done
if (!getDolGlobalString('FICHINTER_CLASSIFY_BILLED') && $object->statut > Fichinter::STATUS_DRAFT && $object->statut < Fichinter::STATUS_CLOSED) {
if (!getDolGlobalString('FICHINTER_CLASSIFY_BILLED') && $object->status > Fichinter::STATUS_DRAFT && $object->status < Fichinter::STATUS_CLOSED) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifydone&token='.newToken().'">'.$langs->trans("InterventionClassifyDone").'</a></div>';
}
@@ -1904,13 +1904,13 @@ if ($action == 'create') {
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
// Show direct download link
if ($object->statut != Fichinter::STATUS_DRAFT && getDolGlobalString('FICHINTER_ALLOW_EXTERNAL_DOWNLOAD')) {
if ($object->status != Fichinter::STATUS_DRAFT && getDolGlobalString('FICHINTER_ALLOW_EXTERNAL_DOWNLOAD')) {
print '<br><!-- Link to download main doc -->'."\n";
print showDirectDownloadLink($object).'<br>';
}
// Show online signature link
if ($object->statut != Fichinter::STATUS_DRAFT && getDolGlobalString('FICHINTER_ALLOW_ONLINE_SIGN')) {
if ($object->status != Fichinter::STATUS_DRAFT && getDolGlobalString('FICHINTER_ALLOW_ONLINE_SIGN')) {
print '<br><!-- Link to sign -->';
require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';

View File

@@ -6,7 +6,7 @@
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015-2020 Charlene Benke <charlie@patas-monkey.com>
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2023-2024 William Mead <william.mead@manchenumerique.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
@@ -145,9 +145,15 @@ class Fichinter extends CommonObject
/**
* @var int status
* @deprecated Use $status instead
*/
public $statut = 0; // 0=draft, 1=validated, 2=invoiced, 3=Terminate
/**
* @var int status
*/
public $status = 0; // 0=draft, 1=validated, 2=invoiced, 3=Terminate
/**
* @var string description
*/
@@ -340,7 +346,7 @@ class Fichinter extends CommonObject
$sql .= ", '".$this->db->escape($this->model_pdf)."'";
$sql .= ", ".($this->fk_project ? ((int) $this->fk_project) : 0);
$sql .= ", ".($this->fk_contrat ? ((int) $this->fk_contrat) : 0);
$sql .= ", ".((int) $this->statut);
$sql .= ", ".((int) $this->status);
$sql .= ", ".($this->signed_status);
$sql .= ", ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null");
$sql .= ", ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null");
@@ -555,7 +561,7 @@ class Fichinter extends CommonObject
$error = 0;
// Protection
if ($this->statut <= self::STATUS_DRAFT) {
if ($this->status <= self::STATUS_DRAFT) {
return 0;
}
@@ -580,7 +586,8 @@ class Fichinter extends CommonObject
}
if (!$error) {
$this->statut = self::STATUS_DRAFT;
$this->status = self::STATUS_DRAFT;
$this->statut = self::STATUS_DRAFT; // deprecated
$this->db->commit();
return 1;
} else {
@@ -725,7 +732,7 @@ class Fichinter extends CommonObject
$error = 0;
if ($this->statut == self::STATUS_CLOSED) {
if ($this->status == self::STATUS_CLOSED) {
return 0;
} else {
$this->db->begin();
@@ -751,7 +758,8 @@ class Fichinter extends CommonObject
}
if (!$error) {
$this->statut = self::STATUS_CLOSED;
$this->status = self::STATUS_CLOSED;
$this->statut = self::STATUS_CLOSED; // deprecated
$this->db->commit();
return 1;
} else {
@@ -884,9 +892,7 @@ class Fichinter extends CommonObject
$datas = [];
$datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("ShowIntervention").'</u>';
if (isset($this->status)) {
$datas['picto'] .= ' '.$this->getLibStatut(5);
}
$datas['picto'] .= ' '.$this->getLibStatut(5);
$datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
return $datas;
@@ -1340,12 +1346,12 @@ class Fichinter extends CommonObject
$this->statut = self::STATUS_DRAFT; // deprecated
// Clear fields
$this->user_author_id = $user->id;
$this->user_author_id = $user->id;
$this->user_validation_id = 0;
$this->date_creation = '';
$this->date_validation = '';
$this->date_creation = '';
$this->date_validation = '';
$this->ref_client = '';
$this->ref_client = '';
if (!$clone_notes) {
$this->note_private = '';