SE_PROM;Tabelas Promocionais;sys_tbbrow; 7; 2;18;79;se_prom;;
:SKEL
variavel m_fcli:=if(Select("sccrcli")=0,0,sccrcli->(Recno()))
variavel w_tabpromocao:=0
variavel m_pdesconto:=0
VARIAVEL zbOpenAll = #TEXTO_FONTE
   DbCloseAll()
   ABRA("0NOIDX",r_siga,"sccrcli","sccrcli")
   ABRA("0NOIDX",r_siga,"sccpfab","sccpfab")
   ABRA("0NOIDX",r_siga,"se_prod","Se_prod","seip_c","pcod","seip_n","pdesc")
   Abra("0NOIDX",R_Siga, "SE_PROM", "SE_PROM","SE_PROM", "str(cr_cod_cli,6)+str(cr_tabela,3)+str(Pcod,6)+Str(pPrincforn,6)+Grupo")
#FIM_TEXTO_FONTE
variavel zbAction:={|bFunction| zrecn:=Recno(), eVal(bFunction), eVal(zbOpenAll), DbGoTo(zrecn), DobRefresh() }
variavel znil:=(eVal(zbOpenAll),DbGoBottom(),DbSkip(-8))

VARIAVEL zbCli := { |nCli| if(nCli>0, sccrcli->( DbGoto(nCli), '('+lTrim(Str(nCli,10))+')-'+if(empty(cr_fantasi),cr_nome,cr_fantasi) ), "Qualquer um com o Plano") }
VARIAVEL zbPlano := { |nPlanoPag| if(nPlanoPag>0, lTrim(Str(nPlanoPag,4)) , "Todos") }
VARIAVEL zbFabric := { |x_forn| sccpfab->( DbGoto(x_forn), if(empty(cp_fantasi),cp_nome,cp_fantasi) ) }
VARIAVEL zbProd := { |x_pcod| Se_Prod->( DbSeek(x_pcod) ), se_prod->Pdesc}

variavel #TEXTO_FONTE
   //ONINIT
      hwg_TbFi(@D_oB, 'Prod;PCOD;N;9999;4;N;')
      hwg_TbFi(@D_oB, 'Descricao;Eval(zbProd,pcod);P;@s35;30;N;')
      hwg_TbFi(@D_oB, 'PrProm;pvluven2;N;9999.99;7;S;')
      hwg_TbFi(@D_oB, '%Desc;se_prod->( if( (pCod=se_prom->pCod.or.DbSeek(se_prom->pCod)).and.pVluVenda>0, 100*(pVluVenda-se_prom->pVluVen2)/pVluVenda, "?" ));P;9999.99;7;N;')
      hwg_TbFi(@D_oB, 'Plano;Eval(zbPlano,Cr_Tabela);P;XXXXX;5;N;')
      hwg_TbFi(@D_oB, 'NomeCli;Eval(zbCli,Cr_Cod_Cli);P;@s23;23;N;')
      hwg_TbFi(@D_oB, 'Fabricante;Eval(zbFabric,Se_Prod->pprincforn);C;@s10;10;N;')
      hwg_TbFi(@D_oB, 'PrNormal;se_prod->(pCod=se_prom->pCod.or.DbSeek(se_prom->pCod),pvluvenda);P;9999.99;7;N;')
      hwg_TbFi(@D_oB, 'Val_Dsc;se_prod->( if( (pCod=se_prom->pCod.or.DbSeek(se_prom->pCod)).and.pVluVenda>0, pVluVenda-se_prom->pVluVen2, "?" ));P;9999.99;7;N;')
   //ENDONINIT
   //ONDLGINIT
      // oDlg:Maximize()
   //ENDDLGINIT
#FIM_TEXTO_FONTE

COMANDO SAIDA znil := ( Se_Prod->(DbCloseArea()), Sccpfab->(DbCloseArea()), sccrcli->(DbCloseArea()) )
:TBMT
22;eval(zbAction,{||AnexaProm("QBE", @m_fcli, @w_tabpromocao, @m_pdesconto)});Ins-Selecionar_Produtos ;
13;doget(d_ob);Barra-Altera ;
7;tb_del(d_ob);Del-Deleta ;
79;tb_index(d_ob);O-Ordena ;
80;tb_pesq(d_ob);P-Pesquisa ;
73;eval(zbAction,{||lst_alias(d_ob)});I-Listagens ;
