162 lines
4.8 KiB
PHP
162 lines
4.8 KiB
PHP
<?php
|
|
|
|
class FiberPlanCableEndpointController extends mfBaseController
|
|
{
|
|
|
|
protected function init()
|
|
{
|
|
$this->needlogin = true;
|
|
$me = new User();
|
|
$me->loadMe();
|
|
$this->me = $me;
|
|
$this->layout()->set("me", $me);
|
|
|
|
if (!$me->is(["Admin"])) {
|
|
$this->redirect("Dashboard");
|
|
}
|
|
}
|
|
|
|
protected function indexAction()
|
|
{
|
|
|
|
$this->layout()->setTemplate("FiberPlanCableEndpoint/Index");
|
|
$fiberplancableendpoints = FiberPlanCableEndpointModel::getAll();
|
|
$this->layout()->set("fiberplancableendpoints", $fiberplancableendpoints);
|
|
|
|
}
|
|
|
|
protected function addAction()
|
|
{
|
|
$fiberPlanCables=FiberPlanCableModel::getAll();
|
|
$this->layout()->set("fiberPlanCables", $fiberPlanCables);
|
|
$pops=PopModel::getAll();
|
|
$this->layout()->set("pops", $pops);
|
|
$racks=RackModel::getAll();
|
|
$this->layout()->set("racks", $racks);
|
|
$modules=ModuleModel::getAll();
|
|
$this->layout()->set("modules", $modules);
|
|
$fiberPlanDispatchers=FiberPlanDispatcherModel::getAll();
|
|
$this->layout()->set("fiberPlanDispatchers", $fiberPlanDispatchers);
|
|
$buildings=BuildingModel::getAll();
|
|
$this->layout()->set("buildings", $buildings);
|
|
|
|
$this->layout()->setTemplate("FiberPlanCableEndpoint/Form");
|
|
|
|
}
|
|
|
|
protected function editAction()
|
|
{
|
|
$id = $this->request->id;
|
|
|
|
if (!is_numeric($id) || !$id) {
|
|
$this->layout()->setFlash("f nicht gefunden", "error");
|
|
$this->redirect("FiberPlanCableEndpoint");
|
|
}
|
|
|
|
$fiberplancableendpoints = new FiberPlanCableEndpoint($id);
|
|
if ($fiberplancableendpoints->id != $id) {
|
|
$this->layout()->setFlash("f nicht gefunden", "error");
|
|
$this->redirect("FiberPlanCableEndpoint");
|
|
}
|
|
|
|
$this->layout()->set("fiberplancableendpoints", $fiberplancableendpoints);
|
|
return $this->addAction();
|
|
}
|
|
|
|
protected function saveAction()
|
|
{
|
|
$r = $this->request;
|
|
$id = $r->id;
|
|
//var_dump($r->get());exit;
|
|
if (is_numeric($id) && $id > 0) {
|
|
$mode = "edit";
|
|
$fiberplancableendpoints = new FiberPlanCableEndpoint($id);
|
|
if (!$fiberplancableendpoints->id) {
|
|
$this->layout()->setFlash("f nicht gefunden", "error");
|
|
$this->redirect("FiberPlanCableEndpoint");
|
|
}
|
|
} else {
|
|
$mode = "add";
|
|
}
|
|
|
|
$data = [];
|
|
$data['fiberPlanCable_id'] = trim($r->fiberPlanCable_id);
|
|
$data['pop_id'] = trim($r->pop_id);
|
|
$data['rack_id'] = trim($r->rack_id);
|
|
$data['module_id'] = trim($r->module_id);
|
|
$data['fiberPlanDispatcher_id'] = trim($r->fiberPlanDispatcher_id);
|
|
$data['building_id'] = trim($r->building_id);
|
|
$data['startport'] = trim($r->startport);
|
|
$data['endport'] = trim($r->endport);
|
|
|
|
|
|
if (!$data['fiberPlanCable_id']) {
|
|
$data['fiberPlanCable_id']=NULL;
|
|
}
|
|
if (!$data['pop_id']) {
|
|
$data['pop_id']=NULL;
|
|
}
|
|
if (!$data['rack_id']) {
|
|
$data['rack_id']=NULL;
|
|
}
|
|
if (!$data['module_id']) {
|
|
$data['module_id']=NULL;
|
|
}
|
|
if (!$data['fiberPlanDispatcher_id']) {
|
|
$data['fiberPlanDispatcher_id']=NULL;
|
|
}
|
|
if (!$data['building_id']) {
|
|
$data['building_id']=NULL;
|
|
}
|
|
if (!$data['startport']) {
|
|
$data['startport']=NULL;
|
|
}
|
|
if (!$data['endport']) {
|
|
$data['endport']=NULL;
|
|
}
|
|
|
|
|
|
// var_dump($_FILES);
|
|
// var_dump($upload);
|
|
// exit;
|
|
|
|
|
|
if ($mode == "edit") {
|
|
$fiberplancableendpoints->update($data);
|
|
|
|
} else {
|
|
$fiberplancableendpoints = FiberPlanCableEndpointModel::create($data);
|
|
}
|
|
// var_dump($filestore);
|
|
// exit;
|
|
$id = $fiberplancableendpoints->save();
|
|
|
|
if (!$id) {
|
|
$this->layout()->setFlash("f konnte nicht angelegt werden", "error");
|
|
$this->redirect("FiberPlanCableEndpoint");
|
|
}
|
|
|
|
if ($mode == "edit") {
|
|
$this->layout()->setFlash("f erfolgreich geändert", "success");
|
|
} else if ($mode = "add") {
|
|
$this->layout()->setFlash("f erfolgreich angelegt", "success");
|
|
}
|
|
$this->redirect("FiberPlanCableEndpoint");
|
|
}
|
|
|
|
|
|
protected function deleteAction()
|
|
{
|
|
$id = $this->request->id;
|
|
$fiberplancableendpoints = new FiberPlanCableEndpoint($id);
|
|
if (!$fiberplancableendpoints->id || $fiberplancableendpoints->id != $id) {
|
|
$this->layout()->setFlash("f nicht gefunden.", "error");
|
|
$this->redirect("FiberPlanCableEndpoint");
|
|
}
|
|
|
|
$fiberplancableendpoints->delete();
|
|
$this->redirect("FiberPlanCableEndpoint");
|
|
}
|
|
|
|
}
|