Showing posts with label editing. Show all posts
Showing posts with label editing. Show all posts

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

4/13/2011

Forcing Pick Box Use (ZP 32 & ZP SQL)

I recently had a customer ask if there is a way to force users to fill in fields using the Pick Box feature. One way to do this is to disable the field for direct editing by making the field read only. You can do this for selected fields in the screen scripts. The example below makes the Existing Use field read only so the only way it can be filled in is by using the Pick Box option. The script uses "Base" for the Module, "Property" for the Screen, and "Screen" for the Action.

propscreen.zp_pageframe1.page1.txtExist_use.readonly = .T.

You can add as many fields to the same script as needed.

1/27/2011

Copy and Pasting Fields Between Records (ZP 32 or ZP SQL)

A customer using the Rental Screen wanted to be able to copy information from the existing rental record whenever they added a new one. There is a built-in carry-over option in the Rental Screen if you right-click on the Add button, but that option does not copy all the fields this customer needed. I devised the following script as a way to copy and paste multiple fields at a time between any two records in the same database. This script uses "Housing" for the Module, "Rental" for the Screen and "Left" for the Action:

myaction = inputbox("Enter C to Copy or P to Paste")
if lower(myaction) = "c"
javascript:void(0)
wait window "copying fields..." nowait
public mydata
mydata = createobject("empty")
addproperty(mydata,"user1",rental.user1)
addproperty(mydata,"user2",rental.user2)
addproperty(mydata,"user3",rental.user3)
addproperty(mydata,"user6",rental.user6)
addproperty(mydata,"notes1",rental.notes1)
endif
if lower(myaction) = "p"
wait window "pasting fields..." nowait
if vartype(mydata) = "o"
rescreen.isediting = .t.
gather name mydata memo
release mydata
endif
rescreen.refresh
endif

NOTES
- This script crams both the Copy and Paste actions into one button (the left click Script button) with a prompt to decide which action to take. You could also easily split this into two scripts and put the Copy action in the left click and the Paste action in the right click and drop the prompt code.
- You can revise a script like this to work with any of the ZP databases and with any number of fields.
- Note that the Paste option puts you into Edit Mode, which means you can Cancel the Edit to negate the paste.

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/12/2011

Archiving Fields in the Notes

I have a customer who wants to archive old data before they edit and change the value of certain fields. You can easily automate the archiving of various fields into one of the Notes fields by using a script. The example I'm using is archiving the Zoning District and the Existing Use fields in the Property Screen into the Notes1 field. The script copies the fields into the Notes when you click on the Script button while editing a Property record. This script uses "Base" for the Module, "Property" for the Screen, and "Left" for the Action:

if propscreen.isediting = .T.
replace notes1 with iif(empty(notes1),"",alltrim(notes1) +chr(13)+chr(13));
+ "ZONING ARCHIVED: "+dtoc(date()) + chr(13)+;
"Old Zoning: " + alltrim(zoning);
+"  Use: " + alltrim(exist_use)
propscreen.refresh
endif

In ZP 32 the "notes1" field should be referred to as "notes".

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

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.

3/22/2010

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


Preventing Violation Type Editing

The City of Whitehall wanted a way to prevent users from changing the Violation Type of existing violations. This was accomplished with two scripts. Both scripts use "Zoning" as the Module and "Violations" as the Screen. The first script uses "Edit" as the Action and it disables the Violation Type drop down box when editing:

vlscreen.zp_pageframe1.page1.cmbVio_type.enabled = .F.

Another script is need for the “Add” Action to make sure the drop-down box works when you are adding new violations:

vlscreen.zp_pageframe1.page1.cmbVio_type.enabled = .T.

3/03/2010

Preventing Fee Editing

This script will prevent anyone from editing the fee amount once the fee has been paid. This example uses the Zoning database and keys in on the Date Paid field as the deciding factor.  I use "Zoning" as the Module, "Zoning" as the Screen, and "Edit" as the Action. The script is:

IF NOT EMPTY(date_paid)
znscreen.zp_pageframe1.page1.txtPer_fee.enabled = .F.
ELSE
znscreen.zp_pageframe1.page1.txtPer_fee.enabled = .T.
ENDIF

The second part of the script enables the Fee field again if you navigate to another record where the condition no longer holds true.