Index: /branches/LCSv1/controllers/default.py
===================================================================
--- /branches/LCSv1/controllers/default.py	(revision 610)
+++ /branches/LCSv1/controllers/default.py	(revision 612)
@@ -43,5 +43,5 @@
                 INPUT(_name='enddate',_class='date'),BR(),
                 INPUT(_value="Search", _type='submit', _class="btn btn-primary btn-default", _style="margin:  7% 45% 2% 40%;"))
-    if form.process().accepted:
+    if form.process(onvalidation=special_validation).accepted:
         # Put the form fields into the session variables
         session.closureid = form.vars.closureid
@@ -53,4 +53,9 @@
         redirect(URL('results'))
     return dict(form=form)
+# Search Form: Special validation check to reject lognum without closureID
+def special_validation(form):
+    # Error if a lognum was given and no closure id
+    if (len(form.vars.lognum) > 0 and len(form.vars.closureid) == 0):
+       form.errors.lognum = 'Must provide a closureID when specifying a log number'
 # Show the item that was found in the search
 def results():
Index: /branches/LCSv1/controllers/default.py.bak
===================================================================
--- /branches/LCSv1/controllers/default.py.bak	(revision 593)
+++ /branches/LCSv1/controllers/default.py.bak	(revision 612)
@@ -1,2 +1,3 @@
+# added comments for testing
 # Constants
 hwys = ['','1','5', '22', '55', '57', '73', '74', '91', '133', '142', '241', '261', '405', '605']
@@ -4,7 +5,7 @@
 # Show the login page
 def index():
-    form = FORM(LABEL('Username:',_for='username', _class="label"),
-                INPUT(_name='username',_size='10'),BR(),
-                INPUT(_type='submit', _class="submit-button btn btn-primary"))
+    form = FORM(LABEL('Username:',_for='username', _class="label username-label"),
+                INPUT(_name='username', _size='15', _style="font-size: 18px;"), BR(),
+                INPUT(_type='submit',_value="Log in", _class=" btn btn-primary", _style="margin-top: 3%;"))
     if form.process().accepted:
         # Put the username entry into the session variable
@@ -28,6 +29,19 @@
 # Display a search form
 def search():
-    form = FORM(LABEL('ClosureID/Log:',_for='closureid', _class="label"), INPUT(_name='closureid',_size='7'),INPUT(_name='lognum',_size='3'),XML('&nbsp;&nbsp;&nbsp;'), LABEL('Route: ',_for='route', _class="label"), SELECT(hwys,_name='route'), XML('&nbsp;&nbsp;&nbsp;'), LABEL('Direction: ',_for='direction', _class="label"), SELECT(hwyDirections,_name='direction'), BR(),BR(),LABEL('Dates:',_for='startdate', _class="label") ,INPUT(_name='startdate',_class='date'), XML('&nbsp;&nbsp;&nbsp;'), LABEL('  to:',_for='enddate', _class="label"), INPUT(_name='enddate'),'(MMDDYYYY)',BR(),BR(),INPUT(_type='submit', _class="submit-button btn btn-primary"))
-    if form.process().accepted:
+    form = FORM(LABEL('ClosureID/Log:',_for='closureid', _class="label"), 
+                INPUT(_name='closureid',_size='7', _style="margin-right: 5px;"),
+                INPUT(_name='lognum',_size='3'),
+                XML('&nbsp;&nbsp;&nbsp;'), 
+                LABEL('Route: ',_for='route', _class="label"), 
+                SELECT(hwys,_name='route'), XML('&nbsp;&nbsp;&nbsp;'), 
+                LABEL('Direction: ',_for='direction', _class="label"),
+                SELECT(hwyDirections,_name='direction'), BR(),BR(), 
+                LABEL('Dates:',_for='startdate', _class="label"), 
+                INPUT(_name='startdate',_class='date'), 
+                XML('&nbsp;&nbsp;&nbsp;'), 
+                LABEL('  to:',_for='enddate', _class="label"), 
+                INPUT(_name='enddate',_class='date'),BR(),
+                INPUT(_value="Search", _type='submit', _class="btn btn-primary btn-default", _style="margin:  7% 45% 2% 40%;"))
+    if form.process(onvalidation=special_validation).accepted:
         # Put the form fields into the session variables
         session.closureid = form.vars.closureid
