added new estmk export
This commit is contained in:
@@ -19,7 +19,10 @@ class DashboardNewController extends mfBaseController {
|
||||
}
|
||||
|
||||
$this->layout()->set('additionalJS', ["plugins/chart.js/chart.4.4.6.js", "plugins/chart.js/chartjs-adapter-moment.min.js"]);
|
||||
Helper::renderVue($this, $this->mod, "Dashboard", ["IS_ADMIN" => $this->me->is("Admin") ? "true" : "false"]);
|
||||
Helper::renderVue($this, $this->mod, "Dashboard", [
|
||||
"IS_ADMIN" => $this->me->is("Admin") ? "true" : "false",
|
||||
"ME_ADDRESS_ID" => $this->me->address_id,
|
||||
]);
|
||||
}
|
||||
|
||||
protected function adbAction() {
|
||||
@@ -333,6 +336,86 @@ class DashboardNewController extends mfBaseController {
|
||||
]);
|
||||
}
|
||||
|
||||
protected function exportAction() {
|
||||
// Filter campaigns where network owner is 209
|
||||
$netowner_id = 209;
|
||||
|
||||
// Get all campaigns for this network owner
|
||||
$all_campaigns = $this->me->is("Admin") ? PreordercampaignModel::getAll() : PreordercampaignModel::search(["owner_id" => $this->me->address_id]);
|
||||
|
||||
if (empty($all_campaigns) || $all_campaigns[0] === NULL) {
|
||||
http_response_code(500);
|
||||
self::returnJson(["status" => 500, "message" => "Keine Kampagnen gefunden"]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Filter campaigns by network owner
|
||||
$filtered_campaigns = array_filter($all_campaigns, function($campaign) use ($netowner_id) {
|
||||
$campaign_obj = new Preordercampaign($campaign->id);
|
||||
return $campaign_obj->network->owner_id == $netowner_id;
|
||||
});
|
||||
|
||||
if (empty($filtered_campaigns)) {
|
||||
http_response_code(404);
|
||||
self::returnJson(["status" => 404, "message" => "Keine Kampagnen für Netowner 209 gefunden"]);
|
||||
return;
|
||||
}
|
||||
|
||||
$export_data = [];
|
||||
|
||||
foreach ($filtered_campaigns as $campaign) {
|
||||
$campaign_ids = [$campaign->id];
|
||||
$gemeinde_ids = []; // Empty array as in original
|
||||
|
||||
$order_max_homes = $this->getTotalHomes($campaign_ids, $gemeinde_ids);
|
||||
|
||||
$efh_connection_types = ["single-dwelling", "business"];
|
||||
$mph_connection_types = ["apartment-building", "apartment", "multi-dwelling"];
|
||||
|
||||
$countFunction = function($params, $statusFlag = null) use ($campaign_ids, $gemeinde_ids) {
|
||||
$baseParams = ["preordercampaign_id" => $campaign_ids, "gemeinde_id" => $gemeinde_ids];
|
||||
$params = array_merge($baseParams, $params);
|
||||
return $statusFlag ?
|
||||
PreorderModel::countStatusFlagsActive($params, $statusFlag) :
|
||||
PreorderModel::countActive($params);
|
||||
};
|
||||
|
||||
$baufortschritt_140 = $countFunction([">status_code" => "139", "<status_code" => "899"]);
|
||||
$ont_installiert_300 = $countFunction([">status_code" => "299", "<status_code" => "899"]);
|
||||
$provider_bestellt_500 = $countFunction([">status_code" => "499", "<status_code" => "899"]);
|
||||
|
||||
$campaign_data = [
|
||||
'campaign_id' => $campaign->id,
|
||||
'campaign_name' => $campaign->name ?? 'Unnamed Campaign',
|
||||
'type' => 'default',
|
||||
'order_max_home_addrdb' => $order_max_homes,
|
||||
'order_actual_order' => $countFunction([]),
|
||||
'order_efh' => $countFunction(["connection_type" => $efh_connection_types]),
|
||||
'order_efh_vorsorge' => $countFunction(["connection_type" => $efh_connection_types, "type" => "provision"]),
|
||||
'order_efh_vollanschluss' => $countFunction(["connection_type" => $efh_connection_types, "type" => "order"]),
|
||||
'order_mph' => $countFunction(["connection_type" => $mph_connection_types]),
|
||||
'order_mph_vorsorge' => $countFunction(["connection_type" => $mph_connection_types, "type" => "provision"]),
|
||||
'order_mph_vollanschluss' => $countFunction(["connection_type" => $mph_connection_types, "type" => "order"]),
|
||||
'baufortschritt_140' => $baufortschritt_140,
|
||||
'installationspaket_erhalten' => $countFunction(["connection_type" => $efh_connection_types], 145),
|
||||
'lehrrohr_im_haus' => $countFunction(["connection_type" => $efh_connection_types], 200),
|
||||
'inhouse_kabel_verlegt_efh' => $countFunction(["connection_type" => $efh_connection_types], 242),
|
||||
'inhouse_kabel_verlegt_mph' => $countFunction(["connection_type" => $mph_connection_types], 242),
|
||||
'installationsfortschritt_245' => $countFunction([">status_code" => "244", "<status_code" => "899"]),
|
||||
'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' => $provider_bestellt_500
|
||||
];
|
||||
|
||||
$export_data[] = $campaign_data;
|
||||
}
|
||||
|
||||
self::returnJson($export_data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Installationsfortschritt Provider
|
||||
//
|
||||
|
||||
|
||||
Reference in New Issue
Block a user