<?xml version="1.0" encoding="UTF-8"?>
<part class="form">
  <style>
    <property name="Geometry">{150,162,1028,650}</property>
    <property name="Name">[SF_NFE.scr]</property>
    <property name="Caption">[Relação de Notas Geradas]</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">[3 - Maximized]</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
// oDlg:Move( , , MAX(798,GetDesktopWidth()*0.95), MAX(570,GetDesktopHeight()*0.90), 1 )
oDlg:Center()

//skel VARIAVEL zBlVendedor = {|xVnd| sf_vend->(dbgoto(xVnd)), sf_vend->nome }
//skel VARIAVEL zbObra={||vb_pref->(DbGoTo(SF_FATNF->fObra),cr_fantasi)}
//skel VARIAVEL Zrecn := (DbGoBottom(),DbSkip(-10),Recno())
//skel VARIAVEL zBlkForn := {|nCli| sccpfor->(DbGoto(nCli)), sccpfor->cp_nome }
//skel VARIAVEL zBlkCli := {|nCli| If(fgdev$"DTE".and.!"918"$fCodOp, sccpfor->(DbGoto(nCli),cp_nome), sccrcli->(DbGoto(nCli),cr_nome) ) }
//skel VARIAVEL zBlkPrd := {|nPcod| se_prod->(dbseek(nPcod)), se_prod->pdesc }

//skel VARIAVEL zbOpenAll:=#TEXTO_FONTE
//skel    (DbCloseAll(), Abra("0NOIDX",r_siga,"sccpfor","sccpfor"), Abra("0NOIDX",r_siga,"sccrcli","sccrcli"), Abra("0NOIDX",r_siga,"se_prod","se_prod","seip_c","pcod"))
//skel    (Abra("0NOIDX",r_siga,Se_mov,"se_mov",Seim_p,"fnumped"), Abra("0NOIDX", r_siga, "SCCRDUP", "SCCRDUP", "SCRID_ND", "CR_NUM_PED"),Abra ("0NOIDX",r_siga, "sf_vend", "sf_vend"))
//skel    Abra ("0NOIDX",r_siga,"sf_fatnf","sf_fatnf", "sffatnf2","pfnum")
//skel    Abra ("0NOIDX","", "mem:_nfref", "_nfref")
//skel    DBGOTO(Zrecn)
//skel #FIM_TEXTO_FONTE

//skel VARIAVEL zNil = eval(zbOpenAll)

//skel zFiltEmit = "Val(nfe_nprot)>0"

//skel VARIAVEL zbPrtConferente := {|| zrecn:=recno(), Relat('lst_exec("CUPOM_NFE_SEPARACAO")',"nb",,"X"), eVal(zbOpenAll) }
//skel VARIAVEL zbPrtPedido:={||z_recno:=Recno(), Relat('lst_exec("CUPOM_NFS_PRT")',"nb",,"X"), eVal(zbOpenAll) }

//#define x_BLUE       16711680
//#define x_DARKBLUE   10027008
//#define x_WHITE      16777215
//#define x_CYAN       16776960
//#define x_BLACK             0
//#define x_RED             255
//#define x_GREEN         32768
//#define x_GRAY        8421504
//#define x_YELLOW        65535

//skel varIAVEL bCor = {|| if(se_prod->pdic6=0.or.se_prod->pcodclafis=0.or.left(se_prod->punidade,1)=" ", {16777215,255,16777215,10027008},{16711680,16777215,16776960,10027008}) }

oContextMenu:=Hwg_ContextMenu()
hwg_Btn(oToolbar,270,5,64,64)

hwg_TbMt(oToolbar,'13;SelPrdNFeReferenciada("MARCA_DESMARCA", d_ob);Enter-Marca_Desmarca ;Enter - Marca_Desmarca;;;;;')
hwg_TbMt(oToolbar,'32;SelPrdNFeReferenciada("MARCA_DESMARCA_TODAS", d_ob);Barra-Todas ;Barra-Todas;;;;;')

