@@ -309,45 +363,50 @@
Rechnungsperiode |
Verz. Verrechnungsstart |
-
+
+
+
+
getCredit(); if(!$credit) continue; ?>
| approved) ? "checked='checked'" : ""?> /> |
- =($credit["partner"]) ? $credit["partner"]->getCompanyOrName() : ""?> |
-
- =$contract->product_name?>
+ | =($credit["partner"]) ? $credit["partner"]->getCompanyOrName() : ""?> |
+
+ =$contract->product_name?>
termination_id && $contract->termination): ?>
=$contract->termination->code?> - = str_replace("\n", " - ", $contract->termination->getAddress())?>
-
+
|
-
+ |
- =$contract->matchcode?>
+ =$contract->crediting_matchcode?>
|
- =($credit["rate_source"] == "rate") ? "€ ".$credit["rate"] : "€ ".$contract->price_nne?> =($credit["rate_source"] == "rate") ? "(Prozentrate)" : "(NNE)"?> |
-
+ |
+ =($credit["rate_source"] == "rate") ? "€ ".$credit["rate"] : "€ ".$contract->price_nne?> =($credit["rate_source"] == "rate") ? "(Prozentrate)" : "(NNE)"?>
+ |
+
billing_period == 1): ?>
- monatlich
+ monatlich
billing_period == 24): ?>
- biennal
+ 3-jährlich
billing_period == 36): ?>
- triennal
+ 3-jährlich
=(12 / $contract->billing_period)?>x Jährlich
|
- =($contract->billing_delay) ? $contract->billing_delay." Monate" : ""?> |
+ =($contract->billing_delay) ? $contract->billing_delay." Monate" : ""?> |
@@ -383,7 +442,9 @@
?>
var products = =json_encode($prods)?>;
-
+
+
+
function toggleOrderApproval(cbox, order_id, type) {
if(!parseInt(order_id) || !order_id) return;
@@ -413,39 +474,207 @@
$("#" + type + "-products-" + order_id + " .checkbox-toggle").prop("checked", false);
}
}
-
- function toggleEdit(type, id, control_name) {
- var textBlock = $("#" + type + "-" + id + " ." + control_name + " .text");
- var editBlock = $("#" + type + "-" + id + " ." + control_name + " .edit");
-
- var control = $("#" + type + "-" + id + " ." + control_name + " .edit .edit-control");
-
- var current_val = control.data("val");
- var original_val = control.data("ov");
-
- textBlock.toggle();
- editBlock.toggle();
-
- if(type == "owner" || type == "billingaddress") {
- return;
- }
-
- if(control_name == "product") {
- if(!control.children().length) {
- products.forEach((product) => {
- var opt = document.createElement("option");
- opt.text = product.name;
- opt.value = product.id;
- control.append(opt);
+
+ function toggleEdit(type, id, control_name) {
+ if(type === "owner" || type === "billingaddress") {
+ $("#" + type + "-" + id + " .text").toggle();
+ $("#" + type + "-" + id + " .edit").toggle();
+
+ if($("#" + type + "-" + id + " .edit").is(":visible")) {
+ console.log("visible");
+ $("#" + type + "-" + id + " .edit select").autoComplete();
+ }
+
+ return;
+ }
+
+ var textBlock = $("#" + type + "-" + id + " ." + control_name + " .text");
+ var editBlock = $("#" + type + "-" + id + " ." + control_name + " .edit");
+
+ var control = $("#" + type + "-" + id + " ." + control_name + " .edit .edit-control");
+
+ var current_val = control.data("val");
+ var original_val = control.data("ov");
+
+ textBlock.toggle();
+ editBlock.toggle();
+
+
+ if(control_name == "product") {
+ if(!control.children().length) {
+ products.forEach((product) => {
+ var opt = document.createElement("option");
+ opt.text = product.name;
+ opt.value = product.id;
+ control.append(opt);
+ });
+ console.log(current_val);
+ control.val(current_val);
+ }
+ }
+ }
+
+ function saveEdit(type, id, control_name) {
+ var textBlock = $("#" + type + "-" + id + " ." + control_name + " .text");
+ var editBlock = $("#" + type + "-" + id + " ." + control_name + " .edit");
+
+ var control = $("#" + type + "-" + id + " ." + control_name + " .edit .edit-control");
+ control.removeClass("invalid");
+
+ var current_val = control.data("val");
+ var original_val = control.data("ov");
+
+ var new_value = control.val();
+
+ console.log(new_value);
+
+ if(!new_value.length && control_name !== "billing_delay") {
+ control.addClass("invalid");
+ return;
+ }
+
+ var action = "saveContract";
+ if(type === "credit") {
+ var action = "saveCredit";
+ }
+
+ var data = {};
+ data["do"] = action;
+ data["id"] = id;
+ data[control_name] = new_value;
+
+ console.log(data);
+
+ var ctx = {id: id, control_name: control_name};
+ // save
+ $.ajax({
+ url: "=self::getUrl("Contractqueue", "api")?>",
+ type: "POST",
+ data: data,
+ context: ctx,
+ success: function (success) {
+ console.log(ctx);
+ const id = ctx.id;
+ const control_name = ctx.control_name;
+
+ var textBlock = $("#" + type + "-" + id + " ." + control_name + " .text");
+ var editBlock = $("#" + type + "-" + id + " ." + control_name + " .edit");
+
+ //console.log(success);
+ if(success.status != "OK") {
+ $("#" + type + "-" + id + " ." + control_name + " .edit .edit-control").addClass("invalid");
+ return;
+ }
+
+ Object.entries(success.result.contract).forEach(item => {
+ const [key, value] = item;
+ console.log(key + ": " + value);
+ var text = $("#contract-" + id + " ." + key + " .text .value");
+ var control = $("#contract-" + id + " ." + key + " .edit .edit-control");
+
+ if (text.length && control.length) {
+ if(key === "billing_period") {
+ switch (parseInt(value)) {
+ case 1:
+ text.text("Monatlich");
+ $("#credit-" + id + " .billing_period.text.value").text("Monatlich");
+ break;
+ case 12:
+ text.text("Jährlich");
+ $("#credit-" + id + " .billing_period.text.value").text("Jährlich");
+ break;
+ case 24:
+ text.text("2-Jährlich");
+ $("#credit-" + id + " .billing_period.text.value").text("2-Jährlich");
+ break;
+ case 36:
+ text.text("3-Jährlich");
+ $("#credit-" + id + " .billing_period.text.value").text("3-Jährlich");
+ break;
+ }
+ } else if(key === "billing_delay") {
+ if (value > 0) {
+ text.text(value + " Monate");
+ $("#credit-" + id + " .billing_delay.text.value").text(value + " Monate");
+ } else {
+ text.text("");
+ $("#credit-" + id + " .billing_delay.text.value").text("");
+ }
+ } else if(key === "product") {
+ var product_name = success.result.contract.product_name;
+ text.text(product_name);
+ $("#credit-" + id + " .product.text .value").text(product_name);
+ } else {
+ text.text(value);
+ }
+
+ control.data("val", value);
+ control.data("ov", value);
+ }
+ });
+
+
+ Object.entries(success.result.credit).forEach(item => {
+ const [key, value] = item;
+ console.log(key + ": " + value);
+
+ var text = $("#credit-" + id + " ." + key + " .text .value");
+ //var control = $("#credit-" + id + " ." + key + " .edit .edit-control");
+
+ if(key === "crediting_rate") {
+ console.log(success.result.credit.crediting_partner_text);
+ $("#credit-" + id + " .crediting_partner_rate.text.value").text(success.result.credit.crediting_partner_text);
+ } /*else if(key === "crediting_partner_id") {
+ if(!value) {
+ $("#credit-" + id + " .crediting_partner_text.text.value").text("");
+ }
+ $("#credit-" + id + " .crediting_partner_text.text.value").text(value);
+ }*/ else {
+ text.text(value);
+ }
+
+ });
+
+ editBlock.hide();
+ textBlock.show();
+ },
+ dataType: "json"
});
- console.log(current_val);
- control.val(current_val);
- }
-
- return;
}
-
- }
+
+ function saveAddress(type, id) {
+ var new_value = $("input[name='" + type + "_id-" + id + "'").val();
+
+ $.ajax({
+ url: "=self::getUrl("Address", "api")?>",
+ type: "GET",
+ context: id,
+ data: {
+ do: "getAddress",
+ id: new_value
+ },
+ success: function(success) {
+ if(success.status !== "OK") {
+ return;
+ }
+ address = success.result.address;
+
+
+
+ $("#" + type + "-" + id + " .text").html(
+ `
${address.customer_number}
+
${address.name}
+ ${address.street}
+ ${address.zip} ${address.city}
`
+ );
+ $("#" + type + "-" + id + " .text").toggle();
+ $("#" + type + "-" + id + " .edit").toggle();
+ },
+ dataType: "json"
+ });
+ }
+
+
\ No newline at end of file
diff --git a/Layout/default/Network/Form.php b/Layout/default/Network/Form.php
index 242631406..55051113a 100644
--- a/Layout/default/Network/Form.php
+++ b/Layout/default/Network/Form.php
@@ -21,7 +21,7 @@
diff --git a/application/Address/AddressController.php b/application/Address/AddressController.php
index cdc1c8ee1..76696bde7 100644
--- a/application/Address/AddressController.php
+++ b/application/Address/AddressController.php
@@ -481,6 +481,7 @@ class AddressController extends mfBaseController {
}
$a = $address->toArray();
+ $a['name'] = $address->getCompanyOrName();
return ['address' => $a];
}
diff --git a/application/Api/v1/OperationaldataApicontroller.php b/application/Api/v1/OperationaldataApicontroller.php
new file mode 100644
index 000000000..6f99986ae
--- /dev/null
+++ b/application/Api/v1/OperationaldataApicontroller.php
@@ -0,0 +1,265 @@
+db(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
+ }
+
+ protected function registerRoutes()
+ {
+
+ /*
+ * TODO: Load Api Modules automatically in mfBaseApiController
+ */
+ /*$modules = [];
+ foreach (["Cif", "Activation"] as $moduleName) {
+ $classname = "application\\Api\\v1\\Modules\\Preorder\\" . $moduleName;
+ $modules[$moduleName] = new $classname([
+ "get" => $this->get,
+ "post" => $this->post,
+ "db" => $this->db(),
+ "me" => $this->me
+ ]);
+ }*/
+
+ $this->addRoute("/operationaldata/networks", "getNetworks", "GET");
+ $this->addRoute("/operationaldata/preordercampaigns", "getPreorderCampaigns", "GET");
+ $this->addRoute("/operationaldata/buildings", "getBuildingsByCampaign", "GET");
+
+ /*$this->addRoute("/preorder/open", "getOpenPreorders", "GET");
+ $this->addRoute("/preorder/customerInstallationFeedback", [$modules["Cif"], "getCifData"], "GET");
+ $this->addRoute("/preorder/customerInstallationFeedback", [$modules["Cif"], "userSetCif"], "POST");
+
+ $this->addRoute("/preorder/:code/clientInstallationFinished", [$modules["Cif"], "providerSetCif"], "POST");
+ $this->addRoute("/preorder/:code/serviceActivated", [$modules["Activation"], "setServiceActive"], "POST");
+ $this->addRoute("/preorder/:code", "getPreorder", "GET");
+ $this->addRoute("/preorder/:code", "cancelPreorder", "DELETE");
+ */
+
+ }
+
+ /*
+ * is called after User is authenticated by API Key
+ */
+ protected function authenticated()
+ {
+ $this->registerRoutes();
+
+ if ($this->me->is("preorderaddressreporting")) {
+ return mfResponse::Forbidden();
+ }
+
+ $campaignApiusers = PreordercampaignApiuserModel::search(["worker_id" => $this->me->id]);
+
+ foreach ($campaignApiusers as $campaignApiuser) {
+ $campaign = new Preordercampaign($campaignApiuser->preordercampaign_id);
+ if ($campaign->id) {
+ foreach (PreordercampaignSalesclusterModel::search(['preordercampaign_id' => $campaign->id]) as $campain_scluster) {
+ if (!in_array($campain_scluster->salescluster_id, $this->filter_salescluster_ids)) {
+ $this->filter_salescluster_ids[] = $campain_scluster->salescluster_id;
+ }
+
+ $this->campaigns_by_scluster[$campain_scluster->salescluster_id] = $campaign->id;
+
+ }
+ $this->campaigns[$campaign->id] = $campaign;
+
+ // get allowed preordertypes
+ if (is_array($campaign->types) && count($campaign->types)) {
+ foreach ($campaign->types as $type) {
+ $this->allowed_preordertypes[] = $type->type;
+ }
+ }
+
+ if ($campaign->district_is_city == 1) {
+ $this->district_is_city = true;
+ }
+ if ($campaign->hausnummer_add_zusatz == 1) {
+ $this->hausnummer_add_zusatz = true;
+ }
+ if ($campaign->exist_is_error == 1) {
+ $this->exist_is_error = true;
+ }
+ if ($campaign->require_connectiontype == 1) {
+ $this->require_connectiontype = true;
+ }
+ if ($campaign->allow_unit_update == 1) {
+ $this->allow_unit_update = true;
+ }
+ } else {
+ $this->log->debug(__METHOD__ . ": campaign not found (PreordercampaignApiuser::preordercampaign_id " . $campaignApiuser->preordercampaign_id . ")");
+ $this->log->debug(print_r($campaignApiuser, true));
+ }
+
+
+ foreach (PreordercampaignOriginhostnameModel::search(['preordercampaign_id' => $campaign->id]) as $origin) {
+ $this->addAllowedOrigin($origin->hostname);
+ }
+ }
+
+ $this->allowed_preordertypes = array_unique($this->allowed_preordertypes);
+ }
+
+ protected function getNetworks() {
+ $return = [];
+
+ $my_network_ids = [];
+
+ foreach($this->me->my_networks as $network) {
+ if($network->id && !in_array($network->id, $my_network_ids)) {
+ $my_network_ids[] = $network->id;
+ }
+ }
+
+ $networks = NetworkModel::search(["opsystem" => "snopp"]);
+
+ foreach($networks as $network) {
+ if(!in_array($network->id, $my_network_ids)) continue;
+
+ $name = $network->name;
+
+ if($network->adb_netzgebiet_id) {
+ $cityname = preg_replace('/^Liezen\s+-\s+/', '', $network->adb_netzgebiet->name);
+ $name = "ROC_".$network->adb_netzgebiet->extref."_".$cityname;
+ }
+
+ $net = [];
+ $net["id"] = $network->id;
+ $net["name"] = $name;
+ $net["created"] = $network->create;
+ $net["updated"] = $network->edit;
+ $return[] = $net;
+ }
+
+ return mfResponse::Ok(["networks" => $return]);
+ }
+
+ protected function getPreorderCampaigns() {
+ $return = [];
+
+ foreach($this->campaigns as $campaign) {
+ $c = [];
+ $c["id"] = $campaign->id;
+ $c["name"] = $campaign->name;
+ $c["created"] = $campaign->create;
+ $c["updated"] = $campaign->edit;
+ $return[] = $c;
+ }
+
+ return mfResponse::Ok(["preordercampaigns" => $return]);
+ }
+
+ protected function getBuildingsByCampaign() {
+ $buildings = [];
+
+ if(!array_key_exists("campaign_id", $this->get) || !$this->get["campaign_id"]) {
+ return mfResponse::BadRequest(["message" => "mandatory parameter campaign_id is missing."]);
+ }
+
+ $campaign_id = $this->get["campaign_id"];
+
+ if(!is_numeric($campaign_id) || $campaign_id < 1) {
+ return mfResponse::BadRequest(["message" => "Invalid value for campaign_id"]);
+ }
+
+ $campaign = new Preordercampaign($campaign_id);
+ if(!$campaign) {
+ return mfResponse::NotFound(["message" => "Network not found"]);
+ }
+
+ $adb_netzgebiet_id = $campaign->adb_netzgebiet->id;
+
+ if(!$adb_netzgebiet_id) {
+ return mfResponse::NotFound(["message" => "Network not found"]);
+ }
+
+ $db = $this->db(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
+
+ $sql = AddressDB::$wohneinheit_query;
+ $sql .= " WHERE Hausnummer.netzgebiet_id=$adb_netzgebiet_id AND Hausnummer.visibility = 'public'";
+
+ $res = $db->query($sql);
+ if(!$db->num_rows($res)) {
+ return mfResponse::Ok(["buildings" => []]);
+ }
+
+ $b = [];
+
+ while($data = $db->fetch_object($res)) {
+ if(!array_key_exists($data->hausnummer_id, $b)) {
+ $housenumber = $data->hausnummer;
+ if($this->hausnummer_add_zusatz) {
+ if($data->zusatz) {
+ $housenumber .= " (".$data->zusatz.")";
+ }
+ }
+
+ $b[$data->hausnummer_id] = [
+ 'id' => $data->hausnummer_id,
+ 'oaid' => $data->hausnummer_oaid,
+ 'cluster_id' => $data->netzgebiet_extref,
+ 'zip' => $data->plz,
+ 'city' => $data->gemeinde,
+ "municipality" => "",
+ 'district' => $data->ortschaft,
+ 'street' => $data->strasse,
+ 'housenumber' => $housenumber,
+ 'gps_lat' => ($data->gps_lat) ? (float)$data->gps_lat : null,
+ 'gps_long' => ($data->gps_long) ? (float)$data->gps_long : null,
+
+ "homes" => []
+ ];
+
+ if($this->district_is_city) {
+ $b[$data->hausnummer_id]['city'] = $data->ortschaft;
+ $b[$data->hausnummer_id]['municipality'] = $data->gemeinde;
+ } else {
+ unset($b[$data->hausnummer_id]['municipality']);
+ }
+ }
+
+ $b[$data->hausnummer_id]["homes"][] = [
+ 'id' => $data->wohneinheit_id,
+ 'oaid' => $data->wohneinheit_oaid,
+ 'num' => (int)$data->num,
+ 'block' => $data->block,
+ 'stiege' => $data->stiege,
+ 'stock' => $data->stock,
+ 'tuer' => $data->tuer,
+ 'zusatz' => $data->zusatz,
+ ];
+
+
+ }
+
+ /*foreach($b as $tmp_b) {
+ $homes = array_values($tmp_b["homes"]);
+ return mfResponse::Ok(["Homes" => $homes]);
+ unset($tmp_b["homes"]);
+ $tmp_b["homes"] = array_values($homes);
+ $buildings[] = $tmp_b;
+
+ }*/
+
+ $buildings = array_values($b);
+
+ return mfResponse::Ok(["buildings" => $buildings]);
+ }
+}
\ No newline at end of file
diff --git a/application/Api/v1/PreorderApicontroller.php b/application/Api/v1/PreorderApicontroller.php
index d5db00a6d..94c8c5041 100644
--- a/application/Api/v1/PreorderApicontroller.php
+++ b/application/Api/v1/PreorderApicontroller.php
@@ -156,7 +156,7 @@ class PreorderApicontroller extends mfBaseApicontroller {
foreach(PreorderModel::searchActive($preorder_search) as $preorder) {
$return[] = $preorder->getApiArray();
}
-
+ $this->requestLog->debug(print_r($return, true));
return mfResponse::Ok(["preorders" => $return]);
}
diff --git a/application/Contractqueue/Contractqueue.php b/application/Contractqueue/Contractqueue.php
index a802df0f0..4c2b2b0b4 100644
--- a/application/Contractqueue/Contractqueue.php
+++ b/application/Contractqueue/Contractqueue.php
@@ -13,7 +13,20 @@ class Contractqueue extends mfBaseModel {
private $sla;
private $creator;
private $editor;
-
+
+ protected function afterSave() {
+ $this->crediting_partner = null;
+ $this->reseller = null;
+ $this->owner = null;
+ $this->billingaddress = null;
+ $this->product = null;
+ $this->orderproduct = null;
+ $this->termination = null;
+ $this->sla = null;
+ $this->creator = null;
+ $this->editor = null;
+ }
+
public function generateMatchcode() {
$owner_address = $this->getProperty("owner")->street.", ".$this->getProperty("owner")->zip." ".$this->getProperty("owner")->city;
diff --git a/application/Contractqueue/ContractqueueController.php b/application/Contractqueue/ContractqueueController.php
index d087c805a..6a24934df 100644
--- a/application/Contractqueue/ContractqueueController.php
+++ b/application/Contractqueue/ContractqueueController.php
@@ -29,7 +29,7 @@ class ContractqueueController extends mfBaseController {
}
}
- $this->layout->set("filter", $filter);
+ $this->layout->set("filter", array_map(fn($a) => htmlentities($a), $filter));
$filter = $this->getPreparedFilter($filter);
// pagination defaults
@@ -67,7 +67,7 @@ class ContractqueueController extends mfBaseController {
}
protected function getPreparedFilter($filter) {
-
+
return $filter;
}
@@ -108,7 +108,6 @@ class ContractqueueController extends mfBaseController {
var_dump($product_attribs);exit;
}*/
if(is_array($product_attribs) && array_key_exists("crediting_partner", $product_attribs) && $product_attribs["crediting_partner"] && is_object($product_attribs["crediting_partner"])) {
-
if($product_attribs["crediting_partner"]->value) {
$contract->crediting_partner_id = $product_attribs["crediting_partner"]->value;
}
@@ -124,6 +123,7 @@ class ContractqueueController extends mfBaseController {
if($contract->matchcode) {
$primary_matchcode = $contract->matchcode;
}
+ $contract->crediting_matchcode = $order->owner->getCompanyOrName().", ".$order->owner->street.", ".$order->owner->zip." ".$order->owner->city;
$contracts[] = $contract;
}
@@ -168,4 +168,140 @@ class ContractqueueController extends mfBaseController {
$this->layout()->setFlash("Alle Bestellungen importiert", "success");
$this->redirect("Contractqueue");
}
+
+ protected function apiAction() {
+ if(!$this->me->is(["Admin"])) {
+ $this->redirect("Dashboard");
+ }
+ $do = $this->request->do;
+ $data = [];
+
+ switch($do) {
+ case "saveContract":
+ $return = $this->saveContractApi();
+ break;
+ default:
+ $return = false;
+ }
+
+ if(!is_array($return) || !count($return)) {
+ $data = ["status" => "error"];
+ $this->returnJson($data);
+ }
+ $data['status'] = "OK";
+ $data['result'] = $return;
+ $this->returnJson($data);
+ }
+
+ private function saveContractApi() {
+ $r = $this->request;
+
+ $valid_fields = [
+ "product" => "product_id",
+ "matchcode" => "matchcode",
+ "price" => "price",
+ "price_setup" => "price_setup",
+ "billing_period" => "billing_period",
+ "billing_delay" => "billing_delay"
+ ];
+
+ $data = [];
+ foreach($r->get() as $f => $v) {
+ if(array_key_exists($f, $valid_fields)) {
+ $data[$valid_fields[$f]] = $v;
+ }
+ }
+
+ if(!count($data)) {
+ return false;
+ }
+
+ $cq = new Contractqueue($r->id);
+ if(!$cq->id) {
+ return false;
+ }
+
+ if(array_key_exists("product_id", $data)) {
+ $product = new Product($data["product_id"]);
+ if(!$product->id) {
+ $this->log->error(__METHOD__.": neue product_id nicht gefunden");
+ return false;
+ }
+ $data["product_name"] = $product->name;
+ }
+
+ $cq->update($data);
+ if(!$cq->save()) {
+ return false;
+ }
+ //var_dump($cq->product, $cq->product->attributes);exit;
+ // find reseller / receiver of credit
+ // from product
+ $product_attribs = $cq->product->attributes;
+ /*if($op->id == "8666") {
+ var_dump($product_attribs);exit;
+ }*/
+
+ $cq->crediting_partner_id = null;
+ $cq->crediting_partner_rate = null;
+
+ if(is_array($product_attribs) && array_key_exists("crediting_partner", $product_attribs) && $product_attribs["crediting_partner"] && is_object($product_attribs["crediting_partner"])) {
+ if($product_attribs["crediting_partner"]->value && $product_attribs["crediting_partner"]->value != $cq->crediting_partner_id) {
+ $cq->crediting_partner_id = $product_attribs["crediting_partner"]->value;
+ }
+ if($product_attribs["crediting_rate"]->value) {
+ $crediting_rate_price = round($cq->price / 100 * $product_attribs["crediting_rate"]->value, 4);
+ if($crediting_rate_price != $cq->crediting_partner_rate) {
+ $cq->crediting_partner_rate = $crediting_rate_price;
+ }
+
+ }
+ }
+ // or from netowner if anschluss product
+ if(!$cq->crediting_partner_id && $cq->termination_id && $cq->product->price_nne > 0) {
+ $cq->crediting_partner_id = $cq->termination->building->network->owner_id;
+ }
+
+ if(!$cq->save()) {
+ return false;
+ }
+
+ $return = [];
+ $return["product"] = $cq->product_id;
+ $return["product_name"] = $cq->product->name;
+ $return["termination"] = ($cq->termination_id) ? $cq->termination->code." ".str_replace("\n", " - ", $cq->termination->getAddress()) : null;
+ $return["matchcode"] = $cq->matchcode;
+ $return["price"] = $cq->price;
+ $return["price_setup"] = $cq->price_setup;
+ $return["billing_period"] = $cq->billing_period;
+ $return["billing_delay"] = $cq->billing_delay;
+
+ $credit = [];
+ $credit["crediting_rate"] = null;
+ $credit["crediting_partner_id"] = $cq->crediting_partner_id;
+ $credit["crediting_partner_name"] = "";
+ $credit["crediting_rate"] = 0;
+ $credit["crediting_matchcode"] = "";
+
+
+ if($cq->crediting_partner_id) {
+ $credit["crediting_partner_name"] = $cq->crediting_partner->getCompanyOrName();
+
+ if($cq->crediting_partner_rate) {
+ $credit["crediting_rate"] = $cq->crediting_partner_rate;
+ $credit["crediting_partner_name"] = "€ ".number_format($cq->crediting_partner_rate, 4, ",",".")." (Prozentrate)";
+ } else {
+ $credit["crediting_rate"] = $cq->price_nne;
+ $credit["crediting_partner_name"] = "€ ".number_format($cq->crediting_partner_rate, 4, ",",".")." (NNE)";
+ }
+
+ $credit["crediting_matchcode"] = $cq->crediting_matchcode;
+ }
+
+
+
+
+ return ["contract" => $return, "credit" => $credit];
+
+ }
}
\ No newline at end of file
diff --git a/application/Contractqueue/ContractqueueModel.php b/application/Contractqueue/ContractqueueModel.php
index d17e4cf9a..36187379d 100644
--- a/application/Contractqueue/ContractqueueModel.php
+++ b/application/Contractqueue/ContractqueueModel.php
@@ -14,6 +14,7 @@ class ContractqueueModel {
public $product_name;
public $product_info;
public $matchcode;
+ public $crediting_matchcode;
public $amount;
public $sla_id = null;
public $product_external;
diff --git a/application/Network/NetworkController.php b/application/Network/NetworkController.php
index 93334f73b..16b612486 100644
--- a/application/Network/NetworkController.php
+++ b/application/Network/NetworkController.php
@@ -76,6 +76,7 @@ class NetworkController extends mfBaseController {
$data['name'] = $r->name;
$data['note'] = $r->note;
$data['adb_netzgebiet_id'] = ($r->adb_netzgebiet_id) ? $r->adb_netzgebiet_id : null;
+ $data['opsystem'] = ($r->opsystem === "snopp") ? "snopp" : null;
if($r->sytemowner_action_status) {
$data['sytemowner_action_status'] = $r->sytemowner_action_status;
diff --git a/application/Network/NetworkModel.php b/application/Network/NetworkModel.php
index 52931ca89..b2aefe54a 100644
--- a/application/Network/NetworkModel.php
+++ b/application/Network/NetworkModel.php
@@ -4,6 +4,7 @@ class NetworkModel {
public $name;
public $owner_id ;
public $adb_netzgebiet_id;
+ public $opsystem;
public $sytemowner_action_status;
public $note;
@@ -141,6 +142,13 @@ class NetworkModel {
$where .= " AND adb_netzgebiet_id IN (". implode(",", $adb_netzgebiet_id).")";
}
}
+
+ if(array_key_exists("opsystem", $filter)) {
+ $opsystem = FronkDB::singleton()->escape($filter['opsystem']);
+ if($opsystem) {
+ $where .= " AND Network.`opsystem` = '$opsystem'";
+ }
+ }
diff --git a/db/migrations/20240125122644_create_contractqueue.php b/db/migrations/20240125122644_create_contractqueue.php
index d41bb098c..e0306575a 100644
--- a/db/migrations/20240125122644_create_contractqueue.php
+++ b/db/migrations/20240125122644_create_contractqueue.php
@@ -10,9 +10,14 @@ final class CreateContractqueue extends AbstractMigration
if($this->getEnvironment() == "thetool") {
$table = $this->table("Contractqueue");
$table->addColumn("approved", "integer", ["null" => false, "default" => 0]);
+ $table->addColumn("approved_credit", "integer", ["null" => false, "default" => 0]);
$table->addColumn("contract_id", "integer", ["null" => true, "default" => null]);
$table->addColumn("order_id", "integer", ["null" => false]);
$table->addColumn("orderproduct_id", "integer", ["null" => true, "default" => null]);
+ $table->addColumn("crediting_partner_id", "integer", ["null" => true, "default" => null]);
+ $table->addColumn("crediting_partner_rate", "decimal", ["null" => true, "default" => null, "precision" => 10, "scale" => 4]);
+ $table->addColumn("reseller_id", "integer", ["null" => true, "default" => null]);
+ $table->addColumn("reseller_rate", "decimal", ["null" => true, "default" => null, "precision" => 10, "scale" => 4]);
$table->addColumn("owner_id", "integer", ["null" => false]);
$table->addColumn("billingaddress_id", "integer", ["null" => true, "default" => null]);
$table->addColumn("termination_id", "integer", ["null" => true, "default" => null]);
@@ -20,6 +25,7 @@ final class CreateContractqueue extends AbstractMigration
$table->addColumn("product_name", "string", ["null" => false, "limit" => 255]);
$table->addColumn("product_info", "text", ["null" => true, "default" => null]);
$table->addColumn("matchcode", "string", ["null" => true, "default" => null, "limit" => 255]);
+ $table->addColumn("crediting_matchcode", "string", ["null" => true, "default" => null, "limit" => 255]);
$table->addColumn("amount", "decimal", ["null" => false, "precision" => 9, "scale" => 6]);
$table->addColumn("sla_id", "integer", ["null" => true, "default" => null]);
$table->addColumn("product_external", "integer", ["null" => false, "default" => 0, "limit" => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY]);
@@ -30,6 +36,7 @@ final class CreateContractqueue extends AbstractMigration
$table->addColumn("price_nbe", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]);
$table->addColumn("billing_delay", "integer", ["null" => false, "default" => 0]);
$table->addColumn("billing_period", "integer", ["null" => false, "default" => 1]);
+ $table->addColumn("contract_term", "integer", ["null" => false, "default" => 12]);
$table->addColumn("order_date", "integer", ["null" => true, "default" => null]);
$table->addColumn("finish_date", "integer", ["null" => true, "default" => null]);
$table->addColumn("finish_date_by", "integer", ["null" => true, "default" => null]);
diff --git a/db/migrations/20240402170133_network_add_opsystem.php b/db/migrations/20240402170133_network_add_opsystem.php
new file mode 100644
index 000000000..068f497ed
--- /dev/null
+++ b/db/migrations/20240402170133_network_add_opsystem.php
@@ -0,0 +1,31 @@
+getEnvironment() == "thetool") {
+ $table = $this->table("Network");
+ $table->addColumn("opsystem", "enum", ["null" => true, "default" => null, "values" => "snopp", "after" => "adb_netzgebiet_id"]);
+ $table->update();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+
+ public function down(): void
+ {
+ if($this->getEnvironment() == "thetool") {
+ $this->table("Network")->removeColumn("opsystem")->update();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+}
diff --git a/lib/mvcfronk/mfBase/mfBaseApicontroller.php b/lib/mvcfronk/mfBase/mfBaseApicontroller.php
index d69b7a91a..e404a85ba 100644
--- a/lib/mvcfronk/mfBase/mfBaseApicontroller.php
+++ b/lib/mvcfronk/mfBase/mfBaseApicontroller.php
@@ -103,7 +103,7 @@ class mfBaseApicontroller {
private function logRequest() {
$this->requestLog->debug("==================================================================");
- $this->requestLog->debug("new API request for ".$_SERVER['REQUEST_URI']. " from ".$_SERVER['REMOTE_ADDR']);
+ $this->requestLog->debug("new API request: ".$_SERVER['REQUEST_METHOD']." ".$_SERVER['REQUEST_URI']. " from ".$_SERVER['REMOTE_ADDR']);
$this->requestLogstr = "";
foreach($_GET as $key => $value) {
$this->requestLogstr .= "; $key='$value'";
@@ -157,6 +157,7 @@ class mfBaseApicontroller {
foreach(apache_request_headers() as $header => $value) {
$this->headers[strtolower($header)] = $value;
}
+
// GET parameters
$get = $params;
unset($get['mod']);