Added ability to assign a category of product to a customer

Fix: error by canceling the creation of a category
This commit is contained in:
Regis Houssin 2008-10-07 08:46:31 +00:00
parent 26e25f18a1
commit 4a43e65828
3 changed files with 35 additions and 15 deletions

View File

@ -1,8 +1,8 @@
<?php <?php
/* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org> /* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
* Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com> * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -36,7 +36,7 @@ if (isset ($_REQUEST['choix']))
$nbcats = $_REQUEST['choix']; $nbcats = $_REQUEST['choix'];
} }
else else
{ // par d<EFBFBD>fault, une nouvelle cat<61>gorie sera dans une seule cat<61>gorie m<>re { // par default, une nouvelle categorie sera dans une seule categorie mere
$nbcats = 1; $nbcats = 1;
} }
@ -55,32 +55,39 @@ if ($_REQUEST['origin'])
if ($_POST["action"] == 'add' && $user->rights->categorie->creer) if ($_POST["action"] == 'add' && $user->rights->categorie->creer)
{ {
// Action ajout d'une cat<EFBFBD>gorie // Action ajout d'une categorie
if ($_POST["cancel"]) if ($_POST["cancel"])
{ {
print 'origin : '.$idProdOrigin;
if ($idProdOrigin) if ($idProdOrigin)
{ {
header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?id='.$idProdOrigin.'&type='.$_GET["type"]); header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?id='.$idProdOrigin.'&type='.$_GET["type"]);
exit; exit;
} }
if ($idCompanyOrigin) else if ($idCompanyOrigin)
{ {
header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idCompanyOrigin.'&type='.$_GET["type"]); header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idCompanyOrigin.'&type='.$_GET["type"]);
exit; exit;
} }
if ($idSupplierOrigin) else if ($idSupplierOrigin)
{ {
header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idSupplierOrigin.'&type='.$_GET["type"]); header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idSupplierOrigin.'&type='.$_GET["type"]);
exit; exit;
} }
else
{
header("Location: ".DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$_GET["type"]);
exit;
}
} }
$categorie = new Categorie($db); $categorie = new Categorie($db);
$categorie->label = $_POST["nom"]; $categorie->label = $_POST["nom"];
$categorie->description = $_POST["description"]; $categorie->description = $_POST["description"];
$categorie->socid = $_POST["socid"];
$categorie->visible = $_POST["visible"]; $categorie->visible = $_POST["visible"];
$categorie->type = $_POST["type"]; $categorie->type = $_POST["type"];
if($_POST['catMere'] != "-1") if($_POST['catMere'] != "-1")
$categorie->id_mere = $_POST['catMere']; $categorie->id_mere = $_POST['catMere'];
@ -184,12 +191,23 @@ if ($user->rights->categorie->creer)
} }
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans ("AddIn").'</td><td>'; if ($_GET['type'] == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
print $html->select_all_categories($_GET['type']); {
print '</td></tr>'; print '<tr><td>'.$langs->trans ("AssignedToCustomer").'</td><td>';
print '<tr><td>'.$langs->trans ("ContentsVisibleByAll").'</td><td>'; print $html->select_societes('','socid','s.client = 1 AND s.fournisseur = 0',1);
print $html->selectyesno("visible", 1,1); print '</td></tr>';
print '</td></tr>'; print '<input type="hidden" name="catMere" value="-1">';
print '<input type="hidden" name="type" value="0">';
}
else
{
print '<tr><td>'.$langs->trans ("AddIn").'</td><td>';
print $html->select_all_categories($_GET['type']);
print '</td></tr>';
print '<tr><td>'.$langs->trans ("ContentsVisibleByAll").'</td><td>';
print $html->selectyesno("visible", 1,1);
print '</td></tr>';
}
print '<tr><td colspan="2" align="center">'; print '<tr><td colspan="2" align="center">';
print '<input type="submit" class="button" value="'.$langs->trans("CreateThisCat").'" name="creation" />'; print '<input type="submit" class="button" value="'.$langs->trans("CreateThisCat").'" name="creation" />';
print ' &nbsp; &nbsp; '; print ' &nbsp; &nbsp; ';

View File

@ -70,4 +70,5 @@ CustomersCategoriesShort=Customers categories
ProductsCategoriesShort=Products categories ProductsCategoriesShort=Products categories
ThisCategoryHasNoProduct=This category does not contain any product. ThisCategoryHasNoProduct=This category does not contain any product.
ThisCategoryHasNoSupplier=This category does not contain any supplier. ThisCategoryHasNoSupplier=This category does not contain any supplier.
ThisCategoryHasNoCustomer=This category does not contain any customer. ThisCategoryHasNoCustomer=This category does not contain any customer.
AssignedToCustomer=Assigned to a customer

View File

@ -70,4 +70,5 @@ CustomersCategoriesShort=Cat
ProductsCategoriesShort=Catégories produits ProductsCategoriesShort=Catégories produits
ThisCategoryHasNoProduct=Cette catégorie ne contient aucun produit. ThisCategoryHasNoProduct=Cette catégorie ne contient aucun produit.
ThisCategoryHasNoSupplier=Cette catégorie ne contient aucun fournisseur. ThisCategoryHasNoSupplier=Cette catégorie ne contient aucun fournisseur.
ThisCategoryHasNoCustomer=Cette catégorie ne contient aucun client. ThisCategoryHasNoCustomer=Cette catégorie ne contient aucun client.
AssignedToCustomer=Attribuer à un client