Showing posts with label building. Show all posts
Showing posts with label building. Show all posts

1/19/2015

Referecing Zoning District Setbacks From Any Screen (ZPSQL)

From the Property Screen you can easily reference the minimum setbacks defined for the assigned Zoning District by clicking on the "Zoning" label to display the Zoning District Maintenance Screen. This option may be even more useful on permit screens where you need to compare the desired setbacks of a project with those allowed. This script uses the Building Screen as an example but the script will work for almost any screen. I'm using the right-click option on the Script button but that is easily changed too. To implement the script start in User Defined Scripts Screen using "Building" as the Module, "Building" as the Screen and "Right" as the Action. Click the New button and then paste in the script below:

myAlias = alias()
 if not empty(property.zoning)
myCommand = [do zcodes_link in maintsql.app with '] + property.zoning +[']
&myCommand
endif

select (myAlias)

Now if you go to any Building Screen and right-click on the Script button the Zoning District Maintenance Screen will pop up showing the minimum setbacks allowed for that property.




3/15/2012

Forcing Final Date Fill Ins (ZP SQL)

A customer recently asked if there was a way to force the filling in of the Final Date field after a "FINAL" inspection was completed in the Building Inspection Details Screen. This script does just that assuming you have an inspection type called "FINAL" and that your result value is "APPROVED."  If those conditions are met and the Final Date field is empty in the Building Screen, the script will fill in today's date and put you in Edit Mode in the Building Screen after you exit the Inspection Details Screen. This script uses "Building" for the Module, "Buildinsp" for the Screen, and "Save" for the Action:

if detail1.detail = "FINAL" and detail1.iresult = "APPROVED" and ISNULL(build1.occ_date)
= messagebox("Be sure to check Final Date in Building Screen",64,"Alert")
CURSORSETPROP('Buffering',4,'build1')
replace build1.occ_date with date()
buildscreen.isediting = .T.
endif

5/19/2011

Set New Defaults for Max Rows in Reports (ZP SQL)

A customer asked me today if there was a way to set a new default value for the Max Rows field on report screens. The Max Rows value determines the maximum number of records pulled by a SQL query when running a report. It defaults to 100 records which is sufficient for most reports but in their case was not enough for the Building Combo Reports screen. This script sets the value to zero for that screen which removes the restriction on the number of rows a query can pull. The script uses "Building" for the Module, "BldCombo" for the Screen, and "Screen" for the Action.

 rep_combo.max_rows.value = 0

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

1/14/2011

Who Scheduled That?

Had a customer ask if there was a way they could keep track of who scheduled a particular Building Inspection and when. I devised a script that checks to see when the Next Inspection date changes and then replaces the Last Time field with the current users initials and the month and day. This script uses "Building" for the Module, "Buildinsp" for the Screen, and "Save" for the Action:

if insp_date <> oldval("insp_date")
replace last_time with trim(zonepro.owner)+left(dtoc(date()),5)
endif

NOTES
- It is the OLDVAL( ) function that checks to see if the Next Inspection date field has changed during editing.
- This script is not of any use in ZP 32 if you are not using Security.
- For ZP SQL you would change "zonepro.owner" to "zpsecure.ownint".
- There are only a handful of fields available to stick this info into. I chose Last Time because this field should be blank when you are scheduling a new inspection.

1/06/2011

A Variation On Locking the Notes Field

There is an option in the Global Options screen that lets you lock the Note2 field is various screens so that no one can alter any text that has been moved into that field using the Append Notes button. Today I worked out a way that you can imitate that same effect on either the Notes1 or Notes2 field with the added benefit of a security level check. With this script, anyone with a security level greater than 1 cannot directly edit the Building Notes1 field. They can still add to the field however by typing into the Notes2 field and then using the Append Notes button to add that text to the existing text in Notes1. Note that the script must also disable the other Append Notes button. This script uses "Building" for the Module, "Building" for the Screen, and "Edit" for the Action:

