Updating the Client Database
The first thing we will need to do is create a place in the local database to store the value of the field. Database management and structure is controlled through SpecialArguments.py, found in the Floworks root directory.
SpecialArguments.py Example
###################################
# V2.0.10
###################################
#PM_SparkPlugs
try:
cursor.execute("""
ALTER TABLE `floworks`.`workorders` ADD COLUMN `PM_SparkPlugs` VARCHAR(45) DEFAULT NULL AFTER PM_CheckBattery
""")
print "V2.0.10: PM_SparkPlugs added to workorders"
except MySQLdb.Error, e:
print "V2.0.10: PM_SparkPlugs already exists in workorders"
SpecialArguments.py is part of the command.py loop and will execute when machine is first booted and again at the specified command interval (currently 20 minutes).
Tip
When adding a field to the database with this method, execute SpecialArguments.py within the development environment (rather than adding the field manually to the database). This will ensure that the script added the field successfully and that there are no syntax errors.
Updating the Client Interface
Updating the Client Interface involves locating the appropriate file in the Floworks code base. In the example above we are adding a field to the PM Checklist on the work order…therefore, we would need to locate the “C:\Floworks\xampp\htdocs\forms\workorder” folder.
Mark-up Example
Because we are making changes to the form, we will need to also add the new field to the code that saves the form, to ensure that we’re saving the new interface field to the new database field created above. In this example, we will open the “saveWorkOrder.php” file contained within the same directory and add the highlighted line of code:
A Note on updating the PM Checklist
Because the PM Checklist is “Template-Driven”, any new PM field that you wish to add to the Client side interface will be hidden by default unless you first add it to list of available fields on a given template. In following with the above example, we will need to add the new PM field to the internal “pmfields” table.
Once added, the field will need to included on a PM Template. This can be done from the Field Service section of the Intranet under “PM Administration”
This will automatically sync to the client machines and become an available PM checklist option on any unit that is assigned to this PM Template.
Add Field to the XML Structure
Now that the new field has been established in the local database and can be edited from the interface, we need to make sure that this new field is generated in the XML that is sent in when a work order is submitted. Continuing with the above example, open functions.php within the Floworks core and locate code that is generating the XML for the Work Orders.
functions.php
Next Steps
After completing the Client-side changes, please see the following pages for instructions on deploying this change.