diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index ecf95c5096d..60855c42d58 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -43,23 +43,23 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; class Categorie extends CommonObject { // Categories types - const TYPE_PRODUCT = 0; // TODO Replace with value 'product' - const TYPE_SUPPLIER = 1; // TODO Replace this value with 'supplier' - const TYPE_CUSTOMER = 2; // TODO Replace this value with 'customer' - const TYPE_MEMBER = 3; // TODO Replace this value with 'member' - const TYPE_CONTACT = 4; // TODO Replace this value with 'contact' - const TYPE_USER = 4; // categorie contact and user are same ! TODO Replace this value with 'user' - - const TYPE_ACCOUNT = 5; // TODO Replace this value with 'bank_account' - const TYPE_PROJECT = 6; // TODO Replace this value with 'project' + const TYPE_PRODUCT = 'product'; + const TYPE_SUPPLIER = 'supplier'; + const TYPE_CUSTOMER = 'customer'; + const TYPE_MEMBER = 'member'; + const TYPE_CONTACT = 'contact'; + const TYPE_USER = 'user'; + const TYPE_PROJECT = 'project'; + const TYPE_ACCOUNT = 'bank_account'; const TYPE_BANK_LINE = 'bank_line'; + public $picto = 'category'; /** * @var array ID mapping from type string * - * @note This array should be remove in future, once previous constants are moved to the string value. + * @note This array should be remove in future, once previous constants are moved to the string value. Deprecated */ private $MAP_ID = array( 'product' => 0, @@ -67,10 +67,21 @@ class Categorie extends CommonObject 'customer' => 2, 'member' => 3, 'contact' => 4, - 'user' => 4, 'account' => 5, 'project' => 6, + 'user' => 7, ); + public static $MAP_ID_TO_CODE = array( + 0 => 'product', + 1 => 'supplier', + 2 => 'customer', + 3 => 'member', + 4 => 'contact', + 5 => 'account', + 6 => 'project', + 7 => 'user', + ); + /** * @var array Foreign keys mapping from type string * @@ -82,9 +93,9 @@ class Categorie extends CommonObject 'supplier' => 'soc', 'member' => 'member', 'contact' => 'socpeople', - 'user' => 'user', - 'account' => 'account', - 'project' => 'project', + 'user' => 'user', + 'account' => 'account', + 'project' => 'project', ); /** * @var array Category tables mapping from type string @@ -97,9 +108,9 @@ class Categorie extends CommonObject 'supplier' => 'fournisseur', 'member' => 'member', 'contact' => 'contact', - 'user' => 'user', - 'account' => 'account', - 'project' => 'project', + 'user' => 'user', + 'account' => 'account', + 'project' => 'project', ); /** * @var array Object class mapping from type string @@ -113,8 +124,8 @@ class Categorie extends CommonObject 'member' => 'Adherent', 'contact' => 'Contact', 'user' => 'User', - 'account' => 'Account', - 'project' => 'Project', + 'account' => 'Account', + 'project' => 'Project', ); /** * @var array Object table mapping from type string @@ -128,8 +139,8 @@ class Categorie extends CommonObject 'member' => 'adherent', 'contact' => 'socpeople', 'user' => 'user', - 'account' => 'bank_account', - 'project' => 'projet', + 'account' => 'bank_account', + 'project' => 'projet', ); public $element='category'; diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index ea4d60e9b5b..c751fad67a7 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -39,6 +39,8 @@ $id=GETPOST('id','int'); $type=(GETPOST('type','aZ09') ? GETPOST('type','aZ09') : Categorie::TYPE_PRODUCT); $catname=GETPOST('catname','alpha'); +if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility + /* * View @@ -53,8 +55,8 @@ elseif ($type == Categorie::TYPE_CUSTOMER) { $title=$langs->trans("CustomersCat elseif ($type == Categorie::TYPE_MEMBER) { $title=$langs->trans("MembersCategoriesArea"); $typetext='member'; } elseif ($type == Categorie::TYPE_CONTACT) { $title=$langs->trans("ContactsCategoriesArea"); $typetext='contact'; } elseif ($type == Categorie::TYPE_ACCOUNT) { $title=$langs->trans("AccountsCategoriesArea"); $typetext='account'; } -elseif ($type == Categorie::TYPE_USER) { $title=$langs->trans("UsersCategoriesArea"); $typetext='user'; } elseif ($type == Categorie::TYPE_PROJECT) { $title=$langs->trans("ProjectsCategoriesArea"); $typetext='project'; } +elseif ($type == Categorie::TYPE_USER) { $title=$langs->trans("UsersCategoriesArea"); $typetext='user'; } else { $title=$langs->trans("CategoriesArea"); $typetext='unknown'; } $arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js'); diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index e99e081e015..e6047ed2149 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -42,6 +42,8 @@ $type=GETPOST('type'); $action=GETPOST('action','aZ09'); $confirm=GETPOST('confirm'); +if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility + if ($id == "") { dol_print_error('','Missing parameter id'); @@ -100,15 +102,16 @@ if ($object->id) elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort"); elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort"); elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort"); - else $title=$langs->trans("Category"); + elseif ($type == Categorie::TYPE_USER) $title=$langs->trans("UsersCategoriesShort"); + else $title=$langs->trans("Category"); $head = categories_prepare_head($object,$type); dol_fiche_head($head, 'photos', $title, -1, 'category'); - + $linkback = ''.$langs->trans("BackToList").''; - + $object->ref = $object->label; $morehtmlref='
'.$langs->trans("Root").' >> '; $ways = $object->print_all_ways(" >> ", '', 1); @@ -117,9 +120,9 @@ if ($object->id) $morehtmlref.=$way."
\n"; } $morehtmlref.='
'; - + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - + /* * Confirmation de la suppression de photo */ @@ -129,7 +132,7 @@ if ($object->id) } print '
'; - + print '
'; print '
'; print ''; @@ -148,7 +151,7 @@ if ($object->id) print "
\n"; print '
'; - + print dol_fiche_end(); @@ -258,7 +261,7 @@ if ($object->id) } print ''; - + if ($nbphoto < 1) { print '
'.$langs->trans("NoPhotoYet")."
"; diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index 7dbe6325e1d..40b40eab921 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -35,11 +35,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $langs->load("categories"); $langs->load("languages"); -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$action=GETPOST('action','alpha'); -$cancel=GETPOST('cancel','alpha'); -$type=GETPOST('type'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action','alpha'); +$cancel = GETPOST('cancel','alpha'); +$type = GETPOST('type','aZ09'); + +if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility // Security check $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); @@ -153,6 +155,7 @@ elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategor elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort"); elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort"); elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort"); +elseif ($type == Categorie::TYPE_USER) $title=$langs->trans("UsersCategoriesShort"); else $title=$langs->trans("Category"); $head = categories_prepare_head($object,$type); @@ -256,9 +259,9 @@ if ($action == 'edit') print ''; } } - + print '
'; - + print '
'; print ''; print '     '; @@ -271,7 +274,7 @@ if ($action == 'edit') else if ($action != 'add') { if ($cnt_trans) print '
'; - + if (! empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 1c6186d5df4..75a9215e18d 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -34,13 +34,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $langs->load("categories"); -$id=GETPOST('id','int'); -$label=GETPOST('label'); -$type=GETPOST('type'); +$id = GETPOST('id','int'); +$label= GETPOST('label','alpha'); +$type = GETPOST('type','az09'); $action=GETPOST('action','aZ09'); -$confirm=GETPOST('confirm'); +$confirm = GETPOST('confirm','alpha'); $removeelem = GETPOST('removeelem','int'); -$elemid=GETPOST('elemid'); +$elemid = GETPOST('elemid','alpha'); if ($id == "" && $label == "") { @@ -61,6 +61,7 @@ if ($result <= 0) } $type=$object->type; +if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility $extrafields = new ExtraFields($db); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); @@ -187,6 +188,7 @@ elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategor elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort"); elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort"); elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort"); +elseif ($type == Categorie::TYPE_USER) $title=$langs->trans("ProjectsCategoriesShort"); else $title=$langs->trans("Category"); $head = categories_prepare_head($object,$type);