Browse Source

Merge pull request #226 from shacky/master

Meeting - recurrence every month (the same day of week, e.g. first mo…
Janusz Tylek 2 years ago
committed by GitHub
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 0 deletions
  1. +17

+ 17
- 0
modules/CRM/Meeting/MeetingCommon_0.php View File

@@ -232,6 +232,8 @@ class CRM_MeetingCommon extends ModuleCommon {
8=>__('Customize week'),
9=>__('Every two weeks'),
10=>__('Every month'),
12=>__('Every month (the same day of the week, e.g. last monday every month)'),
13=>__('Every month (the same day of the week, e.g. first monday every month)'),
11=>__('Every year')
if ($mode=='add' || $mode=='edit') {
@@ -646,6 +648,21 @@ class CRM_MeetingCommon extends ModuleCommon {
$tday = date('d', strtotime($r['date']));
if ($cday!=$tday && ($tday<=$numdays || $numdays!=$cday)) return null;
if ($r['recurrence_type']==12 || $r['recurrence_type']==13) {
$evdate = strtotime($r['date']);
$cday = date('l', $iday);
$tday = date('l', $evdate);
if($cday!=$tday) return null;
$cmonth = date('Y-m H:i:s',$iday);
$tmonth = date('Y-m H:i:s',$evdate);
$cfive = ($cmonth==date('Y-m H:i:s',strtotime('fifth '.$cday.' of '.$cmonth))) && ($r['recurrence_type']==12);
//if first "monday" of event month is same as event date go and check first "monday" of currently selected month is same as current date - if not, skip
if((strtotime('first '.$cday.' of '.$tmonth)==$evdate && strtotime('first '.$cday.' of '.$cmonth)!=$iday) ||
(strtotime('second '.$cday.' of '.$tmonth)==$evdate && strtotime('second '.$cday.' of '.$cmonth)!=$iday) ||
(strtotime('third '.$cday.' of '.$tmonth)==$evdate && strtotime('third '.$cday.' of '.$cmonth)!=$iday) ||
//for last week check if it's fivth "monday" of month and compare last week days only
((strtotime('fourth '.$cday.' of '.$tmonth)==$evdate || strtotime('fifth '.$cday.' of '.$tmonth)==$evdate) && ((!$cfive && strtotime('fourth '.$cday.' of '.$cmonth)!=$iday) || ($cfive && strtotime('fifth '.$cday.' of '.$cmonth)!=$iday)))) return null;
if ($r['recurrence_type']==11) {
$cmonth = date('m', $iday);
$tmonth = date('m', strtotime($r['date']));