-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathClient.prg
More file actions
13378 lines (10060 loc) · 439 KB
/
Client.prg
File metadata and controls
13378 lines (10060 loc) · 439 KB
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
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "FiveWin.Ch"
#include "Report.ch"
#include "Folder.ch"
#include "Label.ch"
#include "RichEdit.ch"
#include "Xbrowse.ch"
#include "FastRepH.ch"
#include "Factu.ch"
#include "Ini.ch"
#define _COD 1
#define _TITULO 2
#define _NIF 3
#define _DOMICILIO 4
#define _POBLACION 5
#define _PROVINCIA 6
#define _CODPOSTAL 7
#define _TELEFONO 8
#define _FAX 9
#define _MOVIL 10
#define _NBREST 11
#define _DIREST 12
#define _DIAPAGO 13
#define _DIAPAGO2 14
#define _BANCO 15
#define _DIRBANCO 16
#define _POBBANCO 17
#define _CPROBANCO 18
#define _CUENTA 19
#define _NTIPCLI 20
#define _CODPAGO 21
#define _CDTOESP 22
#define _NDTOESP 23
#define _CDPP 24
#define _NDPP 25
#define _NDTOCNT 26
#define _NDTORAP 27
#define _CDTOUNO 28
#define _CDTODOS 29
#define _NDTOPTF 30
#define _RIESGO 31
#define _COPIASF 32
#define _SERIE 33
#define _NREGIVA 34
#define _LREQ 35
#define _SUBCTA 36
#define _CTAVENTA 37
#define _CAGENTE 38
#define _LMAYORISTA 39
#define _NTARIFA 40
#define _LLABEL 41
#define _NLABEL 42
#define _CCODTAR 43
#define _MCOMENT 44
#define _CCODRUT 45
#define _CCODRUT2 46
#define _CCODPAI 47
#define _CCODGRP 48
#define _CCODREM 49
#define _CMEIINT 50
#define _CWEBINT 51
#define _LCHGPRE 52
#define _LCRESOL 53
#define _LPNTVER 54
#define _CUSRDEF01 55
#define _CUSRDEF02 56
#define _CUSRDEF03 57
#define _CUSRDEF04 58
#define _CUSRDEF05 59
#define _CUSRDEF06 60
#define _CUSRDEF07 61
#define _CUSRDEF08 62
#define _CUSRDEF09 63
#define _CUSRDEF10 64
#define _LVISLUN 65
#define _LVISMAR 66
#define _LVISMIE 67
#define _LVISJUE 68
#define _LVISVIE 69
#define _LVISSAB 70
#define _LVISDOM 71
#define _NVISLUN 72
#define _NVISMAR 73
#define _NVISMIE 74
#define _NVISJUE 75
#define _NVISVIE 76
#define _NVISSAB 77
#define _NVISDOM 78
#define _CAGELUN 79
#define _CAGEMAR 80
#define _CAGEMIE 81
#define _CAGEJUE 82
#define _CAGEVIE 83
#define _CAGESAB 84
#define _CAGEDOM 85
#define _LSNDINT 86
#define _CPERCTO 87
#define _CCODALM 88
#define _NMESVAC 89
#define _NIMPRIE 90
#define _NCOLOR 91
#define _SUBCTADTO 92
#define _LBLQCLI 93
#define _LMOSCOM 94
#define _LTOTALB 95
#define _CDTOATP 96
#define _NDTOATP 97
#define _NSBRATP 98
#define _CCODUSR 99
#define _DFECCHG 100
#define _CTIMCHG 101
#define _NTIPRET 102
#define _NPCTRET 103
#define _DFECBLQ 104
#define _CMOTBLQ 105
#define _LMODDAT 106
#define _LMAIL 107
#define _CCODTRN 108
#define _MOBSERV 109
#define _LPUBINT 110
#define _CCLAVE 111
#define _CCODWEB 112
#define _CCODEDI 113
#define _CFACAUT 114
#define _LWEB 115
#define _NDTOART 116
#define _LEXCFID 117
#define _MFACAUT 118
#define _DFECNACI 119
#define _NSEXO 120
#define _NTARCMB 121
#define _DLLACLI 122
#define _CTIMCLI 123
#define _TELEFONO2 124
#define _MOVIL2 125
#define _CAGENTE2 126
#define _CDEPARTA 127
#define _CDOMENT 128
#define _CPOBENT 129
#define _CCPENT 130
#define _CPRVENT 131
#define _CPROVEE 132
#define _CCODBIC 133
#define _CHORARIO 134
#define _CENTIDAD 135
#define _DPETRIE 136
#define _DCONRIE 137
#define _LINACLI 138
#define _DFECINA 139
#define _CMOTINA 140
#define _DALTA 141
#define _UUID 142
#define _aCCODCLI 1 // C 12 0
#define _aCCODGRP 2 // C 12 0
#define _aCCODART 3 // C 14 0
#define _aCCODFAM 4 // C 8 0
#define _aNTIPATP 5 // N 1 0
#define _aCCODPR1 6 // C 5 0
#define _aCVALPR1 7 // C 5 0
#define _aCCODPR2 8 // C 5 0
#define _aCVALPR2 9 // C 5 0
#define _aDFECINI 10 // D 8 0
#define _aDFECFIN 11 // D 8 0
#define _aLPRCCOM 12 // L 1 0
#define _aNPRCCOM 13 // N 16 6
#define _aNPRCART 14 // N 16 6
#define _aNPRCART2 15 // N 16 6
#define _aNPRCART3 16 // N 16 6
#define _aNPRCART4 17 // N 16 6
#define _aNPRCART5 18 // N 16 6
#define _aNPRCART6 19 // N 16 6
#define _aNPREIVA1 20 // N 16 6
#define _aNPREIVA2 21 // N 16 6
#define _aNPREIVA3 22 // N 16 6
#define _aNPREIVA4 23 // N 16 6
#define _aNPREIVA5 24 // N 16 6
#define _aNPREIVA6 25 // N 16 6
#define _aNDTOART 26 // N 6 2
#define _aNDPRART 27 // N 6 2
#define _aLCOMAGE 28 // L 1 0
#define _aNCOMAGE 29 // N 6 2
#define _aNDTODIV 30 // N 16 6
#define _aLAPLPRE 31 // L 1 0
#define _aLAPLPED 32 // L 1 0
#define _aLAPLALB 33 // L 1 0
#define _aLAPLFAC 34 // L 1 0
#define _aLAPLSAT 35 // L 1 0
#define _aNUNVOFE 36 // N 3 0
#define _aNUNCOFE 37 // N 3 0
#define _aNTIPXBY 38 // N 1 0
#define _aNDTO1 39 // N 16 6
#define _aNDTO2 40 // N 16 6
#define _aNDTO3 41 // N 16 6
#define _aNDTO4 42 // N 16 6
#define _aNDTO5 43 // N 16 6
#define _aNDTO6 44 // N 16 6
#define _aCCODAGE 45 // C 3 0
#define _aCCODENV 46 // C 3 0
#define fldGeneral oFld:aDialogs[1]
#define fldComercial oFld:aDialogs[2]
#define fldImpuestos oFld:aDialogs[3]
#define fldAutomaticas oFld:aDialogs[4]
#define fldDirecciones oFld:aDialogs[5]
#define fldBancos oFld:aDialogs[6]
#define fldContabilidad oFld:aDialogs[7]
#define fldDefinidos oFld:aDialogs[8]
#define fldTarifa oFld:aDialogs[9]
#define fldDocumentos oFld:aDialogs[10]
#define fldIncidencias oFld:aDialogs[11]
#define fldObservaciones oFld:aDialogs[12]
#define fldContactos oFld:aDialogs[13]
#define fldFacturae oFld:aDialogs[14]
#define fldRecibos oFld:aDialogs[15]
#define FW_BOLD 700
memvar dbfCli
memvar cDbfCli
memvar dbfObr
memvar cDbfObr
memvar dbfCon
memvar cDbfCon
static oWndBrw
static dbfConfig
static nView
static filClient
static tmpClient
static dbfPro
static dbfProL
static dbfArtKit
static dbfFPago
static dbfDoc
static cFpago
static dbfFamilia
static oBandera
static dbfAlmT
static dbfRuta
static dbfTmpDoc
static dbfTmpFacturae
static dbfTmpObr
static dbfTmpBnc
static dbfTmpAtp
static dbfTmpInc
static dbfTmpCon
static dbfTmpSubCta
static dbfArtDiv
static dbfOfe
static oTransportistaSelector
static cTmpDoc
static cTmpFacturae
static cTmpObr
static cTmpBnc
static cTmpAtp
static cTmpCta
static cTmpInc
static cTmpCon
static oFacAut
static oGrpCli
static oPais
static oCtaRem
static cAgente
static oNewImp
static oEnvases
static oGetTarifa
static cPinDiv
static cPouDiv
static cPorDiv
static aRgbColor
static oMenu
static oStock
static oBanco
static aFacAut := {}
static oFecIniCli
static oFecFinCli
static dFecIniCli
static dFecFinCli
static oEstadoCli
static aEstadoCli := { "Pendientes", "Pagados", "Todos" }
static cEstadoCli
static oPeriodoCli
static aPeriodoCli := {}
static cPeriodoCli
static cDescuentosAtipicos
static aDescuentosAtipicos
static oBrwRecCli
static oRTF
static cRTF
static lBold
static lItalic
static lUnderline
static lBullet
static aRentabilidad := { { "", "", 0, .t., .f. } }
static aStrClients := { "Clientes", "Potenciales", "Web" }
static lExpandida := .f.
static lExternal := .f.
static lOpenFiles := .f.
static nLabels := 1
static cIniCli
static oDetCamposExtra
static oEntidades
static aEntidades := {}
static bEdtRec := { | aTmp, aGet, dbf, oBrw, bWhen, bValid, nMode | EdtRec( aTmp, aGet, dbf, oBrw, bWhen, bValid, nMode ) }
static bEdtBig := { | aTmp, aGet, dbf, oBrw, bWhen, bValid, nMode | EdtBig( aTmp, aGet, dbf, oBrw, bWhen, bValid, nMode ) }
static bEdtAtp := { | aTmp, aGet, dbf, oBrw, bWhen, bValid, nMode | EdtAtp( aTmp, aGet, dbf, oBrw, bWhen, bValid, nMode ) }
static bEdtDoc := { | aTmp, aGet, dbf, oBrw, bWhen, bValid, nMode, cCodCli | EdtDoc( aTmp, aGet, dbf, oBrw, bWhen, bValid, nMode, cCodCli ) }
static bEdtBnc := { | aTmp, aGet, dbf, oBrw, bWhen, bValid, nMode, cCodCli | EdtBnc( aTmp, aGet, dbf, oBrw, bWhen, bValid, nMode, cCodCli ) }
static bEdtInc := { | aTmp, aGet, dbf, oBrw, bWhen, bValid, nMode | EdtInc( aTmp, aGet, dbf, oBrw, bWhen, bValid, nMode ) }
static bEdtFacturae := { | aTmp, aGet, dbf, oBrw, bWhen, bValid, nMode, cCodCli | EdtFacturae( aTmp, aGet, dbf, oBrw, bWhen, bValid, nMode, cCodCli ) }
static oReporting
static oMailing
//-----------------------------------------------------------------------------
STATIC FUNCTION OpenFiles( lExt )
local oBlock
local oError
if lOpenFiles
MsgStop( 'Imposible abrir ficheros de clientes' )
Return ( .f. )
end if
DEFAULT lExt := .f.
lExternal := lExt
oBlock := ErrorBlock( {| oError | ApoloBreak( oError ) } )
BEGIN SEQUENCE
DisableAcceso()
nView := D():CreateView()
lOpenFiles := .t.
D():Clientes( nView )
D():TiposIva( nView )
D():Divisas( nView )
D():Atipicas( nView )
D():Articulos( nView )
D():AlbaranesClientes( nView )
D():FacturasClientes( nView )
D():FacturasClientesCobros( nView )
( D():FacturasClientesCobros( nView ) )->( OrdSetFocus( "cCodCli" ) )
D():ClientesEntidad( nView )
D():Empresa( nView )
D():ClientesDirecciones( nView )
D():ClientesBancos( nView )
D():ClientesIncidencias( nView )
D():ClientesDocumentos( nView )
D():ClientesContactos( nView )
/*
Articulos-------------------------------------------------------------------
*/
USE ( cPatEmp() + "ARTKIT.DBF" ) NEW VIA ( cDriver() ) SHARED ALIAS ( cCheckArea( "ARTTIK", @dbfArtKit ) )
SET ADSINDEX TO ( cPatEmp() + "ARTKIT.CDX" ) ADDITIVE
USE ( cPatEmp() + "AGENTES.DBF" ) NEW VIA ( cDriver() ) SHARED ALIAS ( cCheckArea( "AGENTES", @cAgente ) )
SET ADSINDEX TO ( cPatEmp() + "AGENTES.CDX" ) ADDITIVE
/*
Otros Ficheros--------------------------------------------------------------
*/
USE ( cPatEmp() + "FPAGO.DBF" ) NEW VIA ( cDriver() ) SHARED ALIAS ( cCheckArea( "FPAGO", @dbfFPago ) )
SET ADSINDEX TO ( cPatEmp() + "FPAGO.CDX" ) ADDITIVE
USE ( cPatEmp() + "FAMILIAS.DBF" ) NEW VIA ( cDriver() ) SHARED ALIAS ( cCheckArea( "FAMILIAS", @dbfFamilia ) )
SET ADSINDEX TO ( cPatEmp() + "FAMILIAS.CDX" ) ADDITIVE
USE ( cPatEmp() + "ALMACEN.DBF" ) NEW VIA ( cDriver() ) SHARED ALIAS ( cCheckArea( "ALMACEN", @dbfAlmT ) )
SET ADSINDEX TO ( cPatEmp() + "ALMACEN.CDX" ) ADDITIVE
USE ( cPatEmp() + "PRO.DBF" ) NEW VIA ( cDriver() ) SHARED ALIAS ( cCheckArea( "PRO", @dbfPro ) )
SET ADSINDEX TO ( cPatEmp() + "PRO.CDX" ) ADDITIVE
USE ( cPatEmp() + "TBLPRO.DBF" ) NEW VIA ( cDriver() ) SHARED ALIAS ( cCheckArea( "TBLPRO", @dbfProL ) )
SET ADSINDEX TO ( cPatEmp() + "TBLPRO.CDX" ) ADDITIVE
USE ( cPatEmp() + "RDOCUMEN.DBF" ) NEW SHARED VIA ( cDriver() ) ALIAS ( cCheckArea( "RDOCUMEN", @dbfDoc ) )
SET ADSINDEX TO ( cPatEmp() + "RDOCUMEN.CDX" ) ADDITIVE
SET TAG TO "CTIPO"
USE ( cPatEmp() + "OFERTA.DBF" ) NEW VIA ( cDriver() ) SHARED ALIAS ( cCheckArea( "OFERTA", @dbfOfe ) )
SET ADSINDEX TO ( cPatEmp() + "OFERTA.CDX" ) ADDITIVE
USE ( cPatEmp() + "ARTDIV.DBF" ) NEW VIA ( cDriver() ) SHARED ALIAS ( cCheckArea( "ARTDIV", @dbfArtDiv ) )
SET ADSINDEX TO ( cPatEmp() + "ARTDIV.CDX" ) ADDITIVE
USE ( cPatEmp() + "RUTA.DBF" ) NEW VIA ( cDriver() ) SHARED ALIAS ( cCheckArea( "RUTA", @dbfRuta ) )
SET ADSINDEX TO ( cPatEmp() + "RUTA.CDX" ) ADDITIVE
oBandera := TBandera():New()
oStock := TStock():Create( cPatEmp() )
if !oStock:lOpenFiles()
lOpenFiles := .f.
end if
oPais := TPais():Create( cPatDat() )
if !oPais:OpenFiles()
lOpenFiles := .f.
end if
oCtaRem := TCtaRem():Create( cPatEmp() )
if !oCtaRem:OpenFiles()
lOpenFiles := .f.
end if
oNewImp := TNewImp():Create( cPatEmp() )
if !oNewImp:OpenFiles()
lOpenFiles := .f.
end if
oFacAut := TFacAutomatica():Create( cPatEmp() )
if !oFacAut:Openfiles()
lOpenfiles := .f.
end if
oBanco := TBancos():Create()
oBanco:OpenFiles()
oGrpCli := TGrpCli():Create()
if !oGrpCli:OpenFiles()
lOpenFiles := .f.
end if
oDetCamposExtra := TDetCamposExtra():New()
if !oDetCamposExtra:OpenFiles()
lOpenFiles := .f.
end if
oDetCamposExtra:SetTipoDocumento( "Clientes" )
oDetCamposExtra:setbId( {|| D():ClientesId( nView ) } )
oEntidades := TEntidades():Create()
if !oEntidades:OpenFiles()
lOpenFiles := .f.
end if
CodigosPostales():GetInstance():OpenFiles()
oTransportistaSelector := TransportistasController():New()
oEnvases := TFrasesPublicitarias():Create( cPatEmp() )
if !oEnvases:OpenFiles()
lOpenFiles := .f.
end if
cPinDiv := cPinDiv( cDivEmp() ) // Picture de la divisa de compra
cPouDiv := cPouDiv( cDivEmp() ) // Picture de la divisa
cPorDiv := cPorDiv( cDivEmp() ) // Picture de la divisa redondeada
LoaIniCli( cPatEmp() )
oMailing := TGenMailingClientes():New( nView )
EnableAcceso()
RECOVER USING oError
lOpenFiles := .f.
EnableAcceso()
msgStop( ErrorMessage( oError ), "Imposible abrir todas las bases de datos de clientes" )
END SEQUENCE
ErrorBlock( oBlock )
if !lOpenFiles
CloseFiles()
end if
RETURN ( lOpenFiles )
//--------------------------------------------------------------------------//
STATIC FUNCTION CloseFiles( lDestroy )
DEFAULT lDestroy := .f.
DisableAcceso()
if oGrpCli != nil
oGrpCli:End()
end if
CLOSE ( dbfArtKit )
CLOSE ( cFPago )
CLOSE ( cAgente )
CLOSE ( dbfFPago )
CLOSE ( dbfAlmT )
CLOSE ( dbfFamilia )
CLOSE ( dbfPro )
CLOSE ( dbfProL )
CLOSE ( dbfDoc )
CLOSE ( dbfOfe )
CLOSE ( dbfArtDiv )
CLOSE ( dbfRuta )
if !Empty( oStock )
oStock:end()
end if
if oPais != nil
oPais:end()
end if
if oCtaRem != nil
oCtaRem:end()
end if
if oNewImp != nil
oNewImp:end()
end if
if !Empty( oFacAut )
oFacAut:End()
end if
if !Empty( oEnvases )
oEnvases:end()
end if
if !Empty( oBanco )
oBanco:End()
end if
if !Empty( oDetCamposExtra )
oDetCamposExtra:CloseFiles()
end if
if !empty( oEntidades )
oEntidades:End()
end if
if !empty(oMailing)
oMailing:end()
end if
if !Empty( oTransportistaSelector )
oTransportistaSelector:End()
end if
CodigosPostales():GetInstance():CloseFiles()
D():DeleteView( nView )
dbfArtKit := nil
cFPago := nil
cAgente := nil
dbfFPago := nil
dbfAlmT := nil
dbfFamilia := nil
dbfPro := nil
dbfProL := nil
dbfDoc := nil
dbfOfe := nil
dbfArtDiv := nil
dbfRuta := nil
oDetCamposExtra := nil
oEnvases := nil
if lDestroy
oWndBrw := nil
end if
lOpenFiles := .f.
enableAcceso()
Return .t.
//--------------------------------------------------------------------------//
//Funciones del programa
//--------------------------------------------------------------------------//
FUNCTION Client( oMenuItem, oWnd, cCodCli )
local oSnd
local oRpl
local oDel
local nLevel
local oRotor
local oScript
DEFAULT oMenuItem := "01032"
DEFAULT oWnd := oWnd()
if Empty( oWndBrw )
/*
Obtenemos el nivel de acceso---------------------------------------------
*/
nLevel := Auth():Level( oMenuItem )
if nAnd( nLevel, 1 ) == 0
msgStop( "Acceso no permitido." )
return nil
end if
/*
Cerramos todas las ventanas----------------------------------------------
*/
if oWnd != nil
SysRefresh(); oWnd:CloseAll(); SysRefresh()
end if
/*
Apertura de ficheros-----------------------------------------------------
*/
if !OpenFiles( .f. )
return nil
end if
/*
Anotamos el movimiento para el navegador---------------------------------
*/
DisableAcceso()
DEFINE SHELL oWndBrw FROM 0, 0 TO 22, 80 ;
XBROWSE ;
TITLE "Clientes" ;
PROMPT "Código cliente",;
"Nombre",;
if( uFieldEmpresa( "nCifRut" ) == 1, "NIF/CIF", "RUT" ),;
"Domicilio",;
"Población",;
"Provincia",;
"Código postal",;
"Teléfono",;
"Establecimiento",;
"Correo electrónico",;
"Cliente web" ,;
"Ruta" ;
ALIAS ( D():Clientes( nView ) );
MRU "gc_user_16";
APPEND ( WinAppRec( oWndBrw:oBrw, bEdtRec, D():Clientes( nView ) ) );
DUPLICAT ( WinDupRec( oWndBrw:oBrw, bEdtRec, D():Clientes( nView ) ) );
EDIT ( WinEdtRec( oWndBrw:oBrw, bEdtRec, D():Clientes( nView ) ) ) ;
DELETE ( WinDelRec( oWndBrw:oBrw, D():Clientes( nView ), {|| DelDetalle( ( D():Clientes( nView ) )->Cod ) } ) ) ;
LEVEL nLevel ;
OF oWnd
with object ( oWndBrw:AddXCol() )
:cHeader := "Bloqueado"
:nHeadBmpNo := 3
:bStrData := {|| "" }
:bEditValue := {|| ( D():Clientes( nView ) )->lBlqCli }
:nWidth := 20
:SetCheck( { "gc_sign_stop_12", "Nil16" } )
:AddResource( "gc_sign_stop_16" )
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Envio"
:cSortOrder := "lSndInt"
:nHeadBmpNo := 3
:bStrData := {|| "" }
:bEditValue := {|| ( D():Clientes( nView ) )->lSndInt }
:nWidth := 20
:SetCheck( { "gc_mail2_12", "Nil16" } )
:AddResource( "gc_mail2_16" )
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Internet"
:cSortOrder := "lPubInt"
:nHeadBmpNo := 3
:bStrData := {|| "" }
:bEditValue := {|| ( D():Clientes( nView ) )->lPubInt }
:nWidth := 20
:lHide := .t.
:SetCheck( { "gc_earth_12", "Nil16" } )
:AddResource( "gc_earth_16" )
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Tarifas atipicas"
:nHeadBmpNo := 3
:bStrData := {|| "" }
:bEditValue := {|| ( D():Atipicas( nView ) )->( dbSeek( ( D():Clientes( nView ) )->Cod ) ) }
:nWidth := 20
:SetCheck( { "gc_symbol_percent_12", "Nil16" } )
:AddResource( "gc_symbol_percent_16" )
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Potencial"
:nHeadBmpNo := 3
:bStrData := {|| "" }
:bEditValue := {|| ( D():Clientes( nView ) )->nTipCli == 2 }
:nWidth := 20
:SetCheck( { "gc_id_card_hint_12", "Nil16" } )
:AddResource( "gc_id_card_hint_16" )
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Inactivo"
:bStrData := {|| if( ( D():Clientes( nView ) )->lInaCli, "Inactivo", "" ) }
:nWidth := 60
:lHide := .t.
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Código cliente"
:cSortOrder := "Cod"
:bEditValue := {|| ( D():Clientes( nView ) )->Cod }
:nWidth := 110
:bLClickHeader := {| nMRow, nMCol, nFlags, oCol | oWndBrw:ClickOnHeader( oCol ) }
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Nombre"
:cSortOrder := "Titulo"
:bEditValue := {|| ( D():Clientes( nView ) )->Titulo }
:nWidth := 280
:bLClickHeader := {| nMRow, nMCol, nFlags, oCol | oWndBrw:ClickOnHeader( oCol ) }
end with
with object ( oWndBrw:AddXCol() )
if uFieldEmpresa( "nCifRut" ) == 1
:cHeader := "NIF/CIF"
else
:cHeader := "RUT"
:cEditPicture := "@R 999999999-9"
end if
:cSortOrder := "Nif"
:bEditValue := {|| ( D():Clientes( nView ) )->Nif }
:nWidth := 80
:bLClickHeader := {| nMRow, nMCol, nFlags, oCol | oWndBrw:ClickOnHeader( oCol ) }
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Teléfono"
:cSortOrder := "Telefono"
:bEditValue := {|| ( D():Clientes( nView ) )->Telefono }
:nWidth := 80
:bLClickHeader := {| nMRow, nMCol, nFlags, oCol | oWndBrw:ClickOnHeader( oCol ) }
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Fax"
:bEditValue := {|| ( D():Clientes( nView ) )->Fax }
:nWidth := 80
:bLClickHeader := {| nMRow, nMCol, nFlags, oCol | oWndBrw:ClickOnHeader( oCol ) }
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Domicilio"
:cSortOrder := "Domicilio"
:bEditValue := {|| ( D():Clientes( nView ) )->Domicilio }
:nWidth := 300
:bLClickHeader := {| nMRow, nMCol, nFlags, oCol | oWndBrw:ClickOnHeader( oCol ) }
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Población"
:cSortOrder := "Poblacion"
:bEditValue := {|| ( D():Clientes( nView ) )->Poblacion }
:nWidth := 200
:bLClickHeader := {| nMRow, nMCol, nFlags, oCol | oWndBrw:ClickOnHeader( oCol ) }
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Código postal"
:cSortOrder := "CodPostal"
:bEditValue := {|| ( D():Clientes( nView ) )->CodPostal }
:nWidth := 60
:bLClickHeader := {| nMRow, nMCol, nFlags, oCol | oWndBrw:ClickOnHeader( oCol ) }
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Provincia"
:cSortOrder := "Provincia"
:bEditValue := {|| ( D():Clientes( nView ) )->Provincia }
:nWidth := 100
:bLClickHeader := {| nMRow, nMCol, nFlags, oCol | oWndBrw:ClickOnHeader( oCol ) }
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Establecimiento"
:cSortOrder := "NbrEst"
:bEditValue := {|| ( D():Clientes( nView ) )->NbrEst }
:nWidth := 100
:bLClickHeader := {| nMRow, nMCol, nFlags, oCol | oWndBrw:ClickOnHeader( oCol ) }
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Correo electrónico"
:cSortOrder := "cMeiInt"
:bEditValue := {|| ( D():Clientes( nView ) )->cMeiInt }
:nWidth := 100
:bLClickHeader := {| nMRow, nMCol, nFlags, oCol | oWndBrw:ClickOnHeader( oCol ) }
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Riesgo"
:bEditValue := {|| Trans( ( D():Clientes( nView ) )->Riesgo, PicOut() ) }
:nWidth := 60
:nDataStrAlign := AL_RIGHT
:nHeadStrAlign := AL_RIGHT
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Contacto"
:bEditValue := {|| ( D():Clientes( nView ) )->cPerCto }
:nWidth := 200
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Comentarios"
:bEditValue := {|| ( D():Clientes( nView ) )->mComent }
:nWidth := 200
:lHide := .t.
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Observaciones"
:bEditValue := {|| cTextRichText( ( D():Clientes( nView ) )->mObserv ) }
:nWidth := 200
:lHide := .t.
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Cliente web"
:cSortOrder := "cCliWeb"
:bEditValue := {|| aStrClients[ Min( Max( ( D():Clientes( nView ) )->nTipCli, 1 ), len( aStrClients ) ) ] }
:nWidth := 100
:bLClickHeader := {| nMRow, nMCol, nFlags, oCol | oWndBrw:ClickOnHeader( oCol ) }
:lHide := .t.
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Ruta"
:cSortOrder := "cCodRut"
:bEditValue := {|| ( D():Clientes( nView ) )->cCodRut + if( !Empty( ( D():Clientes( nView ) )->cCodRut ), " - ", "" ) + RetFld( ( D():Clientes( nView ) )->cCodRut, dbfRuta ) }
:nWidth := 100
:bLClickHeader := {| nMRow, nMCol, nFlags, oCol | oWndBrw:ClickOnHeader( oCol ) }
:lHide := .t.
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Pago"
:bEditValue := {|| ( D():Clientes( nView ) )->CodPago + if( !Empty( ( D():Clientes( nView ) )->CodPago ), " - " , "" ) + RetFld( ( D():Clientes( nView ) )->CodPago, dbfFPago ) }
:nWidth := 200
:lHide := .t.
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Última venta"
:bEditValue := {|| dtoc( dUltimaVentaCliente( ( D():Clientes( nView ) )->Cod, D():AlbaranesClientes( nView ), D():FacturasClientes( nView ) ) ) }
:nWidth := 80
:lHide := .t.
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Última llamada"
:bEditValue := {|| dtoc( ( D():Clientes( nView ) )->dLlaCli ) + space( 1 ) + ( D():Clientes( nView ) )->cTimCli }
:nWidth := 100
:lHide := .t.
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Agente"
:bEditValue := {|| if( !Empty( ( D():Clientes( nView ) )->cAgente ), ( D():Clientes( nView ) )->cAgente + " - " + RetNbrAge( ( D():Clientes( nView ) )->cAgente, cAgente ), "" ) }
:nWidth := 200
:lHide := .t.
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Transportista"
:bEditValue := {|| AllTrim( ( D():Clientes( nView ) )->cCodTrn ) + " - " + SQLTransportistasModel():getNombreWhereCodigo( ( D():Clientes( nView ) )->cCodTrn ) }
:nWidth := 180
:lHide := .t.
end with
with object ( oWndBrw:AddXCol() )
:cHeader := "Grupo"
:bEditValue := {|| alltrim( ( D():Clientes( nView ) )->cCodGrp ) + " - " + oGrpCli:nombreGrupo( ( D():Clientes( nView ) )->cCodGrp ) }
:nWidth := 200
:lHide := .t.
end with
with object ( oWndBrw:AddCol() )
:cHeader := "Alta"
:cEditPicture := "@D"
:bEditValue := {|| ( D():Clientes( nView ) )->dAlta }
:nWidth := 80
:lHide := .t.
:nEditType := 1
:nDataStrAlign := 1
:nHeadStrAlign := 1
:bOnPostEdit := {|oCol, uNewValue| if( dbDialogLock( D():Clientes( nView ) ),;
( ( D():Clientes( nView ) )->dAlta := uNewValue, ( D():Clientes( nView ) )->( dbUnlock() ) ),;
) }
end with
oWndBrw:cHtmlHelp := "Clientes"
oDetCamposExtra:addCamposExtra( oWndBrw )
oWndBrw:CreateXFromCode()
DEFINE BTNSHELL RESOURCE "BUS" OF oWndBrw ;
NOBORDER ;
ACTION ( oWndBrw:SearchSetFocus() ) ;
TOOLTIP "(B)uscar" ;
HOTKEY "B"
oWndBrw:AddSeaBar( "justZero", retNumCodCliEmp() )
DEFINE BTNSHELL RESOURCE "NEW" OF oWndBrw ;
NOBORDER ;
ACTION ( oWndBrw:RecAdd() );
ON DROP ( oWndBrw:RecDup() );
TOOLTIP "(A)ñadir";
BEGIN GROUP;
HOTKEY "A" ;
LEVEL ACC_APPD
DEFINE BTNSHELL RESOURCE "DUP" OF oWndBrw ;
NOBORDER ;
ACTION ( oWndBrw:RecDup() );
TOOLTIP "(D)uplicar";
HOTKEY "D" ;
LEVEL ACC_APPD
DEFINE BTNSHELL RESOURCE "EDIT" OF oWndBrw ;
NOBORDER ;
ACTION ( oWndBrw:RecEdit() );
TOOLTIP "(M)odificar";
HOTKEY "M" ;
LEVEL ACC_EDIT
DEFINE BTNSHELL RESOURCE "ZOOM" OF oWndBrw ;
NOBORDER ;
ACTION ( WinZooRec( oWndBrw:oBrw, bEdtRec, ( D():Clientes( nView ) ) ) );
TOOLTIP "(Z)oom";
HOTKEY "Z"
DEFINE BTNSHELL oDel RESOURCE "DEL" OF oWndBrw ;
NOBORDER ;
ACTION ( oWndBrw:RecDel() );
TOOLTIP "(E)liminar";
HOTKEY "E" ;
LEVEL ACC_DELE
DEFINE BTNSHELL RESOURCE "DEL" OF oWndBrw ;
NOBORDER ;
ACTION ( TDelTarifasClientes():New() );
TOOLTIP "Eliminar tarifas" ;