Merge pull request #3415 from GPCsolutions/3.8-2571-suppliers
Added tags/categories management to suppliers
This commit is contained in:
commit
3feeaf7294
@ -6,6 +6,7 @@
|
|||||||
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
|
||||||
* Copyright (C) 2014 Jean Heimburger <jean@tiaris.info>
|
* Copyright (C) 2014 Jean Heimburger <jean@tiaris.info>
|
||||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.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
|
* 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
|
||||||
@ -262,6 +263,12 @@ if ($object->id > 0)
|
|||||||
print "</td>";
|
print "</td>";
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
// Categories
|
||||||
|
print '<tr><td>' . $langs->trans("Categories") . '</td>';
|
||||||
|
print '<td colspan="3">';
|
||||||
|
print $form->showCategories($object->id, 'supplier', 1);
|
||||||
|
print "</td></tr>";
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
$parameters=array('socid'=>$object->id, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');
|
$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
|
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
* Copyright (C) 2011-2013 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
* Copyright (C) 2011-2013 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.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
|
* 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
|
||||||
@ -411,7 +412,7 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Categories association
|
// Customer categories association
|
||||||
$custcats = GETPOST( 'custcats', 'array' );
|
$custcats = GETPOST( 'custcats', 'array' );
|
||||||
if (!empty( $custcats )) {
|
if (!empty( $custcats )) {
|
||||||
$cat = new Categorie( $db );
|
$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
|
// Logo/Photo save
|
||||||
$dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/";
|
$dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/";
|
||||||
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
|
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
|
||||||
@ -525,7 +536,7 @@ if (empty($reshook))
|
|||||||
$error = $object->error; $errors = $object->errors;
|
$error = $object->error; $errors = $object->errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Categories association
|
// Customer categories association
|
||||||
// First we delete all categories association
|
// First we delete all categories association
|
||||||
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'categorie_societe';
|
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'categorie_societe';
|
||||||
$sql .= ' WHERE fk_soc = ' . $object->id;
|
$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
|
// Logo/Photo save
|
||||||
$dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos";
|
$dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos";
|
||||||
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
|
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
|
||||||
@ -1247,12 +1274,25 @@ else
|
|||||||
// Categories
|
// Categories
|
||||||
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
|
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
|
||||||
{
|
{
|
||||||
print '<tr><td class="toptd">'.fieldLabel('Categories','custcats').'</td><td colspan="3">';
|
// Customer
|
||||||
|
if ($object->prospect || $object->client) {
|
||||||
|
print '<tr><td class="toptd">' . fieldLabel('CustomersCategoriesShort', 'custcats') . '</td><td colspan="3">';
|
||||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1);
|
$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 $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null,
|
||||||
|
null, "90%");
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Supplier
|
||||||
|
if ($object->fournisseur) {
|
||||||
|
print '<tr><td class="toptd">' . fieldLabel('SuppliersCategoriesShort', 'suppcats') . '</td><td colspan="3">';
|
||||||
|
$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 "</td></tr>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
$parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3');
|
$parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3');
|
||||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||||
@ -1763,7 +1803,9 @@ else
|
|||||||
// Categories
|
// Categories
|
||||||
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
|
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
|
||||||
{
|
{
|
||||||
print '<tr><td>'.fieldLabel('Categories', 'custcats').'</td>';
|
// Customer
|
||||||
|
if ($object->prospect || $object->client) {
|
||||||
|
print '<tr><td>' . fieldLabel('CustomersCategoriesShort', 'custcats') . '</td>';
|
||||||
print '<td colspan="3">';
|
print '<td colspan="3">';
|
||||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, null, null, null, 1);
|
$cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, null, null, null, 1);
|
||||||
$c = new Categorie($db);
|
$c = new Categorie($db);
|
||||||
@ -1775,6 +1817,21 @@ else
|
|||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Supplier
|
||||||
|
if ($object->fournisseur) {
|
||||||
|
print '<tr><td>' . fieldLabel('SuppliersCategoriesShort', 'suppcats') . '</td>';
|
||||||
|
print '<td colspan="3">';
|
||||||
|
$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 "</td></tr>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
$parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3');
|
$parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3');
|
||||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||||
@ -2209,12 +2266,23 @@ else
|
|||||||
// Tags / categories
|
// Tags / categories
|
||||||
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
|
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
|
||||||
{
|
{
|
||||||
print '<tr><td>' . $langs->trans( "Categories" ) . '</td>';
|
// Customer
|
||||||
|
if ($object->prospect || $object->client) {
|
||||||
|
print '<tr><td>' . $langs->trans("CustomersCategoriesShort") . '</td>';
|
||||||
print '<td colspan="3">';
|
print '<td colspan="3">';
|
||||||
print $form->showCategories($object->id, 'customer', 1);
|
print $form->showCategories($object->id, 'customer', 1);
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Supplier
|
||||||
|
if ($object->fournisseur) {
|
||||||
|
print '<tr><td>' . $langs->trans("SuppliersCategoriesShort") . '</td>';
|
||||||
|
print '<td colspan="3">';
|
||||||
|
print $form->showCategories($object->id, 'supplier', 1);
|
||||||
|
print "</td></tr>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Incoterms
|
// Incoterms
|
||||||
if (!empty($conf->incoterm->enabled))
|
if (!empty($conf->incoterm->enabled))
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user