Esempio n. 1
0
                $values = '\'' . $student_id . '\',\'' . $date . '\',\'' . $period_id . '\',\'' . GetCurrentMP('QTR', $date) . '\',\'' . $period . '\',\'Y\',';
                $go = 0;
                foreach ($columns as $column => $value) {
                    if ($value) {
                        $fields .= $column . ',';
                        $values .= '\'' . str_replace("\\'", "''", $value) . '\',';
                        $go = true;
                    }
                }
                $sql .= '(' . substr($fields, 0, -1) . ') values(' . substr($values, 0, -1) . ')';
                if ($go) {
                    DBQuery($sql);
                }
            }
        }
        UpdateAttendanceDaily($student_id, $date);
    }
    $current_RET = DBGet(DBQuery('SELECT ATTENDANCE_TEACHER_CODE,ATTENDANCE_CODE,ATTENDANCE_REASON,STUDENT_ID,ADMIN,COURSE_PERIOD_ID FROM attendance_period WHERE SCHOOL_DATE=\'' . $date . '\''), array(), array('STUDENT_ID', 'COURSE_PERIOD_ID'));
    unset($_REQUEST['attendance']);
}
$codes_RET = DBGet(DBQuery('SELECT ID,SHORT_NAME,TITLE FROM attendance_codes WHERE SCHOOL_ID=\'' . UserSchool() . '\' AND SYEAR=\'' . UserSyear() . '\''));
$periods_RET = DBGet(DBQuery('SELECT PERIOD_ID,SHORT_NAME,TITLE FROM school_periods WHERE SCHOOL_ID=\'' . UserSchool() . '\' AND SYEAR=\'' . UserSyear() . '\' ORDER BY SORT_ORDER'));
//if(isset($_REQUEST['student_id']) && $_REQUEST['student_id']!='new')
if (isset($_REQUEST['student_id']) && optional_param('student_id', '', PARAM_ALPHANUM) != 'new') {
    //if(UserStudentID() != $_REQUEST['student_id'])
    if (UserStudentID() != optional_param('student_id', '', PARAM_ALPHANUM)) {
        //$_SESSION['student_id'] = $_REQUEST['student_id'];
        $_SESSION['student_id'] = optional_param('student_id', '', PARAM_ALPHANUM);
        echo '<script language=JavaScript>parent.side.location="' . $_SESSION['Side_PHP_SELF'] . '";</script>';
    }
    $functions = array('ATTENDANCE_CODE' => '_makeCodePulldown', 'ATTENDANCE_TEACHER_CODE' => '_makeCode', 'ATTENDANCE_REASON' => '_makeReasonInput');
Esempio n. 2
0
#  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>');
}
if ($_REQUEST['day_end'] && $_REQUEST['month_end'] && $_REQUEST['year_end']) {
    $end_date = $_REQUEST['day_end'] . '-' . $_REQUEST['month_end'] . '-' . substr($_REQUEST['year_end'], 2, 4);
} else {
    $end_date = DBDate();
}
DrawBC("Attendance >> " . ProgramTitle());
if ($_REQUEST['attendance'] && ($_POST['attendance'] || $_REQUEST['ajax']) && AllowEdit()) {
    foreach ($_REQUEST['attendance'] as $student_id => $values) {
        foreach ($values as $school_date => $columns) {
            $sql = 'UPDATE attendance_period SET ADMIN=\'Y\',';
            foreach ($columns as $column => $value) {
                $sql .= $column . '=\'' . str_replace("\\'", "''", $value) . '\',';
            }
            $sql = substr($sql, 0, -1) . ' WHERE SCHOOL_DATE=\'' . $school_date . '\' AND PERIOD_ID=\'' . $_REQUEST['period_id'] . '\' AND STUDENT_ID=\'' . $student_id . '\'';
            DBQuery($sql);
            UpdateAttendanceDaily($student_id, $school_date);
        }
    }
    $current_RET = DBGet(DBQuery('SELECT ATTENDANCE_TEACHER_CODE,ATTENDANCE_CODE,ATTENDANCE_REASON,STUDENT_ID,ADMIN,COURSE_PERIOD_ID FROM attendance_period WHERE SCHOOL_DATE=\'' . $date . '\''), array(), array('STUDENT_ID', 'COURSE_PERIOD_ID'));
    unset($_REQUEST['attendance']);
}
if ($_REQUEST['search_modfunc'] || $_REQUEST['student_id'] || UserStudentID() || User('PROFILE') == 'parent' || User('PROFILE') == 'student') {
    $PHP_tmp_SELF = PreparePHP_SELF();
    $extraM .= "";
    $period_select = "<SELECT name=period_id onchange='this.form.submit();'><OPTION value=\"\">Daily</OPTION>";
    if (!UserStudentID() && !$_REQUEST['student_id']) {
        $periods_RET = DBGet(DBQuery('SELECT PERIOD_ID,TITLE FROM school_periods WHERE SYEAR=\'' . UserSyear() . '\' AND SCHOOL_ID=\'' . UserSchool() . '\' ORDER BY SORT_ORDER'));
        if (count($periods_RET) > 1) {
            foreach ($periods_RET as $period) {
                $period_select .= "<OPTION value=" . $period['PERIOD_ID'] . ($_REQUEST['period_id'] == $period['PERIOD_ID'] ? ' SELECTED' : '') . ">" . $period['TITLE'] . '</OPTION>';
            }
Esempio n. 4
0
                            		values('$student_id','$date','$period_id','$current_mp','$course_period_id','$_REQUEST[absence_code]','$_REQUEST[absence_code]','$_REQUEST[absence_reason]','Y')";*/
                            $sql = 'INSERT INTO attendance_period (STUDENT_ID,SCHOOL_DATE,PERIOD_ID,MARKING_PERIOD_ID,COURSE_PERIOD_ID,ATTENDANCE_CODE,ATTENDANCE_TEACHER_CODE,ATTENDANCE_REASON,ADMIN)values(\'' . $student_id . '\',\'' . $date . '\',\'' . $period_id . '\',\'' . $current_mp . '\',\'' . $course_period_id . '\',\'' . optional_param('absence_code', '', PARAM_NUMBER) . '\',\'' . optional_param('absence_code', '', PARAM_NUMBER) . '\',\'' . optional_param('absence_reason', '', PARAM_SPCL) . '\',\'Y\')';
                            DBQuery($sql);
                        }
                    } else {
                        /*$sql = "UPDATE attendance_period SET ATTENDANCE_CODE='$_REQUEST[absence_code]',ATTENDANCE_TEACHER_CODE='$_REQUEST[absence_code]',ATTENDANCE_REASON='$_REQUEST[absence_reason]',ADMIN='Y'
                        			WHERE STUDENT_ID='$student_id' AND SCHOOL_DATE='$date' AND PERIOD_ID='$period_id'";
                        		*/
                        $sql = 'UPDATE attendance_period SET ATTENDANCE_CODE=\'' . optional_param('absence_code', '', PARAM_NUMBER) . '\',ATTENDANCE_TEACHER_CODE=\'' . optional_param('absence_code', '', PARAM_NUMBER) . '\',ATTENDANCE_REASON=\'' . optional_param('absence_reason', '', PARAM_SPCL) . '\',ADMIN=\'Y\'
								WHERE STUDENT_ID=\'' . $student_id . '\' AND SCHOOL_DATE=\'' . $date . '\' AND PERIOD_ID=\'' . $period_id . '\'';
                        DBQuery($sql);
                    }
                }
                $val = optional_param('absence_reason', '', PARAM_SPCL);
                //UpdateAttendanceDaily($student_id,$date,($_REQUEST['absence_reason']?$_REQUEST['absence_reason']:false));
                UpdateAttendanceDaily($student_id, $date, $val ? $val : false);
            }
        }
        //-----------------------For update attendance_completed----------------------------------------
        $current_RET = DBGet(DBQuery('SELECT STUDENT_ID,PERIOD_ID,SCHOOL_DATE,ATTENDANCE_CODE FROM attendance_period WHERE EXTRACT(MONTH FROM SCHOOL_DATE)=\'' . $_REQUEST['month'] * 1 . '\' AND EXTRACT(YEAR FROM SCHOOL_DATE)=\'' . $_REQUEST[year] . '\''), array(), array('SCHOOL_DATE', 'PERIOD_ID'));
        foreach ($_REQUEST['dates'] as $date => $yes) {
            $course_periods_RET = DBGet(DBQuery('SELECT s.COURSE_PERIOD_ID,cpv.PERIOD_ID,cp.TEACHER_ID FROM schedule s,course_periods cp,course_period_var cpv,attendance_calendar ac,school_periods sp WHERE sp.PERIOD_ID=cpv.PERIOD_ID AND cp.COURSE_PERIOD_ID=cpv.COURSE_PERIOD_ID AND ac.SCHOOL_DATE=\'' . date('Y-m-d', strtotime($date)) . '\' AND ac.CALENDAR_ID=cp.CALENDAR_ID AND (ac.BLOCK=sp.BLOCK OR sp.BLOCK IS NULL) AND s.COURSE_PERIOD_ID=cp.COURSE_PERIOD_ID AND cpv.DOES_ATTENDANCE=\'Y\' AND (ac.SCHOOL_DATE BETWEEN s.START_DATE AND s.END_DATE OR (s.END_DATE IS NULL AND ac.SCHOOL_DATE>=s.START_DATE)) AND position(substring(\'UMTWHFS\' FROM DAYOFWEEK(ac.SCHOOL_DATE)  FOR 1) IN cpv.DAYS)>0 AND cp.MARKING_PERIOD_ID IN (' . $all_mp . ') AND s.MARKING_PERIOD_ID IN (' . $all_mp . ') AND NOT (cp.HALF_DAY=\'Y\' AND (SELECT STATE_CODE FROM attendance_codes WHERE ID=\'' . optional_param('absence_code', '', PARAM_NUMBER) . '\')=\'H\')'), array(), array('PERIOD_ID'));
            foreach ($_REQUEST['period'] as $period_id => $yes) {
                $attn_taken = count($current_RET[$date][$period_id]);
                $attn_possible = count($course_periods_RET[$period_id]);
                if ($attn_possible == $attn_taken) {
                    if ($attn_possible > 0) {
                        $RET = DBGet(DBQuery('SELECT \'' . 'completed' . '\' AS COMPLETED FROM attendance_completed WHERE STAFF_ID=\'' . $course_periods_RET[$period_id][1]['TEACHER_ID'] . '\' AND SCHOOL_DATE=\'' . $date . '\' AND PERIOD_ID=\'' . $period_id . '\''));
                        if (!count($RET)) {
                            DBQuery('INSERT INTO attendance_completed (STAFF_ID,SCHOOL_DATE,PERIOD_ID) values(\'' . $course_periods_RET[$period_id][1]['TEACHER_ID'] . '\',\'' . $date . '\',\'' . $period_id . '\')');
                        }
Esempio n. 5
0
        /*UpdateAttendanceDaily($student_id,$date,($_REQUEST['attendance_day'][$student_id]['COMMENT']?$_REQUEST['attendance_day'][$student_id]['COMMENT']:false));*/
        $val = clean_param($_REQUEST['attendance_day'][$student_id]['COMMENT'], PARAM_SPCL);
        UpdateAttendanceDaily($student_id, $date, $val ? $val : false);
        unset($_REQUEST['attendance_day'][$student_id]);
    }
    echo $_REQUEST['attendance_day'][$student_id]['COMMENT'];
    $current_RET = DBGet(DBQuery("SELECT ATTENDANCE_TEACHER_CODE,ATTENDANCE_CODE,ATTENDANCE_REASON,STUDENT_ID,ADMIN,COURSE_PERIOD_ID FROM {$table} WHERE SCHOOL_DATE='" . $date . "'" . $extra_sql), array(), array('STUDENT_ID', 'COURSE_PERIOD_ID'));
    unset($_REQUEST['attendance']);
    unset($_SESSION['_REQUEST_vars']['attendance']);
    unset($_SESSION['_REQUEST_vars']['attendance_day']);
}
if (count($_REQUEST['attendance_day'])) {
    foreach ($_REQUEST['attendance_day'] as $student_id => $comment) {
        $val = clean_param($comment['COMMENT'], PARAM_SPCL);
        //UpdateAttendanceDaily($student_id,$date,$comment['COMMENT']);
        UpdateAttendanceDaily($student_id, $date, $val);
    }
    unset($_REQUEST['attendance_day']);
}
$codes_RET = DBGet(DBQuery("SELECT ID,SHORT_NAME,TITLE,STATE_CODE FROM ATTENDANCE_CODES WHERE SCHOOL_ID='" . UserSchool() . "' AND SYEAR='" . UserSyear() . "' AND TABLE_NAME='{$_REQUEST['table']}'"));
$periods_RET = DBGet(DBQuery("SELECT PERIOD_ID,SHORT_NAME,TITLE FROM SCHOOL_PERIODS WHERE SCHOOL_ID='" . UserSchool() . "' AND SYEAR='" . UserSyear() . "' AND EXISTS (SELECT * FROM COURSE_PERIODS WHERE PERIOD_ID=SCHOOL_PERIODS.PERIOD_ID AND DOES_ATTENDANCE='Y') ORDER BY SORT_ORDER"));
//if(isset($_REQUEST['student_id']) && $_REQUEST['student_id']!='new')
if (isset($_REQUEST['student_id']) && optional_param('student_id', '', PARAM_ALPHANUM) != 'new') {
    //if(UserStudentID() != $_REQUEST['student_id'])
    if (UserStudentID() != optional_param('student_id', '', PARAM_ALPHANUM)) {
        //$_SESSION['student_id'] = $_REQUEST['student_id'];
        $_SESSION['student_id'] = optional_param('student_id', '', PARAM_ALPHANUM);
        echo '<script language=JavaScript>parent.side.location="' . $_SESSION['Side_PHP_SELF'] . '?modcat="+parent.side.document.forms[0].modcat.value;</script>';
    }
    $functions = array('ATTENDANCE_CODE' => '_makeCodePulldown', 'ATTENDANCE_TEACHER_CODE' => '_makeCode', 'ATTENDANCE_REASON' => '_makeReasonInput');
    /*$schedule_RET = DBGet(DBQuery("SELECT
Esempio n. 6
0
                $all_mp = GetAllMP('QTR', $current_mp);
                $course_periods_RET = DBGet(DBQuery("SELECT s.COURSE_PERIOD_ID,cp.PERIOD_ID,cp.HALF_DAY FROM SCHEDULE s,COURSE_PERIODS cp,ATTENDANCE_CALENDAR ac,SCHOOL_PERIODS sp WHERE sp.PERIOD_ID=cp.PERIOD_ID AND ac.SCHOOL_DATE='{$date}' AND ac.CALENDAR_ID=cp.CALENDAR_ID AND (ac.BLOCK=sp.BLOCK OR sp.BLOCK IS NULL) AND s.COURSE_PERIOD_ID=cp.COURSE_PERIOD_ID AND s.STUDENT_ID='{$student_id}' AND cp.PERIOD_ID IN {$periods_list} AND position(',0,' IN cp.DOES_ATTENDANCE)>0 AND (ac.SCHOOL_DATE BETWEEN s.START_DATE AND s.END_DATE OR (s.END_DATE IS NULL AND ac.SCHOOL_DATE>=s.START_DATE)) AND position(substring('{$daysWeek}' FROM cast(extract(DOW FROM ac.SCHOOL_DATE) AS INT)*2+1 FOR 2) IN cp.DAYS)>0 AND s.MARKING_PERIOD_ID IN ({$all_mp})"), array(), array('PERIOD_ID'));
                //echo '<pre>'; var_dump($course_periods_RET); echo '</pre>';
                foreach ($_REQUEST['period'] as $period_id => $yes) {
                    $course_period_id = $course_periods_RET[$period_id][1]['COURSE_PERIOD_ID'];
                    if ($course_period_id && !($course_periods_RET[$period_id][1]['COURSE_PERIOD_ID'] == 'Y' && $state_code == 'H')) {
                        if (!$current_RET[$student_id][$date][$period_id]) {
                            $sql = "INSERT INTO ATTENDANCE_PERIOD (STUDENT_ID,SCHOOL_DATE,PERIOD_ID,MARKING_PERIOD_ID,COURSE_PERIOD_ID,ATTENDANCE_CODE,ATTENDANCE_REASON,ADMIN)\n\t\t\t\t\t\t\t\t\t\tvalues('{$student_id}','{$date}','{$period_id}','{$current_mp}','{$course_period_id}','{$_REQUEST['absence_code']}','{$_REQUEST['absence_reason']}','Y')";
                            DBQuery($sql);
                        } else {
                            $sql = "UPDATE ATTENDANCE_PERIOD SET ATTENDANCE_CODE='{$_REQUEST['absence_code']}',ATTENDANCE_REASON='{$_REQUEST['absence_reason']}',ADMIN='Y',COURSE_PERIOD_ID='{$course_period_id}'\n\t\t\t\t\t\t\t\tWHERE STUDENT_ID='{$student_id}' AND SCHOOL_DATE='{$date}' AND PERIOD_ID='{$period_id}'";
                            DBQuery($sql);
                        }
                    }
                }
                UpdateAttendanceDaily($student_id, $date, $_REQUEST['absence_reason'] ? $_REQUEST['absence_reason'] : false);
            }
        }
        unset($_REQUEST['modfunc']);
        $note = _('Absence records were added for the selected students.');
    } else {
        BackPrompt(_('You must choose at least one period and one student.'));
    }
}
DrawHeader(ProgramTitle());
if (!$_REQUEST['modfunc']) {
    $extra['link'] = array('FULL_NAME' => false);
    $extra['SELECT'] = ",CAST (NULL AS CHAR(1)) AS CHECKBOX";
    if ($_REQUEST['search_modfunc'] == 'list') {
        echo "<FORM action=Modules.php?modname={$_REQUEST['modname']}&modfunc=save METHOD=POST>";
        DrawHeader('', SubmitButton(_('Add Absences to Selected Students')));
                if ($go) {
                    DBQuery($sql);
                }
            }
        }
        UpdateAttendanceDaily($student_id, $date, $_REQUEST['attendance_day'][$student_id]['COMMENT'] ? $_REQUEST['attendance_day'][$student_id]['COMMENT'] : false);
        unset($_REQUEST['attendance_day'][$student_id]);
    }
    $current_RET = DBGet(DBQuery($current_Q), array(), array('STUDENT_ID', 'PERIOD_ID'));
    unset($_REQUEST['attendance']);
    unset($_SESSION['_REQUEST_vars']['attendance']);
    unset($_SESSION['_REQUEST_vars']['attendance_day']);
}
if (count($_REQUEST['attendance_day'])) {
    foreach ($_REQUEST['attendance_day'] as $student_id => $comment) {
        UpdateAttendanceDaily($student_id, $date, $comment['COMMENT']);
    }
    unset($_REQUEST['attendance_day']);
}
$codes_RET = DBGet(DBQuery("SELECT ID,SHORT_NAME,TITLE,STATE_CODE FROM ATTENDANCE_CODES WHERE SCHOOL_ID='" . UserSchool() . "' AND SYEAR='" . UserSyear() . "' AND TABLE_NAME='{$_REQUEST['table']}'"));
$periods_RET = DBGet(DBQuery("SELECT PERIOD_ID,SHORT_NAME,TITLE FROM SCHOOL_PERIODS WHERE SCHOOL_ID='" . UserSchool() . "' AND SYEAR='" . UserSyear() . "' AND EXISTS (SELECT '' FROM COURSE_PERIODS WHERE PERIOD_ID=SCHOOL_PERIODS.PERIOD_ID AND position(',{$_REQUEST['table']},' IN DOES_ATTENDANCE)>0) ORDER BY SORT_ORDER"));
$categories_RET = DBGet(DBQuery("SELECT ID,TITLE FROM ATTENDANCE_CODE_CATEGORIES WHERE SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "'"));
if (count($categories_RET)) {
    $tmp_PHP_SELF = PreparePHP_SELF($_REQUEST, array('table', 'codes'));
    $headerl = '<TABLE><TR>';
    /*if($_REQUEST['table']!=='0')
    	{
    		$tabcolor = '#DFDFDF';
    		$textcolor = '#999999';
    	}
    	else
#  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 '../../RedirectModulesInc.php';
DrawBC("Attendance > " . ProgramTitle());
$message = '<TABLE><TR><TD colspan=7 align=center>From ' . DateInputAY(DBDate('mysql'), 'min', 1) . ' to ' . DateInputAY(DBDate('mysql'), 'max', 2) . '</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[date('d-m-Y', $i)]) {
            foreach ($students_RET as $student) {
                UpdateAttendanceDaily($student['STUDENT_ID'], date('Y-m-d', $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>');
}