From 832b78911ceaa5a9f42336df497cbd5e6e08f116 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 3 Nov 2011 11:49:22 +0100 Subject: [PATCH] Fix: optimize code --- htdocs/comm/action/class/actioncomm.class.php | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 99bd144d727..e6e62350ec3 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1,22 +1,22 @@ * Copyright (C) 2004-2011 Laurent Destailleur -* Copyright (C) 2005-2011 Regis Houssin -* Copyright (C) 2011 Juanjo Menent -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2011 Juanjo Menent + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ /** * \file htdocs/comm/action/class/actioncomm.class.php @@ -626,52 +626,52 @@ class ActionComm extends CommonObject if ($mode == 0) { - if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable'); - if ($percent==0) return $langs->trans('StatusActionToDo').' (0%)'; - if ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%)'; - if ($percent >= 100) return $langs->trans('StatusActionDone').' (100%)'; + if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable'); + else if ($percent==0) return $langs->trans('StatusActionToDo').' (0%)'; + else if ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%)'; + else if ($percent >= 100) return $langs->trans('StatusActionDone').' (100%)'; } - if ($mode == 1) + else if ($mode == 1) { - if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable'); - if ($percent==0) return $langs->trans('StatusActionToDo'); - if ($percent > 0 && $percent < 100) return $percent.'%'; - if ($percent >= 100) return $langs->trans('StatusActionDone'); + if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable'); + else if ($percent==0) return $langs->trans('StatusActionToDo'); + else if ($percent > 0 && $percent < 100) return $percent.'%'; + else if ($percent >= 100) return $langs->trans('StatusActionDone'); } - if ($mode == 2) + else if ($mode == 2) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'),'statut9').' '.$langs->trans('StatusNotApplicable'); - if ($percent==0) return img_picto($langs->trans('StatusActionToDo'),'statut1').' '.$langs->trans('StatusActionToDo'); - if ($percent > 0 && $percent < 100) return img_picto($langs->trans('StatusActionInProcess'),'statut3').' '. $percent.'%'; - if ($percent >= 100) return img_picto($langs->trans('StatusActionDone'),'statut6').' '.$langs->trans('StatusActionDone'); + if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'),'statut9').' '.$langs->trans('StatusNotApplicable'); + else if ($percent==0) return img_picto($langs->trans('StatusActionToDo'),'statut1').' '.$langs->trans('StatusActionToDo'); + else if ($percent > 0 && $percent < 100) return img_picto($langs->trans('StatusActionInProcess'),'statut3').' '. $percent.'%'; + else if ($percent >= 100) return img_picto($langs->trans('StatusActionDone'),'statut6').' '.$langs->trans('StatusActionDone'); } - if ($mode == 3) + else if ($mode == 3) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans("Status").': '.$langs->trans('StatusNotApplicable'),'statut9'); - if ($percent==0) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionToDo').' (0%)','statut1'); - if ($percent > 0 && $percent < 100) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionInProcess').' ('.$percent.'%)','statut3'); - if ($percent >= 100) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionDone').' (100%)','statut6'); + if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans("Status").': '.$langs->trans('StatusNotApplicable'),'statut9'); + else if ($percent==0) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionToDo').' (0%)','statut1'); + else if ($percent > 0 && $percent < 100) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionInProcess').' ('.$percent.'%)','statut3'); + else if ($percent >= 100) return img_picto($langs->trans("Status").': '.$langs->trans('StatusActionDone').' (100%)','statut6'); } - if ($mode == 4) + else if ($mode == 4) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'),'statut9').' '.$langs->trans('StatusNotApplicable'); - if ($percent==0) return img_picto($langs->trans('StatusActionToDo'),'statut1').' '.$langs->trans('StatusActionToDo').' (0%)'; - if ($percent > 0 && $percent < 100) return img_picto($langs->trans('StatusActionInProcess'),'statut3').' '.$langs->trans('StatusActionInProcess').' ('.$percent.'%)';; - if ($percent >= 100) return img_picto($langs->trans('StatusActionDone'),'statut6').' '.$langs->trans('StatusActionDone').' (100%)'; + if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'),'statut9').' '.$langs->trans('StatusNotApplicable'); + else if ($percent==0) return img_picto($langs->trans('StatusActionToDo'),'statut1').' '.$langs->trans('StatusActionToDo').' (0%)'; + else if ($percent > 0 && $percent < 100) return img_picto($langs->trans('StatusActionInProcess'),'statut3').' '.$langs->trans('StatusActionInProcess').' ('.$percent.'%)'; + else if ($percent >= 100) return img_picto($langs->trans('StatusActionDone'),'statut6').' '.$langs->trans('StatusActionDone').' (100%)'; } - if ($mode == 5) + else if ($mode == 5) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'),'statut9'); - if ($percent==0) return '0% '.img_picto($langs->trans('StatusActionToDo'),'statut1'); - if ($percent > 0 && $percent < 100) return $percent.'% '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%','statut3'); - if ($percent >= 100) return $langs->trans('StatusActionDone').' '.img_picto($langs->trans('StatusActionDone'),'statut6'); + if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'),'statut9'); + else if ($percent==0) return '0% '.img_picto($langs->trans('StatusActionToDo'),'statut1'); + else if ($percent > 0 && $percent < 100) return $percent.'% '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%','statut3'); + else if ($percent >= 100) return $langs->trans('StatusActionDone').' '.img_picto($langs->trans('StatusActionDone'),'statut6'); } - if ($mode == 6) + else if ($mode == 6) { - if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'),'statut9'); - if ($percent==0) return '0% '.img_picto($langs->trans('StatusActionToDo'),'statut1'); - if ($percent > 0 && $percent < 100) return $percent.'% '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%','statut3'); - if ($percent >= 100) return img_picto($langs->trans('StatusActionDone'),'statut6'); + if ($percent==-1 && ! $hidenastatus) return img_picto($langs->trans('StatusNotApplicable'),'statut9'); + else if ($percent==0) return '0% '.img_picto($langs->trans('StatusActionToDo'),'statut1'); + else if ($percent > 0 && $percent < 100) return $percent.'% '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%','statut3'); + else if ($percent >= 100) return img_picto($langs->trans('StatusActionDone'),'statut6'); } return ''; }