<?xml version="1.0" encoding="UTF-8"?>
<part class="form">
  <style>
    <property name="Geometry">{442,51,1022,598}</property>
    <property name="Name">[sccrdup_cli1.scr]</property>
    <property name="Caption">[Compras do Cliente]</property>
    <property name="AlwaysOnTop">.F.</property>
    <property name="AutoCenter">.T.</property>
    <property name="Font">
      <font name="Verdana" width="0" height="-13" weight="400"/>
    </property>
    <property name="FormType">[dlgModal]</property>
    <property name="Modal">.F.</property>
    <property name="ScopeVarObj">[Private]</property>
    <property name="lClipper">.T.</property>
    <property name="lExitOnEnter">.F.</property>
    <property name="lExitOnESC">.T.</property>
    <property name="FromStyle">[Center]</property>
    <property name="Clipsiblings">.F.</property>
    <property name="Clipchildren">.F.</property>
    <property name="TitleBar">.T.</property>
    <property name="StyleBorder">[3 - Sizable (Default)]</property>
    <property name="nBackColor">14215660</property>
    <property name="Icon">[]</property>
    <property name="Bitmap">[icon\tela.jpg]</property>
    <property name="NoIcon">.F.</property>
    <property name="SystemMenu">.T.</property>
    <property name="Minimizebox">.F.</property>
    <property name="Maximizebox">.T.</property>
    <property name="AbsAlignment">.T.</property>
    <property name="WindowState">[1 - Normal (Default)]</property>
    <property name="minHeight">-1</property>
    <property name="maxHeight">-1</property>
    <property name="minWidth">-1</property>
    <property name="maxWidth">-1</property>
    <property name="ScrollBars">[0 - None (Default)]</property>
    <property name="DSControl">.F.</property>
  </style>
  <method name="onDlgInit">
    <![CDATA[parameters oDlg
//skel VARIAVEL znil := __SetCentury("on")
//skel VARIAVEL zbCor := {||IF(cr_dt_venc<s_datual,zCorVc, if(cr_dt_venc>s_datual,zCorAv,{d_ob:tcolor,d_ob:bcolor,D_oB:tColorSel,D_oB:bColorSel}) )}
//skel VARIAVEL zbSoAbertas := {|| m_fcli=cr_cod_cli.and.!left(Cr_num_ped,2)$"/CX/CZ/".and.DAY(CR_DT_LQD)=0 }
//skel VARIAVEL zbTodas := {|| m_fcli=cr_cod_cli.and.!left(Cr_num_ped,2)$"/CX/CZ/"}
//skel VARIAVEL zbFiltraAbertas := {|| DbSetFilter(zbSoAbertas, "m_fcli=cr_cod_cli"), if(sGuiMode, d_ob:Top(), D_oB:goTop())}
//skel VARIAVEL zbFiltraTodas := {|| DbSetFilter(zbTodas, "m_fcli=cr_cod_cli"), if(sGuiMode, d_ob:top(), D_oB:goTop()) }

//skel variavel znCodCli := sccrcli->(Recno())
//skel VARIAVEL zbCli={|nCodCli|sccrcli->(DbGoto(nCodCli),cr_nome)}
//skel VARIAVEL zFgCliClosed := (Select("SCCRCLI")=0)
//skel VARIAVEL zFgProdClosed := (Select("SE_PROD")=0)
//skel VARIAVEL zFgMovClosed := (Select("SE_MOVNF")=0)
//skel VARIAVEL znAzul0:=16711680
//skel VARIAVEL znAzul1:=10027008
//skel VARIAVEL zAzul2:=16776960
//skel VARIAVEL zW:=16777215
//skel VARIAVEL zBlack:=0
//skel VARIAVEL zRed:=255
//skel VARIAVEL zGreen:=32768
//skel VARIAVEL znCinza:=8421504
//skel VARIAVEL zYellow:=65535
//skel VARIAVEL zRecno := Recno()
//skel VARIAVEL zFgUsaCores:=(xGetEnv("USA_CORES_NO_BROWSE")<>"N")

//skel VARIAVEL zBlkPrd := {|nPcod| se_prod->(dbseek(nPcod)), se_prod->pdesc }
//skel VARIAVEL zBfVencidas:={||DbSetFilter({||day(cr_dt_lqd)=0.and.cr_dt_venc<s_datual},"day(cr_dt_lqd)=0.and.cr_dt_venc<s_datual"),DbGoTop(),d_ob:Refresh(),d_ob:SetFocus()}
//skel VARIAVEL zBfHoje:={||DbSetFilter({||day(cr_dt_lqd)=0.and.cr_dt_venc=s_datual},"day(cr_dt_lqd)=0.and.cr_dt_venc=s_datual"),DbGoTop(),d_ob:Refresh(),d_ob:SetFocus()}
//skel VARIAVEL zBfLocacao:={||DbSetFilter({||'RR NFS'$cr_obs},"'RR NFS'$cr_obs"),DbGoTop(),d_ob:Refresh(),d_ob:SetFocus()}
//skel VARIAVEL zBfTodas:={||DbClearFilter(),DbGoTop(),d_ob:Refresh(),d_ob:SetFocus()}
//skel VARIAVEL zbObra={||vb_pref->(DbGoTo(_DUPLCLI->fObra),cr_fantasi)}
//skel variavel z1BOpenAll:=#TEXTO_FONTE
//skel    se sys_segmento='locacao'.and.select('vb_pref')=0 entao Abra ('0NOIDX',r_siga, 'vb_pref','vb_pref')
//skel    se select('se_prod')=0 entao Abra ("0NOIDX",r_siga, "se_prod", "se_prod", "seip_c", "pcod")
//skel    se select('sccrcli')=0 entao Abra ("0NOIDX",r_siga, "sccrcli","sccrcli")
//skel    if _duplcli->(FieldPos('fnum')>0)
//skel       se select('se_movnf')=0 entao Abra ('0NOIDX', r_siga, SE_MOV, 'SE_MOVNF', Seim_f, 'mfnum') 
//skel    else
//skel       se select('se_movnf')=0 entao Abra ('0NOIDX', r_siga, SE_MOV, 'SE_MOVNF', Seim_p, 'FNUMPED') 
//skel    endif
//skel    DbSelectArea("_duplcli")
//skel    DbGoTo( zRecno )
//skel #FIM_TEXTO_FONTE

//skel variavel znil = eVal( z1BOpenAll )

//skel variavel zbMarcaDups:=#TEXTO_FONTE
//skel    Private xDbStruct := _duplcli->(DbStruct()), zrecno
//skel    aAdd( xDbStruct, {"RecnoDupl","N",8,0} )
//skel    aAdd( xDbStruct, {"CR_AREC",  "N",11,2} )
//skel    aAdd( xDbStruct, {"fg_fat",   "C",1,0} ) 
//skel    aAdd( xDbStruct, {"mvalordia","N",10,2} ) 
//skel    aAdd( xDbStruct, {"fval",     "N",10,2} ) 
//skel    aAdd( xDbStruct, {"Correcao", "N",10,2} ) 
//skel    aAdd( xDbStruct, {"AssNome",  "C",25,0} )
//skel    DbCreate( 'mem:_dups', xDbStruct )
//skel    use ( 'mem:_dups' ) new exclusive
//skel    _duplcli->( DbGoTop(), DbEval( {|| _dupls->( AppendBlank(), Gather( _duplcli->(Scatter())) ) } ) )
//skel    _duplcli->( DbCloseArea() )
//skel    copy to ( 'mem:_duplcli' ) 
//skel    DbCloseArea()
//skel    DbDrop( 'mem:_dups' )
//skel    DbCloseAll()
//skel    Use ('mem:_duplcli') Alias _DuplCli New Exclusive         
//skel    _DuplCli->( DBGOTOP(), Brow_Db("SCCRDUP_CLI1_COB_SEMPRODUTOS") )
//skel    Abra_Arq ("SCCRCLI")
//skel    DbGoTo(znCodCli)
//skel    eVal(zbOpenAll)
//skel #FIM_TEXTO_FONTE

//skel comando saida #TEXTO_FONTE
//skel     se select('vb_pref')>0 entao vb_pref->(DbCloseArea())
//skel     se zFgCliClosed entao sccrcli->(DbCloseArea())
//skel     se zFgProdClosed entao se_prod->(DbCloseArea())
//skel     se zFgMovClosed entao se_movnf->(DbCloseArea())
//skel #FIM_TEXTO_FONTE

//skel VARIAVEL zbPrtPedido:= {||zrecno:=Recno(), Relat('lst_exec("BORDCOB00")',"nb",,"X"), eVal(z1BOpenAll) }

d_ob:lEditable = .t.

oContextMenu:=Hwg_ContextMenu()
hwg_Btn(oToolbar,5,5,64,64)
hwg_TbMt(oToolbar,'  7;tb_del(D_ob);DEL-DELeta ;DEL-Deleta;deletar.ico;;;;;Deleta;;;')
hwg_TbMt(oToolbar,' 80;tb_pesq(d_ob);P-Pesquisa ;P-Pesquisa na coluna do cursor;pesquisa.ico;;;;;&P-Pesquisa;;;')
hwg_TbMt(oToolbar,' 79;tb_index(D_OB);O-Ordena ;O-Ordena a coluna do cursor;ordenar.ico;;;;;&O-Ordena;;;')
hwg_TbMt(oToolbar,' 73;eVal(zbPrtPedido);1-Imprime;I-Imprime Extrato ;impressora.ico;;;;;&1-Imprime;;;')
hwg_TbMt(oToolbar,' 73;eVal(zbMarcaDups);1-Impr_Sel;I-Imprime Extrato Apos Selecionar Titulos a Listar;impressora.ico;;;;;&2-MarcaImprime;;;')

hwg_Btn(oToolbar,10,544,70,24)
hwg_TbMt(oToolbar,' 32;DoGet(D_oB);Barra-Edita ;Barra - Edita;sembitmap;;;Lucida Bright;-11;Edita;;6;')
hwg_TbMt(oToolbar,' 61;doget(D_ob,,.t.);=-Repete_Edicao ;= - Repete_Edicao;sembitmap;;;Lucida Bright;-11;&=-Repete_Edicao;;6;')
hwg_TbMt(oToolbar,' 84;tb_locate(D_oB);T-Trecho ;T-Pesquisa Trecho na coluna do cursor;sembitmap;;;Lucida Bright;-11;&T-Trecho;;6;')
hwg_TbMt(oToolbar,' 67;tb_locate(D_oB);C-Repete_Busca ;C-Repete Busca na coluna do cursor;sembitmap;;;Lucida Bright;-11;&C-Continua;;6;')
hwg_TbMt(oToolbar,' 70;tb_filter(d_ob);F-Filtra ;F-Filtra Cursor;sembitmap;;;Lucida Bright;-11;&F-Filtra;;6;')
hwg_TbMt(oToolbar,' 92;PrtBordero("RTF", , , "carne.rtf");\-Carnes_rtf ;\ - Carnes_rtf;sembitmap;;;Lucida Bright;-11;&\-Carnes_rtf;;6;')
hwg_TbMt(oToolbar,' 65;eVal(zbFiltraAbertas);A-Abertas ;A - Abertas;sembitmap;;;Lucida Bright;-11;&A-Abertas;;6;')
hwg_TbMt(oToolbar,' 74;PrtBordero("PDF", , , "duplicata.pdf");J-BOLETOS_pdf ;J - BOLETOS_pdf;sembitmap;;;Lucida Bright;-11;&J-BOLETOS_pdf;;6;')
hwg_TbMt(oToolbar,' 47;eVal(zbFiltraTodas);/-Todas ;/ - Todas;sembitmap;;;Lucida Bright;-11;&/-Todas;;6;')
hwg_TbMt(oToolbar,' 72;PrtBordero("HTM", , , "duplicata.htm");H-BOLETOS_Html ;H - BOLETOS_Html;sembitmap;;;Lucida Bright;-11;&H-BOLETOS_Html ;6;6;')
hwg_TbMt(oToolbar,' 47;PrtBordero("RTF", , , "duplicata.rtf" );/-Duplicatas_rtf ;/ - Duplicatas_rtf;sembitmap;;;Lucida Bright;-11;&/-Duplicatas_rtf;;6;')

SetDlgKey(oDlg,8,26,{|| (aBrowses[nBrwAtivo,2])->(moveRec(aBrowses[nBrwAtivo,1],"UP"))})
SetDlgKey(oDlg,8,28,{|| (aBrowses[nBrwAtivo,2])->(moveRec(aBrowses[nBrwAtivo,1],"DOWN"))})
Hwg_EndMenu()

oDlgStatusBar:Anchor:=14
oBrwIt:Refresh()
oDlg:MAXIMIZE()]]>
  </method>
  <method name="onPaint">
    <![CDATA[Parameters oCtrl,hDC
oCtrl:bpaint:=NIL
D_oB:setFocus()]]>
  </method>
  <part class="status">
    <style>
      <property name="Geometry">{0,568,1022,30}</property>
      <property name="Name">[oDlgStatusBar]</property>
      <property name="aParts">{608,152,0}</property>
    </style>
  </part>
  <part class="browse">
    <style>
      <property name="Geometry">{11,77,1000,255}</property>
      <property name="Name">[d_ob]</property>
      <property name="Anchor">15</property>
      <property name="font">
        <font name="Lucida Sans Unicode" width="0" height="-16" weight="400"/>
      </property>
      <property name="GridLinesSepColor">0</property>
      <property name="TabIndex">4</property>
    </style>
    <method name="onGetFocus">
      <![CDATA[nBrwAtivo:=1]]>
    </method>
    <method name="onPosChange">
      <![CDATA[oBrwIt:Refresh()]]>
    </method>
    <method name="onInit">
      <![CDATA[   hwg_TbFi(D_oB, 'Cupom;cr_num_ped;C;999999xx;  8;N;')
   hwg_TbFi(D_oB, 'TipoDoc;SxNomeFormaPag(CR_TIP_DUP);C;@S8;8;N;')
   hwg_TbFi(D_oB, 'Emissao;cr_dt_emis;D;; 10;N;')
   IF zFgUsaCores
      hwg_TbFi(D_oB, 'Valor;cr_Valor;N;@E 999,999.99; 10;N;zbCor;')
      hwg_TbFi(D_oB, 'Vencto;cr_dt_venc;D;; 10;N;zbCor;')
   ELSE
      hwg_TbFi(D_oB, 'Valor;cr_Valor;N;@E 999,999.99; 10;N;')
      hwg_TbFi(D_oB, 'Vencto;cr_dt_venc;D;; 10;N;')
   ENDIF
   IF sys_segmento='locacao'
      hwg_TbFi(D_oB, 'NFs;fnum;N;999999;6;N;')
      hwg_TbFi(D_oB, 'Frete NF;fValFrete;N;9999999.99; 10;N;')
      hwg_TbFi(D_oB, 'Obra;fObra;N;999999;6;S;')
      hwg_TbFi(D_oB, 'iObra;fObraNoCli;N;999;7;S;')
      hwg_TbFi(D_oB, 'NomeObra;eVal(zbObra);P;@S25;25;S;')
      hwg_TbFi(D_oB, 'CFOP;cr_cfop+"-"+if(left(cr_cfop,1)$"12","DEVOL",if(left(cr_cfop,3)="5.9","LOCACAO","VENDA"));P;@s13;13;N;')
      hwg_TbFi(D_oB, 'Controle;fNumPed;N;999999999;9;N;')
   else
      hwg_TbFi(D_oB, 'CFOP;CR_CFOP;C;XXXXX;5;N;')
   endif
   hwg_TbFi(D_oB, 'Cli;CR_COD_CLI;N;999999;6;N;')
   hwg_TbFi(D_oB, 'Vd;cr_zona;C;99;  2;N;')
   hwg_TbFi(D_oB, 'Val Lqd/Ad;cr_Val_lqd;N;@E 999,999.99; 10;S;')
   hwg_TbFi(D_oB, 'Dt Lqd;cr_dt_lqd;D;; 10;S;')
   hwg_TbFi(D_oB, 'Hora;cr_hora;C;99:99;5;N;')
   hwg_TbFi(D_oB, 'Obs;cr_obs;C;@s25;25;S;')

   se FIELDPOS('cr_cfop')>0 entao hwg_TbFi(D_oB, 'CFOP;CR_CFOP;C;XXXXX;5;N;')

   hwg_TbFi(D_oB, 'DtAlter;cr_data;D;;10;N;')
   hwg_TbFi(D_oB, 'HrAlter;cr_hora;C;xxxxx;5;N;')
   hwg_TbFi(D_oB, 'Usuario;cr_usuario;C;@s8;8;N;')

   hwg_TbFi(D_oB, 'Td;CR_TIP_DUP;C;!!;  2;N;')
   hwg_TbFi(D_oB, 'Cxa;Si_Caixa;N;999;3;N;')
   hwg_TbFi(D_oB, 'Dt Chq;CR_DT_DOC;D;99/99/9999; 10;S;')
   hwg_TbFi(D_oB, 'ChqCrt;CR_NUM_DOC;N;999999;  6;S;')
   hwg_TbFi(D_oB, 'CtoBco;banco;N;999999;  6;S;')
   hwg_TbFi(D_oB, 'L;CR_TIP_LQD;C;x;  1;N;')
   hwg_TbFi(D_oB, 'J;CR_HA_JURO;C;x;  1;N;')
   hwg_TbFi(D_oB, 'Descont;CR_DESCONT;N;9999999.99; 10;N;')
   hwg_TbFi(D_oB, 'Vd;CR_ZONA;C;xx;  2;N;')
   hwg_TbFi(D_oB, 'S;CR_SITUAC;C;x;  1;N;')
   hwg_TbFi(D_oB, 'Pr;CR_LOCAL;C;xx;  2;N;')
   hwg_TbFi(D_oB, 'Dt Ger;CR_DATA;D;;  8;N;')
   hwg_TbFi(D_oB, 'Hora Ger;CR_HORA;C;@S8;  8;N;')
   hwg_TbFi(D_oB, 'Us;CR_USUARIO;N;9;  1;N;')
   hwg_TbFi(D_oB, 'NumFec;Si_NumFech;N;999999;6;N;')
   hwg_TbFi(D_oB, 'Cxa;Si_Caixa;N;999;3;N;')

D_oB:bColorSel:= RGB(3,23,233)
D_oB:tColorSel:= RGB(255,255,255)
D_oB:Alias := alias()
D_oB:lDisableVScrollPos := .t.
D_oB:bKeyDown := {|self, wParam| (aBrowses[nBrwAtivo,2])->(hwg_oDlgKey(self, wparam,1)) , .T. }
D_oB:bOther:={|o,m,wp,lp| MessagesBrowse(o,m,wp,lp)}
D_oB:cargo:={.T.,.T.,"_DUPLCLI",.F.,.T.,{||.T.} }
AADD(aBrowses,{D_oB,D_oB:Alias,{||.f.},{|| .T.},})
]]>
    </method>
  </part>
  <part class="label">
    <style>
      <property name="Geometry">{410,0,483,47}</property>
      <property name="Name">[oLabel1]</property>
      <property name="Caption">[Duplicatas do Cliente]</property>
      <property name="Justify">[Right]</property>
      <property name="font">
        <font name="Arial" width="0" height="-37" weight="700"/>
      </property>
      <property name="Transparent">.T.</property>
      <property name="TabIndex">5</property>
    </style>
  </part>
  <part class="browse">
    <style>
      <property name="Geometry">{10,339,1003,193}</property>
      <property name="Name">[oBrwIt]</property>
      <property name="Anchor">14</property>
      <property name="font">
        <font name="Arial" width="0" height="-13" weight="400"/>
      </property>
      <property name="TabIndex">6</property>
    </style>
    <method name="onInit">
      <![CDATA[DbSelectArea( 'se_movnf' )
oBrwIt:Alias := 'se_movnf'
oBrwIt:bColorSel:= RGB(3,23,133)
oBrwIt:tColorSel:= RGB(255,255,255)
hwg_TbFi(@oBrwIt, 'Prod;pCod;N;999999;6;;')
hwg_TbFi(@oBrwIt, 'Descricao;eVal(zBlkPrd,pCod);C;@S35;35;;')

IF sys_segmento='locacao' 
   hwg_TbFi(@oBrwIt, '*;if(mfges="S","Locacao",if(mfges="M","Relocacao",if(mfges="E","Devolucao",mfges)));P;@S15;15;;')
   hwg_TbFi(@oBrwIt, 'Quant;mQuant+if(mfges="S",0,mqDevol);P;999999;6;;')
ELSE
   hwg_TbFi(@oBrwIt, '*;if(mfges="S","Saida",if(mfges="D","Devolucao",if(mfges="E","Entrada",if(mfges="C","Cancelamento",mfges))));P;@S15;15;;')
   hwg_TbFi(@oBrwIt, 'Quant;mQuant;N;999999.99;9;;')
ENDIF

IF sys_segmento='locacao' 
   hwg_TbFi(@oBrwIt, 'Devolvida;mqDevol;N;999999;9;S;')
   hwg_TbFi(@oBrwIt, 'Aditivo;mfnum;N;9999999999;10;N;')
   hwg_TbFi(@oBrwIt, 'PrUnLocMes;pValLoca;N;999999.99;11;;')
   hwg_TbFi(@oBrwIt, 'VlTotMes;mQuant*pValLoca;P;999999999.99;12;;')

   hwg_TbFi(@oBrwIt, 'VlUnitIndnz;mValor/mQuant;P;999999999.99;12;;')
   hwg_TbFi(@oBrwIt, 'VlTotIdnz;mValor;N;999999999.99;12;;')
   hwg_TbFi(@oBrwIt, 'Dias1aLoca;pDiasLoca;N;999;13;;')
ELSE
   hwg_TbFi(@oBrwIt, 'NF;mfnum;N;9999999999;10;N;')
   hwg_TbFi(@oBrwIt, 'PrUn;if(mQuant>0,mValor/mQuant,0);P;999999.99;11;;')
   hwg_TbFi(@oBrwIt, 'VlTotal;mValor;N;999999999.99;12;;')
ENDIF

hwg_TbFi(@oBrwIt, 'Cli;mCodForc;N;999999;6;;')
hwg_TbFi(@oBrwIt, '*;mFgEs;C;!;1;;')

oBrwIt:lFilter := .T.

IF _duplcli->(FIELDPOS('fnum')>0)
   oBrwIt:bFirst := {|| se_movnf->( DBSEEK( _DUPLCLI->fNum, .F. ) ) } 
   oBrwIt:bLast  := {|| se_movnf->( DBSEEK( _DUPLCLI->fNum, .F., .T. ) ) }
   oBrwIt:bFor   := {|| se_movnf->mfNum<>0 .AND. se_movnf->mfNum = _DUPLCLI->fNum .AND. se_movnf->mCodForc = _duplcli->cr_cod_cli }
   oBrwIt:bWhile := {|| se_movnf->mfNum = _DUPLCLI->fNum}
else
   oBrwIt:bFirst := {|| se_movnf->( DBSEEK( _DUPLCLI->fNumPed, .F. ) ) } 
   oBrwIt:bLast  := {|| se_movnf->( DBSEEK( _DUPLCLI->fNumPed, .F., .T. ) ) }
   oBrwIt:bFor   := {|| se_movnf->fNumPed<>0 .AND. se_movnf->fNumPed = _DUPLCLI->fNumPed .AND. se_movnf->mCodForc = _duplcli->cr_cod_cli }
   oBrwIt:bWhile := {|| se_movnf->fNumPed = _DUPLCLI->fNumPed}
endif

DBSELECTAREA( '_DuplCli' )]]>
    </method>
  </part>
</part>
