<?xml version="1.0" encoding="UTF-8"?>
<part class="form">
  <style>
    <property name="Geometry">{290,156,1010,620}</property>
    <property name="Name">[vb_apto.scr]</property>
    <property name="Caption">[Checkin x Checkout]</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 zBlFecha={|| z_recno:=recno(),StartMesa("S",,,,d_ob,"/FECHAMENTO/",,,,,"FECHAR",vb_apto->fatprecno), eVal(zbOpenAll)}

//skel VARIAVEL zbStatus={||vb_apto->(if(fatprecno=0.and.empty(DtHr_Ocup),"LIVRE","OCUPADO"))}
//skel VARIAVEL zBlPrint=""
//skel VARIAVEL zBlMovimenta={|| StartMesa("V",,,,d_ob,"/ALTERARPV/",,,,,"MOVIMENTAR",vb_apto->fatprecno) }
//skel VARIAVEL zBlFecha={|| StartMesa("V",,,,d_ob,"/FECHAMENTO/",,,,,"FECHAR",vb_apto->fatprecno) }
//skel VARIAVEL zBlFecharFicha={|| StartMesa("V","fechar_ficha",,,d_ob,"/FECHAMENTO/",,,,,"FECHAR",vb_apto->fatprecno)}
//skel VARIAVEL zBlFecharPedido={|| StartMesa("V","fechar_pedido",,,d_ob,"/FECHAMENTO/",,,,,"FECHAR",vb_apto->fatprecno)}
//skel varIAVEL bCor = {|| if(vb_apto->fatprecno=0, {16777215,32768,16776960,10027008},{16711680,65535,16776960,10027008}) }

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

wSemPedir1TempoAlerta := 15
wSemPedir2TempoAlerta := 30
wSemPedir1CorAlerta := {x_WHITE,x_YELLOW,x_CYAN,x_DARKBLUE}
wSemPedir2CorAlerta := {x_WHITE,x_RED,x_CYAN,x_DARKBLUE}

wEsperaPrato1TempoAlerta := 15
wEsperaPrato2TempoAlerta := 30
wEsperaPrato1CorAlerta := {x_WHITE,x_YELLOW,x_CYAN,x_DARKBLUE}
wEsperaPrato2CorAlerta := {x_WHITE,x_RED,x_CYAN,x_DARKBLUE}

wEsperaEntrega1TempoAlerta := 15
wEsperaEntrega2TempoAlerta := 30
wEsperaEntrega1CorAlerta := {x_WHITE,x_YELLOW,x_CYAN,x_DARKBLUE}
wEsperaEntrega2CorAlerta := {x_WHITE,x_RED,x_CYAN,x_DARKBLUE}

////     bloco cor da mesa x_WHITE,x_GREEN,x_CYAN,x_DARKBLUE
////                        x_BLUE,x_YELLOW,x_CYAN,x_DARKBLUE

//         {x_RED, x_WHITE, x_CYAN, x_GRAY}
//         {x_BLUE, x_WHITE , x_BLACK, x_YELLOW })}
//
//         {x_RED, x_WHITE, x_CYAN, x_DARKBLUE}
//         {x_BLACK, x_WHITE , x_WHITE, x_DARKBLUE })}

IF s_sys_paf
   zBlPrint:={||zRecnoMesa:=Recno(),z_recno:=recno(), Paf_DavPrt(z_recno, "davecf_mesas"), eVal(zbOpenAll)}
ELSE
   // zBlMovimenta:={|| StartMesa("S",,,,d_ob,"/ALTERARPV/",,,,,"MOVIMENTAR",vb_apto->fatprecno) }
   IF xGetEnv("FATURA_SERVICOS")="S" 
      zBlFecha:={|| StartMesa("S",,,,d_ob,"/FECHAMENTO/",,,,,"FECHAR",vb_apto->fatprecno) }
      zBlFecharFicha:={|| StartMesa("S","fechar_ficha",,,d_ob,"/FECHAMENTO/",,,,,"FECHAR",vb_apto->fatprecno)}
      zBlFecharPedido:={|| StartMesa("S","fechar_pedido",,,d_ob,"/FECHAMENTO/",,,,,"FECHAR",vb_apto->fatprecno)}
   ENDIF
   zBlPrint:={||StartMesa("imprimir")}
ENDIF
   
oContextMenu:=Hwg_ContextMenu()
hwg_Btn(oToolbar,5,5,100,54)

hwg_TbMt(oToolbar,'13;StartMesa("get_produtos","cozinha");Enter-Produtos/Servicos;Enter-Lanca Consumo no Apto;sembitmap;;;Lucida Bright;-12;F1-Consumo e/ou &Servicos;')
hwg_TbMt(oToolbar,'76;Eval(zBlMovimenta);L-Altera ou Lanca Consumo;L-Altera ou Lanca Consumo de Itens no Apto;sembitmap;;;Lucida Bright;-12;F6-&Altera Consumo;')
hwg_TbMt(oToolbar,'32;Eval(zBlFecha);Barra-CheckOut ;Barra-Efetua Fechamento de Conta - CheckOut - do Apto;sembitmap;;;Lucida Bright;-12;F2-Check&Out;')

