Merge branch 'master' into fronkdev
This commit is contained in:
@@ -348,6 +348,7 @@ class CalendarController extends mfBaseController
|
||||
'text' => $value->customer_number . " " . $text . " - " . $value->street . ", " . $value->zip . " " . $value->city,
|
||||
'mail' => $value->email,
|
||||
'mobilenumber' => $mobilenumber,
|
||||
'spin' => $value->spin,
|
||||
'location' => $value->street . ", " . $value->zip . " " . $value->city,
|
||||
'name' => $value->customer_number . " " . $text
|
||||
);
|
||||
|
||||
@@ -47,6 +47,7 @@ class CalendarModel
|
||||
3 => 'Grüne Kategorie', //ESTMK IBN
|
||||
4 => 'Lila Kategorie', //Snopp IBN
|
||||
5 => 'Rote Kategorie', //Störung
|
||||
6 => 'Rote Kategorie', //Störung
|
||||
98 => 'Gru00fcne Kategorie', //ESTMK IBN
|
||||
99 => 'Gr\u00fcne Kategorie', //ESTMK IBN
|
||||
);
|
||||
|
||||
@@ -154,7 +154,7 @@ class ConstructionConsent extends mfBaseModel {
|
||||
}
|
||||
return $this->adb_hausnummer;
|
||||
}
|
||||
|
||||
|
||||
if($name == "adb_strasse") {
|
||||
if(!$this->adb_strasse_id) return null;
|
||||
$strasse = new ADBStrasse($this->adb_strasse_id);
|
||||
@@ -307,7 +307,7 @@ class ConstructionConsent extends mfBaseModel {
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
|
||||
/********************************
|
||||
* Begin static Model functions
|
||||
*/
|
||||
@@ -339,7 +339,7 @@ class ConstructionConsent extends mfBaseModel {
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
@@ -377,37 +377,45 @@ class ConstructionConsent extends mfBaseModel {
|
||||
}
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM ConstructionConsent
|
||||
LEFT JOIN ".ADDRESSDB_DBNAME.".view_hausnummer ON (ConstructionConsent.adb_hausnummer_id = view_hausnummer.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;
|
||||
return self::search($filter, false, false, true);
|
||||
}
|
||||
|
||||
public static function search($filter, $limit = false, $order = false) {
|
||||
//var_dump($filter);exit;
|
||||
public static function search($filter, $limit = false, $order = false, $returnCount = false) {
|
||||
$items = [];
|
||||
|
||||
if(!$order) {
|
||||
$order = "adb_hausnummer_id ASC";
|
||||
}
|
||||
$having = '';
|
||||
if(array_key_exists("status_light", $filter) && strlen(trim($filter['status_light'])) > 2) {
|
||||
$having = " HAVING status_light = '".$filter['status_light']."'";
|
||||
}
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM ConstructionConsent
|
||||
LEFT JOIN ".ADDRESSDB_DBNAME.".view_hausnummer ON (ConstructionConsent.adb_hausnummer_id = view_hausnummer.hausnummer_id)
|
||||
$sql = "SELECT
|
||||
ConstructionConsent.*,
|
||||
COALESCE(SUM(cwo.result = 'denied'), 0) AS denied_count,
|
||||
COALESCE(SUM(cwo.result = 'unresolvable'), 0) AS unresolvable_count,
|
||||
COALESCE(SUM(cwo.result = 'moved'), 0) AS moved_count,
|
||||
COALESCE(SUM(cwo.result = 'accepted'), 0) AS accepted_count,
|
||||
COUNT(cwo.id) AS total_owners,
|
||||
CASE
|
||||
WHEN COALESCE(SUM(cwo.result = 'denied'), 0) > 0 THEN 'red'
|
||||
WHEN COALESCE(SUM(cwo.result = 'unresolvable'), 0) > 0
|
||||
OR COALESCE(SUM(cwo.result = 'moved'), 0) > 0 THEN 'yellow'
|
||||
WHEN COALESCE(SUM(cwo.result = 'accepted'), 0) = COUNT(cwo.id)
|
||||
AND COUNT(cwo.id) > 0 THEN 'green'
|
||||
ELSE 'blue'
|
||||
END AS status_light
|
||||
FROM ConstructionConsent
|
||||
LEFT JOIN ConstructionConsentOwner cwo ON ConstructionConsent.id = cwo.constructionconsent_id
|
||||
LEFT JOIN addressdb.view_hausnummer vh ON ConstructionConsent.adb_hausnummer_id = vh.hausnummer_id
|
||||
LEFT JOIN addressdb.Strasse vs ON ConstructionConsent.adb_strasse_id = vs.id
|
||||
WHERE $where
|
||||
GROUP BY ConstructionConsent.id
|
||||
$having
|
||||
ORDER BY $order";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
@@ -418,16 +426,15 @@ class ConstructionConsent extends mfBaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
if ($returnCount) return $db->num_rows($res);
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[$data->id] = new ConstructionConsent($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
return $returnCount ? 0 : $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter) {
|
||||
@@ -439,7 +446,7 @@ class ConstructionConsent extends mfBaseModel {
|
||||
$where .= " AND ConstructionConsent.constructionconsentproject_id=$project_id";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists("constructionconsentproject_id", $filter)) {
|
||||
$constructionconsentproject_id = $filter['constructionconsentproject_id'];
|
||||
if(is_numeric($constructionconsentproject_id)) {
|
||||
@@ -475,20 +482,34 @@ class ConstructionConsent extends mfBaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("gst", $filter)) {
|
||||
$gst = FronkDB::singleton()->escape($filter["gst"]);
|
||||
if($gst) {
|
||||
$where .= " AND gst LIKE '%$gst%'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("address", $filter)) {
|
||||
$address = FronkDB::singleton()->escape($filter["address"]);
|
||||
if($address) {
|
||||
$where .= " AND (vs.name LIKE '%$address%' OR vh.strasse LIKE '%$address%' OR vh.hausnummer LIKE '%$address%' OR vh.plz LIKE '%$address%' OR vh.ortschaft LIKE '%$address%' OR vh.gemeinde LIKE '%$address%')";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("status", $filter)) {
|
||||
$status = FronkDB::singleton()->escape($filter["status"]);
|
||||
if($status) {
|
||||
$where .= " AND status='$status'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists("result", $filter)) {
|
||||
$result = FronkDB::singleton()->escape($filter["result"]);
|
||||
if($result) {
|
||||
$where .= " AND result='$result'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists("owner_name", $filter)) {
|
||||
$owner_name = FronkDB::singleton()->escape($filter["owner_name"]);
|
||||
if($owner_name) {
|
||||
@@ -527,7 +548,43 @@ class ConstructionConsent extends mfBaseModel {
|
||||
if(array_key_exists("network", $filter)) {
|
||||
$network = FronkDB::singleton()->escape($filter["network"]);
|
||||
if($network) {
|
||||
$where .= " AND view_hausnummer.netzgebiet_id=$network";
|
||||
$where .= " AND vh.netzgebiet_id=$network";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("inspection_planner", $filter)) {
|
||||
$inspection_planner = $filter["inspection_planner"];
|
||||
if($inspection_planner == "!NULL") {
|
||||
$where .= " AND inspection_planner IS NOT NULL";
|
||||
} elseif($inspection_planner == "NULL") {
|
||||
$where .= " AND inspection_planner IS NULL";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("conduit_installed_building", $filter)) {
|
||||
$conduit_installed_building = $filter["conduit_installed_building"];
|
||||
if($conduit_installed_building == "!NULL") {
|
||||
$where .= " AND conduit_installed_building IS NOT NULL";
|
||||
} elseif($conduit_installed_building == "NULL") {
|
||||
$where .= " AND conduit_installed_building IS NULL";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("conduit_installed_ftu", $filter)) {
|
||||
$conduit_installed_ftu = $filter["conduit_installed_ftu"];
|
||||
if($conduit_installed_ftu == "!NULL") {
|
||||
$where .= " AND conduit_installed_ftu IS NOT NULL";
|
||||
} elseif($conduit_installed_ftu == "NULL") {
|
||||
$where .= " AND conduit_installed_ftu IS NULL";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("inhouse_cabling", $filter)) {
|
||||
$inhouse_cabling = $filter["inhouse_cabling"];
|
||||
if($inhouse_cabling == "!NULL") {
|
||||
$where .= " AND inhouse_cabling IS NOT NULL";
|
||||
} elseif($inhouse_cabling == "NULL") {
|
||||
$where .= " AND inhouse_cabling IS NULL";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ class ConstructionConsentController extends mfBaseController {
|
||||
|
||||
$items = ConstructionConsent::search($filter, $pagination);
|
||||
$this->layout->set("items", $items);
|
||||
$this->layout()->set("stats", $this->generateStats($filter));
|
||||
|
||||
if(array_key_exists("project_id", $filter) && $filter["project_id"]) {
|
||||
$project = new ConstructionConsentProject($filter["project_id"]);
|
||||
@@ -936,4 +937,40 @@ class ConstructionConsentController extends mfBaseController {
|
||||
|
||||
return ["message" => "ConstructionConsent saved successfully"];
|
||||
}
|
||||
}
|
||||
|
||||
private function generateStats($baseFilter = array()) {
|
||||
function getFilteredCount($wantedFilter, $filterValue, $baseFilter) {
|
||||
if (!empty($baseFilter[$wantedFilter]) && $baseFilter[$wantedFilter] != $filterValue) {
|
||||
return 0;
|
||||
} else {
|
||||
return ConstructionConsent::count(array_merge($baseFilter, [$wantedFilter => $filterValue]));
|
||||
}
|
||||
}
|
||||
|
||||
$allCount = ConstructionConsent::count($baseFilter);
|
||||
$streetCount = getFilteredCount("object_type", "street", $baseFilter);
|
||||
$buildingCount = getFilteredCount("object_type", "building", $baseFilter);
|
||||
$inspection_planner = getFilteredCount("inspection_planner", "!NULL", $baseFilter);
|
||||
$conduit_installed_building = getFilteredCount("conduit_installed_building", "!NULL", $baseFilter);
|
||||
$conduit_installed_ftu = getFilteredCount("conduit_installed_ftu", "!NULL", $baseFilter);
|
||||
$inhouse_cabling = getFilteredCount("inhouse_cabling", "!NULL", $baseFilter);
|
||||
$status_light_blue = getFilteredCount("status_light", "blue", $baseFilter);
|
||||
$status_light_red = getFilteredCount("status_light", "red", $baseFilter);
|
||||
$status_light_yellow = getFilteredCount("status_light", "yellow", $baseFilter);
|
||||
$status_light_green = getFilteredCount("status_light", "green", $baseFilter);
|
||||
|
||||
return array(
|
||||
"all" => $allCount,
|
||||
"street" => $streetCount,
|
||||
"building" => $buildingCount,
|
||||
"inspection_planner" => $inspection_planner,
|
||||
"conduit_installed_building" => $conduit_installed_building,
|
||||
"conduit_installed_ftu" => $conduit_installed_ftu,
|
||||
"inhouse_cabling" => $inhouse_cabling,
|
||||
"status_light_blue" => $status_light_blue,
|
||||
"status_light_red" => $status_light_red,
|
||||
"status_light_yellow" => $status_light_yellow,
|
||||
"status_light_green" => $status_light_green
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,6 +270,14 @@ class DashboardNewController extends mfBaseController {
|
||||
$timeline_ont_installiert_300[0][$key]['value'] += $ont_installiert_300_base_value_before_history;
|
||||
}
|
||||
|
||||
$provider_bestellt_500 = $countFunction([">status_code" => "499", "<status_code" => "899"]);
|
||||
$timeline_provider_bestellt_500 = $this->getTimeline('weekly-provider-bestellt', $campaign_ids, $gemeinde_ids);
|
||||
$provider_bestellt_500_base_value_before_history = $provider_bestellt_500 - $timeline_provider_bestellt_500[0][count($timeline_provider_bestellt_500[0]) - 1]['value'];
|
||||
|
||||
foreach ($timeline_provider_bestellt_500[0] as $key => $value) {
|
||||
$timeline_provider_bestellt_500[0][$key]['value'] += $provider_bestellt_500_base_value_before_history;
|
||||
}
|
||||
|
||||
self::returnJson([
|
||||
'type' => 'default',
|
||||
'order_max_home_addrdb' => $order_max_homes,
|
||||
@@ -289,10 +297,11 @@ class DashboardNewController extends mfBaseController {
|
||||
'ont_installiert_300' => $ont_installiert_300,
|
||||
'vollanschluss_dokumentiert_350' => $countFunction(["status_code" => ["350","500"], "type" => "order"]),
|
||||
'vorsorge_dokumentiert_351' => $countFunction(["status_code" => ["351","500"], "type" => "provision"]),
|
||||
'provider_bestellt_500' => $countFunction(["status_code" => "500"]),
|
||||
'provider_bestellt_500' => $provider_bestellt_500,
|
||||
'timeline' => $this->getTimeline('weekly-orders', $campaign_ids, $gemeinde_ids),
|
||||
'timeline_leerrohr' => $timeline_baufortschritt_140,
|
||||
'timeline_ont_installed' => $timeline_ont_installiert_300
|
||||
'timeline_ont_installed' => $timeline_ont_installiert_300,
|
||||
'timeline_provider_bestellt' => $timeline_provider_bestellt_500
|
||||
|
||||
|
||||
]);
|
||||
@@ -384,6 +393,10 @@ class DashboardNewController extends mfBaseController {
|
||||
$params['add-where'] = " AND ph.`create` <= UNIX_TIMESTAMP('" . $date . " 23:59:59')";
|
||||
$value = PreorderModel::countHistoryStatus($params, 500);
|
||||
break;
|
||||
case 'weekly-provider-bestellt':
|
||||
$params['add-where'] = " AND ph.`create` <= UNIX_TIMESTAMP('" . $date . " 23:59:59')";
|
||||
$value = PreorderModel::countHistoryStatus($params, 500);
|
||||
break;
|
||||
}
|
||||
|
||||
$newData = [
|
||||
|
||||
Reference in New Issue
Block a user