@@ -39,29 +53,53 @@
         redirect(URL('results'))
     return dict(form=form)
+# Search Form: Special validation check to reject lognum without closureID
+def special_validation(form):
+    # Error if a lognum was given and no closure id
+    if (len(form.vars.lognum) > 0 and len(form.vars.closureid = 0)):
+       form.errors.lognum = 'Must provide a closureID when specifying a log number'
 # Show the item that was found in the search
 def results():
+    # query object is equivalent to the where clause in query 
+    query = True
+    msg = ""
     if (len(session.closureid) != 0):
-        hwy = db(db.closures.closureid == session.closureid).select() 
-        msg = "Closure ID = " + session.closureid
-    elif (len(session.route) != 0):
-        hwy = db(db.closures.route == session.route).select() 
-        msg = "route = " + session.route
-    elif (len(session.startdate) == 10):
-        hwy = db(db.closures.startdate >= session.startdate).select()
-        msg = "Start Date >= " + session.startdate
-    else:
+        query = (db.closures.closureid == session.closureid)
+        msg += " Closure ID = " + session.closureid    
+    if (len(session.lognum) != 0):
+        query = query & (db.closures.lognum == session.lognum)
+        msg += " Log number = " + session.lognum    
+    if (len(session.route) != 0):
+        query = query & (db.closures.route == session.route)
+        msg += " Route = " + session.route
+    if (len(session.direction) != 0):
+        query = query & (db.closures.direction == session.direction)
+        msg += " Route = " + session.route
+    if (len(session.startdate) != 0):
+        query = query & (db.closures.startdate >= session.startdate)
+        msg += "Start date = " + session.startdate
+    if (len(session.enddate) != 0):
+        query = query & (db.closures.startdate <= session.enddate)
+        msg += "End date = " + session.enddate
+    
+    # if no restrictions entered then get all entries 
+    if query == True :
         hwy = db().select(db.closures.ALL)
         msg = "ALL"
+    else:
+        # get entries with the matching requirements
+        hwy = db(query).select()
+
     count = len(hwy)
     # Show the results in table format.  Get the radio call number from supervisor name lookup
     header = THEAD(TR(TH(''), TH('DTM',BR(),'Area'), TH('Closure ID/',BR(),'Log No.'),TH('Route & Dir/',BR(),'Type of Closure'),TH('Start Date/',BR(),'End Date/',BR(),'Est. Delay'),TH('Facility'),TH('Limits'),TH('Work'), TH('TMP:',BR(),'Cozeep/',BR(),'Detour'),TH('Requestor/',BR(),'Radio Call No.')))
     multiform = []
+    # Iterates over all search results
     for row in hwy:
         statusfields = row.closureid +','+ row.lognum + ',1097,' + str(row.s1097user) +','+ str(row.startdate) + ',' + formatTime(row.starttime) +','+str(row.s1097date)+','+ formatTime(row.s1097time) + ',1098,' + str(row.s1098user) +','+ str(row.s1098date)+','+ formatTime(row.s1098time)+ ',1022,' + str(row.s1022user) +','+ str(row.s1022date)+','+ formatTime(row.s1022time)
         # Each row contains a form with two buttons and columns with fields from database
         multiform.append(TR(TD(
-                    XML("<button onclick=showPopup(\'"),statusfields,XML("\')>View History</button>"),BR(),
+                    XML("<button class='submit-button' onclick=showPopup(\'"),statusfields,XML("\')>View History</button>"),BR(),
                     FORM(
-                          INPUT(_type='submit',_name='btn2',_value='Show Status Form'),
+                          INPUT(_type='submit',_name='btn2',_value='Show Status Form',_class="submit-button" ),
                           INPUT(_type='hidden',_name='row',_value=row.closureid))),
                           TD(row.closureid[0]),TD(row.closureid,HR(),row.lognum), TD(row.route,' ',row.direction,HR(),row.closuretype), TD(row.startdate,' ',formatTime(row.starttime),HR(),row.enddate,' ',formatTime(row.endtime),HR(),row.estdelay), TD(row.facility),TD(row.startlocation,HR(),row.endlocation), TD(row.worktype), TD(row.tmpcozeep,BR(),row.tmpdetour), TD(row.supervisor,HR(),db(db.supervisors.name == row.supervisor).select().first().radiocallnum) )) 