hwg_TbMt(oToolbar,'65;DoGet(d_ob);A-Edita ;A - Edita;;;')
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,'84;tb_locate(D_OB);T-Busca_Trecho ;T-Pesquisa Trecho na coluna do cursor;;;;')
hwg_TbMt(oToolbar,'70;tb_filter(d_ob);F-Filtra ;F-Filtra Cursor;;;;')

hwg_TbMt(oToolbar,'0;;;espaco;espaco;')
hwg_TbMt(oToolbar,"27;hwg_oDlgKey(oDlg,27,nBrwAtivo);Saida;Saida;xml\icon\saida.ico;;;;;")

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()

oBrwItens:Refresh()
oBrwDups:Refresh()]]>
  </method>
  <method name="onPaint">
    <![CDATA[Parameters oCtrl,hDC
oCtrl:bpaint:=NIL
D_oB:setFocus()]]>
  </method>
  <method name="onGetFocus">
    <![CDATA[DBCLOSEALL()
RETURN .t.]]>
  </method>
  <part class="status">
    <style>
      <property name="Geometry">{0,620,1028,30}</property>
      <property name="Name">[oDlgStatusBar]</property>
      <property name="aParts">{640,160,0}</property>
    </style>
  </part>
  <part class="browse">
    <style>
      <property name="Geometry">{3,74,1014,273}</property>
      <property name="Name">[D_oB]</property>
      <property name="Anchor">15</property>
      <property name="font">
        <font name="Arial" width="0" height="-13" weight="400"/>
      </property>
      <property name="Border">.F.</property>
      <property name="TabIndex">4</property>
    </style>
    <method name="onGetFocus">
      <![CDATA[nBrwAtivo:=1]]>
    </method>
    <method name="onPosChange">
      <![CDATA[oBrwItens:Refresh()
oBrwDups:Refresh()]]>
    </method>
    <method name="onInit">
      <![CDATA[DbSelectArea( '_nfref' )
D_oB:bColorSel:= RGB(3,23,133)
D_oB:tColorSel:= RGB(255,255,255)
D_oB:bKeyDown := {|self, wParam| (aBrowses[nBrwAtivo,2])->(hwg_oDlgKey(self, wparam,1)) , .T. }

hwg_TbFi(D_oB, '*;SelPrdNFeReferenciada("STATUS");C;@s1;1;N;')
hwg_TbFi(D_oB, 'Data;FDATAEMI;D;99.99;5;N;')

hwg_TbFi(D_oB, 'ValorLiq;if(Fval-FCredDevol>0,Fval-FCredDevol,0);P;@E 9,999.99; 8;N;')

hwg_TbFi(D_oB, '*;if(fnum>0,if(val(fModelo)=65,"NFC", if(val(fModelo)=55,"NFE","PND") ),"NFS");P;XXX;3;;')
hwg_TbFi(D_oB, 'NF;fnum;N;999999999;9;N;')
hwg_TbFi(D_oB, 'Mod;fModelo;C;XXX;3;;')
hwg_TbFi(D_oB, 'Controle;fnumped;N;999999999;9;N;')
hwg_TbFi(D_oB, 'Faturada?;sf_fatnf->( if(DbSeek(_nfref->fNum),"NF "+lTrim(Str(fNum,10)),"A_Faturar") );P;@S10;12;;')
IF sys_segmento='locacao'
   hwg_TbFi(D_oB, 'Val_Loca;fvalLoca;N;@E 999,999.99;10;;') 
ENDIF
hwg_TbFi(D_oB, 'Desconto;fDesconto;N;@E 9,999.99; 8;N;')
 
hwg_TbFi(D_oB, 'CodCli;fCli;N;999999;  6;;')
hwg_TbFi(D_oB, 'RazSoc;eVal(zBlkCli,fCli);C;@S22;22;;')
hwg_TbFi(D_oB, '*;fgdev;C;X;3;S;')
hwg_TbFi(D_oB, 'CFOP;fcodop;C;XXXXX;5;;')
hwg_TbFi(D_oB, 'cVd;FVENDEDOR;N;9999;4;S;')
hwg_TbFi(D_oB, 'Vendedor;eval(zBlVendedor,FVENDEDOR);C;@S15;15;N;')

hwg_TbFi(D_oB, 'V;FTIPOVEN;C;@s1;1;N;')
hwg_TbFi(D_oB, 'Usu.;USUARIO;C;@s8;8;N;')
hwg_TbFi(D_oB, 'CT;FCARTAO;N;999;3;S;')
hwg_TbFi(D_oB, 'Cx;SI_CAIXA;N;99;2;N;')
hwg_TbFi(D_oB, 'FechCx;SI_NumFech;N;999999;6;N;')
hwg_TbFi(D_oB, 'Cred.Dev;FCredDevol;N;@E 9,999.99; 8;N;')
hwg_TbFi(D_oB, 'Bco;Fbanco;N;999;3;S;')
hwg_TbFi(D_oB, 'CH;FCHEQUE;N;999999;6;S;')
hwg_TbFi(D_oB, 'BomPara;Fbompara;D;99.99.99;8;S;')
hwg_TbFi(D_oB, 'TV;FTV;C;@s1;2;N;')
hwg_TbFi(D_oB, 'Emissao;left(dtoc(fdataemi),5)+" "+left(fhora,5);C;@s11;11;N;')
hwg_TbFi(D_oB, 'I;FG_FAT;C;@s1;1;N;')
hwg_TbFi(D_oB, 'v;FG_LIB;C;@s1;1;N;')

D_oB:Alias := alias()
D_oB:bOther:={|o,m,wp,lp| MessagesBrowse(o,m,wp,lp)}
D_oB:cargo:={.T.,.T.,"_nfref",.F.,.T.,{||.T.} }
aAdd(aBrowses,{D_oB,D_oB:Alias,{||.f.},{|| .T.},})]]>
    </method>
    <method name="onPaint">
      <![CDATA[SetFocus(d_Ob)
if( select("SF_FATNF")=0, eval(zbOpenAll), DbSelectArea("SF_FATNF") ) ]]>
    </method>
  </part>
  <part class="browse">
    <style>
      <property name="Geometry">{3,348,812,238}</property>
      <property name="Name">[oBrwItens]</property>
      <property name="Anchor">14</property>
      <property name="font">
        <font name="Arial" width="0" height="-13" weight="400"/>
      </property>
      <property name="Border">.F.</property>
      <property name="TabIndex">6</property>
    </style>
    <method name="onInit">
      <![CDATA[oBrwItens:Alias := 'se_mov'
oBrwItens:bColorSel:= RGB(3,23,133)
oBrwItens:tColorSel:= RGB(255,255,255)
DbSelectArea( 'se_mov' )
//hwg_TbFi(@oBrwItens, 'Prod;Pcod;N;999999;6;;bCor;')
hwg_TbFi(@oBrwItens, 'Prod;Pcod;N;999999;6;;;')
hwg_TbFi(@oBrwItens, 'Descricao;eVal(zBlkPrd,pcod);C;@S50;50;;')
IF sys_segmento='locacao'
   hwg_TbFi(@oBrwItens, 'Quant;if(sf_fatnf->fgdev="E","",TRANSFORM(mQuant,"@e 9999999"));P;@S8;8;N;')
   hwg_TbFi(@oBrwItens, 'Devol;if(sf_fatnf->fgdev="E",mQuant,mQdevol) ;P;@e 9999999;8;N;')
   hwg_TbFi(@oBrwItens, 'Locadas;if(sf_fatnf->fgdev="E","",TRANSFORM(mQuant-mQdevol,"@e 9999999"));P;@S8;8;N;')
   hwg_TbFi(@oBrwItens, 'LocMensal;pValLoca;N;@E 9999.99;9;;')
ELSE
   hwg_TbFi(@oBrwItens, 'Quant;mQuant;N;999999.99;9;N;')
endif
hwg_TbFi(@oBrwItens, '*;mFgEs;C;!;1;;')

hwg_TbFi(@oBrwItens, 'Un;se_prod->pUNIDADE;C;XXX;3;;')
hwg_TbFi(@oBrwItens, 'Valor;mValor;N;999999.99;9;;')
hwg_TbFi(@oBrwItens, 'NCM;se_prod->pcodclafis;N;99999999;8;;')
hwg_TbFi(@oBrwItens, 'CFOP;pCfop;C;XXXXX;5;S;')
hwg_TbFi(@oBrwItens, 'ST;se_prod->pCATEGORIA;C;XXX;3;;')
hwg_TbFi(@oBrwItens, 'Barra;se_prod->pdic6;N;9999999999999;13;;')
IF sys_segmento='locacao'
   hwg_TbFi(@oBrwItens, 'Quant;mQuant;N;@e 9999.999;8;S;')
   hwg_TbFi(@oBrwItens, 'QtdJaDev;mQdevol;N;@e 9999.999;8;S;')
ENDIF
// alert('vai definir filtros oBrwItens:alias '+oBrwItens:alias+' Sf_FatNf->fnum '+str(Sf_FatNf->fnum,6)+ ' oBrwItens:nColumns '+str(oBrwItens:nColumns,4) )
oBrwItens:lFilter := .T.
oBrwItens:bFor := {|| mfges$"SMA" } 
oBrwItens:bFirst := {|| se_mov->( DBSEEK( _nfref->fnumped, .F. ) ) } 
oBrwItens:bLast  := {|| se_mov->( DBSEEK( _nfref->fnumped, .F., .T. ) ) }
oBrwItens:bWhile := {|| se_mov->fnumped = _nfref->fnumped}
oBrwItens:Refresh()
DbSelectArea( '_nfref' )
// alert('definiu oBrwItens:alias '+oBrwItens:alias+' Sf_FatNf->fnum '+str(Sf_FatNf->fnum,6)+ ' oBrwItens:nColumns '+str(oBrwItens:nColumns,4) )


]]>
    </method>
  </part>
  <part class="browse">
    <style>
      <property name="Geometry">{820,348,196,118}</property>
      <property name="Name">[oBrwDups]</property>
      <property name="Anchor">12</property>
      <property name="font">
        <font name="Arial" width="0" height="-13" weight="400"/>
      </property>
      <property name="TabIndex">7</property>
    </style>
    <method name="onInit">
      <![CDATA[oBrwDups:Alias := 'sccrdup'
oBrwDups:bColorSel:= RGB(3,23,133)
oBrwDups:tColorSel:= RGB(255,255,255)
DbSelectArea( 'sccrdup' )
hwg_TbFi(@oBrwDups, 'Td;cr_tip_dup;C;XXX;3;;')
hwg_TbFi(@oBrwDups, 'Valor;cr_valor;N;999999.99;9;;')
hwg_TbFi(@oBrwDups, 'BomPara;CR_DT_VENC;P;99.99.9999;10;;')
oBrwDups:lFilter := .T.
oBrwDups:bFirst := {|| sccrdup->( DBSEEK( StrZero(_nfref->fNumPed,6), .F. ) ) } 
oBrwDups:bLast  := {|| sccrdup->( DBSEEK( StrZero(_nfref->fNumPed,6), .F., .T. ) ) }
oBrwDups:bWhile := {|| sccrdup->fNumPed = _nfref->fNumPed }
oBrwDups:Refresh()
DbSelectArea( '_nfref' )
]]>
    </method>
  </part>
  <part class="label">
    <style>
      <property name="Geometry">{5,2,259,67}</property>
      <property name="Name">[oLabel4]</property>
      <property name="Caption">[Tecle ENTER para Selecionar Pedido]</property>
      <property name="TextColor">16711680</property>
      <property name="font">
        <font name="Arial" width="0" height="-29" weight="700"/>
      </property>
      <property name="Transparent">.T.</property>
      <property name="TabIndex">9</property>
    </style>
  </part>
  <part class="editbox">
    <style>
      <property name="Geometry">{854,491,162,36}</property>
      <property name="Name">[owPrincipal]</property>
      <property name="varName">[wPrincipal]</property>
      <property name="Anchor">12</property>
      <property name="Transparent">.T.</property>
      <property name="font">
        <font name="Verdana" width="0" height="-24" weight="700"/>
      </property>
      <property name="cPicture">[@e 999,999.99]</property>
      <property name="Border">.F.</property>
      <property name="TabIndex">10</property>
    </style>
  </part>
  <part class="editbox">
    <style>
      <property name="Geometry">{856,551,160,36}</property>
      <property name="Name">[owQtdAbertas]</property>
      <property name="varName">[wQtdAbertas]</property>
      <property name="Anchor">12</property>
      <property name="Transparent">.T.</property>
      <property name="font">
        <font name="Verdana" width="0" height="-24" weight="700"/>
      </property>
      <property name="cPicture">[@E 999,999]</property>
      <property name="Border">.F.</property>
      <property name="TabIndex">10</property>
    </style>
  </part>
  <part class="label">
    <style>
      <property name="Geometry">{868,474,148,17}</property>
      <property name="Name">[oLabel1]</property>
      <property name="Caption">[Valor Selecionado]</property>
      <property name="Justify">[Right]</property>
      <property name="Anchor">12</property>
      <property name="font">
        <font name="Verdana" width="0" height="-13" weight="400"/>
      </property>
      <property name="Transparent">.T.</property>
      <property name="TabIndex">11</property>
    </style>
  </part>
  <part class="label">
    <style>
      <property name="Geometry">{867,533,149,19}</property>
      <property name="Name">[oLabel2]</property>
      <property name="Caption">[Cupons Selecionadas]</property>
      <property name="Justify">[Right]</property>
      <property name="Anchor">12</property>
      <property name="font">
        <font name="Verdana" width="0" height="-13" weight="400"/>
      </property>
      <property name="Transparent">.T.</property>
      <property name="TabIndex">11</property>
    </style>
  </part>
  <part class="label">
    <style>
      <property name="Geometry">{882,7,24,21}</property>
      <property name="Name">[oLabel3]</property>
      <property name="Caption">[De:]</property>
      <property name="Justify">[Right]</property>
      <property name="font">
        <font name="Arial" width="0" height="-13" weight="400"/>
      </property>
      <property name="Transparent">.T.</property>
      <property name="TabIndex">11</property>
    </style>
  </part>
  <part class="label">
    <style>
      <property name="Geometry">{881,25,25,21}</property>
      <property name="Name">[oLabel5]</property>
      <property name="Caption">[Ate:]</property>
      <property name="Justify">[Right]</property>
      <property name="font">
        <font name="Arial" width="0" height="-13" weight="400"/>
      </property>
      <property name="Transparent">.T.</property>
      <property name="TabIndex">11</property>
    </style>
  </part>
  <part class="editbox">
    <style>
      <property name="Geometry">{907,4,110,22}</property>
      <property name="Name">[od_de]</property>
      <property name="varName">[d_de]</property>
      <property name="font">
        <font name="Verdana" width="0" height="-16" weight="700"/>
      </property>
      <property name="TabIndex">12</property>
    </style>
  </part>
  <part class="editbox">
    <style>
      <property name="Geometry">{907,29,110,22}</property>
      <property name="Name">[od_ate]</property>
      <property name="varName">[d_ate]</property>
      <property name="font">
        <font name="Verdana" width="0" height="-16" weight="700"/>
      </property>
      <property name="TabIndex">12</property>
    </style>
  </part>
</part>