hwg_TbMt(oToolbar,'73;Eval(zBlPrint);I-Imprime_Conta ;I-Imprime Consumo do Apto;sembitmap;;;Lucida Bright;-12;F3 - &Imprime Consumo;')
hwg_TbMt(oToolbar,'73;StartMesa("gerencia_cozinha");Z-Cozinha ;Z-Cozinha;sembitmap;;;Lucida Bright;-12;Z-Co&zinha;')

hwg_TbMt(oToolbar,'73;StartMesa("get_checkin");O-CheckIn ;O-CheckIn do apartamento;sembitmap;;;Lucida Bright;-12;F4-Check&In;')
hwg_TbMt(oToolbar,'84;StartMesa("transferir");T-Transferencia_de_Apto ;Enter-Efetua mudanca de Apartamento;sembitmap;;;Lucida Bright;-12;&Transferencia de Apto;')

hwg_TbMt(oToolbar,'27;hwg_oDlgKey(oDlg, 27, nBrwAtivo);Saida;Saida;xml\icon\sair.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()
StartMesa("desenhe_apto")
vb_apto->( DBGOTOP() )
wSegundosParaRefresh:=5
StartMesa("starttimer","apto")
CiSetKey( "K_F1",'StartMesa("get_produtos","cozinha")',,,"F1: Lanca Consumo no Apartamento")
CiSetKey( "K_F2","Eval(zBlFecha)",,,"F2: Efetua CheckOut do Apartamento")
CiSetKey( "K_F3","Eval(zBlPrint)",,,"F3: Imprime Consumos do Apartamento")
CiSetKey( "K_F4",'StartMesa("get_checkin")',,,"F4: Efetua CheckIn no Apartamento")
//CiSetKey( "K_F5","eVal(zBlFecharFicha)",,,"F5: Fecha Pedido pelo Numero da Ficha")
//CiSetKey( "K_F6",'Eval(zBlMovimenta)',,,"F6: Lanca ou Altera item na mesa")
]]>
  </method>
  <method name="onPaint">
    <![CDATA[Parameters oCtrl,hDC
oCtrl:bpaint:=NIL
D_oB:setFocus()]]>
  </method>
  <part class="status">
    <style>
      <property name="Geometry">{0,590,1010,30}</property>
      <property name="Name">[oDlgStatusBar]</property>
      <property name="aParts">{608,152,0}</property>
    </style>
  </part>
  <part class="browse">
    <style>
      <property name="Geometry">{5,79,1000,165}</property>
      <property name="Name">[D_oB]</property>
      <property name="font">
        <font name="Lucida Sans" width="0" height="-27" weight="600"/>
      </property>
      <property name="GridLinesSepColor">0</property>
      <property name="TabIndex">4</property>
    </style>
    <method name="onGetFocus">
      <![CDATA[nBrwAtivo:=1]]>
    </method>
    <method name="onPosChange">
      <![CDATA[sf_pn->(DBGOTO(vb_apto->FatpRecno))
sf_pnmv->( DBSEEK( sf_pn->fnumped ) )
sf_aptcl->( DBSEEK( STR(sf_pn->fnumped,10)+" ") )
oBrwItens:Refresh()
oBrwOcupantes:Refresh()
RETURN .t.]]>
    </method>
    <method name="onInit">
      <![CDATA[hwg_TbFi(D_oB, 'Apto;apto;N;99; 2;;')
hwg_TbFi(D_oB, 'Tipo;aptipo;C;@S10;10;;')
hwg_TbFi(D_oB, 'Ramal;apfone;C;@S10;10;;')
hwg_TbFi(D_oB, 'Situacao;eval(zbStatus);C;@S10; 10;;bCor;')
hwg_TbFi(D_oB, 'Hospede;cr_nome;C;@S20;10;;')
hwg_TbFi(D_oB, 'Ocupantes;FOCUPANTES;N;999;9;;')

// hwg_TbFi(D_oB, 'Situacao;wcAtraso;P;@S12;12;;wbCorAtraso;')

hwg_TbFi(D_oB, 'DtHr_Ocup;hb_TtoC(DtHr_Ocup);P;@S12;12;;')
hwg_TbFi(D_oB, 'DtHr_Pedid;hb_TtoC(DtHr_Pedid);P;@S12;12;;')
hwg_TbFi(D_oB, 'DtHr_Serv;hb_TtoC(DtHr_Serv);P;@S12;12;;')
hwg_TbFi(D_oB, 'DtHr_Fech;hb_TtoC(DtHr_Fech);P;@S12;12;;')
D_oB:bColorSel:= RGB(3,23,133)
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.,"VB_APTO",.F.,.T.,{||.T.} }
d_ob:bEdit := {|D_oB| .t.}
AADD(aBrowses,{D_oB,D_oB:Alias,{||.f.},{|| .T.},})
]]>
    </method>
  </part>
  <part class="browse">
    <style>
      <property name="Geometry">{159,395,849,142}</property>
      <property name="Name">[oBrwItens]</property>
      <property name="font">
        <font name="Lucida Sans" 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;desc;C;@S30;30;;')
