Changing the week-end to Friday, Please help

ayman-sa wrote on Friday, July 25, 2014:

Dears,

I am located in Africa and I am using OpenEMR Calendar,

Our First Day of week is Saturday, and Friday is Weekend.

I am changed the first day of week to be Saturday successfully.

Now I want to change the weekend to Friday. (Sat and Sun are working days).

Please can you help me on this with detailed steps?

Many Thanks.

cmswest wrote on Friday, July 25, 2014:

so a 6 day work week, and only Friday for rest? good grief!

is the problem that Saturday and Sunday are greyed out? if so here’s my shot at helping:

comment out this line:

ayman-sa wrote on Saturday, July 26, 2014:

Many Thanks Stephen for quick response,

But I need to set Saturday and Sunday to be working days,
and to set Friday to be Weekend (off).

I am using the calendar for the staff to setting their schedules.

Thanks in Advance.

blankev wrote on Saturday, July 26, 2014:

In administration => Other => Calendar you can make as many changes as needed. Tell us how you changed the Calendar to start of Friday…

Open the schedule for work on Saturday, work on Sunday, In O, Out of Office, lunch etc. Don’t forget to change the color to your likings, make some notes so if there is need for a change during an upgrade, to make the same changes to the Calendar.

You can even schedule for Friday to do the maintenance of the System…

alkanzi wrote on Saturday, July 26, 2014:

Hi all,
I think mr. ayman talks about repeated events option (every 2nd day). if you start on sat then you will end up on Friday.
and if you use (every workday) you will jump over sat & sun.

so the question is how to change the workdays to start from 6(sat) and end on 4(thu), while 5(Fri) is a weekend.

cmswest wrote on Saturday, July 26, 2014:

probably going to have to tweak this code:

fsgl wrote on Saturday, July 26, 2014:

Are these substitutions correct?

cmswest wrote on Saturday, July 26, 2014:

nice fsgl, i think all you need is this:

if(Date_Calc::dayOfWeek($day,$month,$year) == 4)
$days += 2;
else
$days += 1;

of course do the same to static function prevWeekday() as well

fsgl wrote on Saturday, July 26, 2014:

I thought line 484 referred to the first day of the work week. Apparently not.

Let’s try again, because the tweaks are not obvious to us non-geeks.

If it’s still wrong, please post the correct changed script.

cmswest wrote on Saturday, July 26, 2014:

sure, but first want to make sure i’m barking up the right tree, as i’ve implemented the code changes and it’s still skipping sat & sunday

i’m trying to repeat a weeks worth of weekday appts for a provider on my test server

found some interesting results here:

fsgl wrote on Saturday, July 26, 2014:

O.K., rather than confusing everyone, I’ll wait patiently for the completion of testing.

No more attachments until final results are in.

Amazing the boatload of codes to sift through. Do we have an index of this stuff in Github for quick reference?

cmswest wrote on Saturday, July 26, 2014:

it’s actually hard wired here:

code could be improved by calling previously discussed function and maybe create a different “lang” here instead of eng:

fsgl wrote on Saturday, July 26, 2014:

Since the OP has only 1 day off, lines 365 & 371 were uncommented.

The finer point of the second link about language vs. english was totally lost on me.

How about this other attachment?

blankev wrote on Saturday, July 26, 2014:

I am located in Africa and I am using OpenEMR Calendar, … not something easy as the Gregorian, Lunar calendar, etc.

We know that the first day of the week is Friday. Now we have to know what are the comparable days of Sat and Sun, since hardcoding is going to replace Starting day from Sunday or Monday to Friday the other days might also be of importance.

Very important to know if you want the client back in say five days. Go to the well known Computer Clinic, nobody is in the Clinic, and they have to walk home to come back in two days again. Or even later.

Ayman Sa, please tell us what are the “rest days” in your weekly Calendar.

fsgl wrote on Saturday, July 26, 2014:

Hint #1: Ayman al-Zawahiri (Ophthalmologist & leader of Al Qaeda).

Hint #2: the day mosque is attended.

blankev wrote on Saturday, July 26, 2014:

fsgl wrote on Saturday, July 26, 2014:

The reason the OP is off on Friday is for the same reason Christians attend church on Sunday.

Nothing disrespectful of Islam was implied or expressed. I purposefully added Dr. al-Zawahiri’s Ophthalmological background to underscore that point.

There is no reason to delete my post.

blankev wrote on Saturday, July 26, 2014:

Hwat is the connection “Al Queda” and OpenEMR? Please explain.

cmswest wrote on Saturday, July 26, 2014:

almost, try below, # sign comments out the code:

on the 2nd point, it looks like Brady created a eng subfolder for translations, etc.

same approach could be used to add one for l’afrique if in demand


/**
* __increment()
* returns the next valid date for an event based on the
* current day,month,year,freq and type
* @private
* @returns string YYYY-MM-DD
*/
function &__increment($d,$m,$y,$f,$t)
{
    if($t == REPEAT_EVERY_DAY) {
        return date('Y-m-d',mktime(0,0,0,$m,($d+$f),$y));
    } elseif($t == REPEAT_EVERY_WORK_DAY) {
        // 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 == "Fri") { $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 == "Fri") { $f++; }
#        else if ($nextWorkDOW == "Sun") { $f++; }

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

    } elseif($t == REPEAT_EVERY_WEEK) {
        return date('Y-m-d',mktime(0,0,0,$m,($d+(7*$f)),$y));
    } elseif($t == REPEAT_EVERY_MONTH) {
        return date('Y-m-d',mktime(0,0,0,($m+$f),$d,$y));
    } elseif($t == REPEAT_EVERY_YEAR) {
        return date('Y-m-d',mktime(0,0,0,$m,$d,($y+$f)));
    }
}
//==================================================================================================

ayman-sa wrote on Saturday, July 26, 2014:

Dears fsgl, Stephen Waite, Peter W.

Many thanks for your help and contribution, the problem has been solved.

Your posts was very helpful.

and thanks for Mr. Moiz.

The attachments shows the modification.

by the way I am Ayman Sa,not Ayman Al zawahry…loool

Ayman.