View ProjeQtOr On SourceForge.net
ProjeQtOr - Project Management Tool
Support us on Capterra
OIN - Open Invention Network
ProjeQtOr free project management software - [SOLVED] isOpenDay function in projeqtor.php - ProjeQtOr
 
 

[SOLVED] isOpenDay function in projeqtor.php

More
06 Jul 2016 17:11 #1 by keloniton
Hello Dear Mr. Babynus
Good day. How are you?
I want to change the off day from Saturday to Friday. I appreciate to know your idea about my following code which doesn't work correctly. This code declares all of the week days as off days. I just want to declare Friday as off day.
in tool/projeqtor.php:

function isOpenDay($dateValue, $idCalendarDefinition = '1') {
global $bankHolidays, $bankWorkdays;
$paramDefaultLocale = Parameter::getGlobalParameter ( 'paramDefaultLocale' );
$iDate = strtotime ( $dateValue );
$year = date ( 'Y', $iDate );
if (! $idCalendarDefinition)
$idCalendarDefinition = 1;
if (array_key_exists ( $year . '#' . $idCalendarDefinition, $bankWorkdays )) {
$aBankWorkdays = $bankWorkdays [$year . '#' . $idCalendarDefinition];
} else {
$cal = new Calendar ();
$crit = array (
'year' => $year,
'isOffDay' => '0',
'idCalendarDefinition' => $idCalendarDefinition
);
$aBankWorkdays = array ();
$lstCal = $cal->getSqlElementsFromCriteria ( $crit );
foreach ( $lstCal as $obj ) {
$aBankWorkdays [] = $obj->day;
}
$bankWorkdays [$year . '#' . $idCalendarDefinition] = $aBankWorkdays;
}
if (array_key_exists ( $year . '#' . $idCalendarDefinition, $bankHolidays )) {
$aBankHolidays = $bankHolidays [$year . '#' . $idCalendarDefinition];
} else {
$cal = new Calendar ();
$crit = array (
'year' => $year,
'isOffDay' => '1',
'idCalendarDefinition' => $idCalendarDefinition
);
$aBankHolidays = array ();
$lstCal = $cal->getSqlElementsFromCriteria ( $crit );
foreach ( $lstCal as $obj ) {
$aBankHolidays [] = $obj->day;
}
$bankHolidays [$year . '#' . $idCalendarDefinition] = $aBankHolidays;
}
// I HAVE ADDED THIS PART
if (date ( 'w', $iDate ) != 5) { // If it is not Friday
if (in_array ( date ( 'Ymd', $iDate ), $aBankWorkdays )) { //if it is a working day
return true; //tell me this is openday
} else { //if it is not a working day
return false;
}
} else { //if it is Friday
return false;
}
}

Please Log in or Create an account to join the conversation.

More
06 Jul 2016 20:14 #2 by babynus
Better use the calendar feature : storing lines in calandar table for off days and opened saturdays or sundays, will automatically fill sbankHolidays (for extra off days) and $bankWorkDays (for worked week-ends)

Babynus
Administrator of ProjeQtOr web site

Please Log in or Create an account to join the conversation.

Moderators: babynusprotion
Time to create page: 0.045 seconds

Cookies settings

×

Functional Cookies

Ce site utilise des cookies pour assurer son bon fonctionnement et ne peuvent pas être désactivés de nos systèmes. Nous ne les utilisons pas à des fins publicitaires. Si ces cookies sont bloqués, certaines parties du site ne pourront pas fonctionner.

Session

Please login to see yours activities!

Other cookies

Ce site web utilise un certain nombre de cookies pour gérer, par exemple, les sessions utilisateurs.