diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php
index 953b48a8adf..8035c2a2e98 100644
--- a/htdocs/fichinter/card.php
+++ b/htdocs/fichinter/card.php
@@ -1577,7 +1577,7 @@ else if ($id > 0 || ! empty($ref))
{
if ($action != 'editdescription' && ($action != 'presend')) {
// Validate
- if ($object->statut == 0 && (count($object->lines) > 0 || !empty($conf->global->FICHINTER_DISABLE_DETAILS))) {
+ if ($object->statut == Fichinter::STATUS_DRAFT && (count($object->lines) > 0 || !empty($conf->global->FICHINTER_DISABLE_DETAILS))) {
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->validate)) {
print '
';
@@ -1585,7 +1585,7 @@ else if ($id > 0 || ! empty($ref))
}
// Modify
- if ($object->statut == 1 && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->unvalidate)))
+ if ($object->statut == Fichinter::STATUS_VALIDATED && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->unvalidate)))
{
print '';
if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) print $langs->trans("Modify");
@@ -1594,7 +1594,7 @@ else if ($id > 0 || ! empty($ref))
}
// Send
- if ($object->statut > 0)
+ if ($object->statut > Fichinter::STATUS_DRAFT)
{
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send)
{
@@ -1606,10 +1606,10 @@ else if ($id > 0 || ! empty($ref))
// Event agenda
if (! empty($conf->global->FICHINTER_ADDLINK_TO_EVENT))
{
- if (! empty($conf->agenda->enabled) && $object->statut > 0)
+ if (! empty($conf->agenda->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
{
$langs->load("agenda");
- if ($object->statut < 2)
+ if ($object->statut < Fichinter::STATUS_BILLED)
{
if ($user->rights->agenda->myactions->create) print '';
else print '';
@@ -1618,10 +1618,10 @@ else if ($id > 0 || ! empty($ref))
}
// Proposal
- if (! empty($conf->propal->enabled) && $object->statut > 0)
+ if (! empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
{
$langs->load("propal");
- if ($object->statut < 2)
+ if ($object->statut < Fichinter::STATUS_BILLED)
{
if ($user->rights->propal->creer) print '';
else print '';
@@ -1629,10 +1629,10 @@ else if ($id > 0 || ! empty($ref))
}
// Invoicing
- if (! empty($conf->facture->enabled) && $object->statut > 0)
+ if (! empty($conf->facture->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
{
$langs->load("bills");
- if ($object->statut < 2)
+ if ($object->statut < Fichinter::STATUS_BILLED)
{
if ($user->rights->facture->creer) print '';
else print '';
@@ -1640,7 +1640,7 @@ else if ($id > 0 || ! empty($ref))
if (! empty($conf->global->FICHINTER_CLASSIFY_BILLED)) // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
{
- if ($object->statut != 2)
+ if ($object->statut != Fichinter::STATUS_BILLED)
{
print '';
}
@@ -1652,7 +1652,7 @@ else if ($id > 0 || ! empty($ref))
}
// Done
- if (empty($conf->global->FICHINTER_CLASSIFY_BILLED) && $object->statut > 0 && $object->statut < 3)
+ if (empty($conf->global->FICHINTER_CLASSIFY_BILLED) && $object->statut > Fichinter::STATUS_DRAFT && $object->statut < Fichinter::STATUS_CLOSED)
{
print '';
}
@@ -1663,7 +1663,7 @@ else if ($id > 0 || ! empty($ref))
}
// Delete
- if (($object->statut == 0 && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer)
+ if (($object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer)
{
print '';
diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php
index 6142d87de7a..eaf10c357e4 100644
--- a/htdocs/fichinter/class/fichinter.class.php
+++ b/htdocs/fichinter/class/fichinter.class.php
@@ -39,7 +39,7 @@ class Fichinter extends CommonObject
public $fk_element='fk_fichinter';
public $table_element_line='fichinterdet';
public $picto = 'intervention';
-
+
/**
* {@inheritdoc}
*/
@@ -62,6 +62,23 @@ class Fichinter extends CommonObject
var $lines = array();
+ /**
+ * Draft status
+ */
+ const STATUS_DRAFT = 0;
+ /**
+ * Validated status
+ */
+ const STATUS_VALIDATED = 1;
+ /**
+ * Billed
+ */
+ const STATUS_BILLED = 2;
+ /**
+ * Closed
+ */
+ const STATUS_CLOSED = 3;
+
/**
* Constructor
*
@@ -361,7 +378,7 @@ class Fichinter extends CommonObject
$this->fk_contrat = $obj->fk_contrat;
$this->user_creation= $obj->fk_user_author;
-
+
$this->extraparams = (array) json_decode($obj->extraparams, true);
if ($this->statut == 0) $this->brouillon = 1;
@@ -546,23 +563,23 @@ class Fichinter extends CommonObject
*/
function getAmount() {
global $db;
-
+
$amount = 0;
-
+
$this->author = new User($db);
$this->author->fetch($this->user_creation);
-
+
$thm = $this->author->thm;
-
+
foreach($this->lines as &$line) {
-
+
$amount+=$line->qty * $thm;
-
+
}
-
+
return $amount;
}
-
+
/**
* Returns the label status
*
@@ -599,7 +616,7 @@ class Fichinter extends CommonObject
return ''.$langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
if ($mode == 6)
return ''.$langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
-
+
return '';
}
@@ -949,7 +966,7 @@ class Fichinter extends CommonObject
return -2;
}
-
+
/**
* Load an object from its id and create a new one in database
@@ -1001,7 +1018,7 @@ class Fichinter extends CommonObject
$this->date_creation = '';
$this->date_validation = '';
$this->ref_client = '';
-
+
// Create clone
$result=$this->create($user);
if ($result < 0) $error++;
@@ -1013,7 +1030,7 @@ class Fichinter extends CommonObject
{
$this->addline($user, $this->id, $line->desc, $line->datei, $line->duration);
}
-
+
// Hook of thirdparty module
if (is_object($hookmanager))
{
@@ -1043,8 +1060,8 @@ class Fichinter extends CommonObject
return -1;
}
}
-
-
+
+
/**
* Adding a line of intervention into data base
*