*pr‚paration REGLEMENT DES REPResentants
pol1=CHR(27)+"&l0O"+chr(27)+"(s12U"+chr(27)+"(s0P"+chr(27)+"(s12H"+chr(27)+"(s12V"+chr(27)+"(s0S"+chr(27)+"(s0B"+chr(27)+"(s3T"
pol2=CHR(27)+"&l0O"+chr(27)+"(s12U"+chr(27)+"(s0P"+chr(27)+"(s16H"+chr(27)+"(s12V"+chr(27)+"(s0S"+chr(27)+"(s0B"+chr(27)+"(s3T"
pol3=CHR(27)+"&l0O"+chr(27)+"(s12U"+chr(27)+"(s1P"+chr(27)+"(s5H"+chr(27)+"(s24V"+chr(27)+"(s0S"+chr(27)+"(s0B"+chr(27)+"(s6T"
set escape on
sele 1
use &repdb index &repndx2,&repndx1 alias rep
SELE 3
USE SDFACTUR INDEX FACTURN ALIAS FC
SET FILTER TO codebq="ATT"
GO TOP
*BROWSE FIELDS NUMERO,IMPRESSION,VALIDATION,REGLEMENT,TTC,codebq freez codebq NOAPPEND
SELE 2
USE REPRGT INDEX REPRGTN ALIAS RGT
sele 4
use sdlignes index sdlignes alias lg
index on cdrep to sdlirep   
set index to sdlirep
set filter to datecomm=ctod("  /  /    ")
sele 5
use sdarti index sdarti alias art
SELE 1
go top
TITRE = "COMMISSIONS REPRESENTANTS"
DO TITRE
@10,0 clear
VNUM=0
Do while .not. eof()  
vrech= rep->cdrep
@10,5 say "repr‚sentant"
? vrech
sele lg
set relation to codearti into art
seek vrech 
IF .not. found()
sele 1
skip +1
loop
ENDI
*on trouve le representant dans les lignes
*d‚but de l'mpression
stotfac =0
totaldu=0.0
set print on
do while lg->cdrep =vrech
if prow() <2
? "Commissions dues … "+trim(rep->nomrep)+" "+rep->prenrep +" code : "+str(rep->cdrep)
?
? "en date du "+dtoc(date())
?
?
? "numfact date                       nature     quant   col      montant     commission"
?? pol2
endi
if prow() >60
eject
loop
endi
numlg=lg->numfact
if totcommlg>0
?ltrim(str(lg->numfact))+" "+dtoc(lg->date)+" "+nature+" "
? "                "+art->designart+" "+str(lg->quantite)+"        "+str(colisage,3,2)+"      "+str(prixlght,10,2)+"     "+str(totcommlg,10,2)
stotfac=stotfac+totcommlg
totaldu=totaldu+totcommlg
replace lg->datecomm with date()
endi
skip+1
if (numlg<> lg->numfact).or.( eof())
if stotfac>0
?"                                                total factur Nø "+str(numlg,10,0)+" "+str(stotfac,10,2)+" Euros"
stotfact=0
endi
endi
loop
enddo
?pol1
? "total du pour ces factures                            "+str(totaldu)+" "+"Euros"
eject
set print off
sele 1
skip +1
loop
enddo
do titre
@ 6,0 clear
@ 10,2 say "tout est il correct"
do OUI_NON
DO UNCAR
IF CAR=110.OR.CAR=78
sele lg
set filter to datecomm =date()
replace all datecomm with ctod("  /  /    ")
endi
close data
retu
 






