// ProjBrow.prg
#INCLUDE "FIVEWIN.CH"
#include "xbrowse.ch"
*STATIC oWndFind
//------------------------
Func _ProjBrow( cMode,oWndMain )
Local oDlg,lOk1,cSay,oSay,cDefa
Local nYear,cFile,nStart
SET DELETED on
SET CENTURY on
SET 3DLOOK on
nYEAR := ( year( DATE() )-30 )
SET EPOCH to ( nYEAR )
// where .exe started from is default directory //
cFILE := GetModuleFileName( GetInstance() )
nSTART := RAT( "\", cFILE )
cDEFA := SUBSTR(cFILE,1,nSTART-1)
SET DEFA to ( cDEFA )
REQUEST DBFCDX
REQUEST DBFFPT
rddsetdefault( "DBFCDX" )
If empty( cMode )
cMode := "V"
Endif
LightGreyGrad()
lOK1 := .F.
DEFINE DIALOG oDlg RESOURCE "FILECHK" ;
TITLE "Please be patient"
cSAY := "Opening Tables"
REDEFINE SAY oSay var cSay ID 120 of oDLG UPDATE
oDLG:bStart := { || lOK1 := _OpenUm0( oDLG,oSAY,@cSAY ) }
ACTIVATE DIALOG oDLG CENTERED
oSay := NIL
cSay := NIL
IF lOK1 = .F.
Close Databases
RETURN(NIL)
ENDIF
// cMode
_ProjBrow1( "A")
CLose Databases
Return(.t.)
//----------------
Static Func _OpenUm0( oDlg, oSay,cSay )
Local cSql,oErr,dbf_stru,cDefa
cDefa := set(7)
If .not. file( cDefa+"\Owner.Dbf" )
Dbf_Stru := {}
Aadd( dbf_stru, { "Owner_Num", "N", 5, 0 } )
Aadd( dbf_stru, { "Owner", "C", 50,0 } )
dbCreate( cDefa+"\Owner.Dbf", dbf_Stru )
Select 1
Use ( cDefa+"\Owner.dbf") via "DBFCDX" EXCL
Append Blank
a->Owner_Num := 44
a->Owner := "Bamberg School District 1"
CLose Databases
ENdif
If .not. file( cDefa+"\Project.Dbf" )
Dbf_Stru := {}
Aadd( dbf_stru, { "Owner_Num", "N", 5, 0 } )
Aadd( dbf_stru, { "Project", "C", 55,0 } )
Aadd( dbf_stru, { "ProjectNum","N", 5, 0 } )
Aadd( dbf_stru, { "ProjMgr", "C", 20,0 } )
Aadd( dbf_stru, { "Status", "C", 1,0 } )
dbCreate( cDefa+"\Project.Dbf", dbf_Stru )
Select 1
Use ( cDefa+"\Project.dbf") via "DBFCDX" EXCL
Index on Owner_Num tag Owner_Num
Append Blank
a->Owner_Num := 44
a->Project := "Bamberg Middle and Bamberg High School Renovations"
a->ProjectNum := 307
a->ProjMgr := "Dale Collier"
a->Status := "1"
CLose Databases
ENdif
cSay := "Opening Ownwer Table"
oSay:ReFresh()
SysReFresh()
Select 1
Use ( cDefa+"\Owner.dbf") via "DBFCDX" EXCL
Go Top
cSay := "Opening Projects Table"
oSay:ReFresh()
SysReFresh()
Select 2
Use ( cDefa+"\Project.dbf") via "DBFCDX" EXCL
Set Order to Tag Owner_num
GoTo 0
oDlg:End()
Return(.t.)
//-------------------------------
FUNC _ProjBrow1( cMODE )
Local oCust,oLbx1,oLbx2,oLbx3
LOCAL SAYING,cDEFA,cSql,oErr,oRsSys
Local oFontB
LOCAL oIco,oCol,oCol1,cName,xTitle
LOCAL aPlan
Local lOk // valid close
Local oBUTT1 // main buttons
Local oBUTT2,oBUTT3,oBUTT4,oBUTT5 // owner buttons
Local oButt6,oButt7,oButt8,oButt9 // project buttons
Local oButt10,oButt11,oButt12,oButt13 // plan butrtons
aPlan := {}
oFontB := TFont():New("Ms Sans Serif",,-6,.F.,.T. ,,,,.F. )
lOk := .f.
aPlan := {}
aColumns := {}
AAdd( aPlan, { space(12),;
0.00,;
0.00,;
0.00,;
0.00,;
0.00,;
0.00,;
0.00,;
0.00,;
0.00,;
0.00,;
0} )
LightGreyGrad()
xTITLE := "Project Management Information"
DEFINE DIALOG oCust RESOURCE "PROJBROW" ;
Title xTitle
REDEFINE SAY oSay1 ID 143 OF oCust UPDATE // owner name
oSay1:SetFont( oFontB )
REDEFINE SAY oSay2 ID 145 OF oCust UPDATE // double click owner
oSay2:SetFont( oFontB )
REDEFINE SAY oSay3 ID 148 OF oCust UPDATE // project info
oSay3:SetFont( oFontB )
REDEFINE SAY oSay4 ID 144 OF oCust UPDATE // double click
oSay4:SetFont( oFontB )
// Owner Browse -------------------------------------------
REDEFINE xBROWSE oLBX1 ;
ALIAS "OWNER" ;
COLUMNS "OWNER" ;
COLSIZES 284 ;
HEADERS "Owner or Client" ;
ID 172 of oCust ;
AUTOCOLS LINES CELL
oLbx1:lFooter := .t.
oCol := oLbx1:aCols[ 1 ]
oCol:bFooter := { || Ltrim( Str( oLbx1:KeyNo() ) ) + " / " + LTrim( Str( oLbx1:KeyCount() ) ) }
oLbx1:bChange := { || oCol:RefreshFooter() }
oLbx1:lRecordSelector := .f.
_BrowColor( oLbx1 )
oLbx1:bLDblClick := { |nRow,nCol | _ProjSlct( oButt2,oButt3,oButt4,;
oButt5,oLbx2,oLbx3,@aPlan)}
// owner buttons -------------------------------------------------------------------------------------
REDEFINE BTNBMP oButt2 ID 120 of oCust ; // add
PROMPT "Add" CENTER 2007;
ACTION ( NIL )
REDEFINE BTNBMP oButt3 ID 121 of oCust ; // edit
PROMPT "Edit" CENTER 2007;
ACTION ( NIL )
REDEFINE BTNBMP oButt4 ID 122 of oCust ; // view
PROMPT "View" CENTER 2007;
ACTION ( NIL )
REDEFINE BTNBMP oButt5 ID 123 of oCust ; // del
PROMPT "Del" CENTER 2007;
ACTION ( NIL )
// projects ---------------------------------------------------------------------
REDEFINE xBROWSE oLBX2 ;
ALIAS "PROJECT" ;
COLUMNS "PROJECT", ;
"PROJMGR", ;
"STATUS" ;
COLSIZES 260,75,74 ;
HEADERS "Project", ;
"Project Mgr", ;
"Status" ;
ID 173 of oCust ;
AUTOCOLS LINES CELL
oLbx2:lFooter := .t.
oCol := oLbx2:aCols[ 1 ]
oCol:bFooter := { || Ltrim( Str( oLbx2:KeyNo() ) ) + " / " + LTrim( Str( oLbx2:KeyCount() ) ) }
oLbx2:bChange := { || oCol:RefreshFooter() }
oLbx2:lRecordSelector := .f.
_BrowColor( oLbx2 )
oLbx2:bLDblClick := { |nRow,nCol | _BuildPlan( oLbx3, @aPlan ),oLbx3:MakeTotals(),oLbx3:ReFresh(),oLbx3:SetFocus() }
// project buttons -------------------------------------------------------------------------------------
REDEFINE BTNBMP oButt6 ID 124 of oCust ; // add
PROMPT "Add" CENTER 2007;
ACTION ( NIL )
REDEFINE BTNBMP oButt7 ID 125 of oCust ; // edit
PROMPT "Edit" CENTER 2007;
ACTION ( NIL )
REDEFINE BTNBMP oButt8 ID 126 of oCust ; // view
PROMPT "View" CENTER 2007;
ACTION ( NIL )
REDEFINE BTNBMP oButt9 ID 127 of oCust ; // del
PROMPT "Del" CENTER 2007;
ACTION ( NIL )
// project plan ---------------------------
REDEFINE xBROWSE oLbx3 ;
ARRAY aPlan ;
HEADERS "Budget"+CRLF+"Item", ;
"Origional"+CRLF+"Budget", ;
"Budget"+CRLF+"Revision", ;
"Current"+CRLF+"Budget", ;
"Origional"+CRLF+"Contract", ;
"Contract"+CRLF+"Revisions", ;
"Current"+CRLF+"Committed", ;
"Pending"+CRLF+"Proposals", ;
"Potential"+CRLF+"Exposures", ;
"Potential"+CRLF+"Costs", ;
"Potential"+CRLF+"Project Costs" ;
COLSIZES 185,73,73,73,73,73,73,73,73,73,73 ; // 11
PICTURE "","@)999,999,999.99","@)999,999,999.99","@)999,999,999.99","@)999,999,999.99" ;
ID 174 of oCust ;
AUTOCOLS CELL LINES
oLbx3:lHScroll := .t. // turn on horiz scroll bar
oLbx3:aCols[12]:Hide() // hide last column used for row color
* oCol:bSumCondition := { |nValue, oCol| oCol:oLbx3:aRow[ 12 ] <> '2' }
* oCol:bSumCondition := { |nValue, oCol| oLbx3:aArrayData[ oLbx3:nArrayAt, 12 ] <> '2' }
oCol:bSumCondition := { |nValue, oCol| oCol:oLbx3:Potential:Value() <> '2' }
oLbx3:nStretchCol := 1
oLbx3:lFooter := .t.
oCol := oLbx3:aCols[ 1 ]
oCol:bFooter := { || Ltrim( Str( oLbx3:KeyNo() ) ) + " / " + LTrim( Str( oLbx3:KeyCount() ) ) }
oLbx3:bChange := { || oCol:RefreshFooter() }
oLbx3:nFooterTypes := AGGR_SUM
oLbx3:MakeTotals()
oLbx3:lRecordSelector := .f.
* msginfo( olbx3:aCols[12] )
* oLbx3:bClrStd := {|| { CLR_BLACK,;
* if( len(aPlan) = 0,CLR_WHITE,;
* if( oLbx3:aCols[12] = '1', RGB(179,203,204), CLR_WHITE )) } }
* msginfo( olbx3:aCols[12] )
* oLbx3:bClrStd := {|| { CLR_BLACK,;
* if( Len(aPlan) = 0,CLR_WHITE,;
* if( oLbx3:aCols[12] = '2', RGB(179,203,204), CLR_WHITE )) } }
* For i = 1 to LEN( oLbx3:aCols )
* oCol := oLbx3:aCols[ i ]
* oLbx3:aCols[ i ]:bClrStd := ChangeColor( oLbx3, i, oCol )
* Next
* _BrowColor( oLbx3 )
// plan buttons -------------------------------------------------------------------------------------
REDEFINE BTNBMP oButt10 ID 129 of oCust ; // add
PROMPT "Add" CENTER 2007;
ACTION ( NIL )
REDEFINE BTNBMP oButt11 ID 130 of oCust ; // edit
PROMPT "Edit" CENTER 2007;
ACTION ( NIL )
REDEFINE BTNBMP oButt12 ID 131 of oCust ; // view
PROMPT "View" CENTER 2007;
ACTION ( NIL )
REDEFINE BTNBMP oButt13 ID 132 of oCust ; // del
PROMPT "Del" CENTER 2007;
ACTION ( NIL )
// main buttons -------------------------------------------------------------------------------------
REDEFINE BTNBMP oButt1 ID 128 of oCust ; // Close and Save
RESOURCE "CANCEL", "DCANCEL", "DCANCEL" ;
PROMPT "Close" LEFT 2007;
ACTION ( oCust:END(), dbCloseAll() )
ACTIVATE DIALOG oCust ;
ON INIT ( oCust:Move(0,0),Asize( aPlan,0 ),oLbx3:ReFresh() ) ;
VALID(!GETKEYSTATE( 27 ))
RETURN( NIL )
//--------------------------
Static Func _ReSizeUm( oCust,oWndChild,oLbx1 )
oCust:SetSize( oWndChild:nWidth, oWndChild:nHeight, .t. ) // frame and dialog link
// dialog controls
oCust:bResized = { | nSizeType, nWidth, nHeight | ResizeControls( nSizeType, nWidth, nHeight, oCust ) }
Return(nil)
//-------------------------
Static Func ResizeControls( nSizeType, nWidth, nHeight, oCust )
*xbrowse(oCust:aControls)
// 185
if nSizeType = 0 //SIZE_MAXIMIZED //125 //60
oCust:aControls[ 15 ]:SetSize( nWidth - 60, nHeight - 300 ) //txbrowse
endif
Return(nil)
//---------------------------
Static Func ChangeColor( oLbx3,i,oCol ) //
Local nColumn,nRow,cText
msginfo( i )
cText := oLbx3:aCols[ i ]:Value
msginfo( cText )
If i = 12
msginfo(oLbx3:aCols[ i ]:Value )
Else
Return {|| { CLR_BLACK, CLR_WHITE } }
ENdif
*Return {|| { ColorCell( oLbxA:aCols[ i ]:Value ), ColorCell( oLbxA:aCols[ i ]:Value ) } }
Return {|| { CLR_BLACK, ColorCell( oLbx3:aCols[ i ]:Value, oCol ) } }
//-------------------
Static Func ColorCell( cText,oCol )
LOCAL cColor,nLen,nColor
Local oBrw
msginfo( cText )
nColor := RGB(255, 255, 128)
Return(nCOlor)
oBrw := oCol:oBrw
If empty(cText) .or. cText = " "
nColor := GetSysColor( 5 )
Return(nColor)
Endif
cText := alltrim( cText )
// get the last byte
// cColor can only be 1-9
nLen := len( cText )
cColor := substr(cText,nLen,1)
DO CASE
CASE cColor = "1" // yellow
nColor := RGB(255, 255, 128)
CASE cColor = "7" // light Blue
nColor := RGB(172,206,215)
CASE cColor = "9" // sand
nColor := RGB(221,218,185)
*Msginfo( oBrw:nArrayAt )
*msginfo( oCol:nArrayCol )
*FillRect( hDC, { 100, 0, 150, 641 }, oBrCyan:hBrush )
*SysWait(2)
CASE cColor = "8" // maroon
nColor := RGB(171,129,151)
CASE cColor = "5" // Red
nColor := RGB(240, 0, 0)
CASE cColor = "6" // light green
nColor := RGB(210,235,216)
CASE cColor = "3" // blue
nColor := RGB(0,100,200)
CASE cColor = "4" // orange
nColor := RGB(255,172,89)
CASE cColor = "2" // Red
nColor := RGB(240, 0, 0)
OTHERWISE
nColor := GetSysColor( 5 )
ENDCASE
RETURN( nColor )
//----------------------------
Static Func _BuildPlan( oLbx3, aPlan )
Local oDlg,cSay,oSay,lOk1,i,oCol
DEFINE DIALOG oDlg ;
FROM 5, 8 to 10, 75 ;
TITLE "Building Plan Information ...... Please be patient" ;
STYLE nOr( WS_POPUP,WS_CAPTION,WS_THICKFRAME )
cSAY := "Building Plan "
@ 1,13 SAY oSAY VAR cSAY of oDLG //COLOR "N/W"
oDLG:bStart := { || _BuildUM( oDLG, @oSAY, @cSAY,@aPlan,oLbx3 )}
ACTIVATE DIALOG oDLG CENTERED
*For i = 1 to LEN( oLbx3:aCols )
* oCol := oLbx3:aCols[ i ]
* oLbx3:aCols[ i ]:bClrStd := ChangeColor( oLbx3, i, oCol )
*Next
*oLbx3:ReFresh()
oLbx3:MakeTotals()
oLbx3:ReFresh()
oLbx3:SetFocus()
Return(nil)
//---------------------------
Static Func _BuildUm(oDlg,oSay,cSay,aPlan,oLbx3 )
Local oRsBitem,oRsBrev,cSql,oErr,nProj,nTCurBud,cBRNumber,nTAmtOC,nAmtR,nCurrent
Local cBINumber
Local oRsCitem,nAmtC
Local aBitem,cBCat,cCostCat,cCat,i,cBudItem
Local oCol,cProj
Local oRsCopr, cCINumber,nAmtCr
nProj := b->ProjectNum
nTCurBud := 0.00 // total current budget counter
nTAmtOC := 0.00 // total origional contract counter
nAmtR := 0.00 // budget revision item
nCurrent := 0.00 // current budget item
nAmtC := 0.00 // origional contract item
nAmtCr := 0.00 // contract rev
aBitem := {}
// resize the array
Asize( aPlan,0 )
// create the Bitem list and sort accordingly
AAdd( aBitem, { "Asbestos Abatment ", "307.21", "1", 0.00 } )
AAdd( aBitem, { "B-E High School HVAC Controls ", "307.20", "1", 0.00 } )
AAdd( aBitem, { "B-E High School School Renovations ", "307.19", "1", 7000000.00 } )
AAdd( aBitem, { "B-E Middle School Renovations ", "307.10", "1", 3000000.00 } )
AAdd( aBitem, { "Campus Communications ", "306.6", "1", 0.00 } )
AAdd( aBitem, { "DHEC Required BEMS Asbestos Cleanup", "307.22", "1", 0.00 } )
AAdd( aBitem, { "End of Line ", "307.17", "1", 0.00 } )
AAdd( aBitem, { "Impact Fees ", "307.13", "1", 0.00 } )
AAdd( aBitem, { "Infrastructure ", "307.16", "1", 0.00 } )
AAdd( aBitem, { "Moving Costs ", "307.14", "1", 0.00 } )
AAdd( aBitem, { "Owner Controlled C-Funds ", "307.12", "1", 75000.00 } )
AAdd( aBitem, { "Security Survellance ", "307.18", "1", 0.00 } )
AAdd( aBitem, { "Advertising ", "307.1", "3", 50000.00 } )
AAdd( aBitem, { "Architect Fee ", "307.2", "3", 775000.00 } )
AAdd( aBitem, { "CM Fee ", "307.3", "3", 211434.00 } )
AAdd( aBitem, { "FF and E ", "307.15", "3", 250000.00 } )
AAdd( aBitem, { "Geotechnical Testing ", "307.5", "3", 0.00 } )
AAdd( aBitem, { "IBC Chapter 1 and 17 Inspections ", "307.4", "3", 0.00 } )
AAdd( aBitem, { "Legal Counsulting ", "307.7", "3", 0.00 } )
AAdd( aBitem, { "Printing ", "307.8", "3", 0.00 } )
AAdd( aBitem, { "Survey ", "307.9", "3", 0.00 } )
AAdd( aBitem, { "Contingency ", "307.11", "7", 425016.00 } )
cProj := ltrim(str(nProj))
// add direct and indirect blank records
AAdd( aBitem, { "Direct Cost SubTotal", cProj+".998", "2", 0.10 } )
AAdd( aBitem, { "Indirect Cost Subtotal", cProj+".999", "4", 0.00 } )
nTCurBud := 0.00
nTAmtRev := 0.00
aSort( aBitem,,, {|x,y| (x[3] + x[1]) < (y[3] + y[1]) } )
*xbrowse(aBitem )
*xbrowse( aBitem )
For i = 1 to len(aBitem)
cBudItem := upper(aBitem[i][1]) // budget item
cCat := aBitem[i][3] // catagory
cBINumber := aBitem [i][2] // valtype C
If empty(cBINumber)
cBINumber := "999999999999999"
Endif
nAmtr := 0.00
nAmtc := 0.00
nCurrent := 0.00
AAdd( aPlan, { aBitem[i][1], ; // budget item description
aBitem[i][4] ,; // Origional Budget
nAmtR,; // Budget Revision
nCurrent,; // current budget
nAmtC,; // origional contract
0.00,; // contract revisions
0.00,; // current committed
0.00,; // pending proposals
0.00,; // potential exposures
0.00,; // potential costs
0.00,; // potential proj costs
aBitem[i][3] }) // 1 = direct cost, // used to color row
// 2 = indirect cost,
// 3 = unk
// 4 = cont
Next
oDlg:ENd()
*For i = 1 to LEN( oLbx3:aCols )
* oCol := oLbx3:aCols[ i ]
* oLbx3:aCols[ i ]:bClrStd := ChangeColor( oLbx3, i, oCol )
*Next
*oLbx3:ReFresh()
Return(.t.)
//------------------------------
Static Func _ProjSlct( oButt2,oButt3,oButt4,;
oButt5,oLbx2,oLbx3,aPlan)
Local nOwner_Number,Saying,cOwner
Select 1
If Eof()
Saying := "Sorry .. you can not view a Project unless you have an Owner First"
MsgInfo( Saying )
Return(.f.)
Endif
// resize the array
Asize( aPlan,0 )
oLbx3:ReFresh()
oLbx3:MakeTotals()
cOwner := a->Owner
If empty(cOwner)
cOwner := "Unknown"
Endif
cOwner := alltrim( cOwner )
select 1
nOwner_Number := a->Owner_Num
If empty(nOwner_number)
nOwner_Number := 0
Saying := "Sorry .. no Projects Exist for Owner "+chr(10)
Saying += " "+chr(10)
Saying += cOwner
Msginfo( Saying )
Select 2
GoTo 0
oLbx2:ReFresh()
Return(.f.)
ENdif
Select 2
Set Order to Tag Owner_num
Seek nOwner_Number
If .not. Found()
Select 2
GoTo 0
ENdif
oLbx2:ReFresh()
Return(.t.)
//------------------
Static Func LightGreyGrad()
SetDlgGradient( { { .50, nRGB( 216, 216, 216 ), nRGB( 255, 255, 255 ) } } )
Return(nil)
//----------------------
Static Func _BrowColor( oLbx )
// foreground // background
local aGradBarSelFocus := {{1, RGB(0,128,255) , RGB(0,128,255) }} // in focus
local aGradBarSel := {{1, RGB(255,255,255), RGB(192,192,192) }} // not in focus 192
WITH OBJECT oLbx
:bClrSel := {|| { CLR_BLACK, aGradBarSel } } // not in focus
:bClrSelFocus := {|| { CLR_WHITE, aGradBarSelFocus } } // in focus
END
Return(nil)
// end ProjBrow