removing passive finish when required field is empty
This commit is contained in:
@@ -175,7 +175,10 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-3">
|
<div class="mt-3">
|
||||||
<button type="button" class="btn btn-primary" form="wf-termination-<?=$term->id?>" onclick="document.getElementById(this.getAttribute('form')).submit()">Speichern</button>
|
<button type="button" class="btn btn-primary" form="wf-termination-<?=$term->id?>" onclick="validateAndSubmit(<?=$term->id?>)">Speichern</button>
|
||||||
|
</div>
|
||||||
|
<div class="text-danger hidden mt-2" id="wf-submit-error-<?=$term->id?>">
|
||||||
|
Nicht fertiggestellt.
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -208,7 +211,7 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<form method="post" name="wf-termination-<?=$term->id?>" id="wf-termination-<?=$term->id?>" action="<?=self::getUrl("Linework","save", ["filter" => $filter, "s" => $pagination['start']])?>" enctype="multipart/form-data" >
|
<form method="post" name="wf-termination-<?=$term->id?>" id="wf-termination-<?=$term->id?>" action="<?=self::getUrl("Linework","save", ["filter" => $filter, "s" => $pagination['start']])?>" enctype="multipart/form-data">
|
||||||
<input type="hidden" name="id" value="<?=$term->id?>" />
|
<input type="hidden" name="id" value="<?=$term->id?>" />
|
||||||
<table class="table workflow-table">
|
<table class="table workflow-table">
|
||||||
<?php $i = 0; foreach($term->workflowitems as $item): ?>
|
<?php $i = 0; foreach($term->workflowitems as $item): ?>
|
||||||
@@ -339,17 +342,43 @@ $(document).ready(function() {
|
|||||||
var pos = $('#termination-' + term).offset().top;
|
var pos = $('#termination-' + term).offset().top;
|
||||||
$(window).scrollTop(pos - 150 );
|
$(window).scrollTop(pos - 150 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('input[name=wfitemplaceholder_customer_passive_finished]').each(function() {
|
||||||
|
var elem = this;
|
||||||
|
//console.log(elem);
|
||||||
|
$(elem).click(function() {
|
||||||
|
var id_match = $(this).attr("id").match(/wfitemplaceholder_customer_passive_finished_(\d+)$/);
|
||||||
|
var id = id_match[1];
|
||||||
|
//console.log(id);
|
||||||
|
|
||||||
|
validateWorkflowItem(id);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$('form[id^="wf-termination-"]').each(function() {
|
||||||
|
var elem = this;
|
||||||
|
console.log(elem);
|
||||||
|
$(elem).submit(function(e) {
|
||||||
|
|
||||||
|
console.log(this);
|
||||||
|
var id_match = $(this).attr("name").match(/wf-termination-(\d+)$/);
|
||||||
|
var id = id_match[1];
|
||||||
|
if(canSubmit(id)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('input[name=wfitemplaceholder_customer_passive_finished]').each(function() {
|
|
||||||
var elem = this;
|
function validateWorkflowItem(id) {
|
||||||
//console.log(elem);
|
var required_fields = {
|
||||||
$(elem).click(function() {
|
|
||||||
var id_match = $(this).attr("id").match(/wfitemplaceholder_customer_passive_finished_(\d+)$/);
|
|
||||||
var id = id_match[1];
|
|
||||||
//console.log(id);
|
|
||||||
|
|
||||||
required_fields = {
|
|
||||||
pop_id: "int",
|
pop_id: "int",
|
||||||
schrank: "string",
|
schrank: "string",
|
||||||
baugruppe: "string",
|
baugruppe: "string",
|
||||||
@@ -372,14 +401,13 @@ $('input[name=wfitemplaceholder_customer_passive_finished]').each(function() {
|
|||||||
|
|
||||||
var missing = false;
|
var missing = false;
|
||||||
for(var field1 in required_fields) {
|
for(var field1 in required_fields) {
|
||||||
field2 = "ist_" + field1;
|
var field2 = "ist_" + field1;
|
||||||
type = required_fields[field1];
|
var type = required_fields[field1];
|
||||||
|
|
||||||
var val1 = $("#wfitem_" + field1 + "_" + id).val();
|
var val1 = $("#wfitem_" + field1 + "_" + id).val();
|
||||||
|
var val2 = true;
|
||||||
if($("#wfitem_" + field2 + "_" + id).length) {
|
if($("#wfitem_" + field2 + "_" + id).length) {
|
||||||
var val2 = $("#wfitem_" + field2 + "_" + id).val();
|
var val2 = $("#wfitem_" + field2 + "_" + id).val();
|
||||||
} else {
|
|
||||||
val2 = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == "bool") {
|
if(type == "bool") {
|
||||||
@@ -400,15 +428,41 @@ $('input[name=wfitemplaceholder_customer_passive_finished]').each(function() {
|
|||||||
|
|
||||||
if(missing) {
|
if(missing) {
|
||||||
$("#wfitemplaceholder_customer_passive_finished_" + id).prop('checked', false);
|
$("#wfitemplaceholder_customer_passive_finished_" + id).prop('checked', false);
|
||||||
|
$("#wfitem_customer_passive_finished_" + id).val(0);
|
||||||
$("#wfitemplaceholder_customer_passive_finished_" + id).attr("readonly", true);
|
$("#wfitemplaceholder_customer_passive_finished_" + id).attr("readonly", true);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$("#wfitemplaceholder_customer_passive_finished_" + id).attr("disabled", false);
|
$("#wfitemplaceholder_customer_passive_finished_" + id).attr("disabled", false);
|
||||||
|
$("#wfitem_customer_passive_finished_" + id).val(1);
|
||||||
$("#wfitemplaceholder_customer_passive_finished_" + id).prop('readonly', true);
|
$("#wfitemplaceholder_customer_passive_finished_" + id).prop('readonly', true);
|
||||||
|
$("#wf-submit-error-" + id).hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return !missing;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
function canSubmit(id) {
|
||||||
|
if($("#wfitemplaceholder_customer_passive_finished_" + id).prop('checked')) {
|
||||||
|
if(!validateWorkflowItem(id)) {
|
||||||
|
console.log("cant submit");
|
||||||
|
$("#wf-submit-error-" + id).show();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log("can submit");
|
||||||
|
$("#wf-submit-error-" + id).hide();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateAndSubmit(id) {
|
||||||
|
//e.preventDefault();
|
||||||
|
if(canSubmit(id)) {
|
||||||
|
$('#wf-termination-' + id).trigger("submit");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -72,15 +72,19 @@ class Workflowvalue extends mfBaseModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*if($this->item->name == "customer_passive_finished") {
|
||||||
|
var_dump($value, $this->{"value_".$value_type});exit;
|
||||||
|
}*/
|
||||||
|
|
||||||
if($value === null) {
|
if($value === null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($value_type == "int" && !$value) {
|
if($value_type == "int" && $this->{"value_".$value_type} == null && !$value) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->item->type == "bool" && $this->{"value_".$value_type} = null && $value == 0) {
|
if($this->item->type == "bool" && $this->{"value_".$value_type} == null && $value == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user