diff --git a/resources/views/gadaian/v2/edit.blade.php b/resources/views/gadaian/v2/edit.blade.php index b2fef2c..f119521 100644 --- a/resources/views/gadaian/v2/edit.blade.php +++ b/resources/views/gadaian/v2/edit.blade.php @@ -379,24 +379,22 @@ $('#beratpermata').val(""); } - $('#kuantiti').val(''); - - $('#karat').val(''); if(marhun == 'G/B' || marhun == 'WFR' || marhun == 'SYE' || marhun == 'DNR'){ if(marhun == 'DNR' || marhun == 'SYE'){ - $('#karat option').show(); - $('#karat option').not('[value="21.0K"]').not('[value="22.0K"]').not('[value="23.0K"]').not('[value="24.0K"]').not('[value="24.0Kgb"]').not(':first').hide(); + $('#sltkarat option').show(); + $('#sltkarat option').not('[value="21.0K"]').not('[value="22.0K"]').not('[value="23.0K"]').not('[value="24.0K"]').not('[value="24.0Kgb"]').not(':first').hide(); }else{ - $('#karat option').show(); - $('#karat option').not('[value="21.0K"]').not('[value="22.0K"]').not('[value="23.0K"]').not('[value="24.0K"]').not('[value="24.0Kgb"]').not(':first').hide(); + $('#sltkarat option').show(); + $('#sltkarat option').not('[value="21.0K"]').not('[value="22.0K"]').not('[value="23.0K"]').not('[value="24.0K"]').not('[value="24.0Kgb"]').not(':first').hide(); } $('#text-berat').html('Berat Keseluruhan'); - $('#kuantiti').attr('disabled', false); + $('#kuantiti_edit').attr('disabled', false); }else{ - $('#karat option').show(); + $('#kuantiti_edit').val(1); + $('#sltkarat option').show(); $('#text-berat').html('Berat'); - $('#kuantiti').attr('disabled', true); + $('#kuantiti_edit').attr('disabled', true); } }); @@ -431,6 +429,26 @@ $(".div_anggaran_edit").css("display", "none"); $('#beratpermataedit').val(""); } + + $('#kuantiti').val(''); + + $('#karat').val(''); + if(marhun == 'G/B' || marhun == 'WFR' || marhun == 'SYE' || marhun == 'DNR'){ + if(marhun == 'DNR' || marhun == 'SYE'){ + $('#karat option').show(); + $('#karat option').not('[value="21.0K"]').not('[value="22.0K"]').not('[value="23.0K"]').not('[value="24.0K"]').not('[value="24.0Kgb"]').not(':first').hide(); + }else{ + $('#karat option').show(); + $('#karat option').not('[value="21.0K"]').not('[value="22.0K"]').not('[value="23.0K"]').not('[value="24.0K"]').not('[value="24.0Kgb"]').not(':first').hide(); + } + + $('#text-berat').html('Berat Keseluruhan'); + $('#kuantiti').attr('disabled', false); + }else{ + $('#karat option').show(); + $('#text-berat').html('Berat'); + $('#kuantiti').attr('disabled', true); + } }); $('#karat').change(function(){ @@ -520,6 +538,12 @@ closeOnSelect: false }); + $('#nota_edit').select2({ + tags: true, + placeholder: "Select or add options", + width: 'resolve' + }); + $(".select2_batupermata").select2({ dropdownParent: $('#editMarhunModal'), tags: true, @@ -729,6 +753,13 @@ success:function(data){ $.each(data,function(index,jemas){ $("#marhun_edit").append(new Option(jemas['descpt'], jemas['marhun'])); + + res.forEach(function(value) { + if ($('#nota_edit').find("option[value='" + value + "']").length === 0) { + let newOption = new Option(value, value, true, true); + $('#nota_edit').append(newOption).trigger('change'); + } + }); $('#nota_edit').val(res).trigger('change'); $('#kuantiti_edit').val(kuantiti); diff --git a/resources/views/gadaian/v2/index.blade.php b/resources/views/gadaian/v2/index.blade.php index ffa9c4d..6f8a356 100644 --- a/resources/views/gadaian/v2/index.blade.php +++ b/resources/views/gadaian/v2/index.blade.php @@ -402,7 +402,7 @@ $('#marhun_edit').change(function(){ var marhun = this.value; - + if (!arrayBatuPermata.includes(marhun)) { $(".col_edit_permata").css("display", "block"); } else { @@ -411,6 +411,24 @@ $(".div_anggaran_edit").css("display", "none"); $('#beratpermataedit').val(""); } + + if(marhun == 'G/B' || marhun == 'WFR' || marhun == 'SYE' || marhun == 'DNR'){ + if(marhun == 'DNR' || marhun == 'SYE'){ + $('#sltkarat option').show(); + $('#sltkarat option').not('[value="21.0K"]').not('[value="22.0K"]').not('[value="23.0K"]').not('[value="24.0K"]').not('[value="24.0Kgb"]').not(':first').hide(); + }else{ + $('#sltkarat option').show(); + $('#sltkarat option').not('[value="21.0K"]').not('[value="22.0K"]').not('[value="23.0K"]').not('[value="24.0K"]').not('[value="24.0Kgb"]').not(':first').hide(); + } + + $('#text-berat').html('Berat Keseluruhan'); + $('#kuantiti_edit').attr('disabled', false); + }else{ + $('#kuantiti_edit').val(1); + $('#sltkarat option').show(); + $('#text-berat').html('Berat'); + $('#kuantiti_edit').attr('disabled', true); + } }); $('#karat').change(function(){ @@ -493,6 +511,12 @@ allowClear: true, closeOnSelect: false }); + + $('#nota_edit').select2({ + tags: true, + placeholder: "Select or add options", + width: 'resolve' + }); $(".select2_batupermata").select2({ dropdownParent: $('#editMarhunModal'), @@ -1643,7 +1667,15 @@ success:function(data){ $.each(data,function(index,jemas){ $("#marhun_edit").append(new Option(jemas['descpt'], jemas['marhun'])); - $('#nota_edit').val(res).trigger('change'); + + res.forEach(function(value) { + if ($('#nota_edit').find("option[value='" + value + "']").length === 0) { + let newOption = new Option(value, value, true, true); + $('#nota_edit').append(newOption).trigger('change'); + } + }); + + $('#nota_edit').val(res).trigger('change'); $('#kuantiti_edit').val(kuantiti); diff --git a/resources/views/modal/editmarhun.blade.php b/resources/views/modal/editmarhun.blade.php index 23b1955..0e4c021 100644 --- a/resources/views/modal/editmarhun.blade.php +++ b/resources/views/modal/editmarhun.blade.php @@ -29,7 +29,7 @@