This commit is contained in:
Laurent Destailleur 2017-07-25 21:22:22 +02:00
parent 5b9ac2a7a9
commit 521d61c5ef
2 changed files with 45 additions and 28 deletions

View File

@ -1577,7 +1577,7 @@ else if ($id > 0 || ! empty($ref))
{ {
if ($action != 'editdescription' && ($action != 'presend')) { if ($action != 'editdescription' && ($action != 'presend')) {
// Validate // 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)) { 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 '<div class="inline-block divButAction"><a class="butAction" href="card.php?id=' . $object->id . '&action=validate"'; print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id=' . $object->id . '&action=validate"';
print '>' . $langs->trans("Validate") . '</a></div>'; print '>' . $langs->trans("Validate") . '</a></div>';
@ -1585,7 +1585,7 @@ else if ($id > 0 || ! empty($ref))
} }
// Modify // 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 '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=modify">'; print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=modify">';
if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) print $langs->trans("Modify"); if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) print $langs->trans("Modify");
@ -1594,7 +1594,7 @@ else if ($id > 0 || ! empty($ref))
} }
// Send // 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) 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 // Event agenda
if (! empty($conf->global->FICHINTER_ADDLINK_TO_EVENT)) 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"); $langs->load("agenda");
if ($object->statut < 2) if ($object->statut < Fichinter::STATUS_BILLED)
{ {
if ($user->rights->agenda->myactions->create) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'&amp;backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("AddEvent").'</a></div>'; if ($user->rights->agenda->myactions->create) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'&amp;backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("AddEvent").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddEvent").'</a></div>'; else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddEvent").'</a></div>';
@ -1618,10 +1618,10 @@ else if ($id > 0 || ! empty($ref))
} }
// Proposal // Proposal
if (! empty($conf->propal->enabled) && $object->statut > 0) if (! empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
{ {
$langs->load("propal"); $langs->load("propal");
if ($object->statut < 2) if ($object->statut < Fichinter::STATUS_BILLED)
{ {
if ($user->rights->propal->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddProp").'</a></div>'; if ($user->rights->propal->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddProp").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddProp").'</a></div>'; else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddProp").'</a></div>';
@ -1629,10 +1629,10 @@ else if ($id > 0 || ! empty($ref))
} }
// Invoicing // Invoicing
if (! empty($conf->facture->enabled) && $object->statut > 0) if (! empty($conf->facture->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
{ {
$langs->load("bills"); $langs->load("bills");
if ($object->statut < 2) if ($object->statut < Fichinter::STATUS_BILLED)
{ {
if ($user->rights->facture->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddBill").'</a></div>'; if ($user->rights->facture->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddBill").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddBill").'</a></div>'; else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddBill").'</a></div>';
@ -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 (! 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 '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("InterventionClassifyBilled").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("InterventionClassifyBilled").'</a></div>';
} }
@ -1652,7 +1652,7 @@ else if ($id > 0 || ! empty($ref))
} }
// Done // 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 '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifydone">'.$langs->trans("InterventionClassifyDone").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifydone">'.$langs->trans("InterventionClassifyDone").'</a></div>';
} }
@ -1663,7 +1663,7 @@ else if ($id > 0 || ! empty($ref))
} }
// Delete // 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 '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete"'; print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete"';
print '>'.$langs->trans('Delete').'</a></div>'; print '>'.$langs->trans('Delete').'</a></div>';

View File

@ -39,7 +39,7 @@ class Fichinter extends CommonObject
public $fk_element='fk_fichinter'; public $fk_element='fk_fichinter';
public $table_element_line='fichinterdet'; public $table_element_line='fichinterdet';
public $picto = 'intervention'; public $picto = 'intervention';
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -62,6 +62,23 @@ class Fichinter extends CommonObject
var $lines = array(); 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 * Constructor
* *
@ -361,7 +378,7 @@ class Fichinter extends CommonObject
$this->fk_contrat = $obj->fk_contrat; $this->fk_contrat = $obj->fk_contrat;
$this->user_creation= $obj->fk_user_author; $this->user_creation= $obj->fk_user_author;
$this->extraparams = (array) json_decode($obj->extraparams, true); $this->extraparams = (array) json_decode($obj->extraparams, true);
if ($this->statut == 0) $this->brouillon = 1; if ($this->statut == 0) $this->brouillon = 1;
@ -546,23 +563,23 @@ class Fichinter extends CommonObject
*/ */
function getAmount() { function getAmount() {
global $db; global $db;
$amount = 0; $amount = 0;
$this->author = new User($db); $this->author = new User($db);
$this->author->fetch($this->user_creation); $this->author->fetch($this->user_creation);
$thm = $this->author->thm; $thm = $this->author->thm;
foreach($this->lines as &$line) { foreach($this->lines as &$line) {
$amount+=$line->qty * $thm; $amount+=$line->qty * $thm;
} }
return $amount; return $amount;
} }
/** /**
* Returns the label status * Returns the label status
* *
@ -599,7 +616,7 @@ class Fichinter extends CommonObject
return '<span class="hideonsmartphone">'.$langs->trans($this->statuts_short[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]); return '<span class="hideonsmartphone">'.$langs->trans($this->statuts_short[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
if ($mode == 6) if ($mode == 6)
return '<span class="hideonsmartphone">'.$langs->trans($this->statuts[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]); return '<span class="hideonsmartphone">'.$langs->trans($this->statuts[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
return ''; return '';
} }
@ -949,7 +966,7 @@ class Fichinter extends CommonObject
return -2; return -2;
} }
/** /**
* Load an object from its id and create a new one in database * 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_creation = '';
$this->date_validation = ''; $this->date_validation = '';
$this->ref_client = ''; $this->ref_client = '';
// Create clone // Create clone
$result=$this->create($user); $result=$this->create($user);
if ($result < 0) $error++; if ($result < 0) $error++;
@ -1013,7 +1030,7 @@ class Fichinter extends CommonObject
{ {
$this->addline($user, $this->id, $line->desc, $line->datei, $line->duration); $this->addline($user, $this->id, $line->desc, $line->datei, $line->duration);
} }
// Hook of thirdparty module // Hook of thirdparty module
if (is_object($hookmanager)) if (is_object($hookmanager))
{ {
@ -1043,8 +1060,8 @@ class Fichinter extends CommonObject
return -1; return -1;
} }
} }
/** /**
* Adding a line of intervention into data base * Adding a line of intervention into data base
* *