Fix: hide supplier fields if supplier module is disabled
This commit is contained in:
parent
6cd0fc074f
commit
0df44a7787
@ -68,6 +68,29 @@ class ActionsCardCommon
|
||||
{
|
||||
$this->tpl[$key] = $value;
|
||||
}
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
$this->tpl['ajax_selecttype'] = "\n".'<script type="text/javascript" language="javascript">
|
||||
jQuery(document).ready(function () {
|
||||
jQuery("#radiocompany").click(function() {
|
||||
document.formsoc.action.value="create";
|
||||
document.formsoc.canvas.value="default";
|
||||
document.formsoc.private.value=0;
|
||||
document.formsoc.submit();
|
||||
});
|
||||
jQuery("#radioprivate").click(function() {
|
||||
document.formsoc.action.value="create";
|
||||
document.formsoc.canvas.value="individual";
|
||||
document.formsoc.private.value=1;
|
||||
document.formsoc.submit();
|
||||
});
|
||||
});
|
||||
</script>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'create' || $action == 'edit')
|
||||
{
|
||||
@ -97,19 +120,6 @@ class ActionsCardCommon
|
||||
// We verified if the tag prefix is used
|
||||
if ($modCodeClient->code_auto) $this->tpl['prefix_customercode'] = $modCodeClient->verif_prefixIsUsed();
|
||||
|
||||
// Load object modCodeFournisseur
|
||||
$module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON;
|
||||
if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON;
|
||||
if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
|
||||
{
|
||||
$module = substr($module, 0, dol_strlen($module)-4);
|
||||
}
|
||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php");
|
||||
$modCodeFournisseur = new $module;
|
||||
$this->tpl['auto_suppliercode'] = $modCodeFournisseur->code_auto;
|
||||
// We verified if the tag prefix is used
|
||||
if ($modCodeFournisseur->code_auto) $this->tpl['prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed();
|
||||
|
||||
// TODO create a function
|
||||
$this->tpl['select_customertype'] = '<select class="flat" name="client">';
|
||||
$this->tpl['select_customertype'].= '<option value="2"'.($this->object->client==2?' selected="selected"':'').'>'.$langs->trans('Prospect').'</option>';
|
||||
@ -124,18 +134,36 @@ class ActionsCardCommon
|
||||
$this->tpl['ismodifiable_customercode'] = $this->object->codeclient_modifiable();
|
||||
$s=$modCodeClient->getToolTip($langs,$this->object,0);
|
||||
$this->tpl['help_customercode'] = $form->textwithpicto('',$s,1);
|
||||
|
||||
// Supplier
|
||||
$this->tpl['yn_supplier'] = $form->selectyesno("fournisseur",$this->object->fournisseur,1);
|
||||
$this->tpl['suppliercode'] = $this->object->code_fournisseur;
|
||||
if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) $this->tpl['suppliercode'] = $modCodeFournisseur->getNextValue($this->object,1);
|
||||
$this->tpl['ismodifiable_suppliercode'] = $this->object->codefournisseur_modifiable();
|
||||
$s=$modCodeFournisseur->getToolTip($langs,$this->object,1);
|
||||
$this->tpl['help_suppliercode'] = $form->textwithpicto('',$s,1);
|
||||
|
||||
$this->object->LoadSupplierCateg();
|
||||
$this->tpl['suppliercategory'] = $this->object->SupplierCategories;
|
||||
$this->tpl['select_suppliercategory'] = $form->selectarray("fournisseur_categorie",$this->object->SupplierCategories,$_POST["fournisseur_categorie"],1);
|
||||
|
||||
if ($conf->fournisseur->enabled)
|
||||
{
|
||||
$this->tpl['supplier_enabled'] = 1;
|
||||
|
||||
// Load object modCodeFournisseur
|
||||
$module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON;
|
||||
if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON;
|
||||
if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
|
||||
{
|
||||
$module = substr($module, 0, dol_strlen($module)-4);
|
||||
}
|
||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php");
|
||||
$modCodeFournisseur = new $module;
|
||||
$this->tpl['auto_suppliercode'] = $modCodeFournisseur->code_auto;
|
||||
// We verified if the tag prefix is used
|
||||
if ($modCodeFournisseur->code_auto) $this->tpl['prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed();
|
||||
|
||||
// Supplier
|
||||
$this->tpl['yn_supplier'] = $form->selectyesno("fournisseur",$this->object->fournisseur,1);
|
||||
$this->tpl['suppliercode'] = $this->object->code_fournisseur;
|
||||
if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) $this->tpl['suppliercode'] = $modCodeFournisseur->getNextValue($this->object,1);
|
||||
$this->tpl['ismodifiable_suppliercode'] = $this->object->codefournisseur_modifiable();
|
||||
$s=$modCodeFournisseur->getToolTip($langs,$this->object,1);
|
||||
$this->tpl['help_suppliercode'] = $form->textwithpicto('',$s,1);
|
||||
|
||||
$this->object->LoadSupplierCateg();
|
||||
$this->tpl['suppliercategory'] = $this->object->SupplierCategories;
|
||||
$this->tpl['select_suppliercategory'] = $form->selectarray("fournisseur_categorie",$this->object->SupplierCategories,$_POST["fournisseur_categorie"],1);
|
||||
}
|
||||
|
||||
// Zip
|
||||
$this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->cp,'zipcode',array('town','selectpays_id','departement_id'),6);
|
||||
|
||||
@ -22,23 +22,7 @@
|
||||
<!-- BEGIN PHP TEMPLATE -->
|
||||
|
||||
<?php if ($conf->use_javascript_ajax) { ?>
|
||||
<script type="text/javascript" language="javascript">
|
||||
jQuery(document).ready(function () {
|
||||
jQuery("#radiocompany").click(function() {
|
||||
document.formsoc.action.value="create";
|
||||
document.formsoc.canvas.value="default";
|
||||
document.formsoc.private.value=0;
|
||||
document.formsoc.submit();
|
||||
});
|
||||
jQuery("#radioprivate").click(function() {
|
||||
document.formsoc.action.value="create";
|
||||
document.formsoc.canvas.value="individual";
|
||||
document.formsoc.private.value=1;
|
||||
document.formsoc.submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php echo $this->control->tpl['ajax_selecttype']; ?>
|
||||
<br>
|
||||
<?php echo $langs->trans("ThirdPartyType") ?>:
|
||||
<input type="radio" id="radiocompany" class="flat" name="private" value="0"'<?php echo (! $_REQUEST["private"]?' checked="true"':''); ?>>
|
||||
@ -83,6 +67,7 @@ jQuery(document).ready(function () {
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php if ($this->control->tpl['supplier_enabled']) { ?>
|
||||
<tr>
|
||||
<td><span class="fieldrequired"><?php echo $langs->trans('Supplier'); ?></span></td>
|
||||
<td><?php echo $this->control->tpl['yn_supplier']; ?></td>
|
||||
@ -97,9 +82,7 @@ jQuery(document).ready(function () {
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
if ($this->control->tpl['fournisseur']) {
|
||||
if (sizeof($this->control->tpl['suppliercategory']) > 0) { ?>
|
||||
<?php if (sizeof($this->control->tpl['suppliercategory']) > 0) { ?>
|
||||
<tr>
|
||||
<td><?php echo $langs->trans('SupplierCategory'); ?></td>
|
||||
<td colspan="3"><?php echo $this->control->tpl['select_suppliercategory']; ?></td>
|
||||
|
||||
@ -22,23 +22,7 @@
|
||||
<!-- BEGIN PHP TEMPLATE -->
|
||||
|
||||
<?php if ($conf->use_javascript_ajax) { ?>
|
||||
<script type="text/javascript" language="javascript">
|
||||
jQuery(document).ready(function () {
|
||||
jQuery("#radiocompany").click(function() {
|
||||
document.formsoc.action.value="create";
|
||||
document.formsoc.canvas.value="default";
|
||||
document.formsoc.private.value=0;
|
||||
document.formsoc.submit();
|
||||
});
|
||||
jQuery("#radioprivate").click(function() {
|
||||
document.formsoc.action.value="create";
|
||||
document.formsoc.canvas.value="individual";
|
||||
document.formsoc.private.value=1;
|
||||
document.formsoc.submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php echo $this->control->tpl['ajax_selecttype']; ?>
|
||||
<br>
|
||||
<?php echo $langs->trans("ThirdPartyType") ?>:
|
||||
<input type="radio" id="radiocompany" class="flat" name="private" value="0"'<?php echo (! $_REQUEST["private"]?' checked="true"':''); ?>>
|
||||
@ -95,6 +79,7 @@ jQuery(document).ready(function () {
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php if ($this->control->tpl['supplier_enabled']) { ?>
|
||||
<tr>
|
||||
<td><span class="fieldrequired"><?php echo $langs->trans('Supplier'); ?></span></td>
|
||||
<td><?php echo $this->control->tpl['yn_supplier']; ?></td>
|
||||
@ -109,9 +94,7 @@ jQuery(document).ready(function () {
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
if ($this->control->tpl['fournisseur']) {
|
||||
if (sizeof($this->control->tpl['suppliercategory']) > 0) { ?>
|
||||
<?php if (sizeof($this->control->tpl['suppliercategory']) > 0) { ?>
|
||||
<tr>
|
||||
<td><?php echo $langs->trans('SupplierCategory'); ?></td>
|
||||
<td colspan="3"><?php echo $this->control->tpl['select_suppliercategory']; ?></td>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user