**************************
*FACTURAS DE VENTA
**************************
FUNCTION fFacturas()
REQUEST FWZEBRA
Local aCol:={0,0,0,0,0,0,0,0,0,0,0,0,0},nWidth:=0
Local aCols:={0,0,0}
Local vGet2:="get2",vGet1:="get1",uVar,cText:=space(15)
Local oExpPqr, oPanel1, oPanel2, oPanel3, oPanel4
Local oSplitV
Local aGrad := { { CLR_WHITE, RGB( 51, 153, 255 ) },;
{ CLR_WHITE, RGB( 51, 153, 255 ) } }
Local vGBus := space(100)
//CONSULTA DEL LISTADO DE LAS FACTURAS
oVar:="SELECT FAC.*,SUM(MOV.mm_subtot) AS subtotal,"+;
"SUM(MOV.mm_basiva) AS base,"+;
"SUM(MOV.mm_valiva) AS iva,"+;
"SUM(MOV.mm_totale) AS total,"+;
"CONCAT(t_razons,' ',t_prinom,' ',t_segnom,' ',t_priape,' ',t_segape) AS nombre,TER.t_ciudad,"+;
"BOD.b_nombre,DOC.*"+;
" FROM ((("+oLamcla:tFact+" FAC"+;
" LEFT JOIN "+oLamcla:tMofa+" MOV ON FAC.ll_consec=MOV.mm_consec)"+;
" LEFT JOIN "+oLamcla:tTerc+" TER ON FAC.ll_tercer=TER.t_tercer)"+;
" LEFT JOIN "+oLamcla:tBode+" BOD ON FAC.ll_bodega=BOD.b_bodega)"+;
" LEFT JOIN "+oLamcla:tDofa+" DOC ON FAC.ll_docume=DOC.ee_codigo"+;
" GROUP BY FAC.ll_consec ORDER BY FAC.ll_docume,FAC.ll_consec + 0"
//el + 0 Es para que mysql tome en campo consecutivo como numero
oRsFtr := FW_OPENRECORDSET(oCnFtr,oVar,adLockOptimistic,adOpenKeyset)
Define Font oFont Name "Calibri" Size 0,-13 BOLD
Define Font oFont1 Name "Calibri" Size 0,-13
Define Font oFont2 Name "Calibri" Size 0,-20 BOLD
Define Font oFontT Name "Calibri" Size 0,-13 STRIKEOUT
Define Font oFontN Name "Calibri" Size 0,-13
DEFINE WINDOW oWChPq MDICHILD TITLE "Facturas de Venta" ICON "#8001" OF oWnd
SET MESSAGE OF oWChPq TO "Facturas de Venta" 2010
oExpPqr = TExplorerBar():New( 00, 00, 240, oWChPq:nHeight, oWChPq )
oExpPqr:nTopColor := RGB( 215, 215, 215 )
oExpPqr:nBottomColor := RGB( 215, 215, 215 )
oPanel1 = oExpPqr:AddPanel( "FACTURAS DE VENTA", "#8068", , 30, 0, aGrad, , CLR_WHITE, CLR_WHITE )
oPanel1:AddLink( "Agregar Fact. ", {|| manteFacturas(0) }, "#8203" )
oPanel1:AddLink( "Modificar Fact.", {|| manteFacturas() }, "#8202" )
oPanel1:AddLink( "Anular Fact.", {|| msginfo("Sin Acceso") }, "#8204" )
oPanel1:AddLink( "Importar JSON", {|| leerdirectorio() }, "#8210" )
oPanel1:nClrHover := RGB( 213, 234, 255 )
oPanel2 = oExpPqr:AddPanel( "REPORTES", "#8067", , 25, 0 )
oPanel2:SetColor( RGB( 0, 0, 255 ), CLR_WHITE)
oPanel2:AddLink( "Certificado Trazabilidad", {|| impTrazabilidad() }, "#8209" )
oPanel2:AddLink( "Configurar Impresora", {|| PrinterSetup() }, "#8205" )
oPanel3 = oExpPqr:AddPanel( "FACT.ELECTRÓNICA", "#8066", , 25, 0 )
oPanel3:SetColor( RGB( 0, 0, 255 ), CLR_WHITE)
oPanel3:AddLink( "Enviar DIAN ", {|| msginfo("enviamos a la DIAN") }, "#8206" )
oPanel3:AddLink( "Consular Estado ", {|| EnviarEST(oRsFtr:Fields( "ll_consec" ):Value) }, "#8211" )
oPanel4 = oExpPqr:AddPanel( "BUSQUEDA ", "#8099", 40 )
oPanel4:SetColor( RGB( 0, 0, 255 ), CLR_WHITE)
@ 33,11 GET oGBus VAR vGBus OF oPanel4 SIZE 147,23 PIXEL VALID (buscaInfo(vGBus),.t.) PICTURE "@N"
oGBus:bGotFocus := {|| oGBus:SelectAll(.T.) }
@ 33,160 BUTTONBMP of oPanel4 pixel size 23, 23 BITMAP "#8212" ACTION buscaInfo(" ") TOOLTIP "Limpiar Filtro"
oPanel5 = oExpPqr:AddPanel( "SALIDA", "#8070", , 25, 0 )
oPanel5:SetColor( RGB( 0, 0, 255 ), CLR_WHITE)
oPanel5:AddLink( "Cerrar Ventana", {|| oWChPq:End() }, "#8207" )
oBrwFt := TXBrowse():New( oWChPq )
oBrwFt:nMarqueeStyle := MARQSTYLE_HIGHLROW
oBrwFt:nRowDividerStyle := LINESTYLE_LIGHTGRAY
oBrwFt:nColDividerStyle := LINESTYLE_LIGHTGRAY
oBrwFt:nHeaderLines := 1
oBrwFt:lColDividerComplete := .t.
oBrwFt:lRecordSelector := .t.
oBrwFt:nStretchCol := STRETCHCOL_LAST
oBrwFt:l2007 := .f.
oBrwFt:oFont := oFont1
oBrwFt:nLeft := 243 // DISTANCIA DESDE EL BORDER IZQ.
oBrwFt:bLDblClick := {|nRow, nCol| manteFacturas() }
oBrwFt:bKeyDown := {|nKey,oGet,nCol|TeclasFtr(nKey,oGet,nCol)}
oCol = oBrwFt:AddCol()
oCol:bStrData = { || If( oRsFtr:Eof, Space( nWidth ), TRANSFORM( oRsFtr:Fields( "ll_consec" ):Value ,"9999999999" ) ) }
oCol:cHeader = "Consec."
oCol:nWidth = 65
oCol:nHeadStrAlign = AL_RIGHT
oCol:nDataStrAlign = AL_RIGHT
oCol:oHeaderFont = oFont
oCol = oBrwFt:AddCol()
oCol:bStrData = { || If( oRsFtr:Eof, Space( nWidth ), cValtoChar( oRsFtr:Fields( "ll_contro" ):Value ) ) }
oCol:cHeader = "Tipo"
oCol:nWidth = 40
oCol:nHeadStrAlign = AL_LEFT
oCol:nDataStrAlign = AL_LEFT
oCol:oHeaderFont = oFont
oCol = oBrwFt:AddCol()
oCol:bStrData = { || If( oRsFtr:Eof, Space( nWidth ), DTOC(oRsFtr:Fields("ll_fechas" ):Value) ) }
oCol:cHeader = "Fecha Factura"
oCol:nWidth = 90
oCol:nHeadStrAlign = AL_LEFT
oCol:nDataStrAlign = AL_LEFT
oCol:oHeaderFont = oFont
oCol = oBrwFt:AddCol()
oCol:bStrData = { || If( oRsFtr:Eof, Space( nWidth ), cValtoChar( oRsFtr:Fields( "ll_tercer" ):Value ) ) }
oCol:cHeader = "Tercero"
oCol:nWidth = 90
oCol:nHeadStrAlign = AL_LEFT
oCol:nDataStrAlign = AL_LEFT
oCol:oHeaderFont = oFont
oCol = oBrwFt:AddCol()
oCol:bStrData = { || If( oRsFtr:Eof, Space( nWidth ), alltrim( cValtoChar( oRsFtr:Fields( "nombre" ):Value ) ) ) }
oCol:cHeader = "Nombre"
oCol:nWidth = 300
oCol:nHeadStrAlign = AL_LEFT
oCol:nDataStrAlign = AL_LEFT
oCol:oHeaderFont = oFont
oCol = oBrwFt:AddCol()
oCol:bStrData = { || If( oRsFtr:Eof, Space( nWidth ), ;
if(cValtoChar( oRsFtr:Fields( "ll_anulad" ):Value )="A","Anulada","Activa") ) }
oCol:cHeader = "Estado"
oCol:nWidth = 90
oCol:nHeadStrAlign = AL_LEFT
oCol:nDataStrAlign = AL_LEFT
oCol:oHeaderFont = oFont
oCol = oBrwFt:AddCol()
oCol:bStrData = { || If( oRsFtr:Eof, Space( nWidth ), Transform(oRsFtr:Fields( "subtotal" ):Value,oLamcla:PIC7) ) }
oCol:cHeader = "Sub Total"
oCol:nWidth = 85
oCol:nHeadStrAlign = AL_RIGHT
oCol:nDataStrAlign = AL_RIGHT
oCol:oHeaderFont = oFont
oCol = oBrwFt:AddCol()
oCol:bStrData = { || If( oRsFtr:Eof, Space( nWidth ), Transform(oRsFtr:Fields( "base" ):Value,oLamcla:PIC7) ) }
oCol:cHeader = "Base I.V.A."
oCol:nWidth = 85
oCol:nHeadStrAlign = AL_RIGHT
oCol:nDataStrAlign = AL_RIGHT
oCol:oHeaderFont = oFont
oCol = oBrwFt:AddCol()
oCol:bStrData = { || If( oRsFtr:Eof, Space( nWidth ), Transform(oRsFtr:Fields( "iva" ):Value,oLamcla:PIC7) ) }
oCol:cHeader = "I.V.A."
oCol:nWidth = 85
oCol:nHeadStrAlign = AL_RIGHT
oCol:nDataStrAlign = AL_RIGHT
oCol:oHeaderFont = oFont
oCol = oBrwFt:AddCol()
oCol:bStrData = { || If( oRsFtr:Eof, Space( nWidth ), Transform(oRsFtr:Fields( "total" ):Value,oLamcla:PIC7) ) }
oCol:cHeader = "Total"
oCol:nWidth = 85
oCol:nHeadStrAlign = AL_RIGHT
oCol:nDataStrAlign = AL_RIGHT
oCol:oHeaderFont = oFont
oBrwFt:SetADO( oRsFtr )
//oBrwFt:aCols[6]:oDataFont := {|o| if(upper(left(o:Value,1)) ="A",oFontT,oFontN)}
oBrwFt:CreateFromCode()
@ 00,240 SPLITTER oSplitV VERTICAL ;
PREVIOUS CONTROLS oExpPqr ;
HINDS CONTROLS oBrwFt ;
SIZE 1, oWChPq:nHeight PIXEL ;
OF oWChPq ;
3DLOOK UPDATE
oSplitV:lStatic:=.t.
oBtF4:disable()
oWChPq:bPostEnd := { || oRsFtr:Close(),oCnFtr:Close() }
ACTIVATE WINDOW oWChPq MAXIMIZED ON INIT (oBrwFt:goBottom(),oBrwFt:setfocus()) ON RESIZE( oExpPqr:AdjLeft(), oSplitV:AdjClient(), oSplitV:AdjRight() ) VALID(oBtF4:enable(),.t. )