if vartype(zpsecure) = "O" and val(zpsecure.bds) > 1
buildscreen.zp_pageframe1.page4.edtNotes1.enabled=.F.
buildscreen.zp_pageframe1.page4.notes_buttons1.move1_btn.enabled=.F.
endif

You may want to clean things up by adding another script to the "Save" action that re-enables the text to make it more readable.

For ZP SQL the script would be:

if zpsecure.bds > 1
buildscreen.zp_pageframe1.page3.edtNotes1.enabled=.F.
buildscreen.zp_pageframe1.page3.notes_buttons1.move1_btn.enabled=.F.
endif

You could also change the script to make access dependent on a user's Security Initials so that only one person had access. Do this by changing the first line to:

if zpsecure.ownerinit <> "ZPD"

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.

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

3/22/2010

Linking Zoning Permits To A Building Permit

This script was designed to enable a customer to keep better tabs on permits in other databases that are somehow associated with a given building permit. The example used here is a Zoning permit that is a required precursor to a Building permit. The objective is to be able to view the details of that Zoning permit from within the Building Screen. I created a script that will browse select fields of the Zoning record from within the Building Screen. This script uses "Building" as the Module, "Building" as the Screen and "Left" as the Action which means it will run when you click on the User Script Button in the Building Screen.

mylink = strextract(build1.notes1,"<BeginLink>","<EndLink>",1,1)
if not empty(mylink) select id_code as id,typeinsp as type,details,cert as permit,cert_date as date from zoning
into cursor tempzoning where id_code = mylink
browse normal in window mainzone noedit nodelete title "Linked Zoning Record"
use in iif(used('zoning'),'zoning',0)
use in iif(used('tempzoning'),'tempzoning',0)
endif
select build1

This script will now display a browse window anytime a Zoning record is linked to a Building record, but you have to define that link. To create a link to the desired Zoning permit in the Notes1 field of the Building record I’m using the technique that is explained in the "Selective Notes Printing 1" video on the Training Videos  section of our web page.

Here are the steps I take:
- Go to the Zoning permit record that you want to link and make a note of the ID Code. (That is the second number in the ID string at the top right of the Main tab.)
- Go to the Building record where you want to implement the link.
- Go to the Notes tab. Hit "Edit", and add this text anywhere in the Notes1 field:

<BeginLink> id_code <EndLink>

- Replace the bit that says id_code with the Zoning id_code you made a note of and save your change.

Now you click on the User Script Button to display a browse table with details about the linked Zoning record. This script technique can be expanded to work with any databases. The link tags are good candidates for using with the Notekeeper feature.

To use this option with ZP SQL the initial script needs some minor changes:

mylink = strextract(build1.notes1,"<BeginLink>","<EndLink>",1,1)
if not empty(mylink)
myCommand=[select id_code as id,typeinsp as type,details,cert as permit,;
cert_date as date from zoning where id_code = '] + mylink +[']
dosqlcommand(myCommand,'tempzoning')
browse normal in window mainzone noedit nodelete title "Linked Zoning Record"
use in iif(used('tempzoning'),'tempzoning',0)
endif
select build1

Enhancing Security For Closed Permits

A customer who uses the Security Module wanted a way to prevent users without the proper access levels from editing building permit records after they had been closed. Only users with a security level of 1 should be allowed to edit those permits. The following script assumes that the Occupy Date field is used to indicate whether a record is closed or not. This script uses "Building" as the Module, "Building" as the Screen and "Edit" as the Action:

if vartype(zpsecure) = "O" and not empty(occ_date) and val(zpsecure.bds) > 1
= messagebox("You cannot edit a finaled permit.",64,"Action Canceled")
buildscreen.isediting = .f.
endif

To use this option with ZP SQL the script needs a slightly altered first line:

if not empty(occ_date) and zpsecure.bds > 1
= messagebox("You cannot edit a finaled permit.",64,"Action Canceled")
buildscreen.isediting = .f.
endif