-
Notifications
You must be signed in to change notification settings - Fork 0
/
busca_os_rel.php
214 lines (130 loc) · 8 KB
/
busca_os_rel.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?php
require_once("config/db.php");
include("libraries/functions.php");
include("libraries/feriado.php");
$link = new mysqli('localhost', 'root', 'mericunofoide', 'help_desk_ecos');
$link->set_charset('utf8');
if(isset($_POST['c_id'])) {
$datas = explode("#", $_POST['c_id']);
$dt_inicial = $datas[0];
$dt_final = $datas[1];
$meses_index = get_meses_index($dt_inicial, $dt_final);
$msg = "";
$meses = array('Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez');
$result_OSs = mysqli_query($link, "SELECT * from ordem_servico O where O.status > 1 and (O.dt_conclusao BETWEEN '$dt_inicial' and '$dt_final')");
//$tde =mysqli_num_rows($result_OSs);
//echo "<script>alert('Aqui $tde')</script>";
echo '<tr >
<td rowspan="3"></td>
<td colspan="4"><b>-</b></td>
<td colspan="4"><center><b>CHAMADO</b></center></td>
</tr>
<tr >
<td rowspan="2"><center><b>ESC ATEND.</b></center></td>
<td rowspan="2"><center><b>Nº O.S.</b></center></td>
<td rowspan="2"><center><b>PROGRAM.</b></center></td>
<td rowspan="2"><center><b>CHAMADOS</b></center></td>
<td colspan="2"><center><b>72 HRS(Atend.)</b></center></td>
<td colspan="2"><center><b>15DD(Resolução)</b></center></td>
</tr>
<tr >
<td><center><b>< 3 DD</b></center></td>
<td><center><b>> 3 DD</b></center></td>
<td><center><b>< 15</b></center></td>
<td><center><b>> 15</b></center></td>
</tr>';
foreach ($meses_index as $key => $value) {
$mes_val = explode("#", $value)[0] + 1;
$ano_val = explode("#", $value)[1];
// #################################################################################### Inicio consultas rapidas ########################################################################################
// por parametro em todas no lugar do numero da sede em todos
$ESC_ATEND = mysqli_num_rows(mysqli_query($link, "SELECT DISTINCT O.fk_id_nome_escola from ordem_servico O where O.status = 3 and (O.dt_conclusao BETWEEN '$dt_inicial' and '$dt_final') and O.fk_id_sede = 1 and MONTH(O.dt_conclusao) = '$mes_val' and Year(O.dt_conclusao) = '$ano_val'"));
$Num_O_S = mysqli_num_rows(mysqli_query($link, "SELECT * from ordem_servico O where O.status = 3 and (O.dt_conclusao BETWEEN '$dt_inicial' and '$dt_final') and O.fk_id_sede = 1 and MONTH(O.dt_conclusao) = '$mes_val' and Year(O.dt_conclusao) = '$ano_val'"));
$PROGRAM = mysqli_num_rows(mysqli_query($link, "SELECT * from ordem_servico O where O.status = 3 and (O.dt_conclusao BETWEEN '$dt_inicial' and '$dt_final') and O.fk_id_sede = 1 and O.tipo_chamado = 1 and MONTH(O.dt_conclusao) = '$mes_val' and Year(O.dt_conclusao) = '$ano_val'"));
$CHAMADOS = mysqli_num_rows(mysqli_query($link, "SELECT * from ordem_servico O where O.status = 3 and (O.dt_conclusao BETWEEN '$dt_inicial' and '$dt_final') and O.fk_id_sede = 1 and O.tipo_chamado = 0 and MONTH(O.dt_conclusao) = '$mes_val' and Year(O.dt_conclusao) = '$ano_val'"));
//############################################################################################## fim consultas rápidas ##################################################################################
//##################################### Inicio consultas complexas
$DD72_HRS_Atend_ok = 0;
$HRS72_Atend_off = 0;
$DD15_Resolucao_ok = 0;
$DD15_Resolucao_off = 0;
//$qq = mysqli_num_rows($result_OSs);
//echo "<script>alert('num $qq')</script>";
while($row_os = mysqli_fetch_object($result_OSs)){
//#################################################################### SLA ATENDIMENTO #########################################################
$data_1 = explode(' ', $row_os->dt_abertura);
$data = $data_1[0];
$ano = explode('-', $data)[0];
$mes = explode('-', $data)[1];
$dia = explode('-', $data)[2];
$temp = $dia.'/'.$mes.'/'.$ano;
$dt_sla_aten = somar_dias_uteis($temp,'4','');// faltam 2 dias para vencer
//echo "<script>alert('$temp')</script>";
$dt_1exec_os_result = mysqli_query($link, "SELECT EXEC.data_execucao from ordem_servico O, execucao_diaria EXEC where O.id_os = '$row_os->id_os' and EXEC.fk_id_ordem_servico = '$row_os->id_os'");
$dt_1exec_os = mysqli_fetch_object($dt_1exec_os_result)->data_execucao;
//echo "<script>alert('Mes1exec $dt_1exec_os temp $temp')</script>";
$ano_1exec = explode('-', $dt_1exec_os)[0];
$mes_1exec = explode('-', $dt_1exec_os)[1];
if (($ano_1exec == $ano_val) && ($mes_1exec == $mes_val)) {
//echo "<script>alert('Aqui heh')</script>";
if (($dt_1exec_os >= $row_os->dt_abertura) && ($dt_1exec_os <= $dt_sla_aten)) { // e sede == sede_parametro
//echo "<script>alert('ID $row_os->id_os')</script>";
$DD72_HRS_Atend_ok += 1;
}else{
$HRS72_Atend_off+=1;
}
}
//#################################################################### SLA CONCLUSAO #########################################################
$data_1 = explode(' ', $row_os->dt_conclusao);
$data = $data_1[0];
$ano = explode('-', $data)[0];
$mes = explode('-', $data)[1];
$dia = explode('-', $data)[2];
$temp = $dia.'/'.$mes.'/'.$ano;
$dt_sla_conc = somar_dias_uteis($temp,'16','');// faltam 15 dias para vencer
//echo "<script>alert('$temp')</script>";
//echo "<script>alert('Mes1exec $dt_1exec_os temp $temp')</script>";
$ano_conc = explode('-', $row_os->dt_conclusao)[0];
$mes_conc = explode('-', $row_os->dt_conclusao)[1];
if (($ano_conc == $ano_val) && ($mes_conc == $mes_val)) {
//echo "<script>alert('Aqui heh')</script>";
if ($row_os->dt_conclusao <= $dt_sla_conc) { // e sede == sede_parametro
//echo "<script>alert('ID $row_os->id_os')</script>";
$DD15_Resolucao_ok += 1;
}else{
$DD15_Resolucao_off+=1;
}
}
//echo "<script>alert('Mes1exec $mes_1exec Mes_val $mes_val')</script>";
//echo "<script>alert('Data')</script>";
//break;
}
//echo "<script>alert('$DD72_HRS_Atend_ok')</script>";
echo "<tr>";
$cols = "";
$cols = $cols."<td>".$meses[$mes_val-1]."/".$ano_val."</td>";
$cols = $cols."<td>".$ESC_ATEND."</td>";
$cols = $cols."<td>".$Num_O_S."</td>";
$cols = $cols."<td>".$PROGRAM."</td>";
$cols = $cols."<td>".$CHAMADOS."</td>";
$cols = $cols."<td>".$DD72_HRS_Atend_ok."</td>";
$cols = $cols."<td>".$HRS72_Atend_off."</td>";
$cols = $cols."<td>".$DD15_Resolucao_ok."</td>";
$cols = $cols."<td>".$DD15_Resolucao_off."</td>";
echo $cols.'</tr>';
//break;
}
/**$sql = "SELECT * FROM motivo_chamado WHERE visivel_p_escola = '1' AND fk_id_departamento = '$dp' ORDER BY motivo";
$res = mysqli_query($link, $sql);
if(mysqli_num_rows($res) > 0) {
echo "<option value=''>Selecione a categoria...</option>";
while($row = mysqli_fetch_object($res)) {
echo "<option value='".$row->id_motivo."'>".$row->motivo."</option>";
}
} else {
echo "<option>Não há categorias disponíveis</option>";
}**/
} else {
header('location: ./');
}
?>