PM-2917 "Case Scheduler issues" SOLVED
Issue:
Case Scheduler issues
Cause:
No se considero ciertas combinaciones de configuracion para: Daily, Monthly
Solution:
- Se mejoro los metodos/algoritmos involucrados para la "generacion de la siguiente fecha de ejecucion"
- Se reviso todas las opciones de configuracion: Daily, Weekly, Monthly, One time only, Every
This commit is contained in:
@@ -600,164 +600,111 @@ class CaseScheduler extends BaseCaseScheduler
|
|||||||
$this->Update( $Fields );
|
$this->Update( $Fields );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateNextRun($sOption, $sValue = "", $sActualTime = "", $sDaysPerformTask = "", $sWeeks = "", $sStartDay = "", $sMonths = "", $currentDate = "", $flagOptionWeeklyNextRun = true)
|
public function updateNextRun($option, $optionMonth = "", $date = "", $daysPerformTask = "", $weeks = "", $startDay = "", $months = "", $currentDate = "", $flagNoTodayForNextRun = true)
|
||||||
{
|
{
|
||||||
$nActualDate = $currentDate . " " . $sActualTime;
|
try {
|
||||||
$dEstimatedDate = '';
|
$dateNextRun = "";
|
||||||
$sWeeks = trim($sWeeks, " |");
|
|
||||||
|
|
||||||
switch ($sOption) {
|
$currentDate = trim($currentDate . " " . $date); //$date and $currentDate are the same
|
||||||
case '1':
|
$weeks = trim($weeks, " |");
|
||||||
switch ($sValue) {
|
$months = trim($months, " |");
|
||||||
case '1':
|
|
||||||
$dEstimatedDate = date( 'Y-m-d H:i:s', strtotime( "$nActualDate +1 day" ) );
|
|
||||||
break;
|
|
||||||
case '2':
|
|
||||||
$nDayOfTheWeek = date( 'w', strtotime( $sActualTime ) );
|
|
||||||
$nDayOfTheWeek = ($nDayOfTheWeek == 0) ? 7 : $nDayOfTheWeek;
|
|
||||||
|
|
||||||
if ($nDayOfTheWeek >= 5) {
|
$arrayMonthsShort = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
|
||||||
$dEstimatedDate = date( 'Y-m-d H:i:s', strtotime( "$nActualDate +3 day" ) );
|
$arrayWeekdays = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
|
||||||
} else {
|
|
||||||
$dEstimatedDate = date( 'Y-m-d H:i:s', strtotime( "$nActualDate +1 day" ) );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '3':
|
|
||||||
$dEstimatedDate = date( 'Y-m-d H:i:s', strtotime( "$nActualDate + " . $sDaysPerformTask . " day" ) );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '2':
|
|
||||||
if ($sWeeks != "") {
|
|
||||||
$aDaysWeek = array ('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
|
|
||||||
|
|
||||||
$nDayOfTheWeek = (int)(date("w", strtotime($sActualTime)));
|
switch ((int)($option)) {
|
||||||
$nDayOfTheWeek = ($nDayOfTheWeek == 0)? 7 : $nDayOfTheWeek;
|
case 1:
|
||||||
|
//Daily
|
||||||
|
$dateNextRun = date("Y-m-d H:i:s", strtotime(($flagNoTodayForNextRun)? "$currentDate +1 day" : $currentDate));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
//Weekly
|
||||||
|
if ($weeks != "") {
|
||||||
|
$weekday = (int)(date("w", strtotime($date)));
|
||||||
|
$weekday = ($weekday == 0)? 7 : $weekday;
|
||||||
|
|
||||||
$arrayWeekdays = explode("|", $sWeeks);
|
$arrayWeekdaysData = explode("|", $weeks);
|
||||||
$firstDay = (int)($arrayWeekdays[0]);
|
|
||||||
$lastDay = (int)($arrayWeekdays[count($arrayWeekdays) - 1]);
|
|
||||||
|
|
||||||
$flagFound1 = $nDayOfTheWeek < $firstDay || in_array($nDayOfTheWeek, $arrayWeekdays);
|
$firstWeekday = (int)($arrayWeekdaysData[0]);
|
||||||
$flagFound2 = ($flagFound1)? false : ($firstDay <= $nDayOfTheWeek && $nDayOfTheWeek <= $lastDay);
|
|
||||||
|
|
||||||
if ($flagFound1 || $flagFound2) {
|
$nextWeekday = $firstWeekday;
|
||||||
$typeStatement = "this";
|
$typeStatement = "this";
|
||||||
|
$flag = false;
|
||||||
|
|
||||||
if ($flagFound1) {
|
foreach ($arrayWeekdaysData as $value) {
|
||||||
$indexDay = (in_array($nDayOfTheWeek, $arrayWeekdays))? $nDayOfTheWeek : $firstDay;
|
$d = (int)($value);
|
||||||
|
|
||||||
if ($flagOptionWeeklyNextRun) {
|
if ((!$flagNoTodayForNextRun && $d >= $weekday) || ($flagNoTodayForNextRun && $d > $weekday)) {
|
||||||
$index = array_search($nDayOfTheWeek, $arrayWeekdays);
|
$nextWeekday = $d;
|
||||||
|
$flag = true;
|
||||||
if ($index !== false && isset($arrayWeekdays[$index + 1])) {
|
break;
|
||||||
$indexDay = $arrayWeekdays[$index + 1];
|
|
||||||
} else {
|
|
||||||
$typeStatement = "next";
|
|
||||||
$indexDay = $firstDay;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($flagFound2) {
|
if (!$flag) {
|
||||||
$indexDay = $firstDay;
|
$typeStatement = "next";
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($arrayWeekdays as $value) {
|
$dateNextRun = date("Y-m-d", strtotime($currentDate . " " . $typeStatement . " " . $arrayWeekdays[$nextWeekday - 1])) . " " . date("H:i:s", strtotime($date));
|
||||||
$day = (int)($value);
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
//Monthly
|
||||||
|
if ($months != "") {
|
||||||
|
$year = (int)(date("Y", strtotime($date)));
|
||||||
|
$month = (int)(date("m", strtotime($date)));
|
||||||
|
|
||||||
if ($day > $nDayOfTheWeek) {
|
$arrayStartDay = explode("|", $startDay);
|
||||||
$indexDay = $day;
|
$arrayMonthsData = explode("|", $months);
|
||||||
break;
|
|
||||||
}
|
$firstMonth = (int)($arrayMonthsData[0]);
|
||||||
|
|
||||||
|
$nextMonth = $firstMonth;
|
||||||
|
$flag = false;
|
||||||
|
|
||||||
|
foreach ($arrayMonthsData as $value) {
|
||||||
|
$m = (int)($value);
|
||||||
|
|
||||||
|
if ((!$flagNoTodayForNextRun && $m >= $month) || ($flagNoTodayForNextRun && $m > $month)) {
|
||||||
|
$nextMonth = $m;
|
||||||
|
$flag = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$indexDay--;
|
if (!$flag) {
|
||||||
|
$year++;
|
||||||
|
}
|
||||||
|
|
||||||
$dEstimatedDate = date("Y-m-d", strtotime($nActualDate . " " . $typeStatement . " " . $aDaysWeek[$indexDay])) . " " . date("H:i:s", strtotime($sActualTime));
|
switch ((int)($optionMonth)) {
|
||||||
} else {
|
case 1:
|
||||||
$nEveryDays = $sDaysPerformTask;
|
$day = (int)($arrayStartDay[1]);
|
||||||
|
|
||||||
$typeStatement = ($firstDay >= $nDayOfTheWeek || $nEveryDays == 1)? "next" : "last";
|
$dateNextRun = date("Y-m-d", strtotime("$year-$nextMonth-$day")) . " " . date("H:i:s", strtotime($date));
|
||||||
$indexDay = $firstDay - 1;
|
break;
|
||||||
|
case 2:
|
||||||
|
$arrayFormat = array(
|
||||||
|
1 => "+0 week %s %s %d", //First
|
||||||
|
2 => "+1 week %s %s %d", //Second
|
||||||
|
3 => "+2 week %s %s %d", //Third
|
||||||
|
4 => "+3 week %s %s %d", //Fourth
|
||||||
|
5 => "last %s of %s %d" //Last
|
||||||
|
);
|
||||||
|
|
||||||
if ($nEveryDays == 1) {
|
$day = (int)($arrayStartDay[2]);
|
||||||
$dEstimatedDate = date("Y-m-d", strtotime($nActualDate . " " . $typeStatement . " " . $aDaysWeek[$indexDay])) . " " . date("H:i:s", strtotime($sActualTime));
|
|
||||||
} else {
|
$dateNextRun = date("Y-m-d", strtotime(sprintf($arrayFormat[(int)($arrayStartDay[1])], $arrayWeekdays[$day - 1], $arrayMonthsShort[$nextMonth - 1], $year))) . " " . date("H:i:s", strtotime($date));
|
||||||
$nEveryDays = 1;
|
break;
|
||||||
$nDataTmp = date( 'Y-m-d', strtotime( "$nActualDate + " . $nEveryDays . " Week" ) );
|
|
||||||
$dEstimatedDate = date("Y-m-d", strtotime($nDataTmp . " " . $typeStatement . " " . $aDaysWeek[$indexDay])) . " " . date("H:i:s", strtotime($sActualTime));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
}
|
||||||
case '3':
|
|
||||||
if (strlen( $sMonths ) > 0) {
|
|
||||||
// Must have at least one selected month
|
|
||||||
// Calculamos para la siguiente ejecucion, acorde a lo seleccionado
|
|
||||||
$aStartDay = explode( '|', $sStartDay );
|
|
||||||
$nYear = date( "Y", strtotime( $sActualTime ) );
|
|
||||||
$nCurrentMonth = date( "m", strtotime( $sActualTime ) );
|
|
||||||
$nCurrentDay = date( "d", strtotime( $sActualTime ) );
|
|
||||||
$aMonths = explode( '|', $sMonths );
|
|
||||||
|
|
||||||
$nSW = 0;
|
//Return
|
||||||
$nNextMonth = 0;
|
return $dateNextRun;
|
||||||
foreach ($aMonths as $value) {
|
} catch (Exception $e) {
|
||||||
if ($value > $nCurrentMonth) {
|
throw $e;
|
||||||
$nNextMonth = $value - 1;
|
|
||||||
$nSW = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($nSW == 1) {
|
|
||||||
$nExecNextMonth = $nNextMonth;
|
|
||||||
} else {
|
|
||||||
$nExecNextMonth = $aMonths[0] - 1;
|
|
||||||
$nYear ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($sValue) {
|
|
||||||
case '1':
|
|
||||||
$nExecNextMonth ++;
|
|
||||||
$nCurrentDay = $aStartDay[1];
|
|
||||||
$dEstimatedDate = date( 'Y-m-d', strtotime( "$nYear-$nExecNextMonth-$nCurrentDay" ) ) . ' ' . date( 'H:i:s', strtotime( $sActualTime ) );
|
|
||||||
break;
|
|
||||||
case '2':
|
|
||||||
$aMontsShort = array ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
|
|
||||||
$aWeeksShort = array ('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
|
|
||||||
$sNumDayWeek = $aStartDay[1];
|
|
||||||
$sDayWeek = ($aStartDay[2] == 7 ? 0 : $aStartDay[2]);
|
|
||||||
switch ($sNumDayWeek) {
|
|
||||||
case '1':
|
|
||||||
$sDaysWeekOpt = "+0";
|
|
||||||
break;
|
|
||||||
case '2':
|
|
||||||
$sDaysWeekOpt = "+1";
|
|
||||||
break;
|
|
||||||
case '3':
|
|
||||||
$sDaysWeekOpt = "+2";
|
|
||||||
break;
|
|
||||||
case '4':
|
|
||||||
$sDaysWeekOpt = "+3";
|
|
||||||
break;
|
|
||||||
case '5':
|
|
||||||
$sDaysWeekOpt = "-1";
|
|
||||||
$nExecNextMonth ++;
|
|
||||||
if ($nExecNextMonth >= 12) {
|
|
||||||
$nExecNextMonth = 0;
|
|
||||||
$nYear ++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$dEstimatedDate = date( 'Y-m-d', strtotime( $sDaysWeekOpt . ' week ' . $aWeeksShort[$sDayWeek - 1] . ' ' . $aMontsShort[$nExecNextMonth] . ' ' . $nYear ) ) . ' ' . date( 'H:i:s', strtotime( $sActualTime ) );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return $dEstimatedDate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Exists ($sUid)
|
public function Exists ($sUid)
|
||||||
@@ -836,44 +783,34 @@ class CaseScheduler extends BaseCaseScheduler
|
|||||||
public function getTimeNextRunByDate(array $arrayCaseSchedulerData, $date, $flagUpdateTimeNextRun = true)
|
public function getTimeNextRunByDate(array $arrayCaseSchedulerData, $date, $flagUpdateTimeNextRun = true)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$arrayNextDate = array();
|
|
||||||
|
|
||||||
//Get date
|
|
||||||
$caseSchedulerOption = (int)($arrayCaseSchedulerData["SCH_OPTION"]);
|
$caseSchedulerOption = (int)($arrayCaseSchedulerData["SCH_OPTION"]);
|
||||||
$caseSchedulerTimeNextRun = $arrayCaseSchedulerData["SCH_TIME_NEXT_RUN"];
|
$caseSchedulerTimeNextRun = $arrayCaseSchedulerData["SCH_TIME_NEXT_RUN"];
|
||||||
|
$caseSchedulerStartTime = date("H:i:s", strtotime($arrayCaseSchedulerData["SCH_START_TIME"]));
|
||||||
|
|
||||||
list($value, $daysPerformTask, $weeks, $startDay, $months) = $this->getVariablesFromRecord($arrayCaseSchedulerData);
|
list($value, $daysPerformTask, $weeks, $startDay, $months) = $this->getVariablesFromRecord($arrayCaseSchedulerData);
|
||||||
|
|
||||||
$timeDate = strtotime($date); //Current time
|
$timeDate = strtotime($date); //Current time
|
||||||
$timeCaseSchedulerTimeNextRun = strtotime($caseSchedulerTimeNextRun);
|
|
||||||
|
|
||||||
$flagTimeNextRun = false;
|
$flagTimeNextRun = true;
|
||||||
$flagUpdate = false;
|
$flagUpdate = false;
|
||||||
|
|
||||||
if ($caseSchedulerOption != 1) {
|
switch ($caseSchedulerOption) {
|
||||||
//Others
|
case 1:
|
||||||
$flagTimeNextRun = true;
|
case 2:
|
||||||
} else {
|
case 3:
|
||||||
//Daily
|
//Daily
|
||||||
$arrayDate = array(
|
//Weekly
|
||||||
date("Y-m-d", strtotime($arrayCaseSchedulerData["SCH_START_DATE"])) . " " . date("H:i:s", $timeCaseSchedulerTimeNextRun),
|
//Monthly
|
||||||
date("Y-m-d", $timeDate) . " " . date("H:i:s", $timeCaseSchedulerTimeNextRun)
|
$caseSchedulerTimeNextRun = date("Y-m-d", strtotime($arrayCaseSchedulerData["SCH_START_DATE"])) . " " . $caseSchedulerStartTime;
|
||||||
);
|
$caseSchedulerTimeNextRun = $this->updateNextRun($caseSchedulerOption, $value, $caseSchedulerTimeNextRun, $daysPerformTask, $weeks, $startDay, $months, "", false);
|
||||||
|
|
||||||
$flagTimeNextRun = true;
|
$timeCaseSchedulerTimeNextRun = strtotime($caseSchedulerTimeNextRun);
|
||||||
|
|
||||||
foreach ($arrayDate as $d) {
|
|
||||||
$caseSchedulerTimeNextRun2 = $d;
|
|
||||||
$timeCaseSchedulerTimeNextRun2 = strtotime($caseSchedulerTimeNextRun2);
|
|
||||||
|
|
||||||
if ($timeDate < $timeCaseSchedulerTimeNextRun2) {
|
|
||||||
$caseSchedulerTimeNextRun = $caseSchedulerTimeNextRun2;
|
|
||||||
|
|
||||||
|
if ($timeCaseSchedulerTimeNextRun > $timeDate) {
|
||||||
$flagTimeNextRun = false;
|
$flagTimeNextRun = false;
|
||||||
$flagUpdate = true;
|
$flagUpdate = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($flagTimeNextRun) {
|
if ($flagTimeNextRun) {
|
||||||
@@ -884,7 +821,7 @@ class CaseScheduler extends BaseCaseScheduler
|
|||||||
//Daily
|
//Daily
|
||||||
//Weekly
|
//Weekly
|
||||||
//Monthly
|
//Monthly
|
||||||
$caseSchedulerTimeNextRun = date("Y-m-d", $timeDate) . " " . date("H:i:s", $timeCaseSchedulerTimeNextRun);
|
$caseSchedulerTimeNextRun = date("Y-m-d", $timeDate) . " " . $caseSchedulerStartTime;
|
||||||
$caseSchedulerTimeNextRun = $this->updateNextRun($caseSchedulerOption, $value, $caseSchedulerTimeNextRun, $daysPerformTask, $weeks, $startDay, $months, "", false);
|
$caseSchedulerTimeNextRun = $this->updateNextRun($caseSchedulerOption, $value, $caseSchedulerTimeNextRun, $daysPerformTask, $weeks, $startDay, $months, "", false);
|
||||||
|
|
||||||
$timeCaseSchedulerTimeNextRun = strtotime($caseSchedulerTimeNextRun);
|
$timeCaseSchedulerTimeNextRun = strtotime($caseSchedulerTimeNextRun);
|
||||||
@@ -895,7 +832,7 @@ class CaseScheduler extends BaseCaseScheduler
|
|||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
//One time only
|
//One time only
|
||||||
$caseSchedulerTimeNextRun = date("Y-m-d", $timeDate) . " " . date("H:i:s", $timeCaseSchedulerTimeNextRun);
|
$caseSchedulerTimeNextRun = date("Y-m-d", $timeDate) . " " . $caseSchedulerStartTime;
|
||||||
|
|
||||||
$timeCaseSchedulerTimeNextRun = strtotime($caseSchedulerTimeNextRun);
|
$timeCaseSchedulerTimeNextRun = strtotime($caseSchedulerTimeNextRun);
|
||||||
|
|
||||||
|
|||||||
@@ -897,7 +897,6 @@ class CaseScheduler
|
|||||||
$sDaysPerformTask = "";
|
$sDaysPerformTask = "";
|
||||||
$sWeeks = "";
|
$sWeeks = "";
|
||||||
$sMonths = "";
|
$sMonths = "";
|
||||||
$sStartDay = "";
|
|
||||||
|
|
||||||
switch ($option) {
|
switch ($option) {
|
||||||
case "INS":
|
case "INS":
|
||||||
@@ -992,7 +991,6 @@ class CaseScheduler
|
|||||||
}
|
}
|
||||||
|
|
||||||
$arrayCaseSchedulerData["SCH_MONTHS"] = $sMonths;
|
$arrayCaseSchedulerData["SCH_MONTHS"] = $sMonths;
|
||||||
$sStartDay = $arrayCaseSchedulerData["SCH_START_DAY"];
|
|
||||||
$sValue = $nStartDay;
|
$sValue = $nStartDay;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1013,123 +1011,33 @@ class CaseScheduler
|
|||||||
$arrayCaseSchedulerData["SCH_END_DATE"] = ($arrayData["SCH_END_DATE"] != "")? $arrayData["SCH_END_DATE"] : null;
|
$arrayCaseSchedulerData["SCH_END_DATE"] = ($arrayData["SCH_END_DATE"] != "")? $arrayData["SCH_END_DATE"] : null;
|
||||||
|
|
||||||
//If the start date has changed then recalculate the next run time
|
//If the start date has changed then recalculate the next run time
|
||||||
$recalculateDate = ($arrayData["SCH_START_DATE"] == $arrayData["PREV_SCH_START_DATE"])? false : true;
|
$recalculateDate = ($arrayData["SCH_START_DATE"] != $arrayData["PREV_SCH_START_DATE"])? true : false;
|
||||||
$recalculateTime = (date("H:i:s", strtotime($arrayData["SCH_START_TIME"])) == date("H:i:s", strtotime($arrayData["PREV_SCH_START_TIME"])))? false : true;
|
$recalculateTime = (date("H:i:s", strtotime($arrayData["SCH_START_TIME"])) != date("H:i:s", strtotime($arrayData["PREV_SCH_START_TIME"])))? true : false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nActualTime = $arrayData["SCH_START_TIME"];
|
switch ($caseSchedulerOption) {
|
||||||
|
case 4:
|
||||||
if ($caseSchedulerOption != 1 && $caseSchedulerOption != 4 && $caseSchedulerOption != 5) {
|
|
||||||
if ($sStartDay == "") {
|
|
||||||
$sStartDay = date("Y-m-d");
|
|
||||||
}
|
|
||||||
|
|
||||||
$dCurrentDay = (int)(date("d"));
|
|
||||||
$dCurrentMonth = (int)(date("m"));
|
|
||||||
|
|
||||||
$aStartDay = ($caseSchedulerOption == 3)? explode("|", $arrayCaseSchedulerData["SCH_START_DAY"]) : array();
|
|
||||||
|
|
||||||
if ($caseSchedulerOption == 3 && $aStartDay[0] == "1") {
|
|
||||||
$monthsArray = explode("|", $sMonths);
|
|
||||||
|
|
||||||
foreach ($monthsArray as $row) {
|
|
||||||
switch ($option) {
|
|
||||||
case "INS":
|
|
||||||
if ((int)($row) == $dCurrentMonth && $dCurrentDay <= (int)($aStartDay[1])) {
|
|
||||||
$startTime = $arrayData["SCH_START_TIME"] . ":00";
|
|
||||||
$arrayCaseSchedulerData["SCH_TIME_NEXT_RUN"] = date("Y") . "-" . $row . "-" . $aStartDay[1] . " " . $startTime;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
$arrayCaseSchedulerData["SCH_TIME_NEXT_RUN"] = $caseScheduler->updateNextRun($caseSchedulerOption, $sValue, $nActualTime, $sDaysPerformTask, $sWeeks, $sStartDay, $sMonths, $sDateTmp, false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "UPD":
|
|
||||||
if ($dCurrentMonth == $row && $dCurrentDay < $aStartDay[1]) {
|
|
||||||
$startTime = $arrayData["SCH_START_TIME"] . ":00";
|
|
||||||
|
|
||||||
if ($recalculateDate) {
|
|
||||||
$arrayCaseSchedulerData["SCH_TIME_NEXT_RUN"] = date("Y") . "-" . $row . "-" . $aStartDay[1] . " " . $startTime;
|
|
||||||
} else {
|
|
||||||
if ($recalculateTime) {
|
|
||||||
$arrayCaseSchedulerData["SCH_TIME_NEXT_RUN"] = $caseScheduler->getSchTimeNextRun("Y-m-d") . " " . $arrayData["SCH_START_TIME"] . ":00";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
if ($recalculateDate) {
|
|
||||||
$arrayCaseSchedulerData["SCH_TIME_NEXT_RUN"] = $caseScheduler->updateNextRun($caseSchedulerOption, $sValue, $nActualTime, $sDaysPerformTask, $sWeeks, $sStartDay, $sMonths, $sDateTmp, false);
|
|
||||||
} else {
|
|
||||||
if ($recalculateTime) {
|
|
||||||
$arrayCaseSchedulerData["SCH_TIME_NEXT_RUN"] = $caseScheduler->getSchTimeNextRun("Y-m-d") . " " . $arrayData["SCH_START_TIME"] . ":00";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
switch ($option) {
|
|
||||||
case "INS":
|
|
||||||
$arrayCaseSchedulerData["SCH_TIME_NEXT_RUN"] = $caseScheduler->updateNextRun($caseSchedulerOption, $sValue, $nActualTime, $sDaysPerformTask, $sWeeks, $sStartDay, $sMonths, $sDateTmp, false);
|
|
||||||
break;
|
|
||||||
case "UPD":
|
|
||||||
if ($recalculateDate) {
|
|
||||||
$arrayCaseSchedulerData["SCH_TIME_NEXT_RUN"] = $caseScheduler->updateNextRun($caseSchedulerOption, $sValue, $nActualTime, $sDaysPerformTask, $sWeeks, $sStartDay, $sMonths, $sDateTmp, false);
|
|
||||||
} else {
|
|
||||||
if ($recalculateTime) {
|
|
||||||
$arrayCaseSchedulerData["SCH_TIME_NEXT_RUN"] = $caseScheduler->getSchTimeNextRun("Y-m-d") . " " . $arrayData["SCH_START_TIME"] . ":00";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($caseSchedulerOption == 4) {
|
|
||||||
$arrayCaseSchedulerData["SCH_END_DATE"] = $arrayCaseSchedulerData["SCH_START_TIME"];
|
$arrayCaseSchedulerData["SCH_END_DATE"] = $arrayCaseSchedulerData["SCH_START_TIME"];
|
||||||
}
|
break;
|
||||||
|
case 5:
|
||||||
switch ($option) {
|
|
||||||
case "INS":
|
|
||||||
$arrayCaseSchedulerData["SCH_TIME_NEXT_RUN"] = $arrayCaseSchedulerData["SCH_START_TIME"];
|
|
||||||
break;
|
|
||||||
case "UPD":
|
|
||||||
if ($recalculateDate) {
|
|
||||||
$arrayCaseSchedulerData["SCH_TIME_NEXT_RUN"] = $arrayCaseSchedulerData["SCH_START_TIME"];
|
|
||||||
} else {
|
|
||||||
if ($recalculateTime) {
|
|
||||||
$arrayCaseSchedulerData["SCH_TIME_NEXT_RUN"] = $caseScheduler->getSchTimeNextRun("Y-m-d") . " " . $arrayData["SCH_START_TIME"] . ":00";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($caseSchedulerOption == 5) {
|
|
||||||
switch ($option) {
|
switch ($option) {
|
||||||
case "INS":
|
case "INS":
|
||||||
$arrayCaseSchedulerData["SCH_START_TIME"] = time();
|
$arrayCaseSchedulerData["SCH_START_TIME"] = time();
|
||||||
$arrayCaseSchedulerData["SCH_START_DATE"] = $arrayCaseSchedulerData["SCH_START_TIME"];
|
$arrayCaseSchedulerData["SCH_START_DATE"] = $arrayCaseSchedulerData["SCH_START_TIME"];
|
||||||
|
|
||||||
$date = $arrayCaseSchedulerData["SCH_START_TIME"];
|
|
||||||
break;
|
break;
|
||||||
case "UPD":
|
case "UPD":
|
||||||
$date = $caseScheduler->getSchLastRunTime();
|
|
||||||
|
|
||||||
if (is_null($date)) {
|
|
||||||
$date = $caseScheduler->getSchStartTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
$date = strtotime($date);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$arrayCaseSchedulerData["SCH_REPEAT_EVERY"] = $arrayData["SCH_REPEAT_EVERY"];
|
$arrayCaseSchedulerData["SCH_REPEAT_EVERY"] = $arrayData["SCH_REPEAT_EVERY"];
|
||||||
$arrayCaseSchedulerData["SCH_TIME_NEXT_RUN"] = date("Y-m-d H:i:s", $date + (((int)($arrayData["SCH_REPEAT_EVERY"])) * 60 * 60));
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($option) {
|
switch ($option) {
|
||||||
case "INS":
|
case "INS":
|
||||||
|
$arrayCaseSchedulerData["SCH_TIME_NEXT_RUN"] = date("Y-m-d") . " " . (($caseSchedulerOption != 5)? $arrayData["SCH_START_TIME"] . ":00" : date("H:i:s"));
|
||||||
|
|
||||||
if ($arrayData["SCH_END_DATE"] != "") {
|
if ($arrayData["SCH_END_DATE"] != "") {
|
||||||
$arrayCaseSchedulerData["SCH_END_DATE"] = $arrayData["SCH_END_DATE"];
|
$arrayCaseSchedulerData["SCH_END_DATE"] = $arrayData["SCH_END_DATE"];
|
||||||
}
|
}
|
||||||
@@ -1138,13 +1046,13 @@ class CaseScheduler
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($arrayData["SCH_REPEAT_TASK_CHK"])) {
|
//if (!empty($arrayData["SCH_REPEAT_TASK_CHK"])) {
|
||||||
if ($arrayData["SCH_REPEAT_EVERY_OPT"] . "" == "2") {
|
// if ($arrayData["SCH_REPEAT_EVERY_OPT"] . "" == "2") {
|
||||||
$arrayCaseSchedulerData["SCH_REPEAT_EVERY"] = ((int)($arrayData["SCH_REPEAT_EVERY"])) * 60;
|
// $arrayCaseSchedulerData["SCH_REPEAT_EVERY"] = ((int)($arrayData["SCH_REPEAT_EVERY"])) * 60;
|
||||||
} else {
|
// } else {
|
||||||
$arrayCaseSchedulerData["SCH_REPEAT_EVERY"] = (int)($arrayData["SCH_REPEAT_EVERY"]);
|
// $arrayCaseSchedulerData["SCH_REPEAT_EVERY"] = (int)($arrayData["SCH_REPEAT_EVERY"]);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
//Create/Update
|
//Create/Update
|
||||||
$caseSchedulerAux = new \CaseScheduler();
|
$caseSchedulerAux = new \CaseScheduler();
|
||||||
@@ -1193,11 +1101,11 @@ class CaseScheduler
|
|||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
//One time only
|
//One time only
|
||||||
$flagUpdateTimeNextRun = $arrayCaseSchedulerData["SCH_START_TIME"] != $arrayCaseSchedulerDataOld["SCH_START_TIME"];
|
$flagUpdateTimeNextRun = $recalculateTime || $arrayCaseSchedulerData["SCH_START_TIME"] != $arrayCaseSchedulerDataOld["SCH_START_TIME"];
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
//Every
|
//Every
|
||||||
$flagUpdateTimeNextRun = $arrayCaseSchedulerData["SCH_REPEAT_EVERY"] != $arrayCaseSchedulerDataOld["SCH_REPEAT_EVERY"];
|
$flagUpdateTimeNextRun = $option == "INS" || $arrayCaseSchedulerData["SCH_REPEAT_EVERY"] != $arrayCaseSchedulerDataOld["SCH_REPEAT_EVERY"];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,7 @@
|
|||||||
<td class="FormFieldContent">
|
<td class="FormFieldContent">
|
||||||
<table style="width: 100%">
|
<table style="width: 100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 20%">{$form.SCH_START_DAY}</td>
|
<td style="width: 35%">{$form.SCH_START_DAY}</td>
|
||||||
<td> {$SCH_START_DAY_OPT_1} {$form.SCH_START_DAY_OPT_1} <br/>
|
<td> {$SCH_START_DAY_OPT_1} {$form.SCH_START_DAY_OPT_1} <br/>
|
||||||
{$SCH_START_DAY_OPT_2_WEEKS} {$SCH_START_DAY_OPT_2_DAYS_WEEK}
|
{$SCH_START_DAY_OPT_2_WEEKS} {$SCH_START_DAY_OPT_2_DAYS_WEEK}
|
||||||
{$form.SCH_START_DAY_OPT_2_WEEKS} {$form.SCH_START_DAY_OPT_2_DAYS_WEEK} <br/>
|
{$form.SCH_START_DAY_OPT_2_WEEKS} {$form.SCH_START_DAY_OPT_2_DAYS_WEEK} <br/>
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ WHERE A.PRO_UID='@#PRO_UID' AND A.TAS_START = 'TRUE' ]]><en><![CDATA[Task]]></en
|
|||||||
<en><![CDATA[Monthly]]></en>
|
<en><![CDATA[Monthly]]></en>
|
||||||
</SELECT_3>
|
</SELECT_3>
|
||||||
<SCH_START_DAY type="radiogroup" required="0" mode="edit" options="Array">
|
<SCH_START_DAY type="radiogroup" required="0" mode="edit" options="Array">
|
||||||
<en><![CDATA[]]><option name="1"><![CDATA[Day]]></option><option name="2"><![CDATA[The]]></option></en>
|
<en><![CDATA[]]><option name="1"><![CDATA[Day of month]]></option><option name="2"><![CDATA[The day]]></option></en>
|
||||||
</SCH_START_DAY>
|
</SCH_START_DAY>
|
||||||
<SCH_START_DAY_OPT_1 type="text" maxlength="2" validate="Int" mask="##" required="0" readonly="0" defaultvalue="1" size="2" mode="edit">
|
<SCH_START_DAY_OPT_1 type="text" maxlength="2" validate="Int" mask="##" required="0" readonly="0" defaultvalue="1" size="2" mode="edit">
|
||||||
<en><![CDATA[]]></en>
|
<en><![CDATA[]]></en>
|
||||||
@@ -696,7 +696,7 @@ function validateSchedulerFields(oForm) {
|
|||||||
msgBox("@G::LoadTranslation(ID_REQUIRED_NAME_CASE_SCHEDULER)", 'alert');
|
msgBox("@G::LoadTranslation(ID_REQUIRED_NAME_CASE_SCHEDULER)", 'alert');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var listNames = document.getElementById('form[SCH_LIST]').value;
|
var listNames = document.getElementById('form[SCH_LIST]').value;
|
||||||
listNames = listNames.split("^");
|
listNames = listNames.split("^");
|
||||||
for (var i= 1; i<listNames.length; i++) {
|
for (var i= 1; i<listNames.length; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user