Added adding POPs
This commit is contained in:
@@ -92,8 +92,29 @@ class AddresstypeModel {
|
||||
if(is_array($filter['addresstype']) && count($filter['addresstype'])) {
|
||||
$at = $filter['addresstype'];
|
||||
$in = [];
|
||||
if(in_array("owner", $at)) {
|
||||
$in[] = "Addresstype.type = 'owner'";
|
||||
if(in_array("systemowner", $at)) {
|
||||
$in[] = "Addresstype.type = 'systemowner'";
|
||||
}
|
||||
if(in_array("netowner", $at)) {
|
||||
$in[] = "Addresstype.type = 'netowner'";
|
||||
}
|
||||
if(in_array("salespartner", $at)) {
|
||||
$in[] = "Addresstype.type = 'Addresstype'";
|
||||
}
|
||||
if(in_array("pipeworker", $at)) {
|
||||
$in[] = "Addresstype.type = 'pipeworker'";
|
||||
}
|
||||
if(in_array("lineworker", $at)) {
|
||||
$in[] = "Addresstype.type = 'lineworker'";
|
||||
}
|
||||
if(in_array("netoperator", $at)) {
|
||||
$in[] = "Addresstype.type = 'netoperator'";
|
||||
}
|
||||
if(in_array("support", $at)) {
|
||||
$in[] = "Addresstype.type = 'support'";
|
||||
}
|
||||
if(in_array("billing", $at)) {
|
||||
$in[] = "Addresstype.type = 'billing'";
|
||||
}
|
||||
if(in_array("employee", $at)) {
|
||||
$in[] = "Addresstype.type = 'employee'";
|
||||
@@ -107,9 +128,6 @@ class AddresstypeModel {
|
||||
if(in_array("contact", $at)) {
|
||||
$in[] = "Addresstype.type = 'contact'";
|
||||
}
|
||||
if(in_array("billing", $at)) {
|
||||
$in[] = "Addresstype.type = 'billing'";
|
||||
}
|
||||
|
||||
$or = "";
|
||||
if(count($in)) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
class Network extends mfBaseModel {
|
||||
private $owner;
|
||||
private $pops;
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
@@ -15,6 +16,16 @@ class Network extends mfBaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
if($name == "pops") {
|
||||
if($this->id) {
|
||||
$pops = PopModel::search(['network_id' => $this->id]);
|
||||
$this->pops = $pops;
|
||||
return $this->pops;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
@@ -13,5 +13,89 @@ class PopController extends mfBaseController {
|
||||
$this->redirect("Dashboard");
|
||||
}*/
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
|
||||
}
|
||||
|
||||
protected function addAction() {
|
||||
$this->layout()->setTemplate("Pop/Form");
|
||||
$this->layout()->set("networks", NetworkModel::getAll());
|
||||
if($this->request->network_id) {
|
||||
$pop = new Pop();
|
||||
$pop->network_id = $this->request->network_id;
|
||||
$this->layout()->set("pop", $pop);
|
||||
}
|
||||
}
|
||||
|
||||
protected function editAction() {
|
||||
$id = $this->request->id;
|
||||
if(!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("POP nicht gefunden", "error");
|
||||
$this->redirect("Network");
|
||||
}
|
||||
|
||||
$pop = new Pop($id);
|
||||
if($pop->id != $id) {
|
||||
$this->layout()->setFlash("POP nicht gefunden", "error");
|
||||
$this->redirect("Network");
|
||||
}
|
||||
|
||||
$this->layout()->set("pop", $pop);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
//var_dump($r);exit;
|
||||
if(is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$pop = new Pop($id);
|
||||
if(!$pop->id) {
|
||||
$this->layout()->setFlash("POP nicht gefunden", "error");
|
||||
$this->redirect("Network");
|
||||
}
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
//var_dump($r->addresstypes);exit;
|
||||
|
||||
if(!$r->network_id || !$r->name) {
|
||||
$this->layout()->setFlash("Bitte Name und Netzgebiet eintragen", "error");
|
||||
$this->layout()->set("pop", $pop);
|
||||
unset($r->network_id);
|
||||
return $this->add();
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['network_id'] = $r->network_id;
|
||||
$data['name'] = $r->name;
|
||||
$data['gps_lat'] = $r->gps_lat;
|
||||
$data['gps_long'] = $r->gps_long;
|
||||
$data['location'] = $r->location;
|
||||
$data['note'] = $r->note;
|
||||
|
||||
$data['edit_by'] = 1;
|
||||
|
||||
if($mode == "add") {
|
||||
$data['create_by'] = 1;
|
||||
$pop = PopModel::create($data);
|
||||
} else {
|
||||
$pop->update($data);
|
||||
}
|
||||
|
||||
//var_dump($address);exit;
|
||||
|
||||
$new_id = $pop->save();
|
||||
if(!$new_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern", "error");
|
||||
$this->layout()->set("network", $network);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Netzgebiet erfolgreich gespeichert.", "success");
|
||||
$this->redirect("Pop", "Edit", ['id' => $new_id]);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,11 @@
|
||||
|
||||
class PopModel {
|
||||
public $name = null;
|
||||
public $owner_id = null;
|
||||
public $network_id = null;
|
||||
public $gps_lat = null;
|
||||
public $gps_long = null;
|
||||
public $location = null;
|
||||
|
||||
public $note = null;
|
||||
|
||||
public $create_by = null;
|
||||
@@ -15,7 +19,7 @@ class PopModel {
|
||||
}
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new Network();
|
||||
$model = new Pop();
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(property_exists(get_called_class(), $field)) {
|
||||
@@ -33,10 +37,10 @@ class PopModel {
|
||||
$item = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("Network", "*", "id=$id LIMIT 1");
|
||||
$res = $db->select("Pop", "*", "id=$id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Network($data);
|
||||
$item = new Pop($data);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
@@ -46,10 +50,10 @@ class PopModel {
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("Network", "*");
|
||||
$res = $db->select("Pop", "*");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Network($data);
|
||||
$items[] = new Pop($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
@@ -60,10 +64,10 @@ class PopModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Network", "*". "$where ORDER BY name, owner_id");
|
||||
$res = $db->select("Pop", "*", "$where ORDER BY name, network_id");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new Network($data);
|
||||
$item = new Pop($data);
|
||||
if($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
@@ -78,10 +82,10 @@ class PopModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("Network", "*". "$where ORDER BY name, owner_id");
|
||||
$res = $db->select("Pop", "*", "$where ORDER BY name, network_id");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new Network($data);
|
||||
$items[] = new Pop($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
@@ -91,10 +95,10 @@ class PopModel {
|
||||
$where = "1=1 ";
|
||||
|
||||
//var_dump($filter);exit;
|
||||
if(array_key_exists("owner_id", $filter)) {
|
||||
$ownerid= $filter['owner_id'];
|
||||
if(is_numeric($ownerid)) {
|
||||
$where .= " AND owner_id=$ownerid";
|
||||
if(array_key_exists("network_id", $filter)) {
|
||||
$networkid = $filter['network_id'];
|
||||
if(is_numeric($networkid)) {
|
||||
$where .= " AND network_id=$networkid";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user