From 9c84e82d3c628222a46a2e2959617fa758283333 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Sat, 6 Nov 2021 14:12:55 +0100 Subject: [PATCH] changed some workflowitems to update every termination in building --- Layout/default/Linework/Index.php | 44 ++++++- Layout/default/Order/Form.php | 2 +- Layout/default/Pipework/Index.php | 2 + Layout/default/Workflow/form.php | 116 +++++++++--------- application/Linework/LineworkController.php | 65 +++++++++- .../Workflowvalue/WorkflowvalueModel.php | 7 ++ 6 files changed, 171 insertions(+), 65 deletions(-) diff --git a/Layout/default/Linework/Index.php b/Layout/default/Linework/Index.php index eafb607ad..3e2b4dd5c 100644 --- a/Layout/default/Linework/Index.php +++ b/Layout/default/Linework/Index.php @@ -358,9 +358,42 @@ $(document).ready(function() { }); + $('select[id^="wfitem_abschlusstyp_"]').each(function() { + var elem = this; + $(elem).change(function() { + var id_match = $(this).attr("id").match(/wfitem_abschlusstyp_(\d+)$/); + var id = id_match[1]; + + if($(this).val() == "SC/APC in FTU") { + $('#workflow-item-inhouse_cabling_supplied-' + id + ' .wf-content').hide(); + $('#workflow-item-inhouse_cabling_deployed-' + id + ' .wf-content').hide(); + } else { + $('#workflow-item-inhouse_cabling_supplied-' + id + ' .wf-content').show(); + $('#workflow-item-inhouse_cabling_deployed-' + id + ' .wf-content').show(); + } + }); + $(elem).change(); + }); + + $('select[id^="wfitem_ist_abschlusstyp_"]').each(function() { + var elem = this; + $(elem).change(function() { + var id_match = $(this).attr("id").match(/wfitem_ist_abschlusstyp_(\d+)$/); + var id = id_match[1]; + + if($(this).val() == "SC/APC in FTU") { + $('#workflow-item-inhouse_cabling_supplied-' + id + ' .wf-content').hide(); + $('#workflow-item-inhouse_cabling_deployed-' + id + ' .wf-content').hide(); + } else { + $('#workflow-item-inhouse_cabling_supplied-' + id + ' .wf-content').show(); + $('#workflow-item-inhouse_cabling_deployed-' + id + ' .wf-content').show(); + } + }); + $(elem).change(); + }); + $('form[id^="wf-termination-"]').each(function() { var elem = this; - console.log(elem); $(elem).submit(function(e) { console.log(this); @@ -392,14 +425,19 @@ function validateWorkflowItem(id) { 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", }; + console.log("abschlusstyp: " + $("#wfitem_abschlusstyp_" + id).val()); + console.log("ist abschlusstyp: " + $("#wfitem_ist_abschlusstyp_" + id).val()); + if($("#wfitem_abschlusstyp_" + id).val() != "SC/APC in FTU" && $("#wfitem_ist_abschlusstyp_" + id).val() != "SC/APC in FTU") { + required_fields["inhouse_cabling_supplied"] = "bool"; + required_fields["inhouse_cabling_deployed"] = "bool"; + } + var missing = false; for(var field1 in required_fields) { diff --git a/Layout/default/Order/Form.php b/Layout/default/Order/Form.php index 23003f4c1..29568af16 100644 --- a/Layout/default/Order/Form.php +++ b/Layout/default/Order/Form.php @@ -298,7 +298,7 @@
- +
diff --git a/Layout/default/Pipework/Index.php b/Layout/default/Pipework/Index.php index 91cc7d5c1..f8f41067d 100644 --- a/Layout/default/Pipework/Index.php +++ b/Layout/default/Pipework/Index.php @@ -289,6 +289,8 @@ $(document).ready(function() { var pos = $('#building-' + building).offset().top; $(window).scrollTop(pos - 150 ); } + + }); $('select[name=wfitem_pipework_finished]').each(function() { diff --git a/Layout/default/Workflow/form.php b/Layout/default/Workflow/form.php index 85a67c1d2..87b58b7b6 100644 --- a/Layout/default/Workflow/form.php +++ b/Layout/default/Workflow/form.php @@ -7,64 +7,66 @@ } } ?> - width > 1) ? "colspan='".$item->width."'" : ""?> style="width: commaToDot(round(100 / $wfColspan, 2) * $item->width)?>%"> - type != "gps"): ?> - - + width > 1) ? "colspan='".$item->width."'" : ""?> style="width: commaToDot(round(100 / $wfColspan, 2) * $item->width)?>%"> +
+ type != "gps"): ?> + + - type) { - case "string": - include(realpath(dirname(__FILE__)."/items/")."/string.php"); - break; - case "int": - include(realpath(dirname(__FILE__)."/items/")."/int.php"); - break; - case "bool": - include(realpath(dirname(__FILE__)."/items/")."/bool.php"); - break; - case "enum": - include(realpath(dirname(__FILE__)."/items/")."/enum.php"); - break; - case "text": - include(realpath(dirname(__FILE__)."/items/")."/text.php"); - break; - case "file": - include(realpath(dirname(__FILE__)."/items/")."/file.php"); - break; - case "gps": - include(realpath(dirname(__FILE__)."/items/")."/gps.php"); - break; - case "color": - include(realpath(dirname(__FILE__)."/items/")."/color.php"); - break; - case "delimiter": - include(realpath(dirname(__FILE__)."/items/")."/delimiter.php"); - break; - case "date": - include(realpath(dirname(__FILE__)."/items/")."/date.php"); - break; - case "empty": - include(realpath(dirname(__FILE__)."/items/")."/empty.php"); - break; - default: - include(realpath(dirname(__FILE__)."/items/")."/string.php"); - } - ?> -
- value->changed): ?> - title="Geändert: value->changed)?> von value->changer->name?> (value->changer->address->getCompanyOrName(true)?>)" - - > - value->changed): ?> - value->changer->getAbbrName()?> - - + switch($item->type) { + case "string": + include(realpath(dirname(__FILE__)."/items/")."/string.php"); + break; + case "int": + include(realpath(dirname(__FILE__)."/items/")."/int.php"); + break; + case "bool": + include(realpath(dirname(__FILE__)."/items/")."/bool.php"); + break; + case "enum": + include(realpath(dirname(__FILE__)."/items/")."/enum.php"); + break; + case "text": + include(realpath(dirname(__FILE__)."/items/")."/text.php"); + break; + case "file": + include(realpath(dirname(__FILE__)."/items/")."/file.php"); + break; + case "gps": + include(realpath(dirname(__FILE__)."/items/")."/gps.php"); + break; + case "color": + include(realpath(dirname(__FILE__)."/items/")."/color.php"); + break; + case "delimiter": + include(realpath(dirname(__FILE__)."/items/")."/delimiter.php"); + break; + case "date": + include(realpath(dirname(__FILE__)."/items/")."/date.php"); + break; + case "empty": + include(realpath(dirname(__FILE__)."/items/")."/empty.php"); + break; + default: + include(realpath(dirname(__FILE__)."/items/")."/string.php"); + } + ?> +
+ value->changed): ?> + title="Geändert: value->changed)?> von value->changer->name?> (value->changer->address->getCompanyOrName(true)?>)" + + > + value->changed): ?> + value->changer->getAbbrName()?> + + +
\ No newline at end of file diff --git a/application/Linework/LineworkController.php b/application/Linework/LineworkController.php index 0d523522f..ee084d460 100644 --- a/application/Linework/LineworkController.php +++ b/application/Linework/LineworkController.php @@ -249,10 +249,15 @@ class LineworkController extends mfBaseController { * Custom checks */ - - if($termination->workflowitems[TT_WORKFLOW_ITEM_LINEWORK_DONE]->value_int) { - $required_fields = ["baugruppe","modul","ports","abschlusstyp","bb_kabel","bb_fasern","kundenkabel_typ","kundenkabel_fasern","backbone_finished","inhouse_cabling_supplied","inhouse_cabling_deployed","bep_deployed","customer_cable_injected","spliced_network","spliced_customer"]; + $required_fields = ["baugruppe","modul","ports","abschlusstyp","bb_kabel","bb_fasern","kundenkabel_typ","kundenkabel_fasern","backbone_finished","bep_deployed","customer_cable_injected","spliced_network","spliced_customer"]; + //,"inhouse_cabling_supplied","inhouse_cabling_deployed" + + if($termination->workflowitems['abschlusstyp']->value->value_string != "SC/APC in FTU" && $termination->workflowitems['ist_abschlusstyp']->value->value_string != "SC/APC in FTU") { + $required_fields[] = "inhouse_cabling_supplied"; + $required_fields[] = "inhouse_cabling_deployed"; + } + $can_finish = true; foreach($required_fields as $f) { $type = $termination->workflowitems[$f]->type; @@ -262,12 +267,64 @@ class LineworkController extends mfBaseController { } if(!$can_finish) { - $this->log->info("Resetting customer_passive_finished because of missing"); + $this->log->info("Resetting customer_passive_finished because of missing values"); $termination->workflowitems[TT_WORKFLOW_ITEM_LINEWORK_DONE]->value->value_int = 0; $termination->workflowitems[TT_WORKFLOW_ITEM_LINEWORK_DONE]->value->save(); } } + // set values for all terminations in this building + if($termination->workflowitems['bb_kabel']->value->value_string) { + $value = $termination->workflowitems['bb_kabel']->value->value_string; + foreach($termination->building->terminations as $t) { + $t->workflowitems['bb_kabel']->value->value_string = $value; + $t->workflowitems['bb_kabel']->value->save(); + } + } + if($termination->workflowitems['bb_kabel_steps']->value->value_string) { + $value = $termination->workflowitems['bb_kabel_steps']->value->value_string; + foreach($termination->building->terminations as $t) { + $t->workflowitems['bb_kabel_steps']->value->value_string = $value; + $t->workflowitems['bb_kabel_steps']->value->save(); + } + } + if($termination->workflowitems['kundenkabel_typ']->value->value_string) { + $value = $termination->workflowitems['kundenkabel_typ']->value->value_string; + foreach($termination->building->terminations as $t) { + $t->workflowitems['kundenkabel_typ']->value->value_string = $value; + $t->workflowitems['kundenkabel_typ']->value->save(); + } + } + + $value = $termination->workflowitems['customer_cable_injected']->value->value_int; + foreach($termination->building->terminations as $t) { + $t->workflowitems['customer_cable_injected']->value->value_int = $value; + $t->workflowitems['customer_cable_injected']->value->save(); + } + + if($termination->workflowitems['ist_bb_kabel']->value->value_string) { + $value = $termination->workflowitems['ist_bb_kabel']->value->value_string; + foreach($termination->building->terminations as $t) { + $t->workflowitems['ist_bb_kabel']->value->value_string = $value; + $t->workflowitems['ist_bb_kabel']->value->save(); + } + } + if($termination->workflowitems['ist_bb_kabel_steps']->value->value_string) { + $value = $termination->workflowitems['ist_bb_kabel_steps']->value->value_string; + foreach($termination->building->terminations as $t) { + $t->workflowitems['ist_bb_kabel_steps']->value->value_string = $value; + $t->workflowitems['ist_bb_kabel_steps']->value->save(); + } + } + if($termination->workflowitems['ist_kundenkabel_typ']->value->value_string) { + $value = $termination->workflowitems['ist_kundenkabel_typ']->value->value_string; + foreach($termination->building->terminations as $t) { + $t->workflowitems['ist_kundenkabel_typ']->value->value_string = $value; + $t->workflowitems['ist_kundenkabel_typ']->value->save(); + } + } + + // file upload //var_dump($_FILES);exit; if(array_key_exists("LineworkFileUpload", $_FILES) && !$_FILES['LineworkFileUpload']['error']) { diff --git a/application/Workflowvalue/WorkflowvalueModel.php b/application/Workflowvalue/WorkflowvalueModel.php index de8c1c009..2f4ddb374 100644 --- a/application/Workflowvalue/WorkflowvalueModel.php +++ b/application/Workflowvalue/WorkflowvalueModel.php @@ -27,6 +27,13 @@ class WorkflowvalueModel { $me = new User(); $me->loadMe(); + if($model->changed === null) { + $model->changed = date('U'); + } + if($model->changed_by === null) { + $model->changed_by = $me->id; + } + if($model->create_by === null) { $model->create_by = $me->id; }