<?xml version="1.0" encoding="UTF-8"?>
<part class="form">
  <style>
    <property name="Geometry">{166,85,1022,598}</property>
    <property name="Name">[sf_pn.scr]</property>
    <property name="Caption">[Prenotas Disponiveis]</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="Variables">{aComboOpcoes}</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 zbObra={||vb_pref->(DbGoTo(SF_FATP->fObra),cr_fantasi)}
//skel VARIAVEL zBlVendedor = {|xVnd| sf_vend->(dbgoto(xVnd)), sf_vend->nome }
//skel VARIAVEL zBlkCli={|nCli| If(left(fCodop,1)$"123" .or. fgdev$"DTE", if(fCodop="1.201","*ORDEM PRODUCAO*",sccpfor->(DbGoto(nCli),cp_nome)), sccrcli->(DbGoto(nCli),cr_nome) ) }
//skel VARIAVEL zBlkPrd={|nPcod| se_prod->(dbseek(nPcod)), se_prod->pdesc }

//skel VARIAVEL zBlDespacho:=#TEXTO_FONTE
//skel    if .not. fg_fat$"FS"
//skel       (RegLock(),_FIELD->FG_FAT:="D",DBCOMMIT(),DBUNLOCK(),ALERT("O PEDIDO FOI ENVIADO PARA A AREA DE DESPACHO"),DobRefresh())
//skel    else
//skel       ALERT("Esse Pedido ja gerou NFE/NFS e por isso nao pode ser enviado para o DESPACHO") 
//skel    ENDIF
//skel #FIM_TEXTO_FONTE

//skel variavel zbAction:={|bFunction| z_recno:=Recno(), eVal(bFunction), eVal(zbOpenAll), DbGoTo(z_recno), DobRefresh()}

//skel VARIAVEL zBlEnter={||if(fg_fat<>"S",vb_venda(fTipoDig,,.t.,,,"/ALTERARPN/"),Alert("Esse pedido ja foi faturado!"))}
//skel VARIAVEL zBlC={||if(fg_fat="S".and.!empty(fChaveNfe),Nfe_ImprimirDanfe(fNum,fNum),Alert("Esse pedido ainda nao Gerou NFE"))}

//skel VARIAVEL wOpcao := 'a4'
//skel VARIAVEL zbPrtConferente:={||if(fgdev="E".and.fg_fat$'S6',StartLocacao("Prt_Itens_A_Ser_Devolvidos",fNumPed),if(fg_fat$"1P",Relat('lst_exec("CUPOM_PN_PRODUCAO")',"nb",,"X"),Relat('lst_exec("CUPOM_PN_SEPARACAO")',"nb",,"X"))) }
//skel VARIAVEL zbPrtPedido:= {||Relat('lst_exec("CUPOM_PN_PRT")',"nb",,"X") }
//skel VARIAVEL zbPrtPedidoFr3Rolo:= {||wopcao:='rolo', Relat('lst_exec("CUPOM_PN_PRT_FR3")',"nb",,"X"), wopcao:='a4' }
//skel VARIAVEL zbPrtPedidoFr3:= {||Relat('lst_exec("CUPOM_PN_PRT_FR3")',"nb",,"X") }
//skel VARIAVEL zbPrtPedRolo:= {||Relat("vb_r4(,,'PN',,"+lTrim(Str(fNumPed,11))+")","nb") }

//skel VARIAVEL zbDelPedido:=#TEXTO_FONTE
//skel     IF fg_fat$'D23N6'
//skel        if ALERT("Deseja cancelar a PRENOTA ?",{"1.Sim","2.Nao"})=1
//skel           (reglock(),_FIELD->FG_FAT:="C",DBCOMMIT(),DBUNLOCK(),ALERT("A PRENOTA FOI CANCELADA"),DobRefresh())
//skel        endif
//skel    else
//skel        Alert("Nao posso cancelar pedidos Ja Faturados, ou Ja Cancelados, ou na Producao, ou em Analise de Credito, ou na Producao !")
//skel    endif
//skel #FIM_TEXTO_FONTE

//skel variavel bCor = {|| if(fSubsidio>0, {16777215,255,16777215,10027008},{16711680,16777215,16776960,10027008})}

