From a12e959833445dab03d3b027506a5b1870245e1f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 Nov 2015 16:33:50 +0100 Subject: [PATCH] Do not show billed status after order status --- htdocs/commande/card.php | 67 ++++++++++++------------ htdocs/commande/class/commande.class.php | 54 ++++++++++--------- htdocs/commande/list.php | 8 +-- 3 files changed, 68 insertions(+), 61 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index fbaba482c50..7da702dea23 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2281,7 +2281,15 @@ if ($action == 'create' && $user->rights->commande->creer) $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if (empty($reshook)) { - // Valid + // Send + if ($object->statut > Commande::STATUS_DRAFT) { + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) { + print '
' . $langs->trans('SendByMail') . '
'; + } else + print '
' . $langs->trans('SendByMail') . '
'; + } + + // Valid if ($object->statut == Commande::STATUS_DRAFT && $object->total_ttc >= 0 && $numlines > 0 && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))) @@ -2300,14 +2308,29 @@ if ($action == 'create' && $user->rights->commande->creer) { print '' . $langs->trans("AddAction") . ''; } - // Send - if ($object->statut > Commande::STATUS_DRAFT) { - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) { - print '
' . $langs->trans('SendByMail') . '
'; - } else - print '
' . $langs->trans('SendByMail') . '
'; + + // Create intervention + if ($conf->ficheinter->enabled) { + $langs->load("interventions"); + + if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { + if ($user->rights->ficheinter->creer) { + print '
' . $langs->trans('AddIntervention') . '
'; + } else { + print '
' . $langs->trans('AddIntervention') . '
'; + } + } } + // Create contract + if ($conf->contrat->enabled && ($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_ACCEPTED)) { + $langs->load("contracts"); + + if ($user->rights->contrat->creer) { + print '
' . $langs->trans('AddContract') . '
'; + } + } + // Ship $numshipping = 0; if (! empty($conf->expedition->enabled)) { @@ -2327,31 +2350,14 @@ if ($action == 'create' && $user->rights->commande->creer) } } - // Create intervention - if ($conf->ficheinter->enabled) { - $langs->load("interventions"); - - if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { - if ($user->rights->ficheinter->creer) { - print '
' . $langs->trans('AddIntervention') . '
'; - } else { - print '
' . $langs->trans('AddIntervention') . '
'; - } - } - } - // Reopen a closed order if (($object->statut == Commande::STATUS_CLOSED || $object->statut == Commande::STATUS_CANCELED) && $user->rights->commande->creer) { print '
' . $langs->trans('ReOpen') . '
'; } - // Create contract - if ($conf->contrat->enabled && ($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_ACCEPTED)) { - $langs->load("contracts"); - - if ($user->rights->contrat->creer) { - print '
' . $langs->trans('AddContract') . '
'; - } + // Set to shipped + if (($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_ACCEPTED) && $user->rights->commande->cloturer) { + print '
' . $langs->trans('ClassifyShipped') . '
'; } // Create bill and Classify billed @@ -2360,16 +2366,11 @@ if ($action == 'create' && $user->rights->commande->creer) if (! empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { print '
' . $langs->trans("CreateBill") . '
'; } - if ($user->rights->commande->creer && $object->statut > Commande::STATUS_ACCEPTED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { + if ($user->rights->commande->creer && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { print '
' . $langs->trans("ClassifyBilled") . '
'; } } - // Set to shipped - if (($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_ACCEPTED) && $user->rights->commande->cloturer) { - print '
' . $langs->trans('ClassifyShipped') . '
'; - } - // Clone if ($user->rights->commande->creer) { print '
' . $langs->trans("ToClone") . '
'; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 1ee2cad12ec..8176d1f3c63 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2865,79 +2865,85 @@ class Commande extends CommonOrder */ function getLibStatut($mode) { - return $this->LibStatut($this->statut,$this->facturee,$mode); + if ($this->facturee && empty($this->billed)) $this->billed=$this->facturee; // For backward compatibility + return $this->LibStatut($this->statut,$this->billed,$mode); } /** * Return label of status * - * @param int $statut Id statut - * @param int $billed If invoiced - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status + * @param int $statut Id statut + * @param int $billed If invoiced + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $donotshowbilled Do not show billed status after order status + * @return string Label of status */ - function LibStatut($statut,$billed,$mode) + function LibStatut($statut,$billed,$mode,$donotshowbilled=0) { global $langs, $conf; + + $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'); if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraft'); - if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidated'); - if ($statut==self::STATUS_ACCEPTED) return $langs->trans('StatusOrderSentShort'); + if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidated').$billedtext; + if ($statut==self::STATUS_ACCEPTED) return $langs->trans('StatusOrderSentShort').$billedtext; if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBill'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').' - '.$langs->trans("Billed"); + if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext; if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed'); } elseif ($mode == 1) { if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceledShort'); if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraftShort'); - if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidatedShort'); - if ($statut==self::STATUS_ACCEPTED) return $langs->trans('StatusOrderSentShort'); + if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidatedShort').$billedtext; + if ($statut==self::STATUS_ACCEPTED) return $langs->trans('StatusOrderSentShort').$billedtext; if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBillShort'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').' - '.$langs->trans("Billed"); + if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext; if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed'); } elseif ($mode == 2) { if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceledShort'); if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraftShort'); - if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'),'statut1').' '.$langs->trans('StatusOrderValidatedShort'); - if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSent'),'statut3').' '.$langs->trans('StatusOrderSentShort'); + if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'),'statut1').' '.$langs->trans('StatusOrderValidatedShort').$billedtext; + if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSent'),'statut3').' '.$langs->trans('StatusOrderSentShort').$billedtext; if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut7').' '.$langs->trans('StatusOrderToBillShort'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').' - '.$langs->trans("Billed"),'statut6').' '.$langs->trans('StatusOrderProcessed').' - '.$langs->trans("Billed"); + if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext; if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed'),'statut6').' '.$langs->trans('StatusOrderProcessedShort'); } elseif ($mode == 3) { if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5'); if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0'); - if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'),'statut1'); - if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSentShort'),'statut3'); + if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1'); + if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3'); if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut7'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').' - '.$langs->trans("Billed"),'statut6'); + if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6'); if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed'),'statut6'); } elseif ($mode == 4) { if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceled'); if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraft'); - if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'),'statut1').' '.$langs->trans('StatusOrderValidated'); - if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSentShort'),'statut3').' '.$langs->trans('StatusOrderSent'); + if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1').' '.$langs->trans('StatusOrderValidated').$billedtext; + if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3').' '.$langs->trans('StatusOrderSent').$billedtext; if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut7').' '.$langs->trans('StatusOrderToBill'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill').' - '.$langs->trans("Billed"),'statut6').' '.$langs->trans('StatusOrderToBill').' - '.$langs->trans("Billed"); + if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill').$billedtext,'statut6').' '.$langs->trans('StatusOrderToBill').$billedtext; if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed'),'statut6').' '.$langs->trans('StatusOrderProcessed'); } elseif ($mode == 5) { if ($statut==self::STATUS_CANCELED) return ''.$langs->trans('StatusOrderCanceledShort').' '.img_picto($langs->trans('StatusOrderCanceled'),'statut5'); if ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraftShort').' '.img_picto($langs->trans('StatusOrderDraft'),'statut0'); - if ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidatedShort').' '.img_picto($langs->trans('StatusOrderValidated'),'statut1'); - if ($statut==self::STATUS_ACCEPTED) return ''.$langs->trans('StatusOrderSentShort').' '.img_picto($langs->trans('StatusOrderSent'),'statut3'); + if ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidatedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1'); + if ($statut==self::STATUS_ACCEPTED) return ''.$langs->trans('StatusOrderSentShort').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext,'statut3'); if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBillShort').' '.img_picto($langs->trans('StatusOrderToBill'),'statut7'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBillShort').' - '.$langs->trans("Billed").' '.img_picto($langs->trans('StatusOrderToBill').' - '.$langs->trans("Billed"),'statut6'); + if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBillShort').$billedtext.' '.img_picto($langs->trans('StatusOrderToBill').$billedtext,'statut6'); if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessedShort').' '.img_picto($langs->trans('StatusOrderProcessed'),'statut6'); } } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 44c5a870ec4..b35aa1628f3 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -136,7 +136,7 @@ llxHeader('',$langs->trans("Orders"),$help_url); $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; $sql.= ' s.nom as name, s.rowid as socid, s.client, s.code_client, c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client,'; -$sql.= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as facturee'; +$sql.= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql.= ', '.MAIN_DB_PREFIX.'commande as c'; if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande'; @@ -559,7 +559,7 @@ if ($resql) { if ($user->rights->facture->creer) { - if (($objp->fk_statut > 0 && $objp->fk_statut < 3) || ($objp->fk_statut == 3 && $objp->facturee == 0)) + if (($objp->fk_statut > 0 && $objp->fk_statut < 3) || ($objp->fk_statut == 3 && $objp->billed == 0)) { print ' '; print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').''; @@ -582,10 +582,10 @@ if ($resql) print ''.price($objp->total_ht).''; // Statut - print ''.$generic_commande->LibStatut($objp->fk_statut,$objp->facturee,5).''; + print ''.$generic_commande->LibStatut($objp->fk_statut, $objp->billed, 5, 1).''; // Billed - print ''.yn($objp->facturee).''; + print ''.yn($objp->billed).''; print '';