You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/models/garagem.js
+21-3Lines changed: 21 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ module.exports = {
18
18
`,
19
19
20
20
getAllViagensUnidade: `
21
-
SELECT uv.id, v.nome as veiculo, v.placa, u.nome as unidade, uv.saida, uv.chegada, uv.motivo, uv.motorista, uv.responsavel, uv.km_inicial, uv.km_final
21
+
SELECT uv.id, uv.liberacao, v.nome as veiculo, v.placa, u.nome as unidade, uv.saida, uv.chegada, uv.motivo, uv.motorista, uv.responsavel, uv.km_inicial, uv.km_final
22
22
from utilizacao_veicular uv
23
23
join veiculos v on uv.id_veiculo = v.id
24
24
join unidade u on uv.unidade = u.id
@@ -35,18 +35,36 @@ module.exports = {
35
35
order by uv.saida, uv.chegada asc;
36
36
`,
37
37
38
+
createViagem: `INSERT INTO UTILIZACAO_VEICULAR (ID, ID_VEICULO, UNIDADE, ID_SOLICITACAO, MOTIVO, MOTORISTA, KM_INICIAL, RESPONSAVEL, LIBERACAO) VALUES ($1,$2,$3,$4,(select motivo from solicitacao_veicular where id = $5),$6,$7,(select responsavel from solicitacao_veicular where id = $8), $9);`,
39
+
40
+
iniciarViagem: `UPDATE UTILIZACAO_VEICULAR SET MOTORISTA = $1, KM_INICIAL = $2, SAIDA = $3 WHERE ID = $4;`,
41
+
38
42
getAllSolicitacoes: `
39
-
SELECT sv.id, v.placa, v.nome as veiculo, sv.data_viagem, sv.responsavel, sv.motivo, s.nome as status
43
+
SELECT sv.id, v.placa, v.nome as veiculo, sv.data_viagem, sv.responsavel, s.nome as status, sv.resumo
40
44
FROM solicitacao_veicular sv
41
45
join veiculos v on sv.id_veiculo = v.id
42
46
join status_solicitacao s on sv.id_status = s.id
43
47
where sv.id_orgao = $1
44
48
order by sv.data_viagem asc;
45
49
`,
46
50
51
+
indisponibilizaVeiculo: `UPDATE VEICULOS SET STATUS = 2 WHERE ID = $1;`,
52
+
disponibilizaVeiculo: `UPDATE VEICULOS SET STATUS = 1 WHERE ID = (select id_veiculo from utilizacao_veicular where id = $1);`,
53
+
concluiSolicitacao: `UPDATE SOLICITACAO_VEICULAR SET ID_STATUS = 'd7e3227d-854b-41e5-a4db-94cadf994d78' WHERE ID = (SELECT ID_SOLICITACAO FROM UTILIZACAO_VEICULAR WHERE ID = $1);`,
54
+
55
+
getSolicitacao: `
56
+
SELECT sv.id, sv.id_unidade, sv.resumo, sv.telefone_responsavel, v.placa, v.nome as veiculo, sv.data_viagem, sv.responsavel, sv.motivo, s.nome as status
0 commit comments