function ProperDate($date = '', $length = 'long')
{
    $months_number['JAN'] = '1';
    $months_number['FEB'] = '2';
    $months_number['MAR'] = '3';
    $months_number['APR'] = '4';
    $months_number['MAY'] = '5';
    $months_number['JUN'] = '6';
    $months_number['JUL'] = '7';
    $months_number['AUG'] = '8';
    $months_number['SEP'] = '9';
    $months_number['OCT'] = '10';
    $months_number['NOV'] = '11';
    $months_number['DEC'] = '12';
    if ($date && strlen($date) == 9) {
        $year = substr($date, 7);
        $month = $months_number[strtoupper(substr($date, 3, 3))];
        $day = substr($date, 0, 2) * 1;
        $comment = '<!-- ' . ($year < 50 ? 20 : 19) . $year . MonthNWSwitch(substr($date, 3, 3), 'tonum') . substr($date, 0, 2) . ' -->';
    } elseif ($date) {
        $year = substr($date, 0, 4);
        $month = substr($date, 5, 2) * 1;
        $day = substr($date, 8) * 1;
        $comment = '<!-- ' . $year . substr($date, 5, 2) . substr($date, 8) . ' -->';
    }
    if ((Preferences('MONTH') == 'm' || Preferences('MONTH') == 'M') && (Preferences('DAY') == 'j' || Preferences('DAY') == 'd') && Preferences('YEAR')) {
        $sep = '/';
    } else {
        $sep = ' ';
    }
    if ($date) {
        return date(($length == 'long' || Preferences('MONTH') != 'F' ? Preferences('MONTH') : 'M') . $sep . Preferences('DAY') . $sep . Preferences('YEAR'), mktime(0, 0, 0, $month, $day, $year));
    }
}
Example #2
0
function VerifyDate($date)
{
    /*
    	if(strlen($date)==9) // ORACLE
    	{
    		$day = substr($date,0,2)*1;
    		$month = MonthNWSwitch(substr($date,3,3),'tonum')*1;
    		$year = substr($date,7,2);
    		$year = (($year<50)?20:19) . $year;
    	}
    	elseif(strlen($date)==10) // POSTGRES
    	{
    		$day = substr($date,8,2)*1;
    		$month = substr($date,5,2)*1;
    		$year = substr($date,0,4);
    	}
    	else
    		return false;
    */
    $vdate = explode("-", $date);
    if (count($vdate)) {
        $day = $vdate[0];
        $month = MonthNWSwitch($vdate[1], 'tonum');
        $year = $vdate[2];
        $e_date = '01-' . $month . '-' . $year;
        $num_days = date('t', strtotime($e_date));
        if ($num_days < $day) {
            return false;
        }
    } else {
        return false;
    }
    return checkdate($month, $day, $year);
}
Example #3
0
function date_to_timestamp($date)
{
    $newarr = array();
    foreach ($date as $dt) {
        $arr_date = explode('/', $dt);
        $month = MonthNWSwitch($arr_date[0], 'tonum');
        $day = $arr_date[1];
        $year = $arr_date[2];
        array_push($newarr, mktime(0, 0, 0, $month, $day, $year));
    }
    return $newarr;
}
function VerifyDate($date)
{
    $vdate = explode("-", $date);
    if (count($vdate)) {
        $day = $vdate[0];
        $month = MonthNWSwitch($vdate[1], 'tonum');
        $year = $vdate[2];
        $e_date = '01-' . $month . '-' . $year;
        $num_days = date('t', strtotime($e_date));
        if ($num_days < $day) {
            return false;
        }
    } else {
        return false;
    }
    return checkdate($month, $day, $year);
}
Example #5
0
function VerifyDate($date)
{
    if (strlen($date) == 9) {
        $day = substr($date, 0, 2) + 0;
        $month = MonthNWSwitch(substr($date, 3, 3), 'tonum') + 0;
        $year = substr($date, 7, 2);
        $year = ($year < 50 ? 20 : 19) . $year;
    } elseif (strlen($date) == 10) {
        $day = substr($date, 8, 2) + 0;
        $month = substr($date, 5, 2) + 0;
        $year = substr($date, 0, 4);
    } elseif (strlen($date) == 11) {
        $day = substr($date, 0, 2) + 0;
        $month = MonthNWSwitch(substr($date, 3, 3), 'tonum') + 0;
        $year = substr($date, 7, 4);
    } else {
        return false;
    }
    return checkdate($month, $day, $year);
}
#  This program is released under the terms of the GNU General Public License as
#  published by the Free Software Foundation, version 2 of the License.
#  See license.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#***************************************************************************************
include '../../Redirect_modules.php';
DrawBC("" . _('Attendance') . " > " . ProgramTitle());
$message = '<TABLE><TR><TD colspan=7 align=center>' . _('From') . ' ' . PrepareDate(DBDate(), '_min') . ' ' . _('to') . ' ' . PrepareDate(DBDate(), '_max') . '</TD></TR></TABLE>';
if (Prompt_Home(_('Confirm'), _('When do you want to recalculate the daily attendance?'), $message)) {
    $current_RET = DBGet(DBQuery('SELECT DISTINCT DATE_FORMAT(SCHOOL_DATE,\'%d-%m-%Y\') as SCHOOL_DATE FROM attendance_calendar WHERE SCHOOL_ID=\'' . UserSchool() . '\' AND SYEAR=\'' . UserSyear() . '\''), array(), array('SCHOOL_DATE'));
    $students_RET = GetStuList();
    $begin = mktime(0, 0, 0, MonthNWSwitch($_REQUEST['month_min'], 'to_num'), $_REQUEST['day_min'] * 1, $_REQUEST['year_min']) + 43200;
    $end = mktime(0, 0, 0, MonthNWSwitch($_REQUEST['month_max'], 'to_num'), $_REQUEST['day_max'] * 1, $_REQUEST['year_max']) + 43200;
    for ($i = $begin; $i <= $end; $i += 86400) {
        if ($current_RET[strtoupper(date('d-M-y', $i))]) {
            foreach ($students_RET as $student) {
                UpdateAttendanceDaily($student['STUDENT_ID'], date('d-M-y', $i));
            }
        }
    }
    unset($_REQUEST['modfunc']);
    DrawHeader('<table><tr><td><IMG SRC=assets/check.gif></td><td>' . _('The Daily Attendance for that timeframe has been recalculated.') . '</td></tr></table>');
}
         }
     } else {
         $err_msg = "End date cannot be after {$nm} end date";
         break 2;
     }
 } else {
     if ($dates['END_DATE'] != '') {
         if (strtotime($dates['END_DATE']) <= strtotime($columns['END_DATE'])) {
             $cal_sql = 'SELECT CALENDAR_ID FROM school_calendars WHERE SCHOOL_ID=\'' . UserSchool() . '\' AND SYEAR=\'' . UserSyear() . '\'';
             $calender = DBGet(DBQuery($cal_sql));
             $calender = $calender[1];
             $attendance_calendar = DBGet(DBQuery('SELECT MIN(SCHOOL_DATE) as START_DATE,MAX(SCHOOL_DATE) as END_DATE FROM attendance_calendar WHERE SCHOOL_ID=\'' . UserSchool() . '\' AND SYEAR=\'' . UserSyear() . '\''));
             //
             $vdate = explode("-", $columns['END_DATE']);
             $calender = $calender[1];
             $m = MonthNWSwitch($vdate[1], 'tonum');
             $end_m = $vdate[0] . "-" . $m . "-" . $vdate[1];
             if ($attendance_calendar[1]['END_DATE'] != '' && strtotime($end_m) > strtotime($attendance_calendar[1]['END_DATE'])) {
                 $err_msg = "End date cannot be changed  because the calendar has already been created";
                 break 2;
             }
             if ($value != '') {
                 while (!VerifyDate($value)) {
                     $value = date('d-M-Y', strtotime($value) - 86400);
                 }
                 $sql .= $column . '=\'' . str_replace("'", "''", str_replace("\\'", "'", $value)) . '\',';
                 $go = true;
             }
         } else {
             $err_msg = "End date cannot be before {$nm} end date";
             break 2;
Example #8
0
                echo "<TR><TD>" . button('dot', '0000FF', '', '6') . "</TD><TD> <A HREF=# onclick='javascript:window.open(\"for_window.php?modname={$_REQUEST['modname']}&modfunc=detail&event_id={$event['ID']}&year={$_REQUEST['year']}&month=" . MonthNWSwitch($_REQUEST['month'], 'tochar') . "\",\"blank\",\"width=500,height=300\"); return false;'><b>" . ($event['TITLE'] ? $event['TITLE'] : '***') . "</b></A></TD></TR>";
            }
            if (count($assignments_RET[$date])) {
                foreach ($assignments_RET[$date] as $event) {
                    echo "<TR><TD>" . button('dot', $event['ASSIGNED'] == 'Y' ? '00FF00' : 'FF0000', '', 6) . "</TD><TD><A HREF=# onclick='javascript:window.open(\"for_window.php?modname={$_REQUEST['modname']}&modfunc=detail&assignment_id={$event['ID']}&year={$_REQUEST['year']}&month=" . MonthNWSwitch($_REQUEST['month'], 'tochar') . "\",\"blank\",\"width=500,height=300\"); return false;'>" . $event['TITLE'] . "</A></TD></TR>";
                }
            }
            echo '</TABLE>';
        } elseif (count($assignments_RET[$date])) {
            echo '<TABLE cellpadding=0 cellspacing=0 border=0>';
            foreach ($assignments_RET[$date] as $event) {
                echo "<TR><TD>" . button('dot', $event['ASSIGNED'] == 'Y' ? '00FF00' : 'FF0000', '', 6) . "</TD><TD><A HREF=# onclick='javascript:window.open(\"for_window.php?modname={$_REQUEST['modname']}&modfunc=detail&assignment_id={$event['ID']}&year={$_REQUEST['year']}&month=" . MonthNWSwitch($_REQUEST['month'], 'tochar') . "\",\"blank\",\"width=500,height=300\"); return false;'>" . $event['TITLE'] . "</A></TD></TR>";
            }
            echo '</TABLE>';
        }
        echo "</td></tr>";
        if (AllowEdit()) {
            echo "<tr><td valign=bottom align=left>" . button('add', '', "# onclick='javascript:window.open(\"for_window.php?modname={$_REQUEST['modname']}&modfunc=detail&event_id=new&school_date={$date}&year={$_REQUEST['year']}&month=" . MonthNWSwitch($_REQUEST['month'], 'tochar') . "\",\"blank\",\"width=500,height=300\"); return false;'") . "</td></tr>";
        }
        echo "</table></TD>";
        $return_counter++;
        if ($return_counter % 7 == 0) {
            echo "</TR><TR>";
        }
    }
    echo "</TR></TABLE>";
    echo "</TD></TR></TABLE>";
    echo '<BR>' . SubmitButton('Save', '', 'class=btn_medium');
    echo "</CENTER>";
    echo '</FORM>';
}
Example #9
0
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#***************************************************************************************
include '../../Redirect_modules.php';
define('LANG_RECORDS_ADDED_CONFIRMATION', 'Absence records were added for the selected students.');
define('LANG_CHOOSE_STUDENT_ERROR', 'You must choose at least one period and one student.');
define('LANG_ABSENCE_CODE', 'Absence Code');
define('LANG_ABSENCE_REASON', 'Absence Reason');
//include("languages/English/$_REQUEST[modname]");
if (!$_REQUEST['month']) {
    $_REQUEST['month'] = date("m");
} else {
    $_REQUEST['month'] = MonthNWSwitch($_REQUEST['month'], 'tonum');
}
if (!$_REQUEST['year']) {
    $_REQUEST['year'] = date("Y");
} else {
    $_REQUEST['year'] = $_REQUEST['year'] < 1900 ? '20' . $_REQUEST['year'] : $_REQUEST['year'];
}
//if($_REQUEST['modfunc']=='save')
if (optional_param('modfunc', '', PARAM_NOTAGS) == 'save') {
    if (count($_REQUEST['period']) && count($_REQUEST['student']) && count($_REQUEST['dates'])) {
        foreach ($_REQUEST['period'] as $period_id => $yes) {
            $periods_list .= ",'" . $period_id . "'";
        }
        $periods_list = '(' . substr($periods_list, 1) . ')';
        foreach ($_REQUEST['student'] as $student_id => $yes) {
            $students_list .= ",'" . $student_id . "'";
function _makeNumeric($number, $column)
{
    global $max_min_RET, $chart, $diff, $diff_max, $mins, $THIS_RET, $start_date, $end_date;
    if ($_REQUEST['timeframe'] == 'month') {
        $index = $THIS_RET['TIMEFRAME'] * 1 - MonthNWSwitch($_REQUEST['month_start'], 'tonum') * 1 + 1 + 12 * ($_REQUEST['year_end'] - $_REQUEST['year_start']);
    } elseif ($_REQUEST['timeframe'] == 'SYEAR') {
        $start = GetSyear($start_date);
        $end = GetSyear($end_date);
        $index = 0;
        for ($i = $start; $i <= $end; $i++) {
            $index++;
            if ($i == $THIS_RET['TIMEFRAME']) {
                break;
            }
        }
    }
    if (!$number) {
        $number = 0;
    }
    if ($diff == 0) {
        $chart['chart_data'][0][1] = $number;
        $chart['chart_data'][$index][1]++;
    } elseif ($diff < $diff_max) {
        //$chart['chart_data'][0][((int) $number - (int) $max_min_RET[1]['MIN']+1)] = (int) $number;
        $chart['chart_data'][$index][(int) $number - (int) $max_min_RET[1]['MIN'] + 1]++;
    } else {
        for ($i = 1; $i <= $diff_max; $i++) {
            if ($number >= $mins[$i] && $number < $mins[$i + 1] || $i == $diff_max) {
                $chart['chart_data'][$index][$i]++;
                break;
            }
        }
    }
    return $number;
}
Example #11
0
function PrepareDate($date, $title = '', $allow_na = true, $options = '')
{
    global $_CENTRE;
    if ($options == '') {
        $options = array();
    }
    if (!$options['Y'] && !$options['M'] && !$options['D'] && !$options['C']) {
        $options += array('Y' => true, 'M' => true, 'D' => true, 'C' => true);
    }
    if ($options['short'] == true) {
        $extraM = "style='width:65;' ";
    }
    if ($options['submit'] == true) {
        if ($options['C']) {
            $e = "onchange='document.location.href=\"" . PreparePHP_SELF($_REQUEST, array('month' . $title, 'day' . $title, 'year' . $title)) . "&amp;month{$title}=\"+this.form.month{$title}.value+\"&amp;day{$title}=\"+this.form.day{$title}.value+\"&amp;year{$title}=\"+this.form.year{$title}.value;'";
            $extraM .= $e;
            $extraD .= $e;
            $extraY .= $e;
        } else {
            $extraM .= "onchange='document.location.href=\"" . PreparePHP_SELF($_REQUEST, array('month' . $title)) . "&amp;month{$title}=\"+this.form.month{$title}.value;'";
            $extraD .= "onchange='document.location.href=\"" . PreparePHP_SELF($_REQUEST, array('day' . $title)) . "&amp;day{$title}=\"+this.form.day{$title}.value;'";
            $extraY .= "onchange='document.location.href=\"" . PreparePHP_SELF($_REQUEST, array('year' . $title)) . "&amp;year{$title}=\"+this.form.year{$title}.value;'";
        }
    }
    if ($options['C']) {
        $_CENTRE['PrepareDate']++;
    }
    if (strlen($date) == 9) {
        $day = substr($date, 0, 2);
        $month = substr($date, 3, 3);
        $year = substr($date, 7, 2);
        if ($year == '00' && ($month == '000' && $day == '00')) {
            $year = '0000';
        } else {
            $year = ($year < 50 ? '20' : '19') . $year;
        }
        $return .= '<!-- ' . $year . MonthNWSwitch($month, 'tonum') . $day . ' -->';
    } elseif (strlen($date) == 10) {
        $day = substr($date, 8, 2);
        $month = MonthNWSwitch(substr($date, 5, 2), 'tochar');
        $year = substr($date, 0, 4);
        $return .= '<!-- ' . $year . MonthNWSwitch($month, 'tonum') . $day . ' -->';
    } else {
        $day = substr($date, 0, 2);
        $month = substr($date, 3, 3);
        $year = substr($date, 7, 4);
        $return .= '<!-- ' . $year . MonthNWSwitch($month, 'tonum') . $day . ' -->';
    }
    // MONTH  ---------------
    if ($options['M']) {
        $return .= '<SELECT NAME=month' . $title . ' id=monthSelect' . $_CENTRE['PrepareDate'] . ' SIZE=1 ' . $extraM . '>';
        if ($allow_na) {
            if ($month == '000') {
                $return .= '<OPTION value="" SELECTED>N/A';
            } else {
                $return .= '<OPTION value="">N/A';
            }
        }
        foreach (array('JAN' => _('January'), 'FEB' => _('February'), 'MAR' => _('March'), 'APR' => _('April'), 'MAY' => _('May'), 'JUN' => _('June'), 'JUL' => _('July'), 'AUG' => _('August'), 'SEP' => _('September'), 'OCT' => _('October'), 'NOV' => _('November'), 'DEC' => _('December')) as $key => $name) {
            $return .= '<OPTION VALUE=' . $key . ($month == $key ? ' SELECTED' : '') . '>' . $name;
        }
        $return .= '</SELECT>';
    }
    // DAY  ---------------
    if ($options['D']) {
        $return .= '<SELECT NAME=day' . $title . ' id=daySelect' . $_CENTRE['PrepareDate'] . ' SIZE=1 ' . $extraD . '>';
        if ($allow_na) {
            if ($day == '00') {
                $return .= '<OPTION value="" SELECTED>N/A';
            } else {
                $return .= '<OPTION value="">N/A';
            }
        }
        for ($i = 1; $i <= 31; $i++) {
            if (strlen($i) == 1) {
                $print = '0' . $i;
            } else {
                $print = $i;
            }
            $return .= '<OPTION VALUE=' . $print . ($day == $print ? ' SELECTED' : '') . '>' . $i;
        }
        $return .= '</SELECT>';
    }
    // YEAR  ---------------
    if ($options['Y']) {
        if (!$year || $year == '0000') {
            $begin = date('Y') - 20;
            $end = date('Y') + 5;
        } else {
            $begin = $year - 5;
            $end = $year + 5;
        }
        $return .= '<SELECT NAME=year' . $title . ' id=yearSelect' . $_CENTRE['PrepareDate'] . ' SIZE=1 ' . $extraY . '>';
        if ($allow_na) {
            if ($year == '0000') {
                $return .= '<OPTION value="" SELECTED>N/A';
            } else {
                $return .= '<OPTION value="">N/A';
            }
        }
        for ($i = $begin; $i <= $end; $i++) {
            $return .= '<OPTION VALUE=' . $i . ($year == $i ? ' SELECTED' : '') . '>' . $i;
        }
        $return .= '</SELECT>';
    }
    if ($options['C']) {
        $return .= '<img src="assets/jscalendar/img.gif" id="trigger' . $_CENTRE['PrepareDate'] . '" style="cursor: pointer; cursor:hand; border: 1px solid red;" onmouseover=this.style.background="red"; onmouseout=this.style.background=""; />';
    }
    if ($_REQUEST['_CENTRE_PDF']) {
        $return = ProperDate($date);
    }
    return $return;
}
Example #12
0
function PrepareDateSchedule($date = '', $title = '', $allow_na = true, $options = '')
{
    global $_openSIS;
    if ($options == '') {
        $options = array();
    }
    if (!$options['Y'] && !$options['M'] && !$options['D'] && !$options['C']) {
        $options += array('Y' => true, 'M' => true, 'D' => true, 'C' => true);
    }
    if ($options['short'] == true) {
        $extraM = "style='width:60;' ";
    }
    if ($options['submit'] == true) {
        $tmp_REQUEST['M'] = $tmp_REQUEST['D'] = $tmp_REQUEST['Y'] = $_REQUEST;
        unset($tmp_REQUEST['M']['month' . $title]);
        unset($tmp_REQUEST['D']['day' . $title]);
        unset($tmp_REQUEST['Y']['year' . $title]);
        $extraM .= "onchange='document.location.href=\"" . PreparePHP_SELF($tmp_REQUEST['M']) . "&amp;month{$title}=\"+this.form.month{$title}.value;'";
        $extraD .= "onchange='document.location.href=\"" . PreparePHP_SELF($tmp_REQUEST['D']) . "&amp;day{$title}=\"+this.form.day{$title}.value;'";
        $extraY .= "onchange='document.location.href=\"" . PreparePHP_SELF($tmp_REQUEST['Y']) . "&amp;year{$title}=\"+this.form.year{$title}.value;'";
    }
    if ($options['C']) {
        $_openSIS['PrepareDate']++;
    }
    if (strlen($date) == 9) {
        $day = substr($date, 0, 2);
        $month = substr($date, 3, 3);
        $year = substr($date, 7, 2);
        $return .= '<!-- ' . $year . MonthNWSwitch($month, 'tonum') . $day . ' -->';
    } else {
        $temp = split('-', $date);
        if (strlen($temp[0]) == 4) {
            $day = $temp[2];
            $year = substr($temp[0], 2, 2);
        } else {
            $day = $temp[0];
            $year = substr($temp[2], 2, 2);
        }
        $month = MonthNWSwitch($temp[1], 'tochar');
        $return .= '<!-- ' . $year . MonthNWSwitch($month, 'tonum') . $day . ' -->';
    }
    // MONTH  ---------------
    if ($options['M']) {
        $return .= "<div style='float:left; margin-right:2px;'><SELECT CLASS=cal_month NAME=month" . $title . " id=monthSelect" . $_openSIS['PrepareDate'] . " SIZE=1 {$extraM}>";
        //  -------------------------------------------------------------------------- //
        if ($month == 'JAN') {
            $month = 1;
        } elseif ($month == 'FEB') {
            $month = 2;
        } elseif ($month == 'MAR') {
            $month = 3;
        } elseif ($month == 'APR') {
            $month = 4;
        } elseif ($month == 'MAY') {
            $month = 5;
        } elseif ($month == 'JUN') {
            $month = 6;
        } elseif ($month == 'JUL') {
            $month = 7;
        } elseif ($month == 'AUG') {
            $month = 8;
        } elseif ($month == 'SEP') {
            $month = 9;
        } elseif ($month == 'OCT') {
            $month = 10;
        } elseif ($month == 'NOV') {
            $month = 11;
        } elseif ($month == 'DEC') {
            $month = 12;
        }
        //  -------------------------------------------------------------------------- //
        if ($allow_na) {
            if ($month == '000') {
                $return .= "<OPTION value=\"\" SELECTED>N/A";
            } else {
                $return .= "<OPTION value=\"\">N/A";
            }
        }
        if ($month == '1') {
            $return .= "<OPTION VALUE=JAN SELECTED>January";
        } else {
            $return .= "<OPTION VALUE=JAN>January";
        }
        if ($month == '2') {
            $return .= "<OPTION VALUE=FEB SELECTED>February";
        } else {
            $return .= "<OPTION VALUE=FEB>February";
        }
        if ($month == '3') {
            $return .= "<OPTION VALUE=MAR SELECTED>March";
        } else {
            $return .= "<OPTION VALUE=MAR>March";
        }
        if ($month == '4') {
            $return .= "<OPTION VALUE=APR SELECTED>April";
        } else {
            $return .= "<OPTION VALUE=APR>April";
        }
        if ($month == '5') {
            $return .= "<OPTION VALUE=MAY SELECTED>May";
        } else {
            $return .= "<OPTION VALUE=MAY>May";
        }
        if ($month == '6') {
            $return .= "<OPTION VALUE=JUN SELECTED>June";
        } else {
            $return .= "<OPTION VALUE=JUN>June";
        }
        if ($month == '7') {
            $return .= "<OPTION VALUE=JUL SELECTED>July";
        } else {
            $return .= "<OPTION VALUE=JUL>July";
        }
        if ($month == '8') {
            $return .= "<OPTION VALUE=AUG SELECTED>August";
        } else {
            $return .= "<OPTION VALUE=AUG>August";
        }
        if ($month == '9') {
            $return .= "<OPTION VALUE=SEP SELECTED>September";
        } else {
            $return .= "<OPTION VALUE=SEP>September";
        }
        if ($month == '10') {
            $return .= "<OPTION VALUE=OCT SELECTED>October";
        } else {
            $return .= "<OPTION VALUE=OCT>October";
        }
        if ($month == '11') {
            $return .= "<OPTION VALUE=NOV SELECTED>November";
        } else {
            $return .= "<OPTION VALUE=NOV>November";
        }
        if ($month == '12') {
            $return .= "<OPTION VALUE=DEC SELECTED>December";
        } else {
            $return .= "<OPTION VALUE=DEC>December";
        }
        $return .= "</SELECT></div>";
    }
    // DAY  ---------------
    if ($options['D']) {
        $return .= "<div style='float:left; margin-right:2px;'><SELECT NAME=day" . $title . " id=daySelect" . $_openSIS['PrepareDate'] . " SIZE=1 {$extraD}>";
        if ($allow_na) {
            if ($day == '00') {
                $return .= "<OPTION value=\"\" SELECTED>N/A";
            } else {
                $return .= "<OPTION value=\"\">N/A";
            }
        }
        for ($i = 1; $i <= 31; $i++) {
            if (strlen($i) == 1) {
                $print = '0' . $i;
            } else {
                $print = $i;
            }
            $return .= "<OPTION VALUE=" . $print;
            if ($day == $print) {
                $return .= " SELECTED";
            }
            $return .= ">{$i} ";
        }
        $return .= "</SELECT></div>";
    }
    // YEAR	 ---------------
    if ($options['Y']) {
        if (!$year) {
            $begin = date('Y') - 20;
            $end = date('Y') + 5;
        } else {
            if ($year < 50) {
                $year = '20' . $year;
            } else {
                $year = '19' . $year;
            }
            $begin = $year - 5;
            $end = $year + 5;
        }
        $return .= "<div style='float:left; margin-right:2px;'><SELECT NAME=year" . $title . " id=yearSelect" . $_openSIS['PrepareDate'] . " SIZE=1 {$extraY}>";
        if ($allow_na) {
            if ($year == '00') {
                $return .= "<OPTION value=\"\" SELECTED>N/A";
            } else {
                $return .= "<OPTION value=\"\">N/A";
            }
        }
        for ($i = $begin; $i <= $end; $i++) {
            $return .= "<OPTION VALUE=" . substr($i, 0);
            if ($year == $i) {
                $return .= " SELECTED";
            }
            $return .= ">" . $i;
        }
        $return .= "</SELECT></div>";
    }
    if ($options['C']) {
        $return .= '<div style="margin-top:-3px; float:left"><img src="assets/calendar.gif" id="trigger' . $_openSIS['PrepareDate'] . '" style="cursor: hand;" onmouseover=this.style.background=""; onmouseout=this.style.background=""; onClick=' . "MakeDate('" . $_openSIS['PrepareDate'] . "',this);" . ' /></div>';
    }
    if ($_REQUEST['_openSIS_PDF']) {
        $return = ProperDate($date);
    }
    return $return;
}
function PrepareDate_for_EndInput($date = '', $title = '', $allow_na = true, $options = '')
{
    global $_openSIS;
    if ($options == '') {
        $options = array();
    }
    if (!$options['Y'] && !$options['M'] && !$options['D'] && !$options['C']) {
        $options += array('Y' => true, 'M' => true, 'D' => true, 'C' => true);
    }
    if ($options['short'] == true) {
        $extraM = "style='width:60;' ";
    }
    if ($options['submit'] == true) {
        $tmp_REQUEST['M'] = $tmp_REQUEST['D'] = $tmp_REQUEST['Y'] = $_REQUEST;
        unset($tmp_REQUEST['M']['month' . $title]);
        unset($tmp_REQUEST['D']['day' . $title]);
        unset($tmp_REQUEST['Y']['year' . $title]);
        $extraM .= "onchange='document.location.href=\"" . PreparePHP_SELF($tmp_REQUEST['M']) . "&amp;month{$title}=\"+this.form.month{$title}.value;'";
        $extraD .= "onchange='document.location.href=\"" . PreparePHP_SELF($tmp_REQUEST['D']) . "&amp;day{$title}=\"+this.form.day{$title}.value;'";
        $extraY .= "onchange='document.location.href=\"" . PreparePHP_SELF($tmp_REQUEST['Y']) . "&amp;year{$title}=\"+this.form.year{$title}.value;'";
    }
    if ($options['C']) {
        $_openSIS['PrepareDate']++;
    }
    if (strlen($date) == 9) {
        $day = substr($date, 0, 2);
        $month = substr($date, 3, 3);
        $year = substr($date, 7, 2);
        $return .= '<!-- ' . $year . MonthNWSwitch($month, 'tonum') . $day . ' -->';
    } else {
        $day = substr($date, 8, 2);
        $month = MonthNWSwitch(substr($date, 5, 2), 'tochar');
        $year = substr($date, 2, 2);
        $return .= '<!-- ' . $year . MonthNWSwitch($month, 'tonum') . $day . ' -->';
    }
    // MONTH  ---------------
    if ($options['M']) {
        $return .= "<div style=white-space:nowrap ><SELECT NAME=month" . $title . " id=monthSelect" . $_openSIS['PrepareDate'] . " SIZE=1 {$extraM}>";
        //  -------------------------------------------------------------------------- //
        if ($month == 'JAN') {
            $month = 1;
        } elseif ($month == 'FEB') {
            $month = 2;
        } elseif ($month == 'MAR') {
            $month = 3;
        } elseif ($month == 'APR') {
            $month = 4;
        } elseif ($month == 'MAY') {
            $month = 5;
        } elseif ($month == 'JUN') {
            $month = 6;
        } elseif ($month == 'JUL') {
            $month = 7;
        } elseif ($month == 'AUG') {
            $month = 8;
        } elseif ($month == 'SEP') {
            $month = 9;
        } elseif ($month == 'OCT') {
            $month = 10;
        } elseif ($month == 'NOV') {
            $month = 11;
        } elseif ($month == 'DEC') {
            $month = 12;
        }
        //  -------------------------------------------------------------------------- //
        if ($allow_na) {
            if ($month == '000') {
                $return .= "<OPTION value=\"\" SELECTED>N/A";
            } else {
                $return .= "<OPTION value=\"\">N/A";
            }
        }
        if ($month == '1') {
            $return .= "<OPTION VALUE=JAN SELECTED>January";
        } else {
            $return .= "<OPTION VALUE=JAN>January";
        }
        if ($month == '2') {
            $return .= "<OPTION VALUE=FEB SELECTED>February";
        } else {
            $return .= "<OPTION VALUE=FEB>February";
        }
        if ($month == '3') {
            $return .= "<OPTION VALUE=MAR SELECTED>March";
        } else {
            $return .= "<OPTION VALUE=MAR>March";
        }
        if ($month == '4') {
            $return .= "<OPTION VALUE=APR SELECTED>April";
        } else {
            $return .= "<OPTION VALUE=APR>April";
        }
        if ($month == '5') {
            $return .= "<OPTION VALUE=MAY SELECTED>May";
        } else {
            $return .= "<OPTION VALUE=MAY>May";
        }
        if ($month == '6') {
            $return .= "<OPTION VALUE=JUN SELECTED>June";
        } else {
            $return .= "<OPTION VALUE=JUN>June";
        }
        if ($month == '7') {
            $return .= "<OPTION VALUE=JUL SELECTED>July";
        } else {
            $return .= "<OPTION VALUE=JUL>July";
        }
        if ($month == '8') {
            $return .= "<OPTION VALUE=AUG SELECTED>August";
        } else {
            $return .= "<OPTION VALUE=AUG>August";
        }
        if ($month == '9') {
            $return .= "<OPTION VALUE=SEP SELECTED>September";
        } else {
            $return .= "<OPTION VALUE=SEP>September";
        }
        if ($month == '10') {
            $return .= "<OPTION VALUE=OCT SELECTED>October";
        } else {
            $return .= "<OPTION VALUE=OCT>October";
        }
        if ($month == '11') {
            $return .= "<OPTION VALUE=NOV SELECTED>November";
        } else {
            $return .= "<OPTION VALUE=NOV>November";
        }
        if ($month == '12') {
            $return .= "<OPTION VALUE=DEC SELECTED>December";
        } else {
            $return .= "<OPTION VALUE=DEC>December";
        }
        $return .= "</SELECT> ";
    }
    // DAY  ---------------
    if ($options['D']) {
        $return .= "<SELECT NAME=day" . $title . " id=daySelect" . $_openSIS['PrepareDate'] . " SIZE=1 {$extraD}>";
        if ($allow_na) {
            if ($day == '00') {
                $return .= "<OPTION value=\"\" SELECTED>N/A";
            } else {
                $return .= "<OPTION value=\"\">N/A";
            }
        }
        for ($i = 1; $i <= 31; $i++) {
            if (strlen($i) == 1) {
                $print = '0' . $i;
            } else {
                $print = $i;
            }
            $return .= "<OPTION VALUE=" . $print;
            if ($day == $print) {
                $return .= " SELECTED";
            }
            $return .= ">{$i} ";
        }
        $return .= "</SELECT> ";
    }
    // YEAR	 ---------------
    if ($options['Y']) {
        if (!$year) {
            $begin = date('Y') - 60;
            $end = date('Y') + 20;
        } else {
            if ($year < 50) {
                $year = '20' . $year;
            } else {
                $year = '19' . $year;
            }
            $begin = $year - 59;
            $end = $year + 21;
        }
        $return .= "<SELECT NAME=year" . $title . " id=yearSelect" . $_openSIS['PrepareDate'] . " SIZE=1 {$extraY}>";
        if ($allow_na) {
            if ($year == '00') {
                $return .= "<OPTION value=\"\" SELECTED>N/A";
            } else {
                $return .= "<OPTION value=\"\">N/A";
            }
        }
        for ($i = $begin; $i <= $end; $i++) {
            $return .= "<OPTION VALUE=" . substr($i, 0);
            if ($year == $i) {
                $return .= " SELECTED";
            }
            $return .= ">" . $i;
        }
        $return .= "</SELECT> ";
    }
    if ($options['C']) {
        $return .= '</div>';
    }
    if ($_REQUEST['_openSIS_PDF']) {
        $return = ProperDate($date);
    }
    return $return;
}
function _makeNumeric($number, $column)
{
    global $max_min_RET, $chart, $diff, $mins, $THIS_RET;
    $index = $THIS_RET['TIMEFRAME'] * 1 - MonthNWSwitch($_REQUEST['month_start'], 'tonum') * 1 + 1;
    if (!$number) {
        $number = 0;
    }
    if ($diff == 0) {
        $chart['chart_data'][0][1] = $number;
        $chart['chart_data'][$index][1]++;
    } elseif ($diff < 5) {
        $chart['chart_data'][0][(int) $number - (int) $max_min_RET[1]['MIN'] + 1] = (int) $number;
        $chart['chart_data'][$index][(int) $number - (int) $max_min_RET[1]['MIN'] + 1]++;
    } else {
        for ($i = 1; $i <= 5; $i++) {
            if ($number >= $mins[$i] && $number < $mins[$i + 1] || $i == 5) {
                $chart['chart_data'][$index][$i]++;
                break;
            }
        }
    }
    return $number;
}
Example #15
0
             foreach ($assignments_RET[$date] as $event) {
                 echo '<TR class="center"><TD style="width:1px; background-color:' . ($event['ASSIGNED'] == 'Y' ? '#00FF00' : '#FF0000') . '"></TD><TD>' . '<A HREF="#" onclick=\'javascript:window.open("Modules.php?modname=' . $_REQUEST['modname'] . '&modfunc=detail&assignment_id=' . $event['ID'] . '&year=' . $_REQUEST['year'] . '&month=' . MonthNWSwitch($_REQUEST['month'], 'tochar') . '","blank","width=500,height=400"); return false;\'>' . $event['TITLE'] . '</A></TD></TR>';
             }
         }
         echo '</TABLE>';
     } elseif (count($assignments_RET[$date])) {
         echo '<TABLE class="cellpadding-0" style="border-collapse:separate; border-spacing:2px;">';
         foreach ($assignments_RET[$date] as $event) {
             echo '<TR class="center"><TD style="width:1px; background-color:' . ($event['ASSIGNED'] == 'Y' ? '#00FF00' : '#FF0000') . '"></TD><TD>' . '<A HREF="#" onclick=\'javascript:window.open("Modules.php?modname=' . $_REQUEST['modname'] . '&modfunc=detail&assignment_id=' . $event['ID'] . '&year=' . $_REQUEST['year'] . '&month=' . MonthNWSwitch($_REQUEST['month'], 'tochar') . '","blank","width=500,height=400"); return false;\'>' . $event['TITLE'] . '</A></TD></TR>';
         }
         echo '</TABLE>';
     }
     echo '</TD></TR>';
     if (AllowEdit()) {
         //modif Francois: days numbered
         echo '<tr style="height:100%"><td style="vertical-align:bottom; text-align:left;">' . button('add', '', '"#" onclick=\'javascript:window.open("Modules.php?modname=' . $_REQUEST['modname'] . '&modfunc=detail&event_id=new&school_date=' . $date . '&year=' . $_REQUEST['year'] . '&month=' . MonthNWSwitch($_REQUEST['month'], 'tochar') . '","blank","width=500,height=400"); return false;\' title="' . _('New Event') . '"') . '</td>';
         if (SchoolInfo('NUMBER_DAYS_ROTATION') !== null) {
             echo '<td style="text-align:right; vertical-align:bottom;">' . (($dayNumber = dayToNumber($day_time)) ? _('Day') . '&nbsp;' . $dayNumber : '&nbsp;') . '</td>';
         }
         echo '</tr>';
     } elseif (SchoolInfo('NUMBER_DAYS_ROTATION') !== null) {
         echo '<tr><td style="text-align:right; vertical-align: bottom;">' . (($dayNumber = dayToNumber($day_time)) ? _('Day') . '&nbsp;' . $dayNumber : '&nbsp;') . '</td></tr>';
     }
     echo '</table></TD>';
     $return_counter++;
     if ($return_counter % 7 == 0) {
         echo '</TR><TR>';
     }
 }
 echo '</TR></TABLE>';
 echo '</TD></TR></TABLE>';