added new adb dashboard
This commit is contained in:
@@ -34,6 +34,7 @@ class ADBHausnummerModel {
|
||||
public $manual_update_by;
|
||||
public $manual_update_info;
|
||||
public $rimo_id;
|
||||
public $rimo_type;
|
||||
public $rimo_ex_state;
|
||||
public $rimo_op_state;
|
||||
public $rimo_fcp_name;
|
||||
@@ -111,13 +112,15 @@ class ADBHausnummerModel {
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM (
|
||||
|
||||
|
||||
public static function count($filter, $join_tables = true) {
|
||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
|
||||
if ($join_tables) {
|
||||
$sql = "SELECT COUNT(*) as cnt FROM (
|
||||
SELECT Hausnummer.id FROM Hausnummer
|
||||
LEFT JOIN Ortschaft ON (Ortschaft.id = Hausnummer.ortschaft_id)
|
||||
LEFT JOIN Gemeinde ON (Gemeinde.id = Ortschaft.gemeinde_id)
|
||||
@@ -125,21 +128,43 @@ class ADBHausnummerModel {
|
||||
LEFT JOIN Plz ON (Hausnummer.plz_id = Plz.id)
|
||||
LEFT JOIN HausnummerStatusflagValue ON (HausnummerStatusflagValue.hausnummer_id = Hausnummer.id)
|
||||
WHERE $where
|
||||
GROUP BY Hausnummer.id
|
||||
) hn
|
||||
";
|
||||
) hn";
|
||||
} else $sql = "SELECT COUNT(*) as cnt FROM Hausnummer WHERE $where";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function search($filter, $limit = false, $returnDBRessource = false) {
|
||||
|
||||
public static function countHomes($filter) {
|
||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
|
||||
$sql = "SELECT COUNT(Wohneinheit.id) as cnt
|
||||
FROM Hausnummer
|
||||
LEFT JOIN Wohneinheit ON (Wohneinheit.hausnummer_id = Hausnummer.id)
|
||||
WHERE $where";
|
||||
|
||||
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 search($filter, $limit = false, $returnDBRessource = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
@@ -436,6 +461,29 @@ class ADBHausnummerModel {
|
||||
$where .= " AND HausnummerStatusflagValue.flag_id = $status_flag AND HausnummerStatusflagValue.value=1";
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists("rimo_type", $filter)) {
|
||||
$rimo_type = $filter['rimo_type'];
|
||||
$where .= is_array($rimo_type)
|
||||
? " AND Hausnummer.rimo_type IN ('" . implode("', '", $rimo_type) . "')"
|
||||
: " AND Hausnummer.rimo_type = '$rimo_type'";
|
||||
}
|
||||
|
||||
if (array_key_exists("rimo_ex_state", $filter)) {
|
||||
$rimo_ex_state = $filter['rimo_ex_state'];
|
||||
$where .= is_array($rimo_ex_state)
|
||||
? " AND Hausnummer.rimo_ex_state IN ('" . implode("', '", $rimo_ex_state) . "')"
|
||||
: " AND Hausnummer.rimo_ex_state = '$rimo_ex_state'";
|
||||
}
|
||||
|
||||
if (array_key_exists("rimo_op_state", $filter)) {
|
||||
$rimo_op_state = $filter['rimo_op_state'];
|
||||
$where .= is_array($rimo_op_state)
|
||||
? " AND Hausnummer.rimo_op_state IN ('" . implode("', '", $rimo_op_state) . "')"
|
||||
: " AND Hausnummer.rimo_op_state = '$rimo_op_state'";
|
||||
}
|
||||
|
||||
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
|
||||
@@ -22,6 +22,18 @@ class DashboardNewController extends mfBaseController {
|
||||
Helper::renderVue($this, $this->mod, "Dashboard", ["IS_ADMIN" => $this->me->is("Admin") ? "true" : "false"]);
|
||||
}
|
||||
|
||||
protected function adbAction() {
|
||||
if (!$this->me->can("Statistics") || !$this->me->is(["Admin", "netowner", "salespartner"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
|
||||
if (!$this->me->is("Admin")) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
|
||||
Helper::renderVue($this, "DashboardAdb", "Dashboard ADB", ["IS_ADMIN" => $this->me->is("Admin") ? "true" : "false"]);
|
||||
}
|
||||
|
||||
|
||||
protected function getNetOwnerFilterOptionsAction() {
|
||||
$allPreorderCampaigns = PreordercampaignModel::getAll();
|
||||
@@ -43,6 +55,20 @@ class DashboardNewController extends mfBaseController {
|
||||
self::returnJson($netowners);
|
||||
}
|
||||
|
||||
protected function getNetworkFilterOptionsAction() {
|
||||
$netowners = [];
|
||||
$allNetworks = ADBNetzgebietModel::getAll();
|
||||
foreach ($allNetworks as $network) {
|
||||
if (!$this->me->is("Admin") && $network->owner_id != $this->me->address_id) continue;
|
||||
|
||||
if (!in_array($network->id, array_column($netowners, 'value'))) {
|
||||
$netowners[] = ['text' => $network->name, 'value' => $network->id];
|
||||
}
|
||||
}
|
||||
|
||||
self::returnJson($netowners);
|
||||
}
|
||||
|
||||
protected function getCampaignFilterOptionsAction() {
|
||||
$post = json_decode(file_get_contents('php://input'), true);
|
||||
$netowner_ids = isset($post['netOwners']) ? [$post['netOwners']] : [];
|
||||
@@ -460,4 +486,55 @@ class DashboardNewController extends mfBaseController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function getDashboardAddressDBDataAction() {
|
||||
if (!$this->me->is("Admin")) self::sendError("Keine Berechtigung");
|
||||
$baseFilter = [];
|
||||
|
||||
if (!empty($str = $this->request->netzgebiet_id)) $baseFilter["netzgebiet_id"] = $this->request->netzgebiet_id;
|
||||
|
||||
$sum_counts = [
|
||||
"sum" => ADBHausnummerModel::count(array_merge($baseFilter, ["is_deleted" => 0]), false),
|
||||
"sum_homes" => ADBHausnummerModel::countHomes(array_merge($baseFilter, ["is_deleted" => 0])),
|
||||
"op_state_planned" => ADBHausnummerModel::count(array_merge($baseFilter, ["is_deleted" => 0, "rimo_op_state" => "Planned"]), false),
|
||||
"op_state_passed" => ADBHausnummerModel::count(array_merge($baseFilter, ["is_deleted" => 0, "rimo_op_state" => "Passed"]), false),
|
||||
"op_state_connected" => ADBHausnummerModel::count(array_merge($baseFilter, ["is_deleted" => 0, "rimo_op_state" => "Connected"]), false),
|
||||
];
|
||||
|
||||
$efh_rimo_types = ["residential", "company", "2/3 familienhaus", "public"];
|
||||
|
||||
$efh_counts = [
|
||||
"sum" => ADBHausnummerModel::count(array_merge($baseFilter, ["is_deleted" => 0, "rimo_type" => $efh_rimo_types]), false),
|
||||
"sum_homes" => ADBHausnummerModel::countHomes(array_merge($baseFilter, ["is_deleted" => 0, "rimo_type" => $efh_rimo_types])),
|
||||
"op_state_planned" => ADBHausnummerModel::count(array_merge($baseFilter, ["is_deleted" => 0, "rimo_op_state" => "Planned", "rimo_type" => $efh_rimo_types]), false),
|
||||
"op_state_passed" => ADBHausnummerModel::count(array_merge($baseFilter, ["is_deleted" => 0, "rimo_op_state" => "Passed", "rimo_type" => $efh_rimo_types]), false),
|
||||
"op_state_connected" => ADBHausnummerModel::count(array_merge($baseFilter, ["is_deleted" => 0, "rimo_op_state" => "Connected", "rimo_type" => $efh_rimo_types]), false),
|
||||
];
|
||||
|
||||
$mph_rimo_types = ["multiple dwellings"];
|
||||
|
||||
$mph_counts = [
|
||||
"sum" => ADBHausnummerModel::count(array_merge($baseFilter, ["is_deleted" => 0, "rimo_type" => $mph_rimo_types]), false),
|
||||
"sum_homes" => ADBHausnummerModel::countHomes(array_merge($baseFilter, ["is_deleted" => 0, "rimo_type" => $mph_rimo_types])),
|
||||
"op_state_planned" => ADBHausnummerModel::count(array_merge($baseFilter, ["is_deleted" => 0, "rimo_op_state" => "Planned", "rimo_type" => $mph_rimo_types]), false),
|
||||
"op_state_passed" => ADBHausnummerModel::count(array_merge($baseFilter, ["is_deleted" => 0, "rimo_op_state" => "Passed", "rimo_type" => $mph_rimo_types]), false),
|
||||
"op_state_connected" => ADBHausnummerModel::count(array_merge($baseFilter, ["is_deleted" => 0, "rimo_op_state" => "Connected", "rimo_type" => $mph_rimo_types]), false),
|
||||
];
|
||||
|
||||
$other_types = [
|
||||
"type_greenfield" => ADBHausnummerModel::count(array_merge($baseFilter, ["is_deleted" => 0, "rimo_type" => "greenfield"]), false),
|
||||
"type_greenfield_homes" => ADBHausnummerModel::countHomes(array_merge($baseFilter, ["is_deleted" => 0, "rimo_type" => "greenfield"])),
|
||||
"type_transformer_station" => ADBHausnummerModel::count(array_merge($baseFilter, ["is_deleted" => 0, "rimo_type" => "transformer station"]), false),
|
||||
"type_transformer_station_homes" => ADBHausnummerModel::countHomes(array_merge($baseFilter, ["is_deleted" => 0, "rimo_type" => "transformer station"])),
|
||||
"type_others" => ADBHausnummerModel::count(array_merge($baseFilter, ["is_deleted" => 0, "rimo_type" => "other"]), false),
|
||||
"type_others_homes" => ADBHausnummerModel::countHomes(array_merge($baseFilter, ["is_deleted" => 0, "rimo_type" => "other"])),
|
||||
];
|
||||
|
||||
self::returnJson([
|
||||
"sum_counts" => $sum_counts,
|
||||
"efh_counts" => $efh_counts,
|
||||
"mph_counts" => $mph_counts,
|
||||
"other_types" => $other_types
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user