*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]=154
tab[28,1]=166
pg=0
ppg=0
vtotcum=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
use bgmv index temp alias mv
set filter to group<>" ".and.&vfiltre
*set order to 2
Blanc="               "
go bott
date2=mv->date
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"+ch
pol2=CHR(27)+"&l1O"+chr(27)+"&l8D"+chr(27)+"(s12U"+chr(27)+"(s0P"+chr(27)+"(s16H"+chr(27)+"(s10V"+ch
pol3=CHR(27)+"&l1O"+chr(27)+"(s12U"+chr(27)+"(s1P"+chr(27)+"(s5H"+chr(27)+"(s24V"+chr(27)+"(s0S"+chr
totfac=0000.00
vtotmois=0
vcummois=0
*************
* recherche de la tabulation maxi
vtab=0
if mv->tabul >vtab
vtab=mv->tabul
endi
vtabmax=vtab
if vtabmax >13
ppg=int(vtabmax/13)+1
? "tab max = ",vtab,"page :",ppg
**********************
vimp=0
sele 2
use bgregd index bgregd alias lig
zap
sele mv
replace all type with "N" for type ="H"
set esca on
vcode=right(dtoc(mv->date),2)+substr(dtoc(mv->date),4,2)+left(dtoc(mv->date),2)+mv->type+mv->group+c
sele lig
append blank
replace code with vcode,date with mv->date,type with mv->type,groupe with mv->group, caps with mv->c
replace tabul with mv->tabul,numfact with mv->numfact
flush
do while .t.
replace lig->total with lig->total+mv->q2
? "fiche : "+vcode,lig->total ,recno()
if .not. eof()
else
exit
endif
if vcode = trim(right(dtoc(mv->date),2)+substr(dtoc(mv->date),4,2)+left(dtoc(mv->date),2)+mv->type+m
*wait
loop
index on groupe to bgregg
*préparation des cumuls
vgroup=lig->groupe
do while lig->groupe = vgroup
tab[lig->tabul,3]=tab[lig->tabul,3]+lig->total
set index to bgregd,bgregg
*équilibrage des lignes
*pour chaque jour vérifier qu'il y a une tabul <14 et une >15 sinon en créer une
ex=0
vdaa=lig->daa
tabmax=14
tabmin=18
vcode =lig->code
vdate=lig->date
vtype=lig->type
vcaps=lig->caps
vfact=lig->numfact
do while date=vdate
if tabul>tabmax
tabmax=tabul
if tabul<tabmin
tabmin=tabul
rec=recno()
if tabmax =12
replace code with vcode,date with vdate,type with vtype, caps with vcaps,groupe with " "
replace tabul with 26,daa with vdaa,numfact with vfact
ex=1
if tabmin =13
replace code with vcode,date with vdate,type with vtype,groupe with " ", caps with vcaps
replace tabul with 12,daa with vdaa,numfact with vfact
if ex=1
* 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
do wHIle .not. eof()
mois=cmonth(lig->date)
if mois=mois2 .and.lig->tabul> pg*13 .and. lig->tabul <=14+(pg*13)
vimp=1
vtitlig="       "
vcode=left(lig->code,7)
if vimp=1
*****************************titre****************
if prow()<2
? pol3+titre+" mois de "+mois+"  "+str(year(lig->date),4)+"  "+societe+" page "+str(pg+1,2,0)
?
? pol2 +"   jour   "
for c=(13*pg)+1 to 13+(13*pg)
??"  "+tab[c,4]+left(blanc,10-len(tab[c,4]))
****************************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"+" "
*********creation d'une ligne
do while left(lig->code,7) =vcode
vi=lig->tabul
if vi> pg*13 .and. vi <14+(pg*13)
vt=ltrim(str(tab[vi+(1*pg),1]-1))
??chr(27)+"&a"+vt+"C"+str(lig->total,10,2)
tab[vi,2]=tab[vi,2]+lig->total
vtotmois=vtotmois+lig->total
tab[28,2]=tab[28,2]+lig->total
*tab[vi,3]=tab[vi,3]+lig->total
tab[28,3]=tab[28,3]+lig->total
vcummois=vcummois+lig->total
vtotcum=vtotcum+lig->total
*********
for vtb=(14*pg)+1 to 14+(14*pg)
vt=ltrim(str(tab[vtb,1]-3))
?? chr(27)+"&a"+vt+"C│"
next vtb
vt=ltrim(str(tab[28,1]-1))
??chr(27)+"&a"+vt+"C"+str(tab[28,2],10,2)
?"--------------------------------------------------------------------------------------------------
tab[28,2]=0
if prow()>53
*impression des totaux colonne
tab[28,2]=vtotmois
?? "total page "
vt=ltrim(str(tab[c+(1*pg),1]-1))
??chr(27)+"&a"+vt+"C"+str(tab[c,2],10,2)
tab[c,2]=0
next C
for c=(14*pg)+2 to 14+(14*pg)
vt=ltrim(str(tab[c,1]-3))
? " "
? "cumulé"
for c=(13*pg)+1 to 13 +(13*pg)
??chr(27)+"&a"+vt+"C"+str(tab[c,3],10,2)
tab[27,3]=tab[27,3]+tab[c,3]
??chr(27)+"&a"+vt+"C"+str(tab[27,3],10,2)
? "général: ",vtotcum
?"                          ."
wait "attente impression"
mois1=mois
if .not.eof()
? "général: ",vtotcum,"soit ",vtotcum/.75,"bt"
pg=pg+1
ppg=ppg-1
*eject
do pol
retu