oContextMenu:=Hwg_ContextMenu()
hwg_Btn(oToolbar,5,5,64,64)
// hwg_TbMt(oToolbar,"13;eVal(zBlEnter);Enter-Altera;Enter-Altera o Pedido;xml\icon\alterarpn.ico;47;47;;")
hwg_TbMt(oToolbar,"80;tb_pesq(D_OB);P-Pesquisa;P-Pesquisa;xml\icon\Pesquisanfe.ico;47;47;;")
hwg_TbMt(oToolbar,"0;;;espaco;espaco;")
IF sys_segmento='locacao'
   hwg_TbMt(oToolbar,"65;eVal(zbAction, {||StartLocacao('prt_contrato_remessa',fnum,fCodop,fCli,fNumPed,alias())});A-Contrato;A-Imprime Contrato da Remessa ou Aditivo de Locacao;xml\icon\alterar.ico;47;47;;")
   hwg_TbMt(oToolbar,"68;eval(zbAction, zBlDespacho);D-Enviar para Despacho;D-Envia pedido para area de Despacho;xml\icon\cadastro.ico;47;47;;")
EndIf
hwg_TbMt(oToolbar,' 73;eVal(zbAction, zbPrtConferente);I-Conferente;I-Imprime o Conferente de separacao de produtos;impressora.ico;;;;;&I-Conferente;;;')
hwg_TbMt(oToolbar,' 73;eVal(zbAction, zbPrtPedido);1-Orcamento;I-Imprime Pedido/Orcamento em PDF formato papel A4;impressora.ico;;;;;&1-Ped.PDF;;;')
hwg_TbMt(oToolbar,' 73;eVal(zbAction, zbPrtPedRolo);2-Pedido;A-Imprime Pedido/Orcamento com opcoes impressora Matricial;impressora.ico;;;;;&2=Prt.Pedido;;;')
hwg_TbMt(oToolbar,' 73;eVal(zbAction, zbPrtPedidoFr3);3-A4_Fr3;I-Imprime Copia do Pedido/Orcamento em Papel A4 FR3;impressora.ico;;;;;&3-A4_Fr3;;;')
hwg_TbMt(oToolbar,' 73;eVal(zbAction, zbPrtPedidoFr3Rolo);4-RoloFr3;I-Imprime Copia do Pedido/Orcamento em Impressora Rolo FR3;impressora.ico;;;;;&4-RoloFr3;;;')

hwg_TbMt(oToolbar,"0;;;espaco;espaco;")
hwg_TbMt(oToolbar,"13;eVal(zbAction, zBlEnter);Enter-Altera;Enter-AlteraPN;xml\icon\alterarpn.ico;47;47;;")
hwg_TbMt(oToolbar,'7;eVal(zbDelPedido);DEL-DELeta ;DEL-Cancela o Pedido Corrente;deletar.ico;;;;;Deleta;;;')

