#include "fivewin.ch"
REQUEST DBFCDX
REQUEST DBFFPT
EXTERNAL ORDKEYNO,ORDKEYCOUNT,ORDCREATE,ORDKEYGOTO
function Tariffe()
local oDlg, oFont,oBold
local oBrwBase,oBrwTariffe
local aget[1]
local nFilterCol := 8
local aListini := Crea_Array_listini() //creation price_list
local aData := Crea_Base(aListini)
local cFilter := alistini[1][2]
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE FONT oBold NAME "TAHOMA" SIZE 0,-14 BOLD
DEFINE DIALOG oDlgTariffe SIZE 500,600;
PIXEL TRUEPIXEL RESIZABLE FONT oFont;
TITLE " Tariffe"
@ 10, 40 SAY oSay1 PROMPT "Tariffe Base" SIZE 400,24 PIXEL OF oDlgTariffe CENTER FONT oBold
@ 38,20 SAY "Listino :" SIZE 80,14 PIXEL OF oDlgTariffe
@ 70,20 XBROWSE oBrwBase SIZE -5,200 PIXEL OF oDlgTariffe ;
HEADERS "Elemento","Settore","Giorni","Costo", "Bloccato";
DATASOURCE FilterArray( aData, nFilterCol, cFilter ) ;
COLUMNS 3,4,5,6,7;
CELL LINES NOBORDER
WITH OBJECT oBrwBase
:CreateFromCode()
END
@ 36,75 COMBOBOX cFilter ITEMS ArrTranspose( aListini )[ 1] SIZE 100,400 PIXEL OF oDlgTariffe;
ON CHANGE ( oBrwBase:aArrayData := FilterArray( aData, nFilterCol, cFilter ), ;
oBrwBase:GoTop(), oBrwBase:Refresh() )
@ 550,260 BUTTON oBtnClose PROMPT "Conferma" SIZE 80,30 PIXEL OF oDlgTariffe;
ACTION NIL
@ 550,360 BUTTON oBtnOK PROMPT "Annulla" SIZE 80,30 PIXEL OF oDlgTariffe;
ACTION NIL
oDlgTariffe:bResized := <||
local oRect := oDlgTariffe:GetCliRect()
oBtnClose:nLeft := oRect:nRight - 220
oBtnClose:nTop := oRect:nBottom - 50
oBtnOK:nLeft := oRect:nRight - 120
oBtnOK:nTop := oRect:nBottom - 50
oBrwBase:refresh()
* oBrwTariffe:refresh()
RETURN nil
>
ACTIVATE DIALOG oDlgTariffe CENTERED
RELEASE FONT oFont, oBold
RETURN nil
//----------------------------------------------------------------//
static function FilterArray( aData, nFilterCol, cFilter )
local aFilter := {}
AEval( aData, { |a| If( a[ nFilterCol ] == cFilter, AAdd( aFilter, a ), nil ) } )
return aFilter
//----------------------------------------------------------------//
Function Crea_Array_listini()
Local alist_temp:={}
USE LISTINI ALIAS LI SHARE NEW VIA "DBFCDX"
INDEX ON NAME TAG "IDXLISTINI"
LI->(dbgotop())
DO While !LI->(eof())
AaDd(alist_temp,{ LI->NAME,LI->ID })
LI->(dbskip())
ENDDO
return alist_temp
//----------------------------------------------------------------//
Static Function Crea_Base(aListini)
Local atemp:={}
Local n := 1
Local nGiorni := 1
Local nPriceTemp:= 10
Local lIsLock := .t.
Local cId :=" "
Local cSector :=" "
USE SPIAGGIA ALIAS SP SHARE NEW VIA "DBFCDX"
INDEX ON id+settore TAG "IDXSETTORE"
SP->(ordSetFocus("IDXSETTORE")) //indicizzo su settori
SP->(dbgotop())
//Creo tariffe base secondo gli elementi che sono in archivio e per listino
Do while .not. SP->(eof())
IF !Empty(SP->SETTORE) .and. (sp->SETTORE!=cSector .or. sp->Id!=cId)
For k=1 to Len(aListini)
AaDd(atemp,{strzero(n,4),;
SP->id,;
SP->DESC,;
SP->SETTORE,;
nGiorni,;
nPriceTemp,;
lIslock,;
aListini[k][2] } )
n++
next
Endif
cSector := sp->SETTORE
cId := sp->Id
SP->(dbskip())
Enddo
return aTemp