-
Notifications
You must be signed in to change notification settings - Fork 0
/
editaNota.php
99 lines (89 loc) · 4.11 KB
/
editaNota.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
<?php
try {
include_once('conexao.php');
/* BUSCA DADOS DA NOTA */
$py = md5('idnota');
$sql = $pdo->prepare("SELECT idnota,datado,tecnico,texto FROM nota WHERE idnota = :idnota");
$sql->bindParam(':idnota', $_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;
?>
<form class="form-edita-nota">
<div class="modal-header">
<button type="button" class="close closed" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Edita nota <small>(<i class="fa fa-asterisk"></i> Campo obrigatório)</small></h4>
</div>
<div class="modal-body">
<input type="hidden" id="idnota" class="form-control" value="<?php echo $lin->idnota; ?>">
<div class="form-group">
<label for="datado"><i class="fa fa-asterisk"></i> Data</label>
<div class="input-group col-md-3">
<input type="text" id="datado-nota-" 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="tecnico"><i class="fa fa-asterisk"></i> Técnico</label>
<div class="input-group col-md-5">
<select id="tecnico-nota-" 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($lin->tecnico == $lin2->nome) {
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="texto"><i class="fa fa-asterisk"></i> Texto</label>
<textarea id="texto-" class="form-control" required><?php echo $lin->texto; ?></textarea>
</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-nota">Salvar</button>
</div>
</form>
<script src="js/apart.min.js"></script>
<?php
unset($lin,$ano,$mes,$dia);
} //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();
}
?>