Added RTR C10 reporting
This commit is contained in:
@@ -6,9 +6,15 @@ class Admin_RtrReporting {
|
||||
private $log;
|
||||
private $flash = [];
|
||||
private $systemowner_id = 1;
|
||||
private $energie_bb_id = 209;
|
||||
|
||||
private $netowner_is_systemowner = [
|
||||
1473,
|
||||
421,
|
||||
|
||||
];
|
||||
private $additional_owner_networks = [
|
||||
7 // mortantsch
|
||||
7, // mortantsch
|
||||
];
|
||||
private $ort_replace = [
|
||||
"St.Ruprecht/Raab" => "Sankt Ruprecht an der Raab",
|
||||
@@ -444,6 +450,95 @@ class Admin_RtrReporting {
|
||||
|
||||
}
|
||||
|
||||
protected function c10reportAction() {
|
||||
$data = [];
|
||||
|
||||
$systemowner = new Address($this->systemowner_id);
|
||||
$energie_bb = new Address($this->energie_bb_id);
|
||||
if(!$energie_bb->id) {
|
||||
return [
|
||||
"error" => "Energie BB id nicht gesetzt",
|
||||
"template" => "Admin/RtrReporting/Index",
|
||||
"redirect" => "",
|
||||
"templateVars" => []
|
||||
];
|
||||
}
|
||||
|
||||
foreach(ContractModel::searchActive([]) as $contract) {
|
||||
if(!is_array($contract->product->attributes) || !array_key_exists("rtr_tech_code", $contract->product->attributes) || !$contract->product->attributes["rtr_tech_code"]->value) continue;
|
||||
|
||||
$prov_id = false;
|
||||
$prod_code = $contract->product->attributes["rtr_tech_code"]->value;
|
||||
if(!$prod_code) continue;
|
||||
|
||||
if($contract->termination_id) {
|
||||
$network_id = $contract->termination->building->network_id;
|
||||
$netowner_id = $contract->termination->building->network->owner_id;
|
||||
|
||||
if(in_array($network_id, $this->additional_owner_networks)) {
|
||||
$netowner_id = $this->systemowner_id;
|
||||
}
|
||||
|
||||
if(in_array($netowner_id, $this->netowner_is_systemowner)) {
|
||||
$netowner_id = $this->systemowner_id;
|
||||
}
|
||||
|
||||
$netowner = new Address($netowner_id);
|
||||
|
||||
if($netowner->id && is_array($netowner->attributes) && array_key_exists("rtrcode", $netowner->attributes) && $netowner->attributes["rtrcode"]->value) {
|
||||
$prov_id = $netowner->attributes["rtrcode"]->value;
|
||||
}
|
||||
if(!$prov_id) {
|
||||
$this->log->debug(__METHOD__.": keine provider id trotz termination | netowner: $netowner_id ".$netowner->getCompanyOrName());
|
||||
}
|
||||
}
|
||||
|
||||
$prod_code_start = substr($prod_code, 0, 4);
|
||||
$prod_code_p = $prod_code_start."1";
|
||||
$prod_code_b = $prod_code_start."2";
|
||||
|
||||
if(!$prov_id) {
|
||||
if($prod_code_start == "1432") {
|
||||
// is OAN product
|
||||
$prov_id = $energie_bb->attributes["rtrcode"]->value;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$prov_id) {
|
||||
$prov_id = $systemowner->attributes["rtrcode"]->value;
|
||||
}
|
||||
|
||||
if(!array_key_exists($prov_id, $data)) {
|
||||
$data[$prov_id] = [];
|
||||
}
|
||||
|
||||
if(!in_array($prod_code_p, $data[$prov_id])) {
|
||||
$data[$prov_id][] = $prod_code_p;
|
||||
}
|
||||
if(!in_array($prod_code_b, $data[$prov_id])) {
|
||||
$data[$prov_id][] = $prod_code_b;
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($data);exit;
|
||||
|
||||
$csv_header = "partnernetz_id;code";
|
||||
$csv = $csv_header."\n";
|
||||
foreach($data as $prov_id => $prov) {
|
||||
foreach($prov as $prod_code) {
|
||||
$csv .= "$prov_id;";
|
||||
$csv .= "$prod_code";
|
||||
$csv .= "\n";
|
||||
}
|
||||
}
|
||||
|
||||
header("Content-type: text/csv; charset=utf-8");
|
||||
header('Content-disposition: attachment; filename="rtr-C10-report-'.date('Y-m-d_H-i-s').'.csv"');
|
||||
|
||||
echo $csv;
|
||||
exit;
|
||||
}
|
||||
|
||||
/*
|
||||
* 1042% = radio
|
||||
* 1431% = fiber
|
||||
|
||||
Reference in New Issue
Block a user