@@ -70,5 +108,4 @@
     if request.vars.btn2:
         redirect(URL('statuslist'))
-
     return dict(msg=msg, count=count, highways=hwy, table=header, multiform=multiform)
 
@@ -87,7 +124,7 @@
 
         form = FORM(BR(), 
-                TABLE(THEAD(TR(TH('Closure ID/',BR(),'Log No.'),TH('Route & Dir',BR(),'Type of Closure'),TH('Start Date/',BR(),'End Date/',BR(),'Est. Delay'),TH('Requestor/',BR(),'Radio Call No.'),TH('Status'))),
+                TABLE(THEAD(TR(TH('Closure ID/',BR(),'Log No.'), TH('Route & Dir',BR(),'Type of Closure'),TH('Start Date/',BR(),'End Date/',BR(),'Est. Delay'),TH('Requestor/',BR(),'Radio Call No.'),TH('Status'))),
                     [TR(TD(row.closureid,HR(),row.lognum),TD(row.route,' ',row.direction,HR(),row.closuretype),TD(row.startdate,HR(),row.enddate,HR(),row.estdelay),TD(row.supervisor,BR(),db(db.supervisors.name == row.supervisor).select().first().radiocallnum),TD(LABEL('1097'), INPUT(_type='checkbox', _name='statustype', _value='1097'+row.closureid),LABEL('1098'), INPUT(_type='checkbox', _name='statustype', _value='1098'+row.closureid),LABEL('1022'), INPUT(_type='checkbox', _name='statustype', _value='1022'+row.closureid),BR(), LABEL('Statuser:'),INPUT(_name='statuser',_size='9'))) for row in closedItems],
-                    _border='1', _cellpadding='5'),INPUT(_type='submit',_value="submit status form"),)
+                    _border='1', _cellpadding='5'),INPUT(_type='submit',_value="submit status form",_class="submit-button"),)
         
     else:
@@ -125,9 +162,4 @@
     return dict(msg=msg)
 # Utility functions for formatting
-def formatDate(msg):
-    if (msg):
-        return msg[4:6]+"/"+msg[6:8]+"/"+msg[0:4]
-    else:
-        return ""
 def formatTime(msg):
     if (msg):
@@ -157,14 +189,19 @@
            LABEL('*Direction',_for='direction'), SELECT(hwyDirections,_name='direction', requires=IS_LENGTH(minsize=1,error_message='direction cannot be empty')), XML('&nbsp;&nbsp;&nbsp;'), 
            LABEL('*Facility',_for='facility'), SELECT(facilities,_name='facility', requires=IS_LENGTH(minsize=1,error_message='facility cannot be empty')), BR(),BR(), 
