Added ability to assign a category of product to a customer

This commit is contained in:
Regis Houssin 2008-10-07 12:24:33 +00:00
parent 977bacbdab
commit cf937a4278
6 changed files with 79 additions and 18 deletions

View File

@ -217,7 +217,10 @@ class Categorie
{ {
$sql .= ", description = '".addslashes($this->description)."'"; $sql .= ", description = '".addslashes($this->description)."'";
} }
$sql .= ", fk_soc = ".$this->socid; if ($this->socid)
{
$sql .= ", fk_soc = ".$this->socid;
}
$sql .= ", visible = '".$this->visible."'"; $sql .= ", visible = '".$this->visible."'";
$sql .= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;

View File

@ -140,7 +140,7 @@ else
print '</td></tr>'; print '</td></tr>';
if ($_GET['type'] == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER) if ($_GET['type'] == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER && !$categorie->id_mere)
{ {
print '<tr><td>'.$langs->trans ("AssignedToCustomer").'</td><td>'; print '<tr><td>'.$langs->trans ("AssignedToCustomer").'</td><td>';
print $html->select_societes($categorie->socid,'socid','s.client = 1 AND s.fournisseur = 0',1); print $html->select_societes($categorie->socid,'socid','s.client = 1 AND s.fournisseur = 0',1);

View File

@ -45,7 +45,11 @@ if ($_REQUEST['origin'])
if ($_GET['type'] == 0) $idProdOrigin = $_REQUEST['origin']; if ($_GET['type'] == 0) $idProdOrigin = $_REQUEST['origin'];
if ($_GET['type'] == 1) $idSupplierOrigin = $_REQUEST['origin']; if ($_GET['type'] == 1) $idSupplierOrigin = $_REQUEST['origin'];
if ($_GET['type'] == 2) $idCompanyOrigin = $_REQUEST['origin']; if ($_GET['type'] == 2) $idCompanyOrigin = $_REQUEST['origin'];
}
if ($_REQUEST['catorigin'])
{
if ($_GET['type'] == 0) $idCatOrigin = $_REQUEST['catorigin'];
} }
// If socid provided by ajax company selector // If socid provided by ajax company selector
@ -80,6 +84,11 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer)
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 if ($idCatOrigin)
{
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCatOrigin.'&type='.$_GET["type"]);
exit;
}
else else
{ {
header("Location: ".DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$_GET["type"]); header("Location: ".DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$_GET["type"]);
@ -140,6 +149,11 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer)
header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idSupplierOrigin.'&mesg='.urlencode($langs->trans("CatCreated"))); header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idSupplierOrigin.'&mesg='.urlencode($langs->trans("CatCreated")));
exit; exit;
} }
if ($idCatOrigin)
{
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCatOrigin.'&mesg='.urlencode($langs->trans("CatCreated")));
exit;
}
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$result.'&type='.$_POST["type"]); header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$result.'&type='.$_POST["type"]);
exit; exit;
@ -174,6 +188,10 @@ if ($user->rights->categorie->creer)
{ {
print '<input type="hidden" name="origin" value="'.$_REQUEST['origin'].'">'; print '<input type="hidden" name="origin" value="'.$_REQUEST['origin'].'">';
} }
if ($_REQUEST['catorigin'])
{
print '<input type="hidden" name="catorigin" value="'.$_REQUEST['catorigin'].'">';
}
print '<input type="hidden" name="nom" value="'.$nom.'">'; print '<input type="hidden" name="nom" value="'.$nom.'">';
print_fiche_titre($langs->trans("CreateCat")); print_fiche_titre($langs->trans("CreateCat"));
@ -200,11 +218,24 @@ if ($user->rights->categorie->creer)
print '</td></tr>'; print '</td></tr>';
if ($_GET['type'] == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER) if ($_GET['type'] == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
{ {
print '<tr><td>'.$langs->trans ("AssignedToCustomer").'</td><td>'; if ($_REQUEST['catorigin'])
print $html->select_societes($_REQUEST['socid_id'],'socid','s.client = 1 AND s.fournisseur = 0',1); {
print '</td></tr>'; print '<tr><td>'.$langs->trans ("AddIn").'</td><td>';
print '<input type="hidden" name="catMere" value="-1">'; print $html->select_all_categories($_GET['type'],$_REQUEST['catorigin']);
print '<input type="hidden" name="visible" value="1">'; print '</td></tr>';
print '<tr><td>'.$langs->trans ("ContentsVisibleByAll").'</td><td>';
print $html->selectyesno("visible", 1,1);
print '</td></tr>';
print '<input type="hidden" name="socid" value="'.$_GET['socid'].'">';
}
else
{
print '<tr><td>'.$langs->trans ("AssignedToCustomer").'</td><td>';
print $html->select_societes($_REQUEST['socid_id'],'socid','s.client = 1 AND s.fournisseur = 0',1);
print '</td></tr>';
print '<input type="hidden" name="catMere" value="-1">';
print '<input type="hidden" name="visible" value="1">';
}
} }
else else
{ {

View File

@ -123,13 +123,23 @@ print '</td></tr>';
if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER) if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
{ {
$soc = new Societe($db); if ($c->socid)
$soc->fetch($c->socid); {
$soc = new Societe($db);
print '<tr><td width="20%" class="notopnoleft">'; $soc->fetch($c->socid);
print $langs->trans("AssignedToTheCustomer").'</td><td>';
print $soc->getNomUrl(1); print '<tr><td width="20%" class="notopnoleft">';
print '</td></tr>'; print $langs->trans("AssignedToTheCustomer").'</td><td>';
print $soc->getNomUrl(1);
print '</td></tr>';
}
else
{
print '<tr><td width="20%" class="notopnoleft">';
print $langs->trans("InternalCategory").'</td><td>';
print ($c->visible ? $langs->trans("Visible") : $langs->trans("Invisible"));
print '</td></tr>';
}
} }
else else
{ {
@ -203,6 +213,21 @@ else
print "<tr><td>".$langs->trans("NoSubCat")."</td></tr>"; print "<tr><td>".$langs->trans("NoSubCat")."</td></tr>";
} }
print "</table>\n"; print "</table>\n";
/*
* Boutons actions
*/
if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
{
print "<div class='tabsAction'>\n";
if ($user->rights->categorie->creer)
{
print "<a class='butAction' href='fiche.php?action=create&amp;catorigin=".$c->id."&amp;socid=".$c->socid."&amp;type=".$type."'>".$langs->trans("Create")."</a>";
}
print "</div>";
}
} }
@ -323,4 +348,4 @@ if($c->type == 2)
$db->close(); $db->close();
llxFooter('$Date$ - $Revision$'); llxFooter('$Date$ - $Revision$');
?> ?>

View File

@ -72,4 +72,5 @@ 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 AssignedToCustomer=Assigned to a customer
AssignedToTheCustomer=Assigned to the customer AssignedToTheCustomer=Assigned to the customer
InternalCategory=Inernal category

View File

@ -72,4 +72,5 @@ ThisCategoryHasNoProduct=Cette cat
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 AssignedToCustomer=Attribuer à un client
AssignedToTheCustomer=Attribué au client AssignedToTheCustomer=Attribué au client
InternalCategory=Catégorie interne