Embed
Email

_ GLOBAL =

Document Sample

Shared by: cuiliqing
Categories
Tags
Stats
views:
1
posted:
10/31/2011
language:
English
pages:
11
{ GLOBAL =

Dim CurrentSelection As String

Dim ReqNumber,ReqPurpose As String

Dim QueryStr As String

Dim lErr As Long

Dim strModelIds As String

Dim strModelId As String

Dim lReqId As Long, lModelId As Long

Dim hrReqLine As Long, hrReq As Long

Dim seStatus As Long

Dim lLine As Long

}

NAME = "Wizard"

TITLE = "Assets assigned to: " & [Firstname] & " " & [Name]

VERSION = "4311"

{ PAGE pgUser

{ ONENTER =

retval={USERS.SORT(1,1)}

}

TITLE = "Choose the persons to buyout"

{ DBLISTBOX Users

COLNAME = "Name|FirstName|Location"

COLWIDTH = "25|30|45"

DBLCLICK = 1

LABEL = "Persons to buyout"

MANDATORY = 1

MULTISEL = 1

TABLE = "amEmplDept"

TREE = 0

VALUE = "-1"

VISIBLE = 1

}

{ COMMANDBUTTON cbADD

CAPTION = "Add"

{ CLICK =

Dim strList As String

Dim strValues As String

Dim strFeatures As String

Dim strStrippedFeatures As String

Dim strLine As String

Dim strSep As String

RetVal=0

strList = {lbModelSelect.VALUES}

if not isempty({pgUser.Users}) AND not isnull({pgUser.Users}) Then

if lLine > 0 Then strList = strList & ","

lLine = lLine + CountValues({Users}, ",", "\")

strValues=amDbGetListEx("SELECT Name,FirstName,Location FROM

amEmplDept WHERE lempldeptId IN (" & {pgUser.Users} & ")" , "|", ",", "=")

RetVal=amSetProperty("lbModelSelect.VALUES", strList & strValues)

End if

}

WIDTH = 3000

YOFFSET = 0

}

{ CHECKBOX ALLLINES

CAPTION = "Take all lines into account"

READONLY = 0

VALUE = 0

}

{ LISTBOX lbModelSelect

COLNAME = AmGetFieldLabelFromName("amEmplDept", "Name") & "|" &

AmGetFieldLabelFromName("amEmplDept", "FirstName") & "|" &

AmGetFieldLabelFromName("amEmplDept", "Location")

COLWIDTH = ""

EDITABLE = "0|0|0"

LABEL = "Selected Employees"

MULTISEL = 1

VALUE = "-1"

VALUES = ""

}

{ COMMANDBUTTON cbDEL

CAPTION = "Remove"

{ CLICK =

if {lbModelSelect.VALUE} -1 AND lLine > 0 Then

lErr = amSetProperty("lbModelSelect.VALUES",

removeRows({lbModelSelect.VALUES} , {lbModelSelect.VALUE}))

lLine = lLine - 1

End if

}

LABEL = ""

WIDTH = 3000

}

{ TRANSITION trPersonToAssets

TO = "pgAssets"

}

}



{ PAGE pgAssets

{ LABEL lblInstructions

CAPTION = "Please select the Asset(s) that you would like to calculate a buyout cost

on."

}

{ DBLISTBOX dblbAssets

COLNAME = "Model|Model.Name|Asset.AcquContract.Ref|Asset.mMarketVal"

FILTER = "Asset.seAcquMethod = 2 AND seAssignment = 0 AND user.lEmplDeptId

IN (" & {pgUser.lbModelSelect} & ")"

LABEL = "Assets"

MANDATORY = 1

MULTISEL = 1

TABLE = "amPortfolio"

TREE = 1

VALUE = "-1"

}

{ TRANSITION trToDamagedLost

TO = "pgDamagedLost"

}

}



{ PAGE pgDamagedLost

TITLE = "Assets not being returned"

{ CHECKBOX cbReturnAll

CAPTION = "Check here if all assets will be returned."

LABEL = "Return All"

VALUE = 0

}

{ DBLISTBOX dblbDamagedLost

COLNAME = "Model|Model.Name|Asset.AcquContract.Ref|Asset.mMarketVal"

{ ENABLED =

If {cbReturnAll} = 1 Then

RetVal = FALSE

Else

RetVal = TRUE

END IF

}

FILTER = "lPortfolioItemId in (" & {pgAssets.dblbAssets.Value} & ")"

LABEL = "Please select any assets that have been damaged, lost or stolen or otherwise

will not be returned to the leasing company at the end of the lease."

MULTISEL = 1

TABLE = "amPortfolio"

TREE = 0

VALUE = "-1"

}

{ TRANSITION trToEmail

TO = "pgEmail"

}

}



{ PAGE pgEmail

TITLE = "Send Mail to...."

{ DBLISTBOX dblbEmailTo

COLNAME = "Name|Firstname|Email"

FILTER = "bDepartment = 0"

LABEL = "If you would like to email the results of the calculation to someone, please

select an employee below for the 'to' field:"

TABLE = "amEmplDept"

TREE = 0

VALUE = "-1"

}

{ DBLISTBOX dblbEmailCC

COLNAME = "Name|Firstname|Email"

FILTER = "bDepartment = 0"

LABEL = "If you would like to CC the results of the calculation to someone, please

select an employee below for the 'CC' field:"

TABLE = "amEmplDept"

TREE = 0

VALUE = "-1"

}

{ TRANSITION trToDisplayBuyout

TO = "pgDisplayBuyout"

}

}



{ PAGE pgDisplayBuyout

{ STRING strEmailTo

VALUE = amDbGetString("Select Email from amEmplDept where lEmplDeptId = "

& {pgEmail.dblbEmailTo})

}

{ STRING strSMTPEmailTo

{ VALUE =

If len({strEmailTo}) = 0 THEN

RetVal = ""

else

RetVal = "SMTP:" & {strEmailTo}

END IF

}

}

{ STRING strEmailCC

VALUE = amDbGetString("Select Email from amEmplDept where lEmplDeptId = "

& {pgEmail.dblbEmailCC})

}

{ STRING strSMTPEmailCC

{ VALUE =

If len({strEmailCC}) = 0 THEN

RetVal = ""

else

RetVal = "SMTP:" & {strEmailCC}

END IF

}

}

{ STRING strTester

{ VALUE =

Dim strAssets as String

Dim strThisAsset as String

Dim thisListPrice as Double

Dim dbleSecTilRetire as Double

Dim dToday as Date

Dim dRetire as Date

Dim intQRemain as Integer

Dim strDecimal as String

Dim strQRemain as String

Dim intRounder as Integer

Dim strTest as String

Dim thislrf as Double

Dim thisLoc as String

Dim thisTaxRate as Double

Dim totalBuyout as Double

Dim thisBuyout as Double

Dim thisAssetTag as String

Dim thisProduct as String

Dim strWizardRunner as String

Dim crlf as String

Dim strBuyouts as String

Dim isBuyout

Dim thisNature as String

Dim thisSerial as String



crlf = chr(13) & chr (10)



strWizardRunner = [CurrentUser.Firstname] & " " & [CurrentUser.Name]



dToday = Date()



strAssets = {pgAssets.dblbAssets}

strBuyouts = {pgDamagedLost.dblbDamagedLost}



totalBuyout = 0



strTest = "The buyout quote you requested for " & [firstname] & " " & [name] & " is

as follows:" & crlf & crlf

strTest = strTest & "The buyout cost represents the remaining rent on each piece of

equipment under the assumption that all equipment will be returned at the end of the

lease. "

strTest = strTest & "If a particular piece of equipment has been reported lost, stolen,

damaged or otherwise will not be returned "

strTest = strTest & "at the end of the lease, a fair market value for the item has been

added to the cost for that item. "

strTest = strTest & "If there are any of these items, they will be indicated by '(No

equipment to return)' at the end of the line." & crlf & crlf



do While instr(1,strAssets,",") > 0

intQRemain = 0

intRounder = 0

thisLoc = ""

thisTaxRate = 0



strThisAsset = leftpart(strAssets,",",1)

dRetire = amDbGetDate("Select Asset.dSchedRetire from amPortfolio where

lPortfolioItemId = " & cdbl(strThisAsset))



strQRemain = cstr(amDateDiff(dRetire,dToday)/7889231.4984)



intQRemain = CINT(LeftPart(strQRemain,".",0))

intRounder = CINT(left(RightPartFromLeft(strQRemain,".",1),1))





thisListPrice = amDbGetDouble("Select Asset.mMarketVal from amPortfolio where

lPortfolioItemId = " & cdbl(strThisAsset))

thislrf = amDbGetDouble("Select Asset.AcquContract.pDefLrf from amPortfolio

where lPortfolioItemId = " & cdbl(strThisAsset))

thisLoc = ucase(amDbGetString("Select Location.field1 from amPortfolio where

lPortfolioItemId = " & cdbl(strThisAsset)))

thisProduct = amDbGetString("Select Model.Name from amPortfolio where

lPortfolioItemId = " & cdbl(strThisAsset))



if {pgDamagedLost.cbReturnAll} = 0 THEN

isBuyout = TRUE

Else

isBuyout = FALSE

End If



select case thisLoc

Case "LOU"

thisTaxRate = 1.06

Case "DAL"

thisTaxRate = 1.0825

Case "IRV"

thisTaxRate = 1.0775

Case Else

thisTaxRate = 1.08

END SELECT







thisNature = amDbGetString("Select Model.Nature.Name from amPortfolio where

lPortfolioItemId = " & cdbl(strThisAsset))

thisBuyout = intQRemain*thisListPrice*thislrf*thisTaxRate



if isBuyout = TRUE THEN

thisBuyout = thisBuyout + thisListPrice*.25*thisTaxRate

END IF



totalBuyout = totalBuyout + thisBuyout



intRounder = CINT(right(left(RightPart(thisBuyout,".",1),3),1))

thisBuyout = cdbl(cstr(LeftPart(thisBuyout,".",0)) & "." &

cstr(Left(RightPartFromLeft(thisBuyout,".",1),2)))



if intRounder > 4 THEN

thisBuyout = thisBuyout + .01

End If



if thisNature = "Computer" THEN

thisSerial = amDbGetString("Select Asset.SerialNo from amPortfolio where

lPortfolioItemId = " & cdbl(strThisAsset))

strTest = strTest & thisProduct & " (Serial#: " & thisSerial & ") has " &

intQRemain & " quarters remaining on lease and a remaining rent (plus buyout cost if

applicable) of: $" & thisBuyout

else

strTest = strTest & thisProduct & " has " & intQRemain & " quarters remaining on

lease and a remaining rent (plus buyout cost if applicable) of: $" & thisBuyout

END IF



if isBuyout = TRUE THEN

strTest = strTest & " (No equipment to return)" & crlf & crlf

else

strTest = strTest & crlf & crlf

END IF



strAssets = RightPartFromLeft(strAssets,",",1)

LOOP

strThisAsset = strAssets



if {pgDamagedLost.cbReturnAll} = 0 THEN

isBuyout = TRUE

Else

isBuyout = FALSE

End If



dRetire = amDbGetDate("Select Asset.dSchedRetire from amPortfolio where

lPortfolioItemId = " & cdbl(strThisAsset))



strQRemain = cstr(amDateDiff(dRetire,dToday)/7889231.4984)



intQRemain = CINT(LeftPart(strQRemain,".",0))

intRounder = CINT(left(RightPartFromLeft(strQRemain,".",1),1))





thisListPrice = amDbGetDouble("Select Asset.mMarketVal from amPortfolio where

lPortfolioItemId = " & cdbl(strThisAsset))

thislrf = amDbGetDouble("Select Asset.AcquContract.pDefLrf from amPortfolio

where lPortfolioItemId = " & cdbl(strThisAsset))

thisLoc = ucase(amDbGetString("Select Location.field1 from amPortfolio where

lPortfolioItemId = " & cdbl(strThisAsset)))

thisProduct = amDbGetString("Select Model.Name from amPortfolio where

lPortfolioItemId = " & cdbl(strThisAsset))

thisNature = amDbGetString("Select Model.Nature.Name from amPortfolio where

lPortfolioItemId = " & cdbl(strThisAsset))



select case thisLoc

Case "LOU"

thisTaxRate = 1.06

Case "DAL"

thisTaxRate = 1.0825

Case "IRV"

thisTaxRate = 1.0775

Case Else

thisTaxRate = 1.08

END SELECT





thisBuyout = thisListPrice*thislrf*thisTaxRate*intQRemain





if isBuyout = TRUE THEN

thisBuyout = thisBuyout + thisListPrice*.25*thisTaxRate

END IF

intRounder = CINT(right(left(RightPart(thisBuyout,".",1),3),1))

thisBuyout = cdbl(cstr(LeftPart(thisBuyout,".",0)) & "." &

cstr(Left(RightPartFromLeft(thisBuyout,".",1),2)))



if intRounder > 4 THEN

thisBuyout = thisBuyout + .01

End If





if thisNature = "Computer" THEN

thisSerial = amDbGetString("Select Asset.SerialNo from amPortfolio where

lPortfolioItemId = " & cdbl(strThisAsset))

strTest = strTest & thisProduct & " (Serial#: " & thisSerial & ") has " & intQRemain

& " quarters remaining on lease and a remaining rent (plus buyout cost if applicable) of:

$" & thisBuyout

else

strTest = strTest & thisProduct & " has " & intQRemain & " quarters remaining on

lease and a remaining rent (plus buyout cost if applicable) of: $" & thisBuyout

END IF



if isBuyout = TRUE THEN

strTest = strTest & " (No Equipment to return)" & crlf & crlf

else

strTest = strTest & crlf & crlf

END IF



totalBuyout = totalBuyout + thisBuyout



intRounder = CINT(right(left(RightPart(totalBuyout,".",1),3),1))

totalBuyout = cdbl(cstr(LeftPart(totalBuyout,".",0)) & "." &

cstr(Left(RightPartFromLeft(totalBuyout,".",1),2)))



if intRounder > 4 THEN

totalBuyout = totalBuyout + .01

End If



strTest = strTest & "**** The total cost for all listed items is: $" & totalBuyout & "

****" & crlf & crlf



strTest = strTest & "Thank you," & crlf





strTest = strTest & strWizardRunner



RetVal = strTest

}

}

{ LABEL lblEmail

CAPTION = "Email To: " & {strEmailTo} & ""

}

{ LABEL lblEmailCC

CAPTION = "Email CC: " & {strEmailCC} & ""

}

{ TEXTBOX tbEmail

LABEL = "Proposed Email"

MANDATORY = 1

MULTILINE = 15

VALUE = {strTester}

}

{ OPTIONBUTTONS obSendMail

MANDATORY = 1

VALUE = ""

VALUES = "Don't Send Email,Send Email"

}

}



{ FINISH FINISH

{ DO =

Dim Err

On error goto ErrorHandler



if {pgDisplayBuyout.obSendMail} = 2 AND len({pgDisplayBuyout.strEmailTo}) > 0

THEN

Dim Subject as String

Dim strTo as String

Dim strCC as String



strTo = {pgDisplayBuyout.strSMTPEmailTo}

strCC = {pgDisplayBuyout.strSMTPEmailCC}

AmLog("Emailing: " & strTo)

Err = AmProgress(50)

AmLog("Copying: " & strCC)

Err = AmProgress(100)



Subject = "Your request for a Buyout Quote"



Err =

AmActionMail(strTo,strCC,"SMTP:Janice.Eckerle@yum.com",Subject,{pgDisplayBuyo

ut.tbEmail},1,0,"","",0)

else

AmLog("Wizard completed. No email sent.")

Err = AmProgress(100)

END IF



RetVal = 0

Exit Function



ErrorHandler:

On Error Goto 0

Err = AmLog(AmLastError() & " - " & AmLastErrorMsg(), LOG_ERROR)

Err = AmLog(FormatResString("The Email has not been sent. Please check email

addresses and try again.", "") , LOG_ERROR)

RetVal = 1

Exit Function

}

SUMMARY = 1

}



Related docs
Other docs by cuiliqing
7 Recipes from Joe A.
Views: 0  |  Downloads: 0
Re-installingXPMode
Views: 0  |  Downloads: 0
telefonica_en
Views: 0  |  Downloads: 0
3220 Chap 6 demos
Views: 0  |  Downloads: 0
chap history.docx
Views: 1  |  Downloads: 0
Subcontractor Bid Form - The Fountains
Views: 0  |  Downloads: 0
English
Views: 0  |  Downloads: 0
DESIGNER'S SCHEDULE USE
Views: 0  |  Downloads: 0
Security Service Providers
Views: 44  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!