From ee808cdfd72ffb4618c22ca0d28f9be9c75c282e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= <rdoursenaud@gpcsolutions.fr>
Date: Sat, 23 May 2015 18:52:31 +0200
Subject: [PATCH] Added types constants to categories

---
 htdocs/adherents/class/adherent.class.php   |  4 +-
 htdocs/adherents/list.php                   | 10 +--
 htdocs/categories/card.php                  | 13 +--
 htdocs/categories/categorie.php             | 84 ++++++++++----------
 htdocs/categories/class/categorie.class.php | 54 ++++++++-----
 htdocs/categories/index.php                 | 25 +++---
 htdocs/categories/photos.php                | 21 ++---
 htdocs/categories/traduction.php            | 19 ++---
 htdocs/categories/viewcat.php               | 87 +++++++++++----------
 htdocs/comm/prospect/list.php               | 17 ++--
 htdocs/compta/stats/cabyprodserv.php        |  7 +-
 htdocs/compta/stats/casoc.php               | 13 +--
 htdocs/contact/list.php                     | 18 ++---
 htdocs/core/class/html.form.class.php       | 36 ++++-----
 htdocs/core/lib/company.lib.php             | 19 ++---
 htdocs/core/lib/contact.lib.php             |  7 +-
 htdocs/core/lib/member.lib.php              |  8 +-
 htdocs/core/lib/pdf.lib.php                 |  4 +-
 htdocs/core/lib/product.lib.php             | 10 ++-
 htdocs/fourn/list.php                       | 13 +--
 htdocs/product/card.php                     |  9 ++-
 htdocs/product/composition/card.php         | 15 ++--
 htdocs/product/list.php                     | 24 +++---
 htdocs/product/reassort.php                 | 11 +--
 htdocs/product/reassortlot.php              | 11 +--
 htdocs/societe/class/societe.class.php      | 31 ++++----
 htdocs/societe/societe.php                  | 12 +--
 27 files changed, 309 insertions(+), 273 deletions(-)

diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index f3c391b5ecd..99d73dd9cf6 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -8,6 +8,7 @@
  * Copyright (C) 2014-2015	Alexandre Spangaro		<alexandre.spangaro@gmail.com>
  * Copyright (C) 2015       Marcos García           <marcosgdf@gmail.com>
  * Copyright (C) 2015       Frederic France         <frederic.france@free.fr>
+ * Copyright (C) 2015       Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -1584,7 +1585,8 @@ class Adherent extends CommonObject
         }
         if ($option == 'category')
         {
-            $link = '<a href="'.DOL_URL_ROOT.'/categories/categorie.php?id='.$this->id.'&type=3'.$linkclose;
+			$type = Categorie::TYPE_MEMBER;
+			$link = '<a href="'.DOL_URL_ROOT.'/categories/categorie.php?id='.$this->id.'&type='.$type.$linkclose;
             $linkend='</a>';
         }
 
diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php
index 38ffeae2993..1e128da7fa7 100644
--- a/htdocs/adherents/list.php
+++ b/htdocs/adherents/list.php
@@ -1,8 +1,8 @@
 <?php
