Gestion js : déroulement des sous bom

This commit is contained in:
atm-lena 2022-02-07 16:28:58 +01:00
parent 5c862435a8
commit f921c10e3a
3 changed files with 48 additions and 2 deletions

View File

@ -1312,6 +1312,13 @@ class Mo extends CommonObject
$text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) ? '- '.$langs->trans("StockOnReception").'<br>' : '');
print '<tr class="liste_titre">';
// Product or sub-bom
print '<td class="linecoldescription">'.$langs->trans('Description');
if (!empty($conf->global->BOM_SUB_BOM)) {
print ' &nbsp; <a id="show_all" href="#">'.img_picto('', 'folder-open', 'class="paddingright"').$langs->trans("ExpandAll").'</a>&nbsp;&nbsp;';
print '<a id="hide_all" href="#">'.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").'</a>&nbsp;';
}
print '</td>';
print '<td>'.$langs->trans('Ref').'</td>';
print '<td class="right">'.$langs->trans('Qty');
if ($this->bom->bomtype == 0) {

View File

@ -243,7 +243,46 @@ if ($action == 'create') {
?>
<script>
$(document).ready(function () {
jQuery('#fk_bom').change(function() {
/*TODO : DUPLICATA, factoriser le code : bom_card.php line 589**/
// When clicking on collapse
$(".collapse_bom").click(function() {
console.log("We click on collapse");
var id_bom_line = $(this).attr('id').replace('collapse-', '');
console.log($(this).html().indexOf('folder-open'));
if($(this).html().indexOf('folder-open') <= 0) {
$('[parentid="'+ id_bom_line +'"]').show();
$(this).html('<?php echo dol_escape_js(img_picto('', 'folder-open')); ?>');
}
else {
$('[parentid="'+ id_bom_line +'"]').hide();
$(this).html('<?php echo dol_escape_js(img_picto('', 'folder')); ?>');
}
return false;
});
// To Show all the sub bom lines
$("#show_all").click(function() {
console.log("We click on show all");
$("[class^=sub_bom_lines]").show();
$("[class^=collapse_bom]").html('<?php echo dol_escape_js(img_picto('', 'folder-open')); ?>');
return false;
});
// To Hide all the sub bom lines
$("#hide_all").click(function() {
console.log("We click on hide all");
$("[class^=sub_bom_lines]").hide();
$("[class^=collapse_bom]").html('<?php echo dol_escape_js(img_picto('', 'folder')); ?>');
return false;
});
/*TODO : DUPLICATA, factoriser le code**/
jQuery('#fk_bom').change(function() {
console.log('We change value of BOM with BOM of id '+jQuery('#fk_bom').val());
if (jQuery('#fk_bom').val() > 0)
{

View File

@ -99,7 +99,7 @@ if ($resql) {
$sub_bom_line->fetch($obj->rowid);
//If hidden conf is set, we show directly all the sub-BOM lines
if (!empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT)) {
if (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT)) {
print '<tr style="display:none" class="sub_bom_lines" parentid="'.$line->id.'">';
} else {
print '<tr class="sub_bom_lines" parentid="'.$line->id.'">';