-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.php
112 lines (101 loc) · 3.26 KB
/
index.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
if(!isset($_GET['s'])) $s = 1; else $s = $_GET['s'];
if(!isset($_GET['f'])) $f = ""; else $f = $_GET['f'];
/*****************************************/
/* PASO 1 */
/*****************************************/
if($s == 1)
{
if($f == "")
{
foreach (glob("*.xlsx") as $data2up)
{
echo '<a href="?s=2&f='.str_replace(array(".xlsx","-"),array("",""),$data2up).'">'.$data2up.'</a><br/>';
}
}
else
{
header("Location: ?s=2&f=".$f);
}
}
/*****************************************/
/* PASO 2 */
/*****************************************/
if($s == 2)
{
require_once('PHPExcel.php');
require_once('funciones.php');
$data = getSheets($f . '.xlsx');
$hoy = date('d/m/Y');
$html = '';
/*$set = "S";
$elm = $data[$set];*/
foreach($data as $set => $elm)
{
$txt = "addSET('" . $set . "');\n";
for($i = 1; $i <= max(array_keys($elm)); $i++)
{
$obj = $elm[$i];
$nivel = $obj[0]; /* trafo: potencia */
$tipo = $obj[1];
$barra = $obj[2]; /* trafo: # */
$bar2 = $obj[3]; /* Int: #Trafo */
$name = $obj[4]; /* trafo: Rel Transformación | Int: Devanado */
$state = $obj[5];
$extra = $obj[6];
if(in_array($tipo,Array('SB','DB')))
{
$state = ($state == 'NEW') ? $state . $bar2 : $state;
$txt .= "add" . $tipo . "('" . $set . "','" . $nivel . "'," . $state . ");\n";
}
elseif(in_array($tipo,Array('Rsv','SSAA')))
{
$state = ($state == 'NEW') ? $state . $extra : $state;
$txt .= "add" . $tipo . "('" . $set . "','" . $nivel . "','" . $barra . "'," . $state;
if($bar2 != "")
{
$txt .= ",'" . $bar2 . "'";
}
$txt .= ");\n";
}
elseif(in_array($tipo,Array('Alim','Cap','Med','Esp')))
{
$state = ($state == 'NEW') ? $state . $bar2 : $state;
$txt .= "add" . $tipo . "('" . $name . "','" . $set . "','" . $nivel . "','" . $barra . "'," . $state;
if($bar2 != "")
{
$txt .= ",'" . $bar2 . "'";
}
$txt .= ");\n";
}
elseif(in_array($tipo,Array('AcopLong','AcopExt')))
{
$state = ($state == 'NEW') ? $state . $extra : $state;
$txt .= "add" . $tipo . "('" . $set . "','" . $nivel . "','" . $barra . "','" . $bar2 . "'," . $state . ");\n";
if($tipo == 'AcopLong' && $name == "O")
{
$txt .= "switchAcopLong('" . $set . "','" . $nivel . "','" . $barra . "','" . $bar2 . "'," . $state . ");\n";
}
}
elseif(in_array($tipo,Array('T2d','T3d')))
{
$state = ($state == 'NEW') ? $state . $bar2 : $state;
$txt .= "add" . $tipo . "('" . $set . "','" . $barra . "','" . $name . "','" . $nivel . "'," . $state;
if($bar2 != "")
{
$txt .= ",'" . $bar2 . "'";
}
$txt .= ");\n";
}
elseif(in_array($tipo,Array('Sec','Int')))
{
$state = ($state == 'NEW') ? $state . $extra : $state;
$txt .= "add" . $tipo . "('" . $set . "','" . $nivel . "','" . $barra . "','" . $bar2 . "','" . $name . "'," . $state . ");\n";
}
}
$html .= str_replace(Array('[SET]','[SETNAME]','[FECHA]','[CODE2EXEC]'),Array($set,$set_name[$set],$hoy,$txt),file_get_contents('set.html'));
}
print str_replace(Array('[TITLE]','[CANVAS]'),Array($f,$html),file_get_contents('template.html'));
}
/*$objWriter=PHPExcel_IOFactory::createWriter($objPHPExcel,'Excel2007');
$objWriter->save("Plan.xlsx");*/