diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 74949814577..b9bcaaa4a6c 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -46,8 +46,8 @@ class FactureFournisseur extends CommonInvoice var $product_ref; var $ref_supplier; var $socid; - //! 0=Standard invoice, 1=Replacement invoice, 2=Credit note invoice, 3=Deposit invoice, 4=Proforma invoice - var $type; + //Check constants for types + var $type = self::TYPE_STANDARD; //! 0=draft, //! 1=validated //! 2=classified paid partially (close_code='discount_vat','badcustomer') or completely (close_code=null), @@ -87,6 +87,30 @@ class FactureFournisseur extends CommonInvoice var $extraparams=array(); + /** + * Standard invoice + */ + const TYPE_STANDARD = 0; + + /** + * Replacement invoice + */ + const TYPE_REPLACEMENT = 1; + + /** + * Credit note invoice + */ + const TYPE_CREDIT_NOTE = 2; + + /** + * Deposit invoice + */ + const TYPE_DEPOSIT = 3; + + /** + * Proforma invoice + */ + const TYPE_PROFORMA = 4; /** * Constructor @@ -338,7 +362,7 @@ class FactureFournisseur extends CommonInvoice $this->ref_supplier = $obj->ref_supplier; $this->entity = $obj->entity; - $this->type = empty($obj->type)?0:$obj->type; + $this->type = empty($obj->type)? self::TYPE_STANDARD:$obj->type; $this->fk_soc = $obj->fk_soc; $this->datec = $this->db->jdate($obj->datec); $this->date = $this->db->jdate($obj->datef); diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index 6c47f66ec7d..9a228f28802 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -125,13 +125,13 @@ if ($object->id > 0) // Type print ''.$langs->trans('Type').''; print $object->getLibType(); - if ($object->type == 1) + if ($object->type == FactureFournisseur::TYPE_REPLACEMENT) { $facreplaced=new FactureFournisseur($db); $facreplaced->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("ReplaceInvoice",$facreplaced->getNomUrl(1)).')'; } - if ($object->type == 2) + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { $facusing=new FactureFournisseur($db); $facusing->fetch($object->fk_facture_source); diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 6d095e48b93..c6aab783018 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -1518,13 +1518,13 @@ else // Type print ''.$langs->trans('Type').''; print $object->getLibType(); - if ($object->type == 1) + if ($object->type == FactureFournisseur::TYPE_REPLACEMENT) { $facreplaced=new FactureFournisseur($db); $facreplaced->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("ReplaceInvoice",$facreplaced->getNomUrl(1)).')'; } - if ($object->type == 2) + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { $facusing=new FactureFournisseur($db); $facusing->fetch($object->fk_facture_source); @@ -2166,7 +2166,7 @@ else } // Reopen a standard paid invoice - if (($object->type == 0 || $object->type == 1) && ($object->statut == 2 || $object->statut == 3)) // A paid invoice (partially or completely) + if (($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_REPLACEMENT) && ($object->statut == 2 || $object->statut == 3)) // A paid invoice (partially or completely) { if (! $facidnext && $object->close_code != 'replaced') // Not replaced by another invoice { diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php index e3963a5f738..12b754dea19 100644 --- a/htdocs/fourn/facture/note.php +++ b/htdocs/fourn/facture/note.php @@ -98,13 +98,13 @@ if ($object->id > 0) // Type print ''.$langs->trans('Type').''; print $object->getLibType(); - if ($object->type == 1) + if ($object->type == FactureFournisseur::TYPE_REPLACEMENT) { $facreplaced=new FactureFournisseur($db); $facreplaced->fetch($object->fk_facture_source); print ' ('.$langs->transnoentities("ReplaceInvoice",$facreplaced->getNomUrl(1)).')'; } - if ($object->type == 2) + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { $facusing=new FactureFournisseur($db); $facusing->fetch($object->fk_facture_source);