Commit 330e4b15 authored by François Jacquet's avatar François Jacquet
Browse files

#218 Use getDisplayName & getDisplayNameSQL functions programwide

To finish, next is Grades/TeacherCompletion.php
parent e102c7fa
......@@ -128,7 +128,7 @@ if ( isset( $_REQUEST['h'] )
{
// Select Staff where last login > now.
$staff_RET = DBGet( DBQuery( "SELECT STAFF_ID AS ID, USERNAME, PASSWORD, EMAIL,
LAST_NAME||', '||FIRST_NAME AS FULL_NAME, LAST_LOGIN, PROFILE_ID
" . getDisplayNameSQL() . " AS FULL_NAME, LAST_LOGIN, PROFILE_ID
FROM STAFF
WHERE LAST_LOGIN > CURRENT_TIMESTAMP
AND SYEAR='" . Config( 'SYEAR' ) . "'" ) );
......@@ -156,7 +156,7 @@ if ( isset( $_REQUEST['h'] )
// Select Students where last login > now & enrolled.
$student_RET = DBGet( DBQuery( "SELECT s.STUDENT_ID AS ID, s.USERNAME, s.PASSWORD,
s." . $custom_field . " AS EMAIL,
s.LAST_NAME||', '||s.FIRST_NAME AS FULL_NAME, s.LAST_LOGIN
" . getDisplayNameSQL( 's' ) . " AS FULL_NAME, s.LAST_LOGIN
FROM STUDENTS s, STUDENT_ENROLLMENT se
WHERE s.LAST_LOGIN > CURRENT_TIMESTAMP
AND se.SYEAR='" . Config( 'SYEAR' ) . "'
......@@ -336,7 +336,7 @@ function _sendPasswordResetEmail( $user_id, $user_type = 'staff', $email )
{
// Get Staff email, password.
$staff_RET = DBGet( DBQuery( "SELECT USERNAME, PASSWORD,
LAST_NAME||', '||FIRST_NAME AS FULL_NAME
" . getDisplayNameSQL() . " AS FULL_NAME
FROM STAFF
WHERE STAFF_ID='" . $user_id . "'
AND SYEAR='" . Config( 'SYEAR' ) . "'" ) );
......@@ -350,9 +350,9 @@ function _sendPasswordResetEmail( $user_id, $user_type = 'staff', $email )
elseif ( $user_type === 'student' )
{
// Get Student username, password, name.
$student_RET = DBGet( DBQuery( "SELECT USERNAME, PASSWORD,
LAST_NAME||', '||FIRST_NAME AS FULL_NAME
FROM STUDENTS s, STUDENT_ENROLLMENT ssm
$student_RET = DBGet( DBQuery( "SELECT USERNAME,PASSWORD,
" . getDisplayNameSQL( 's' ) . " AS FULL_NAME
FROM STUDENTS s,STUDENT_ENROLLMENT ssm
WHERE s.STUDENT_ID='" . $user_id . "'
AND s.STUDENT_ID=ssm.STUDENT_ID
AND ssm.SYEAR='" . Config( 'SYEAR' ) . "'
......@@ -508,7 +508,7 @@ function _notifyServerAdminPasswordReset( $user_id )
return false;
}
$staff_RET = DBGet( DBQuery( "SELECT USERNAME, LAST_NAME||', '||FIRST_NAME AS FULL_NAME, PROFILE
$staff_RET = DBGet( DBQuery( "SELECT USERNAME," . getDisplayNameSQL() . " AS FULL_NAME,PROFILE
FROM STAFF
WHERE STAFF_ID='" . $user_id . "'
AND SYEAR='" . Config( 'SYEAR' ) . "'" ) );
......
......@@ -362,7 +362,8 @@ $addJavascripts .= 'var menuStudentID = "' . UserStudentID() . '",
// Student SELECT (Parents only).
if ( User( 'PROFILE' ) === 'parent' ) :
$students_RET = DBGet( DBQuery( "SELECT sju.STUDENT_ID,s.LAST_NAME||', '||s.FIRST_NAME AS FULL_NAME,se.SCHOOL_ID
$students_RET = DBGet( DBQuery( "SELECT sju.STUDENT_ID,
" . getDisplayNameSQL( 's' ) . " AS FULL_NAME,se.SCHOOL_ID
FROM STUDENTS s,STUDENTS_JOIN_USERS sju,STUDENT_ENROLLMENT se
WHERE s.STUDENT_ID=sju.STUDENT_ID
AND sju.STAFF_ID='" . User( 'STAFF_ID' ) . "'
......@@ -658,7 +659,7 @@ $addJavascripts .= 'var menuStudentID = "' . UserStudentID() . '",
&& ( User( 'PROFILE' ) === 'admin'
|| User( 'PROFILE' ) === 'teacher' ) ) :
$current_student_RET = DBGet( DBQuery( "SELECT FIRST_NAME||' '||LAST_NAME||coalesce(' '||NAME_SUFFIX,' ') AS FULL_NAME
$current_student_RET = DBGet( DBQuery( "SELECT " . getDisplayNameSQL() . " AS FULL_NAME
FROM STUDENTS
WHERE STUDENT_ID='" . UserStudentID() . "'" ) ); ?>
......@@ -682,7 +683,7 @@ $addJavascripts .= 'var menuStudentID = "' . UserStudentID() . '",
&& ( User( 'PROFILE' ) === 'admin'
|| User( 'PROFILE' ) === 'teacher' ) ) :
$current_user_RET = DBGet( DBQuery( "SELECT FIRST_NAME||' '||LAST_NAME AS FULL_NAME
$current_user_RET = DBGet( DBQuery( "SELECT " . getDisplayNameSQL() . " AS FULL_NAME
FROM STAFF
WHERE STAFF_ID='" . UserStaffID() . "'" ) ); ?>
......
......@@ -328,7 +328,8 @@ else
if ( $_REQUEST['expanded_view']!='true' && !isset($_REQUEST['_ROSARIO_PDF']))
{
$extra2['WHERE'] .= ')';
$extra2['SELECT_ONLY'] = 'ssm.STUDENT_ID,p.PERSON_ID,p.FIRST_NAME,p.LAST_NAME,sjp.STUDENT_RELATION,pjc.TITLE,pjc.VALUE,a.PHONE,sjp.ADDRESS_ID ';
$extra2['SELECT_ONLY'] = 'ssm.STUDENT_ID,p.PERSON_ID,p.FIRST_NAME,p.LAST_NAME,p.MIDDLE_NAME,
sjp.STUDENT_RELATION,pjc.TITLE,pjc.VALUE,a.PHONE,sjp.ADDRESS_ID ';
$extra2['FROM'] .= ',ADDRESS a,STUDENTS_JOIN_ADDRESS sja LEFT OUTER JOIN STUDENTS_JOIN_PEOPLE sjp ON (sja.STUDENT_ID=sjp.STUDENT_ID AND sja.ADDRESS_ID=sjp.ADDRESS_ID AND (sjp.CUSTODY=\'Y\' OR sjp.EMERGENCY=\'Y\')) LEFT OUTER JOIN PEOPLE p ON (p.PERSON_ID=sjp.PERSON_ID) LEFT OUTER JOIN PEOPLE_JOIN_CONTACTS pjc ON (pjc.PERSON_ID=p.PERSON_ID) ';
$extra2['WHERE'] .= ' AND a.ADDRESS_ID=sja.ADDRESS_ID AND sja.STUDENT_ID=ssm.STUDENT_ID ';
$extra2['ORDER_BY'] .= 'COALESCE(sjp.CUSTODY,\'N\') DESC';
......
......@@ -125,7 +125,8 @@ else
$extra['WHERE'] .= ')';
$extra2['WHERE'] .= ')';
$extra2['SELECT'] .= ',p.PERSON_ID,p.FIRST_NAME,p.LAST_NAME,sjp.STUDENT_RELATION,pjc.TITLE,pjc.VALUE,a.PHONE,sjp.ADDRESS_ID ';
$extra2['SELECT'] .= ',p.PERSON_ID,p.FIRST_NAME,p.LAST_NAME,p.MIDDLE_NAME,
sjp.STUDENT_RELATION,pjc.TITLE,pjc.VALUE,a.PHONE,sjp.ADDRESS_ID ';
$extra2['FROM'] .= ',ADDRESS a,PEOPLE p,PEOPLE_JOIN_CONTACTS pjc,STUDENTS_JOIN_PEOPLE sjp,STUDENTS_JOIN_ADDRESS sja ';
$extra2['WHERE'] .= ' AND sja.STUDENT_ID=ssm.STUDENT_ID AND sjp.STUDENT_ID=sja.STUDENT_ID AND pjc.PERSON_ID=sjp.PERSON_ID AND p.PERSON_ID=sjp.PERSON_ID AND sjp.ADDRESS_ID=a.ADDRESS_ID AND (sjp.CUSTODY=\'Y\' OR sjp.EMERGENCY=\'Y\') ';
$extra2['group'] = array('STUDENT_ID','PERSON_ID');
......
......@@ -120,7 +120,9 @@ if ( isset( $_REQUEST['search_modfunc'] )
{
unset($extra);
$extra['SELECT_ONLY'] .= "ap.COURSE_PERIOD_ID, s.STUDENT_ID, s.FIRST_NAME, s.LAST_NAME, ap.SCHOOL_DATE, cp.TITLE, ap.PERIOD_ID, sc.START_DATE, sc.END_DATE ";
$extra['SELECT_ONLY'] .= "ap.COURSE_PERIOD_ID,s.STUDENT_ID,
" . getDisplayNameSQL( 's' ) . " AS FULL_NAME,
ap.SCHOOL_DATE,cp.TITLE,ap.PERIOD_ID,sc.START_DATE,sc.END_DATE ";
$extra['FROM'] .= " ,ATTENDANCE_PERIOD ap, COURSE_PERIODS cp, SCHEDULE sc ";
//$extra['WHERE'] .= " AND ssm.student_id=s.student_id AND ap.STUDENT_ID=s.STUDENT_ID AND ap.COURSE_PERIOD_ID = cp.COURSE_PERIOD_ID AND ('".DBDate()."' BETWEEN ssm.START_DATE AND ssm.END_DATE OR ssm.END_DATE IS NULL) ";
//$extra['WHERE'] .= " AND ssm.student_id=s.student_id AND ap.STUDENT_ID=s.STUDENT_ID AND ap.COURSE_PERIOD_ID = cp.COURSE_PERIOD_ID ";
......@@ -142,8 +144,7 @@ if ( isset( $_REQUEST['search_modfunc'] )
$studentidr = $rr['STUDENT_ID'];
$courseidr = $rr['COURSE_PERIOD_ID'];
$periodidr = $rr['PERIOD_ID'];
$firstr = $rr['FIRST_NAME'];
$lastr = $rr['LAST_NAME'];
$full_namer = $rr['FULL_NAME'];
$schooldater = $rr['SCHOOL_DATE'];
$titler = $rr['TITLE'];
$startr = $rr['START_DATE'];
......@@ -171,8 +172,7 @@ if ( isset( $_REQUEST['search_modfunc'] )
$courseid2 = $courseidr;
$periodid2 = $periodidr;
$schooldate2 = $schooldater;
$first2 = $firstr;
$last2 = $lastr;
$full_name2 = $full_namer;
$title2 = $titler;
$start2 = $startr;
$end2 = $endr;
......@@ -180,7 +180,9 @@ if ( isset( $_REQUEST['search_modfunc'] )
//echo "$totalrows";
unset($extra);
$extra['SELECT_ONLY'] .= "ap.COURSE_PERIOD_ID, s.STUDENT_ID, s.FIRST_NAME, s.LAST_NAME, ap.SCHOOL_DATE, cp.TITLE, cp.SHORT_NAME, ap.PERIOD_ID, sc.START_DATE, sc.END_DATE ";
$extra['SELECT_ONLY'] .= "ap.COURSE_PERIOD_ID,s.STUDENT_ID,
" . getDisplayNameSQL( 's' ) . " AS FULL_NAME,
ap.SCHOOL_DATE,cp.TITLE,cp.SHORT_NAME,ap.PERIOD_ID,sc.START_DATE,sc.END_DATE ";
$extra['FROM'] .= " ,ATTENDANCE_PERIOD ap, COURSE_PERIODS cp, SCHEDULE sc ";
//$extra['WHERE'] .= " AND ssm.student_id=s.student_id AND ap.STUDENT_ID=s.STUDENT_ID AND ap.COURSE_PERIOD_ID = cp.COURSE_PERIOD_ID AND ('".DBDate()."' BETWEEN ssm.START_DATE AND ssm.END_DATE OR ssm.END_DATE IS NULL) ";
//$extra['WHERE'] .= " AND ssm.student_id=s.student_id AND ap.STUDENT_ID=s.STUDENT_ID AND ap.COURSE_PERIOD_ID = cp.COURSE_PERIOD_ID ";
......@@ -254,8 +256,7 @@ if ( isset( $_REQUEST['search_modfunc'] )
$studentid = $r['STUDENT_ID'];
$courseid = $r['COURSE_PERIOD_ID'];
$periodid = $r['PERIOD_ID'];
$first = $r['FIRST_NAME'];
$last = $r['LAST_NAME'];
$full_name = $r['FULL_NAME'];
$schooldate = $r['SCHOOL_DATE'];
$title = $r['TITLE'];
$short_name = $r['SHORT_NAME'];
......@@ -292,7 +293,7 @@ if ( isset( $_REQUEST['search_modfunc'] )
echo '<tr>
<td><input type="checkbox" name="deletecheck[' . $count . ']" value="' . $count . '"></td>
<td>' . $first . ' ' . $last . ' (' . $studentid . ')</td>
<td>' . $full_name . ' (' . $studentid . ')</td>
<td>' . $short_name . ' (' .$courseid . ')</td>
<td>' . ProperDate( $start ) . '</td>
<td>' . ProperDate( $end ) . '</td>
......@@ -329,7 +330,7 @@ if ( isset( $_REQUEST['search_modfunc'] )
echo '<tr>
<td><input type="checkbox" name="deletecheck[' . $count . ']" value="' . $count . '"></td>
<td>' . $first . ' ' . $last . ' (' . $studentid . ')</td>
<td>' . $full_name . ' (' . $studentid . ')</td>
<td>' . $short_name . ' (' . $courseid . ')</td>
<td>' . ProperDate( $start ) . '</td>
<td>' . ProperDate( $end ) . '</td>
......@@ -350,8 +351,7 @@ if ( isset( $_REQUEST['search_modfunc'] )
$courseid2 = $courseid;
$periodid2 = $periodid;
$schooldate2 = $schooldate;
$first2 = $first;
$last2 = $last;
$full_name2 = $full_name;
$title2 = $title;
$start2 = $start;
$end2 = $end;
......
......@@ -48,22 +48,46 @@ echo '</form>';
//FJ multiple school periods for a course period
if ( SchoolInfo( 'NUMBER_DAYS_ROTATION' ) !== null )
{
$sql = "SELECT s.STAFF_ID,s.LAST_NAME||', '||s.FIRST_NAME AS FULL_NAME,sp.TITLE,cpsp.PERIOD_ID,cp.TITLE AS CP_TITLE,
(SELECT 'Y' FROM ATTENDANCE_COMPLETED ac WHERE ac.STAFF_ID=cp.TEACHER_ID AND ac.SCHOOL_DATE=acc.SCHOOL_DATE AND ac.PERIOD_ID=sp.PERIOD_ID AND TABLE_NAME='".$_REQUEST['table']."') AS COMPLETED
FROM STAFF s,COURSE_PERIODS cp,SCHOOL_PERIODS sp,ATTENDANCE_CALENDAR acc, COURSE_PERIOD_SCHOOL_PERIODS cpsp
WHERE
cp.COURSE_PERIOD_ID=cpsp.COURSE_PERIOD_ID AND
sp.PERIOD_ID = cpsp.PERIOD_ID AND position(',".$_REQUEST['table'].",' IN cp.DOES_ATTENDANCE)>0
AND cp.TEACHER_ID=s.STAFF_ID AND cp.MARKING_PERIOD_ID IN (".GetAllMP('QTR',GetCurrentMP('QTR',$date)).")
AND cp.SYEAR='".UserSyear()."' AND cp.SCHOOL_ID='".UserSchool()."' AND s.PROFILE='teacher'
".(($_REQUEST['period'])?" AND cpsp.PERIOD_ID='".$_REQUEST['period']."'":'')." AND acc.CALENDAR_ID=cp.CALENDAR_ID AND acc.SCHOOL_DATE='".$date."'
AND acc.SYEAR='".UserSyear()."' AND (acc.MINUTES IS NOT NULL AND acc.MINUTES>0)
AND (sp.BLOCK IS NULL AND position(substring('MTWHFSU' FROM cast((SELECT CASE COUNT(school_date)% ".SchoolInfo('NUMBER_DAYS_ROTATION')." WHEN 0 THEN ".SchoolInfo('NUMBER_DAYS_ROTATION')." ELSE COUNT(school_date)% ".SchoolInfo('NUMBER_DAYS_ROTATION')." END AS day_number FROM attendance_calendar WHERE school_date>=(SELECT start_date FROM school_marking_periods WHERE start_date<=acc.SCHOOL_DATE AND end_date>=acc.SCHOOL_DATE AND mp='QTR' AND SCHOOL_ID=cp.SCHOOL_ID) AND school_date<=acc.SCHOOL_DATE AND SCHOOL_ID=cp.SCHOOL_ID) AS INT) FOR 1) IN cpsp.DAYS)>0
OR sp.BLOCK IS NOT NULL AND acc.BLOCK IS NOT NULL AND sp.BLOCK=acc.BLOCK)
ORDER BY FULL_NAME";
$sql = "SELECT s.STAFF_ID," . getDisplayNameSQL( 's' ) . " AS FULL_NAME,
sp.TITLE,cpsp.PERIOD_ID,cp.TITLE AS CP_TITLE,
(SELECT 'Y'
FROM ATTENDANCE_COMPLETED ac
WHERE ac.STAFF_ID=cp.TEACHER_ID
AND ac.SCHOOL_DATE=acc.SCHOOL_DATE
AND ac.PERIOD_ID=sp.PERIOD_ID
AND TABLE_NAME='" . $_REQUEST['table'] . "') AS COMPLETED
FROM STAFF s,COURSE_PERIODS cp,SCHOOL_PERIODS sp,ATTENDANCE_CALENDAR acc,COURSE_PERIOD_SCHOOL_PERIODS cpsp
WHERE cp.COURSE_PERIOD_ID=cpsp.COURSE_PERIOD_ID
AND sp.PERIOD_ID=cpsp.PERIOD_ID AND position('," . $_REQUEST['table'] . ",' IN cp.DOES_ATTENDANCE)>0
AND cp.TEACHER_ID=s.STAFF_ID
AND cp.MARKING_PERIOD_ID IN (" . GetAllMP( 'QTR', GetCurrentMP( 'QTR', $date ) ) . ")
AND cp.SYEAR='" . UserSyear() . "'
AND cp.SCHOOL_ID='" . UserSchool() . "'
AND s.PROFILE='teacher'
" . ( $_REQUEST['period'] ? " AND cpsp.PERIOD_ID='" . $_REQUEST['period'] . "'" : '' ) . "
AND acc.CALENDAR_ID=cp.CALENDAR_ID
AND acc.SCHOOL_DATE='" . $date . "'
AND acc.SYEAR='" . UserSyear() . "'
AND (acc.MINUTES IS NOT NULL AND acc.MINUTES>0)
AND (sp.BLOCK IS NULL
AND position(substring('MTWHFSU' FROM cast((SELECT CASE COUNT(school_date)% " . SchoolInfo( 'NUMBER_DAYS_ROTATION' ) . "
WHEN 0 THEN " . SchoolInfo( 'NUMBER_DAYS_ROTATION' ) . "
ELSE COUNT(school_date)% " . SchoolInfo( 'NUMBER_DAYS_ROTATION' ) . " END AS day_number
FROM attendance_calendar
WHERE school_date>=(SELECT start_date
FROM school_marking_periods
WHERE start_date<=acc.SCHOOL_DATE
AND end_date>=acc.SCHOOL_DATE
AND mp='QTR' AND SCHOOL_ID=cp.SCHOOL_ID)
AND school_date<=acc.SCHOOL_DATE
AND SCHOOL_ID=cp.SCHOOL_ID) AS INT) FOR 1) IN cpsp.DAYS)>0
OR sp.BLOCK IS NOT NULL
AND acc.BLOCK IS NOT NULL
AND sp.BLOCK=acc.BLOCK)
ORDER BY FULL_NAME";
} else {
$sql = "SELECT s.STAFF_ID,s.LAST_NAME||', '||s.FIRST_NAME AS FULL_NAME,sp.TITLE,
cpsp.PERIOD_ID,cp.TITLE AS CP_TITLE,
$sql = "SELECT s.STAFF_ID," . getDisplayNameSQL( 's' ) . " AS FULL_NAME,
sp.TITLE,cpsp.PERIOD_ID,cp.TITLE AS CP_TITLE,
(SELECT 'Y'
FROM ATTENDANCE_COMPLETED ac
WHERE ac.STAFF_ID=cp.TEACHER_ID
......
......@@ -212,7 +212,11 @@ if ( $_REQUEST['modfunc'] === 'save'
else //if user already exists
{
$id = $students[1]['STAFF_ID'];
$staff = DBGet(DBquery("SELECT FIRST_NAME||' '||LAST_NAME AS NAME,USERNAME,PASSWORD FROM STAFF WHERE STAFF_ID='".$id."'"));
$staff = DBGet( DBquery( "SELECT " . getDisplayNameSQL() . " AS NAME,
USERNAME,PASSWORD
FROM STAFF
WHERE STAFF_ID='" . $id . "'" ) );
$account = 'old';
}
......@@ -373,18 +377,27 @@ function _makeChooseCheckbox($value,$title)
return '';
}
function _makeContactSelect($value,$column)
{ global $THIS_RET;
function _makeContactSelect( $value, $column )
{
global $THIS_RET;
if ( ! $THIS_RET['STAFF_ID'])
$RET = DBGet(DBQuery("SELECT sjp.PERSON_ID,sjp.STUDENT_RELATION,p.FIRST_NAME||' '||p.LAST_NAME AS CONTACT
if ( ! $THIS_RET['STAFF_ID'] )
{
$RET = DBGet( DBQuery( "SELECT sjp.PERSON_ID,sjp.STUDENT_RELATION,
p.FIRST_NAME,p.LAST_NAME,p.MIDDLE_NAME
FROM STUDENTS_JOIN_PEOPLE sjp,PEOPLE p
WHERE p.PERSON_ID=sjp.PERSON_ID
AND sjp.STUDENT_ID='".$value."'
AND sjp.ADDRESS_ID='".$THIS_RET['ADDRESS_ID']."'
ORDER BY sjp.STUDENT_RELATION"));
AND sjp.STUDENT_ID='" . $value . "'
AND sjp.ADDRESS_ID='" . $THIS_RET['ADDRESS_ID'] . "'
ORDER BY sjp.STUDENT_RELATION" ) );
}
else
$RET = DBGet(DBQuery("SELECT '' AS PERSON_ID,STAFF_ID AS STUDENT_RELATION,FIRST_NAME||' '||LAST_NAME AS CONTACT FROM STAFF WHERE STAFF_ID='".$THIS_RET['STAFF_ID']."'"));
{
$RET = DBGet( DBQuery( "SELECT '' AS PERSON_ID,STAFF_ID AS STUDENT_RELATION,
FIRST_NAME,LAST_NAME,MIDDLE_NAME
FROM STAFF WHERE
STAFF_ID='" . $THIS_RET['STAFF_ID'] . "'" ) );
}
if (count($RET))
{
......@@ -393,7 +406,13 @@ function _makeContactSelect($value,$column)
foreach ( (array) $RET as $contact)
{
$return .= '<tr><td>'.($contact['PERSON_ID']?'<input type="radio" name="contact['.$value.']" value='.$contact['PERSON_ID'].$checked.' />':'&nbsp;').'</td>';
$return .= '<td>'.$contact['CONTACT'].'</td>';
$return .= '<td>' . getDisplayName(
$contact['FIRST_NAME'],
$contact['LAST_NAME'],
$contact['MIDDLE_NAME']
) . '</td>';
$return .= '<td>('.$contact['STUDENT_RELATION'].')</td></tr>';
$checked = '';
}
......
......@@ -39,7 +39,7 @@ if ( $_REQUEST['modfunc'] === 'save' )
{
$st_list = '\''.implode('\',\'',$_REQUEST['staff']).'\'';
$extra['SELECT'] = ",s.FIRST_NAME||' '||s.LAST_NAME AS NAME,s.USERNAME,s.PASSWORD,s.EMAIL";
$extra['SELECT'] = "," . getDisplayNameSQL( 's' ) . " AS NAME,s.USERNAME,s.PASSWORD,s.EMAIL";
$extra['WHERE'] = " AND s.STAFF_ID IN (" . $st_list . ")";
$RET = GetStaffList( $extra );
......@@ -59,18 +59,21 @@ if ( $_REQUEST['modfunc'] === 'save' )
$password_encrypted = encrypt_password($password);
DBQuery("UPDATE STAFF SET PASSWORD='".$password_encrypted."' WHERE STAFF_ID='".$staff_id."'");
$students_RET = DBGet(DBQuery("SELECT s.FIRST_NAME||' '||s.LAST_NAME AS FULL_NAME
$students_RET = DBGet( DBQuery( "SELECT " . getDisplayNameSQL( 's' ) . " AS FULL_NAME
FROM STUDENTS s,STUDENT_ENROLLMENT sse,STUDENTS_JOIN_USERS sju
WHERE sju.STAFF_ID='".$staff_id."'
WHERE sju.STAFF_ID='" . $staff_id . "'
AND s.STUDENT_ID=sju.STUDENT_ID
AND sse.STUDENT_ID=sju.STUDENT_ID
AND sse.SYEAR='".UserSyear()."'
AND sse.END_DATE IS NULL"));
AND sse.SYEAR='" . UserSyear() . "'
AND sse.END_DATE IS NULL" ) );
//echo '<pre>'; var_dump($students_RET); echo '</pre>';
$student_list = '';
foreach ( (array) $students_RET as $student)
$student_list .= str_replace('&nbsp;',' ',$student['FULL_NAME'])."\r";
foreach ( (array) $students_RET as $student )
{
$student_list .= $student['FULL_NAME'] . "\r";
}
$msg = str_replace('__ASSOCIATED_STUDENTS__',$student_list,$message);
$msg = str_replace('__SCHOOL_ID__',SchoolInfo('TITLE'),$msg);
......
......@@ -276,15 +276,13 @@ if ( isset( $_REQUEST['values'] )
// FJ add SendEmail function.
require_once 'ProgramFunctions/SendEmail.fnc.php';
$student_RET = DBGet( DBQuery( "SELECT FIRST_NAME,LAST_NAME
$student_RET = DBGet( DBQuery( "SELECT " . getDisplayNameSQL() . " AS FULL_NAME
FROM STUDENTS
WHERE STUDENT_ID='" . UserStudentID() . "'" ) );
$student_name = $student_RET[1]['FIRST_NAME'] . ' ' . $student_RET[1]['LAST_NAME'];
$message = sprintf(
_( 'New Registration %s (%d) has been registered by %s.' ),
$student_name,
$student_RET[1]['FULL_NAME'],
UserStudentID(),
User( 'NAME' )
);
......@@ -533,7 +531,7 @@ if ( isset( $custom_fields_RET['200000009'] )
$student_dataquery .= ', CUSTOM_200000009';
}
$student_RET = DBGet( DBQuery( "SELECT FIRST_NAME,LAST_NAME" . $student_dataquery . "
$student_RET = DBGet( DBQuery( "SELECT " . getDisplayNameSQL() . " AS FULL_NAME" . $student_dataquery . "
FROM STUDENTS
WHERE STUDENT_ID='" . UserStudentID() . "'" ) );
......@@ -541,8 +539,8 @@ $student = $student_RET[1];
echo '<hr /><p><b>' . sprintf(
_( 'Information about %s %s' ),
$student['FIRST_NAME'],
$student['LAST_NAME'] ) . ':</b></p>';
$student['FULL_NAME']
) . ':</b></p>';
// Display General Info's tab custom fields (Other Info).
$_REQUEST['category_id'] = '1';
......
......@@ -34,8 +34,8 @@ function EmailReferral( $referral_id, $emails )
FROM DISCIPLINE_REFERRALS
WHERE ID='" . $referral_id . "'" . $where ) );
$categories_RET = DBGet( DBQuery( "SELECT f.ID,u.TITLE,u.SELECT_OPTIONS,f.DATA_TYPE,u.SORT_ORDER
FROM DISCIPLINE_FIELDS f,DISCIPLINE_FIELD_USAGE u
$categories_RET = DBGet( DBQuery( "SELECT f.ID,u.TITLE,u.SELECT_OPTIONS,f.DATA_TYPE,u.SORT_ORDER
FROM DISCIPLINE_FIELDS f,DISCIPLINE_FIELD_USAGE u
WHERE u.DISCIPLINE_FIELD_ID=f.ID
AND u.SCHOOL_ID='" . UserSchool() . "'
AND u.SYEAR='" . UserSyear() . "'
......@@ -45,7 +45,7 @@ function EmailReferral( $referral_id, $emails )
{
$referral = $referral_RET[1];
$student_RET = DBGet( DBQuery( "SELECT FIRST_NAME||' '||LAST_NAME||coalesce(' '||NAME_SUFFIX,' ') AS FULL_NAME
$student_RET = DBGet( DBQuery( "SELECT " . getDisplayNameSQL() . " AS FULL_NAME
FROM STUDENTS
WHERE STUDENT_ID='" . $referral['STUDENT_ID'] . "'" ) );
......@@ -129,4 +129,4 @@ function EmailReferral( $referral_id, $emails )
require_once 'ProgramFunctions/SendEmail.fnc.php';
return SendEmail( $to, $subject,$message, $from );
}
\ No newline at end of file
}
......@@ -111,7 +111,7 @@ echo '</form>';
".(($_REQUEST['period'])?" AND cp.PERIOD_ID='".$_REQUEST['period']."'":'')."
AND NOT EXISTS (SELECT '' FROM ELIGIBILITY_COMPLETED ac WHERE ac.STAFF_ID=cp.TEACHER_ID AND ac.PERIOD_ID = sp.PERIOD_ID AND ac.SCHOOL_DATE BETWEEN '".$start_date."' AND '".$end_date."')
";*/
$sql = "SELECT s.LAST_NAME||', '||s.FIRST_NAME AS FULL_NAME,sp.TITLE,cpsp.PERIOD_ID,
$sql = "SELECT " . getDisplayNameSQL( 's' ) . " AS FULL_NAME,sp.TITLE,cpsp.PERIOD_ID,
s.STAFF_ID,cp.TITLE AS CP_TITLE
FROM STAFF s,COURSE_PERIODS cp,SCHOOL_PERIODS sp,COURSE_PERIOD_SCHOOL_PERIODS cpsp
WHERE cp.COURSE_PERIOD_ID=cpsp.COURSE_PERIOD_ID
......
......@@ -31,8 +31,20 @@ foreach ( (array) $schools_RET as $syear => $schools)
$schools_select[ $syear ][$school['ID']] = $school['TITLE'];
//echo '<pre>'; var_dump($schools_select); echo '</pre>';
$students_RET = DBGet(DBQuery("SELECT fst.TRANSACTION_ID,fst.ACCOUNT_ID,fst.SYEAR,".db_case(array('fst.STUDENT_ID',"''",'NULL',"(SELECT FIRST_NAME||' '||LAST_NAME FROM STUDENTS WHERE STUDENT_ID=fst.STUDENT_ID)"))." AS FULL_NAME,fst.ACCOUNT_ID AS STUDENTS,fst.SCHOOL_ID FROM FOOD_SERVICE_TRANSACTIONS fst WHERE fst.SCHOOL_ID IS NULL"),array('STUDENTS' => '_students','SCHOOL_ID' => '_make_school'));
$staff_RET = DBGet(DBQuery("SELECT fst.TRANSACTION_ID,fst.STAFF_ID,fst.SYEAR,(SELECT FIRST_NAME||' '||LAST_NAME FROM STAFF WHERE STAFF_ID=fst.STAFF_ID) AS FULL_NAME,fst.SCHOOL_ID FROM FOOD_SERVICE_STAFF_TRANSACTIONS fst WHERE fst.SCHOOL_ID IS NULL"),array('SCHOOL_ID' => '_make_staff_school'));
$students_RET = DBGet( DBQuery( "SELECT fst.TRANSACTION_ID,fst.ACCOUNT_ID,fst.SYEAR," .
db_case( array(
'fst.STUDENT_ID',
"''",
'NULL',
"(SELECT " . getDisplayNameSQL() . " FROM STUDENTS WHERE STUDENT_ID=fst.STUDENT_ID)"
) ) . " AS FULL_NAME,fst.ACCOUNT_ID AS STUDENTS,fst.SCHOOL_ID
FROM FOOD_SERVICE_TRANSACTIONS
fst WHERE fst.SCHOOL_ID IS NULL" ), array( 'STUDENTS' => '_students', 'SCHOOL_ID' => '_make_school' ) );
$staff_RET = DBGet( DBQuery( "SELECT fst.TRANSACTION_ID,fst.STAFF_ID,fst.SYEAR,
(SELECT " . getDisplayNameSQL() . " FROM STAFF WHERE STAFF_ID=fst.STAFF_ID) AS FULL_NAME,fst.SCHOOL_ID
FROM FOOD_SERVICE_STAFF_TRANSACTIONS fst
WHERE fst.SCHOOL_ID IS NULL" ), array( 'SCHOOL_ID' => '_make_staff_school' ) );
//echo '<pre>'; var_dump($students_RET); echo '</pre>';
//echo '<pre>'; var_dump($users_RET); echo '</pre>';
......
......@@ -29,11 +29,21 @@ if ( $_REQUEST['modfunc'] === 'update' )
if ( ! $_REQUEST['modfunc']
&& UserStudentID() )
{
$student = DBGet(DBQuery("SELECT s.STUDENT_ID,s.FIRST_NAME||' '||s.LAST_NAME AS FULL_NAME,fssa.ACCOUNT_ID,fssa.STATUS,fssa.DISCOUNT,fssa.BARCODE,(SELECT BALANCE FROM FOOD_SERVICE_ACCOUNTS WHERE ACCOUNT_ID=fssa.ACCOUNT_ID) AS BALANCE FROM STUDENTS s,FOOD_SERVICE_STUDENT_ACCOUNTS fssa WHERE s.STUDENT_ID='".UserStudentID()."' AND fssa.STUDENT_ID=s.STUDENT_ID"));
$student = DBGet( DBQuery( "SELECT s.STUDENT_ID," . getDisplayNameSQL( 's' ) . " AS FULL_NAME,
fssa.ACCOUNT_ID,fssa.STATUS,fssa.DISCOUNT,fssa.BARCODE,
(SELECT BALANCE FROM FOOD_SERVICE_ACCOUNTS WHERE ACCOUNT_ID=fssa.ACCOUNT_ID) AS BALANCE
FROM STUDENTS s,FOOD_SERVICE_STUDENT_ACCOUNTS fssa
WHERE s.STUDENT_ID='" . UserStudentID() . "'
AND fssa.STUDENT_ID=s.STUDENT_ID" ) );
$student = $student[1];
// find other students associated with the same account
$xstudents = DBGet(DBQuery("SELECT s.STUDENT_ID,s.FIRST_NAME||' '||s.LAST_NAME AS FULL_NAME FROM STUDENTS s,FOOD_SERVICE_STUDENT_ACCOUNTS fssa WHERE fssa.ACCOUNT_ID='".$student['ACCOUNT_ID']."' AND s.STUDENT_ID=fssa.STUDENT_ID AND s.STUDENT_ID!='".UserStudentID()."'"));
// Find other students associated with the same account.
$xstudents = DBGet( DBQuery( "SELECT s.STUDENT_ID," . getDisplayNameSQL( 's' ) . " AS FULL_NAME
FROM STUDENTS s,FOOD_SERVICE_STUDENT_ACCOUNTS fssa
WHERE fssa.ACCOUNT_ID='" . $student['ACCOUNT_ID'] . "'
AND s.STUDENT_ID=fssa.STUDENT_ID
AND s.STUDENT_ID!='" . UserStudentID() . "'" ) );
echo '<table class="width-100p valign-top fixed-col"><tr><td>';
......
......@@ -14,7 +14,11 @@ if ( $_REQUEST['modfunc'] === 'update' )
$RET = DBGet(DBQuery("SELECT ACCOUNT_ID FROM FOOD_SERVICE_STUDENT_ACCOUNTS WHERE BARCODE='".trim($_REQUEST['food_service']['BARCODE'])."' AND STUDENT_ID!='".UserStudentID()."'"));
if ( $RET)
{
$student_RET = DBGet(DBQuery("SELECT s.FIRST_NAME||' '||s.LAST_NAME AS FULL_NAME FROM STUDENTS s,FOOD_SERVICE_STUDENT_ACCOUNTS fssa WHERE s.STUDENT_ID=fssa.STUDENT_ID AND fssa.ACCOUNT_ID='".$RET[1]['ACCOUNT_ID']."'"));
$student_RET = DBGet( DBQuery( "SELECT " . getDisplayNameSQL( 's' ) . " AS FULL_NAME
FROM STUDENTS s,FOOD_SERVICE_STUDENT_ACCOUNTS fssa
WHERE s.STUDENT_ID=fssa.STUDENT_ID
AND fssa.ACCOUNT_ID='" . $RET[1]['ACCOUNT_ID'] . "'" ) );
$question = _("Are you sure you want to assign that barcode?");
$message = sprintf(_("That barcode is already assigned to Student <b>%s</b>."),$student_RET[1]['FULL_NAME']).' '._("Hit OK to reassign it to the current student or Cancel to cancel all changes.");
}
......@@ -23,7 +27,10 @@ if ( $_REQUEST['modfunc'] === 'update' )
$RET = DBGet(DBQuery("SELECT STAFF_ID FROM FOOD_SERVICE_STAFF_ACCOUNTS WHERE BARCODE='".trim($_REQUEST['food_service']['BARCODE'])."'"));
if ( $RET)
{
$staff_RET = DBGet(DBQuery("SELECT FIRST_NAME||' '||LAST_NAME AS FULL_NAME FROM STAFF WHERE STAFF_ID='".$RET[1]['STAFF_ID']."'"));
$staff_RET = DBGet( DBQuery( "SELECT " . getDisplayNameSQL() . " AS FULL_NAME
FROM STAFF
WHERE STAFF_ID='" . $RET[1]['STAFF_ID'] . "'" ) );
$question = _("Are you sure you want to assign that barcode?");
$message = sprintf(_("That barcode is already assigned to User <b>%s</b>."),$staff_RET[1]['FULL_NAME']).' '._("Hit OK to reassign it to the current student or Cancel to cancel all changes.");
}
......@@ -86,16 +93,27 @@ echo ErrorMessage( $error );
if (UserStudentID() && ! $_REQUEST['modfunc'])
{
$student = DBGet(DBQuery("SELECT s.STUDENT_ID,s.FIRST_NAME||' '||s.LAST_NAME AS FULL_NAME,fssa.ACCOUNT_ID,fssa.STATUS,fssa.DISCOUNT,fssa.BARCODE,(SELECT BALANCE FROM FOOD_SERVICE_ACCOUNTS WHERE ACCOUNT_ID=fssa.ACCOUNT_ID) AS BALANCE FROM STUDENTS s,FOOD_SERVICE_STUDENT_ACCOUNTS fssa WHERE s.STUDENT_ID='".UserStudentID()."' AND fssa.STUDENT_ID=s.STUDENT_ID"));
$student = DBGet(DBQuery("SELECT s.STUDENT_ID," . getDisplayNameSQL( 's' ) . " AS FULL_NAME,
fssa.ACCOUNT_ID,fssa.STATUS,fssa.DISCOUNT,fssa.BARCODE,
(SELECT BALANCE FROM FOOD_SERVICE_ACCOUNTS WHERE ACCOUNT_ID=fssa.ACCOUNT_ID) AS BALANCE
FROM STUDENTS s,FOOD_SERVICE_STUDENT_ACCOUNTS fssa
WHERE s.STUDENT_ID='" . UserStudentID() . "'
AND fssa.STUDENT_ID=s.STUDENT_ID" ) );
$student = $student[1];
// find other students associated with the same account
$xstudents = DBGet(DBQuery("SELECT s.STUDENT_ID,s.FIRST_NAME||' '||s.LAST_NAME AS FULL_NAME
// Find other students associated with the same account.
$xstudents = DBGet( DBQuery( "SELECT s.STUDENT_ID," . getDisplayNameSQL( 's' ) . " AS FULL_NAME
FROM STUDENTS s,FOOD_SERVICE_STUDENT_ACCOUNTS fssa
WHERE fssa.ACCOUNT_ID='".$student['ACCOUNT_ID']."'
WHERE fssa.ACCOUNT_ID='" . $student['ACCOUNT_ID'] . "'
AND s.STUDENT_ID=fssa.STUDENT_ID
AND s.STUDENT_ID!='".UserStudentID()."'".
($_REQUEST['include_inactive']?'':" AND exists(SELECT '' FROM STUDENT_ENROLLMENT WHERE STUDENT_ID=s.STUDENT_ID AND SYEAR='".UserSyear()."' AND (START_DATE<=CURRENT_DATE AND (END_DATE IS NULL OR CURRENT_DATE<=END_DATE)))")));
AND s.STUDENT_ID!='" . UserStudentID() . "'" .
( $_REQUEST['include_inactive'] ? '' :
" AND exists(SELECT ''
FROM STUDENT_ENROLLMENT
WHERE STUDENT_ID=s.STUDENT_ID
AND SYEAR='" . UserSyear() . "'
AND (START_DATE<=CURRENT_DATE AND (END_DATE IS NULL OR CURRENT_DATE<=END_DATE)))" ) ) );
echo '<form action="Modules.php?modname='.$_REQUEST['modname'].'&modfunc=update" method="POST">';
......
......@@ -30,12 +30,29 @@ if ( UserStudentID()
if ( $_REQUEST['detailed_view']=='true')
{
$RET = DBGet(DBQuery("SELECT fst.TRANSACTION_ID AS TRANS_ID,fst.TRANSACTION_ID,fst.ACCOUNT_ID,fst.SHORT_NAME,fst.STUDENT_ID,fst.DISCOUNT,(SELECT sum(AMOUNT) FROM FOOD_SERVICE_TRANSACTION_ITEMS WHERE TRANSACTION_ID=fst.TRANSACTION_ID) AS AMOUNT,fst.BALANCE,fst.TIMESTAMP AS DATE,fst.DESCRIPTION,".db_case(array('fst.STUDENT_ID',"''",'NULL',"(SELECT LAST_NAME||', '||FIRST_NAME FROM STUDENTS WHERE STUDENT_ID=fst.STUDENT_ID)"))." AS FULL_NAME,".db_case(array('fst.SELLER_ID',"''",'NULL',"(SELECT FIRST_NAME||' '||LAST_NAME FROM STAFF WHERE STAFF_ID=fst.SELLER_ID)"))." AS SELLER
$RET = DBGet( DBQuery( "SELECT fst.TRANSACTION_ID AS TRANS_ID,fst.TRANSACTION_ID,
fst.ACCOUNT_ID,fst.SHORT_NAME,fst.STUDENT_ID,fst.DISCOUNT,
(SELECT sum(AMOUNT)
FROM FOOD_SERVICE_TRANSACTION_ITEMS
WHERE TRANSACTION_ID=fst.TRANSACTION_ID) AS AMOUNT,
fst.BALANCE,fst.TIMESTAMP AS DATE,fst.DESCRIPTION," .
db_case( array(
'fst.STUDENT_ID',
"''",
'NULL',
"(SELECT " . getDisplayNameSQL() . " FROM STUDENTS WHERE STUDENT_ID=fst.STUDENT_ID)"
) ) . " AS FULL_NAME," .
db_case( array(
'fst.SELLER_ID',
"''",
'NULL',
"(SELECT " . getDisplayNameSQL() . " FROM STAFF WHERE STAFF_ID=fst.SELLER_ID)"
) ) . " AS SELLER
FROM FOOD_SERVICE_TRANSACTIONS fst
WHERE SYEAR='".UserSyear()."'
AND fst.TIMESTAMP BETWEEN '".$date."' AND date '".$date."' +1
AND SCHOOL_ID='".UserSchool()."'".$where."
ORDER BY ".($_REQUEST['by_name']?"FULL_NAME,":'')."fst.TRANSACTION_ID DESC"),array('DATE' => 'ProperDateTime','SHORT_NAME' => 'bump_count'));
WHERE SYEAR='" . UserSyear() . "'
AND fst.TIMESTAMP BETWEEN '" . $date . "' AND date '" . $date . "' +1
AND SCHOOL_ID='" . UserSchool() . "'" . $where . "
ORDER BY " . ( $_REQUEST['by_name'] ? "FULL_NAME," : '' ) . "fst.TRANSACTION_ID DESC" ), array( 'DATE' => 'ProperDateTime', 'SHORT_NAME' => 'bump_count' ) );
foreach ( (array) $RET as $RET_key => $RET_val) {
$RET[ $RET_key ]=array_map('types_locale', $RET_val);
......@@ -82,14 +99,23 @@ if ( UserStudentID()
}
else
{
$RET = DBGet(DBQuery("SELECT fst.TRANSACTION_ID,fst.ACCOUNT_ID,fst.SHORT_NAME,fst.STUDENT_ID,fst.DISCOUNT,
(SELECT sum(AMOUNT) FROM FOOD_SERVICE_TRANSACTION_ITEMS WHERE TRANSACTION_ID=fst.TRANSACTION_ID) AS AMOUNT,
fst.BALANCE,fst.TIMESTAMP AS DATE,fst.DESCRIPTION,".db_case(array('fst.STUDENT_ID',"''",'NULL',"(SELECT LAST_NAME||', '||FIRST_NAME FROM STUDENTS WHERE STUDENT_ID=fst.STUDENT_ID)"))." AS FULL_NAME
$RET = DBGet( DBQuery( "SELECT fst.TRANSACTION_ID,fst.ACCOUNT_ID,fst.SHORT_NAME,
fst.STUDENT_ID,fst.DISCOUNT,
(SELECT sum(AMOUNT)
FROM FOOD_SERVICE_TRANSACTION_ITEMS
WHERE TRANSACTION_ID=fst.TRANSACTION_ID) AS AMOUNT,
fst.BALANCE,fst.TIMESTAMP AS DATE,fst.DESCRIPTION," .
db_case( array(
'fst.STUDENT_ID',
"''",
'NULL',
"(SELECT " . getDisplayNameSQL() . " FROM STUDENTS WHERE STUDENT_ID=fst.STUDENT_ID)"