From 46a8511c69a9d485f4e05edc20cdfc0554eac0e0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Apr 2018 18:25:57 +0200 Subject: [PATCH] Look and feel v8 (delete button in end of list) --- htdocs/holiday/card.php | 19 ++++++++----------- htdocs/holiday/class/holiday.class.php | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index c653c756bba..e5b35b5a434 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1279,20 +1279,15 @@ else print '
'; // Boutons d'actions - if ($cancreate && $object->statut == 1) + if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) { print ''.$langs->trans("EditCP").''; } - if ($cancreate && $object->statut == 1) // If draft + if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) // If draft { print ''.$langs->trans("Validate").''; } - if ($user->rights->holiday->delete && ($object->statut == 1 || $object->statut == 4 || $object->statut == 5)) // If draft or canceled or refused - { - print ''.$langs->trans("DeleteCP").''; - } - - if ($object->statut == 2) // If validated + if ($object->statut == Holiday::STATUS_VALIDATED) // If validated { if ($user->id == $object->fk_validator) { @@ -1305,17 +1300,19 @@ else print ''.$langs->trans("ActionRefuseCP").''; } } - if (($user->id == $object->fk_validator || in_array($object->fk_user, $childids) || ! empty($user->rights->holiday->write_all)) && ($object->statut == 2 || $object->statut == 3)) // Status validated or approved { if (($object->date_debut > dol_now()) || $user->admin) print ''.$langs->trans("ActionCancelCP").''; else print ''.$langs->trans("ActionCancelCP").''; } - - if ($cancreate && $object->statut == 4) + if ($cancreate && $object->statut == Holiday::STATUS_CANCELED) { print ''.$langs->trans("SetToDraft").''; } + if ($user->rights->holiday->delete && ($object->statut == Holiday::STATUS_DRAFT || $object->statut == Holiday::STATUS_CANCELED || $object->statut == Holiday::STATUS_REFUSED)) // If draft or canceled or refused + { + print ''.$langs->trans("DeleteCP").''; + } print '
'; } diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index c034db59c57..490db17fef0 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -71,6 +71,27 @@ class Holiday extends CommonObject var $optValue = ''; var $optRowid = ''; + /** + * Draft status + */ + const STATUS_DRAFT = 1; + /** + * Validated status + */ + const STATUS_VALIDATED = 2; + /** + * Approved + */ + const STATUS_APPROVED = 3; + /** + * Canceled + */ + const STATUS_CANCELED = 4; + /** + * Refused + */ + const STATUS_REFUSED = 5; + /** * Constructor