-/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2002-2003 Jean-Louis Bergamo   <jlb@j1b.org>
- * Copyright (C) 2004-2014 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2013      Raphaël Doursenaud   <rdoursenaud@gpcsolutions.fr>
+/* Copyright (C) 2001-2003  Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2002-2003  Jean-Louis Bergamo      <jlb@j1b.org>
+ * Copyright (C) 2004-2014  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2013-2015  Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -210,7 +210,7 @@ if ($resql)
 	if (! empty($conf->categorie->enabled))
 	{
 		$moreforfilter.=$langs->trans('Categories'). ': ';
-		$moreforfilter.=$formother->select_categories(3,$search_categ,'search_categ',1);
+		$moreforfilter.=$formother->select_categories(Categorie::TYPE_MEMBER,$search_categ,'search_categ',1);
 		$moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
 	}
 	if ($moreforfilter)
diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php
index db7b73998c1..7ba04331454 100644
--- a/htdocs/categories/card.php
+++ b/htdocs/categories/card.php
@@ -4,6 +4,7 @@
  * Copyright (C) 2005-2014	Regis Houssin		<regis.houssin@capnetworks.com>
  * Copyright (C) 2007		Patrick Raguin		<patrick.raguin@gmail.com>
  * Copyright (C) 2013		Florian Henry		<florian.henry@open-concept.pro>
+ * Copyright (C) 2015       Raphaël Doursenaud  <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -50,14 +51,14 @@ $parent=GETPOST('parent');
 
 if ($origin)
 {
-	if ($type == 0) $idProdOrigin 		= $origin;
-	if ($type == 1) $idSupplierOrigin 	= $origin;
-	if ($type == 2) $idCompanyOrigin 	= $origin;
-	if ($type == 3) $idMemberOrigin 	= $origin;
-	if ($type == 4) $idContactOrigin 	= $origin;
+	if ($type == Categorie::TYPE_PRODUCT)     $idProdOrigin     = $origin;
+	if ($type == Categorie::TYPE_SUPPLIER)    $idSupplierOrigin = $origin;
+	if ($type == Categorie::TYPE_CUSTOMER)    $idCompanyOrigin  = $origin;
+	if ($type == Categorie::TYPE_MEMBER)      $idMemberOrigin   = $origin;
+	if ($type == Categorie::TYPE_CONTACT)     $idContactOrigin  = $origin;
 }
 
-if ($catorigin && $type == 0) $idCatOrigin = $catorigin;
+if ($catorigin && $type == Categorie::TYPE_PRODUCT) $idCatOrigin = $catorigin;
 
 $object = new Categorie($db);
 
diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php
index 0dc404ac3d1..155593b5efd 100644
--- a/htdocs/categories/categorie.php
+++ b/htdocs/categories/categorie.php
@@ -6,6 +6,7 @@
  * Copyright (C) 2007      Patrick Raguin  		<patrick.raguin@gmail.com>
  * Copyright (C) 2010      Juanjo Menent        <jmenent@2byte.es>
  * Copyright (C) 2013      Florian Henry        <florian.henry@open-concept.pro>
+ * Copyright (C) 2015      Raphaël Doursenaud   <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -46,40 +47,40 @@ $dbtablename = '';
 
 // For categories on third parties
 if (! empty($socid)) $id = $socid;
-if (! isset($type)) $type = 0;
-if ($type == 1 || $type == 2) $socid = $id;
+if (! isset($type)) $type = Categorie::TYPE_PRODUCT;
+if ($type == Categorie::TYPE_SUPPLIER || $type == Categorie::TYPE_CUSTOMER) $socid = $id;
 
 if ($id || $ref)
 {
-	if ($type == 0) {
+	if ($type == Categorie::TYPE_PRODUCT) {
 		$elementtype = 'product';
 		$objecttype = 'produit|service&categorie';
 		$objectid = isset($id)?$id:(isset($ref)?$ref:'');
 		$dbtablename = 'product';
 		$fieldid = isset($ref)?'ref':'rowid';
 	}
-	elseif ($type == 1) {
+	elseif ($type == Categorie::TYPE_SUPPLIER) {
 		$elementtype = 'fournisseur';
 		$objecttype = 'societe&categorie';
 		$objectid = isset($id)?$id:(isset($socid)?$socid:'');
 		$dbtablename = '&societe';
 		$fieldid = 'rowid';
 	}
-	elseif ($type == 2) {
+	elseif ($type == Categorie::TYPE_CUSTOMER) {
 		$elementtype = 'societe';
 		$objecttype = 'societe&categorie';
 		$objectid = isset($id)?$id:(isset($socid)?$socid:'');
 		$dbtablename = '&societe';
 		$fieldid = 'rowid';
 	}
-	elseif ($type == 3) {
+	elseif ($type == Categorie::TYPE_MEMBER) {
 		$elementtype = 'member';
 		$objecttype = 'adherent&categorie';
 		$objectid = isset($id)?$id:(isset($ref)?$ref:'');
 		$dbtablename = 'adherent';
 		$fieldid = ! empty($ref)?'ref':'rowid';
 	}
-	elseif ($type == 4) {
+	elseif ($type == Categorie::TYPE_CONTACT) {
 		$elementtype = 'societe';
 		$objecttype = 'contact';
 		$objectid = isset($id)?$id:(isset($ref)?$ref:'');
@@ -109,34 +110,34 @@ if (empty($reshook))
 	// Remove element from category
 	if ($removecat > 0)
 	{
-		if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
+		if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer))
 		{
 			require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
 			$object = new Product($db);
 			$result = $object->fetch($id, $ref);
 			$elementtype = 'product';
 		}
-		if ($type==1 && $user->rights->societe->creer)
+		if ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer)
 		{
 			require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
 			$object = new Fournisseur($db);
 			$result = $object->fetch($objectid);
 			$elementtype = 'fournisseur';
 		}
-		if ($type==2 && $user->rights->societe->creer)
+		if ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer)
 		{
 			$object = new Societe($db);
 			$result = $object->fetch($objectid);
 			$elementtype = 'societe';
 		}
-		if ($type == 3 && $user->rights->adherent->creer)
+		if ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer)
 		{
 			require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
 			$object = new Adherent($db);
 			$result = $object->fetch($objectid);
 			$elementtype = 'member';
 		}
-		if ($type == 4 && $user->rights->societe->creer)
+		if ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer)
 		{
 			require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
 			$object = new Contact($db);
@@ -157,34 +158,34 @@ if (empty($reshook))
 	// Add object into a category
 	if ($parent > 0)
 	{
-		if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
+		if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer))
 		{
 			require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
 			$object = new Product($db);
 			$result = $object->fetch($id, $ref);
 			$elementtype = 'product';
 		}
-		if ($type==1 && $user->rights->societe->creer)
+		if ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer)
 		{
 			require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
 			$object = new Fournisseur($db);
 			$result = $object->fetch($objectid);
 			$elementtype = 'fournisseur';
 		}
-		if ($type==2 && $user->rights->societe->creer)
+		if ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer)
 		{
 			$object = new Societe($db);
 			$result = $object->fetch($objectid);
 			$elementtype = 'societe';
 		}
-		if ($type==3 && $user->rights->adherent->creer)
+		if ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer)
 		{
 			require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
 			$object = new Adherent($db);
 			$result = $object->fetch($objectid);
 			$elementtype = 'member';
 		}
-		if ($type == 4 && $user->rights->societe->creer)
+		if ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer)
 		{
 			require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
 			$object = new Contact($db);
@@ -324,7 +325,7 @@ if ($socid)
 }
 else if ($id || $ref)
 {
-	if ($type == 0)
+	if ($type == Categorie::TYPE_PRODUCT)
 	{
 		$langs->load("products");
 
@@ -377,7 +378,7 @@ else if ($id || $ref)
 		formCategory($db,$product,0,$socid,($user->rights->produit->creer || $user->rights->service->creer));
 	}
 
-	if ($type == 3)
+	if ($type == Categorie::TYPE_MEMBER)
 	{
 		$langs->load("members");
 
@@ -455,7 +456,7 @@ else if ($id || $ref)
 
 		formCategory($db,$member,3,0,$user->rights->adherent->creer);
 	}
-	if ($type == 4)
+	if ($type == Categorie::TYPE_CONTACT)
 	{
 		$langs->load("contact");
 
@@ -618,16 +619,16 @@ function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1)
 {
 	global $user,$langs,$form,$bc;
 
-	if ($typeid == 0) $title = $langs->trans("ProductsCategoriesShort");
-	if ($typeid == 1) $title = $langs->trans("SuppliersCategoriesShort");
-	if ($typeid == 2) $title = $langs->trans("CustomersProspectsCategoriesShort");
-	if ($typeid == 3) $title = $langs->trans("MembersCategoriesShort");
-	if ($typeid == 4) $title = $langs->trans("ContactCategoriesShort");
+	if ($typeid == Categorie::TYPE_PRODUCT)     $title = $langs->trans("ProductsCategoriesShort");
+	if ($typeid == Categorie::TYPE_SUPPLIER)    $title = $langs->trans("SuppliersCategoriesShort");
+	if ($typeid == Categorie::TYPE_CUSTOMER)    $title = $langs->trans("CustomersProspectsCategoriesShort");
+	if ($typeid == Categorie::TYPE_MEMBER)      $title = $langs->trans("MembersCategoriesShort");
+	if ($typeid == Categorie::TYPE_CONTACT)     $title = $langs->trans("ContactCategoriesShort");
 
 	$linktocreate='';
 	if ($showclassifyform && $user->rights->categorie->creer)
 	{
-		$linktocreate='<a href="'.DOL_URL_ROOT.'/categories/card.php?action=create&amp;origin='.$object->id.'&type='.$typeid.'&urlfrom='.urlencode($_SERVER["PHP_SELF"].'?'.(($typeid==1||$typeid==2)?'socid':'id').'='.$object->id.'&type='.$typeid).'">';
+		$linktocreate='<a href="'.DOL_URL_ROOT.'/categories/card.php?action=create&amp;origin='.$object->id.'&type='.$typeid.'&urlfrom='.urlencode($_SERVER["PHP_SELF"].'?'.(($typeid==Categorie::TYPE_SUPPLIER||$typeid==Categorie::TYPE_CUSTOMER)?'socid':'id').'='.$object->id.'&type='.$typeid).'">';
 		$linktocreate.=$langs->trans("CreateCat").' ';
 		$linktocreate.=img_picto($langs->trans("Create"),'filenew');
 		$linktocreate.="</a>";
@@ -662,11 +663,11 @@ function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1)
 
 	if (count($cats) > 0)
 	{
-		if ($typeid == 0) $title=$langs->trans("ProductIsInCategories");
-		if ($typeid == 1) $title=$langs->trans("CompanyIsInSuppliersCategories");
-		if ($typeid == 2) $title=$langs->trans("CompanyIsInCustomersCategories");
-		if ($typeid == 3) $title=$langs->trans("MemberIsInCategories");
-		if ($typeid == 4) $title=$langs->trans("ContactIsInCategories");
+		if ($typeid == Categorie::TYPE_PRODUCT)     $title=$langs->trans("ProductIsInCategories");
+		if ($typeid == Categorie::TYPE_SUPPLIER)    $title=$langs->trans("CompanyIsInSuppliersCategories");
+		if ($typeid == Categorie::TYPE_CUSTOMER)    $title=$langs->trans("CompanyIsInCustomersCategories");
+		if ($typeid == Categorie::TYPE_MEMBER)      $title=$langs->trans("MemberIsInCategories");
+		if ($typeid == Categorie::TYPE_CONTACT)     $title=$langs->trans("ContactIsInCategories");
 		print "\n";
 		print '<table class="noborder" width="100%">';
 		print '<tr class="liste_titre"><td colspan="2">'.$title.':</td></tr>';
@@ -687,11 +688,11 @@ function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1)
 				// Link to delete from category
 				print '<td align="right">';
 				$permission=0;
-				if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer);
-				if ($typeid == 1) $permission=$user->rights->societe->creer;
-				if ($typeid == 2) $permission=$user->rights->societe->creer;
-				if ($typeid == 3) $permission=$user->rights->adherent->creer;
-				if ($typeid == 4) $permission=$user->rights->societe->creer;
+				if ($typeid == Categorie::TYPE_PRODUCT)     $permission=($user->rights->produit->creer || $user->rights->service->creer);
+				if ($typeid == Categorie::TYPE_SUPPLIER)    $permission=$user->rights->societe->creer;
+				if ($typeid == Categorie::TYPE_CUSTOMER)    $permission=$user->rights->societe->creer;
+				if ($typeid == Categorie::TYPE_MEMBER)      $permission=$user->rights->adherent->creer;
+				if ($typeid == Categorie::TYPE_CONTACT)     $permission=$user->rights->societe->creer;
 				if ($permission)
 				{
 					print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removecat=".$cat->id."'>";
@@ -715,18 +716,17 @@ function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1)
 	}
 	else
 	{
-		if ($typeid == 0) $title=$langs->trans("ProductHasNoCategory");
-		if ($typeid == 1) $title=$langs->trans("CompanyHasNoCategory");
-		if ($typeid == 2) $title=$langs->trans("CompanyHasNoCategory");
-		if ($typeid == 3) $title=$langs->trans("MemberHasNoCategory");
-		if ($typeid == 4) $title=$langs->trans("ContactHasNoCategory");
+		if ($typeid == Categorie::TYPE_PRODUCT)     $title=$langs->trans("ProductHasNoCategory");
+		if ($typeid == Categorie::TYPE_SUPPLIER)    $title=$langs->trans("CompanyHasNoCategory");
+		if ($typeid == Categorie::TYPE_CUSTOMER)    $title=$langs->trans("CompanyHasNoCategory");
+		if ($typeid == Categorie::TYPE_MEMBER)      $title=$langs->trans("MemberHasNoCategory");
+		if ($typeid == Categorie::TYPE_CONTACT)     $title=$langs->trans("ContactHasNoCategory");
 		print $title;
 		print "<br/>";
 	}
 	return 0;
 }
 
-
 llxFooter();
 
 $db->close();
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index 96949371bae..e5953121e82 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -1,13 +1,14 @@
 <?php
-/* Copyright (C) 2005      Matthieu Valleton    <mv@seeschloss.org>
- * Copyright (C) 2005      Davoleau Brice       <brice.davoleau@gmail.com>
- * Copyright (C) 2005      Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2006-2012 Regis Houssin        <regis.houssin@capnetworks.com>
- * Copyright (C) 2006-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2007      Patrick Raguin	  	<patrick.raguin@gmail.com>
- * Copyright (C) 2013      Juanjo Menent      	<jmenent@2byte.es>
- * Copyright (C) 2013      Philippe Grand	  	<philippe.grand@atoo-net.com>
- * Copyright (C) 2015      Marcos García        <marcosgdf@gmail.com>
+/* Copyright (C) 2005       Matthieu Valleton       <mv@seeschloss.org>
+ * Copyright (C) 2005       Davoleau Brice          <brice.davoleau@gmail.com>
+ * Copyright (C) 2005       Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2006-2012  Regis Houssin           <regis.houssin@capnetworks.com>
+ * Copyright (C) 2006-2012  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2007       Patrick Raguin          <patrick.raguin@gmail.com>
+ * Copyright (C) 2013       Juanjo Menent           <jmenent@2byte.es>
+ * Copyright (C) 2013       Philippe Grand          <philippe.grand@atoo-net.com>
+ * Copyright (C) 2015       Marcos García           <marcosgdf@gmail.com>
+ * Copyright (C) 2015       Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -40,6 +41,13 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  */
 class Categorie extends CommonObject
 {
+	// Categories types
+	const TYPE_PRODUCT = 0;
+	const TYPE_SUPPLIER = 1;
+	const TYPE_CUSTOMER = 2;
+	const TYPE_MEMBER = 3;
+	const TYPE_CONTACT = 4;
+
 	public $element='category';
 	public $table_element='categories';
 
@@ -1166,11 +1174,17 @@ class Categorie extends CommonObject
 		$cats = array();
 
 		$typeid=-1; $table='';
-		if ($type == '0' || $type == 'product')	       { $typeid=0; $table='product';   $type='product'; }
-		else if ($type == '1' || $type == 'supplier') { $typeid=1; $table='soc';   $type='fournisseur'; }
-		else if ($type == '2' || $type == 'customer') { $typeid=2; $table='soc';   $type='societe'; }
-		else if ($type == '3' || $type == 'member')   { $typeid=3; $table='member';    $type='member'; }
-        else if ($type == '4' || $type == 'contact')  { $typeid=4; $table='socpeople'; $type='contact'; }
+		if ($type == '0' || $type == 'product') {
+			$typeid=self::TYPE_PRODUCT;     $table='product';   $type='product';
+		} else if ($type == '1' || $type == 'supplier') {
+			$typeid=self::TYPE_SUPPLIER;    $table='soc';       $type='fournisseur';
+		} else if ($type == '2' || $type == 'customer') {
+			$typeid=self::TYPE_CUSTOMER;    $table='soc';       $type='societe';
+		} else if ($type == '3' || $type == 'member') {
+			$typeid=self::TYPE_MEMBER;      $table='member';    $type='member';
+		} else if ($type == '4' || $type == 'contact') {
+			$typeid=self::TYPE_CONTACT;     $table='socpeople'; $type='contact';
+		}
 
 		$sql = "SELECT ct.fk_categorie, c.label";
 		$sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$type." as ct, ".MAIN_DB_PREFIX."categorie as c";
@@ -1220,11 +1234,11 @@ class Categorie extends CommonObject
 		$cats = array();
 
 		$typeid=-1;
-		if ($type == 0 || $type == 'product')	     { $typeid=0; }
-		else if ($type == 1 || $type == 'supplier') { $typeid=1; }
-		else if ($type == 2 || $type == 'customer') { $typeid=2; }
-		else if ($type == 3 || $type == 'member')   { $typeid=3; }
-        else if ($type == 4 || $type == 'contact')	 { $typeid=4; }
+		if ($type == 0 || $type == 'product')       { $typeid=self::TYPE_PRODUCT; }
+		else if ($type == 1 || $type == 'supplier') { $typeid=self::TYPE_SUPPLIER; }
+		else if ($type == 2 || $type == 'customer') { $typeid=self::TYPE_CUSTOMER; }
+		else if ($type == 3 || $type == 'member')   { $typeid=self::TYPE_MEMBER; }
+        else if ($type == 4 || $type == 'contact')  { $typeid=self::TYPE_CONTACT; }
 
 		// Generation requete recherche
 		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
@@ -1550,7 +1564,7 @@ class Categorie extends CommonObject
         $this->specimen=1;
         $this->description = 'This is a description';
         $this->socid = 1;
-        $this->type = 0;
+        $this->type = self::TYPE_PRODUCT;
     }
 
 	/**
diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php
index 590cb4edb49..2a41d318ff5 100644
--- a/htdocs/categories/index.php
+++ b/htdocs/categories/index.php
@@ -1,9 +1,10 @@
 <?php
-/* Copyright (C) 2005      Matthieu Valleton    <mv@seeschloss.org>
- * Copyright (C) 2005      Eric Seigne          <eric.seigne@ryxeo.com>
- * Copyright (C) 2006-2015 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2007      Patrick Raguin       <patrick.raguin@gmail.com>
- * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
+/* Copyright (C) 2005       Matthieu Valleton   <mv@seeschloss.org>
+ * Copyright (C) 2005       Eric Seigne         <eric.seigne@ryxeo.com>
+ * Copyright (C) 2006-2015  Laurent Destailleur <eldy@users.sourceforge.net>
+ * Copyright (C) 2007       Patrick Raguin      <patrick.raguin@gmail.com>
+ * Copyright (C) 2005-2012  Regis Houssin       <regis.houssin@capnetworks.com>
+ * Copyright (C) 2015       Raphaël Doursenaud  <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -35,7 +36,7 @@ $langs->load("categories");
 if (! $user->rights->categorie->lire) accessforbidden();
 
 $id=GETPOST('id','int');
-$type=(GETPOST('type') ? GETPOST('type') : 0);
+$type=(GETPOST('type') ? GETPOST('type') : Categorie::TYPE_PRODUCT);
 $catname=GETPOST('catname','alpha');
 $section=(GETPOST('section')?GETPOST('section'):0);
 
@@ -47,12 +48,12 @@ $section=(GETPOST('section')?GETPOST('section'):0);
 $categstatic = new Categorie($db);
 $form = new Form($db);
 
-if ($type == 0) $title=$langs->trans("ProductsCategoriesArea");
-elseif ($type == 1) $title=$langs->trans("SuppliersCategoriesArea");
-elseif ($type == 2) $title=$langs->trans("CustomersCategoriesArea");
-elseif ($type == 3) $title=$langs->trans("MembersCategoriesArea");
-elseif ($type == 4) $title=$langs->trans("ContactsCategoriesArea");
-else $title=$langs->trans("CategoriesArea");
+if ($type == Categorie::TYPE_PRODUCT)       $title=$langs->trans("ProductsCategoriesArea");
+elseif ($type == Categorie::TYPE_SUPPLIER)  $title=$langs->trans("SuppliersCategoriesArea");
+elseif ($type == Categorie::TYPE_CUSTOMER)  $title=$langs->trans("CustomersCategoriesArea");
+elseif ($type == Categorie::TYPE_MEMBER)    $title=$langs->trans("MembersCategoriesArea");
+elseif ($type == Categorie::TYPE_CONTACT)   $title=$langs->trans("ContactsCategoriesArea");
+else                                        $title=$langs->trans("CategoriesArea");
 
 $arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');
 $arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css');
diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php
index eb496db1af9..f3a84eed5d5 100644
--- a/htdocs/categories/photos.php
+++ b/htdocs/categories/photos.php
@@ -1,9 +1,10 @@
 <?php
-/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2015 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2005      Eric Seigne          <eric.seigne@ryxeo.com>
- * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
- * Copyright (C) 2014      Jean-François Ferry  <jfefe@aternatik.fr>
+/* Copyright (C) 2001-2007  Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2015  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2005       Eric Seigne             <eric.seigne@ryxeo.com>
+ * Copyright (C) 2005-2012  Regis Houssin           <regis.houssin@capnetworks.com>
+ * Copyright (C) 2014       Jean-François Ferry     <jfefe@aternatik.fr>
+ * Copyright (C) 2015       Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -93,11 +94,11 @@ $form = new Form($db);
 if ($object->id)
 {
 	$title=$langs->trans("ProductsCategoryShort");
-	if ($type == 0) $title=$langs->trans("ProductsCategoryShort");
-	elseif ($type == 1) $title=$langs->trans("SuppliersCategoryShort");
-	elseif ($type == 2) $title=$langs->trans("CustomersCategoryShort");
-	elseif ($type == 3) $title=$langs->trans("MembersCategoryShort");
-	elseif ($type == 4) $title=$langs->trans("ContactCategoriesShort");
+	if ($type == Categorie::TYPE_PRODUCT)       $title=$langs->trans("ProductsCategoryShort");
+	elseif ($type == Categorie::TYPE_SUPPLIER)  $title=$langs->trans("SuppliersCategoryShort");
+	elseif ($type == Categorie::TYPE_CUSTOMER)  $title=$langs->trans("CustomersCategoryShort");
+	elseif ($type == Categorie::TYPE_MEMBER)    $title=$langs->trans("MembersCategoryShort");
+	elseif ($type == Categorie::TYPE_CONTACT)   $title=$langs->trans("ContactCategoriesShort");
 
 	$head = categories_prepare_head($object,$type);
 	dol_fiche_head($head, 'photos', $title, 0, 'category');
diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php
index 98d4fb2b930..94570d48f3e 100644
--- a/htdocs/categories/traduction.php
+++ b/htdocs/categories/traduction.php
@@ -1,7 +1,8 @@
 <?php
-/* Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
- * Copyright (C) 2007      Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2010-2012 Destailleur Laurent <eldy@users.sourceforge.net>
+/* Copyright (C) 2005-2012  Regis Houssin           <regis.houssin@capnetworks.com>
+ * Copyright (C) 2007       Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2010-2012  Destailleur Laurent     <eldy@users.sourceforge.net>
+ * Copyright (C) 2015       Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -143,12 +144,12 @@ llxHeader("","",$langs->trans("Translation"));
 $form = new Form($db);
 $formadmin=new FormAdmin($db);
 
-if ($type == 0) $title=$langs->trans("ProductsCategoryShort");
-elseif ($type == 1) $title=$langs->trans("SuppliersCategoryShort");
-elseif ($type == 2) $title=$langs->trans("CustomersCategoryShort");
-elseif ($type == 3) $title=$langs->trans("MembersCategoryShort");
-elseif ($type == 4) $title=$langs->trans("ContactCategoriesShort");
-else $title=$langs->trans("Category");
+if ($type == Categorie::TYPE_PRODUCT)       $title=$langs->trans("ProductsCategoryShort");
+elseif ($type == Categorie::TYPE_SUPPLIER)  $title=$langs->trans("SuppliersCategoryShort");
+elseif ($type == Categorie::TYPE_CUSTOMER)  $title=$langs->trans("CustomersCategoryShort");
+elseif ($type == Categorie::TYPE_MEMBER)    $title=$langs->trans("MembersCategoryShort");
+elseif ($type == Categorie::TYPE_CONTACT)   $title=$langs->trans("ContactCategoriesShort");
+else                                        $title=$langs->trans("Category");
 
 $head = categories_prepare_head($object,$type);
 dol_fiche_head($head, 'translation', $title, 0, 'category');
diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php
index 198ac73cd2a..36e6f53ecc3 100644
--- a/htdocs/categories/viewcat.php
+++ b/htdocs/categories/viewcat.php
@@ -1,8 +1,9 @@
 <?php
-/* Copyright (C) 2005      Matthieu Valleton	<mv@seeschloss.org>
- * Copyright (C) 2006-2010 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2007      Patrick Raguin		<patrick.raguin@gmail.com>
- * Copyright (C) 2005-2012 Regis Houssin		<regis.houssin@capnetworks.com>
+/* Copyright (C) 2005       Matthieu Valleton	<mv@seeschloss.org>
+ * Copyright (C) 2006-2010  Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2007       Patrick Raguin		<patrick.raguin@gmail.com>
+ * Copyright (C) 2005-2012  Regis Houssin		<regis.houssin@capnetworks.com>
+ * Copyright (C) 2015       Raphaël Doursenaud  <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -70,33 +71,33 @@ $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
 // Remove element from category
 if ($id > 0 && $removeelem > 0)
 {
-	if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
+	if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer))
 	{
 		require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
 		$tmpobject = new Product($db);
 		$result = $tmpobject->fetch($removeelem);
 		$elementtype = 'product';
 	}
-	else if ($type==1 && $user->rights->societe->creer)
+	else if ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer)
 	{
 		$tmpobject = new Societe($db);
 		$result = $tmpobject->fetch($removeelem);
 		$elementtype = 'fournisseur';
 	}
-	else if ($type==2 && $user->rights->societe->creer)
+	else if ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer)
 	{
 		$tmpobject = new Societe($db);
 		$result = $tmpobject->fetch($removeelem);
 		$elementtype = 'societe';
 	}
-	else if ($type == 3 && $user->rights->adherent->creer)
+	else if ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer)
 	{
 		require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
 		$tmpobject = new Adherent($db);
 		$result = $tmpobject->fetch($removeelem);
 		$elementtype = 'member';
 	}
-	else if ($type == 4 && $user->rights->societe->creer) {
+	else if ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) {
 
 		require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
 		$tmpobject = new Contact($db);
@@ -121,7 +122,7 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi
 	}
 }
 
-if ($type==0 && $elemid && $action == 'addintocategory' && ($user->rights->produit->creer || $user->rights->service->creer))
+if ($type == Categorie::TYPE_PRODUCT && $elemid && $action == 'addintocategory' && ($user->rights->produit->creer || $user->rights->service->creer))
 {
 	require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
 	$newobject = new Product($db);
@@ -158,12 +159,12 @@ $form = new Form($db);
 
 llxHeader("","",$langs->trans("Categories"));
 
-if ($type == 0) $title=$langs->trans("ProductsCategoryShort");
-elseif ($type == 1) $title=$langs->trans("SuppliersCategoryShort");
-elseif ($type == 2) $title=$langs->trans("CustomersCategoryShort");
-elseif ($type == 3) $title=$langs->trans("MembersCategoryShort");
-elseif ($type == 4) $title=$langs->trans("ContactCategoriesShort");
-else $title=$langs->trans("Category");
+if ($type == Categorie::TYPE_PRODUCT)       $title=$langs->trans("ProductsCategoryShort");
+elseif ($type == Categorie::TYPE_SUPPLIER)  $title=$langs->trans("SuppliersCategoryShort");
+elseif ($type == Categorie::TYPE_CUSTOMER)  $title=$langs->trans("CustomersCategoryShort");
+elseif ($type == Categorie::TYPE_MEMBER)    $title=$langs->trans("MembersCategoryShort");
+elseif ($type == Categorie::TYPE_CONTACT)   $title=$langs->trans("ContactCategoriesShort");
+else                                        $title=$langs->trans("Category");
 
 $head = categories_prepare_head($object,$type);
 
@@ -283,7 +284,7 @@ else
 }
 
 // List of products or services (type is type of category)
-if ($object->type == 0)
+if ($object->type == Categorie::TYPE_PRODUCT)
 {
 	$prods = $object->getObjectsInCateg("product");
 	if ($prods < 0)
@@ -292,7 +293,7 @@ if ($object->type == 0)
 	}
 	else
 	{
-		$showclassifyform=1; $typeid=0;
+		$showclassifyform=1; $typeid=Categorie::TYPE_PRODUCT;
 
 		// Form to add record into a category
 		if ($showclassifyform)
@@ -334,10 +335,10 @@ if ($object->type == 0)
 				print '<td align="right">';
 				$typeid=$object->type;
 				$permission=0;
-				if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer);
-				if ($typeid == 1) $permission=$user->rights->societe->creer;
-				if ($typeid == 2) $permission=$user->rights->societe->creer;
-				if ($typeid == 3) $permission=$user->rights->adherent->creer;
+				if ($typeid == Categorie::TYPE_PRODUCT)     $permission=($user->rights->produit->creer || $user->rights->service->creer);
+				if ($typeid == Categorie::TYPE_SUPPLIER)    $permission=$user->rights->societe->creer;
+				if ($typeid == Categorie::TYPE_CUSTOMER)    $permission=$user->rights->societe->creer;
+				if ($typeid == Categorie::TYPE_MEMBER)      $permission=$user->rights->adherent->creer;
 				if ($permission)
 				{
 					print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$prod->id."'>";
@@ -356,7 +357,7 @@ if ($object->type == 0)
 	}
 }
 
-if ($object->type == 1)
+if ($object->type == Categorie::TYPE_SUPPLIER)
 {
 	$socs = $object->getObjectsInCateg("supplier");
 	if ($socs < 0)
@@ -384,10 +385,10 @@ if ($object->type == 1)
 				print '<td align="right">';
 				$typeid=$object->type;
 				$permission=0;
-				if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer);
-				if ($typeid == 1) $permission=$user->rights->societe->creer;
-				if ($typeid == 2) $permission=$user->rights->societe->creer;
-				if ($typeid == 3) $permission=$user->rights->adherent->creer;
+				if ($typeid == Categorie::TYPE_PRODUCT)     $permission=($user->rights->produit->creer || $user->rights->service->creer);
+				if ($typeid == Categorie::TYPE_SUPPLIER)    $permission=$user->rights->societe->creer;
+				if ($typeid == Categorie::TYPE_CUSTOMER)    $permission=$user->rights->societe->creer;
+				if ($typeid == Categorie::TYPE_MEMBER)      $permission=$user->rights->adherent->creer;
 				if ($permission)
 				{
 					print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$soc->id."'>";
@@ -407,7 +408,7 @@ if ($object->type == 1)
 	}
 }
 
-if($object->type == 2)
+if($object->type == Categorie::TYPE_CUSTOMER)
 {
 	$socs = $object->getObjectsInCateg("customer");
 	if ($socs < 0)
@@ -438,10 +439,10 @@ if($object->type == 2)
 				print '<td align="right">';
 				$typeid=$object->type;
 				$permission=0;
-				if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer);
-				if ($typeid == 1) $permission=$user->rights->societe->creer;
-				if ($typeid == 2) $permission=$user->rights->societe->creer;
-				if ($typeid == 3) $permission=$user->rights->adherent->creer;
+				if ($typeid == Categorie::TYPE_PRODUCT)     $permission=($user->rights->produit->creer || $user->rights->service->creer);
+				if ($typeid == Categorie::TYPE_SUPPLIER)    $permission=$user->rights->societe->creer;
+				if ($typeid == Categorie::TYPE_CUSTOMER)    $permission=$user->rights->societe->creer;
+				if ($typeid == Categorie::TYPE_MEMBER)      $permission=$user->rights->adherent->creer;
 				if ($permission)
 				{
 					print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$soc->id."'>";
@@ -461,7 +462,7 @@ if($object->type == 2)
 }
 
 // List of members
-if ($object->type == 3)
+if ($object->type == Categorie::TYPE_MEMBER)
 {
 	require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
 
@@ -493,10 +494,10 @@ if ($object->type == 3)
 				print '<td align="right">';
 				$typeid=$object->type;
 				$permission=0;
-				if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer);
-				if ($typeid == 1) $permission=$user->rights->societe->creer;
-				if ($typeid == 2) $permission=$user->rights->societe->creer;
-				if ($typeid == 3) $permission=$user->rights->adherent->creer;
+				if ($typeid == Categorie::TYPE_PRODUCT)     $permission=($user->rights->produit->creer || $user->rights->service->creer);
+				if ($typeid == Categorie::TYPE_SUPPLIER)    $permission=$user->rights->societe->creer;
+				if ($typeid == Categorie::TYPE_CUSTOMER)    $permission=$user->rights->societe->creer;
+				if ($typeid == Categorie::TYPE_MEMBER)      $permission=$user->rights->adherent->creer;
 				if ($permission)
 				{
 					print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$member->id."'>";
@@ -515,7 +516,7 @@ if ($object->type == 3)
 }
 
 //Categorie contact
-if($object->type == 4)
+if($object->type == Categorie::TYPE_CONTACT)
 {
 	$contacts = $object->getObjectsInCateg("contact");
 	if ($contacts < 0)
@@ -544,11 +545,11 @@ if($object->type == 4)
 				print '<td align="right">';
 				$typeid=$object->type;
 				$permission=0;
-				if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer);
-				if ($typeid == 1) $permission=$user->rights->societe->creer;
-				if ($typeid == 2) $permission=$user->rights->societe->creer;
-				if ($typeid == 3) $permission=$user->rights->adherent->creer;
-				if ($typeid == 4) $permission=$user->rights->societe->creer;
+				if ($typeid == Categorie::TYPE_PRODUCT)     $permission=($user->rights->produit->creer || $user->rights->service->creer);
+				if ($typeid == Categorie::TYPE_SUPPLIER)    $permission=$user->rights->societe->creer;
+				if ($typeid == Categorie::TYPE_CUSTOMER)    $permission=$user->rights->societe->creer;
+				if ($typeid == Categorie::TYPE_MEMBER)      $permission=$user->rights->adherent->creer;
+				if ($typeid == Categorie::TYPE_CONTACT)     $permission=$user->rights->societe->creer;
 				if ($permission)
 				{
 					print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$contact->id."'>";
diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php
index 176d71c77be..15cb4c32d5c 100644
--- a/htdocs/comm/prospect/list.php
+++ b/htdocs/comm/prospect/list.php
@@ -1,11 +1,12 @@
 <?php
-/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2015 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
- * Copyright (C) 2011      Philippe Grand       <philippe.grand@atoo-net.com>
- * Copyright (C) 2013      Florian Henry        <florian.henry@open-concept.pro>
- * Copyright (C) 2013      Cédric Salvador      <csalvador@gpcsolutions.fr>
- * Copyright (C) 2015      Jean-François Ferry	<jfefe@aternatik.fr>
+/* Copyright (C) 2001-2004  Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2015  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012  Regis Houssin           <regis.houssin@capnetworks.com>
+ * Copyright (C) 2011       Philippe Grand          <philippe.grand@atoo-net.com>
+ * Copyright (C) 2013       Florian Henry           <florian.henry@open-concept.pro>
+ * Copyright (C) 2013       Cédric Salvador         <csalvador@gpcsolutions.fr>
+ * Copyright (C) 2015       Jean-François Ferry     <jfefe@aternatik.fr>
+ * Copyright (C) 2015       Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -299,7 +300,7 @@ if ($resql)
 	if (! empty($conf->categorie->enabled))
 	{
 	 	$moreforfilter.=$langs->trans('Categories'). ': ';
-		$moreforfilter.=$formother->select_categories(2,$search_categ,'search_categ',1);
+		$moreforfilter.=$formother->select_categories(Categorie::TYPE_CUSTOMER,$search_categ,'search_categ',1);
 	 	$moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
 	}
  	// If the user can view prospects other than his'
diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php
index 61f0bbb590d..0ce8c8b0915 100644
--- a/htdocs/compta/stats/cabyprodserv.php
+++ b/htdocs/compta/stats/cabyprodserv.php
@@ -1,6 +1,7 @@
 <?php
-/* Copyright (C) 2013 Antoine Iauch        <aiauch@gpcsolutions.fr>
- * Copyright (C) 2013 Laurent Destailleur  <eldy@users.sourceforge.net>
+/* Copyright (C) 2013   Antoine Iauch       <aiauch@gpcsolutions.fr>
+ * Copyright (C) 2013   Laurent Destailleur <eldy@users.sourceforge.net>
+ * Copyright (C) 2015   Raphaël Doursenaud  <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -245,7 +246,7 @@ if ($modecompta == 'CREANCES-DETTES')
     // Category filter
     print '<tr class="liste_titre">';
     print '<td>';
-    print $langs->trans("Category") . ': ' . $formother->select_categories(0, $selected_cat, 'search_categ', true);
+    print $langs->trans("Category") . ': ' . $formother->select_categories(Categorie::TYPE_PRODUCT, $selected_cat, 'search_categ', true);
     print ' ';
     print $langs->trans("SubCats") . '? ';
     print '<input type="checkbox" name="subcat" value="yes"';
diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php
index ae0a57983f4..32a4f8555cc 100644
--- a/htdocs/compta/stats/casoc.php
+++ b/htdocs/compta/stats/casoc.php
@@ -1,9 +1,10 @@
 <?php
-/* Copyright (C) 2001-2003 Rodolphe Quiedeville  <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2013 Laurent Destailleur   <eldy@users.sourceforge.net>
- * Copyright (C) 2005-2009 Regis Houssin         <regis.houssin@capnetworks.com>
- * Copyright (C) 2007      Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
- * Copyright (C) 2013      Antoine Iauch         <aiauch@gpcsolutions.fr>
+/* Copyright (C) 2001-2003  Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2013  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2009  Regis Houssin           <regis.houssin@capnetworks.com>
+ * Copyright (C) 2007       Franky Van Liedekerke   <franky.van.liedekerke@telenet.be>
+ * Copyright (C) 2013       Antoine Iauch           <aiauch@gpcsolutions.fr>
+ * Copyright (C) 2015       Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -313,7 +314,7 @@ print "<table class=\"noborder\" width=\"100%\">";
     // Category filter
 print '<tr class="liste_titre">';
 print '<td>';
-print $langs->trans("Category") . ': ' . $formother->select_categories(2, $selected_cat, 'search_categ', true);
+print $langs->trans("Category") . ': ' . $formother->select_categories(Categorie::TYPE_CUSTOMER, $selected_cat, 'search_categ', true);
 print ' ';
 print $langs->trans("SubCats") . '? ';
 print '<input type="checkbox" name="subcat" value="yes"';
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index ec8004aa18a..3d67d63c138 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -1,12 +1,12 @@
 <?php
-/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2003      Eric Seigne          <erics@rycks.com>
- * Copyright (C) 2004-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
- * Copyright (C) 2013      Raphaël Doursenaud   <rdoursenaud@gpcsolutions.fr>
- * Copyright (C) 2013      Cédric Salvador      <csalvador@gpcsolutions.fr>
- * Copyright (C) 2013      Alexandre Spangaro   <alexandre.spangaro@gmail.com>
- * Copyright (C) 2015       Jean-François Ferry		<jfefe@aternatik.fr>
+/* Copyright (C) 2001-2004  Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2003       Eric Seigne             <erics@rycks.com>
+ * Copyright (C) 2004-2012  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012  Regis Houssin           <regis.houssin@capnetworks.com>
+ * Copyright (C) 2013-2015  Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
+ * Copyright (C) 2013       Cédric Salvador         <csalvador@gpcsolutions.fr>
+ * Copyright (C) 2013       Alexandre Spangaro      <alexandre.spangaro@gmail.com>
+ * Copyright (C) 2015       Jean-François Ferry     <jfefe@aternatik.fr>
  *
  * 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
@@ -276,7 +276,7 @@ if ($result)
     if (! empty($conf->categorie->enabled))
     {
     	$moreforfilter.=$langs->trans('Categories'). ': ';
-    	$moreforfilter.=$formother->select_categories(4,$search_categ,'search_categ',1);
+    	$moreforfilter.=$formother->select_categories(Categorie::TYPE_CONTACT,$search_categ,'search_categ',1);
     	$moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
     }
     if ($moreforfilter)
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 6eab9d8b545..b4e5a8a0ec0 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1,21 +1,21 @@
 <?php
-/* Copyright (c) 2002-2007 Rodolphe Quiedeville  <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2012 Laurent Destailleur   <eldy@users.sourceforge.net>
- * Copyright (C) 2004      Benoit Mortier        <benoit.mortier@opensides.be>
- * Copyright (C) 2004      Sebastien Di Cintio   <sdicintio@ressource-toi.org>
- * Copyright (C) 2004      Eric Seigne           <eric.seigne@ryxeo.com>
- * Copyright (C) 2005-2014 Regis Houssin         <regis.houssin@capnetworks.com>
- * Copyright (C) 2006      Andre Cianfarani      <acianfa@free.fr>
- * Copyright (C) 2006      Marc Barilley/Ocebo   <marc@ocebo.com>
- * Copyright (C) 2007      Franky Van Liedekerke <franky.van.liedekerker@telenet.be>
- * Copyright (C) 2007      Patrick Raguin        <patrick.raguin@gmail.com>
- * Copyright (C) 2010      Juanjo Menent         <jmenent@2byte.es>
- * Copyright (C) 2010-2014 Philippe Grand        <philippe.grand@atoo-net.com>
- * Copyright (C) 2011      Herve Prot            <herve.prot@symeos.com>
- * Copyright (C) 2012-2014 Marcos García         <marcosgdf@gmail.com>
- * Copyright (C) 2012      Cedric Salvador       <csalvador@gpcsolutions.fr>
- * Copyright (C) 2012-2014 Raphaël Doursenaud    <rdoursenaud@gpcsolutions.fr>
- * Copyright (C) 2014      Alexandre Spangaro    <alexandre.spangaro@gmail.com>
+/* Copyright (c) 2002-2007  Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2012  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2004       Benoit Mortier          <benoit.mortier@opensides.be>
+ * Copyright (C) 2004       Sebastien Di Cintio     <sdicintio@ressource-toi.org>
+ * Copyright (C) 2004       Eric Seigne             <eric.seigne@ryxeo.com>
+ * Copyright (C) 2005-2014  Regis Houssin           <regis.houssin@capnetworks.com>
+ * Copyright (C) 2006       Andre Cianfarani        <acianfa@free.fr>
+ * Copyright (C) 2006       Marc Barilley/Ocebo     <marc@ocebo.com>
+ * Copyright (C) 2007       Franky Van Liedekerke   <franky.van.liedekerker@telenet.be>
+ * Copyright (C) 2007       Patrick Raguin          <patrick.raguin@gmail.com>
+ * Copyright (C) 2010       Juanjo Menent           <jmenent@2byte.es>
+ * Copyright (C) 2010-2014  Philippe Grand          <philippe.grand@atoo-net.com>
+ * Copyright (C) 2011       Herve Prot              <herve.prot@symeos.com>
+ * Copyright (C) 2012-2014  Marcos García           <marcosgdf@gmail.com>
+ * Copyright (C) 2012       Cedric Salvador         <csalvador@gpcsolutions.fr>
+ * Copyright (C) 2012-2015  Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
+ * Copyright (C) 2014       Alexandre Spangaro      <alexandre.spangaro@gmail.com>
  *
  * 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
@@ -4593,7 +4593,7 @@ class Form
 
 		if ($rendermode == 0)
 		{
-			$cate_arbo = $this->select_all_categories(0, '', 'parent', 64, 0, 1);
+			$cate_arbo = $this->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1);
 			foreach($categories as $c) {
 				$arrayselected[] = $c->id;
 			}
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 690d015ac38..c1c9d9e2311 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -1,13 +1,14 @@
 <?php
-/* Copyright (C) 2006-2011	Laurent Destailleur		<eldy@users.sourceforge.net>
- * Copyright (C) 2006		    Rodolphe Quiedeville	<rodolphe@quiedeville.org>
- * Copyright (C) 2007		    Patrick Raguin			  <patrick.raguin@gmail.com>
- * Copyright (C) 2010-2012  Regis Houssin			    <regis.houssin@capnetworks.com>
- * Copyright (C) 2013-2014  Florian Henry		  	  <florian.henry@open-concept.pro>
- * Copyright (C) 2013-2014  Juanjo Menent		  	  <jmenent@2byte.es>
- * Copyright (C) 2013       Christophe Battarel		<contact@altairis.fr>
+/* Copyright (C) 2006-2011  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2006       Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2007       Patrick Raguin          <patrick.raguin@gmail.com>
+ * Copyright (C) 2010-2012  Regis Houssin           <regis.houssin@capnetworks.com>
+ * Copyright (C) 2013-2014  Florian Henry           <florian.henry@open-concept.pro>
+ * Copyright (C) 2013-2014  Juanjo Menent           <jmenent@2byte.es>
+ * Copyright (C) 2013       Christophe Battarel     <contact@altairis.fr>
  * Copyright (C) 2013       Alexandre Spangaro      <alexandre.spangaro@gmail.com>
  * Copyright (C) 2015       Frederic France         <frederic.france@free.fr>
+ * Copyright (C) 2015       Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -83,8 +84,8 @@ function societe_prepare_head(Societe $object)
     //show categorie tab
     if (! empty($conf->categorie->enabled)  && ! empty($user->rights->categorie->lire))
     {
-        $type = 2;
-        if ($object->fournisseur) $type = 1;
+        $type = Categorie::TYPE_CUSTOMER;
+        if ($object->fournisseur) $type = Categorie::TYPE_SUPPLIER;
         $head[$h][0] = DOL_URL_ROOT.'/categories/categorie.php?socid='.$object->id."&type=".$type;
         $head[$h][1] = $langs->trans('Categories');
         $head[$h][2] = 'category';
diff --git a/htdocs/core/lib/contact.lib.php b/htdocs/core/lib/contact.lib.php
index 278402679f8..26b0b0c0e5f 100644
--- a/htdocs/core/lib/contact.lib.php
+++ b/htdocs/core/lib/contact.lib.php
@@ -1,7 +1,8 @@
 <?php
-/* Copyright (C) 2006-2010	Laurent Destailleur	<eldy@users.sourceforge.net>
- * Copyright (C) 2010-2012	Regis Houssin		<regis.houssin@capnetworks.com>
+/* Copyright (C) 2006-2010  Laurent Destailleur <eldy@users.sourceforge.net>
+ * Copyright (C) 2010-2012  Regis Houssin       <regis.houssin@capnetworks.com>
  * Copyright (C) 2015       Frederic France     <frederic.france@free.fr>
+ * Copyright (C) 2015       Raphaël Doursenaud  <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -88,7 +89,7 @@ function contact_prepare_head(Contact $object)
 
     if (! empty($conf->categorie->enabled)  && ! empty($user->rights->categorie->lire))
     {
-    	$type = 4;
+    	$type = Categorie::TYPE_CONTACT;
     	$head[$tab][0] = DOL_URL_ROOT.'/categories/categorie.php?id='.$object->id."&type=".$type;
     	$head[$tab][1] = $langs->trans('Categories');
     	$head[$tab][2] = 'category';
diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php
index 695c3d65629..e3bc5c236bc 100644
--- a/htdocs/core/lib/member.lib.php
+++ b/htdocs/core/lib/member.lib.php
@@ -1,6 +1,7 @@
 <?php
-/* Copyright (C) 2006-2011  Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2015       Alexandre Spangaro   <alexandre.spangaro@gmail.com>
+/* Copyright (C) 2006-2011  Laurent Destailleur <eldy@users.sourceforge.net>
+ * Copyright (C) 2015       Alexandre Spangaro  <alexandre.spangaro@gmail.com>
+ * Copyright (C) 2015       Raphaël Doursenaud  <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -70,7 +71,8 @@ function member_prepare_head(Adherent $object)
 	// Show category tab
 	if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
 	{
-		$head[$h][0] = DOL_URL_ROOT."/categories/categorie.php?id=".$object->id.'&type=3';
+		$type = Categorie::TYPE_MEMBER;
+		$head[$h][0] = DOL_URL_ROOT."/categories/categorie.php?id=".$object->id.'&type='.$type;
 		$head[$h][1] = $langs->trans('Categories');
 		$head[$h][2] = 'category';
 		$h++;
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 6c94d5595dd..6174e2de121 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -6,7 +6,7 @@
  * Copyright (C) 2010		Juanjo Menent       	<jmenent@2byte.es>
  * Copyright (C) 2012		Christophe Battarel		<christophe.battarel@altairis.fr>
  * Copyright (C) 2012       Cédric Salvador         <csalvador@gpcsolutions.fr>
- * Copyright (C) 2012-2014  Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
+ * Copyright (C) 2012-2015  Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  * Copyright (C) 2014		Cedric GROSS			<c.gross@kreiz-it.fr>
  * Copyright (C) 2014		Teddy Andreotti			<125155@supinfo.com>
  *
@@ -1099,7 +1099,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
 		include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
 		$categstatic=new Categorie($db);
 		// recovering the list of all the categories linked to product
-		$tblcateg=$categstatic->containing($idprod,0);
+		$tblcateg=$categstatic->containing($idprod, Categorie::TYPE_PRODUCT);
 		foreach ($tblcateg as $cate)
 		{
 			// Adding the descriptions if they are filled
diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php
index 32e5fa4ba78..f8c3ed12cf6 100644
--- a/htdocs/core/lib/product.lib.php
+++ b/htdocs/core/lib/product.lib.php
@@ -1,7 +1,8 @@
 <?php
-/* Copyright (C) 2006-2008 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2007      Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2009-2010 Regis Houssin        <regis.houssin@capnetworks.com>
+/* Copyright (C) 2006-2008  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2007       Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2009-2010  Regis Houssin           <regis.houssin@capnetworks.com>
+ * Copyright (C) 2015       Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -60,7 +61,8 @@ function product_prepare_head($object)
 	/* No more required. Replaced with new multiselect component
 	if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire)
 	{
-		$head[$h][0] = DOL_URL_ROOT."/categories/categorie.php?id=".$object->id.'&type=0';
+		$type = Categorie::TYPE_PRODUCT;
+		$head[$h][0] = DOL_URL_ROOT."/categories/categorie.php?id=".$object->id.'&type='.$type;
 		$head[$h][1] = $langs->trans('Categories');
 		$head[$h][2] = 'category';
 		$h++;
diff --git a/htdocs/fourn/list.php b/htdocs/fourn/list.php
index c44aa39622d..62985db80b2 100644
--- a/htdocs/fourn/list.php
+++ b/htdocs/fourn/list.php
@@ -1,9 +1,10 @@
 <?php
-/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
- * Copyright (C) 2011      Philippe Grand       <philippe.grand@atoo-net.com>
- * Copyright (C) 2013      Cédric Salvador      <csalvador@gpcsolutions.fr>
+/* Copyright (C) 2001-2006  Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2012  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012  Regis Houssin           <regis.houssin@capnetworks.com>
+ * Copyright (C) 2011       Philippe Grand          <philippe.grand@atoo-net.com>
+ * Copyright (C) 2013       Cédric Salvador         <csalvador@gpcsolutions.fr>
+ * Copyright (C) 2015       Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -168,7 +169,7 @@ if ($resql)
 	if (! empty($conf->categorie->enabled))
 	{
 		$moreforfilter.=$langs->trans('Categories'). ': ';
-		$moreforfilter.=$htmlother->select_categories(1,$search_categ,'search_categ',1);
+		$moreforfilter.=$htmlother->select_categories(Categorie::TYPE_SUPPLIER,$search_categ,'search_categ',1);
 		$moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
 	}
 	if ($moreforfilter)
diff --git a/htdocs/product/card.php b/htdocs/product/card.php
index f6e64b36f6a..7780bb560a5 100644
--- a/htdocs/product/card.php
+++ b/htdocs/product/card.php
@@ -11,7 +11,8 @@
  * Copyright (C) 2011-2014	Alexandre Spangaro		<alexandre.spangaro@gmail.com>
  * Copyright (C) 2014		Cédric Gross			<c.gross@kreiz-it.fr>
  * Copyright (C) 2014		Ferran Marcet			<fmarcet@2byte.es>
- * Copyright (C) 2015           Jean-François Ferry		<jfefe@aternatik.fr>
+ * Copyright (C) 2015       Jean-François Ferry     <jfefe@aternatik.fr>
+ * Copyright (C) 2015       Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -974,7 +975,7 @@ else
 
 		// Categories
 		print '<tr><td valign="top">'.$langs->trans("Categories").'</td><td colspan="3">';
-		$cate_arbo = $form->select_all_categories(0, '', 'parent', 64, 0, 1);
+		$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1);
 		print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, 250);
 		print "</td></tr>";
 
@@ -1265,9 +1266,9 @@ else
 
 			// Categories
 			print '<tr><td valign="top">'.$langs->trans("Categories").'</td><td colspan="3">';
-			$cate_arbo = $form->select_all_categories(0, '', 'parent', 64, 0, 1);
+			$cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1);
 			$c = new Categorie($db);
-			$cats = $c->containing($object->id,0);
+			$cats = $c->containing($object->id,Categorie::TYPE_PRODUCT);
 			foreach($cats as $cat) {
 				$arrayselected[] = $cat->id;
 			}
diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php
index cdb20e28dbf..112d6d2d44b 100644
--- a/htdocs/product/composition/card.php
+++ b/htdocs/product/composition/card.php
@@ -1,10 +1,11 @@
 <?php
-/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2013 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2005      Eric Seigne          <eric.seigne@ryxeo.com>
- * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
- * Copyright (C) 2006      Andre Cianfarani     <acianfa@free.fr>
- * Copyright (C) 2011-2014 Juanjo Menent        <jmenent@2byte.es>
+/* Copyright (C) 2001-2007  Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2013  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2005       Eric Seigne             <eric.seigne@ryxeo.com>
+ * Copyright (C) 2005-2012  Regis Houssin           <regis.houssin@capnetworks.com>
+ * Copyright (C) 2006       Andre Cianfarani        <acianfa@free.fr>
+ * Copyright (C) 2011-2014  Juanjo Menent           <jmenent@2byte.es>
+ * Copyright (C) 2015       Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -473,7 +474,7 @@ if ($id > 0 || ! empty($ref))
 			if (! empty($conf->categorie->enabled))
 			{
 				print '<tr><td>'.$langs->trans("CategoryFilter").' &nbsp; </td>';
-				print '<td class="maxwidthonsmartphone">'.$form->select_all_categories(0, $parent).'</td></tr>';
+				print '<td class="maxwidthonsmartphone">'.$form->select_all_categories(Categorie::TYPE_PRODUCT, $parent).'</td></tr>';
 			}
 			print '</table>';
 			print '</form>';
diff --git a/htdocs/product/list.php b/htdocs/product/list.php
index 2f61a07fa60..83e15cb104e 100644
--- a/htdocs/product/list.php
+++ b/htdocs/product/list.php
@@ -1,15 +1,15 @@
 <?php
-/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
- * Copyright (C) 2012-2013 Marcos García        <marcosgdf@gmail.com>
- * Copyright (C) 2013      Juanjo Menent        <jmenent@2byte.es>
- * Copyright (C) 2013      Raphaël Doursenaud   <rdoursenaud@gpcsolutions.fr>
- * Copyright (C) 2013      Jean Heimburger   	<jean@tiaris.info>
- * Copyright (C) 2013      Cédric Salvador      <csalvador@gpcsolutions.fr>
- * Copyright (C) 2013      Florian Henry        <florian.henry@open-concept.pro>
- * Copyright (C) 2013      Adolfo segura        <adolfo.segura@gmail.com>
- * Copyright (C) 2015       Jean-François Ferry	<jfefe@aternatik.fr>
+/* Copyright (C) 2001-2006  Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2011  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012  Regis Houssin           <regis.houssin@capnetworks.com>
+ * Copyright (C) 2012-2013  Marcos García           <marcosgdf@gmail.com>
+ * Copyright (C) 2013       Juanjo Menent           <jmenent@2byte.es>
+ * Copyright (C) 2013-2015  Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
+ * Copyright (C) 2013       Jean Heimburger         <jean@tiaris.info>
+ * Copyright (C) 2013       Cédric Salvador         <csalvador@gpcsolutions.fr>
+ * Copyright (C) 2013       Florian Henry           <florian.henry@open-concept.pro>
+ * Copyright (C) 2013       Adolfo segura           <adolfo.segura@gmail.com>
+ * Copyright (C) 2015       Jean-François Ferry     <jfefe@aternatik.fr>
  *
  * 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
@@ -292,7 +292,7 @@ else
     		if (! empty($conf->categorie->enabled))
     		{
     		 	$moreforfilter.=$langs->trans('Categories'). ': ';
-    			$moreforfilter.=$htmlother->select_categories(0,$search_categ,'search_categ',1);
+    			$moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT,$search_categ,'search_categ',1);
     		 	$moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
     		}
     	 	if ($moreforfilter)
diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php
index 4a93741e4e7..ce2e7363feb 100644
--- a/htdocs/product/reassort.php
+++ b/htdocs/product/reassort.php
@@ -1,8 +1,9 @@
 <?php
-/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2015 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
- * Copyright (C) 2013      Cédric Salvador      <csalvador@gpcsolutions.fr>
+/* Copyright (C) 2001-2006  Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2015  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012  Regis Houssin           <regis.houssin@capnetworks.com>
+ * Copyright (C) 2013       Cédric Salvador         <csalvador@gpcsolutions.fr>
+ * Copyright (C) 2015       Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -221,7 +222,7 @@ if ($resql)
 	if (! empty($conf->categorie->enabled))
 	{
 	 	$moreforfilter.=$langs->trans('Categories'). ': ';
-		$moreforfilter.=$htmlother->select_categories(0,$search_categ,'search_categ');
+		$moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT,$search_categ,'search_categ');
 	 	$moreforfilter.=' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ';
 	}
 	$moreforfilter.=$langs->trans("StockTooLow").' <input type="checkbox" name="toolowstock" value="1"'.($toolowstock?' checked':'').'>';
diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php
index 3caeadacef5..86410df8a00 100644
--- a/htdocs/product/reassortlot.php
+++ b/htdocs/product/reassortlot.php
@@ -1,8 +1,9 @@
 <?php
-/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2015 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
- * Copyright (C) 2013      Cédric Salvador      <csalvador@gpcsolutions.fr>
+/* Copyright (C) 2001-2006  Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2015  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012  Regis Houssin           <regis.houssin@capnetworks.com>
+ * Copyright (C) 2013       Cédric Salvador         <csalvador@gpcsolutions.fr>
+ * Copyright (C) 2015       Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -233,7 +234,7 @@ if ($resql)
 	if (! empty($conf->categorie->enabled))
 	{
 	 	$moreforfilter.=$langs->trans('Categories'). ': ';
-		$moreforfilter.=$htmlother->select_categories(0,$search_categ,'search_categ');
+		$moreforfilter.=$htmlother->select_categories(Categorie::TYPE_PRODUCT,$search_categ,'search_categ');
 	 	$moreforfilter.=' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ';
 	}
 	//$moreforfilter.=$langs->trans("StockTooLow").' <input type="checkbox" name="toolowstock" value="1"'.($toolowstock?' checked':'').'>';
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 85d8c3ac83b..18bfea5fb0c 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -1,16 +1,17 @@
 <?php
-/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2015 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2004      Eric Seigne          <eric.seigne@ryxeo.com>
- * Copyright (C) 2003      Brian Fraval         <brian@fraval.org>
- * Copyright (C) 2006      Andre Cianfarani     <acianfa@free.fr>
- * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
- * Copyright (C) 2008      Patrick Raguin       <patrick.raguin@auguria.net>
- * Copyright (C) 2010-2014 Juanjo Menent        <jmenent@2byte.es>
- * Copyright (C) 2013      Florian Henry		  	<florian.henry@open-concept.pro>
- * Copyright (C) 2013      Alexandre Spangaro 	<alexandre.spangaro@gmail.com>
- * Copyright (C) 2013      Peter Fontaine       <contact@peterfontaine.fr>
- * Copyright (C) 2014-2015 Marcos García        <marcosgdf@gmail.com>
+/* Copyright (C) 2002-2006  Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2015  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2004       Eric Seigne             <eric.seigne@ryxeo.com>
+ * Copyright (C) 2003       Brian Fraval            <brian@fraval.org>
+ * Copyright (C) 2006       Andre Cianfarani        <acianfa@free.fr>
+ * Copyright (C) 2005-2012  Regis Houssin           <regis.houssin@capnetworks.com>
+ * Copyright (C) 2008       Patrick Raguin          <patrick.raguin@auguria.net>
+ * Copyright (C) 2010-2014  Juanjo Menent           <jmenent@2byte.es>
+ * Copyright (C) 2013       Florian Henry           <florian.henry@open-concept.pro>
+ * Copyright (C) 2013       Alexandre Spangaro      <alexandre.spangaro@gmail.com>
+ * Copyright (C) 2013       Peter Fontaine          <contact@peterfontaine.fr>
+ * Copyright (C) 2014-2015  Marcos García           <marcosgdf@gmail.com>
+ * Copyright (C) 2015       Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -1334,11 +1335,11 @@ class Societe extends CommonObject
 	            // Fill $toute_categs array with an array of (type => array of ("Categorie" instance))
 	            if ($this->client || $this->prospect)
 	            {
-	                $toute_categs ['societe'] = $static_cat->containing($this->id,2);
+	                $toute_categs ['societe'] = $static_cat->containing($this->id,Categorie::TYPE_CUSTOMER);
 	            }
 	            if ($this->fournisseur)
 	            {
-	                $toute_categs ['fournisseur'] = $static_cat->containing($this->id,1);
+	                $toute_categs ['fournisseur'] = $static_cat->containing($this->id,Categorie::TYPE_SUPPLIER);
 	            }
 
 	            // Remove each "Categorie"
@@ -2747,7 +2748,7 @@ class Societe extends CommonObject
         $this->SupplierCategories = array();
         $sql = "SELECT rowid, label";
         $sql.= " FROM ".MAIN_DB_PREFIX."categorie";
-        $sql.= " WHERE type = 1";
+        $sql.= " WHERE type = ".Categorie::TYPE_SUPPLIER;
 
         $resql=$this->db->query($sql);
         if ($resql)
diff --git a/htdocs/societe/societe.php b/htdocs/societe/societe.php
index b3484a7c008..8a5a77cbb0b 100644
--- a/htdocs/societe/societe.php
+++ b/htdocs/societe/societe.php
@@ -1,9 +1,9 @@
 <?php
-/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2013 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
- * Copyright (C) 2012      Marcos García        <marcosgdf@gmail.com>
- * Copyright (C) 2013      Raphaël Doursenaud   <rdoursenaud@gpcsolutions.fr>
+/* Copyright (C) 2001-2004  Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2013  Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012  Regis Houssin           <regis.houssin@capnetworks.com>
+ * Copyright (C) 2012       Marcos García           <marcosgdf@gmail.com>
+ * Copyright (C) 2013-2015  Raphaël Doursenaud      <rdoursenaud@gpcsolutions.fr>
  *
  * 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
@@ -311,7 +311,7 @@ if ($resql)
     if (! empty($conf->categorie->enabled))
     {
         $moreforfilter.=$langs->trans('Categories'). ': ';
-        $moreforfilter.=$htmlother->select_categories(2,$search_categ,'search_categ');
+        $moreforfilter.=$htmlother->select_categories(Categories::TYPE_CUSTOMER,$search_categ,'search_categ');
         $moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
     }
     // If the user can view prospects other than his'
-- 
GitLab