diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 08f6c35404a..9f48d27ca00 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -29,7 +29,7 @@ /** * \file htdocs/expedition/card.php * \ingroup expedition - * \brief Fiche descriptive d'une expedition + * \brief Card of a shipment */ require '../main.inc.php'; @@ -2492,7 +2492,7 @@ else if ($id || $ref) if (empty($reshook)) { - if ($object->statut == 0 && $num_prod > 0) + if ($object->statut == Expedition::STATUS_DRAFT && $num_prod > 0) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->shipping_advance->validate))) @@ -2507,9 +2507,16 @@ else if ($id || $ref) // TODO add alternative status // 0=draft, 1=validated, 2=billed, we miss a status "delivered" (only available on order) - if ($object->statut == 2 && $object->billed && $user->rights->expedition->creer) + if ($object->statut == Expedition::STATUS_CLOSED && $user->rights->expedition->creer) { - print ''.$langs->trans("ReOpen").''; + if (! empty($conf->facture->enabled) && ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? + { + print ''.$langs->trans("ClassifyUnbilled").''; + } + else + { + print ''.$langs->trans("ReOpen").''; + } } // Send diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 9817e232e9e..85408c7e14a 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -108,6 +108,8 @@ class Expedition extends CommonObject */ function __construct($db) { + global $conf; + $this->db = $db; $this->lines = array(); $this->products = array(); @@ -118,6 +120,20 @@ class Expedition extends CommonObject $this->statuts[0] = 'StatusSendingDraft'; $this->statuts[1] = 'StatusSendingValidated'; $this->statuts[2] = 'StatusSendingProcessed'; + + // List of short language codes for status + $this->statutshorts = array(); + $this->statutshorts[-1] = 'StatusSendingCanceledShort'; + $this->statutshorts[0] = 'StatusSendingDraftShort'; + $this->statutshorts[1] = 'StatusSendingValidatedShort'; + $this->statutshorts[2] = 'StatusSendingProcessedShort'; + + /* Status "billed" or not is managed by another field than status + if (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) + { + $this->statuts[2] = 'StatusSendingBilled'; + $this->statutshorts[2] = 'StatusSendingBilledShort'; + }*/ } /** @@ -1575,32 +1591,32 @@ class Expedition extends CommonObject if ($mode==0) { if ($statut==0) return $langs->trans($this->statuts[$statut]); - if ($statut==1) return $langs->trans($this->statuts[$statut]); - if ($statut==2) return $langs->trans($this->statuts[$statut]); + if ($statut==1) return $langs->trans($this->statuts[$statut]); + if ($statut==2) return $langs->trans($this->statuts[$statut]); } if ($mode==1) { - if ($statut==0) return $langs->trans('StatusSendingDraftShort'); - if ($statut==1) return $langs->trans('StatusSendingValidatedShort'); - if ($statut==2) return $langs->trans('StatusSendingProcessedShort'); + if ($statut==0) return $langs->trans($this->statutshorts[$statut]); + if ($statut==1) return $langs->trans($this->statutshorts[$statut]); + if ($statut==2) return $langs->trans($this->statutshorts[$statut]); } if ($mode == 3) { if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0'); if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4'); - if ($statut==2) return img_picto($langs->trans('StatusSendingProcessed'),'statut6'); + if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut6'); } if ($mode == 4) { if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]); if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); - if ($statut==2) return img_picto($langs->trans('StatusSendingProcessed'),'statut6').' '.$langs->trans('StatusSendingProcessed'); + if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]); } if ($mode == 5) { - if ($statut==0) return $langs->trans('StatusSendingDraftShort').' '.img_picto($langs->trans($this->statuts[$statut]),'statut0'); - if ($statut==1) return $langs->trans('StatusSendingValidatedShort').' '.img_picto($langs->trans($this->statuts[$statut]),'statut4'); - if ($statut==2) return $langs->trans('StatusSendingProcessedShort').' '.img_picto($langs->trans('StatusSendingProcessedShort'),'statut6'); + if ($statut==0) return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut0'); + if ($statut==1) return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut4'); + if ($statut==2) return $langs->trans($this->statutshorts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut6'); } } @@ -2070,7 +2086,7 @@ class Expedition extends CommonObject /** * Classify the shipping as validated/opened * - * @return int <0 if ko, >0 if ok + * @return int <0 if KO, 0 if already open, >0 if OK */ function reOpen() { @@ -2078,6 +2094,12 @@ class Expedition extends CommonObject $error=0; + // Protection. This avoid to move stock later when we should not + if ($this->statut == self::STATUS_VALIDATED) + { + return 0; + } + $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=1'; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 28ddd9d56a8..933412e8688 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -810,6 +810,7 @@ ConfirmMassDeletion=Bulk delete confirmation ConfirmMassDeletionQuestion=Are you sure you want to delete the %s selected record ? RelatedObjects=Related Objects ClassifyBilled=Classify billed +ClassifyUnbilled=Classify unbilled Progress=Progress ClickHere=Click here FrontOffice=Front office