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
we nth))) 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��* G H I J K M N O P P��� ���� 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��* 5 6 7 8 : <