-
Notifications
You must be signed in to change notification settings - Fork 208
/
export_port_connections.php
53 lines (47 loc) · 1.67 KB
/
export_port_connections.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
require_once( "db.inc.php" );
require_once( "facilities.inc.php" );
require_once( "connections_spreadsheet.php" );
if((isset($_REQUEST["deviceid"]) && ($_REQUEST["deviceid"]=="" || $_REQUEST["deviceid"]==null)) || !isset($_REQUEST["deviceid"])){
// No soup for you.
header('Location: '.redirect());
exit;
}
$devList = array();
if ( $_REQUEST["deviceid"] == "wo" ) {
// Special case, we are printing all connections for a work order, which has a cookie associated with it
$woList = json_decode( $_COOKIE["workOrder"] );
foreach($woList as $woDev){
$dev=new Device();
$dev->DeviceID=$woDev;
if($dev->GetDevice()){
$devList[]=$dev;
}
}
} else {
$devList[0] = new Device();
$devList[0]->DeviceID = $_REQUEST["deviceid"];
if ( ! $devList[0]->GetDevice() ) {
// Not a valid device ID
header('Location: '.redirect());
exit;
}
}
$mediaIDList = array();
if( $_REQUEST["deviceid"] == "wo" && isset($_COOKIE['connectionsMediaList'])){
$mediaIDList = json_decode($_COOKIE['connectionsMediaList']);
}else{
$mediaIDList[]='-1';
foreach(MediaTypes::GetMediaTypeList() as $mt){
$mediaIDList[]=''.$mt->MediaID;
}
}
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx(generate_spreadsheet($devList,$mediaIDList));
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
if ( $_REQUEST["deviceid"] == "wo" ) {
header( sprintf( "Content-Disposition: attachment;filename=\"openDCIM-workorder-%s-connections.xlsx\"", date( "YmdHis" ) ) );
} else {
header( "Content-Disposition: attachment;filename=\"openDCIM-dev" . $devList[0]->DeviceID . "-connections.xlsx\"" );
}
$writer->save("php://output");
?>