FIX cutomer or supplier categories visible or not when required
This commit is contained in:
parent
82c89f739d
commit
53b099858f
@ -1063,6 +1063,39 @@ else
|
|||||||
$("#TypeName").html(document.formsoc.LastName.value);
|
$("#TypeName").html(document.formsoc.LastName.value);
|
||||||
document.formsoc.private.value=1;
|
document.formsoc.private.value=1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
init_customer_categ();
|
||||||
|
$("#customerprospect").change(function() {
|
||||||
|
init_customer_categ();
|
||||||
|
});
|
||||||
|
function init_customer_categ() {
|
||||||
|
console.log("is customer or prospect = "+jQuery("#customerprospect").val());
|
||||||
|
if (jQuery("#customerprospect").val() == 0 && (jQuery("#fournisseur").val() == 0 || '.(empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER)?'1':'0').'))
|
||||||
|
{
|
||||||
|
jQuery(".visibleifcustomer").hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
jQuery(".visibleifcustomer").show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init_supplier_categ();
|
||||||
|
$("#fournisseur").change(function() {
|
||||||
|
init_supplier_categ();
|
||||||
|
});
|
||||||
|
function init_supplier_categ() {
|
||||||
|
console.log("is supplier = "+jQuery("#fournisseur").val());
|
||||||
|
if (jQuery("#fournisseur").val() == 0)
|
||||||
|
{
|
||||||
|
jQuery(".visibleifsupplier").hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
jQuery(".visibleifsupplier").show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$("#selectcountry_id").change(function() {
|
$("#selectcountry_id").change(function() {
|
||||||
document.formsoc.action.value="create";
|
document.formsoc.action.value="create";
|
||||||
document.formsoc.submit();
|
document.formsoc.submit();
|
||||||
@ -1421,22 +1454,20 @@ else
|
|||||||
$langs->load('categories');
|
$langs->load('categories');
|
||||||
|
|
||||||
// Customer
|
// Customer
|
||||||
if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) {
|
//if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) {
|
||||||
print '<tr><td class="toptd">' . fieldLabel('CustomersCategoriesShort', 'custcats') . '</td><td colspan="3">';
|
print '<tr class="visibleifcustomer"><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,
|
print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null, null, "90%");
|
||||||
null, "90%");
|
print "</td></tr>";
|
||||||
print "</td></tr>";
|
//}
|
||||||
}
|
|
||||||
|
|
||||||
// Supplier
|
// Supplier
|
||||||
if ($object->fournisseur) {
|
//if ($object->fournisseur) {
|
||||||
print '<tr><td class="toptd">' . fieldLabel('SuppliersCategoriesShort', 'suppcats') . '</td><td colspan="3">';
|
print '<tr class="visibleifsupplier"><td class="toptd">' . fieldLabel('SuppliersCategoriesShort', 'suppcats') . '</td><td colspan="3">';
|
||||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, 'parent', null, null, 1);
|
$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,
|
print $form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, null, null, "90%");
|
||||||
null, "90%");
|
print "</td></tr>";
|
||||||
print "</td></tr>";
|
//}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multicurrency
|
// Multicurrency
|
||||||
@ -1488,11 +1519,6 @@ else
|
|||||||
}
|
}
|
||||||
elseif ($action == 'edit')
|
elseif ($action == 'edit')
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
* Edition
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//print load_fiche_titre($langs->trans("EditCompany"));
|
//print load_fiche_titre($langs->trans("EditCompany"));
|
||||||
|
|
||||||
if ($socid)
|
if ($socid)
|
||||||
@ -1612,8 +1638,10 @@ else
|
|||||||
$sub2=0;
|
$sub2=0;
|
||||||
}else{$sub2=1;}
|
}else{$sub2=1;}
|
||||||
|
|
||||||
print "\n".'<script type="text/javascript">';
|
if ($conf->use_javascript_ajax)
|
||||||
print '$(document).ready(function () {
|
{
|
||||||
|
print "\n".'<script type="text/javascript">';
|
||||||
|
print '$(document).ready(function () {
|
||||||
var val='.$sub.';
|
var val='.$sub.';
|
||||||
var val2='.$sub2.';
|
var val2='.$sub2.';
|
||||||
if("#localtax1assuj_value".value==undefined){
|
if("#localtax1assuj_value".value==undefined){
|
||||||
@ -1647,19 +1675,44 @@ else
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});';
|
init_customer_categ();
|
||||||
print '</script>'."\n";
|
$("#customerprospect").change(function() {
|
||||||
|
init_customer_categ();
|
||||||
|
});
|
||||||
|
function init_customer_categ() {
|
||||||
|
console.log("is customer or prospect = "+jQuery("#customerprospect").val());
|
||||||
|
if (jQuery("#customerprospect").val() == 0 && (jQuery("#fournisseur").val() == 0 || '.(empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER)?'1':'0').'))
|
||||||
|
{
|
||||||
|
jQuery(".visibleifcustomer").hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
jQuery(".visibleifcustomer").show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init_supplier_categ();
|
||||||
|
$("#fournisseur").change(function() {
|
||||||
|
init_supplier_categ();
|
||||||
|
});
|
||||||
|
function init_supplier_categ() {
|
||||||
|
console.log("is supplier = "+jQuery("#fournisseur").val());
|
||||||
|
if (jQuery("#fournisseur").val() == 0)
|
||||||
|
{
|
||||||
|
jQuery(".visibleifsupplier").hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
jQuery(".visibleifsupplier").show();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if ($conf->use_javascript_ajax)
|
$("#selectcountry_id").change(function() {
|
||||||
{
|
document.formsoc.action.value="edit";
|
||||||
print "\n".'<script type="text/javascript" language="javascript">';
|
document.formsoc.submit();
|
||||||
print '$(document).ready(function () {
|
});
|
||||||
$("#selectcountry_id").change(function() {
|
|
||||||
document.formsoc.action.value="edit";
|
})';
|
||||||
document.formsoc.submit();
|
|
||||||
});
|
|
||||||
})';
|
|
||||||
print '</script>'."\n";
|
print '</script>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2022,34 +2075,30 @@ else
|
|||||||
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
|
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
|
||||||
{
|
{
|
||||||
// Customer
|
// Customer
|
||||||
if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) {
|
print '<tr class="visibleifcustomer"><td>' . fieldLabel('CustomersCategoriesShort', 'custcats') . '</td>';
|
||||||
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);
|
$cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER);
|
||||||
$cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER);
|
$arrayselected=array();
|
||||||
$arrayselected=array();
|
foreach ($cats as $cat) {
|
||||||
foreach ($cats as $cat) {
|
$arrayselected[] = $cat->id;
|
||||||
$arrayselected[] = $cat->id;
|
|
||||||
}
|
|
||||||
print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%');
|
|
||||||
print "</td></tr>";
|
|
||||||
}
|
}
|
||||||
|
print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%');
|
||||||
|
print "</td></tr>";
|
||||||
|
|
||||||
// Supplier
|
// Supplier
|
||||||
if ($object->fournisseur) {
|
print '<tr class="visibleifsupplier"><td>' . fieldLabel('SuppliersCategoriesShort', 'suppcats') . '</td>';
|
||||||
print '<tr><td>' . fieldLabel('SuppliersCategoriesShort', 'suppcats') . '</td>';
|
print '<td colspan="3">';
|
||||||
print '<td colspan="3">';
|
$cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, null, null, null, 1);
|
||||||
$cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, null, null, null, 1);
|
$c = new Categorie($db);
|
||||||
$c = new Categorie($db);
|
$cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER);
|
||||||
$cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER);
|
$arrayselected=array();
|
||||||
$arrayselected=array();
|
foreach ($cats as $cat) {
|
||||||
foreach ($cats as $cat) {
|
$arrayselected[] = $cat->id;
|
||||||
$arrayselected[] = $cat->id;
|
|
||||||
}
|
|
||||||
print $form->multiselectarray('suppcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%');
|
|
||||||
print "</td></tr>";
|
|
||||||
}
|
}
|
||||||
|
print $form->multiselectarray('suppcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%');
|
||||||
|
print "</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multicurrency
|
// Multicurrency
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user