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.

Create Copies of Database for use with ArcView

A customer wanted to know how to access ZonePro databases from ArcView. I explained how ArcView chokes on Notes fields and how the ZP Copy program can be used to make copies of the databases minus the fields that ArcView can't handle. The ZP Copy program is really just another way of running scripts and you can do the same thing directly within ZonePro. By way of a demonstration, I wrote a script that runs from the Script button on the Main Screen that makes a copy of the Property database minus the Notes fields. You can then link ArcView to the "property_copy" database. This script uses "Base" as the Module, "MainScreen" as the Screen, and "Right" as the Action.

if file("property.dbf")
use property in 0
select property
copy to property_copy fields except note* fox2x
wait window "Copy Made" nowait
use in property

Note that this script only works with ZP 32.

Link Photos for Contractor Database

The City of Whiting wanted to know if they could use the Photo Module to attach image files to records in the Contractor Screen. While that is not possible, I did devise a script that gives some of the same functionality. This script looks in a designated folder to see if there is a subfolder that matches the name of the contractor company. If it finds such a folder it launches the folder in Windows Explorer. The user can then easily see the contents of the folder be they image files, Word documents, or whatever. Using the Windows thumbnail option with such folders makes them even more informative. While this script uses the Company field as the folder name, almost any field in the contractor database could be used as the matching criteria. This script works well with one of the
Script Button options such as "Left" or "Right". It's worth noting that this script would work just as well in the Property Screen as a poor man's substitute for Photo Module. This script uses the "Contractor" Module, the "Contractor" Screen and the "Left" Action.

myfolder = "c:\photos\" + trim(company)
if directory(myfolder)
shellexecute(0,"open",myfolder,"","",1)
else
wait window "Cannot Find Folder" nowait
endif

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.

Set A Default Permit Type in Other Permits

In Copley Township they use the Other Permits database to track culvert deposit fees. Since it is the only thing they track in that database they wanted an easy way to fill in the Type field consistently every time they add a new record. This script uses "Misc Fee" as the Module, "Other" as the Screen and "Add" as the Action:

replace other.type with "CULVERT DEPOSIT"

You can use this approach to create default values for almost any fields in any database.

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.