hwg_TbFi(@oBrwItens, 'Quant;Quant;N;@e 9,999.999;9;;')
hwg_TbFi(@oBrwItens, 'Pr.Unit;PrUnit;N;@e 99,9999.99;10;;')
hwg_TbFi(@oBrwItens, 'Vl.Total;PrTotal;N;@e 99,9999.99;10;;')
oBrwItens:lFilter := .T.
oBrwItens:bFirst := {|| sf_pnmv->( DBSEEK( sf_pn->fnumped, .F. ) ) } 
oBrwItens:bLast  := {|| sf_pnmv->( DBSEEK( sf_pn->fnumped, .F., .T. ) ) }
oBrwItens:bWhile := {|| vb_apto->fatprecno>0 .and. sf_pnmv->fnumped=sf_pn->fnumped }
// oBrwItens:Refresh()
DbSelectArea( 'sf_pn' )
// alert('definiu oBrwItens:alias '+oBrwItens:alias+' sf_pn->fnumped '+str(sf_pn->fnumped,6)+ ' oBrwItens:nColumns '+str(oBrwItens:nColumns,4) )
]]>
    </method>
  </part>
  <part class="browse">
    <style>
      <property name="Geometry">{159,255,849,127}</property>
      <property name="Name">[oBrwOcupantes]</property>
      <property name="font">
        <font name="Lucida Sans" width="0" height="-13" weight="400"/>
      </property>
      <property name="TabIndex">6</property>
    </style>
    <method name="onInit">
      <![CDATA[oBrwOcupantes:Alias := 'sf_aptcl'
oBrwOcupantes:bColorSel:= RGB(3,23,133)
oBrwOcupantes:tColorSel:= RGB(255,255,255)
DbSelectArea( 'sf_aptcl' )
sf_aptcl->(hwg_TbFi(@oBrwOcupantes, 'Nome;cr_nome;C;@S25;25;;'))
sf_aptcl->(hwg_TbFi(@oBrwOcupantes, 'Dt_Nasc;Cr_Dt_Nasc;D;99.99.9999;10;;'))
sf_aptcl->(hwg_TbFi(@oBrwOcupantes, 'Sexo;cr_sexo;C;xxxx;4;;'))
//sf_aptcl->(hwg_TbFi(@oBrwOcupantes, 'DtHr_Pedid;hb_TtoC(DtHr_Pedid);P;@S14;14;;'))
//sf_aptcl->(hwg_TbFi(@oBrwOcupantes, 'Tempo;tString((Hb_DateTime()-DtHr_Pedid)*86400);P;@S10;10;;'))
oBrwOcupantes:lFilter := .T.
oBrwOcupantes:bFirst := {|| sf_aptcl->( DBSEEK( STR(sf_pn->fnumped,10)+" ") ) } 
oBrwOcupantes:bLast  := {|| sf_aptcl->( DBSEEK( STR(sf_pn->fnumped,10)+" " , .F., .T. ) ) }
oBrwOcupantes:bWhile := {|| vb_apto->fatprecno>0 .and. sf_aptcl->fnumped=sf_pn->fnumped }
// oBrwItens:Refresh()
DbSelectArea( 'sf_pn' )
// alert('definiu oBrwItens:alias '+oBrwItens:alias+' sf_pn->fnumped '+str(sf_pn->fnumped,6)+ ' oBrwItens:nColumns '+str(oBrwItens:nColumns,4) )
]]>
    </method>
  </part>
  <part class="label">
    <style>
      <property name="Geometry">{6,58,95,19}</property>
      <property name="Name">[oLabel2]</property>
      <property name="Caption">[Apartamentos]</property>
      <property name="Transparent">.T.</property>
      <property name="TabIndex">7</property>
    </style>
  </part>
  <part class="label">
    <style>
      <property name="Geometry">{18,395,134,36}</property>
      <property name="Name">[oLabel3]</property>
      <property name="Caption">[Consumos do Apartamento]</property>
      <property name="Justify">[Right]</property>
      <property name="Transparent">.T.</property>
      <property name="TabIndex">7</property>
    </style>
  </part>
  <part class="label">
    <style>
      <property name="Geometry">{18,255,134,34}</property>
      <property name="Name">[oLabel1]</property>
      <property name="Caption">[Cliente e Acompanhantes]</property>
      <property name="Justify">[Right]</property>
      <property name="Transparent">.T.</property>
      <property name="TabIndex">7</property>
    </style>
  </part>
</part>
