add Patching::Save
This commit is contained in:
@@ -19,7 +19,54 @@
|
||||
<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("Patching")?>">
|
||||
<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_patched">Patchstatus</label>
|
||||
<select name="filter[patched]" id="filter_patched" class="form-control">
|
||||
<option value="0" <?=($filter['patched'] != 0) ? "selected='selected'" : ""?>>Nicht gepatched</option>
|
||||
<option value="1" <?=($filter['patched'] == 1) ? "selected='selected'" : ""?>>Gepatched</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_street">Straße</label>
|
||||
<input type="text" class="form-control" name="filter[street]" id="filter_street" value="<?=$filter['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("Patching")?>">Filter zurücksetzen</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card">
|
||||
@@ -62,6 +109,7 @@
|
||||
<th colspan="4">Standort</th>
|
||||
<th colspan="2">ODF</th>
|
||||
<th colspan="4">Abschluss/Device</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<tr class="table-bordered">
|
||||
<th>Netzgebiet</th>
|
||||
@@ -74,12 +122,13 @@
|
||||
<th>Gerät</th>
|
||||
<th>Port</th>
|
||||
<th>Gepatched</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($terminations as $term): ?>
|
||||
<tr>
|
||||
<td><?=$term->building->network->name?></td>
|
||||
<td><?=$term->building->pop->name?></td>
|
||||
<td><?=$term->order->owner->customer_number?><br /> <?=$term->order->owner->getCompanyOrName()?></td>
|
||||
<td><?=($term->order->owner) ? $term->order->owner->customer_number : ""?><br /> <?=($term->order->owner) ? $term->order->owner->getCompanyOrName() : ""?></td>
|
||||
<td>
|
||||
<?=$term->building->street?><br />
|
||||
<?=$term->building->zip?> <?=$term->building->city?>
|
||||
@@ -91,25 +140,31 @@
|
||||
<?=$term->workflowitems["ports"]->value->value_string?>
|
||||
</td>
|
||||
<td>
|
||||
<select name="linework_port" class="form-control">
|
||||
<select name="linework_port" form="term-form-<?=$term->id?>" class="form-control">
|
||||
<?php foreach($term->getLineworkportPairs() as $ports): ?>
|
||||
<?php foreach($ports as $p): ?>
|
||||
<option value="<?=$p?>"><?=$p?></option>
|
||||
<option value="<?=$p?>" <?=($term->patching->linework_ports == $p) ? "selected='selected'" : ""?>><?=$p?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select name="device_type" class="form-control">
|
||||
<select name="device_type" form="term-form-<?=$term->id?>" class="form-control">
|
||||
<option></option>
|
||||
<option value="splitter">Splitter</option>
|
||||
<option value="pon">Shared PON-Port</option>
|
||||
<option value="switch">Switch</option>
|
||||
<option value="splitter" <?=($term->patching->device_type == "splitter") ? "selected='selected'" : ""?>>Splitter</option>
|
||||
<option value="pon" <?=($term->patching->device_type == "pon") ? "selected='selected'" : ""?>>Shared PON-Port</option>
|
||||
<option value="switch" <?=($term->patching->device_type == "switch") ? "selected='selected'" : ""?>>Switch</option>
|
||||
</select>
|
||||
</td>
|
||||
<td><input type="text" class="form-control" name="device_name" value="" placeholder="Gerät" /></td>
|
||||
<td><input type="text" class="form-control" name="device_port" value="" placeholder="Port" /></td>
|
||||
<td><input type="checkbox" class="form-control" name="patched" value="1" /></td>
|
||||
<td><input type="text" class="form-control" form="term-form-<?=$term->id?>" name="device_name" value="<?=$term->patching->device_name?>" placeholder="Gerät" /></td>
|
||||
<td><input type="text" class="form-control" form="term-form-<?=$term->id?>" name="device_port" value="<?=$term->patching->device_port?>" placeholder="Port" /></td>
|
||||
<td><input type="checkbox" class="form-control" form="term-form-<?=$term->id?>" name="patched" value="1" <?=($term->patching->patched == 1) ? "checked='checked'" : ""?> /></td>
|
||||
<td>
|
||||
<form method="post" id="term-form-<?=$term->id?>" action="<?=self::getUrl("Patching","save")?>">
|
||||
<input type="hidden" name="termination_id" value="<?=$term->id?>" />
|
||||
<input type="submit" class="btn btn-primary" value="Speichern" />
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
@@ -17,6 +17,78 @@ class PatchingController extends mfBaseController {
|
||||
protected function indexAction() {
|
||||
$this->layout()->setTemplate("Patching/Index");
|
||||
|
||||
$this->layout->set("filter", $this->request->filter);
|
||||
|
||||
$filter = $this->getPreparedFilter($this->request->filter);
|
||||
//var_dump($filter);exit;
|
||||
// pagination defaults
|
||||
$pagination = [];
|
||||
$pagination['start'] = 0;
|
||||
$pagination['count'] = 20;
|
||||
$pagination['maxItems'] = 0;
|
||||
|
||||
if(is_numeric($this->request->s)) {
|
||||
$pagination['start'] = intval($this->request->s);
|
||||
}
|
||||
|
||||
$my_networks = [];
|
||||
|
||||
if($this->me->is("Admin")) {
|
||||
if($filter['network_id']) {
|
||||
$my_networks[] = new Network($filter['network_id']);
|
||||
} else {
|
||||
$my_networks = NetworkModel::getAll();
|
||||
}
|
||||
$this->layout()->set("mynetworks", NetworkModel::getAll());
|
||||
} else {
|
||||
$use_filter_network = false;
|
||||
$my_networks = $this->me->my_networks;
|
||||
|
||||
foreach($my_networks as $mn) {
|
||||
if($mn->id == $filter['network_id']) {
|
||||
$use_filter_network = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if($use_filter_network) {
|
||||
$my_networks = [];
|
||||
$my_networks[] = new Network($filter['network_id']);
|
||||
}
|
||||
|
||||
$this->layout()->set("mynetworks", $this->me->my_networks);
|
||||
}
|
||||
unset($filter['network_id']);
|
||||
|
||||
// get Buildings in networks
|
||||
$my_network_ids = [];
|
||||
$terms = [];
|
||||
foreach($my_networks as $network) {
|
||||
$my_network_ids[] = $network->id;
|
||||
}
|
||||
|
||||
$terms_search = [
|
||||
"network_id" => $my_network_ids,
|
||||
];
|
||||
|
||||
if(is_array($filter) && count($filter)) {
|
||||
foreach($filter as $name => $value) {
|
||||
$terms_search[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$pagination['maxItems'] = PatchingModel::searchByTerminationCount($terms_search);
|
||||
foreach(PatchingModel::searchByTermination($terms_search, $pagination) as $t) {
|
||||
if(!array_key_exists($t->id, $terms)) {
|
||||
$terms[$t->id] = $t;
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($buildings);exit;
|
||||
$this->layout()->set("terminations", $terms);
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
//var_dump($pagination);exit;
|
||||
/*
|
||||
$terminations = PatchingModel::searchByTermination();
|
||||
$terms = [];
|
||||
foreach($terminations as $term) {
|
||||
@@ -25,10 +97,88 @@ class PatchingController extends mfBaseController {
|
||||
//var_dump($term);
|
||||
}
|
||||
//exit;
|
||||
|
||||
*/
|
||||
$this->layout()->set("terminations", $terms);
|
||||
|
||||
}
|
||||
|
||||
private function getPreparedFilter($filter) {
|
||||
$new_filter = [];
|
||||
//var_dump($filter);exit;
|
||||
if(array_key_exists("patched", $filter)) {
|
||||
if($filter["patched"] == "1") {
|
||||
$new_filter["patched"] = true;
|
||||
} else {
|
||||
$new_filter["patched"] = false;
|
||||
}
|
||||
} else {
|
||||
$new_filter["patched"] = false;
|
||||
}
|
||||
|
||||
foreach($filter as $name => $value) {
|
||||
$new_filter[$name] = $value;
|
||||
}
|
||||
|
||||
return $new_filter;
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
if(!$this->me->is(["Admin", "netowner", "netoperator", "lineworker"])) {
|
||||
$this->layout()->setFlash("Keine Berechtigung", "error");
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
|
||||
$r = $this->request;
|
||||
//var_dump($r);exit;
|
||||
|
||||
$term_id = $r->termination_id;
|
||||
//var_dump($r);exit;
|
||||
if(is_numeric($term_id) && $term_id > 0) {
|
||||
$mode = "edit";
|
||||
$termination = new Termination($term_id);
|
||||
if(!$termination->id) {
|
||||
$this->layout()->setFlash("Anschluss nicht gefunden", "error");
|
||||
$this->redirect("Patching");
|
||||
}
|
||||
} else {
|
||||
$this->layout()->setFlash("Anschluss nicht gefunden", "error");
|
||||
$this->redirect("Patching");
|
||||
}
|
||||
|
||||
$patch_data = [];
|
||||
|
||||
$patching = PatchingModel::getFirst(["termination_id" => $term_id]);
|
||||
if($patching) {
|
||||
$mode = "edit";
|
||||
} else {
|
||||
$mode = "add";
|
||||
$patch_data["termination_id"] = $term_id;
|
||||
}
|
||||
|
||||
|
||||
$patch_data["linework_port"] = $r->linework_port;
|
||||
$patch_data["device_type"] = $r->device_type;
|
||||
$patch_data["device_name"] = $r->device_name;
|
||||
$patch_data["device_port"] = $r->device_port;
|
||||
$patch_data["patched"] = ($r->patched == "1") ? 1 : 0;
|
||||
|
||||
if($mode == "add") {
|
||||
$patch_data['create_by'] = 1;
|
||||
$patching = PatchingModel::create($patch_data);
|
||||
} else {
|
||||
$patching->update($patch_data);
|
||||
}
|
||||
|
||||
$id = $patching->save();
|
||||
if(!$id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern", "error");
|
||||
return $this->indexAction();
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Patchung erfolgreich gespeichert.", "success");
|
||||
$this->redirect("Patching", "Index");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -83,6 +83,41 @@ class PatchingModel {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function searchByTerminationCount($filter = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
|
||||
$sql = "SELECT COUNT(Termination.id) as cnd FROM `Order`
|
||||
LEFT JOIN OrderProduct ON (OrderProduct.order_id = `Order`.id)
|
||||
LEFT JOIN Product ON (Product.id = OrderProduct.product_id)
|
||||
LEFT JOIN Termination ON (Termination.id = OrderProduct.termination_id)
|
||||
LEFT JOIN Building ON (Building.id = Termination.building_id)
|
||||
LEFT JOIN Terminationstatus ON (Terminationstatus.id = Termination.status_id)
|
||||
LEFT JOIN Buildingstatus ON (Buildingstatus.id = Building.status_id)
|
||||
LEFT JOIN Patching ON (Patching.Termination_id = OrderProduct.termination_id)
|
||||
LEFT JOIN Workflowitem ON (Workflowitem.object_type = 'Termination')
|
||||
LEFT JOIN Workflowvalue ON (Workflowvalue.item_id = Workflowitem.id)
|
||||
WHERE Workflowitem.name = 'customer_passive_finished'
|
||||
AND Workflowvalue.object_id = OrderProduct.termination_id
|
||||
AND Workflowvalue.value_int = 1
|
||||
AND $where
|
||||
GROUP BY Termination.id
|
||||
ORDER BY Termination.id ASC LIMIT 1";
|
||||
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function searchByTermination($filter = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
@@ -102,11 +137,12 @@ class PatchingModel {
|
||||
WHERE Workflowitem.name = 'customer_passive_finished'
|
||||
AND Workflowvalue.object_id = OrderProduct.termination_id
|
||||
AND Workflowvalue.value_int = 1
|
||||
AND (Patching.termination_id IS NULL OR Patching.patched = 0)
|
||||
AND $where
|
||||
GROUP BY Termination.id
|
||||
ORDER BY Termination.id ASC";
|
||||
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
// AND (Patching.patched IS NULL OR Patching.patched = 0)
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
@@ -155,7 +191,39 @@ class PatchingModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("patched", $filter)) {
|
||||
$patched = $filter["patched"];
|
||||
if($patched) {
|
||||
$where .= " AND Patching.patched=1";
|
||||
} else {
|
||||
$where .= " AND (Patching.patched IS NULL OR Patching.patched = 0)";
|
||||
}
|
||||
} else {
|
||||
$where .= " AND (Patching.patched IS NULL OR Patching.patched = 0)";
|
||||
}
|
||||
|
||||
if(array_key_exists("network_id", $filter)) {
|
||||
$network_id = $filter['network_id'];
|
||||
if(is_numeric($network_id)) {
|
||||
$where .= " AND Building.network_id=$network_id";
|
||||
} elseif(is_array($network_id) && count($network_id)) {
|
||||
$where .= " AND Building.network_id IN (". implode(",", $network_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("code", $filter)) {
|
||||
$code = FronkDB::singleton()->escape($filter['code']);
|
||||
if($code) {
|
||||
$where .= " AND Building.`code` like '%$code%'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("street", $filter)) {
|
||||
$street = FronkDB::singleton()->escape($filter["street"]);
|
||||
if($street) {
|
||||
$where .= " AND Building.street like '%$street%'";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
|
||||
@@ -8,6 +8,7 @@ class Termination extends mfBaseModel {
|
||||
private $lineworker;
|
||||
private $workflowitems;
|
||||
private $files;
|
||||
private $patching;
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
@@ -154,6 +155,11 @@ class Termination extends mfBaseModel {
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
if($name == "patching") {
|
||||
$this->patching = PatchingModel::getFirst(["termination_i" => $this->id]);
|
||||
return $this->patching;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
Reference in New Issue
Block a user