WIP Linework excel export
This commit is contained in:
@@ -102,6 +102,7 @@
|
|||||||
<div class="col">
|
<div class="col">
|
||||||
<button type="submit" class="btn btn-primary">Filter anwenden</button>
|
<button type="submit" class="btn btn-primary">Filter anwenden</button>
|
||||||
<a class="btn btn-secondary" href="<?=self::getUrl("Linework")?>">Filter zurücksetzen</a>
|
<a class="btn btn-secondary" href="<?=self::getUrl("Linework")?>">Filter zurücksetzen</a>
|
||||||
|
<button type="submit" name="export" value="1" class="btn btn-outline-success ml-2"><i class="fas fa-download mr-1"></i> Download als .xls</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
202
Layout/default/Linework/export.xls.php
Normal file
202
Layout/default/Linework/export.xls.php
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$col = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN','AO','AP','AQ','AR','AS','AT','AU','AV','AW','AX','AY','AZ','BA',
|
||||||
|
'BB','BC','BD','BE','BF','BG','BH','BI','BJ','BK','BL','BM','BN','BO','BP','BQ','BR','BS','BT','BU','BV','BW','BX','BY','BZ'
|
||||||
|
);
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||||
|
|
||||||
|
$xls = new Spreadsheet();
|
||||||
|
$sheet = $xls->getActiveSheet();
|
||||||
|
|
||||||
|
// header
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "id");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Netzgebiet");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Bauabschnitt");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Gebäudecode");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Straße");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "GPS Breite");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "GPS Länge");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Gebäudestatus Code");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Gebäudestatus");
|
||||||
|
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Anschlusscode");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Anschlussname");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Anschlussstatus Code");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Anschlussstatus");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Kontakt");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Telefon");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Email");
|
||||||
|
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Doku-Aufschub");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Baufreigabe");
|
||||||
|
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "AP-Typ");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "AP-Name");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "AP GPS Breite");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "AP GPS Länge");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Rohrverband");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Rohrtyp");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Rohrfarbe");
|
||||||
|
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "POP (Planung)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "POP (Ist-Zustand)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Schrank (Planung)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Schrank (Ist-Zustand)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "HE/Einschub (Planung)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "HE/Einschub (Ist-Zustand)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Modul (Planung)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Modul (Ist-Zustand)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Ports (Planung)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Ports (Ist-Zustand)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Abschlusstyp (Planung)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Abschlusstyp (Ist-Zustand)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "BB-Kabel (Planung)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "BB-Kabel (Ist-Zustand)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "BB-Kabel Typ (Planung)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "BB-Kabel Typ (Ist-Zustand)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "BB-Fasern (Planung)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "BB-Fasern (Ist-Zustand)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Kundenkabel-Typ (Planung)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Kundenkabel-Typ (Ist-Zustand)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Fasern im KU-Kabel (Planung)");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Fasern im KU-Kabel (Ist-Zustand)");
|
||||||
|
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Backbone hergestellt");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "BB-Bautermin");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "KU-Bautermin");
|
||||||
|
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "BEP montiert");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Kundenkabel eingeblasen");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Spleiß Netz");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Spleiß Kunde");
|
||||||
|
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "ONT montiert");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "ONT Seriennummer");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Kunde passiv fertiggestellt");
|
||||||
|
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Kommentar Tiefbau");
|
||||||
|
$sheet->setCellValue($col[$i++].'1', "Kommentar Leitungsbau");
|
||||||
|
|
||||||
|
$sheet->getStyle("A1:".$col[$i]."1")->getFont()->setBold(true);
|
||||||
|
|
||||||
|
$sheet->getRowDimension(1)->setRowHeight(16);
|
||||||
|
|
||||||
|
|
||||||
|
$line = 2;
|
||||||
|
foreach($networks as $networkname => $terminations) {
|
||||||
|
foreach($terminations as $term) {
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
$building = $term->building;
|
||||||
|
|
||||||
|
$sheet->setCellValue($col[$i].$line, $term->id)->getStyle($col[$i].$line)->getFont()->setName("monospace")->setSize(10);
|
||||||
|
$sheet->getStyle($col[$i].$line)->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, $networkname);
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, $building->networksection->name);
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, $building->code)->getStyle($col[$i].$line)->getFont()->setName("monospace")->setSize(10);
|
||||||
|
$sheet->getStyle($col[$i].$line)->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, $building->street);
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, $building->gps_lat)->getStyle($col[$i].$line)->getFont()->setName("monospace")->setSize(10);
|
||||||
|
$sheet->getStyle($col[$i].$line)->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, $building->gps_long)->getStyle($col[$i].$line)->getFont()->setName("monospace")->setSize(10);
|
||||||
|
$sheet->getStyle($col[$i].$line)->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, $building->status->code)->getStyle($col[$i].$line)->getFont()->setName("monospace")->setSize(10);
|
||||||
|
$sheet->getStyle($col[$i].$line)->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, $building->status->name)->getStyle($col[$i].$line)->getFont()->setName("monospace")->setSize(10);
|
||||||
|
$sheet->getStyle($col[$i].$line)->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, $term->code)->getStyle($col[$i].$line)->getFont()->setName("monospace")->setSize(10);
|
||||||
|
$sheet->getStyle($col[$i].$line)->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, $term->name);
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, $term->status->code)->getStyle($col[$i].$line)->getFont()->setName("monospace")->setSize(10);
|
||||||
|
$sheet->getStyle($col[$i].$line)->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, $term->status->name)->getStyle($col[$i].$line)->getFont()->setName("monospace")->setSize(10);
|
||||||
|
$sheet->getStyle($col[$i].$line)->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, $term->contact);
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, $term->phone);
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, $term->email);
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, $term->linework_doku_delay);
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, $term->linework_enabled);
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
$sheet->setCellValue($col[$i].$line, ($term->building->getWorkflowvalue("ist_anschlusspunkt_typ")) ? $term->building->getWorkflowvalue("ist_anschlusspunkt_typ") : $term->building->getWorkflowvalue("anschlusspunkt_typ"));
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, ($term->building->getWorkflowvalue('ist_anschlusspunkt_name')) ? $term->building->getWorkflowvalue('ist_anschlusspunkt_name') : $term->building->getWorkflowvalue('anschlusspunkt_name'));
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
$gps = explode(";", ($term->building->getWorkflowvalue('ist_anschlusspunkt_gps')) ? $term->building->getWorkflowvalue('ist_anschlusspunkt_gps') : $term->building->getWorkflowvalue('anschlusspunkt_gps'));
|
||||||
|
if(is_array($gps) & count($gps) == 2) {
|
||||||
|
$sheet->setCellValue($col[$i].$line, $gps[0])->getStyle($col[$i].$line)->getFont()->setName("monospace")->setSize(10);
|
||||||
|
$sheet->getStyle($col[$i].$line)->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
|
$sheet->setCellValue($col[$i+1].$line, $gps[1])->getStyle($col[$i].$line)->getFont()->setName("monospace")->setSize(10);
|
||||||
|
$sheet->getStyle($col[$i+1].$line)->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
|
}
|
||||||
|
$i += 2;
|
||||||
|
|
||||||
|
$sheet->setCellValue($col[$i].$line, ($term->building->getWorkflowvalue('ist_rohrverband_name')) ? $term->building->getWorkflowvalue('ist_rohrverband_name') : $term->building->getWorkflowvalue('rohrverband_name'));
|
||||||
|
$i++;
|
||||||
|
$sheet->setCellValue($col[$i].$line, ($term->building->getWorkflowvalue('ist_rohrtype')) ? $term->building->getWorkflowvalue('ist_rohrtype') : $term->building->getWorkflowvalue('rohrtype'));
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
$color = ($term->building->getWorkflowvalue('ist_rohrfarbe')) ? $term->building->getWorkflowvalue('ist_rohrfarbe') : $term->building->getWorkflowvalue('rohrfarbe');
|
||||||
|
if($color) {
|
||||||
|
if(TT_CABLE_COLORS[$color]["mark"]) {
|
||||||
|
$sheet->setCellValue($col[$i].$line, "----- ".ucfirst($color)." -----");
|
||||||
|
} else {
|
||||||
|
$sheet->setCellValue($col[$i].$line, ucfirst($color));
|
||||||
|
}
|
||||||
|
$sheet->getStyle($col[$i].$line)->getFont()->setName("monospace")->setSize(10)->getColor()->setARGB(TT_CABLE_COLORS[$color]["hexfg"]);
|
||||||
|
$sheet->getStyle($col[$i].$line)->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB(TT_CABLE_COLORS[$color]["hex"]);
|
||||||
|
$sheet->getStyle($col[$i].$line)->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
|
||||||
|
$sheet->getStyle($col[$i].$line)->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$sheet->getRowDimension($line)->setRowHeight(16);
|
||||||
|
$line++;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sheet->freezePane("A2");
|
||||||
|
//$sheet->getStyle("A2:".$col[$i].$line)->getFont()->setName("monospace")->setSize(10);
|
||||||
|
|
||||||
|
|
||||||
|
for($c = 0; $c < $i; $c++) {
|
||||||
|
$sheet->getColumnDimension($col[$c])->setAutoSize(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//$writer = new Xls($xls);
|
||||||
|
$writer = new Xlsx($xls);
|
||||||
|
|
||||||
|
//header("Content-type: application/vnd.ms-excel");
|
||||||
|
header("Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||||
|
|
||||||
|
header('Content-disposition: attachment; filename="leitungsbau-'.date('Y-m-d_H-i-s').'-'.uniqid().'.xlsx"');
|
||||||
|
$writer->save('php://output');
|
||||||
|
exit;
|
||||||
|
|
||||||
@@ -32,6 +32,11 @@ class LineworkController extends mfBaseController {
|
|||||||
$pagination['count'] = 20;
|
$pagination['count'] = 20;
|
||||||
$pagination['maxItems'] = 0;
|
$pagination['maxItems'] = 0;
|
||||||
|
|
||||||
|
if($this->request->export) {
|
||||||
|
$this->layout()->setTemplate("Linework/export.xls");
|
||||||
|
$pagination = false;
|
||||||
|
}
|
||||||
|
|
||||||
if(is_numeric($this->request->s)) {
|
if(is_numeric($this->request->s)) {
|
||||||
$pagination['start'] = intval($this->request->s);
|
$pagination['start'] = intval($this->request->s);
|
||||||
}
|
}
|
||||||
@@ -101,11 +106,11 @@ class LineworkController extends mfBaseController {
|
|||||||
|
|
||||||
$pagination['maxItems'] = TerminationModel::count($termination_search);
|
$pagination['maxItems'] = TerminationModel::count($termination_search);
|
||||||
foreach(TerminationModel::search($termination_search, $pagination) as $term) {
|
foreach(TerminationModel::search($termination_search, $pagination) as $term) {
|
||||||
if(!array_key_exists($term->network->name, $networks)) {
|
if(!array_key_exists($term->building->network->name, $networks)) {
|
||||||
$networks[$term->network->name] = [];
|
$networks[$term->building->network->name] = [];
|
||||||
}
|
}
|
||||||
if(!array_key_exists($term->id, $networks[$term->network->name])) {
|
if(!array_key_exists($term->id, $networks[$term->building->network->name])) {
|
||||||
$networks[$term->network->name][$term->id] = $term;
|
$networks[$term->building->network->name][$term->id] = $term;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,6 +137,9 @@ class LineworkController extends mfBaseController {
|
|||||||
$this->layout()->set("wfColspan", $item_colspan);
|
$this->layout()->set("wfColspan", $item_colspan);
|
||||||
$this->layout()->set("networks", $networks);
|
$this->layout()->set("networks", $networks);
|
||||||
$this->layout()->set("pagination", $pagination);
|
$this->layout()->set("pagination", $pagination);
|
||||||
|
//var_dump($networks);exit;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
5
composer.json
Normal file
5
composer.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"require": {
|
||||||
|
"phpoffice/phpspreadsheet": "^1.23"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
spl_autoload_register("mfAutoload", true);
|
spl_autoload_register("mfAutoload", true);
|
||||||
|
require_once BASEDIR.'/vendor/autoload.php';
|
||||||
|
|
||||||
//require_once PEARDIR.'/PEAR2/Autoload.php';
|
//require_once PEARDIR.'/PEAR2/Autoload.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user