public function listReccuringTasks() { include "include_reccuringtasks_js.php"; $USERNAME = $_SESSION["uname"]; $sqltoExecute = "select * from RECCURING_TASKS where RT_createdby = '{$USERNAME}' order by RTID desc"; $query = mysql_query($sqltoExecute) or die("Invalid query: " . mysql_error()); $stcount = @mysql_num_rows($query); if ($stcount == 0) { ?> <div style='clear:both; margin-top:40px; margin-left: auto; margin-right:auto; width:96%;'> <span class='bluebuttonSmall' onclick='show_ReccuringTaskForm();'>New Recurring Task</span> </div> <div class='nonewtasks'>Recurring Tasks </div> <?php return; } ?> <div class='listOfReccuringTasks' style='margin-top:50px;'> <span class='listofReccuringTasksSpan' onclick=" $('.ReccuringTasksTable').toggle();">Recurring Tasks (<?php echo $stcount; ?> )</span> <span class='bluebuttonSmall' onclick='show_ReccuringTaskForm();'>New Recurring Task</span> </div> <table align=center cellpadding=0 cellspacing=0 class="ReccuringTasksTable"> <TR class="firstRow"> <TD width="100" align='right' style='cursor:pointer;'> <span style='margin-right:20px;'>RTask ID</span> </TD> <TD width="125" style='cursor:pointer;'>Assigned To</TD> <TD width="145" style='cursor:pointer;'>Project </TD> <TD style='cursor:pointer;'> Task Description </TD> <TD>Occurrence</TD> <TD style='cursor:pointer;' width="130"> </TD> </TR> <?php $tdclass = "oddrow"; while ($row = @mysql_fetch_array($query)) { extract($row); // `RTID`, `RT_project`, `RT_assignto`, `RT_createdby`, `RT_createdDate`, `RT_Desc`, `RT_isPrivate`, `RT_startdate`, // `RT_enddate`, `RT_type`, `RT_EVERYNDAYS`, `RT_EVERYNTHDAYOFMONTH`, `RT_EVERYXWEEKDAY`, `RT_EVERYDAYOFYEAR_MONTH` $tdclass = $tdclass == "oddrow" ? 'evenrow' : 'oddrow'; switch ($RT_type) { case "W": $tmp_occurance = 'On every ' . week_short_toLong($RT_EVERYXWEEKDAY); break; case "N": $tmp_occurance = 'Every <B>' . $RT_EVERYNDAYS . " days</B> starting " . caldate_to_human($RT_startdate); break; case "M": $tmp_occurance = 'On <B>' . dayofmonth_to_daywithsuffix($RT_EVERYNTHDAYOFMONTH) . "</B> of every month"; break; case "Y": $tmp_occurance = 'On <B>' . month_short_toLong($RT_EVERYDAYOFYEAR_MONTH) . ' ' . dayofmonth_to_daywithsuffix($RT_EVERYNTHDAYOFMONTH) . " </B> of every year"; break; default: $tmp_occurance = ' ? '; break; } echo "\n\t\t\t<TR class='RCCRT_TR_{$RTID} {$tdclass}'>\n\t\t\t\t<TD align='right'><span style='margin-right:20px;'>{$RTID}</span></TD>\n\t\t\t\t<TD>{$RT_assignto}</TD>\n\t\t\t\t<TD>{$RT_project}</TD>\n\t\t\t\t<TD>{$RT_Desc}</TD>\n\t\t\t\t<TD>{$tmp_occurance}</TD>\n\t\t\t\t<TD>\n\t\t\t\t\t<span class='bluebuttonSmall' onclick=\"delete_recurringtask('{$RTID}')\">Delete</span>\n\t\t\t\t</TD>\n\t\t\t</TR>"; } echo "</table>"; }
?> </select> </label> </TD> </TR> <TR> <TD align="right"></TD> <TD colspan=3> <label> <input type='radio' id='nrt_frq_weekday_radio' name='nrt_frq_raadio'> Every <select id='nrt_frq_weekday'> <?php foreach (array('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun') as $wday) { echo "<option value='{$wday}'>" . week_short_toLong($wday) . "</option>"; } ?> </select> </label> </TD> </TR> <TR> <TD align="right"></TD> <TD colspan=3> <label> <input type='radio' id='nrt_frq_ndays_radio' name='nrt_frq_raadio'> Every <input size=2 id='nrt_frq_ndays'> days </label> </TD>
function get_DateInstances_inTimeRange($inputInfo) { /* $inputInfo = array( 'StartDate'=>'2009-12-01', 'EndDate'=>'2010-11-25', 'RT_EVERYNTHDAYOFMONTH'=>'22' , 'RT_EVERYDAYOFYEAR_MONTH '=>'jun' , 'RT_EVERYNDAYS'=> '90' , 'RT_EVERYXWEEKDAY' => 'tue', 'nrt_type' => 'W' // W, M , N , Y ); */ $caldate_begin = $inputInfo['StartDate']; $caldate_end = $inputInfo['EndDate']; $DATE_INSTANCES = array(); $ALLMONTHS = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'); $caldate_begin_parts = explode("-", $caldate_begin); $unixtime_begin = mktime(0, 0, 0, $caldate_begin_parts[1], $caldate_begin_parts[2], $caldate_begin_parts[0]); $caldate_end_parts = explode("-", $caldate_end); $unixtime_end = mktime(0, 0, 0, $caldate_end_parts[1], $caldate_end_parts[2], $caldate_end_parts[0]); switch ($inputInfo['nrt_type']) { case "W": $unixtime_instance = strtotime("next " . week_short_toLong($inputInfo['RT_EVERYXWEEKDAY']), $unixtime_begin); $first_instance = $unixtime_instance - 24 * 60 * 60 * 7; if ($first_instance <= $unixtime_instance && $first_instance <= $unixtime_end) { $DATE_INSTANCES[] = date("Y-m-d", $first_instance); } while ($unixtime_begin <= $unixtime_instance && $unixtime_instance <= $unixtime_end) { $DATE_INSTANCES[] = date("Y-m-d", $unixtime_instance); $unixtime_instance = $unixtime_instance + 24 * 60 * 60 * 7; } return $DATE_INSTANCES; break; case "M": // on 5th of every month // on 5th of every month case "Y": // on 5th of every January // get all years in the range $YEARSINRANGE = array(); $TMP_YEAR = (int) $caldate_begin_parts[0]; $TMP_FINALYEAR = (int) $caldate_end_parts[0]; while ($TMP_YEAR <= $TMP_FINALYEAR) { $YEARSINRANGE[] = $TMP_YEAR; $TMP_YEAR++; } // push into instances array if xth of Januray in each year falls in our range foreach ($YEARSINRANGE as $TMP_YEAR) { if ($inputInfo['nrt_type'] == 'M') { foreach ($ALLMONTHS as $FORTHISMONTH) { $unixtime_instance = mktime(0, 0, 0, $FORTHISMONTH, $inputInfo['RT_EVERYNTHDAYOFMONTH'], $TMP_YEAR); if ($unixtime_begin <= $unixtime_instance && $unixtime_instance <= $unixtime_end) { $DATE_INSTANCES[] = date("Y-m-d", $unixtime_instance); } } } else { $unixtime_instance = mktime(0, 0, 0, month_short_toNumber($inputInfo['RT_EVERYDAYOFYEAR_MONTH']), $inputInfo['RT_EVERYNTHDAYOFMONTH'], $TMP_YEAR); if ($unixtime_begin <= $unixtime_instance && $unixtime_instance <= $unixtime_end) { $DATE_INSTANCES[] = date("Y-m-d", $unixtime_instance); } } } return $DATE_INSTANCES; break; case "N": // $unixtime_instance = $unixtime_begin // while ($unixtime_instance is in range) // push $unixtime_instance into instances array // $unixtime_instance = Add n days number of seconds to $unixtime_instance // $RT_EVERYNDAYS = (int) $inputInfo['RT_EVERYNDAYS']; $unixtime_instance = $unixtime_begin; while ($unixtime_begin < $unixtime_instance && $unixtime_instance < $unixtime_end) { $DATE_INSTANCES[] = date("Y-m-d", $unixtime_instance); $unixtime_instance = $unixtime_instance + 24 * 60 * 60 * $RT_EVERYNDAYS; } return $DATE_INSTANCES; break; } }