-           TABLE(TR(TD(),TD('*County'),TD('*Location')),TR(TD('BEGIN='),TD(SELECT('ORA',_name='startcounty')),TD(SELECT(streets,_name='startlocation',_id='startlocation')),
-           TR(TD('END='),TD(SELECT('ORA',_name='endcounty')),TD(SELECT(streets,_name='endlocation',_id='endlocation'))))),BR(),
-           'Date Range:',BR(),
+           TABLE(TR(TD(),TD(LABEL('*County')),TD(LABEL('*Location'))),
+                TR(TD(LABEL('BEGIN=')),TD(SELECT('ORA',_name='startcounty')),
+                TD(SELECT(streets,_name='startlocation',_id='startlocation')),
+           TR(TD(LABEL('END=')),TD(SELECT('ORA',_name='endcounty')),TD(SELECT(streets,_name='endlocation',_id='endlocation'))))),BR(),
+           LABEL('Date Range:'),BR(),
            LABEL('From',_for='startdate'),INPUT(_name='startdate',_size='8',_class='date'), XML('&nbsp;&nbsp;&nbsp;'), 
-           LABEL('to:',_for='enddate'), INPUT(_name='enddate',_size='8',_class='date'),'(MMDDYYYY)',XML('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'), 
+           LABEL('to:',_for='enddate'), INPUT(_name='enddate',_size='8',_class='date'),XML('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'), 
            LABEL('Times',_for='starttime'),SELECT(hournames,_name='starttime'), 
            LABEL(':',_for='starttimemin'),SELECT('','00','15','30','45','59',_name='starttimemin'), XML('&nbsp;&nbsp;'), 
            LABEL('to:',_for='endtime'),SELECT(hournames,_name='endtime'), 
            LABEL(':',_for='endtimemin'),SELECT('','00','15','30','45','59',_name='endtimemin'), BR(),BR(), 
-           TABLE(TR(TD('*Type of Closure'),TD('*Type of Work'),TD('Estimated Delay'),TD('TMP Details')), 
+           TABLE(TR(TD(LABEL('*Type of Closure') ),
+                    TD(LABEL('*Type of Work')),
+                    TD(LABEL('Estimated Delay')),
+                    TD(LABEL('TMP Details'))), 
                  TR(TD(SELECT(closuretypes,_name='closuretype',requires=IS_LENGTH(minsize=1,error_message='type of closure cannot be empty'))), 
                     TD(SELECT(worktypes,_name='worktype', requires=IS_LENGTH(minsize=1,error_message='type of work cannot be empty'))), 
@@ -173,10 +210,15 @@
                        INPUT(_type='checkbox', _name='detour'),'Detour Available')), 
                  _width='100%' ),
-    TABLE(TR(TD('*Supervisor'),TD('Field Rep')), 
+    TABLE(TR(TD(LABEL('*Supervisor')),
+            TD(LABEL('Field Rep'))), 
                   TR(TD(SELECT(supervisors,_name='supervisor', requires=IS_LENGTH(minsize=1,error_message='supervisor cannot be empty'))),
                      TD(SELECT(supervisors,_name='fieldrep')))),
-    TABLE(TR(TD('Meeting Place/CHP Contact'),TD('Reason for Closure'),TD('Additional Remarks / Detour ')), 
-                  TR(TD(INPUT(_name='meeting')),TD(INPUT(_name='reason')),TD(INPUT(_name='remarks',_size='40'))) ), BR(), 
-            INPUT(_type='submit',_value='Submit Closure'),XML('\n'),SELECT(streetlookup,_name='stlookup', _id='stlookup', _class='hideme')) 
+    TABLE(TR(TD( LABEL('Meeting Place/CHP Contact')),
+            TD(LABEL('Reason for Closure')),
+            TD(LABEL('Additional Remarks / Detour '))), 
+                  TR(TD(INPUT(_name='meeting', _size='25')),TD(INPUT(_name='reason',_size='25')),TD(INPUT(_name='remarks',_size='25'))) ), BR(), 
+            INPUT(_type='submit',_value='Submit Closure', _class="btn btn-primary btn-default", _style="margin:  2% 45% 2% 40%;"),
+            XML('\n'),SELECT(streetlookup,_name='stlookup', _id='stlookup', _class='hideme')) 
+
     if form.process().accepted:
         newID = calcNextClosure(form.vars.route)