hwg_Btn(oToolbar,10,544,70,24)
hwg_TbMt(oToolbar,'79;tb_index(D_OB);O-Ordena ;O-Ordena a coluna do cursor;sembitmap;;;Lucida Bright;-11;&O-Ordena;;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,'61;doget(D_ob,,.t.);=-Repete_Edicao ;= - Repete_Edicao;sembitmap;;;Lucida Bright;-11;&=-Repete_Edicao;;6;')
hwg_TbMt(oToolbar,'65;doget(D_ob);A-Edita;A-Edita a Coluna sob o cursor;sembitmap;;;Lucida Bright;-11;A=Editar;;6;')
hwg_TbMt(oToolbar,"27;hwg_oDlgKey(oDlg,27,nBrwAtivo);Saida;Saida;saida.ico;;;Lucida Bright;-11;ESC=Saida;;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()

DBCLEARFILTER()
DBSETORDER(0)
DBGOBOTTOM()
DBSKIP(-13)
  
z_recno:=Recno()
aComboOpcoes:=SitPedido(,"Retorne_Opcoes")
oComboFiltro:aitems := aComboOpcoes
oComboFiltro:Requery()
SetDlgItemText( getmodalhandle(), oComboFiltro:id, wFiltro )
oComboFiltro:Refresh()
]]>
  </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">{10,69,1000,333}</property>
      <property name="Name">[D_oB]</property>
      <property name="Anchor">15</property>
      <property name="GridLinesSepColor">0</property>
      <property name="TabIndex">4</property>
    </style>
    <method name="onGetFocus">
      <![CDATA[nBrwAtivo:=1]]>
    </method>
    <method name="onPosChange">
      <![CDATA[oBrwItens:Refresh()]]>
    </method>
    <method name="onInit">
      <![CDATA[hwg_TbFi(D_oB, 'Prenota;fNumPed;N;999999;6;S;')
hwg_TbFi(D_oB, 'Emissao;fDataEmi;D;; 8;;')
hwg_TbFi(D_oB, 'Hora;fhora;C;;8;N;')

hwg_TbFi(D_oB, 'Controle;fnum;N;999999999;9;;')
hwg_TbFi(D_oB, 'Mod;if(fgdev="E".and.fCodop="1.201","OP", IF(fnum>0, IF( VAL(fModelo)=65,"NFC",IF(VAL(fModelo)=55,"NFE","PED")),"  "));P;XXX;3;;')
//hwg_TbFi(D_oB, 'Pedido;if(fgdev="E","DEVOL",if(pfnum=0,str(fprenota,6),"RELOC"));P;@S6;6;;')
IF sys_segmento='locacao'
   hwg_TbFi(D_oB, 'Oper;if(fgdev="E",if(fCodop="1.201".or.fg_fat$"1P","ORDPRD","DEVOL"),if(fValLoca=0,"VENDA","LOCACAO"));P;@S7;7;;')
   hwg_TbFi(D_oB, 'Val_Prod;if(fgdev<>"E".and.fvalloca>0,"",Transform(fval,"@E 999,999.99"));P;@S10;10;;')
   hwg_TbFi(D_oB, 'Val_Loca;if(fgdev<>"E".and.fvalloca>0,Transform(fvalLoca,"@E 999,999.99"),"");P;@S10;10;;') 

   hwg_TbFi(D_oB, '%AbatQ;fPercAbatQ;N;99.99%;5;S;')
   hwg_TbFi(D_oB, '%AbatF;fPercAbatF;N;99.99%;5;S;')
   hwg_TbFi(D_oB, '%AbatI;fPercAbatI;N;99.99%;5;S;')

   hwg_TbFi(D_oB, '%dPri;fDsc1Loca;N;99.99%;5;;')
   hwg_TbFi(D_oB, '%dRel;fDscReloc;N;99.99%;5;;')
else
   hwg_TbFi(D_oB, 'Oper;if(fgdev="E","DEVOL",if(pfnum=0,if(fValLoca=0,if(fnum<0,"NFS","VENDA"),"LOCACAO"),"RELOC"));P;@S6;6;;')
   hwg_TbFi(D_oB, 'ValLiq;fval;N;@E 999,999.99;10;;')
ENDIF
hwg_TbFi(D_oB, '*;FgDev;C;X; 1;S;')
hwg_TbFi(D_oB, 'CFOP;fCodOp;C;XXXXX; 5;S;')
hwg_TbFi(D_oB, '*;fg_fat;C;!;1;S;')
hwg_TbFi(D_oB, 'CodCli;fCli;N;999999; 6;S;')
hwg_TbFi(D_oB, 'RazSoc;eVal(zBlkCli,fCli);C;@S20;20;;')
IF sys_segmento='locacao'
   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, 'Frete;fValFrete;N;999999.99;9;S;')
ENDIF
hwg_TbFi(D_oB, 'ValProd;fvalprod;N;@E 999,999.99;10;;')
hwg_TbFi(D_oB, 'Desconto;fdesconto;N;@E 999,999.99;10;;')
hwg_TbFi(D_oB, 'cVd;FVENDEDOR;N;9999;4;S;')
hwg_TbFi(D_oB, 'Vendedor;eval(zBlVendedor,FVENDEDOR);C;@S15;15;N;')
se fieldpos('fidcaixa')>0 entao hwg_TbFi(D_oB, 'IdCaixa;fIdCaixa;C;@S20;20;S;bCor;')
hwg_TbFi(D_oB, 'Obs;Nfe_xMotiv;C;@S20;20;N;')
hwg_TbFi(D_oB, 'PrevEnt;fBomPara;D;99.99.9999;10;S;')
hwg_TbFi(D_oB, 'nProt;nfe_nprot;C;@15;8;;')
hwg_TbFi(D_oB, 'Chave;fChaveNfe;C;@S44;44;;')
hwg_TbFi(D_oB, 'XML;nfe_xml;C;@S75;74;;')
hwg_TbFi(D_oB, 'COO;fnumcoo;N;999999; 6;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.,"SF_FATP",.F.,.T.,{||.T.} }
sHwgKeyEdit:= 61
sHwgKeyEdit:= 65
d_ob:bEdit := {|D_oB| .t.}
AADD(aBrowses,{D_oB,D_oB:Alias,{||.f.},{|| .T.},})
]]>
    </method>
  </part>
  <part class="label">
    <style>
      <property name="Geometry">{693,0,181,67}</property>
      <property name="Name">[oLabel1]</property>
      <property name="Caption">[Pedidos Cadastrados]</property>
      <property name="Justify">[Right]</property>
      <property name="font">
        <font name="Arial" width="0" height="-29" weight="700"/>
      </property>
      <property name="Transparent">.T.</property>
      <property name="TabIndex">5</property>
    </style>
  </part>
  <part class="browse">
    <style>
      <property name="Geometry">{148,408,862,137}</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="TabIndex">6</property>
    </style>
    <method name="onInit">
      <![CDATA[oBrwItens:Alias := 'sf_pnmv'
oBrwItens:bColorSel:= RGB(3,23,133)
oBrwItens:tColorSel:= RGB(255,255,255)
DBSELECTAREA( 'sf_pnmv' ) 

hwg_TbFi(@oBrwItens, 'Prod;Cod;N;999999;6;;')
hwg_TbFi(@oBrwItens, 'Descricao;eVal(zBlkPrd,Cod);C;@S50;50;;')
hwg_TbFi(@oBrwItens, 'Pedida;Quant;N;999999;6;;')
hwg_TbFi(@oBrwItens, 'Valor;PrTotal;N;999999.99;9;;')
IF sys_segmento='locacao'
   hwg_TbFi(@oBrwItens, 'TotLocacao;Quant*pValLoca;P;999999.99;10;;')
   hwg_TbFi(@oBrwItens, 'LocUnit;pValLoca;N;999999.99;9;;')
ENDIF
hwg_TbFi(@oBrwItens, 'Glb_Estoq;se_prod->pEatual;P;999999.99;9;;')
hwg_TbFi(@oBrwItens, 'Glb_Reserv;se_prod->pComprom;P;9999999.99;10;;')
hwg_TbFi(@oBrwItens, 'Glb_Livres;(se_prod->pEatual-se_prod->pComprom);P;9999999.99;10;;')
hwg_TbFi(@oBrwItens, 'OS_Reserv;mqReserv;N;999999.99;9;S;')
hwg_TbFi(@oBrwItens, 'OS_Pendentes;Quant-mqReserv;P;999999.99;9;S;')
hwg_TbFi(@oBrwItens, 'Faturadas;mqAtend;N;999999.99;9;N;')
hwg_TbFi(@oBrwItens, 'A Faturar;Quant-mqAtend;P;999999.99;9;N;')

oBrwItens:lFilter := .T.
oBrwItens:bFirst := {|| sf_pnmv->( DBSEEK( Sf_FatP->fNumPed, .F. ) ) } 
oBrwItens:bLast  := {|| sf_pnmv->( DBSEEK( Sf_FatP->fNumPed , .F., .T. ) ) }
oBrwItens:bWhile := {|| sf_pnmv->fNumPed = Sf_FatP->fNumPed }
oBrwItens:Refresh()
DbSelectArea( 'Sf_FatP' )
]]>
    </method>
  </part>
  <part class="combobox">
    <style>
      <property name="Geometry">{684,544,326,23}</property>
      <property name="Name">[oComboFiltro]</property>
      <property name="nInitValue">&quot;&quot;</property>
      <property name="varName">[wFiltro]</property>
      <property name="Anchor">14</property>
      <property name="VarItems">[]</property>
      <property name="Items">{}</property>
      <property name="font">
        <font name="" width="0" height="-19" weight="700"/>
      </property>
      <property name="Transparent">.T.</property>
      <property name="lEdit">.T.</property>
      <property name="TabIndex">8</property>
    </style>
    <method name="onChange">
      <![CDATA[IF EMPTY(wFiltro)
   DBCLEARFILTER()
ELSE
   DBSETFILTER({||fg_fat=wFiltro},"FG_FAT=wFiltro")
ENDIF
DBGOBOTTOM()
DBSKIP(-13)
d_ob:Refresh()]]>
    </method>
    <method name="onLostFocus">
      <![CDATA[IF EMPTY(wFiltro)
   DBCLEARFILTER()
ELSE
   DBSETFILTER({||fg_fat=wFiltro},"FG_FAT=wFiltro")
ENDIF
DBGOBOTTOM()
DBSKIP(-13)
d_ob:Refresh()
]]>
    </method>
    <method name="onInteractiveChange">
      <![CDATA[Parameters value,oComboFiltro
XmlChecaComboBox(value,oComboFiltro,aComboOpcoes)
//ALERT("wFiltro: "+wFiltro)]]>
    </method>
  </part>
  <part class="label">
    <style>
      <property name="Geometry">{635,548,42,19}</property>
      <property name="Name">[oLabel3]</property>
      <property name="Caption">[Filtro:]</property>
      <property name="Anchor">14</property>
      <property name="Transparent">.T.</property>
      <property name="TabIndex">9</property>
    </style>
  </part>
</part>
