#include "FiveWin.ch"
#include "Report.ch"
#include "xBrowse.ch"
#include "constant.ch"
Function Test()
Local oDlg,oBrw
Local nBottom := 16.5
Local nRight := 120
Local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
Local nHeight := nBottom * DLG_CHARPIX_H
Local oFont
Local aRowGrad := { { .5, RGB( 232, 241, 252 ), RGB( 232, 241, 252 ) }, ;
{ .5, RGB( 210, 225, 244 ), RGB( 235, 243, 253 ) } }
Local aSelGrad := { { .5, RGB( 255, 255, 251 ), RGB( 255, 237, 178 ) }, ;
{ .5, RGB( 255, 218, 103 ), RGB( 255, 233, 162 ) } }
Local aData:={}
Local aMes:={ "Gen","Feb","Mar","Apr","Mag","Giu","Lug","Ago","Set","Oct","Nov","Dic" }
Local aEntrate :={}
Local aUscite :={}
Local cClrEntrate := 7031871
Local cClrUscite := 204
Local oBtnChartType[2]
Local oBtnPrint
Local aGet[1]
Local nMaxvalue := 400
Local aCanE :={ { "Gen", 0 }, { "Feb", 0 }, { "Mar", 0 }, { "Apr", 0 }, ;
{ "Mag", 0 }, { "Giu", 0 }, { "Lug", 0 }, { "Ago", 0 }, ;
{ "Set", 0 }, { "Oct", 0 }, { "Nov", 0 }, { "Dic", 0 } }
Local aCanU :={ { "Gen", 0 }, { "Feb", 0 }, { "Mar", 0 }, { "Apr", 0 }, ;
{ "Mag", 0 }, { "Giu", 0 }, { "Lug", 0 }, { "Ago", 0 }, ;
{ "Set", 0 }, { "Oct", 0 }, { "Nov", 0 }, { "Dic", 0 } }
USE MOVIMENTI ALIAS MV
MV->(DbGoTop())
MV->( DBEVAL( { || aCanE[ Month( MV->APFECHA ) ][ 2 ]+= IIF( MV->APTIPO="E", MV->APIMPTOTAL,0) } ) )
MV->( DBEVAL( { || aCanU[ Month( MV->APFECHA ) ][ 2 ]+= IIF( MV->APTIPO="U", MV->APIMPTOTAL,0) } ) )
For n=1 to len( aCanE)
AADD( aEntrate,aCanE[n][2])
next n
For n=1 to len( aCanU)
AADD( aUscite,aCanU[n][2])
next n
AAdd( aData, {'Entrate', aEntrate[1], aEntrate[2], aEntrate[3],;
aEntrate[4], aEntrate[5], aEntrate[6], aEntrate[7], aEntrate[8], ;
aEntrate[9], aEntrate[10], aEntrate[11], aEntrate[12] } )
AAdd( aData, {'Uscite', aUscite[1], aUscite[2], aUscite[3],;
aUscite[4], aUscite[5], aUscite[6], aUscite[7], aUscite[8], ;
aUscite[9], aUscite[10], aUscite[11], aUscite[12] } )
DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-10
DEFINE DIALOG oDlg SIZE nWidth, nHeight;
TRANSPARENT PIXEL TITLE "Test";
FONT oFont
@ 0, 2 XBROWSE oBrw;
HEADERS 'Voci', 'Gen','Feb','Mar','Apr','Mag','Giu','Lug','Ago','Set','Ott','Nov','Dic';
SIZE 470,100 PIXEL ;
OF oDlg ;
ARRAY aData AUTOCOLS FOOTERS
oBrw:nStretchCol := STRETCHCOL_LAST
WITH OBJECT oBrw
:nMarqueeStyle := 4
:bClrSelFocus := { || { CLR_BLACK, aSelGrad } }
:bClrRowFocus := { || { CLR_BLACK, aRowGrad } }
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:lColDividerComplete := .t.
:lRecordSelector := .T.
END
WITH OBJECT oBrw:AddCol()
:cHeader := "CHART"
:aChartCols := { 'Gen','Feb','Mar','Apr','Mag','Giu','Lug','Ago','Set','Ott','Nov','Dic' } // This also works
* :nChartMaxVal := 400
:nWidth := 120
:aChartColors := IIf(LTRIM(oBrw:Voci:Value)=="Entrate",cClrEntrate,cClrUscite)
END
// FOOTERS
AEval( oBrw:aCols, { |o| o:cEditPicture := '99,999.99', ;
o:nFooterType := AGGR_SUM, o:nWidth:= 50, ;
o:bOnChange := { || oBrw:MakeTotals(),oBrw:RefreshFooters() } }, 2 )
oBrw:Voci:cFooter := 'Totale'
oBrw:nDataLines := 3
oBrw:MakeTotals()
oBrw:CreateFromCode()
@100,2 BUTTON oBtnChartType[1] PROMPT "Bar" OF oDlg ;
SIZE 25,15 PIXEL ACTION ( oBrw:Chart:cChartType:= "BAR" ,oBrw:refresh())
@100,30 BUTTON oBtnChartType[2] PROMPT "Line" OF oDlg ;
SIZE 25,15 PIXEL ACTION ( oBrw:Chart:cChartType:= "LINE" ,oBrw:refresh())
@100,60 BUTTON oBtnPrint PROMPT "Report" OF oDlg ;
SIZE 25,15 PIXEL ACTION oBrw:Report()
@ 105, 120 SAY "Select maxvalue:" of oDlg PIXEL
@ 105, 160 get aget[1] var nMaxvalue spinner picture"9999" of oDlg PIXEL on change (oBrw:Chart:nChartMaxVal := nMaxvalue ,oBrw:refresh())
ACTIVATE DIALOG oDlg CENTER ;
on init aget[1]:nHeight:=21.4
RELEASE FONT oFont
RETURN NIL