-
Notifications
You must be signed in to change notification settings - Fork 0
/
editaOcorrencia.php
330 lines (297 loc) · 17.9 KB
/
editaOcorrencia.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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
<?php
try {
include_once('conexao.php');
/* BUSCA DADOS DA OCORRENCIA */
$py = md5('idocorrencia');
$sql = $pdo->prepare("SELECT idocorrencia,cliente,serial,datado,hora,solicitacao,diagnostico,procedimento,observacao,tecnico,retorno,pagamento,fechada,desativada,entrega FROM ocorrencia WHERE idocorrencia = :idocorrencia");
$sql->bindParam(':idocorrencia', $_GET[''.$py.''], PDO::PARAM_INT);
$sql->execute();
$ret = $sql->rowCount();
if($ret > 0) {
$lin = $sql->fetch(PDO::FETCH_OBJ);
//INVERTENDO A DATA
$ano = substr($lin->datado,0,4);
$mes = substr($lin->datado,5,2);
$dia = substr($lin->datado,8);
$lin->datado = $dia."/".$mes."/".$ano;
//BUSCANDO DADOS DO CLIENTE
$sql2 = $pdo->prepare("SELECT idcliente FROM cliente WHERE nome = :nome");
$sql2->bindParam(':nome', $lin->cliente, PDO::PARAM_STR);
$sql2->execute();
$ret2 = $sql2->rowCount();
if($ret2 > 0) {
$lin2 = $sql2->fetch(PDO::FETCH_OBJ);
$idcliente = $lin2->idcliente;
}
else {
$idcliente = '';
}
unset($sql2,$ret2,$lin2);
?>
<form class="form-edita-ocorrencia">
<div class="modal-header">
<button type="button" class="close closed" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Edita ocorrência <small>(<i class="fa fa-asterisk"></i> Campo obrigatório)</small> <span class="pull-right lead"><strong><?php echo $lin->serial; ?></strong></span></h4>
</div>
<div class="modal-body overing">
<div class="col-md-6">
<input type="hidden" id="idocorrencia" class="form-control" value="<?php echo $lin->idocorrencia; ?>">
<input type="hidden" id="serial-" class="form-control" value="<?php echo $lin->serial; ?>">
<div class="form-group">
<label for="cliente"><i class="fa fa-asterisk"></i> Cliente <cite class="msg-cliente- label label-danger"></cite></label>
<input type="hidden" id="idcliente-" class="form-control" value="<?php echo $idcliente; ?>">
<input type="text" id="cliente-" class="form-control" maxlength="255" value="<?php echo $lin->cliente; ?>" title="Digite o nome do cliente" placeholder="Cliente" required>
</div>
<div class="form-group">
<label for="datado"><i class="fa fa-asterisk"></i> Data</label>
<div class="input-group col-md-6">
<input type="text" id="datado-" class="form-control" maxlength="10" value="<?php echo $lin->datado; ?>" title="Digite a data" placeholder="Data" required>
</div>
</div>
<div class="form-group">
<label for="hora"><i class="fa fa-asterisk"></i> Hora</label>
<div class="input-group col-md-6">
<select id="hora-" class="form-control">
<?php
if ($lin->hora == '08:00') { echo'<option value="08:00" selected="selected">08:00</option>'; }
else { echo'<option value="08:00">08:00</option>'; }
if ($lin->hora == '08:30') { echo'<option value="08:30" selected="selected">08:30</option>'; }
else { echo'<option value="08:30">08:30</option>'; }
if ($lin->hora == '09:00') { echo'<option value="09:00" selected="selected">09:00</option>'; }
else { echo'<option value="09:00">09:00</option>'; }
if ($lin->hora == '09:30') { echo'<option value="09:30" selected="selected">09:30</option>'; }
else { echo'<option value="09:30">09:30</option>'; }
if ($lin->hora == '10:00') { echo'<option value="10:00" selected="selected">10:00</option>'; }
else { echo'<option value="10:00">10:00</option>'; }
if ($lin->hora == '10:30') { echo'<option value="10:30" selected="selected">10:30</option>'; }
else { echo'<option value="10:30">10:30</option>'; }
if ($lin->hora == '11:00') { echo'<option value="11:00" selected="selected">11:00</option>'; }
else { echo'<option value="11:00">11:00</option>'; }
if ($lin->hora == '11:30') { echo'<option value="11:30" selected="selected">11:30</option>'; }
else { echo'<option value="11:30">11:30</option>'; }
if ($lin->hora == '13:30') { echo'<option value="13:30" selected="selected">13:30</option>'; }
else { echo'<option value="13:30">13:30</option>'; }
if ($lin->hora == '14:00') { echo'<option value="14:00" selected="selected">14:00</option>'; }
else { echo'<option value="14:00">14:00</option>'; }
if ($lin->hora == '14:30') { echo'<option value="14:30" selected="selected">14:30</option>'; }
else { echo'<option value="14:30">14:30</option>'; }
if ($lin->hora == '15:00') { echo'<option value="15:00" selected="selected">15:00</option>'; }
else { echo'<option value="15:00">15:00</option>'; }
if ($lin->hora == '15:30') { echo'<option value="15:30" selected="selected">15:30</option>'; }
else { echo'<option value="15:30">15:30</option>'; }
if ($lin->hora == '16:00') { echo'<option value="16:00" selected="selected">16:00</option>'; }
else { echo'<option value="16:00">16:00</option>'; }
if ($lin->hora == '16:30') { echo'<option value="16:30" selected="selected">16:30</option>'; }
else { echo'<option value="16:30">16:30</option>'; }
if ($lin->hora == '17:00') { echo'<option value="17:00" selected="selected">17:00</option>'; }
else { echo'<option value="17:00">17:00</option>'; }
if ($lin->hora == '17:30') { echo'<option value="17:30" selected="selected">17:30</option>'; }
else { echo'<option value="17:30">17:30</option>'; }
?>
</select>
</div>
</div>
<div class="control-icheck">
<div class="form-group">
<label for="entrega"><i class="fa fa-asterisk"></i> Entregar</label>
<div class="input-group">
<?php
if($lin->entrega == "T") {
$js = "entrega";
echo'
<span class="form-icheck"><input type="radio" name="entrega-" id="onentrega-" value="T" checked> Sim</span>
<span class="form-icheck"><input type="radio" name="entrega-" id="offentrega-" value="F"> Não</span>';
}
else {
echo'
<span class="form-icheck"><input type="radio" name="entrega-" id="onentrega-" value="T"> Sim</span>
<span class="form-icheck"><input type="radio" name="entrega-" id="offentrega-" value="F" checked> Não</span>';
}
?>
</div>
</div>
<div class="form-group">
<label for="fechada"><i class="fa fa-asterisk"></i> Concluir</label>
<div class="input-group">
<?php
if($lin->fechada == "T") {
$js = "fechada";
echo'
<span class="form-icheck"><input type="radio" name="fechada-" id="onfechada-" value="T" checked> Sim</span>
<span class="form-icheck"><input type="radio" name="fechada-" id="offfechada-" value="F"> Não</span>';
}
else {
echo'
<span class="form-icheck"><input type="radio" name="fechada-" id="onfechada-" value="T" > Sim</span>
<span class="form-icheck"><input type="radio" name="fechada-" id="offfechada-" value="F" checked> Não</span>';
}
?>
</div>
</div>
<div class="form-group">
<label for="retorno"><i class="fa fa-asterisk"></i> Retorno</label>
<div class="input-group">
<?php
if($lin->retorno == "T") {
$js = "retorno";
echo'
<span class="form-icheck"><input type="radio" name="retorno-" id="onretorno-" value="T" checked> Sim</span>
<span class="form-icheck"><input type="radio" name="retorno-" id="offretorno-" value="F"> Não</span>';
}
else {
echo'
<span class="form-icheck"><input type="radio" name="retorno-" id="onretorno-" value="T"> Sim</span>
<span class="form-icheck"><input type="radio" name="retorno-" id="offretorno-" value="F" checked> Não</span>';
}
?>
</div>
</div>
<div class="form-group">
<label for="retorno"><i class="fa fa-asterisk"></i> Pagamento</label>
<div class="input-group">
<?php
switch ($lin->pagamento) {
case 'boleto':
echo'
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="boleto" checked> Boleto</span>
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="cartao"> Cartão</span>
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="contrato"> Contrato</span>
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="dinheiro"> Dinheiro</span>';
break;
case 'cartao':
echo'
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="boleto"> Boleto</span>
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="cartao" checked> Cartão</span>
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="contrato"> Contrato</span>
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="dinheiro"> Dinheiro</span>';
break;
case 'contrato':
echo'
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="boleto"> Boleto</span>
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="cartao"> Cartão</span>
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="contrato" checked> Contrato</span>
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="dinheiro"> Dinheiro</span>';
break;
case 'dinheiro':
echo'
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="boleto"> Boleto</span>
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="cartao"> Cartão</span>
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="contrato"> Contrato</span>
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="dinheiro" checked> Dinheiro</span>';
break;
default:
echo'
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="boleto"> Boleto</span>
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="cartao"> Cartão</span>
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="contrato"> Contrato</span>
<span class="form-icheck"><input type="radio" name="pagamento-" id="" value="dinheiro" checked> Dinheiro</span>';
break;
}
?>
</div>
</div>
<div class="form-group">
<label for="viacliente"> Via</label>
<div class="input-group">
<span class="form-icheck"><input type="checkbox" name="viacliente-" id="viacliente-" value="T"> Imprimir uma via para o cliente</span>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="tecnico"><i class="fa fa-asterisk"></i> Técnico</label>
<div class="input-group col-md-6">
<select id="tecnico-" class="form-control" required>
<option value="" selected>Selecione o técnico</option>
<?php
try {
$sql2 = $pdo->prepare("SELECT nome FROM tecnico ORDER BY nome");
$sql2->execute();
$ret2 = $sql2->rowCount();
if($ret2 > 0) {
while($lin2 = $sql2->fetch(PDO::FETCH_OBJ)) {
if($lin2->nome == $lin->tecnico) {
echo'<option value="'.$lin2->nome.'" selected>'.$lin2->nome.'</option>';
}
else {
echo'<option value="'.$lin2->nome.'">'.$lin2->nome.'</option>';
}
}
unset($lin2);
}
unset($sql2,$ret2);
}
catch(PDOException $e) {
echo 'Erro ao conectar o servidor '.$e->getMessage();
}
?>
</select>
<span class="input-group-addon">
<a data-toggle="modal" data-target="#novo-tecnico" title="Adicionar um novo técnico" href="#"><i class="fa fa-plus fa-fw"></i></a>
</span>
</div>
</div>
<div class="form-group">
<label for="solicitacao"><i class="fa fa-asterisk"></i> Solicitação</label>
<textarea id="solicitacao-" class="form-control" required><?php echo $lin->solicitacao; ?></textarea>
</div>
<div class="form-group">
<label for="diagnostico">Diagnóstico</label>
<textarea id="diagnostico-" class="form-control"><?php echo $lin->diagnostico; ?></textarea>
</div>
<div class="form-group">
<label for="procedimento">Procedimento</label>
<textarea id="procedimento-" class="form-control"><?php echo $lin->procedimento; ?></textarea>
</div>
<div class="form-group">
<label for="observacao">Observação</label>
<textarea id="observacao-" class="form-control"><?php echo $lin->observacao; ?></textarea>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default btn-flat pull-left closed" data-dismiss="modal">Fechar</button>
<button type="submit" class="btn btn-primary btn-flat btn-submit-edita-ocorrencia">Salvar</button>
</div>
</form>
<script src="js/apart.min.js"></script>
<script>
(function() {
<?php
if(empty($js)) { $js = "aberta"; }
switch($js) {
case 'entrega':
echo'
$("#onfechada-").iCheck("disable");
$("#onretorno-").iCheck("disable");';
break;
case 'fechada':
echo'
$("#onentrega-").iCheck("disable");
$("#onretorno-").iCheck("disable");';
break;
case 'retorno':
echo'
$("#onentrega-").iCheck("disable");
$("#onfechada-").iCheck("disable");';
break;
}
?>
})(jQuery);
</script>
<?php
unset($lin,$ano,$mes,$dia,$js,$idcliente);
} //if($ret > 0)
else {
echo'
<div class="callout">
<h4>Parâmentro incorreto</h4>
</div>';
}
unset($pdo,$sql,$ret,$py);
}
catch(PDOException $e) {
echo'Falha ao conectar o servidor '.$e->getMessage();
}
?>