diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index d3e7691f05a..c7b4ca8e556 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -177,6 +177,7 @@ class Deplacement extends CommonObject $sql .= " SET km = ".$this->km; // This is a distance or amount $sql .= " , dated = '".$this->db->idate($this->date)."'"; $sql .= " , type = '".$this->type."'"; + $sql .= " , fk_statut = '".$this->fk_statut."'"; $sql .= " , fk_user = ".$this->fk_user; $sql .= " , fk_user_modif = ".$user->id; $sql .= " , fk_soc = ".($this->socid > 0?$this->socid:'null'); diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index 14c965373ed..eac993909f1 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -51,6 +51,64 @@ $object = new Deplacement($db); /* * Actions */ +if ($action == 'block' && $user->rights->deplacement->valider) +{ + $object->fetch($id); + if ($object->fk_statut == '2') // Already blocked... + { + $mesg='
'.$langs->trans("Error").'
'; + $action=''; + $error++; + } + else + { + $result = $object->fetch($id); + + $object->fk_statut = '2'; + + $result = $object->update($user); + + if ($result > 0) + { + Header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + exit; + } + else + { + $mesg=$object->error; + } + } +} + +if ($action == 'unblock' && $user->rights->deplacement->unvalidate) +{ + $object->fetch($id); + if ($object->fk_statut == '1') // Not blocked... + { + $mesg='
'.$langs->trans("Error").'
'; + $action=''; + $error++; + } + else + { + $result = $object->fetch($id); + + $object->fk_statut = '1'; + + $result = $object->update($user); + + if ($result > 0) + { + Header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + exit; + } + else + { + $mesg=$object->error; + } + } +} + if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->deplacement->supprimer) { $result=$object->delete($id); @@ -473,23 +531,44 @@ else if ($id) print '
'; - if ($user->rights->deplacement->creer) - { - print ''.$langs->trans('Modify').''; + if ($object->fk_statut == '2') // if blocked... + { + if ($user->rights->deplacement->unvalidate) + { + print ''.$langs->trans('Unblock').''; + } + else + { + print ''.$langs->trans('Unblock').''; + } } - else - { - print ''.$langs->trans('Modify').''; - } - if ($user->rights->deplacement->supprimer) - { - print ''.$langs->trans('Delete').''; - } - else - { - print ''.$langs->trans('Delete').''; - } - + if ($object->fk_statut == '1') // If not blocked... + { + if ($user->rights->deplacement->valider) + { + print ''.$langs->trans('Block').''; + } + else + { + print ''.$langs->trans('Block').''; + } + if ($user->rights->deplacement->creer) + { + print ''.$langs->trans('Modify').''; + } + else + { + print ''.$langs->trans('Modify').''; + } + if ($user->rights->deplacement->supprimer) + { + print ''.$langs->trans('Delete').''; + } + else + { + print ''.$langs->trans('Delete').''; + } + } print '
'; } } diff --git a/htdocs/core/modules/modDeplacement.class.php b/htdocs/core/modules/modDeplacement.class.php index c75a4cc4abe..fb48f5b0628 100644 --- a/htdocs/core/modules/modDeplacement.class.php +++ b/htdocs/core/modules/modDeplacement.class.php @@ -90,17 +90,29 @@ class modDeplacement extends DolibarrModules $this->rights[2][3] = 0; $this->rights[2][4] = 'creer'; - $this->rights[3][0] = 173; + $this->rights[3][0] = 173; $this->rights[3][1] = 'Supprimer les deplacements'; $this->rights[3][2] = 'd'; $this->rights[3][3] = 0; $this->rights[3][4] = 'supprimer'; - - $this->rights[4][0] = 178; - $this->rights[4][1] = 'Exporter les deplacements'; - $this->rights[4][2] = 'd'; + + $this->rights[4][0] = 174; + $this->rights[4][1] = 'Bloquer les deplacements'; + $this->rights[4][2] = 'a'; $this->rights[4][3] = 0; - $this->rights[4][4] = 'export'; + $this->rights[4][4] = 'valider'; + + $this->rights[5][0] = 175; + $this->rights[5][1] = 'Debloquer les deplacements'; + $this->rights[5][2] = 'a'; + $this->rights[5][3] = 0; + $this->rights[5][4] = 'unvalidate'; + + $this->rights[6][0] = 178; + $this->rights[6][1] = 'Exporter les deplacements'; + $this->rights[6][2] = 'd'; + $this->rights[6][3] = 0; + $this->rights[6][4] = 'export'; // Exports $r=0; diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index b9884aaf3ad..a21a5d1867f 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -122,6 +122,8 @@ Modify=Modifier Edit=Éditer Validate=Valider ToValidate=À valider +Block=Bloquer +Unblock=Débloquer Save=Enregistrer SaveAs=Enregistrer sous TestConnection=Tester la connexion