*edition du journal tabul‚
*EDITION DES REGIES
TITRE =" JOURNAL DE douanes standard sur une page de 14"
dimension tab[29,4]
tab[1,1]=10
tab[2,1]=22
tab[3,1]=34
tab[4,1]=46
tab[5,1]=58
tab[6,1]=70
tab[7,1]=82
tab[8,1]=94
tab[9,1]=106
tab[10,1]=118
tab[11,1]=130
tab[12,1]=142
tab[13,1]=154
tab[14,1]=166
tab[15,1]=10
tab[16,1]=22
tab[17,1]=34
tab[18,1]=46
tab[19,1]=58
tab[20,1]=70
tab[21,1]=82
tab[22,1]=94
tab[23,1]=106
tab[24,1]=118
tab[25,1]=130
tab[26,1]=142
tab[27,1]=153
tab[28,1]=166
pg=0
ppg=0
for c=1 to 28
tab [c,2]=0.00
tab [c,3]=0.00
tab[c,4]=" "
vtotfac=0
next c
do titre
wait
sele 1
use sdarti index sdarti
set filter to group<>" "
go top
do while .not. eof()
tab[tab,4]=trim(group)
skip
enddo
close data
sele 1
use bgmv index temp alias mv
set filter to group<>" "
*set order to 2
Blanc="               "
go bott
date2=mv->date
go top
date1=mv->date
mois1=cmonth(date1)
mois2=cmonth(date2)
mois=mois1
************
pol1=CHR(27)+"&l1O"+chr(27)+"(s12U"+chr(27)+"(s0P"+chr(27)+"(s12H"+chr(27)+"(s12V"+chr(27)+"(s0S"+chr(27)+"(s0B"+chr(27)+"(s3T"
pol2=CHR(27)+"&l1O"+chr(27)+"&l8D"+chr(27)+"(s12U"+chr(27)+"(s0P"+chr(27)+"(s16H"+chr(27)+"(s10V"+chr(27)+"(s0S"+chr(27)+"(s0B"+chr(27)+"(s3T"
pol3=CHR(27)+"&l1O"+chr(27)+"(s12U"+chr(27)+"(s1P"+chr(27)+"(s5H"+chr(27)+"(s24V"+chr(27)+"(s0S"+chr(27)+"(s0B"+chr(27)+"(s6T"
totfac=0000.00
vtotmois=0
*************
* recherche de la tabulation maxi
vtab=0
go top
do while .not. eof()
if mv->tabul >vtab
vtab=mv->tabul
endi
skip
enddo
vtabmax=vtab
if vtabmax >14
ppg=int(vtabmax/14)+1
endi
? "tab max = ",vtab,"page :",ppg
wait
**********************
go top
vimp=0
sele 2
use bgregd index bgregd alias lig
zap
sele mv
replace all type with "N" for type ="H"
set esca on
go top
do while .not. eof()
vcode=right(dtoc(mv->date),2)+substr(dtoc(mv->date),4,2)+left(dtoc(mv->date),2)+mv->type+mv->group+caps
sele lig
append blank
replace code with vcode,date with mv->date,type with mv->type,groupe with mv->group, caps with mv->caps
replace tabul with mv->tabul
flush
sele mv
do while .t.
replace lig->total with lig->total+mv->q2
? "fiche : "+vcode,lig->total ,recno()
if .not. eof()
skip
else
exit
endif
if vcode = trim(right(dtoc(mv->date),2)+substr(dtoc(mv->date),4,2)+left(dtoc(mv->date),2)+mv->type+mv->group+caps)
*wait
loop
else
exit
endi
enddo
enddo
sele lig
* boucle des pages
do while ppg>0
set print on
? chr(27)+"&l1O"+chr(27)+"&l26A"
? pol2
eject
set margin to 0
set print off
go top
do wHIle .not. eof()
mois=cmonth(lig->date)
set print on
if mois=mois2 .and.lig->tabul> pg*14 .and. lig->tabul <=14+(pg*14)
vimp=1
vtitlig="       "
set margin to 0
else
vimp=0
skip
loop
endi
vcode=left(lig->code,7)
if vimp=1
*****************************titre****************
if prow()<2
? pol3+"REGISTRE DES SORTIES    "+"mois de "+mois+"  "+str(year(lig->date),4)+"  "+societe
?
? pol2 +"   jour   "
for c=14*pg+1 to 14+(14*pg)
??"  "+tab[c,4]+left(blanc,10-len(tab[c,4])
next c
?
?
endi
****************************fin titre***************
?? left(dtoc(lig->date),5)
vt=ltrim(str(tab[1,1]))
do case
case lig->type ="E"
vtitlig="Export"
case lig->type ="C"
vtitlig="C.E.E."
case lig->type ="S"
vtitlig="Sus. Tax."
case lig->caps ="O"
vtitlig="C.R.D."
endcase
??chr(27)+"&a"+vt+"C"+" "+vtitlig
*********creation d'une ligne
do while left(lig->code,7) =vcode
vi=lig->tabul
if vi> pg*14 .and. vi <14+(pg*14)
vt=ltrim(str(tab[vi,1]))
??chr(27)+"&a"+vt+"C"+" "+str(lig->total,7,2)
tab[vi,2]=tab[vi,2]+lig->total
tab[vi,3]=tab[vi,3]+lig->total
vtotmois=vtotmois+lig->total
tab[14+(14*pg),2]=tab[14+(14*pg),2]+lig->total
tab[14+(14*pg),3]=tab[14+(14*pg),3]+lig->total
****
endi    
skip
enddo
for vtb=1 to 14
vt=ltrim(str(tab[vtb,1]-3))
?? chr(27)+"&a"+vt+"C³"
next vtb
vt=ltrim(str(tab[14,1]-1))
??chr(27)+"&a"+vt+"C"+str(tab[14+(14*pg),2],10,2)
?"-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
?
tab[14+(14*pg),2]=0
mois=cmonth(lig->date)
if prow()>53
*impression des totaux colonne
*tab[14+14*pg,2]=vtotmois
?? "total page "
for c=14*pg+2 to 14 +14*pg
vt=ltrim(str(tab[c,1]))
??chr(27)+"&a"+vt+"C"+str(tab[c,2],8,2)
tab[c,2]=0
next C
for c=2 to 14
vt=ltrim(str(tab[c,1]-3))
?? chr(27)+"&a"+vt+"C³"
next C
? " "
?? "cumul avec report"
for c=14*pg+2 to 14 +14*pg
vt=ltrim(str(tab[c,1]))
??chr(27)+"&a"+vt+"C"+str(tab[c,3],8,2)
next C
? "cumul: ",vtotmois
?"                          ."
set print off
wait "attente impression"
set print on
? chr(27)+"&l1O"+chr(27)+"&l26A"
? pol2
eject
set print off
mois1=mois
if .not.eof()
loop
else
exit
endi
endi
endi
enddo
*impression des totaux colonne
*tab[14+14*pg,2]=vtotmois
?? "total page "
for c=14*pg+2 to 14 +14*pg
vt=ltrim(str(tab[c,1]))
??chr(27)+"&a"+vt+"C"+str(tab[c,2],8,2)
tab[c,2]=0
next C
for c=2 to 14
vt=ltrim(str(tab[c,1]-3))
?? chr(27)+"&a"+vt+"C³"
next C
? " "
?? "cumul avec report"
for c=14*pg+2 to 14 +14*pg
vt=ltrim(str(tab[c,1]))
??chr(27)+"&a"+vt+"C"+str(tab[c,3],8,2)
next C
? "cumul g‚n‚ral : ",vtotmois
? "                     ."
set print off
wait
pg=pg+1
ppg=ppg-1
enddo
set print on
? chr(27)+"&l1O"+chr(27)+"&l26A"
? pol2
eject
close data
do pol
set print off
retu
