Merge branch 'devbyspi' into 'master'
MBI API Config Server-Configuration hinzugefügt. See merge request fronk/thetool!8
This commit is contained in:
@@ -208,6 +208,11 @@ class Contract extends mfBaseModel {
|
||||
return $this->journals;
|
||||
}
|
||||
|
||||
if($name == "journals") {
|
||||
$this->journals = array_reverse(ContractjournalModel::search(["contract_id" => $this->id]));
|
||||
return $this->journals;
|
||||
}
|
||||
|
||||
if($name == "links") {
|
||||
$this->links = ContractLinkModel::includesContractId($this->id, ["type" => $link]);
|
||||
//var_dump($this->links);exit;
|
||||
|
||||
@@ -1,266 +1,290 @@
|
||||
<?php
|
||||
|
||||
class CpeprovisioningController 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("Cpeprovisioning/Index");
|
||||
$cpeproducts = [];
|
||||
|
||||
$this->layout->set("filter", $this->request->filter);
|
||||
$filter = $this->getPreparedFilter($this->request->filter);
|
||||
// pagination defaults
|
||||
$pagination = [];
|
||||
$pagination['start'] = 0;
|
||||
$pagination['count'] = 20;
|
||||
$pagination['maxItems'] = 0;
|
||||
|
||||
$order_filter = $filter;
|
||||
//var_dump($filter);exit;
|
||||
/*
|
||||
* Get orderproducts in need of sending a CPE
|
||||
*/
|
||||
//var_dump($order_filter);exit;
|
||||
$orders = OrderModel::search($order_filter);
|
||||
|
||||
foreach($orders as $order) {
|
||||
if($order_filter["hide_delayed_finish"] && $order->finish_after) {
|
||||
// show at most 4 weeks before finish_after date
|
||||
//$after_ts = Layout::dateToInt($order->finish_after);
|
||||
if($order->finish_after > date("U") + (31 * 86400)) {
|
||||
$this->log->debug("Before 4 weeks before finish_after oid ".$order->id);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(is_array($order->terminations) && count($order->terminations)) {
|
||||
if(!$order->cpeprovisioning_enabled && $order->terminations[0]->status->code < TT_TERMSTATUS_CONNECTED) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($order->products as $orderproduct) {
|
||||
if($orderproduct->cpeprovisioning->routerconfig_finished == 1) {
|
||||
if(!$filter['routerconfig_finished']) continue;
|
||||
} else {
|
||||
if($filter['routerconfig_finished']) continue;
|
||||
}
|
||||
$product = $orderproduct->product;
|
||||
|
||||
if(is_array($product->attributes) && count($product->attributes)) {
|
||||
// filter out products without bras_type
|
||||
if(array_key_exists("bras_type", $product->attributes) && $product->attributes['bras_type']->value) {
|
||||
$cpeproducts[] = $orderproduct;
|
||||
} else {
|
||||
$this->log->debug("no bras_type oid ".$order->id);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
// ignore products without attributes
|
||||
$this->log->debug("no attributes oid ".$order->id);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$this->layout()->set("products", $cpeproducts);
|
||||
}
|
||||
|
||||
private function getPreparedFilter($filter) {
|
||||
$new_filter = [];
|
||||
|
||||
if(!is_array($filter)) $filter = [];
|
||||
|
||||
if(array_key_exists("hide_delayed_finish", $filter)) {
|
||||
if($filter["hide_delayed_finish"] == "1") {
|
||||
$new_filter["hide_delayed_finish"] = true;
|
||||
} else {
|
||||
$new_filter["hide_delayed_finish"] = false;
|
||||
}
|
||||
unset($filter["hide_delayed_finish"]);
|
||||
} else {
|
||||
$new_filter["hide_delayed_finish"] = true;
|
||||
}
|
||||
|
||||
if(array_key_exists("routerconfig_finished", $filter)) {
|
||||
if($filter["routerconfig_finished"] == "1") {
|
||||
$new_filter["routerconfig_finished"] = true;
|
||||
$new_filter["hide_delayed_finish"] = false;
|
||||
} else {
|
||||
$new_filter["routerconfig_finished"] = false;
|
||||
$order_filter["finish_date"] = null;
|
||||
}
|
||||
unset($filter["routerconfig_finished"]);
|
||||
} else {
|
||||
$new_filter["routerconfig_finished"] = false;
|
||||
$order_filter["finish_date"] = null;
|
||||
}
|
||||
|
||||
$new_filter['upgrade'] = 0;
|
||||
|
||||
|
||||
foreach($filter as $name => $value) {
|
||||
$new_filter[$name] = $value;
|
||||
}
|
||||
//var_dump($new_filter);exit;
|
||||
return $new_filter;
|
||||
}
|
||||
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
//var_dump($r);exit;
|
||||
if(is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$cpeprovisioning = new Cpeprovisioning($id);
|
||||
if(!$cpeprovisioning->id) {
|
||||
$this->layout()->setFlash("Eintrag nicht gefunden", "error");
|
||||
$this->redirect("Cpeprovisioning");
|
||||
}
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$order_id = $r->order_id;
|
||||
$termination_id = $r->termination_id;
|
||||
if(!(is_numeric($termination_id) && $termination_id > 0) && !(is_numeric($order_id) && $order_id > 0)) {
|
||||
$this->layout()->setFlash("Anschluss oder Bestellung nicht gefunden", "error");
|
||||
$this->redirect("Cpeprovisioning");
|
||||
}
|
||||
|
||||
$orderproduct = OrderProductModel::getFirst(["order_id" => $order_id, "termination_id" => $termination_id]);
|
||||
if(!$orderproduct) {
|
||||
$this->layout()->setFlash("Anschluss gehört nicht zur Bestellung", "error");
|
||||
$this->redirect("Cpeprovisioning");
|
||||
}
|
||||
|
||||
$prov_data = [];
|
||||
$prov_data["termination_id"] = ($r->termination_id) ? $r->termination_id : null;
|
||||
$prov_data["order_id"] = $r->order_id;
|
||||
$prov_data["orderproduct_id"] = $r->orderproduct_id;
|
||||
$prov_data["routerconfig_finished"] = ($r->routerconfig_finished) ? 1 : 0;
|
||||
$prov_data["routertype"] = $r->routertype;
|
||||
$prov_data["shipping"] = ($r->shipping) ? 1 : 0;
|
||||
$prov_data["wifi_ssid"] = $r->wifi_ssid;
|
||||
$prov_data["wifi_pass"] = $r->wifi_pass;
|
||||
$prov_data["mac"] = $r->mac;
|
||||
$prov_data["vlan_public"] = (strlen($r->vlan_public)) ? $r->vlan_public : null;
|
||||
$prov_data["vlan_nat"] = (strlen($r->vlan_nat)) ? $r->vlan_nat : null;
|
||||
$prov_data["vlan_ipv6"] = (strlen($r->vlan_ipv6)) ? $r->vlan_ipv6 : null;
|
||||
$prov_data["ship_weight"] = (strlen($r->ship_weight)) ? $r->ship_weight : null;
|
||||
$prov_data["ship_length"] = (strlen($r->ship_length)) ? $r->ship_length : null;
|
||||
$prov_data["ship_width"] = (strlen($r->ship_width)) ? $r->ship_width : null;
|
||||
$prov_data["ship_height"] = (strlen($r->ship_height)) ? $r->ship_height : null;
|
||||
$prov_data["note"] = $r->note;
|
||||
|
||||
$prov_data["edit_by"] = $this->me->id;
|
||||
|
||||
if($mode == "add") {
|
||||
$prov_data["create_by"] = $this->me->id;
|
||||
$cpeprovisioning = CpeprovisioningModel::create($prov_data);
|
||||
} else {
|
||||
$cpeprovisioning->update($prov_data);
|
||||
}
|
||||
|
||||
//var_dump($prov_data);exit;
|
||||
$new_id = $cpeprovisioning->save();
|
||||
if(!$new_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern", "error");
|
||||
$this->redirect("Cpeprovisioning");
|
||||
}
|
||||
|
||||
// saved successfully, if routerconfig_finished make Journal entry in Order
|
||||
|
||||
if($cpeprovisioning->routerconfig_finished) {
|
||||
$order_product = new OrderProduct($r->orderproduct_id);
|
||||
|
||||
if($cpeprovisioning->shipping) {
|
||||
$text = "CPE zu Produkt \"".$order_product->product->name."\" zum Versand vorbereitet.\n\n";
|
||||
} else {
|
||||
$text = "CPE zu Produkt \"".$order_product->product->name."\" vorbereitet für Techniker zur Vorortinstallation.\n\n";
|
||||
}
|
||||
$text .= "Router: ".$cpeprovisioning->routertype."\n";
|
||||
$text .= "Zugangstyp: ".$order_product->product->attributes['bras_type']->value."\n";
|
||||
if($cpeprovisioning->vlan_public) {
|
||||
$text .= "Vlan Public: ".$cpeprovisioning->vlan_public."\n";
|
||||
}
|
||||
if($cpeprovisioning->vlan_nat) {
|
||||
$text .= "Vlan NAT: ".$cpeprovisioning->vlan_nat."\n";
|
||||
}
|
||||
if($cpeprovisioning->vlan_ipv6) {
|
||||
$text .= "Vlan IPv6: ".$cpeprovisioning->vlan_ipv6."\n";
|
||||
}
|
||||
class CpeprovisioningController extends mfBaseController
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->needlogin = true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me", $me);
|
||||
|
||||
$journal = new OrderJournal();
|
||||
$journal->order_id = $order_id;
|
||||
$journal->text = $text;
|
||||
$journal->create_by = $this->me->id;
|
||||
$journal->edit_by = $this->me->id;
|
||||
|
||||
$journal_id = $journal->save();
|
||||
if(!$journal_id) {
|
||||
$this->layout()->setFlash("Konnte nicht ins Bestelljournal schreiben!", "warning");
|
||||
} else {
|
||||
$cpeprovisioning->order_journal_id = $journal_id;
|
||||
$cpeprovisioning->save();
|
||||
}
|
||||
}
|
||||
|
||||
// save ONT sn
|
||||
if($r->ont_sn) {
|
||||
$termination = new Termination($termination_id);
|
||||
$orig_sn = $termination->getWorkflowvalue("ont_sn", "string");
|
||||
|
||||
if($orig_sn === null) {
|
||||
|
||||
$sn_item = WorkflowitemModel::getFirst(["name" => "ont_sn", "object_type" => "termination"]);
|
||||
//var_dump($sn_item);exit;
|
||||
//var_dump(mfValuecache::singleton()->get("wfItemvalue-item-".$sn_item->id."-object-".$termination_id));exit;
|
||||
if(!$sn_item->id) {
|
||||
$this->log->error("ont_sn workflow item not found");
|
||||
} else {
|
||||
$sn_item->setObjectId($termination_id);
|
||||
$termination->workflowitems["ont_sn"] = $sn_item;
|
||||
//$sn_item->value->setValue($r->ont_sn);
|
||||
|
||||
//$sn_item->value->save();
|
||||
if (!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($r->ont_sn != $orig_sn) {
|
||||
$termination->workflowitems["ont_sn"]->value->setValue($r->ont_sn);
|
||||
$termination->workflowitems["ont_sn"]->value->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$query = [];
|
||||
if(is_numeric($this->request->s) && $this->request->s > 0) {
|
||||
$query["s"] = $this->request->s;
|
||||
|
||||
protected function indexAction()
|
||||
{
|
||||
$cpecounter = 0;
|
||||
$r = $this->request;
|
||||
$page = $r->s;
|
||||
|
||||
$this->layout()->setTemplate("Cpeprovisioning/Index");
|
||||
$cpeproducts = [];
|
||||
|
||||
$this->layout->set("filter", $this->request->filter);
|
||||
$filter = $this->getPreparedFilter($this->request->filter);
|
||||
// pagination defaults
|
||||
$pagination = [];
|
||||
$pagination['start'] = $page;
|
||||
$pagination['count'] = 25;
|
||||
$pagination['maxItems'] = 0;
|
||||
|
||||
$order_filter = $filter;
|
||||
//var_dump($filter);exit;
|
||||
/*
|
||||
* Get orderproducts in need of sending a CPE
|
||||
*/
|
||||
//var_dump($order_filter);exit;
|
||||
$orders = OrderModel::search($order_filter);
|
||||
$orderproductsprefetch = OrderProductModel::precache();
|
||||
|
||||
|
||||
foreach ($orders as $order) {
|
||||
if ($order_filter["hide_delayed_finish"] && $order->finish_after) {
|
||||
|
||||
// show at most 4 weeks before finish_after date
|
||||
//$after_ts = Layout::dateToInt($order->finish_after);
|
||||
if ($order->finish_after > date("U") + (31 * 86400)) {
|
||||
$this->log->debug("Before 4 weeks before finish_after oid " . $order->id);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (is_array($orderproductsprefetch['terminations'][$order->id]) && count($orderproductsprefetch['terminations'][$order->id])) {
|
||||
|
||||
if (!$order->cpeprovisioning_enabled && $orderproductsprefetch['terminations'][$order->id][0]['statuscode'] < TT_TERMSTATUS_CONNECTED) {
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($orderproductsprefetch[$order->id] as $orderproduct) {
|
||||
|
||||
|
||||
if ($orderproduct['routerconfig_finished'] == 1) {
|
||||
if (!$filter['routerconfig_finished']) continue;
|
||||
} else {
|
||||
if ($filter['routerconfig_finished']) continue;
|
||||
}
|
||||
|
||||
|
||||
$productattributes = $orderproduct['attributes'];
|
||||
|
||||
|
||||
if (is_array($productattributes) && count($productattributes)) {
|
||||
// filter out products without bras_type
|
||||
|
||||
if (array_key_exists("bras_type", $productattributes) && $productattributes) {
|
||||
$pagination['maxItems']++;
|
||||
if ($pagination['maxItems'] >= $pagination['start']+1 && $pagination['maxItems'] <= $pagination['start'] + $pagination['count']) {
|
||||
$cpeproducts[] = OrderProductModel::getOne($orderproduct['id']);
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->log->debug("no bras_type oid " . $order->id);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
// ignore products without attributes
|
||||
$this->log->debug("no attributes oid " . $order->id);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
$this->layout()->set("products", $cpeproducts);
|
||||
}
|
||||
if (is_array($this->request->filter)) {
|
||||
$query["filter"] = $this->request->filter;
|
||||
|
||||
private function getPreparedFilter($filter)
|
||||
{
|
||||
$new_filter = [];
|
||||
|
||||
if (!is_array($filter)) $filter = [];
|
||||
|
||||
if (array_key_exists("hide_delayed_finish", $filter)) {
|
||||
if ($filter["hide_delayed_finish"] == "1") {
|
||||
$new_filter["hide_delayed_finish"] = true;
|
||||
} else {
|
||||
$new_filter["hide_delayed_finish"] = false;
|
||||
}
|
||||
unset($filter["hide_delayed_finish"]);
|
||||
} else {
|
||||
$new_filter["hide_delayed_finish"] = true;
|
||||
}
|
||||
|
||||
if (array_key_exists("routerconfig_finished", $filter)) {
|
||||
if ($filter["routerconfig_finished"] == "1") {
|
||||
$new_filter["routerconfig_finished"] = true;
|
||||
$new_filter["hide_delayed_finish"] = false;
|
||||
} else {
|
||||
$new_filter["routerconfig_finished"] = false;
|
||||
$order_filter["finish_date"] = null;
|
||||
}
|
||||
unset($filter["routerconfig_finished"]);
|
||||
} else {
|
||||
$new_filter["routerconfig_finished"] = false;
|
||||
$order_filter["finish_date"] = null;
|
||||
}
|
||||
|
||||
$new_filter['upgrade'] = 0;
|
||||
|
||||
|
||||
foreach ($filter as $name => $value) {
|
||||
$new_filter[$name] = $value;
|
||||
}
|
||||
//var_dump($new_filter);exit;
|
||||
return $new_filter;
|
||||
}
|
||||
|
||||
$qs = http_build_query($query);
|
||||
|
||||
$this->layout()->setFlash("Eintrag erfolgreich gespeichert.", "success");
|
||||
$this->redirect("Cpeprovisioning","Index", $qs);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function saveAction()
|
||||
{
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
//var_dump($r);exit;
|
||||
if (is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$cpeprovisioning = new Cpeprovisioning($id);
|
||||
if (!$cpeprovisioning->id) {
|
||||
$this->layout()->setFlash("Eintrag nicht gefunden", "error");
|
||||
$this->redirect("Cpeprovisioning");
|
||||
}
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$order_id = $r->order_id;
|
||||
$termination_id = $r->termination_id;
|
||||
if (!(is_numeric($termination_id) && $termination_id > 0) && !(is_numeric($order_id) && $order_id > 0)) {
|
||||
$this->layout()->setFlash("Anschluss oder Bestellung nicht gefunden", "error");
|
||||
$this->redirect("Cpeprovisioning");
|
||||
}
|
||||
|
||||
$orderproduct = OrderProductModel::getFirst(["order_id" => $order_id, "termination_id" => $termination_id]);
|
||||
if (!$orderproduct) {
|
||||
$this->layout()->setFlash("Anschluss gehört nicht zur Bestellung", "error");
|
||||
$this->redirect("Cpeprovisioning");
|
||||
}
|
||||
|
||||
$prov_data = [];
|
||||
$prov_data["termination_id"] = ($r->termination_id) ? $r->termination_id : null;
|
||||
$prov_data["order_id"] = $r->order_id;
|
||||
$prov_data["orderproduct_id"] = $r->orderproduct_id;
|
||||
$prov_data["routerconfig_finished"] = ($r->routerconfig_finished) ? 1 : 0;
|
||||
$prov_data["routertype"] = $r->routertype;
|
||||
$prov_data["shipping"] = ($r->shipping) ? 1 : 0;
|
||||
$prov_data["wifi_ssid"] = $r->wifi_ssid;
|
||||
$prov_data["wifi_pass"] = $r->wifi_pass;
|
||||
$prov_data["mac"] = $r->mac;
|
||||
$prov_data["vlan_public"] = (strlen($r->vlan_public)) ? $r->vlan_public : null;
|
||||
$prov_data["vlan_nat"] = (strlen($r->vlan_nat)) ? $r->vlan_nat : null;
|
||||
$prov_data["vlan_ipv6"] = (strlen($r->vlan_ipv6)) ? $r->vlan_ipv6 : null;
|
||||
$prov_data["ship_weight"] = (strlen($r->ship_weight)) ? $r->ship_weight : null;
|
||||
$prov_data["ship_length"] = (strlen($r->ship_length)) ? $r->ship_length : null;
|
||||
$prov_data["ship_width"] = (strlen($r->ship_width)) ? $r->ship_width : null;
|
||||
$prov_data["ship_height"] = (strlen($r->ship_height)) ? $r->ship_height : null;
|
||||
$prov_data["note"] = $r->note;
|
||||
|
||||
$prov_data["edit_by"] = $this->me->id;
|
||||
|
||||
if ($mode == "add") {
|
||||
$prov_data["create_by"] = $this->me->id;
|
||||
$cpeprovisioning = CpeprovisioningModel::create($prov_data);
|
||||
} else {
|
||||
$cpeprovisioning->update($prov_data);
|
||||
}
|
||||
|
||||
//var_dump($prov_data);exit;
|
||||
$new_id = $cpeprovisioning->save();
|
||||
if (!$new_id) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern", "error");
|
||||
$this->redirect("Cpeprovisioning");
|
||||
}
|
||||
|
||||
// saved successfully, if routerconfig_finished make Journal entry in Order
|
||||
|
||||
if ($cpeprovisioning->routerconfig_finished) {
|
||||
$order_product = new OrderProduct($r->orderproduct_id);
|
||||
|
||||
if ($cpeprovisioning->shipping) {
|
||||
$text = "CPE zu Produkt \"" . $order_product->product->name . "\" zum Versand vorbereitet.\n\n";
|
||||
} else {
|
||||
$text = "CPE zu Produkt \"" . $order_product->product->name . "\" vorbereitet für Techniker zur Vorortinstallation.\n\n";
|
||||
}
|
||||
$text .= "Router: " . $cpeprovisioning->routertype . "\n";
|
||||
$text .= "Zugangstyp: " . $order_product->product->attributes['bras_type']->value . "\n";
|
||||
if ($cpeprovisioning->vlan_public) {
|
||||
$text .= "Vlan Public: " . $cpeprovisioning->vlan_public . "\n";
|
||||
}
|
||||
if ($cpeprovisioning->vlan_nat) {
|
||||
$text .= "Vlan NAT: " . $cpeprovisioning->vlan_nat . "\n";
|
||||
}
|
||||
if ($cpeprovisioning->vlan_ipv6) {
|
||||
$text .= "Vlan IPv6: " . $cpeprovisioning->vlan_ipv6 . "\n";
|
||||
}
|
||||
|
||||
$journal = new OrderJournal();
|
||||
$journal->order_id = $order_id;
|
||||
$journal->text = $text;
|
||||
$journal->create_by = $this->me->id;
|
||||
$journal->edit_by = $this->me->id;
|
||||
|
||||
$journal_id = $journal->save();
|
||||
if (!$journal_id) {
|
||||
$this->layout()->setFlash("Konnte nicht ins Bestelljournal schreiben!", "warning");
|
||||
} else {
|
||||
$cpeprovisioning->order_journal_id = $journal_id;
|
||||
$cpeprovisioning->save();
|
||||
}
|
||||
}
|
||||
|
||||
// save ONT sn
|
||||
if ($r->ont_sn) {
|
||||
$termination = new Termination($termination_id);
|
||||
$orig_sn = $termination->getWorkflowvalue("ont_sn", "string");
|
||||
|
||||
if ($orig_sn === null) {
|
||||
|
||||
$sn_item = WorkflowitemModel::getFirst(["name" => "ont_sn", "object_type" => "termination"]);
|
||||
//var_dump($sn_item);exit;
|
||||
//var_dump(mfValuecache::singleton()->get("wfItemvalue-item-".$sn_item->id."-object-".$termination_id));exit;
|
||||
if (!$sn_item->id) {
|
||||
$this->log->error("ont_sn workflow item not found");
|
||||
} else {
|
||||
$sn_item->setObjectId($termination_id);
|
||||
$termination->workflowitems["ont_sn"] = $sn_item;
|
||||
//$sn_item->value->setValue($r->ont_sn);
|
||||
|
||||
//$sn_item->value->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($r->ont_sn != $orig_sn) {
|
||||
$termination->workflowitems["ont_sn"]->value->setValue($r->ont_sn);
|
||||
$termination->workflowitems["ont_sn"]->value->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$query = [];
|
||||
if (is_numeric($this->request->s) && $this->request->s > 0) {
|
||||
$query["s"] = $this->request->s;
|
||||
}
|
||||
if (is_array($this->request->filter)) {
|
||||
$query["filter"] = $this->request->filter;
|
||||
}
|
||||
|
||||
$qs = http_build_query($query);
|
||||
|
||||
$this->layout()->setFlash("Eintrag erfolgreich gespeichert.", "success");
|
||||
$this->redirect("Cpeprovisioning", "Index", $qs);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
class DeviceController extends mfBaseController
|
||||
{
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->needlogin = true;
|
||||
@@ -269,6 +268,8 @@ class DeviceController extends mfBaseController
|
||||
$createConfig = DeviceModel::configcreate($ip);
|
||||
if ($createConfig->success === "true") {
|
||||
$this->layout()->setFlash("Backup wurde erfolgreich erstellt", "success");
|
||||
} elseif (!TT_MBI_API_ENABLE) {
|
||||
$this->layout()->setFlash("Backup konnte nicht erstellt werden. <b>Fehler</b>: Schnittstellenserver wurde vom Admin deaktiviert.", "error");
|
||||
} else {
|
||||
$this->layout()->setFlash("Backup konnte nicht erstellt werden. <b>Fehler</b>: " . $createConfig->error, "error");
|
||||
}
|
||||
|
||||
@@ -139,75 +139,80 @@ class DeviceModel
|
||||
|
||||
public static function getconifg($id)
|
||||
{
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => 'https://172.16.5.56/api/deviceconfigs/' . $id,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_SSL_VERIFYHOST => false,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'GET',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Authorization: Bearer 4|6l5ixx3CYBP7xClqEfVAC3zrBbQlxusAtu4zNwQp'),
|
||||
));
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
$response = "";
|
||||
if (TT_MBI_API_ENABLE) :
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => TT_MBI_API_URL . TT_MBI_API_VERSION . '/deviceconfigs/' . $id,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_SSL_VERIFYHOST => false,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'GET',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Authorization: Bearer ' . TT_MBI_API_KEY),
|
||||
));
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
endif;
|
||||
return json_decode($response);
|
||||
}
|
||||
|
||||
public static function getconifgdownload($id, $format)
|
||||
{
|
||||
$curl = curl_init();
|
||||
$response = "";
|
||||
if (TT_MBI_API_ENABLE) :
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => 'https://172.16.5.56/api/deviceconfigsdownload/' . $id . '/' . $format,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_SSL_VERIFYHOST => false,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'GET',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Authorization: Bearer 5|3QyhSkLgzrHwdVt05wQFUp2sFciiFhhGzucJirnI'),
|
||||
));
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => TT_MBI_API_URL . TT_MBI_API_VERSION . '/deviceconfigsdownload/' . $id . '/' . $format,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_SSL_VERIFYHOST => false,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'GET',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Authorization: Bearer ' . TT_MBI_API_KEY),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
$response = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
// echo $response;
|
||||
// var_dump($response);
|
||||
curl_close($curl);
|
||||
endif;
|
||||
return ($response);
|
||||
}
|
||||
|
||||
|
||||
public static function configcreate($ip)
|
||||
{
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => 'https://172.16.5.56/api/deviceconfigscreate/' . $ip,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_SSL_VERIFYHOST => false,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'GET',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Authorization: Bearer 5|3QyhSkLgzrHwdVt05wQFUp2sFciiFhhGzucJirnI'),
|
||||
));
|
||||
$response = curl_exec($curl);
|
||||
$response = "";
|
||||
if (TT_MBI_API_ENABLE) :
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => TT_MBI_API_URL . TT_MBI_API_VERSION . '/deviceconfigscreate/' . $ip,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_SSL_VERIFYHOST => false,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'GET',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Authorization: Bearer ' . TT_MBI_API_KEY),
|
||||
));
|
||||
$response = curl_exec($curl);
|
||||
endif;
|
||||
return json_decode($response);
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ private $file;
|
||||
return $this->editor;
|
||||
}
|
||||
if($name == "histories") {
|
||||
$this->histories=FilestoreHistoryModel::search(["filestore_id="=>$this->id]);
|
||||
$this->histories=FilestoreHistoryModel::search(["filestore_id$filter"=>$this->id]);
|
||||
return $this->histories;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,26 +19,21 @@ class FilestoreController extends mfBaseController
|
||||
{
|
||||
$this->layout()->setTemplate("Filestore/Index");
|
||||
$files = FilestoreModel::getAll();
|
||||
$fileshistory = FilestoreHistoryModel::getAll();
|
||||
$networkaddress = NetworkAddressModel::getAll();
|
||||
|
||||
|
||||
|
||||
// pagination defaults
|
||||
$pagination = [];
|
||||
$pagination['start'] = 0;
|
||||
$pagination['count'] = 25;
|
||||
$pagination['maxItems'] = 0;
|
||||
if(is_numeric($this->request->s)) {
|
||||
$pagination['start'] = intval($this->request->s);
|
||||
}
|
||||
$pagination['maxItems'] = FilestoreModel::count();
|
||||
$this->layout()->set("files", $files);
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
$this->layout()->set("fileshistory", $fileshistory);
|
||||
$this->layout()->set("networkaddresses", $networkaddress);
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function addAction()
|
||||
{
|
||||
$this->layout()->set("networks", NetworkModel::getAll());
|
||||
$this->layout()->set("networkaddresses", NetworkAddressModel::getAll());
|
||||
$this->layout()->setTemplate("Filestore/Form");
|
||||
}
|
||||
|
||||
@@ -46,9 +41,12 @@ class FilestoreController extends mfBaseController
|
||||
{
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
$editmode = $r->mode;
|
||||
|
||||
//var_dump($r->get());exit;
|
||||
if (is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
|
||||
$filestore = new Filestore($id);
|
||||
if (!$filestore->id) {
|
||||
$this->layout()->setFlash("Datei nicht gefunden", "error");
|
||||
@@ -59,23 +57,37 @@ class FilestoreController extends mfBaseController
|
||||
$dataHistory['name'] = $filestore->name;
|
||||
$dataHistory['description'] = $filestore->description;
|
||||
$dataHistory['file_id'] = $filestore->file_id;
|
||||
$dataHistory['network_id'] = $filestore->network_id;
|
||||
$dataHistory['filestore_id'] = $filestore->id;
|
||||
$dataHistory['create'] = $filestore->create;
|
||||
$dataHistory['create_by'] = $filestore->create_by;
|
||||
$dataHistory['edit'] = date("U");
|
||||
$dataHistory['edit_by'] = $filestore->edit_by;
|
||||
// $dataHistory['edit'] = date("U");
|
||||
$dataHistory['edit'] = $filestore->edit;
|
||||
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['name'] = trim($r->name);
|
||||
$data['description'] = trim($r->description);
|
||||
if ($editmode != "add-version" && $editmode != "edit-history") {
|
||||
$data['name'] = trim($r->name);
|
||||
$data['network_id'] = trim($r->network_id);
|
||||
}
|
||||
|
||||
if (!$data['name']) {
|
||||
$data['description'] = trim($r->description);
|
||||
$data['edit_by'] = trim($this->me->id);
|
||||
|
||||
if (!$data['name'] && $editmode != "add-version" && $editmode != "edit-history") {
|
||||
$this->layout()->setFlash("Name darf nicht leer sein", "error");
|
||||
$this->redirect("Filestore");
|
||||
}
|
||||
|
||||
if (!$data['network_id'] && $editmode != "add-version" && $editmode != "edit-history") {
|
||||
$this->layout()->setFlash("Netzgebiet darf nicht leer sein", "error");
|
||||
$this->redirect("Filestore");
|
||||
}
|
||||
|
||||
if (array_key_exists("filestore", $_FILES) && !$_FILES['filestore']['error']) {
|
||||
$upload_error = false;
|
||||
|
||||
@@ -113,14 +125,17 @@ class FilestoreController extends mfBaseController
|
||||
}
|
||||
$data['file_id'] = $file_id;
|
||||
|
||||
if ($mode == "edit") {
|
||||
|
||||
if ($mode == "edit" && $editmode == "add-version") {
|
||||
$fsh = FilestoreHistoryModel::create($dataHistory);
|
||||
}
|
||||
} else {
|
||||
if ($mode == "add") {
|
||||
if ($mode == "add" || $editmode == "add-version") {
|
||||
$this->layout()->setFlash("Keine Datei angegeben", "error");
|
||||
$this->redirect("Filestore", "add");
|
||||
if ($editmode == "add-version") {
|
||||
$this->redirect("Filestore");
|
||||
} else {
|
||||
$this->redirect("Filestore", "add");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -141,7 +156,7 @@ class FilestoreController extends mfBaseController
|
||||
$id = $filestore->save();
|
||||
|
||||
if (!$id) {
|
||||
$this->layout()->setFlash("Dateiupload fehlgeschlagen33", "error");
|
||||
$this->layout()->setFlash("Dateiupload fehlgeschlagen", "error");
|
||||
$this->redirect("Filestore");
|
||||
}
|
||||
if ($fsh) {
|
||||
@@ -155,19 +170,28 @@ class FilestoreController extends mfBaseController
|
||||
{
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
//var_dump($r->get());exit;
|
||||
if ($r->mode) {
|
||||
$mode = $r->mode;
|
||||
} else {
|
||||
$mode = "";
|
||||
}
|
||||
if (!is_numeric($id) && $id < 1) {
|
||||
|
||||
$this->layout()->setFlash("Datei nicht gefunden", "error");
|
||||
$this->redirect("Filestore");
|
||||
|
||||
}
|
||||
$filestore = new Filestore($id);
|
||||
|
||||
$filestore = new Filestore($id);
|
||||
$filestorehistory = FilestoreHistoryModel::getAllhistory($id);;
|
||||
if (!$filestore->id) {
|
||||
$this->layout()->setFlash("Datei nicht gefunden", "error");
|
||||
$this->redirect("Filestore");
|
||||
}
|
||||
if ($mode) {
|
||||
$this->layout()->set("mode", $mode);
|
||||
}
|
||||
$this->layout()->set("filestorehistory", $filestorehistory);
|
||||
$this->layout()->set("file", $filestore);
|
||||
|
||||
return $this->addAction();
|
||||
@@ -187,11 +211,41 @@ class FilestoreController extends mfBaseController
|
||||
foreach ($filstore->histories as $h) {
|
||||
$h->file->delete();
|
||||
$h->delete();
|
||||
|
||||
}
|
||||
$filstore->file->delete();
|
||||
// check if Product is unused
|
||||
$filstore->delete();
|
||||
$this->redirect("Filestore");
|
||||
}
|
||||
|
||||
protected function apiAction()
|
||||
{
|
||||
if (!$this->me->is(["Admin", "netowner", "pipeplanner", "lineplanner", "pipeworker", "netoperator", "lineworker"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
$id = $this->request->id;
|
||||
|
||||
$filestorehistory = FilestoreHistoryModel::getAllhistory($id);
|
||||
$counter = 0;
|
||||
foreach ($filestorehistory as $history) {
|
||||
$data[$counter]['id'] = $history->id;
|
||||
$data[$counter]['file_id'] = $history->data->file_id;
|
||||
$data[$counter]['name'] = $history->data->name;
|
||||
$data[$counter]['description'] = $history->data->description;
|
||||
$data[$counter]['workername'] = $history->data->workername;
|
||||
$data[$counter]['workerid'] = $history->data->workerid;
|
||||
$data[$counter]['edit'] = $history->edit;
|
||||
if (trim($this->me->id) == $history->data->workerid || $this->me->is(["Admin"])) {
|
||||
$data[$counter]['is_delete'] = 1;
|
||||
} else {
|
||||
$data[$counter]['is_delete'] = 0;
|
||||
}
|
||||
|
||||
|
||||
$counter++;
|
||||
}
|
||||
echo json_encode($data);
|
||||
exit;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ class FilestoreModel
|
||||
{
|
||||
public $order_id;
|
||||
public $file_id;
|
||||
public $network_id;
|
||||
public $name;
|
||||
public $description;
|
||||
|
||||
@@ -54,11 +55,13 @@ class FilestoreModel
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
$sql = "SELECT Filestore.* FROM Filestore
|
||||
$sql = "SELECT Filestore.*,Network.name network,Network.id networkid FROM Filestore
|
||||
LEFT JOIN File ON (Filestore.file_id = File.id)
|
||||
LEFT JOIN Network ON (Filestore.network_id = Network.id)
|
||||
ORDER BY name";
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
|
||||
@@ -147,5 +147,19 @@ class FilestoreHistoryController extends mfBaseController
|
||||
|
||||
return $this->addAction();
|
||||
}
|
||||
protected function deleteAction()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
|
||||
|
||||
$filstorehistory = new FilestoreHistory($id);
|
||||
|
||||
if (!$filstorehistory->id || $filstorehistory->id != $id) {
|
||||
$this->layout()->setFlash("Datei nicht gefunden.", "error");
|
||||
$this->redirect("Filestore");
|
||||
}
|
||||
$filstorehistory->delete();
|
||||
$this->redirect("Filestore");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -58,8 +58,28 @@ class FilestoreHistoryModel
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
$sql = "SELECT FilestoreHistory.* FROM FilestoreHistory
|
||||
|
||||
";
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_array($res)) {
|
||||
$items[$data['filestore_id']] = 1;
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getAllhistory($id)
|
||||
{
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
$sql = "SELECT FilestoreHistory.*,Worker.name workername,Worker.id workerid FROM FilestoreHistory
|
||||
LEFT JOIN File ON (FilestoreHistory.file_id = File.id)
|
||||
ORDER BY name";
|
||||
INNER JOIN Worker ON (FilestoreHistory.edit_by=Worker.id)
|
||||
WHERE `filestore_id` ='" . $id . "'
|
||||
ORDER BY edit DESC";
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_object($res)) {
|
||||
@@ -94,12 +114,10 @@ class FilestoreHistoryModel
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
|
||||
$sql = "SELECT FilestoreHistory.* FROM FilestoreHistory
|
||||
LEFT JOIN File ON (FilestoreHistory.file_id = File.id)
|
||||
WHERE $where
|
||||
ORDER BY name";
|
||||
|
||||
$res = $db->query($sql);
|
||||
|
||||
if ($db->num_rows($res)) {
|
||||
|
||||
@@ -1,145 +1,204 @@
|
||||
<?php
|
||||
|
||||
class OrderProductModel {
|
||||
public $order_id;
|
||||
public $product_id;
|
||||
public $termination_id;
|
||||
public $upgrade;
|
||||
public $amount;
|
||||
public $pos;
|
||||
public $description;
|
||||
public $price;
|
||||
public $price_setup;
|
||||
public $price_nne;
|
||||
public $price_nbe;
|
||||
public $billing_delay;
|
||||
public $billing_period;
|
||||
public $note;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
class OrderProductModel
|
||||
{
|
||||
public $order_id;
|
||||
public $product_id;
|
||||
public $termination_id;
|
||||
public $upgrade;
|
||||
public $amount;
|
||||
public $pos;
|
||||
public $description;
|
||||
public $price;
|
||||
public $price_setup;
|
||||
public $price_nne;
|
||||
public $price_nbe;
|
||||
public $billing_delay;
|
||||
public $billing_period;
|
||||
public $note;
|
||||
|
||||
public static function create(Array $data) {
|
||||
$model = new OrderProduct();
|
||||
|
||||
foreach($data as $field => $value) {
|
||||
if(property_exists(get_called_class(), $field)) {
|
||||
$model->$field = $value;
|
||||
}
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
|
||||
public static function create(array $data)
|
||||
{
|
||||
$model = new OrderProduct();
|
||||
|
||||
foreach ($data as $field => $value) {
|
||||
if (property_exists(get_called_class(), $field)) {
|
||||
$model->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (!array_key_exists("note", $data)) {
|
||||
$model->note = "";
|
||||
}
|
||||
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
if ($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if ($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
if(!array_key_exists("note", $data)) {
|
||||
$model->note = "";
|
||||
}
|
||||
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
if($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getOne($id) {
|
||||
if(!is_numeric($id) || !$id) {
|
||||
throw new Exception("Invalid number", 400);
|
||||
}
|
||||
$item = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("OrderProduct", "*", "id=$id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new OrderProduct($data);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("OrderProduct", "*", "1=1 ORDER BY order_id, pos, product_id, description");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new OrderProduct($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst($filter = false) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("OrderProduct", "*", "$where ORDER BY order_id, pos, product_id, description");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new OrderProduct($data);
|
||||
if($item->id) {
|
||||
|
||||
public static function getOne($id)
|
||||
{
|
||||
if (!is_numeric($id) || !$id) {
|
||||
throw new Exception("Invalid number", 400);
|
||||
}
|
||||
$item = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("OrderProduct", "*", "id=$id LIMIT 1");
|
||||
if ($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new OrderProduct($data);
|
||||
}
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function search($filter) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM OrderProduct WHERE $where ORDER BY order_id, pos, product_id, description";
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new OrderProduct($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
//var_dump($filter);exit;
|
||||
if(array_key_exists("order_id", $filter)) {
|
||||
$order_id = $filter['order_id'];
|
||||
if(is_numeric($order_id)) {
|
||||
$where .= " AND order_id=$order_id";
|
||||
}
|
||||
public static function getAll()
|
||||
{
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("OrderProduct", "*", "1=1 ORDER BY order_id, pos, product_id, description");
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_object($res)) {
|
||||
$items[] = new OrderProduct($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
if(array_key_exists("product_id", $filter)) {
|
||||
$product_id = $filter['product_id'];
|
||||
if(is_numeric($product_id)) {
|
||||
$where .= " AND order_id=$product_id";
|
||||
}
|
||||
|
||||
public static function getFirst($filter = false)
|
||||
{
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("OrderProduct", "*", "$where ORDER BY order_id, pos, product_id, description");
|
||||
if ($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new OrderProduct($data);
|
||||
if ($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if(array_key_exists("termination_id", $filter)) {
|
||||
$termination_id = $filter['termination_id'];
|
||||
if(is_numeric($termination_id)) {
|
||||
$where .= " AND termination_id=$termination_id";
|
||||
}
|
||||
|
||||
public static function search($filter)
|
||||
{
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM OrderProduct WHERE $where ORDER BY order_id, pos, product_id, description";
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_object($res)) {
|
||||
$items[] = new OrderProduct($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
||||
public static function precache()
|
||||
{
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$sql = "SELECT `OrderProduct`.`id`, `OrderProduct`.`order_id`, `OrderProduct`.`product_id`, `OrderProduct`.`termination_id`
|
||||
,`ProducttechAttribute`.`name` ProducttechAttributename,
|
||||
`routerconfig_finished`,
|
||||
`Termination`.`id` `terminationid`,
|
||||
`Terminationstatus`.`code` `statuscode`
|
||||
FROM `OrderProduct`
|
||||
INNER JOIN `Product` ON (`OrderProduct`.`product_id`=`Product`.`id`)
|
||||
INNER JOIN `Producttech` ON (`Producttech`.`id`=`Product`.`producttech_id`)
|
||||
INNER JOIN `ProductAttribute` ON (`ProductAttribute`.`product_id`=`Product`.`id`)
|
||||
INNER JOIN `ProducttechAttribute` ON (`ProductAttribute`.`producttechattribute_id`=`ProducttechAttribute`.`id`)
|
||||
LEFT JOIN `Termination` ON (`OrderProduct`.`termination_id`=`Termination`.`id`)
|
||||
LEFT JOIN `Terminationstatus` ON (`Terminationstatus`.`id` = `Termination`.`status_id`)
|
||||
LEFT JOIN `Cpeprovisioning` ON (`Cpeprovisioning`.`orderproduct_id`=`OrderProduct`.`id`)
|
||||
";
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
$oldProduct = "";
|
||||
$oldOrder = "";
|
||||
while ($data = $db->fetch_array($res)) {
|
||||
if ($data['terminationid'])
|
||||
{
|
||||
$items['terminations'][$data['order_id']][]['statuscode']=$data['statuscode'];
|
||||
}
|
||||
if ($oldOrder != $data['order_id']) {
|
||||
$items[$data['order_id']]['statuscode'] = $data['statuscode'];
|
||||
}
|
||||
if ($oldProduct != $data['id']) {
|
||||
$items[$data['order_id']][$data['id']]['id'] = $data['id'];
|
||||
$items[$data['order_id']][$data['id']]['product_id'] = $data['product_id'];
|
||||
$items[$data['order_id']][$data['id']]['termination_id'] = $data['termination_id'];
|
||||
$items[$data['order_id']][$data['id']]['routerconfig_finished'] = $data['routerconfig_finished'];
|
||||
}
|
||||
if ($data['routerconfig_finished'] == 1) {
|
||||
$items[$data['order_id']][$data['id']]['routerconfig_finished'] = $data['routerconfig_finished'];
|
||||
}
|
||||
|
||||
$items[$data['order_id']][$data['id']]['attributes'][$data['ProducttechAttributename']] = $data['ProducttechAttributename'];
|
||||
$oldProduct = $data['id'];
|
||||
$oldOrder = $data['order_id'];
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter)
|
||||
{
|
||||
$where = "1=1 ";
|
||||
|
||||
//var_dump($filter);exit;
|
||||
if (array_key_exists("order_id", $filter)) {
|
||||
$order_id = $filter['order_id'];
|
||||
if (is_numeric($order_id)) {
|
||||
$where .= " AND order_id=$order_id";
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists("product_id", $filter)) {
|
||||
$product_id = $filter['product_id'];
|
||||
if (is_numeric($product_id)) {
|
||||
$where .= " AND order_id=$product_id";
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists("termination_id", $filter)) {
|
||||
$termination_id = $filter['termination_id'];
|
||||
if (is_numeric($termination_id)) {
|
||||
$where .= " AND termination_id=$termination_id";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user