Showing posts with label alert. Show all posts
Showing posts with label alert. Show all posts

1/25/2011

Adding Alerts After Completed Inspections

Today I had a customer who wanted to add an alert message to their system after certain types of inspections were completed. This script checks after each Save to see if the Last Inspect date is filled and if the inspection item is a "Foundation". If so it displays a message. This script uses "Building" for the Module, "Buildinsp" for the Screen, and "Save" for the Action:

 if  not empty(last_insp) and detail = "FOUNDATION"
= messagebox("Check for As Built",64,"Alert")
endif

4/29/2010

Setting Dual Deadlines for Expire Dates

I just had a customer ask about another Expire Date scenario. They don't have sliding Expire Dates but they have two deadlines. All permits expire in six months if construction is not started, but once started they have two years to finish. To keep track of this scenario you can use the same tutorials that go with the sliding Expire Dates with just some minor modifications to the initial script. Basically you set up the initial six month expiration deadline by setting Expire Days to 183 for each permit type in Maintenance. Then you only need a script to make the switch to the two year deadline. This is done with a script that uses "Building" as the Module, "Building" as the Screen, and "Close" as the Action.

myanswer = 0
mycode = id_code
select max(last_insp) from detail1;
where detail1.id_code = mycode into array mydate
mylast = mydate(1)
if not empty(mylast) and mylast > (cert_date)
myanswer = messagebox("New expire should be "+dtoc(cert_date +730);
+chr(13)+"Do you want to fix it?",68,"New Expiration Needed")
endif
use in detail1
if myanswer = 6
proceedwithclose = .F.
replace exp_date with cert_date+730
buildscreen.isediting = .T.
buildscreen.refresh
endif

4/15/2010

Sliding Expiration Dates

Bradford County wants to institute a policy of always setting the Expire Date six months out from the last completed inspection for a building permit. The idea being that this would make it easy to run a report at any time using the Expire Date to find out which permits were in danger of expiring because of no activity in six months. The script below was designed for the "Close" button option of the Building database. It checks to find the most recent Last Inspection date in the Inspection Details database and then compares that with the current Expire Date. If the gap is less than six months it displays a message saying that the Expire Date should be changed and lists the date it should be changed too. This script uses "Building" as the Module, "Building" as the Screen, and "Close" as the Action.

myanswer = 0
mycode = id_code
select max(last_insp) from detail1;
where detail1.id_code = mycode into array mydate
mylast = mydate(1)
if not empty(mylast) and mylast > (exp_date - 183)
myanswer = messagebox("Last inspection was "+dtoc(mylast);
+chr(13)+"New expire should be "+dtoc(mylast +183);
+chr(13)+"Do you want to fix it?",68,"New Expiration Needed")
endif
use in detail1
if myanswer = 6
proceedwithclose = .F.
replace exp_date with mylast+183
buildscreen.isediting = .T.
buildscreen.refresh
endif

There are Sliding Expire Date tutorials in the Tutorial section of our web site for both ZP 32 and ZP SQL. These tutorials cover this topic at much greater length.

Forcing a Field Value Entry

In the Town of Swansboro they want to keep track of both a calculated job cost and the estimated job cost for any building permits. The calculated job cost is used to derive the permit fee and is stored in the Job Cost field. The estimated job cost is provided by the applicant and is stored in the User5 field. Because the estimated job cost is stored on the extra tab, they want to make sure they don't forget to enter it. This script won't allow you to save the record is that field is blank. The script uses "Building" as the Module, "Building" as the Screen and "Save" as the Action:

 if empty(build1.user5)
= messagebox("Estimated Job Cost field is empty!", 16, "Missing Info")
proceedwithsave = .F. 
endif

Notice that the third line makes use of a special script variable "proceedwithsave" to prevent the Save operation from continuing. If you wanted to give a warning but still allow the Save you could emit that line.

Permit Prerequisites Alerts

In the Town of Montreat they have a special consideration whenever they issue a permit to a property with more than one acre of land. They wanted an alert to indicate that a Storm Water & Erosion Control permit was required if the lot being disturbed was more than an acre. This script was added to the "Building" Module, for the "Building" Screen, using "Add" as the Action:

if property.acres > 1
= messagebox("May require Storm Water Permit!", 16, "Large Lot")
endif

Violation Warning for Owners

At Huber Heights they have a particular landlord that wants to be notified immediately whenever one of his properties has a violation. We created a script that displays a message whenever that owner's name is involved. This script uses "Zoning" as the Module, "Violations" as the Screen and "Add" as the Action which means it will run when you click on the User Script Button in the Building Screen.

if property.own_lname = "PARK REALTY"
= messagebox("Call Bob Watson at Park Realty about this!", 16, "Notify")
endif

To use this scrip in ZP SQL I would change it slightly:
 
if propnames.own_lname = "PARK REALTY"
= messagebox("Call Bob Watson at Park Realty about this!", 16, "Notify")
endif

This script works fine if you have only a few such landlords to track, but would become unwieldy quickly. Another approach would be to key off a value in the Property database that you fill in to indicate you want a message displayed. You could use the USER4 field for example and the value "NOTIFY" to trigger the script. Your script would then look like this for both ZP 32 and ZP SQL:

if property.user4 = "NOTIFY"
= messagebox("Call owner about this!", 16, "Notify")
endif

This option is really just a variation of the built-in Alert Message feature.