Revision: 1524
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1524&view=rev
Author:   cimorrison
Date:     2010-10-21 13:34:36 +0000 (Thu, 21 Oct 2010)

Log Message:
-----------
Extended the check that the start day is not after the end day to the form 
submission validation

Modified Paths:
--------------
    mrbs/branches/from_to_bookings/web/Themes/default/header.inc
    mrbs/branches/from_to_bookings/web/edit_entry.php
    mrbs/branches/from_to_bookings/web/lang.en

Modified: mrbs/branches/from_to_bookings/web/Themes/default/header.inc
===================================================================
--- mrbs/branches/from_to_bookings/web/Themes/default/header.inc        
2010-10-21 13:16:59 UTC (rev 1523)
+++ mrbs/branches/from_to_bookings/web/Themes/default/header.inc        
2010-10-21 13:34:36 UTC (rev 1524)
@@ -290,6 +290,33 @@
     return text;
   }
   
+  <?php
+  // Work out whether the start date is before, after or the same
+  // as the end date.  Store the result in dateDifference which can
+  // be tested for being equal (same), negative (after) or positive (before)
+  ?>
+  function getDateDifference(form)
+  {
+    var startDay = parseInt(form.start_datepicker_alt_day.value);
+    var startMonth = parseInt(form.start_datepicker_alt_month.value);
+    var startYear = parseInt(form.start_datepicker_alt_year.value);
+    var endDay = parseInt(form.end_datepicker_alt_day.value);
+    var endMonth = parseInt(form.end_datepicker_alt_month.value);
+    var endYear = parseInt(form.end_datepicker_alt_year.value);
+ 
+    var diff;
+    diff = endYear - startYear;
+    if (diff == 0)
+    {
+      diff = endMonth - startMonth;
+      if (diff == 0)
+      {
+        diff = endDay - startDay;
+      }
+    }
+    return diff;
+  }
+  
   function adjustSlotSelectors(form)
   {
     <?php
@@ -305,30 +332,8 @@
     var text, durationText, isSelected, i, j;
     var nbsp = '\u00A0';
     var errorText = '<?php echo get_vocab("start_after_end")?>';
+    var dateDifference = getDateDifference(form);
     
-    <?php
-    // Work out whether the start date is before, after or the same
-    // as the end date.  Store the result in dateDifference which can
-    // be tested for being equal (same), negative (after) or positive (before)
-    ?>
-    var startDay = parseInt(form.start_datepicker_alt_day.value);
-    var startMonth = parseInt(form.start_datepicker_alt_month.value);
-    var startYear = parseInt(form.start_datepicker_alt_year.value);
-    var endDay = parseInt(form.end_datepicker_alt_day.value);
-    var endMonth = parseInt(form.end_datepicker_alt_month.value);
-    var endYear = parseInt(form.end_datepicker_alt_year.value);
- 
-    var dateDifference;
-    dateDifference = endYear - startYear;
-    if (dateDifference == 0)
-    {
-      dateDifference = endMonth - startMonth;
-      if (dateDifference == 0)
-      {
-        dateDifference = endDay - startDay;
-      }
-    }
-    
     form.start_seconds.disabled = (dateDifference < 0);
     form.end_seconds.disabled = (dateDifference < 0);
 

Modified: mrbs/branches/from_to_bookings/web/edit_entry.php
===================================================================
--- mrbs/branches/from_to_bookings/web/edit_entry.php   2010-10-21 13:16:59 UTC 
(rev 1523)
+++ mrbs/branches/from_to_bookings/web/edit_entry.php   2010-10-21 13:34:36 UTC 
(rev 1524)
@@ -411,6 +411,17 @@
       return false;
     }
   }
+  
+  <?php
+  // Check that the start date is not after the end date
+  ?>
+  var dateDiff = getDateDifference(form);
+  if (dateDiff < 0)
+  {
+    alert('<?php echo get_vocab("start_after_end_long")?>');
+    return false;
+  }
+  
   <?php if( ! $enable_periods ) { ?>
 
   h = parseInt(form.hour.value);

Modified: mrbs/branches/from_to_bookings/web/lang.en
===================================================================
--- mrbs/branches/from_to_bookings/web/lang.en  2010-10-21 13:16:59 UTC (rev 
1523)
+++ mrbs/branches/from_to_bookings/web/lang.en  2010-10-21 13:34:36 UTC (rev 
1524)
@@ -96,6 +96,8 @@
 $vocab["useful_n-weekly_value"] = "useful n-weekly value.";
 $vocab["private"]            = "Private";
 $vocab["unavailable"]        = "Private";
+$vocab["start_after_end"]    = "Start day after end day";
+$vocab["start_after_end_long"] = "Error: the start day is after the end day";
 
 // Used in view_entry.php
 $vocab["description"]        = "Description";


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to