Revision: 2563
          https://sourceforge.net/p/mrbs/code/2563/
Author:   cimorrison
Date:     2012-11-27 15:23:55 +0000 (Tue, 27 Nov 2012)
Log Message:
-----------
Added the ability to specify the "fifth" and "fifth last" weekdays of the month 
when making monthly recurring bookings.   These are strict interpretations and 
will result in no bookings for months where there are only four of the 
specified day of of the week.  (Using "last" or "first" will give you the 
fourth or fourth last weekday if there are only four weekdays in the month).

Modified Paths:
--------------
    mrbs/trunk/web/edit_entry.php
    mrbs/trunk/web/functions.inc
    mrbs/trunk/web/lang/lang.en
    mrbs/trunk/web/mrbs_sql.inc
    mrbs/trunk/web/site_faq.html

Modified: mrbs/trunk/web/edit_entry.php
===================================================================
--- mrbs/trunk/web/edit_entry.php       2012-11-07 07:01:42 UTC (rev 2562)
+++ mrbs/trunk/web/edit_entry.php       2012-11-27 15:23:55 UTC (rev 2563)
@@ -1362,7 +1362,7 @@
       // do with revisiting.   It assumes all languages have the same order as 
English
       // eg "the second Wednesday" which is probably not true.
       $options = array();
-      foreach (array('1', '2', '3', '4', '-1', '-2', '-3', '-4') as $i)
+      foreach (array('1', '2', '3', '4', '5', '-1', '-2', '-3', '-4', '-5') as 
$i)
       {
         $options[$i] = get_vocab("ord_" . $i);
       }

Modified: mrbs/trunk/web/functions.inc
===================================================================
--- mrbs/trunk/web/functions.inc        2012-11-07 07:01:42 UTC (rev 2562)
+++ mrbs/trunk/web/functions.inc        2012-11-27 15:23:55 UTC (rev 2563)
@@ -404,7 +404,8 @@
 
 
 // Converts a BYDAY (eg "2SU") value for a given year and month into a
-// day of the month
+// day of the month.   Returns FALSE if the day does not exist (eg for "5SU"
+// when there are only four Sundays in the month)
 function byday_to_day($year, $month, $byday)
 {
   // First of all normalise the month and year, as we allow $month > 12
@@ -428,7 +429,16 @@
   // add in the weeks
   $diff += ($ord > 0) ? ($ord - 1) * 7 : ($ord + 1) * 7;
   
-  return $start_dom + $diff;
+  $day = $start_dom + $diff;
+  
+  if (checkdate($month, $day, $year))
+  {
+    return $day;
+  }
+  else
+  {
+    return FALSE;
+  }
 }
 
 

Modified: mrbs/trunk/web/lang/lang.en
===================================================================
--- mrbs/trunk/web/lang/lang.en 2012-11-07 07:01:42 UTC (rev 2562)
+++ mrbs/trunk/web/lang/lang.en 2012-11-27 15:23:55 UTC (rev 2563)
@@ -83,10 +83,12 @@
 $vocab["ord_2"]              = "second";
 $vocab["ord_3"]              = "third";
 $vocab["ord_4"]              = "fourth";
+$vocab["ord_5"]              = "fifth";
 $vocab["ord_-1"]             = "last";
 $vocab["ord_-2"]             = "second last";
 $vocab["ord_-3"]             = "third last";
 $vocab["ord_-4"]             = "fourth last";
+$vocab["ord_-5"]             = "fifth last";
 $vocab["rep_end_date"]       = "Repeat end date";
 $vocab["rep_rep_day"]        = "Repeat day";
 $vocab["rep_freq"]           = "Frequency";

Modified: mrbs/trunk/web/mrbs_sql.inc
===================================================================
--- mrbs/trunk/web/mrbs_sql.inc 2012-11-07 07:01:42 UTC (rev 2562)
+++ mrbs/trunk/web/mrbs_sql.inc 2012-11-27 15:23:55 UTC (rev 2563)
@@ -677,14 +677,15 @@
   
   $date = getdate($time);
   
-  $sec       = $date['seconds'];
-  $min       = $date['minutes'];
-  $hour      = $date['hours'];
-  $day       = $date['mday'];
-  $month     = $date['mon'];
-  $year      = $date['year'];
-  $start_day = $date['wday'];
-  $start_dom = $day;  // the starting day of the month
+  $sec         = $date['seconds'];
+  $min         = $date['minutes'];
+  $hour        = $date['hours'];
+  $day         = $date['mday'];
+  $month       = $date['mon'];
+  $year        = $date['year'];
+  $start_day   = $date['wday'];
+  $start_dom   = $day;  // the starting day of the month
+  $start_month = $month;
   
   // Make sure that the first date is a member of the series
   switch($rep_details['rep_type'])
