From 72d96d2ac3f59f852c5886ef90a10092979c999f Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Tue, 5 Mar 2019 17:13:20 +0100 Subject: [PATCH 1/6] prepare badges --- htdocs/comm/propal/class/propal.class.php | 21 +++++++++------------ htdocs/core/lib/functions.lib.php | 6 +++--- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 304eccf9bb7..203c6bd9f84 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3194,19 +3194,16 @@ class Propal extends CommonObject } $statuttrans=''; - if ($statut==self::STATUS_DRAFT) $statuttrans='statut0'; - elseif ($statut==self::STATUS_VALIDATED) $statuttrans='statut1'; - elseif ($statut==self::STATUS_SIGNED) $statuttrans='statut3'; - elseif ($statut==self::STATUS_NOTSIGNED) $statuttrans='statut5'; - elseif ($statut==self::STATUS_BILLED) $statuttrans='statut6'; + if ($statut==self::STATUS_DRAFT) $statuttrans='status0'; + elseif ($statut==self::STATUS_VALIDATED) $statuttrans='status1'; + elseif ($statut==self::STATUS_SIGNED) $statuttrans='status3'; + elseif ($statut==self::STATUS_NOTSIGNED) $statuttrans='status5'; + elseif ($statut==self::STATUS_BILLED) $statuttrans='status6'; - if ($mode == 0) return $this->labelstatut[$statut]; - elseif ($mode == 1) return $this->labelstatut_short[$statut]; - elseif ($mode == 2) return img_picto($this->labelstatut_short[$statut], $statuttrans).' '.$this->labelstatut_short[$statut]; - elseif ($mode == 3) return img_picto($this->labelstatut[$statut], $statuttrans); - elseif ($mode == 4) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut[$statut]; - elseif ($mode == 5) return ''.$this->labelstatut_short[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); - elseif ($mode == 6) return ''.$this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); + + return dolGetStatus($this->labelstatut[$statut], $this->labelstatut_short[$statut], '', $statuttrans, $mode); + + } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8c6b4c69f82..3144286a6c7 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8012,7 +8012,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st if($displayMode==0){ $return = !empty($html)?$html:$statusLabel; } - elseif($displayMode===1){ + elseif($displayMode==1){ $return = !empty($html)?$html:(!empty($statusLabelShort)?$statusLabelShort:$statusLabel); } // use status with images @@ -8047,7 +8047,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st } // Use new badge - if(!empty($conf->global->MAIN_STATUS_USES_CSS) && !empty($displayMode)){ + elseif(!empty($conf->global->MAIN_STATUS_USES_CSS) && !empty($displayMode)){ $statusLabelShort = !empty($statusLabelShort)?$statusLabelShort:$statusLabel; @@ -8064,7 +8064,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st } - return $return; + return $return.$displayMode; } From e382f136376f07132c7e236ab9a74cfd4d64549b Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Tue, 5 Mar 2019 17:16:38 +0100 Subject: [PATCH 2/6] remove test --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 942099554a2..6f00709e960 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8063,7 +8063,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st } - return $return.$displayMode; + return $return; } From 5fd3a253aba45aa1f31ad511870478e14162621c Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Wed, 6 Mar 2019 14:19:40 +0100 Subject: [PATCH 3/6] add new dolGetStatus to LibStatut in order class --- htdocs/commande/class/commande.class.php | 94 ++++++++---------------- 1 file changed, 30 insertions(+), 64 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 9b55957b0f0..0d9924def9d 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3425,77 +3425,43 @@ class Commande extends CommonOrder $billedtext = ''; if (empty($donotshowbilled)) $billedtext .= ($billed?' - '.$langs->trans("Billed"):''); - //print 'x'.$statut.'-'.$billed; - if ($mode == 0) - { - if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceled'); - elseif ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraft'); - elseif ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidated').$billedtext; - elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext; - elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBill'); - elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext; - elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered'); + if ($statut==self::STATUS_CANCELED){ + $labelstatut = $langs->trans('StatusOrderCanceled'); + $labelstatutShort = $langs->trans('StatusOrderCanceledShort'); + $statuttrans='status5'; } - elseif ($mode == 1) - { - if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceledShort'); - elseif ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraftShort'); - elseif ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidatedShort').$billedtext; - elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext; - elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBillShort'); - elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext; - elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered'); + elseif ($statut==self::STATUS_DRAFT){ + $labelstatut = $langs->trans('StatusOrderDraft'); + $labelstatutShort = $langs->trans('StatusOrderDraftShort'); + $statuttrans='status0'; } - elseif ($mode == 2) - { - if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'), 'statut5').' '.$langs->trans('StatusOrderCanceledShort'); - elseif ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0').' '.$langs->trans('StatusOrderDraftShort'); - elseif ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'), 'statut1').' '.$langs->trans('StatusOrderValidatedShort').$billedtext; - elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSent'), 'statut3').' '.$langs->trans('StatusOrderSentShort').$billedtext; - elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4').' '.$langs->trans('StatusOrderToBillShort'); - elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext; - elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6').' '.$langs->trans('StatusOrderDeliveredShort'); + elseif ($statut==self::STATUS_VALIDATED){ + $labelstatut = $langs->trans('StatusOrderValidated').$billedtext; + $labelstatutShort = $langs->trans('StatusOrderValidatedShort').$billedtext; + $statuttrans='status1'; } - elseif ($mode == 3) - { - if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'), 'statut5'); - elseif ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0'); - elseif ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); - elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext, 'statut3'); - elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4'); - elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); - elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); + elseif ($statut==self::STATUS_SHIPMENTONPROCESS){ + $labelstatut = $langs->trans('StatusOrderSentShort').$billedtext; + $labelstatutShort = $langs->trans('StatusOrderSentShort').$billedtext; + $statuttrans='status3'; } - elseif ($mode == 4) - { - if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'), 'statut5').' '.$langs->trans('StatusOrderCanceled'); - elseif ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0').' '.$langs->trans('StatusOrderDraft'); - elseif ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1').' '.$langs->trans('StatusOrderValidated').$billedtext; - elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext, 'statut3').' '.$langs->trans('StatusOrderSent').$billedtext; - elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4').' '.$langs->trans('StatusOrderToBill'); - elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessedShort').$billedtext, 'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext; - elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6').' '.$langs->trans('StatusOrderDelivered'); + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))){ + $labelstatut = $langs->trans('StatusOrderToBill'); + $labelstatutShort = $langs->trans('StatusOrderToBillShort'); + $statuttrans='status4'; } - elseif ($mode == 5) - { - if ($statut==self::STATUS_CANCELED) return ''.$langs->trans('StatusOrderCanceledShort').' '.img_picto($langs->trans('StatusOrderCanceled'), 'statut5'); - elseif ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraftShort').' '.img_picto($langs->trans('StatusOrderDraft'), 'statut0'); - elseif ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidatedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); - elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSentShort').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext, 'statut3'); - elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBillShort').' '.img_picto($langs->trans('StatusOrderToBill'), 'statut4'); - elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); - elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDeliveredShort').' '.img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))){ + $labelstatut = $langs->trans('StatusOrderProcessed').$billedtext; + $labelstatutShort = $langs->trans('StatusOrderProcessed').$billedtext; + $statuttrans='status6'; } - elseif ($mode == 6) - { - if ($statut==self::STATUS_CANCELED) return ''.$langs->trans('StatusOrderCanceled').' '.img_picto($langs->trans('StatusOrderCanceled'), 'statut5'); - elseif ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraft').' '.img_picto($langs->trans('StatusOrderDraft'), 'statut0'); - elseif ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidated').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); - elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSent').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext, 'statut3'); - elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBill').' '.img_picto($langs->trans('StatusOrderToBill'), 'statut4'); - elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessed').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); - elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDelivered').' '.img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))){ + $labelstatut = $langs->trans('StatusOrderDelivered'); + $labelstatutShort = $langs->trans('StatusOrderDelivered'); + $statuttrans='status6'; } + + return dolGetStatus($labelstatut, $labelstatutShort, '', $statuttrans, $mode); } From ca10b1e4032dc0804567c9b3e50c0df8b5a55a19 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Thu, 7 Mar 2019 11:37:54 +0100 Subject: [PATCH 4/6] add new dolGetStatus to LibStatut in product class --- htdocs/commande/class/commande.class.php | 6 ++ htdocs/product/class/product.class.php | 124 +++++++++++------------ 2 files changed, 65 insertions(+), 65 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 0d9924def9d..89336845501 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3460,6 +3460,12 @@ class Commande extends CommonOrder $labelstatutShort = $langs->trans('StatusOrderDelivered'); $statuttrans='status6'; } + else{ + $labelstatut = $langs->trans('Unknown'); + $labelstatutShort = ''; + $statuttrans=''; + $mode = 0; + } return dolGetStatus($labelstatut, $labelstatutShort, '', $statuttrans, $mode); } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 9ef3ba450cf..5ee523f8265 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4054,83 +4054,77 @@ class Product extends CommonObject { // phpcs:enable global $conf, $langs; - + $langs->load('products'); if (! empty($conf->productbatch->enabled)) { $langs->load("productbatch"); } - + if ($type == 2) { switch ($mode) { - case 0: - return ($status == 0 ? $langs->trans('ProductStatusNotOnBatch') : $langs->trans('ProductStatusOnBatch')); - case 1: - return ($status == 0 ? $langs->trans('ProductStatusNotOnBatchShort') : $langs->trans('ProductStatusOnBatchShort')); - case 2: - return $this->LibStatut($status, 3, 2).' '.$this->LibStatut($status, 1, 2); - case 3: - if ($status == 0) { - return img_picto($langs->trans('ProductStatusNotOnBatch'), 'statut5'); - } - return img_picto($langs->trans('ProductStatusOnBatch'), 'statut4'); - case 4: - return $this->LibStatut($status, 3, 2).' '.$this->LibStatut($status, 0, 2); - case 5: - return $this->LibStatut($status, 1, 2).' '.$this->LibStatut($status, 3, 2); - default: - return $langs->trans('Unknown'); + case 0: + $label = ($status == 0 ? $langs->trans('ProductStatusNotOnBatch') : $langs->trans('ProductStatusOnBatch')); + return dolGetStatus($label); + case 1: + $label = ($status == 0 ? $langs->trans('ProductStatusNotOnBatchShort') : $langs->trans('ProductStatusOnBatchShort')); + return dolGetStatus($label); + case 2: + return $this->LibStatut($status, 3, 2).' '.$this->LibStatut($status, 1, 2); + case 3: + return dolGetStatus($langs->trans('ProductStatusNotOnBatch'), '','',empty($status)?'status5':'status4',3,'dot'); + case 4: + return $this->LibStatut($status, 3, 2).' '.$this->LibStatut($status, 0, 2); + case 5: + return $this->LibStatut($status, 1, 2).' '.$this->LibStatut($status, 3, 2); + default: + return dolGetStatus($langs->trans('Unknown')); + } + + + + } + + $statuttrans=empty($status)?'status5':'status4'; + + if($status == 0){ + // $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch" + if($type==0){ + $labelstatut = $langs->trans('ProductStatusNotOnSellShort'); + $labelstatutShort = $langs->trans('ProductStatusNotOnSell'); + } + elseif($type == 1){ + $labelstatut = $langs->trans('ProductStatusNotOnBuyShort'); + $labelstatutShort = $langs->trans('ProductStatusNotOnBuy'); + } + elseif($type == 2){ + $labelstatut = $langs->trans('ProductStatusNotOnBatch'); + $labelstatutShort = $langs->trans('ProductStatusNotOnBatchShort'); } } - if ($mode == 0) { - if ($status == 0) { - return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')); - } elseif ($status == 1) { - return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')); + elseif($status == 1){ + // $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch" + if($type==0){ + $labelstatut = $langs->trans('ProductStatusOnSellShort'); + $labelstatutShort = $langs->trans('ProductStatusOnSell'); + } + elseif($type == 1){ + $labelstatut = $langs->trans('ProductStatusOnBuyShort'); + $labelstatutShort = $langs->trans('ProductStatusOnBuy'); + } + elseif($type == 2){ + $labelstatut = $langs->trans('ProductStatusOnBatch'); + $labelstatutShort = $langs->trans('ProductStatusOnBatchShort'); } } - elseif ($mode == 1) { - if ($status == 0) { - return ($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')); - } elseif ($status == 1) { - return ($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')); - } + + + if($mode>6){ + return dolGetStatus($langs->trans('Unknown'),'', '', 'status0', 0); } - elseif ($mode == 2) { - if ($status == 0) { - return img_picto($langs->trans('ProductStatusNotOnSell'), 'statut5', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')); - } elseif ($status == 1) { - return img_picto($langs->trans('ProductStatusOnSell'), 'statut4', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')); - } + else{ + return dolGetStatus($labelstatut, $labelstatutShort, '', $statuttrans, $mode); } - elseif ($mode == 3) { - if ($status == 0) { - return img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell') : $langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); - } elseif ($status == 1) { - return img_picto(($type==0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy')), 'statut4', 'class="pictostatus"'); - } - } - elseif ($mode == 4) { - if ($status == 0) { - return img_picto($langs->trans('ProductStatusNotOnSell'), 'statut5', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')); - } elseif ($status == 1) { - return img_picto($langs->trans('ProductStatusOnSell'), 'statut4', 'class="pictostatus"').' '.($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')); - } - } - elseif ($mode == 5) { - if ($status == 0) { - return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); - } elseif ($status == 1) { - return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')), 'statut4', 'class="pictostatus"'); - } - } - elseif ($mode == 6) { - if ($status == 0) { - return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"'); - } elseif ($status == 1) { - return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')), 'statut4', 'class="pictostatus"'); - } - } - return $langs->trans('Unknown'); + } From 97544e0aea479f613e2405f762dae10516cded67 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Thu, 7 Mar 2019 15:24:11 +0100 Subject: [PATCH 5/6] add new dolGetStatus to LibStatut in common invoice class --- htdocs/comm/propal/class/propal.class.php | 14 +- htdocs/commande/class/commande.class.php | 18 +-- htdocs/core/class/commoninvoice.class.php | 155 +++++++--------------- 3 files changed, 62 insertions(+), 125 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 203c6bd9f84..b36416291e6 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3193,15 +3193,15 @@ class Propal extends CommonObject $this->labelstatut_short[4]=$langs->trans("PropalStatusBilledShort"); } - $statuttrans=''; - if ($statut==self::STATUS_DRAFT) $statuttrans='status0'; - elseif ($statut==self::STATUS_VALIDATED) $statuttrans='status1'; - elseif ($statut==self::STATUS_SIGNED) $statuttrans='status3'; - elseif ($statut==self::STATUS_NOTSIGNED) $statuttrans='status5'; - elseif ($statut==self::STATUS_BILLED) $statuttrans='status6'; + $statusType=''; + if ($statut==self::STATUS_DRAFT) $statusType='status0'; + elseif ($statut==self::STATUS_VALIDATED) $statusType='status1'; + elseif ($statut==self::STATUS_SIGNED) $statusType='status3'; + elseif ($statut==self::STATUS_NOTSIGNED) $statusType='status5'; + elseif ($statut==self::STATUS_BILLED) $statusType='status6'; - return dolGetStatus($this->labelstatut[$statut], $this->labelstatut_short[$statut], '', $statuttrans, $mode); + return dolGetStatus($this->labelstatut[$statut], $this->labelstatut_short[$statut], '', $statusType, $mode); } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 89336845501..390e0001594 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3428,46 +3428,46 @@ class Commande extends CommonOrder if ($statut==self::STATUS_CANCELED){ $labelstatut = $langs->trans('StatusOrderCanceled'); $labelstatutShort = $langs->trans('StatusOrderCanceledShort'); - $statuttrans='status5'; + $statusType='status5'; } elseif ($statut==self::STATUS_DRAFT){ $labelstatut = $langs->trans('StatusOrderDraft'); $labelstatutShort = $langs->trans('StatusOrderDraftShort'); - $statuttrans='status0'; + $statusType='status0'; } elseif ($statut==self::STATUS_VALIDATED){ $labelstatut = $langs->trans('StatusOrderValidated').$billedtext; $labelstatutShort = $langs->trans('StatusOrderValidatedShort').$billedtext; - $statuttrans='status1'; + $statusType='status1'; } elseif ($statut==self::STATUS_SHIPMENTONPROCESS){ $labelstatut = $langs->trans('StatusOrderSentShort').$billedtext; $labelstatutShort = $langs->trans('StatusOrderSentShort').$billedtext; - $statuttrans='status3'; + $statusType='status3'; } elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))){ $labelstatut = $langs->trans('StatusOrderToBill'); $labelstatutShort = $langs->trans('StatusOrderToBillShort'); - $statuttrans='status4'; + $statusType='status4'; } elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))){ $labelstatut = $langs->trans('StatusOrderProcessed').$billedtext; $labelstatutShort = $langs->trans('StatusOrderProcessed').$billedtext; - $statuttrans='status6'; + $statusType='status6'; } elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))){ $labelstatut = $langs->trans('StatusOrderDelivered'); $labelstatutShort = $langs->trans('StatusOrderDelivered'); - $statuttrans='status6'; + $statusType='status6'; } else{ $labelstatut = $langs->trans('Unknown'); $labelstatutShort = ''; - $statuttrans=''; + $statusType=''; $mode = 0; } - return dolGetStatus($labelstatut, $labelstatutShort, '', $statuttrans, $mode); + return dolGetStatus($labelstatut, $labelstatutShort, '', $statusType, $mode); } diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 5926f954a46..ec2f539369f 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -469,118 +469,55 @@ abstract class CommonInvoice extends CommonObject global $langs; $langs->load('bills'); - //print "$paye,$status,$mode,$alreadypaid,$type"; - if ($mode == 0) { - $prefix=''; - if (! $paye) { - if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); - elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); - else return $langs->trans('Bill'.$prefix.'StatusStarted'); - } - else - { - if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note - elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice - else return $langs->trans('Bill'.$prefix.'StatusPaid'); - } + $statusType='status0'; + $prefix='Short'; + if (! $paye){ + if ($status == 0){ + $labelstatut = $langs->trans('BillStatusDraft'); + $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusDraft'); + } + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0){ + $labelstatut = $langs->trans('BillStatusClosedUnpaid'); + $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); + $statusType='status5'; + } + elseif (($status == 3 || $status == 2) && $alreadypaid > 0){ + $labelstatut = $langs->trans('BillStatusClosedPaidPartially'); + $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); + $statusType='status9'; + } + elseif ($alreadypaid <= 0){ + $labelstatut = $langs->trans('BillStatusNotPaid'); + $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusNotPaid'); + $statusType='status1'; + } + else{ + $labelstatut = $langs->trans('BillStatusStarted'); + $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusStarted'); + $statusType='status3'; + } } - elseif ($mode == 1) + else { - $prefix='Short'; - if (! $paye) - { - if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled'); - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); - elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid'); - else return $langs->trans('Bill'.$prefix.'StatusStarted'); - } - else - { - if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); - elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); - else return $langs->trans('Bill'.$prefix.'StatusPaid'); - } - } - elseif ($mode == 2) - { - $prefix='Short'; - if (! $paye) - { - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'), 'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'), 'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'), 'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); - else return img_picto($langs->trans('BillStatusStarted'), 'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); - } - else - { - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'), 'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted'); - else return img_picto($langs->trans('BillStatusPaid'), 'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid'); - } - } - elseif ($mode == 3) - { - $prefix='Short'; - if (! $paye) - { - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'), 'statut0'); - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'), 'statut5'); - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9'); - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'), 'statut1'); - else return img_picto($langs->trans('BillStatusStarted'), 'statut3'); - } - else - { - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6'); - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'), 'statut6'); - else return img_picto($langs->trans('BillStatusPaid'), 'statut6'); - } - } - elseif ($mode == 4) - { - $prefix=''; - if (! $paye) - { - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'), 'statut0').' '.$langs->trans('BillStatusDraft'); - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'), 'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'), 'statut1').' '.$langs->trans('BillStatusNotPaid'); - else return img_picto($langs->trans('BillStatusStarted'), 'statut3').' '.$langs->trans('BillStatusStarted'); - } - else - { - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted'); - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'), 'statut6').' '.$langs->trans('BillStatusConverted'); - else return img_picto($langs->trans('BillStatusPaid'), 'statut6').' '.$langs->trans('BillStatusPaid'); - } - } - elseif ($mode == 5 || $mode == 6) - { - $prefix=''; - if ($mode == 5) $prefix='Short'; - if (! $paye) - { - if ($status == 0) return ''.$langs->trans('Bill'.$prefix.'StatusDraft').' '.img_picto($langs->trans('BillStatusDraft'), 'statut0'); - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return ''.$langs->trans('Bill'.$prefix.'StatusCanceled').' '.img_picto($langs->trans('BillStatusCanceled'), 'statut5'); - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return ''.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' '.img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9'); - elseif ($alreadypaid <= 0) - { - if ($type == self::TYPE_CREDIT_NOTE) return ''.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' '.img_picto($langs->trans('StatusNotRefunded'), 'statut1'); - return ''.$langs->trans('Bill'.$prefix.'StatusNotPaid').' '.img_picto($langs->trans('BillStatusNotPaid'), 'statut1'); - } - else return ''.$langs->trans('Bill'.$prefix.'StatusStarted').' '.img_picto($langs->trans('BillStatusStarted'), 'statut3'); - } - else - { - if ($type == self::TYPE_CREDIT_NOTE) return ''.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' '.img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6'); - elseif ($type == self::TYPE_DEPOSIT) return ''.$langs->trans('Bill'.$prefix.'StatusConverted').' '.img_picto($langs->trans('BillStatusConverted'), 'statut6'); - else return ''.$langs->trans('Bill'.$prefix.'StatusPaid').' '.img_picto($langs->trans('BillStatusPaid'), 'statut6'); - } + $statusType='status6'; + + if ($type == self::TYPE_CREDIT_NOTE){ + $labelstatut = $langs->trans('BillStatusPaidBackOrConverted'); // credit note + $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note + } + elseif ($type == self::TYPE_DEPOSIT){ + $labelstatut = $langs->trans('BillStatusConverted'); // deposit invoice + $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice + } + else{ + $labelstatut = $langs->trans('BillStatusPaid'); + $labelstatutShort = $langs->trans('Bill'.$prefix.'StatusPaid'); + } } + + + return dolGetStatus($labelstatut, $labelstatutShort, '', $statusType, $mode); + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps From 052d29d9466ad77aa8dac37d7f9e241548819646 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Mar 2019 20:45:28 +0100 Subject: [PATCH 6/6] Fix phpcs --- htdocs/comm/propal/class/propal.class.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 683d0b8c36e..da63db84a8d 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3199,11 +3199,8 @@ class Propal extends CommonObject elseif ($statut==self::STATUS_SIGNED) $statusType='status3'; elseif ($statut==self::STATUS_NOTSIGNED) $statusType='status5'; elseif ($statut==self::STATUS_BILLED) $statusType='status6'; - return dolGetStatus($this->labelstatut[$statut], $this->labelstatut_short[$statut], '', $statusType, $mode); - - }