Calendar repeat events

omo66 wrote on Thursday, August 28, 2008:

When I check every 2nd workday (for example) I get a schedule for ALL working days of the week…?
I check all 2nd 3rd etc all not working.

I want to create a schedule for e.g
Tuesday 10-1pm 15 min slots
wed 12-2pm 15 minutes slots

how could this be done???

Thanks all

omo66 wrote on Saturday, August 30, 2008:

I figured this out.
I choose month view, then from the very left top I clicked ADD, a new menu showed up. I selected day of the week ( e.g Wed), from drop list I choose weekly.
The rest is simple.

cfapress wrote on Tuesday, September 09, 2008:

This could be a bug. I’ll take a look at the CVS calendar code to see how ‘workday’ is defined and get back to you.

Jason

cfapress wrote on Tuesday, September 09, 2008:

Indeed this was a bug!!

The ‘workday’ repeating feature was including weekends in it’s calculations AND just being kinda stupid with the date math.

I’ll be commiting a change to the CVS code to fix this problem. Now a workday will truly be defined as Mon-Fri and exclude Sat/Sun in the repeating calculations.

Jason

omo66 wrote on Tuesday, September 23, 2008:

Hi Jason,
I would like to start using 2.9 in production soon, … could you tel me how to fix repeat events?

Thank you.

cfapress wrote on Tuesday, September 23, 2008:

Hi Omar,

I can tell you what needs to be changed in the PHP code. If you’re comfortable editing source code yourself it should be pretty easy. If not, you can download the specific file from the CVS source code tree here on SourceForge. I’ll give some instructions for both solutions.

1) Editing the source code
Find the source code file pnuserapi.php it can be found in this folder
<openemr>/interface/main/calendar/modules/PostCalendar
Go to the very bottom of the file to find the function &__increment
Replace the lines of code between
    } elseif($t == REPEAT_EVERY_WORK_DAY) {
and
    } elseif($t == REPEAT_EVERY_WEEK) {
with this block of code:
        // a workday is defined as Mon,Tue,Wed,Thu,Fri
        // repeating on every or Nth work day means to not include
        // weekends (Sat/Sun) in the increment… tricky

        // ugh, a day-by-day loop seems necessary here, something where
        // we can check to see if the day is a Sat/Sun and increment
        // the frequency count so as to ignore the weekend. hmmmm…
        $orig_freq = $f;
        for ($daycount=1; $daycount<=$orig_freq; $daycount++) {
            $nextWorkDOW = date(‘D’,mktime(0,0,0,$m,($d+$daycount),$y));
            if ($nextWorkDOW == “Sat”) { $f++; }
            else if ($nextWorkDOW == “Sun”) { $f++; }
        }
        // and finally make sure we haven’t landed on a Sat/Sun
        // adjust as necessary
        $nextWorkDOW = date(‘D’,mktime(0,0,0,$m,($d+$f),$y));
        if ($nextWorkDOW == “Sat”) { $f+=2; }
        else if ($nextWorkDOW == “Sun”) { $f++; }

        return date(‘Y-m-d’,mktime(0,0,0,$m,($d+$f),$y));

Now SAVE the changes you made and try to create some repeating WorkDay events.

2) Getting file from SourceForge

Click on the ‘More’ link near the top of this page
Position your mouse on the ‘Code’ link that appears (DO NOT CLICK)
Move the mouse to CVS Browse and then click
Click on openemr
Click on interface
Click on main
Click on calendar
Click on modules
Click on PostCalendar
Click on pnuserapi.php
Now you’ll see a list of revisions
Click on the Download link next to Revision 1.18
Save the file to your computer
Now you need to copy the downloaded file onto your server into the folder
<openemr>/interface/main/calendar/modules/PostCalendar

Given the two options I’d suggest #2 since it’s a bit less complicated and doesn’t require any programming knowledge.
Jason

omo66 wrote on Wednesday, September 24, 2008:

thank you Jason , I will test #2 today.