diff --git a/Layout/default/Linework/Index.php b/Layout/default/Linework/Index.php index ec626ed16..fcf65bfc5 100644 --- a/Layout/default/Linework/Index.php +++ b/Layout/default/Linework/Index.php @@ -341,37 +341,72 @@ $(document).ready(function() { } }); -$('select[name=wfitem_linework_finished]').each(function() { +$('input[name=wfitemplaceholder_customer_passive_finished]').each(function() { var elem = this; //console.log(elem); $(elem).click(function() { - var id_match = $(this).attr("id").match(/wfitem_linework_finished_(\d+)$/); + var id_match = $(this).attr("id").match(/wfitemplaceholder_customer_passive_finished_(\d+)$/); var id = id_match[1]; //console.log(id); - var ap_type=$('#wfitem_anschlusspunkt_typ_' + id).val(); - var ap_name=$('#wfitem_anschlusspunkt_name_' + id).val(); - var rohrname=$('#wfitem_rohrverband_name_' + id).val(); - var rohrtype=$('#wfitem_rohrtype_' + id).val(); - var rohrfarbe=$('#wfitem_rohrfarbe_' + id).val(); - - var ist_ap_type=$('#wfitem_ist_anschlusspunkt_typ_' + id).val(); - var ist_ap_name=$('#wfitem_ist_anschlusspunkt_name_' + id).val(); - var ist_rohrname=$('#wfitem_ist_rohrverband_name_' + id).val(); - var ist_rohrtype=$('#wfitem_ist_rohrtype_' + id).val(); - var ist_rohrfarbe=$('#wfitem_ist_rohrfarbe_' + id).val(); - - //console.log(ap_type, ap_name, rohrname, rohrtype, rohrfarbe); + required_fields = { + pop_id: "int", + schrank: "string", + baugruppe: "string", + modul: "string", + ports: "string", + abschlusstyp: "string", + bb_kabel: "string", + bb_fasern: "string", + kundenkabel_typ: "string", + kundenkabel_fasern: "string", + backbone_finished: "bool", + inhouse_cabling_supplied: "bool", + inhouse_cabling_deployed: "bool", + bep_deployed: "bool", + customer_cable_injected: "bool", + spliced_network: "bool", + spliced_customer: "bool", + }; - if((!ap_type && !ist_ap_type) || (!ap_name && !ist_ap_type) || (!rohrname && !ist_rohrname) || (!rohrtype || !ist_rohrtype) || (!rohrfarbe && !ist_rohrfarbe)) { - $(this).find("option").attr("disabled", true); + + var missing = false; + for(var field1 in required_fields) { + field2 = "ist_" + field1; + type = required_fields[field1]; + + var val1 = $("#wfitem_" + field1 + "_" + id).val(); + if($("#wfitem_" + field2 + "_" + id).length) { + var val2 = $("#wfitem_" + field2 + "_" + id).val(); + } else { + val2 = true; + } + + if(type == "bool") { + if(!parseInt(val1)) { + console.log(field1 + " missing"); + missing = true; + } + } else { + if(!val1 && !val2) { + console.log(field1 + " or " + field2 + " missing"); + missing = true; + } + } } - if((ap_type || ist_ap_type) && (ap_name || ist_ap_name) && (rohrname || ist_rohrname) && (rohrtype || ist_rohrtype) && (rohrfarbe || ist_rohrfarbe)) { - //console.log("enable"); - $(this).find("option").removeAttr("disabled"); - } + console.log("missing: "); + console.log(missing); + if(missing) { + $("#wfitemplaceholder_customer_passive_finished_" + id).prop('checked', false); + $("#wfitemplaceholder_customer_passive_finished_" + id).attr("readonly", true); + } else { + $("#wfitemplaceholder_customer_passive_finished_" + id).attr("disabled", false); + $("#wfitemplaceholder_customer_passive_finished_" + id).prop('readonly', true); + } + + }); });