@@ -707,7 +708,7 @@
       else
       {
         $day = byday_to_day($year, $month, $rep_details['month_relative']);
-        if ($day < $start_dom)
+        while (($day === FALSE) || (($day < $start_dom) && ($month == 
$start_month)))
         {
           $month++;
           $day = byday_to_day($year, $month, $rep_details['month_relative']);
@@ -755,17 +756,20 @@
         break;
       
       case REP_MONTHLY:
-        $month++;
-        if (isset($rep_details['month_absolute']))
+        do
         {
-          // Get the day of the month back to where it should be (in case we
-          // decremented it to make it a valid date last time round)
-          $day = $rep_details['month_absolute'];
-        }
-        else
-       else = $rep_details['month_absolute'];e last time round)ase 
wenth)))ng monthly recurring bookings.   These are strict interpretations 
and will result in no bookings for months where there are only four of the 
specified day of of the week.  (Using "last" or "first" will give you the 
fourth or fourth last weekday if there are only four weekdays in the 
month).P���`�K��*������̹�*u�K��*�̹�*ش̹�*��̹�*�M��*x�h��*�����
���kL��*�!�!P�������H�H��*�
�����K��*�L��*P���`�K��*��������x���8m��*�p�����u�K��*�M��*�

���`���kL��*GHIJKMNOPP�������HE��*0�����K��*�L��*P���0�̹�*u�K��*�h��*�y���*�̹�*ش̹�*��̹�*�M��*HE��*0���p
���kL��*8E��*0����
���kL��*(E��*0����
���kL��*E��*0���
���kL��*  
��̹�*u�K��*��̹�*���������*e�K��*ش̹�*�
���y����*e�K��*�̹�*�
���Z����*e�K��*�t���*�h��*�y���*�̹�*��h��*ش̹�*��̹�*�M��*8m��*=ȸ�*����p���*����P���kL��*5678:<=>?@BDP��������=Ÿ�*����u�K��*m��*���=ȸ�*e�K��*m��*�_@f�S
 
Q��l���S���*�����=Ÿ�*����`���kL��*u]��
      
4Q��U^Qʉ��u������*ēvP�������H����*�͸�*�����/��*��/��*�&˸�*��������x��������h��*u�K��*��h��*@�����/��*�����������������/��*����
       {
-          $day = byday_to_day($year, $month, $rep_details['month_relative']);
-        }
+          $month++;
+          if (isset($rep_details['month_absolute']))
+          {
+            // Get the day of the month back to where it should be (in case we
+            // decremented it to make it a valid date last time round)
+            $day = $rep_details['month_absolute'];
+          }
+          else
+          {
+            $day = byday_to_day($year, $month, $rep_details['month_relative']);
+          }
+        } while ($day === FALSE);
         trimToEndOfMonth($month, $day, $year);
         break;
         

Modified: mrbs/trunk/web/site_faq.html
===================================================================
--- mrbs/trunk/web/site_faq.html        2012-11-07 07:01:42 UTC (rev 2562)
+++ mrbs/trunk/web/site_faq.html        2012-11-27 15:23:55 UTC (rev 2563)
@@ -10,6 +10,7 @@
   <h4>Making/Altering Meetings</h4>
   <ul>
     <li><a href="#create">How do I create a meeting?</a></li>
+    <li><a href="#fifth">What is the difference between <q>fifth</q> and 
<q>last</q>?</a></li>
     <li><a href="#repeating_delete">How do I delete one instance of a 
recurring meeting?</a></li>
     <li><a href="#multiple_sites">How do I schedule rooms at different 
sites?</a></li>
     <li><a href="#too_many">My meeting failed to be created because of <q>too 
many entries</q>!</a></li>
@@ -73,6 +74,22 @@
     <a href="#top">Top</a>
   </div>
   
+  <div id="fifth">
+    <h4>What is the difference between <q>fifth</q> and <q>last</q>?</h4>
+    <p>
+      When making a monthly recurring booking, the <q>fifth</q> weekday of 
every month
+      is just that.  If a month does not have a fifth weekday then no booking 
will be
+      made for that month.   If you choose the <q>last</q> weekday of the 
month then a
+      booking will be made on the fourth weekday if there is no fifth weekday.
+    </p>
+    <p>
+      <q>Fifth last</q> works in a similar way, but counting backwards from 
the end of
+      the month.  Using <q>first</q> will give you the fourth last weekday of 
the month
+      if there is no fifth last weekday.
+    </p>
+    <a href="#top">Top</a>
+  </div>
+  
   <div id="repeating_delete">
     <h4>How do I delete one instance of a recurring meeting?</h4>
     <p>
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to