-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnitDM.dfm
584 lines (564 loc) · 17.8 KB
/
UnitDM.dfm
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
object DM: TDM
OldCreateOrder = False
Height = 272
Width = 393
object Conexao: TFDConnection
Params.Strings = (
'Database=ORAFAB'
'User_Name=ORACLC'
'Password=mJ2vhXdhj6kr4Gf'
'DriverID=ora')
Connected = True
LoginPrompt = False
Left = 32
Top = 16
end
object dsChamados: TDataSource
DataSet = sqlChamados
Left = 32
Top = 80
end
object sqlVBase: TFDQuery
Active = True
Connection = Conexao
SQL.Strings = (
'-- CONSULTA: PROCURAR SE USU'#193'RIO E VENDEDOR NA BASE PARA INATIVA' +
#199#195'O'
'-- DATA: 24/06/2022'
'-- SOLICITADA POR: GUILHERME BARBUDO'
'-- CRIADA POR: GUILHERME BARBUDO'
'--SELECT D.*, '
'--FROM ('
'SELECT'
'D.BASE BASE,'
'D.NOME NOME,'
'D.SENHA SENHA,'
'DECODE (D.STATUS_U, '#39'1'#39', '#39'ATIVO'#39', '#39'0'#39', '#39'INATIVO'#39') STATUS'
'FROM ('
' --BASE CLC'
' SELECT'
' '#39'CLC'#39' BASE,'
' '#39'USUARIO'#39' TABELA,'
' U.USU_NOME NOME,'
' U.USU_SENHA SENHA,'
' U.VEN_CODIGO COD_U,'
' V.USU_CODIGO COD_V,'
' U.USU_ATIVO STATUS_U,'
' V.VEN_ATIVO STATUS_V'
' FROM ORACLC.USUARIO U'
' LEFT JOIN ORACLC.VENDEDOR V'
' ON (V.VEN_CODIGO = U.VEN_CODIGO)'
' '
' UNION ALL'
' '
' --BASE PTK'
' SELECT'
' '#39'PTK'#39' BASE,'
' '#39'USUARIO'#39' TABELA,'
' U.USU_NOME NOME, '
' U.USU_SENHA SENHA,'
' U.VEN_CODIGO COD_U,'
' V.USU_CODIGO COD_V,'
' U.USU_ATIVO STATUS_U,'
' V.VEN_ATIVO STATUS_V'
' FROM ORAPTK.USUARIO U'
' LEFT JOIN ORAPTK.VENDEDOR V'
' ON (V.VEN_CODIGO = U.VEN_CODIGO)'
' '
' UNION ALL'
''
' -- BASE LMK'
' SELECT'
' '#39'LMK'#39' BASE,'
' '#39'USUARIO'#39' TABELA,'
' U.USU_NOME NOME, '
' U.USU_SENHA SENHA,'
' U.VEN_CODIGO COD_U,'
' V.USU_CODIGO COD_V,'
' U.USU_ATIVO STATUS_U,'
' V.VEN_ATIVO STATUS_V'
' FROM ORALMK.USUARIO U'
' LEFT JOIN ORALMK.VENDEDOR V'
' ON (V.VEN_CODIGO = U.VEN_CODIGO)'
' '
' UNION ALL'
' '
' --BASE CSC'
' SELECT'
' '#39'CSC'#39' BASE,'
' '#39'USUARIO'#39' TABELA,'
' U.USU_NOME NOME, '
' U.USU_SENHA SENHA,'
' U.VEN_CODIGO COD_U,'
' V.USU_CODIGO COD_V,'
' U.USU_ATIVO STATUS_U,'
' V.VEN_ATIVO STATUS_V'
' FROM ORACSC.USUARIO U'
' LEFT JOIN ORACSC.VENDEDOR V'
' ON (V.VEN_CODIGO = U.VEN_CODIGO)'
' '
' UNION ALL'
' '
' --BASE PMI'
' SELECT'
' '#39'PMI'#39' BASE,'
' '#39'USUARIO'#39' TABELA,'
' U.USU_NOME NOME, '
' U.USU_SENHA SENHA,'
' U.VEN_CODIGO COD_U,'
' V.USU_CODIGO COD_V,'
' U.USU_ATIVO STATUS_U,'
' V.VEN_ATIVO STATUS_V'
' FROM ORAPMI.USUARIO U'
' LEFT JOIN ORAPMI.VENDEDOR V'
' ON (V.VEN_CODIGO = U.VEN_CODIGO)'
' '
' UNION ALL'
''
' -- BASE PMD'
' SELECT'
' '#39'PMD'#39' BASE,'
' '#39'USUARIO'#39' TABELA,'
' U.USU_NOME NOME, '
' U.USU_SENHA SENHA,'
' U.VEN_CODIGO COD_U,'
' V.USU_CODIGO COD_V,'
' U.USU_ATIVO STATUS_U,'
' V.VEN_ATIVO STATUS_V'
' FROM ORAPMD.USUARIO U'
' LEFT JOIN ORAPMD.VENDEDOR V'
' ON (V.VEN_CODIGO = U.VEN_CODIGO)'
' '
' UNION ALL'
' '
' --BASE STG'
' SELECT'
' '#39'STG'#39' BASE,'
' '#39'USUARIO'#39' TABELA,'
' U.USU_NOME NOME, '
' U.USU_SENHA SENHA,'
' U.VEN_CODIGO COD_U,'
' V.USU_CODIGO COD_V,'
' U.USU_ATIVO STATUS_U,'
' V.VEN_ATIVO STATUS_V'
' FROM ORASTG.USUARIO U'
' LEFT JOIN ORASTG.VENDEDOR V'
' ON (V.VEN_CODIGO = U.VEN_CODIGO)'
' '
' UNION ALL'
' '
' --BASE STR'
' SELECT'
' '#39'STR'#39' BASE,'
' '#39'USUARIO'#39' TABELA,'
' U.USU_NOME NOME, '
' U.USU_SENHA SENHA,'
' U.VEN_CODIGO COD_U,'
' V.USU_CODIGO COD_V,'
' U.USU_ATIVO STATUS_U,'
' V.VEN_ATIVO STATUS_V'
' FROM ORASTR.USUARIO U'
' LEFT JOIN ORASTR.VENDEDOR V'
' ON (V.VEN_CODIGO = U.VEN_CODIGO)'
' '
' UNION ALL'
' '
' --BASE LMF'
' SELECT'
' '#39'LMF'#39' BASE,'
' '#39'USUARIO'#39' TABELA,'
' U.USU_NOME NOME, '
' U.USU_SENHA SENHA,'
' U.VEN_CODIGO COD_U,'
' V.USU_CODIGO COD_V,'
' U.USU_ATIVO STATUS_U,'
' V.VEN_ATIVO STATUS_V'
' FROM ORALMF.USUARIO U'
' LEFT JOIN ORALMF.VENDEDOR V'
' ON (V.VEN_CODIGO = U.VEN_CODIGO)'
' '
' UNION ALL'
' '
' --BASE OLT'
' SELECT'
' '#39'OLT'#39' BASE,'
' '#39'USUARIO'#39' TABELA,'
' U.USU_NOME NOME, '
' U.USU_SENHA SENHA,'
' U.VEN_CODIGO COD_U,'
' V.USU_CODIGO COD_V,'
' U.USU_ATIVO STATUS_U,'
' V.VEN_ATIVO STATUS_V'
' FROM ORAOLT.USUARIO U'
' LEFT JOIN ORAOLT.VENDEDOR V'
' ON (V.VEN_CODIGO = U.VEN_CODIGO)'
''
' ) D'
'WHERE D.NOME = TRIM(UPPER(:NOME))')
Left = 104
Top = 152
ParamData = <
item
Name = 'NOME'
DataType = ftString
ParamType = ptInput
Value = Null
end>
end
object sqlChamados: TFDQuery
Active = True
Connection = Conexao
SQL.Strings = (
'SELECT'
' D.COD,'
' D.SITUACAO,'
' D.SOLICITANTE,'
' D.PROBLEMA,'
' D.DATA,'
' D.INTERACAO,'
' D.DIAS,'
' D.TECNICO,'
' D.CHA_STATUS'
'FROM ('
' SELECT'
' CHA.CHA_CODIGO COD, '
' DECODE(CHA.CHA_SITUACAO,'#39'AB'#39','#39'ABERTO'#39','#39'AG'#39','#39'AGUARDANDO'#39','#39 +
'AN'#39','#39'EM ANDAMENTO'#39','#39'OK'#39','#39'FINALIZADO'#39','#39'SD'#39','#39'SOLIC. DESENV.'#39') SITU' +
'ACAO,'
' USU.USU_NOME SOLICITANTE,'
' CHA.CHA_PROBLEMA PROBLEMA,'
' TO_DATE(CHA.CHA_INCLUIDATA, '#39'DD/MM/RRRR'#39') DATA,'
' TO_DATE(CHA.CHA_ALTERADATA, '#39'DD/MM/RRRR'#39') INTERACAO,'
' TO_DATE(SYSDATE,'#39'DD/MM/RRRR'#39') - TO_DATE(CHA.CHA_INCLUIDAT' +
'A,'#39'DD/MM/RRRR'#39') DIAS,'
' CHA.CHA_TECNICO TECNICO,'
' CASE '
' WHEN CHA.CHA_DEPARTAMENTO IN (2,3,4) AND CHA.CHA_TECNICO' +
' IS NULL AND CHA.CHA_SITUACAO = '#39'AB'#39' THEN 0 --ABER' +
'TO'
' WHEN (CHA.CHA_TECNICO = UPPER(:NOME) OR CHA.CHA_ALT' +
'ERAPOR = UPPER(:NOME)) AND CHA.CHA_SITUACAO = '#39'AG'#39 +
' THEN 1 --AGUARDANDO'
' WHEN (CHA.CHA_TECNICO = UPPER(:NOME) OR CHA.CHA_ALT' +
'ERAPOR = UPPER(:NOME)) AND CHA.CHA_SITUACAO = '#39'AN'#39 +
' THEN 2 --ANDAMENTO'
' WHEN (CHA.CHA_FINALIZADOPOR = UPPER(UPPER(:NOME)) AND CHA' +
'.CHA_TECNICO = UPPER(:NOME)) AND CHA.CHA_SITUACAO = '#39'OK'#39 +
' THEN 3 --FINALIZADO'
' ELSE 500 END CHA_STATUS'
' FROM CHAMADO CHA'
' INNER JOIN USUARIO USU ON (USU.USU_CODIGO = CHA.USU_CODIGO)'
' ORDER BY CHA.CHA_INCLUIDATA'
') D'
'WHERE D.CHA_STATUS = :STATUS')
Left = 32
Top = 152
ParamData = <
item
Name = 'NOME'
DataType = ftString
ParamType = ptInput
Value = Null
end
item
Name = 'STATUS'
DataType = ftInteger
ParamType = ptInput
Value = Null
end>
end
object sqlEAcesso: TFDQuery
Connection = Conexao
SQL.Strings = (
'SELECT --USG_CODIGO CODIGO'
' --USU_CODIGO COD_USU'
' COUNT(D.USU_CODIGO_GRUPO) GRUPO_COD'
' ,D.USU_CODIGO_GRUPO'
' ,D.GRUPO_NOME GRUPO_NOME'
' '
' FROM (SELECT USG.*,'
' (SELECT USU_NOME '
' FROM :BASE.USUARIO'
' WHERE USU_CODIGO = USG.USU_CODIGO) AS USU_NOME,'
' (SELECT USU_NOME'
' FROM :BASE.USUARIO'
' WHERE USU_CODIGO = USG.USU_CODIGO_GRUPO) AS GRU' +
'PO_NOME'
' FROM :BASE.USUARIO_GRUPO USG) D'
' WHERE USU_CODIGO IN (SELECT USU_CODIGO'
' FROM :BASE.USUARIO'
' WHERE USU_NOME IN (UPPER(:NOME1), UPPER(:' +
'NOME2)))'
' GROUP BY USU_CODIGO_GRUPO, GRUPO_NOME'
'HAVING COUNT(USU_CODIGO_GRUPO) < 2')
Left = 168
Top = 152
ParamData = <
item
Name = 'NOME1'
DataType = ftString
ParamType = ptInput
Value = Null
end
item
Name = 'NOME2'
DataType = ftString
ParamType = ptInput
Value = Null
end>
end
object sqlLogEmail: TFDQuery
Connection = Conexao
SQL.Strings = (
'SELECT'
' CLI.CLI_EMAILNFE,'
' NFM.*'
'FROM NFE_EMAIL NFM'
'INNER JOIN NF_UNICA NFU ON (NFU.NFU_CODIGO = NFM.NFU_CODIGO AND ' +
'TRIM(NFU.NFU_SERIE) = TRIM(NFM.NFU_SERIE))'
'INNER JOIN CLIENTE CLI ON (CLI.CLI_CODIGO = NFU.CLI_CODIGO)'
'WHERE NFM.NFU_CODIGO = :NUMERO_NF '
'AND TRIM(NFM.NFU_SERIE) = TRIM(:NF_SERIE)')
Left = 232
Top = 152
ParamData = <
item
Name = 'NUMERO_NF'
DataType = ftInteger
ParamType = ptInput
Value = Null
end
item
Name = 'NF_SERIE'
DataType = ftInteger
ParamType = ptInput
Value = Null
end>
object sqlLogEmailCLI_EMAILNFE: TStringField
FieldName = 'CLI_EMAILNFE'
Origin = 'CLI_EMAILNFE'
Size = 1000
end
object sqlLogEmailNFM_CODIGO: TBCDField
FieldName = 'NFM_CODIGO'
Origin = 'NFM_CODIGO'
Required = True
Precision = 15
Size = 0
end
object sqlLogEmailNFU_CODIGO: TBCDField
FieldName = 'NFU_CODIGO'
Origin = 'NFU_CODIGO'
Precision = 6
Size = 0
end
object sqlLogEmailNFU_SERIE: TStringField
FieldName = 'NFU_SERIE'
Origin = 'NFU_SERIE'
FixedChar = True
Size = 2
end
object sqlLogEmailNFM_ASSUNTO: TStringField
FieldName = 'NFM_ASSUNTO'
Origin = 'NFM_ASSUNTO'
Size = 500
end
object sqlLogEmailNFM_DESTINATARIO: TStringField
FieldName = 'NFM_DESTINATARIO'
Origin = 'NFM_DESTINATARIO'
Size = 500
end
object sqlLogEmailNFM_DEST_CC: TStringField
FieldName = 'NFM_DEST_CC'
Origin = 'NFM_DEST_CC'
Size = 500
end
object sqlLogEmailNFM_DEST_CCO: TStringField
FieldName = 'NFM_DEST_CCO'
Origin = 'NFM_DEST_CCO'
Size = 500
end
object sqlLogEmailNFM_OBSERVACAO: TStringField
FieldName = 'NFM_OBSERVACAO'
Origin = 'NFM_OBSERVACAO'
Size = 2000
end
object sqlLogEmailLOT_CODIGO: TBCDField
FieldName = 'LOT_CODIGO'
Origin = 'LOT_CODIGO'
Required = True
Precision = 15
Size = 0
end
object sqlLogEmailNFM_INCLUIDATA: TDateTimeField
FieldName = 'NFM_INCLUIDATA'
Origin = 'NFM_INCLUIDATA'
Required = True
end
object sqlLogEmailNFM_INCLUIPOR: TStringField
FieldName = 'NFM_INCLUIPOR'
Origin = 'NFM_INCLUIPOR'
Required = True
Size = 40
end
object sqlLogEmailNFM_AUTENTICACAO: TStringField
FieldName = 'NFM_AUTENTICACAO'
Origin = 'NFM_AUTENTICACAO'
Size = 200
end
object sqlLogEmailNFM_SERVER: TStringField
FieldName = 'NFM_SERVER'
Origin = 'NFM_SERVER'
Size = 40
end
object sqlLogEmailNFM_SITUACAO: TStringField
FieldName = 'NFM_SITUACAO'
Origin = 'NFM_SITUACAO'
Size = 2
end
object sqlLogEmailNFM_OWNER: TStringField
FieldName = 'NFM_OWNER'
Origin = 'NFM_OWNER'
end
object sqlLogEmailNFM_DATAENVIO: TDateTimeField
FieldName = 'NFM_DATAENVIO'
Origin = 'NFM_DATAENVIO'
end
end
object dsVBase: TDataSource
DataSet = sqlVBase
Left = 104
Top = 80
end
object dsEAcesso: TDataSource
DataSet = sqlEAcesso
Left = 168
Top = 80
end
object dsLogEmail: TDataSource
AutoEdit = False
DataSet = sqlLogEmail
Left = 232
Top = 80
end
object dsEBase: TDataSource
DataSet = sqlEBase
Left = 304
Top = 80
end
object sqlEBase: TFDQuery
Active = True
Connection = Conexao
SQL.Strings = (
'SELECT BASE, COUNT(A.BASE) QNT'
''
' FROM (SELECT '#39'CLC'#39' BASE, USU.USU_NOME, USU.USU_CODIGO, USU_A' +
'TIVO, VEN.VEN_CODIGO'
' FROM ORACLC.USUARIO USU'
' LEFT JOIN ORACLC.VENDEDOR VEN'
' ON (USU.VEN_CODIGO = VEN.VEN_CODIGO)'
' '
' UNION ALL'
' '
' SELECT '#39'STR'#39' BASE, USU.USU_NOME, USU.USU_CODIGO, USU_ATI' +
'VO, VEN.VEN_CODIGO'
' FROM ORASTR.USUARIO USU'
' LEFT JOIN ORASTR.VENDEDOR VEN'
' ON (USU.VEN_CODIGO = VEN.VEN_CODIGO)'
' '
' UNION ALL'
' '
' SELECT '#39'CSC'#39' BASE, USU.USU_NOME, USU.USU_CODIGO, USU_ATI' +
'VO, VEN.VEN_CODIGO'
' FROM ORACSC.USUARIO USU'
' LEFT JOIN ORACSC.VENDEDOR VEN'
' ON (USU.VEN_CODIGO = VEN.VEN_CODIGO)'
' '
' UNION ALL'
' '
' SELECT '#39'OLT'#39' BASE, USU.USU_NOME, USU.USU_CODIGO, USU_ATI' +
'VO, VEN.VEN_CODIGO'
' FROM ORAOLT.USUARIO USU'
' LEFT JOIN ORAOLT.VENDEDOR VEN'
' ON (USU.VEN_CODIGO = VEN.VEN_CODIGO)'
' '
' UNION ALL'
' '
' SELECT '#39'LMF'#39' BASE, USU.USU_NOME, USU.USU_CODIGO, USU_ATI' +
'VO, VEN.VEN_CODIGO'
' FROM ORALMF.USUARIO USU'
' LEFT JOIN ORALMF.VENDEDOR VEN'
' ON (USU.VEN_CODIGO = VEN.VEN_CODIGO)'
' '
' UNION ALL'
' '
' SELECT '#39'PMD'#39' BASE, USU.USU_NOME, USU.USU_CODIGO, USU_ATI' +
'VO, VEN.VEN_CODIGO'
' FROM ORAPMD.USUARIO USU'
' LEFT JOIN ORAPMD.VENDEDOR VEN'
' ON (USU.VEN_CODIGO = VEN.VEN_CODIGO)'
' '
' UNION ALL'
' '
' SELECT '#39'STG'#39' BASE, USU.USU_NOME, USU.USU_CODIGO, USU_ATI' +
'VO, VEN.VEN_CODIGO'
' FROM ORASTG.USUARIO USU'
' LEFT JOIN ORASTG.VENDEDOR VEN'
' ON (USU.VEN_CODIGO = VEN.VEN_CODIGO)'
' '
' UNION ALL'
' '
' SELECT '#39'LMK'#39' BASE, USU.USU_NOME, USU.USU_CODIGO, USU_ATI' +
'VO, VEN.VEN_CODIGO'
' FROM ORALMK.USUARIO USU'
' LEFT JOIN ORALMK.VENDEDOR VEN'
' ON (USU.VEN_CODIGO = VEN.VEN_CODIGO)'
' '
' UNION ALL'
' '
' SELECT '#39'PTK'#39' BASE, USU.USU_NOME, USU.USU_CODIGO, USU_ATI' +
'VO, VEN.VEN_CODIGO '
' FROM ORAPTK.USUARIO USU'
' LEFT JOIN ORAPTK.VENDEDOR VEN'
' ON (USU.VEN_CODIGO = VEN.VEN_CODIGO)'
' '
' UNION ALL'
' '
' SELECT '#39'PMI'#39' BASE, USU.USU_NOME, USU.USU_CODIGO, USU_ATI' +
'VO, VEN.VEN_CODIGO'
' FROM ORAPMI.USUARIO USU'
' LEFT JOIN ORAPMI.VENDEDOR VEN'
' ON (USU.VEN_CODIGO = VEN.VEN_CODIGO))A'
'WHERE A.USU_NOME = UPPER(:NOME1)'
'OR A.USU_NOME = UPPER(:NOME2)'
'GROUP BY A.BASE'
'HAVING COUNT(A.BASE) < 1')
Left = 304
Top = 152
ParamData = <
item
Name = 'NOME1'
DataType = ftString
ParamType = ptInput
Value = Null
end
item
Name = 'NOME2'
DataType = ftString
ParamType = ptInput
Value = Null
end>
object sqlEBaseBASE: TStringField
FieldName = 'BASE'
Origin = 'BASE'
FixedChar = True
Size = 3
end
object sqlEBaseQNT: TFMTBCDField
FieldName = 'QNT'
Origin = 'QNT'
Precision = 38
Size = 38
end
end
end