diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 78a78195d37..5a1f38806bb 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -4,8 +4,9 @@ * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2010-2015 Juanjo Menent - * Copyright (C) 2014 Jean Heimburger + * Copyright (C) 2014 Jean Heimburger * Copyright (C) 2015 Marcos García + * Copyright (C) 2015 Raphaël Doursenaud * * 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 @@ -262,6 +263,12 @@ if ($object->id > 0) print ""; print ''; + // Categories + print '' . $langs->trans("Categories") . ''; + print ''; + print $form->showCategories($object->id, 'supplier', 1); + print ""; + // Other attributes $parameters=array('socid'=>$object->id, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 864f507494a..b80f0f2c086 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1,14 +1,15 @@ - * Copyright (C) 2003 Brian Fraval - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2005 Eric Seigne - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2008 Patrick Raguin - * Copyright (C) 2010-2014 Juanjo Menent - * Copyright (C) 2011-2013 Alexandre Spangaro - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2015 Marcos García +/* Copyright (C) 2001-2007 Rodolphe Quiedeville + * Copyright (C) 2003 Brian Fraval + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2005 Eric Seigne + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2008 Patrick Raguin + * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2011-2013 Alexandre Spangaro + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Marcos García + * Copyright (C) 2015 Raphaël Doursenaud * * 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 @@ -411,7 +412,7 @@ if (empty($reshook)) } } - // Categories association + // Customer categories association $custcats = GETPOST( 'custcats', 'array' ); if (!empty( $custcats )) { $cat = new Categorie( $db ); @@ -421,6 +422,16 @@ if (empty($reshook)) } } + // Supplier categories association + $suppcats = GETPOST('suppcats', 'array'); + if (!empty($suppcats)) { + $cat = new Categorie($db); + foreach ($suppcats as $id_category) { + $cat->fetch($id_category); + $cat->add_type($object, 'supplier'); + } + } + // Logo/Photo save $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/"; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); @@ -525,7 +536,7 @@ if (empty($reshook)) $error = $object->error; $errors = $object->errors; } - // Categories association + // Customer categories association // First we delete all categories association $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'categorie_societe'; $sql .= ' WHERE fk_soc = ' . $object->id; @@ -541,6 +552,22 @@ if (empty($reshook)) } } + // Supplier categories association + // First we delete all categories association + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'categorie_fournisseur'; + $sql .= ' WHERE fk_soc = ' . $object->id; + $db->query($sql); + + // Then we add the associated categories + $categories = GETPOST('suppcats', 'array'); + if (!empty($categories)) { + $cat = new Categorie($db); + foreach ($categories as $id_category) { + $cat->fetch($id_category); + $cat->add_type($object, 'supplier'); + } + } + // Logo/Photo save $dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos"; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); @@ -1245,13 +1272,26 @@ else } // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) - { - print ''.fieldLabel('Categories','custcats').''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1); - print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null, null, "90%"); - print ""; - } + if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + { + // Customer + if ($object->prospect || $object->client) { + print '' . fieldLabel('CustomersCategoriesShort', 'custcats') . ''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1); + print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null, + null, "90%"); + print ""; + } + + // Supplier + if ($object->fournisseur) { + print '' . fieldLabel('SuppliersCategoriesShort', 'suppcats') . ''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, 'parent', null, null, 1); + print $form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, null, + null, "90%"); + print ""; + } + } // Other attributes $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); @@ -1761,19 +1801,36 @@ else } // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) - { - print ''.fieldLabel('Categories', 'custcats').''; - print ''; - $cate_arbo = $form->select_all_categories( Categorie::TYPE_CUSTOMER, null, null, null, null, 1); - $c = new Categorie( $db ); - $cats = $c->containing( $object->id, Categorie::TYPE_CUSTOMER ); - foreach ($cats as $cat) { - $arrayselected[] = $cat->id; + if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + { + // Customer + if ($object->prospect || $object->client) { + print '' . fieldLabel('CustomersCategoriesShort', 'custcats') . ''; + print ''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, null, null, null, 1); + $c = new Categorie($db); + $cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER); + foreach ($cats as $cat) { + $arrayselected[] = $cat->id; + } + print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); + print ""; } - print $form->multiselectarray( 'custcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); - print ""; - } + + // Supplier + if ($object->fournisseur) { + print '' . fieldLabel('SuppliersCategoriesShort', 'suppcats') . ''; + print ''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, null, null, null, 1); + $c = new Categorie($db); + $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER); + foreach ($cats as $cat) { + $arrayselected[] = $cat->id; + } + print $form->multiselectarray('suppcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); + print ""; + } + } // Other attributes $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); @@ -2207,13 +2264,24 @@ else } // Tags / categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) - { - print '' . $langs->trans( "Categories" ) . ''; - print ''; - print $form->showCategories( $object->id, 'customer', 1 ); - print ""; - } + if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + { + // Customer + if ($object->prospect || $object->client) { + print '' . $langs->trans("CustomersCategoriesShort") . ''; + print ''; + print $form->showCategories($object->id, 'customer', 1); + print ""; + } + + // Supplier + if ($object->fournisseur) { + print '' . $langs->trans("SuppliersCategoriesShort") . ''; + print ''; + print $form->showCategories($object->id, 'supplier', 1); + print ""; + } + } // Incoterms if (!empty($conf->incoterm->enabled))