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