Files
thetool/Layout/default/Linework/Index.php
2022-06-15 13:37:06 +02:00

672 lines
36 KiB
PHP

<?php
$pagination_baseurl = $this->getUrl($Mod,"Index");
$pagination_baseurl_params = ["filter" => $filter];
$pagination_entity_name = "Leitungsbauaufträge";
?>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
<?php $wftype = "term"; ?>
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
<li class="breadcrumb-item active">Leitungsbau</li>
</ol>
</div>
<h4 class="page-title">Leitungsbau</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body mb-3">
<h4 class="header-title mb-3">Filter</h4>
<form method="get" action="<?=self::getUrl("Linework")?>">
<div class="row">
<div class="col-1">
<label class="form-label" for="filter_network_id">Netzgebiet</label>
<select name="filter[network_id]" id="filter_network_id" class="form-control">
<option></option>
<?php foreach($mynetworks as $fnet): ?>
<option value="<?=$fnet->id?>" <?=($filter['network_id'] == $fnet->id) ? "selected='selected'" : ""?>><?=$fnet->name?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-1">
<label class="form-label" for="filter_networksection_id">Bauabschnitt</label>
<select name="filter[networksection_id]" id="filter_networksection_id" class="form-control">
<option></option>
<?php foreach($mynetworks as $fnet): ?>
<?php if(is_array($fnet->sections) && count($fnet->sections)): ?>
<optgroup label="<?=$fnet->name?>">
<?php foreach($fnet->sections as $section): ?>
<option value="<?=$section->id?>" <?=($filter['networksection_id'] == $section->id) ? "selected='selected'" : ""?>><?=$section->name?></option>
<?php endforeach; ?>
</optgroup>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
<div class="col-2">
<label class="form-label" for="filter_status_id">Anschlussstatus</label>
<select name="filter[status_id]" id="filter_status_id" class="form-control">
<option></option>
<?php foreach(TerminationstatusModel::getAll() as $status): ?>
<option
value="<?=$status->id?>"
<?php if(is_array($filter)): ?>
<?=($filter['status_id'] == $status->id) ? "selected='selected'" : ""?>
<?php else: ?>
<?=(!array_key_exists("status_id", $filter) && $status->id == 3) ? "selected='selected'" : ""?>
<?php endif; ?>
>
<?=$status->code?> - <?=__($status->name."-t")?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-2">
<label class="form-label" for="filter_linework_doku_delay">Dokuaufschub</label>
<select name="filter[linework_doku_delay]" id="filter_linework_doku_delay" class="form-control">
<option value="0">Ausblenden</option>
<option value="1" <?=($filter['linework_doku_delay'] == 1) ? "selected='selected'" : ""?>>Anzeigen</option>
</select>
</div>
<div class="col-1">
<label class="form-label" for="filter_code">Objekt ID</label>
<input type="text" class="form-control" name="filter[code]" id="filter_code" value="<?=$filter['code']?>" />
</div>
<div class="col-2">
<label class="form-label" for="filter_building_street">Straße</label>
<input type="text" class="form-control" name="filter[building_street]" id="filter_building_street" value="<?=$filter['building_street']?>" />
</div>
</div>
<div class="row mt-2">
<div class="col">
<button type="submit" class="btn btn-primary">Filter anwenden</button>
<a class="btn btn-secondary" href="<?=self::getUrl("Linework")?>">Filter zurücksetzen</a>
<?php if($me->isAdmin()): ?>
<button type="submit" name="export" value="1" class="btn btn-outline-success ml-2"><i class="fas fa-download mr-1"></i> Download als .xls</button>
<?php endif; ?>
</div>
</div>
</form>
</div>
</div>
<div class="card">
<div class="card-body mb-3">
<h4 class="header-title">Auftragsliste nach Netzgebiet</h4>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
<?php if(is_array($networks) && count($networks)): ?>
<?php foreach($networks as $networkname => $terminations): ?>
<?php if(!count($terminations)) continue; ?>
<h4><?=$networkname?></h4>
<table class="table workflow-table mb-2">
<tr>
<th>Anschluss</th>
<th>Tiefbau</th>
<th>Patch-/Kabeldaten</th>
<th>Backbone</th>
<th>BEP</th>
<th>Kundenkabel</th>
<th>Spleiß Netz</th>
<th>Spleiß Kunde</th>
<th>FTU</th>
<th>FTU verlegt</th>
<th>Fertig</th>
</tr>
<?php $bcount = 0;
foreach($terminations as $term): ?>
<?php if($bcount > 0): ?>
<tr id="termination-<?=$term->id?>-top-header" class="hidden">
<th>Anschluss</th>
<th>Tiefbau</th>
<th>Patch-/Kabeldaten</th>
<th>Backbone</th>
<th>BEP</th>
<th>Kundenkabel</th>
<th>Spleiß Netz</th>
<th>Spleiß Kunde</th>
<th>FTU</th>
<th>FTU verlegt</th>
<th>Fertig</th>
</tr>
<?php endif ?>
<tr id="termination-<?=$term->id?>-summary" class="pointer table-bg-<?=($bcount % 2 == 0) ? "even" : "odd"?>">
<td onclick="togglePipework(<?=$term->id?>)">
<div class="name">
<?php if($term->building->gps_lat && $term->building->gps_long): ?>
<a href="https://maps.google.com/maps?t=k&q=loc:<?=$term->building->gps_lat?>+<?=$term->building->gps_long?>" target="_blank">
<i class='fas fa-globe-europe'></i> <strong style="white-space: nowrap;"><?=$term->building->street?></strong>
</a>
<?php else: ?>
<strong style="white-space: nowrap;"><?=$term->building->street?></strong>
<?php endif; ?>
<br />
<span class="text-monospace">[<?=__($term->building->status->name."-b")?>]</span>
<br />
<a href="<?=self::getUrl("Pipework", "Index", ["filter" => ["code" => $term->building->code]])?>" target="_blank"><span class="text-success"><?=$term->code?></span></a>
</div>
<div class="up-arrow hidden">
<i class="fas fa-angle-up"></i>
</div>
</td>
<td onclick="togglePipework(<?=$term->id?>)"><?=(empty($term->building->getWorkflowvalue('pipework_finished'))) ? "<i class='fas fa-times text-danger'></i>" : "<i class='fas fa-check text-success'></i>"?></td>
<td onclick="togglePipework(<?=$term->id?>)"><?=($term->isWorkflowPatchingDone()) ? "<i class='fas fa-check text-success'></i>" : "<i class='fas fa-times text-danger'></i>" ?></td>
<td onclick="togglePipework(<?=$term->id?>)"><?=($term->getWorkflowvalue('backbone_finished') != "1") ? "<i class='fas fa-times text-danger'></i>" : "<i class='fas fa-check text-success'></i>" ?></td>
<td onclick="togglePipework(<?=$term->id?>)"><?=($term->getWorkflowvalue('bep_deployed') != "1") ? "<i class='fas fa-times text-danger'></i>" : "<i class='fas fa-check text-success'></i>" ?></td>
<td onclick="togglePipework(<?=$term->id?>)"><?=($term->getWorkflowvalue('customer_cable_injected') != "1") ? "<i class='fas fa-times text-danger'></i>" : "<i class='fas fa-check text-success'></i>" ?></td>
<td onclick="togglePipework(<?=$term->id?>)"><?=($term->getWorkflowvalue('spliced_network') != "1") ? "<i class='fas fa-times text-danger'></i>" : "<i class='fas fa-check text-success'></i>" ?></td>
<td onclick="togglePipework(<?=$term->id?>)"><?=($term->getWorkflowvalue('spliced_customer') != "1") ? "<i class='fas fa-times text-danger'></i>" : "<i class='fas fa-check text-success'></i>" ?></td>
<td onclick="togglePipework(<?=$term->id?>)">
<?php if(($term->getWorkflowvalue('abschlusstyp') == "SC/APC in FTU" && empty($term->getWorkflowvalue('ist_abschlusstyp'))) || $term->getWorkflowvalue('ist_abschlusstyp') == "SC/APC in FTU"): ?>
<?=($term->getWorkflowvalue('inhouse_cabling_supplied') != "1") ? "<i class='fas fa-times text-danger'></i>" : "<i class='fas fa-check text-success'></i>" ?>
<?php endif; ?>
</td>
<td onclick="togglePipework(<?=$term->id?>)">
<?php if(($term->getWorkflowvalue('abschlusstyp') == "SC/APC in FTU" && empty($term->getWorkflowvalue('ist_abschlusstyp'))) || $term->getWorkflowvalue('ist_abschlusstyp') == "SC/APC in FTU"): ?>
<?=($term->getWorkflowvalue('inhouse_cabling_deployed') != "1") ? "<i class='fas fa-times text-danger'></i>" : "<i class='fas fa-check text-success'></i>" ?>
<?php endif; ?>
</td>
<td onclick="togglePipework(<?=$term->id?>)"><?=($term->getWorkflowvalue('customer_passive_finished') != "1") ? "<i class='fas fa-times text-danger'></i>" : "<i class='fas fa-check text-success'></i>" ?></td>
</tr>
<tr id="termination-<?=$term->id?>" class="table-bg-<?=($bcount % 2 == 0) ? "even" : "odd"?> hidden">
<td>
<div>
<div>
<?php if($term->building->gps_lat && $term->building->gps_long): ?>
<a href="https://maps.google.com/maps?t=k&q=loc:<?=$term->building->gps_lat?>+<?=$term->building->gps_long?>" target="_blank">
<i class='fas fa-globe-europe'></i> <strong style="white-space: nowrap;"><?=$term->building->street?></strong>
</a>
<?php else: ?>
<strong style="white-space: nowrap;"><?=$term->building->street?></strong>
<?php endif; ?>
<br />
<span class="text-monospace">[<?=__($term->building->status->name."-b")?>]</span>
</div>
<div class="mt-2 mb-2">
<a href="<?=self::getUrl("Pipework", "Index", ["filter" => ["code" => $term->building->code]])?>" target="_blank"><span class="text-success"><?=$term->code?></span></a>
<br />
<?php if($term->name): ?>
<?=$term->name?><br />
<?php endif; ?>
</div>
<?php if($term->building->network_id):?>
<div style="hyphens: auto;">
<strong>Netzgebiet</strong>: <?=$term->building->network->name?>
</div>
<?php endif;?>
<?php if($term->building->networksection_id): ?>
<div>
<strong>Bauabschnitt</strong>: <?=$term->building->networksection->name?>
</div>
<?php endif; ?>
</div>
<div class="mt-3">
<?=$term->contact?><br />
<strong><?=$term->phone?></strong><br />
<?=$term->email?>
</div>
<?php if($me->is("Admin", "netowner")): ?>
<div class="mt-3">
<label <?=(!$term->building->lineworker_id) ? "class='text-danger' title='Keine Leitungsbaufirma ausgewählt'" : ""?>>
<input type="checkbox" form="wf-termination-<?=$term->id?>" name="linework_doku_delay" value="1"
<?=($term->linework_doku_delay == 1) ? "checked='checked'" : ""?>
>
Doku-Aufschub
</label>
</div>
<?php endif; ?>
<div class="mt-3">
<label <?=(!$term->building->lineworker_id) ? "class='text-danger' title='Keine Leitungsbaufirma ausgewählt'" : ""?>>
<input type="checkbox" form="wf-termination-<?=$term->id?>" name="linework_enabled" value="1"
<?=($term->linework_enabled == 1) ? "checked='checked'" : ""?> <?=(!$term->building->lineworker_id || !$me->is(["Admin", "pipeplanner", "lineplanner"])) ? "disabled='disabled'" : ""?>
>
Baufreigabe
</label>
<?php if($term->linework_enabled): ?>
<div style="overflow-x:hidden">
<small class="text-info text-mono"
title="Freigegeben: <?=date("d.m.Y H:i",$term->linework_enabled_date)?> von <?=$term->linework_enabler->name?> (<?=$term->linework_enabler->address->getCompanyOrName(true)?>)"
><?=$term->linework_enabler->getAbbrName()?></small>
</div>
<?php endif; ?>
</div>
<div class="mt-3">
<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>
</td>
<td colspan="10">
<table class="table workflow-table table-bordered table-sm table-bg-<?=($bcount % 2 == 0) ? "odd" : "even"?>">
<tr>
<th>AP-Typ</th>
<th>AP-Name</th>
<th>AP-Koordinaten</th>
<th>Rohrverband</th>
<th>Rohrtyp</th>
<th>Rohrfarbe</th>
</tr>
<tr>
<td><?=($term->building->getWorkflowvalue("ist_anschlusspunkt_typ")) ? $term->building->getWorkflowvalue("ist_anschlusspunkt_typ") : $term->building->getWorkflowvalue("anschlusspunkt_typ")?></td>
<td><?=($term->building->getWorkflowvalue('ist_anschlusspunkt_name')) ? $term->building->getWorkflowvalue('ist_anschlusspunkt_name') : $term->building->getWorkflowvalue('anschlusspunkt_name')?></td>
<td>
<?php if($term->building->getWorkflowvalue('ist_anschlusspunkt_gps')): ?>
<a href='https://maps.google.com/maps?t=k&q=loc:<?=join("+", $term->building->workflowitems['ist_anschlusspunkt_gps']->value->gps)?>' target='_blank'><i class='fas fa-external-link-alt'></i> <?=join(", ", $term->building->workflowitems['ist_anschlusspunkt_gps']->value->gps)?></a></td>
<?php elseif($term->building->getWorkflowvalue('anschlusspunkt_gps')): ?>
<a href='https://maps.google.com/maps?t=k&q=loc:<?=join("+", $term->building->workflowitems['anschlusspunkt_gps']->value->gps)?>' target='_blank'><i class='fas fa-external-link-alt'></i> <?=join(", ", $term->building->workflowitems['anschlusspunkt_gps']->value->gps)?></a></td>
<?php endif; ?>
<td><?=($term->building->getWorkflowvalue('ist_rohrverband_name')) ? $term->building->getWorkflowvalue('ist_rohrverband_name') : $term->building->getWorkflowvalue('rohrverband_name')?></td>
<td><?=($term->building->getWorkflowvalue('ist_rohrtype')) ? $term->building->getWorkflowvalue('ist_rohrtype') : $term->building->getWorkflowvalue('rohrtype')?></td>
<td>
<?php if($term->building->getWorkflowvalue('ist_rohrfarbe')): ?>
<span
style="
background-color: #<?=TT_CABLE_COLORS[$term->building->getWorkflowvalue('ist_rohrfarbe')]["hex"]?>;
<?php if(TT_CABLE_COLORS[$term->building->getWorkflowvalue('ist_rohrfarbe')]["mark"]): ?>
color: #<?=TT_CABLE_COLORS[$term->building->getWorkflowvalue('ist_rohrfarbe')]["hexfg"]?>;
<?php else: ?>
color: #<?=TT_CABLE_COLORS[$term->building->getWorkflowvalue('ist_rohrfarbe')]["hex"]?>;
<?php endif; ?>
border-radius: 3px;
">-------</span> <?=ucfirst($term->building->getWorkflowvalue('ist_rohrfarbe'))?>
<?php elseif($term->building->getWorkflowvalue('rohrfarbe')): ?>
<span
style="
background-color: #<?=TT_CABLE_COLORS[$term->building->getWorkflowvalue('rohrfarbe')]["hex"]?>;
<?php if(TT_CABLE_COLORS[$term->building->getWorkflowvalue('rohrfarbe')]["mark"]): ?>
color: #<?=TT_CABLE_COLORS[$term->building->getWorkflowvalue('rohrfarbe')]["hexfg"]?>;
<?php else: ?>
color: #<?=TT_CABLE_COLORS[$term->building->getWorkflowvalue('rohrfarbe')]["hex"]?>;
<?php endif; ?>
border-radius: 3px;
">-------</span> <?=ucfirst($term->building->getWorkflowvalue('rohrfarbe'))?>
<?php endif; ?>
</td>
</tr>
</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">
<input type="hidden" name="id" value="<?=$term->id?>" />
<table class="table workflow-table">
<?php $i = 0; foreach($term->workflowitems as $item): ?>
<?php if($i==0): ?>
<?php if($item->type == "delimiter"): ?>
<tr class="workflow-header"><th colspan='<?=$wfColspan?>'><?=$item->label?></th></tr><tr>
<?php else: ?>
<tr>
<?php endif; ?>
<?php else: ?>
<?php if($item->type == "delimiter"): ?>
</tr><tr class="workflow-header"><th colspan='<?=$wfColspan?>'><?=$item->label?></th></tr><tr>
<?php else: ?>
<?php include(realpath(dirname(__FILE__)."/../")."/Workflow/form.php"); ?>
<?php if(!$me->is("Admin") && $item->required == 1 && $term->workflowitems['customer_passive_finished']->value->id && $term->workflowitems['customer_passive_finished']->value->value_int == 1): ?>
<script type="text/javascript">
<?php if($item->type == "bool"): ?>
document.getElementById("wfitemplaceholder_<?=$item->name?>_<?=$term->id?>").disabled = true;
<?php elseif($item->type != "empty"): ?>
document.getElementById("wfitem_<?=$item->name?>_<?=$term->id?>").disabled = true;
<?php endif; ?>
</script>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
<?php $i++; endforeach; ?>
<?php if(!$me->is("Admin")): ?>
<script type="text/javascript">
document.getElementById("wfitem_backbone_setup_date_<?=$$wftype->id?>").disabled = true;
document.getElementById("wfitem_customer_setup_date_<?=$$wftype->id?>").disabled = true;
</script>
<?php endif; ?>
</tr>
<tr>
<td colspan="3">
<label class="form-label" for="workflow_comment_building_<?=$term->id?>">Kommentar Tiefbau (<?=$term->building->street?>)</label>
<textarea class="form-control" style="height:100%" form="wf-termination-<?=$term->id?>" name="workflow_comment_building" id="workflow_comment_building_<?=$term->id?>"><?=$term->building->workflow_comment?></textarea>
</td>
<td colspan="3">
<label class="form-label" for="workflow_comment_<?=$term->id?>">Kommentar Anschluss (<?=$term->code?>)</label>
<textarea class="form-control" style="height:100%" form="wf-termination-<?=$term->id?>" name="workflow_comment" id="workflow_comment_<?=$term->id?>"><?=$term->workflow_comment?></textarea>
</td>
<td colspan="<?=$wfColspan - 3?>">
<h5>Dokumente</h5>
<table class="table table-sm">
<?php if(is_array($term->files) && count($term->files)): $i=0; foreach($term->files as $file): ?>
<?php if($i % 2 == 0): ?>
<tr>
<td title="<?=$file->file->filename?>">
<a href="<?=self::getUrl("TerminationFile", "delete", ['id' => $file->id, "from" => "linework"])?>" onclick="if(!confirm('Dokument wirklich löschen?')) return false;" class="text-danger mr-1" title="Dokument löschen">
<i class="fas fa-trash"></i>
</a>
<a href="<?=self::getUrl("File", "Download", ['id' => $file->file->id])?>">
<i class="fas fa-download"></i> <?=$file->type?>
</a>
</td>
<?php else: ?>
<td title="<?=$file->file->filename?>">
<a href="<?=self::getUrl("TerminationFile", "delete", ['id' => $file->id, "from" => "linework"])?>" onclick="if(!confirm('Dokument wirklich löschen?')) return false;" class="text-danger mr-1" title="Dokument löschen">
<i class="fas fa-trash"></i>
</a>
<a href="<?=self::getUrl("File", "Download", ['id' => $file->file->id])?>">
<i class="fas fa-download"></i> <?=$file->type?>
</a>
</td>
</tr>
<?php endif; ?>
<?php $i++; endforeach; ?>
<?php if($i % 2 != 0): ?>
<td></td></tr>
<?php endif; ?>
<?php endif; ?>
<tr>
<td>
<strong>Dokument hochladen</strong> <select class="form-control" name="file_type">
<?php foreach(TT_WORKFLOW_TERMINATION_FILE_TYPES as $type): ?>
<option value="<?=$type?>"><?=$type?></option>
<?php endforeach; ?>
</select>
</td>
<td>
<small>Erlaubte Dateiendungen: <?=MFUPLOAD_ALLOWED_EXTENSIONS_STR?></small>
<input type="file" name="LineworkFileUpload" class="form-control-file" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</td>
</tr>
<?php if($bcount < count($terminations) - 1): ?>
<tr id="termination-<?=$term->id?>-bottom-header" class="hidden">
<th>Anschluss</th>
<th>Tiefbau</th>
<th>Patch-/Kabeldaten</th>
<th>Backbone</th>
<th>BEP</th>
<th>Kundenkabel</th>
<th>Spleiß Netz</th>
<th>Spleiß Kunde</th>
<th>FTU</th>
<th>FTU verlegt</th>
<th>Fertig</th>
</tr>
<?php endif; ?>
<?php $bcount++; endforeach; ?>
</table>
<?php endforeach; ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
<?php else: ?>
<i>Keine Bauaufträge gefunden</i>
<?php endif; ?>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
var term;
var hash = window.location.hash.substr(1);
var match = hash.match(/object=(\d+)/);
if(match && match[1]) {
term = match[1]
togglePipework(term);
var pos = $('#termination-' + term + "-summary").offset().top;
$(window).scrollTop(pos - 182);
}
$('input[name=wfitemplaceholder_customer_passive_finished]').each(function() {
var elem = this;
$(elem).click(function() {
var id_match = $(this).attr("id").match(/wfitemplaceholder_customer_passive_finished_(\d+)$/);
var id = id_match[1];
validateWorkflowItem(id);
});
});
$('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($('#wfitem_ist_abschlusstyp_' + id).val() == "") {
if($(this).val() == "SC/APC in FTU") {
$('#workflow-item-inhouse_cabling_supplied-' + id + ' .wf-content').show();
$('#workflow-item-inhouse_cabling_deployed-' + id + ' .wf-content').show();
} else {
$('#workflow-item-inhouse_cabling_supplied-' + id + ' .wf-content').hide();
$('#workflow-item-inhouse_cabling_deployed-' + id + ' .wf-content').hide();
}
} else {
console.log("ist not empty");
if($('#wfitem_ist_abschlusstyp_' + id).val() == "SC/APC in FTU") {
$('#workflow-item-inhouse_cabling_supplied-' + id + ' .wf-content').show();
$('#workflow-item-inhouse_cabling_deployed-' + id + ' .wf-content').show();
} else {
$('#workflow-item-inhouse_cabling_supplied-' + id + ' .wf-content').hide();
$('#workflow-item-inhouse_cabling_deployed-' + id + ' .wf-content').hide();
}
}
/*
if($('#wfitem_ist_abschlusstyp_' + id).val().length && $('#wfitem_ist_abschlusstyp_' + id).val() != "SC/APC in FTU") {
$('#workflow-item-inhouse_cabling_supplied-' + id + ' .wf-content').hide();
$('#workflow-item-inhouse_cabling_deployed-' + id + ' .wf-content').hide();
} else {
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() == "") {
console.log("ist empty");
if($('#wfitem_abschlusstyp_' + id).val() == "SC/APC in FTU") {
$('#workflow-item-inhouse_cabling_supplied-' + id + ' .wf-content').show();
$('#workflow-item-inhouse_cabling_deployed-' + id + ' .wf-content').show();
} else {
$('#workflow-item-inhouse_cabling_supplied-' + id + ' .wf-content').hide();
$('#workflow-item-inhouse_cabling_deployed-' + id + ' .wf-content').hide();
}
} else {
console.log("ist not empty");
if($('#wfitem_ist_abschlusstyp_' + id).val() == "SC/APC in FTU") {
$('#workflow-item-inhouse_cabling_supplied-' + id + ' .wf-content').show();
$('#workflow-item-inhouse_cabling_deployed-' + id + ' .wf-content').show();
} else {
$('#workflow-item-inhouse_cabling_supplied-' + id + ' .wf-content').hide();
$('#workflow-item-inhouse_cabling_deployed-' + id + ' .wf-content').hide();
}
}
});
if($(elem).val() == "SC/APC in FTU") {
$(elem).change();
}
//$(elem).change();
});
$('form[id^="wf-termination-"]').each(function() {
var elem = this;
$(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;
}
});
});
});
function togglePipework(id) {
$("#termination-" + id).toggle(200);
$("#termination-" + id + "-summary td .name").toggle();
$("#termination-" + id + "-summary td .up-arrow").toggle();
$("#termination-" + id + "-bottom-header").toggle();
$("#termination-" + id + "-top-header").toggle();
}
function validateWorkflowItem(id) {
var 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",
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_ist_abschlusstyp_" + id).val() == "SC/APC in FTU") {
required_fields["inhouse_cabling_supplied"] = "bool";
required_fields["inhouse_cabling_deployed"] = "bool";
} else if($("#wfitem_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) {
var field2 = "ist_" + field1;
var type = required_fields[field1];
var val1 = $("#wfitem_" + field1 + "_" + id).val();
var val2 = true;
if($("#wfitem_" + field2 + "_" + id).length) {
var val2 = $("#wfitem_" + field2 + "_" + id).val();
}
if(type == "bool") {
if(!parseInt(val1)) {
console.log(field1 + " missing");
missing = true;
}
} else {
if(!val1 && !val2) {
console.log(field1 + " or " + field2 + " missing");
missing = true;
}
}
}
console.log("missing: ");
console.log(missing);
if(missing) {
$("#wfitemplaceholder_customer_passive_finished_" + id).prop('checked', false);
$("#wfitem_customer_passive_finished_" + id).val(0);
$("#wfitemplaceholder_customer_passive_finished_" + id).attr("readonly", true);
} else {
$("#wfitemplaceholder_customer_passive_finished_" + id).attr("disabled", false);
$("#wfitem_customer_passive_finished_" + id).val(1);
$("#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>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>