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

Omit DBQuery call for DBGet SELECT, 4

parent b0e1f43a
......@@ -398,7 +398,7 @@ function makePublishing($value,$name)
if (is_null($profiles))
{
$profiles_RET = DBGet(DBQuery("SELECT ID,TITLE FROM USER_PROFILES ORDER BY ID"));
$profiles_RET = DBGet( "SELECT ID,TITLE FROM USER_PROFILES ORDER BY ID" );
//add Profiles with Custom permissions to profiles list
$profiles = array_merge(array(
......
......@@ -110,7 +110,7 @@ echo ErrorMessage( $error );
if ( ! $_REQUEST['modfunc'] )
{
$menus_RET = DBGet(DBQuery('SELECT MENU_ID,TITLE FROM FOOD_SERVICE_MENUS WHERE SCHOOL_ID=\''.UserSchool().'\' ORDER BY SORT_ORDER'),array(),array('MENU_ID'));
$menus_RET = DBGet( 'SELECT MENU_ID,TITLE FROM FOOD_SERVICE_MENUS WHERE SCHOOL_ID=\''.UserSchool().'\' ORDER BY SORT_ORDER',array(),array('MENU_ID'));
if ( ! empty( $_REQUEST['tab_id'] ) )
{
if ( $_REQUEST['tab_id']!='new')
......
......@@ -37,7 +37,7 @@ $header .= ' | <a href="Modules.php?modname=' . $_REQUEST['modname'] . '&modfunc
DrawHeader(($_SESSION['FSA_type']=='staff' ? _('User') : _('Student')).' &minus; '.ProgramTitle());
User('PROFILE')=='student'?'':DrawHeader($header);
$menus_RET = DBGet(DBQuery('SELECT MENU_ID,TITLE FROM FOOD_SERVICE_MENUS WHERE SCHOOL_ID=\''.UserSchool().'\' ORDER BY SORT_ORDER'),array(),array('MENU_ID'));
$menus_RET = DBGet( 'SELECT MENU_ID,TITLE FROM FOOD_SERVICE_MENUS WHERE SCHOOL_ID=\''.UserSchool().'\' ORDER BY SORT_ORDER',array(),array('MENU_ID'));
if ( empty( $_REQUEST['menu_id'] ) )
{
if ( ! $_SESSION['FSA_menu_id'])
......
......@@ -96,7 +96,7 @@ if ( $_REQUEST['modfunc'] === 'delete'
$types = array('DEPOSIT' => _('Deposit'),'CREDIT' => _('Credit'),'DEBIT' => _('Debit'));
$menus_RET = DBGet(DBQuery('SELECT TITLE FROM FOOD_SERVICE_MENUS WHERE SCHOOL_ID=\''.UserSchool().'\' ORDER BY SORT_ORDER'));
$menus_RET = DBGet( 'SELECT TITLE FROM FOOD_SERVICE_MENUS WHERE SCHOOL_ID=\''.UserSchool().'\' ORDER BY SORT_ORDER');
$type_select = _('Type').': <select name=type_select><option value=\'\'>'._('Not Specified').'</option>';
foreach ( (array) $types as $short_name => $type)
......
......@@ -29,21 +29,21 @@ if ( $_REQUEST['modfunc'] === 'update' )
if ( ! $_REQUEST['modfunc']
&& UserStudentID() )
{
$student = DBGet( DBQuery( "SELECT s.STUDENT_ID," . DisplayNameSQL( 's' ) . " AS FULL_NAME,
$student = DBGet( "SELECT s.STUDENT_ID," . DisplayNameSQL( '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" ) );
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," . DisplayNameSQL( 's' ) . " AS FULL_NAME
$xstudents = DBGet( "SELECT s.STUDENT_ID," . DisplayNameSQL( '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() . "'" ) );
AND s.STUDENT_ID!='" . UserStudentID() . "'" );
echo '<table class="width-100p valign-top fixed-col"><tr><td>';
......
......@@ -14,10 +14,10 @@ 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 " . DisplayNameSQL( 's' ) . " AS FULL_NAME
$student_RET = DBGet( "SELECT " . DisplayNameSQL( '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'] . "'" ) );
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.");
......@@ -27,9 +27,9 @@ 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 " . DisplayNameSQL() . " AS FULL_NAME
$staff_RET = DBGet( "SELECT " . DisplayNameSQL() . " AS FULL_NAME
FROM STAFF
WHERE STAFF_ID='" . $RET[1]['STAFF_ID'] . "'" ) );
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.");
......@@ -103,7 +103,7 @@ if (UserStudentID() && ! $_REQUEST['modfunc'])
$student = $student[1];
// Find other students associated with the same account.
$xstudents = DBGet( DBQuery( "SELECT s.STUDENT_ID," . DisplayNameSQL( 's' ) . " AS FULL_NAME
$xstudents = DBGet( "SELECT s.STUDENT_ID," . DisplayNameSQL( '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
......@@ -113,7 +113,7 @@ if (UserStudentID() && ! $_REQUEST['modfunc'])
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 (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,7 +30,7 @@ if ( UserStudentID()
if ( $_REQUEST['detailed_view']=='true')
{
$RET = DBGet( DBQuery( "SELECT fst.TRANSACTION_ID AS TRANS_ID,fst.TRANSACTION_ID,
$RET = DBGet( "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
......@@ -52,7 +52,7 @@ if ( UserStudentID()
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' ) );
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);
......@@ -99,7 +99,7 @@ if ( UserStudentID()
}
else
{
$RET = DBGet( DBQuery( "SELECT fst.TRANSACTION_ID,fst.ACCOUNT_ID,fst.SHORT_NAME,
$RET = DBGet( "SELECT fst.TRANSACTION_ID,fst.ACCOUNT_ID,fst.SHORT_NAME,
fst.STUDENT_ID,fst.DISCOUNT,
(SELECT sum(AMOUNT)
FROM FOOD_SERVICE_TRANSACTION_ITEMS
......@@ -115,7 +115,7 @@ if ( UserStudentID()
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' ) );
ORDER BY " . ( $_REQUEST['by_name'] ? "FULL_NAME," : '' ) . "fst.TRANSACTION_ID DESC", array( 'DATE' => 'ProperDateTime', 'SHORT_NAME' => 'bump_count' ) );
$columns = array(
'TRANSACTION_ID' => _( 'ID' ),
......@@ -138,12 +138,12 @@ if ( UserStudentID()
$type_select .= '<option value="'.$short_name.'"'.($_REQUEST['type_select']==$short_name ? ' selected' : '').'>'.$type['DESCRIPTION'].'</option>';
$type_select .= '</select></span>';
$staff_RET = DBGet( DBquery( "SELECT STAFF_ID," . DisplayNameSQL() . " AS FULL_NAME
$staff_RET = DBGet( "SELECT STAFF_ID," . DisplayNameSQL() . " AS FULL_NAME
FROM STAFF
WHERE SYEAR='" . UserSyear() . "'
AND SCHOOLS LIKE '%," . UserSchool() . ",%'
AND PROFILE='admin'
ORDER BY LAST_NAME" ) );
ORDER BY LAST_NAME" );
$staff_select = '<span class="nobr">'._('User').' <select name=staff_select><option value="">'._('Not Specified').'</option>';
foreach ( (array) $staff_RET as $staff)
......
......@@ -99,7 +99,7 @@ if ( $_REQUEST['modfunc'] === 'save' )
if ( $homeroom )
{
$teacher = DBGet( DBQuery( "SELECT " . DisplayNameSQL( 's' ) . " AS FULL_NAME,cs.TITLE
$teacher = DBGet( "SELECT " . DisplayNameSQL( 's' ) . " AS FULL_NAME,cs.TITLE
FROM STAFF s,SCHEDULE sch,COURSE_PERIODS cp,COURSES c,COURSE_SUBJECTS cs
WHERE s.STAFF_ID=cp.TEACHER_ID
AND sch.STUDENT_ID='" . $student['STUDENT_ID'] . "'
......@@ -108,7 +108,7 @@ if ( $_REQUEST['modfunc'] === 'save' )
AND c.SUBJECT_ID=cs.SUBJECT_ID
AND cs.TITLE='" . $homeroom . "'
AND sch.COURSE_PERIOD_ID=cp.COURSE_PERIOD_ID
AND sch.SYEAR='" . UserSyear() . "'" ) );
AND sch.SYEAR='" . UserSyear() . "'" );
}
else
{
......@@ -116,7 +116,7 @@ if ( $_REQUEST['modfunc'] === 'save' )
/*$teacher = DBGet(DBQuery("SELECT s.FIRST_NAME||' '||s.LAST_NAME AS FULL_NAME,cs.TITLE
FROM STAFF s,SCHEDULE sch,COURSE_PERIODS cp,COURSES c,COURSE_SUBJECTS cs,SCHOOL_PERIODS sp
WHERE s.STAFF_ID=cp.TEACHER_ID AND sch.STUDENT_ID='".$student['STUDENT_ID']."' AND cp.COURSE_ID=sch.COURSE_ID AND c.COURSE_ID=cp.COURSE_ID AND c.SUBJECT_ID=cs.SUBJECT_ID AND sp.PERIOD_ID=cp.PERIOD_ID AND sp.ATTENDANCE='Y' AND sch.COURSE_PERIOD_ID=cp.COURSE_PERIOD_ID AND sch.SYEAR='".UserSyear()."'"));*/
$teacher = DBGet( DBQuery( "SELECT " . DisplayNameSQL( 's' ) . " AS FULL_NAME,cs.TITLE
$teacher = DBGet( "SELECT " . DisplayNameSQL( 's' ) . " AS FULL_NAME,cs.TITLE
FROM STAFF s,SCHEDULE sch,COURSE_PERIODS cp,COURSES c,COURSE_SUBJECTS cs,SCHOOL_PERIODS sp,COURSE_PERIOD_SCHOOL_PERIODS cpsp
WHERE cp.COURSE_PERIOD_ID=cpsp.COURSE_PERIOD_ID
AND s.STAFF_ID=cp.TEACHER_ID
......@@ -127,12 +127,12 @@ if ( $_REQUEST['modfunc'] === 'save' )
AND sp.PERIOD_ID=cpsp.PERIOD_ID
AND sp.ATTENDANCE='Y'
AND sch.COURSE_PERIOD_ID=cp.COURSE_PERIOD_ID
AND sch.SYEAR='" . UserSyear() . "'" ) );
AND sch.SYEAR='" . UserSyear() . "'" );
}
$student['TEACHER'] = $teacher[1]['FULL_NAME'];
$xstudents = DBGet( DBQuery( "SELECT " . DisplayNameSQL( 's' ) . " AS FULL_NAME
$xstudents = DBGet( "SELECT " . DisplayNameSQL( '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
......@@ -141,14 +141,14 @@ if ( $_REQUEST['modfunc'] === 'save' )
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 (START_DATE<=CURRENT_DATE AND (END_DATE IS NULL OR CURRENT_DATE<=END_DATE)))" );
$last_deposit = DBGet( DBQuery( "SELECT (SELECT sum(AMOUNT) FROM FOOD_SERVICE_TRANSACTION_ITEMS WHERE TRANSACTION_ID=fst.TRANSACTION_ID) AS AMOUNT,to_char(fst.TIMESTAMP,'YYYY-MM-DD') AS DATE
$last_deposit = DBGet( "SELECT (SELECT sum(AMOUNT) FROM FOOD_SERVICE_TRANSACTION_ITEMS WHERE TRANSACTION_ID=fst.TRANSACTION_ID) AS AMOUNT,to_char(fst.TIMESTAMP,'YYYY-MM-DD') AS DATE
FROM FOOD_SERVICE_TRANSACTIONS fst
WHERE fst.SHORT_NAME='DEPOSIT'
AND fst.ACCOUNT_ID='" . $student['ACCOUNT_ID'] . "'
AND SYEAR='" . UserSyear() . "'
ORDER BY fst.TRANSACTION_ID DESC LIMIT 1" ), array( 'DATE' => 'ProperDate' ) );
ORDER BY fst.TRANSACTION_ID DESC LIMIT 1", array( 'DATE' => 'ProperDate' ) );
$last_deposit = $last_deposit[1];
if ( $_REQUEST['year_end'] === 'Y' )
......
......@@ -75,12 +75,12 @@ if ( $_REQUEST['modfunc'] === 'submit' )
if (UserStudentID() && ! $_REQUEST['modfunc'])
{
$student = DBGet( DBQuery( "SELECT s.STUDENT_ID," . DisplayNameSQL( 's' ) . " AS FULL_NAME,
$student = DBGet( "SELECT s.STUDENT_ID," . DisplayNameSQL( 's' ) . " AS FULL_NAME,
fsa.ACCOUNT_ID,fsa.STATUS,fsa.DISCOUNT,fsa.BARCODE,
(SELECT BALANCE FROM FOOD_SERVICE_ACCOUNTS WHERE ACCOUNT_ID=fsa.ACCOUNT_ID) AS BALANCE
FROM STUDENTS s,FOOD_SERVICE_STUDENT_ACCOUNTS fsa
WHERE s.STUDENT_ID='" . UserStudentID() . "'
AND fsa.STUDENT_ID=s.STUDENT_ID" ) );
AND fsa.STUDENT_ID=s.STUDENT_ID" );
$student = $student[1];
......@@ -101,7 +101,7 @@ if (UserStudentID() && ! $_REQUEST['modfunc'])
echo '<table class="width-100p">';
echo '<tr class="st"><td class="width-100p valign-top">';
$RET = DBGet(DBQuery('SELECT fsti.DESCRIPTION,fsti.AMOUNT FROM FOOD_SERVICE_TRANSACTIONS fst,FOOD_SERVICE_TRANSACTION_ITEMS fsti WHERE fst.ACCOUNT_ID=\''.$student['ACCOUNT_ID'].'\' AND fst.STUDENT_ID=\''.UserStudentID().'\' AND fst.SYEAR=\''.UserSyear().'\' AND fst.SHORT_NAME=\''.$menus_RET[$_REQUEST['menu_id']][1]['TITLE'].'\' AND fst.TIMESTAMP BETWEEN CURRENT_DATE AND \'tomorrow\' AND fsti.TRANSACTION_ID=fst.TRANSACTION_ID'));
$RET = DBGet( 'SELECT fsti.DESCRIPTION,fsti.AMOUNT FROM FOOD_SERVICE_TRANSACTIONS fst,FOOD_SERVICE_TRANSACTION_ITEMS fsti WHERE fst.ACCOUNT_ID=\''.$student['ACCOUNT_ID'].'\' AND fst.STUDENT_ID=\''.UserStudentID().'\' AND fst.SYEAR=\''.UserSyear().'\' AND fst.SHORT_NAME=\''.$menus_RET[$_REQUEST['menu_id']][1]['TITLE'].'\' AND fst.TIMESTAMP BETWEEN CURRENT_DATE AND \'tomorrow\' AND fsti.TRANSACTION_ID=fst.TRANSACTION_ID');
$columns = array('DESCRIPTION' => _('Item'),'AMOUNT' => _('Amount'));
$singular = sprintf(_('Earlier %s Sale'),$menus_RET[$_REQUEST['menu_id']][1]['TITLE']);
......
......@@ -19,12 +19,12 @@ Search('student_id',$extra);
if (UserStudentID() && ! $_REQUEST['modfunc'])
{
$student = DBGet( DBQuery( "SELECT s.STUDENT_ID," . DisplayNameSQL( 's' ) . " AS FULL_NAME,
$student = DBGet( "SELECT s.STUDENT_ID," . DisplayNameSQL( 's' ) . " AS FULL_NAME,
fsa.ACCOUNT_ID,fsa.STATUS,
(SELECT BALANCE FROM FOOD_SERVICE_ACCOUNTS WHERE ACCOUNT_ID=fsa.ACCOUNT_ID) AS BALANCE
FROM STUDENTS s,FOOD_SERVICE_STUDENT_ACCOUNTS fsa
WHERE s.STUDENT_ID='" . UserStudentID() . "'
AND fsa.STUDENT_ID=s.STUDENT_ID" ) );
AND fsa.STUDENT_ID=s.STUDENT_ID" );
$student = $student[1];
......@@ -70,7 +70,7 @@ if (UserStudentID() && ! $_REQUEST['modfunc'])
if ( $_REQUEST['detailed_view']=='true')
{
$RET = DBGet( DBQuery( "SELECT fst.TRANSACTION_ID AS TRANS_ID,fst.TRANSACTION_ID,
$RET = DBGet( "SELECT fst.TRANSACTION_ID AS TRANS_ID,fst.TRANSACTION_ID,
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," .
......@@ -91,7 +91,7 @@ if (UserStudentID() && ! $_REQUEST['modfunc'])
AND SYEAR='" . UserSyear() . "'
AND fst.TIMESTAMP BETWEEN '" . $start_date . "' AND date '" . $end_date . "' +1".
$where . "
ORDER BY fst.TRANSACTION_ID DESC" ), array( 'DATE' => 'ProperDateTime', 'BALANCE' => 'red' ) );
ORDER BY fst.TRANSACTION_ID DESC", array( 'DATE' => 'ProperDateTime', 'BALANCE' => 'red' ) );
foreach ( (array) $RET as $RET_key => $RET_val) {
$RET[ $RET_key ]=array_map('types_locale', $RET_val);
......
......@@ -7,13 +7,15 @@ if ( $_REQUEST['values']
if ( UserStudentID()
&& AllowEdit() )
{
$account_id = DBGet( DBQuery( "SELECT ACCOUNT_ID FROM FOOD_SERVICE_STUDENT_ACCOUNTS WHERE STUDENT_ID='" . UserStudentID() . "'" ) );
$account_id = DBGet( "SELECT ACCOUNT_ID
FROM FOOD_SERVICE_STUDENT_ACCOUNTS
WHERE STUDENT_ID='" . UserStudentID() . "'" );
$account_id = $account_id[1]['ACCOUNT_ID'];
if ( ( $_REQUEST['values']['TYPE'] == 'Deposit' || $_REQUEST['values']['TYPE'] == 'Credit' || $_REQUEST['values']['TYPE'] == 'Debit' ) && ( $amount = is_money( $_REQUEST['values']['AMOUNT'] ) ) )
{
// get next transaction id
$id = DBGet( DBQuery( "SELECT " . db_seq_nextval( 'FOOD_SERVICE_TRANSACTIONS_SEQ' ) . " AS SEQ_ID " ) );
$id = DBGet( "SELECT " . db_seq_nextval( 'FOOD_SERVICE_TRANSACTIONS_SEQ' ) . " AS SEQ_ID " );
$id = $id[1]['SEQ_ID'];
$full_description = DBEscapeString( _( $_REQUEST['values']['OPTION'] ) ) . ' ' . $_REQUEST['values']['DESCRIPTION'];
......@@ -68,12 +70,12 @@ echo ErrorMessage( $error );
if ( UserStudentID()
&& ! $_REQUEST['modfunc'] )
{
$student = DBGet( DBQuery( "SELECT s.STUDENT_ID," . DisplayNameSQL( 's' ) . " AS FULL_NAME,
$student = DBGet( "SELECT s.STUDENT_ID," . DisplayNameSQL( 's' ) . " AS FULL_NAME,
fsa.ACCOUNT_ID,fsa.STATUS,
(SELECT BALANCE FROM FOOD_SERVICE_ACCOUNTS WHERE ACCOUNT_ID=fsa.ACCOUNT_ID) AS BALANCE
FROM STUDENTS s,FOOD_SERVICE_STUDENT_ACCOUNTS fsa
WHERE s.STUDENT_ID='" . UserStudentID() . "'
AND fsa.STUDENT_ID=s.STUDENT_ID" ) );
AND fsa.STUDENT_ID=s.STUDENT_ID" );
$student = $student[1];
......@@ -86,13 +88,13 @@ if ( UserStudentID()
if ( $student['BALANCE'] != '' )
{
$RET = DBGet( DBQuery( "SELECT fst.TRANSACTION_ID,fst.DESCRIPTION AS TYPE,fsti.DESCRIPTION,fsti.AMOUNT
$RET = DBGet( "SELECT fst.TRANSACTION_ID,fst.DESCRIPTION AS TYPE,fsti.DESCRIPTION,fsti.AMOUNT
FROM FOOD_SERVICE_TRANSACTIONS fst,FOOD_SERVICE_TRANSACTION_ITEMS fsti
WHERE fst.SYEAR='" . UserSyear() . "'
AND fst.ACCOUNT_ID='" . $student['ACCOUNT_ID'] . "'
AND (fst.STUDENT_ID IS NULL OR fst.STUDENT_ID='" . UserStudentID() . "')
AND fst.TIMESTAMP BETWEEN CURRENT_DATE AND CURRENT_DATE+1
AND fsti.TRANSACTION_ID=fst.TRANSACTION_ID" ) );
AND fsti.TRANSACTION_ID=fst.TRANSACTION_ID" );
// TODO: code duplication!
/**
......
......@@ -32,7 +32,7 @@ if ( !trim($course_RET[1]['DOES_FS_COUNTS'],','))
// the following query is for when doea_fs_counts is a comma quoted string of meal_id's, ex. ,1,2,4,
//$menus_RET = DBGet(DBQuery('SELECT MENU_ID,TITLE FROM FOOD_SERVICE_MENUS WHERE SCHOOL_ID=\''.UserSchool().'\' AND MENU_ID IN ('.trim($course_RET[1]['DOES_FS_COUNTS'],',').') ORDER BY SORT_ORDER'),array(),array('MENU_ID'));
// use all meal_id's for now
$menus_RET = DBGet(DBQuery('SELECT MENU_ID,TITLE FROM FOOD_SERVICE_MENUS WHERE SCHOOL_ID=\''.UserSchool().'\' ORDER BY SORT_ORDER'),array(),array('MENU_ID'));
$menus_RET = DBGet( 'SELECT MENU_ID,TITLE FROM FOOD_SERVICE_MENUS WHERE SCHOOL_ID=\''.UserSchool().'\' ORDER BY SORT_ORDER',array(),array('MENU_ID'));
//echo '<pre>'; var_dump($menus_RET); echo '</pre>';
if ( empty( $_REQUEST['menu_id'] ) )
if ( ! $_SESSION['FSA_menu_id'] || ! $menus_RET[$_SESSION['FSA_menu_id']])
......@@ -109,7 +109,7 @@ if ( !isset($_ROSARIO['allow_edit']))
}
}
$current_RET = DBGet(DBQuery('SELECT ITEM_ID FROM FOOD_SERVICE_COMPLETED WHERE STAFF_ID=\''.User('STAFF_ID').'\' AND SCHOOL_DATE=\''.$date.'\' AND PERIOD_ID=\''.UserPeriod().'\' AND MENU_ID=\''.$_REQUEST['menu_id'].'\''),array(),array('ITEM_ID'));
$current_RET = DBGet( 'SELECT ITEM_ID FROM FOOD_SERVICE_COMPLETED WHERE STAFF_ID=\''.User('STAFF_ID').'\' AND SCHOOL_DATE=\''.$date.'\' AND PERIOD_ID=\''.UserPeriod().'\' AND MENU_ID=\''.$_REQUEST['menu_id'].'\'',array(),array('ITEM_ID'));
//echo '<pre>'; var_dump($current_RET); echo '</pre>';
if ( $_REQUEST['values']
&& $_POST['values'] )
......@@ -140,7 +140,7 @@ if ( $_REQUEST['values']
if ( $date != DBDate())
$date_note = ' <span style="color:red">'._('The selected date is not today').'</span>';
$completed = DBGet(DBQuery('SELECT count(\'Y\') AS COMPLETED FROM FOOD_SERVICE_COMPLETED WHERE STAFF_ID=\''.User('STAFF_ID').'\' AND SCHOOL_DATE=\''.$date.'\' AND PERIOD_ID=\''.UserPeriod().'\' AND MENU_ID=\''.$_REQUEST['menu_id'].'\''));
$completed = DBGet( 'SELECT count(\'Y\') AS COMPLETED FROM FOOD_SERVICE_COMPLETED WHERE STAFF_ID=\''.User('STAFF_ID').'\' AND SCHOOL_DATE=\''.$date.'\' AND PERIOD_ID=\''.UserPeriod().'\' AND MENU_ID=\''.$_REQUEST['menu_id'].'\'');
if ( $completed[1]['COMPLETED'])
$note[] = button('check')._('You have taken lunch counts today for this period.');
......@@ -150,7 +150,7 @@ DrawHeader(PrepareDate($date,'_date',false,array('submit'=>true)).$date_note,Sub
echo ErrorMessage( $note, 'note' );
$meal_RET = DBGet(DBQuery('SELECT DESCRIPTION FROM CALENDAR_EVENTS WHERE SYEAR='.UserSyear().' AND SCHOOL_ID='.UserSchool().' AND SCHOOL_DATE=\''.$date.'\' AND TITLE=\''.$menus_RET[$_REQUEST['menu_id']][1]['TITLE'].'\''));
$meal_RET = DBGet( 'SELECT DESCRIPTION FROM CALENDAR_EVENTS WHERE SYEAR='.UserSyear().' AND SCHOOL_ID='.UserSchool().' AND SCHOOL_DATE=\''.$date.'\' AND TITLE=\''.$menus_RET[$_REQUEST['menu_id']][1]['TITLE'].'\'' );
if ( $meal_RET)
{
......@@ -160,7 +160,7 @@ if ( $meal_RET)
echo '</td></tr></table><hr />';
}
$items_RET = DBGet(DBQuery('SELECT fsi.ITEM_ID,fsi.DESCRIPTION,fsmi.DOES_COUNT,(SELECT COUNT FROM FOOD_SERVICE_COMPLETED WHERE STAFF_ID=\''.User('STAFF_ID').'\' AND SCHOOL_DATE=\''.$date.'\' AND PERIOD_ID=\''.UserPeriod().'\' AND ITEM_ID=fsi.ITEM_ID AND MENU_ID=fsmi.MENU_ID) AS COUNT FROM FOOD_SERVICE_ITEMS fsi,FOOD_SERVICE_MENU_ITEMS fsmi WHERE fsmi.MENU_ID=\''.$_REQUEST['menu_id'].'\' AND fsi.ITEM_ID=fsmi.ITEM_ID AND fsmi.DOES_COUNT IS NOT NULL ORDER BY fsmi.SORT_ORDER'),array('COUNT' => 'makeTextInput'));
$items_RET = DBGet( 'SELECT fsi.ITEM_ID,fsi.DESCRIPTION,fsmi.DOES_COUNT,(SELECT COUNT FROM FOOD_SERVICE_COMPLETED WHERE STAFF_ID=\''.User('STAFF_ID').'\' AND SCHOOL_DATE=\''.$date.'\' AND PERIOD_ID=\''.UserPeriod().'\' AND ITEM_ID=fsi.ITEM_ID AND MENU_ID=fsmi.MENU_ID) AS COUNT FROM FOOD_SERVICE_ITEMS fsi,FOOD_SERVICE_MENU_ITEMS fsmi WHERE fsmi.MENU_ID=\''.$_REQUEST['menu_id'].'\' AND fsi.ITEM_ID=fsmi.ITEM_ID AND fsmi.DOES_COUNT IS NOT NULL ORDER BY fsmi.SORT_ORDER',array('COUNT' => 'makeTextInput'));
echo '<table class="width-100p"><tr><td style="width:50%;">';
$LO_columns = array('DESCRIPTION' => _('Item'),'COUNT' => _('Count'));
......
......@@ -61,7 +61,7 @@ $sql = "SELECT " . DisplayNameSQL( 's' ) . " AS FULL_NAME,sp.TITLE,cpsp.PERIOD_I
$RET = DBGet(DBQuery($sql),array(),array('STAFF_ID','PERIOD_ID'));
$menus_RET = DBGet(DBQuery('SELECT MENU_ID,TITLE FROM FOOD_SERVICE_MENUS WHERE SCHOOL_ID=\''.UserSchool().'\' ORDER BY SORT_ORDER'),array(),array('MENU_ID'));
$menus_RET = DBGet( 'SELECT MENU_ID,TITLE FROM FOOD_SERVICE_MENUS WHERE SCHOOL_ID=\''.UserSchool().'\' ORDER BY SORT_ORDER',array(),array('MENU_ID'));
if ( empty( $_REQUEST['menu_id'] ) )
{
if ( ! $_SESSION['FSA_menu_id'])
......
......@@ -26,9 +26,9 @@ if ( $_REQUEST['modfunc'] === 'update' )
$RET = DBGet(DBQuery("SELECT STAFF_ID FROM FOOD_SERVICE_STAFF_ACCOUNTS WHERE BARCODE='".trim($_REQUEST['food_service']['BARCODE'])."' AND STAFF_ID!='".UserStaffID()."'"));
if ( $RET)
{
$staff_RET = DBGet( DBQuery( "SELECT " . DisplayNameSQL() . " AS FULL_NAME
$staff_RET = DBGet( "SELECT " . DisplayNameSQL() . " AS FULL_NAME
FROM STAFF
WHERE STAFF_ID='" . $RET[1]['STAFF_ID'] . "'" ) );
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 user or Cancel to cancel all changes.");
......@@ -38,10 +38,10 @@ if ( $_REQUEST['modfunc'] === 'update' )
$RET = DBGet(DBQuery("SELECT ACCOUNT_ID FROM FOOD_SERVICE_STUDENT_ACCOUNTS WHERE BARCODE='".trim($_REQUEST['food_service']['BARCODE'])."'"));
if ( $RET)
{
$student_RET = DBGet( DBQuery( "SELECT " . DisplayNameSQL( 's' ) . " AS FULL_NAME
$student_RET = DBGet( "SELECT " . DisplayNameSQL( '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'] . "'" ) );
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 user student or Cancel to cancel all changes.");
......@@ -80,9 +80,9 @@ if ( $_REQUEST['modfunc'] === 'create' )
{
if ( UserStaffID()
&& AllowEdit()
&& ! DBGet( DBQuery( "SELECT 1
&& ! DBGet( "SELECT 1
FROM FOOD_SERVICE_STAFF_ACCOUNTS
WHERE STAFF_ID='" . UserStaffID() . "'" ) ) )
WHERE STAFF_ID='" . UserStaffID() . "'" ) )
{
$fields = 'STAFF_ID,BALANCE,TRANSACTION_ID,';
$values = "'" . UserStaffID() . "','0.00','0',";
......@@ -118,13 +118,13 @@ Search('staff_id',$extra);
if (UserStaffID() && ! $_REQUEST['modfunc'])
{
$staff = DBGet( DBQuery( "SELECT s.STAFF_ID," . DisplayNameSQL( 's' ) . " AS FULL_NAME,
$staff = DBGet( "SELECT s.STAFF_ID," . DisplayNameSQL( 's' ) . " AS FULL_NAME,
(SELECT s.STAFF_ID FROM FOOD_SERVICE_STAFF_ACCOUNTS WHERE STAFF_ID=s.STAFF_ID) AS ACCOUNT_ID,
(SELECT STATUS FROM FOOD_SERVICE_STAFF_ACCOUNTS WHERE STAFF_ID=s.STAFF_ID) AS STATUS,
(SELECT BALANCE FROM FOOD_SERVICE_STAFF_ACCOUNTS WHERE STAFF_ID=s.STAFF_ID) AS BALANCE,
(SELECT BARCODE FROM FOOD_SERVICE_STAFF_ACCOUNTS WHERE STAFF_ID=s.STAFF_ID) AS BARCODE
FROM STAFF s
WHERE s.STAFF_ID='" . UserStaffID() . "'" ) );
WHERE s.STAFF_ID='" . UserStaffID() . "'" );
$staff = $staff[1];
......
......@@ -23,7 +23,7 @@ if (UserStaffID() && ! $_REQUEST['modfunc'])
if ( $_REQUEST['detailed_view']=='true')
{
$RET = DBGet( DBQuery( "SELECT fst.TRANSACTION_ID AS TRANS_ID,fst.TRANSACTION_ID,
$RET = DBGet( "SELECT fst.TRANSACTION_ID AS TRANS_ID,fst.TRANSACTION_ID,
fst.SHORT_NAME,fst.STAFF_ID,
(SELECT sum(AMOUNT) FROM FOOD_SERVICE_STAFF_TRANSACTION_ITEMS WHERE TRANSACTION_ID=fst.TRANSACTION_ID) AS AMOUNT,
fst.BALANCE,fst.TIMESTAMP AS DATE,fst.DESCRIPTION," .
......@@ -43,7 +43,7 @@ if (UserStaffID() && ! $_REQUEST['modfunc'])
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' ) );
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);
......@@ -88,7 +88,7 @@ if (UserStaffID() && ! $_REQUEST['modfunc'])
}
else
{
$RET = DBGet( DBQuery( "SELECT fst.TRANSACTION_ID,fst.SHORT_NAME,fst.STAFF_ID,
$RET = DBGet( "SELECT fst.TRANSACTION_ID,fst.SHORT_NAME,fst.STAFF_ID,
(SELECT sum(AMOUNT) FROM FOOD_SERVICE_STAFF_TRANSACTION_ITEMS WHERE TRANSACTION_ID=fst.TRANSACTION_ID) AS AMOUNT,
fst.BALANCE,fst.TIMESTAMP AS DATE,fst.DESCRIPTION," .
db_case( array(
......@@ -101,7 +101,7 @@ if (UserStaffID() && ! $_REQUEST['modfunc'])
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' ) );
ORDER BY " . ( $_REQUEST['by_name'] ? "FULL_NAME," : '' ) . "fst.TRANSACTION_ID DESC", array( 'DATE' => 'ProperDateTime', 'SHORT_NAME' => 'bump_count' ) );
$columns = array(
'TRANSACTION_ID' => _( 'ID' ),
......@@ -122,12 +122,12 @@ if (UserStaffID() && ! $_REQUEST['modfunc'])
$type_select .= '<option value="'.$short_name.'"'.($_REQUEST['type_select']==$short_name ? ' selected' : '').'>'.$type['DESCRIPTION'].'</option>';
$type_select .= '</select></span>';
$staff_RET = DBGet( DBquery( "SELECT STAFF_ID," . DisplayNameSQL() . " AS FULL_NAME
$staff_RET = DBGet( "SELECT STAFF_ID," . DisplayNameSQL() . " AS FULL_NAME
FROM STAFF
WHERE SYEAR='" . UserSyear() . "'
AND SCHOOLS LIKE '%," . UserSchool() . ",%'
AND PROFILE='admin'
ORDER BY LAST_NAME" ) );
ORDER BY LAST_NAME" );
$staff_select = '<span class="nobr">'._('User').' <select name=staff_select><option value="">'._('Not Specified').'</option>';
foreach ( (array) $staff_RET as $staff)
......
......@@ -25,12 +25,12 @@ if ( $_REQUEST['modfunc'] === 'save' )
{
$st_list = "'" . implode( "','", $_REQUEST['st_arr'] ) . "'";
$staffs = DBGet( DBQuery( "SELECT s.FIRST_NAME," . DisplayNameSQL( 's' ) . " AS FULL_NAME,
$staffs = DBGet( "SELECT s.FIRST_NAME," . DisplayNameSQL( 's' ) . " AS FULL_NAME,
s.PROFILE,fsa.STATUS,fsa.BALANCE,s.STAFF_ID
FROM STAFF s,FOOD_SERVICE_STAFF_ACCOUNTS fsa
WHERE s.STAFF_ID IN (" . $st_list . ")
AND fsa.STAFF_ID=s.STAFF_ID
AND s.SYEAR='" . UserSyear() . "'" ) );
AND s.SYEAR='" . UserSyear() . "'" );
$handle = PDFStart();
......@@ -68,14 +68,14 @@ if ( $_REQUEST['modfunc'] === 'save' )
echo '<div style="page-break-after: always;"></div>';
}
$last_deposit = DBGet( DBQuery( "SELECT
$last_deposit = DBGet( "SELECT
(SELECT sum(AMOUNT) FROM FOOD_SERVICE_STAFF_TRANSACTION_ITEMS WHERE TRANSACTION_ID=fst.TRANSACTION_ID) AS AMOUNT,
to_char(fst.TIMESTAMP,'YYYY-MM-DD') AS DATE
FROM FOOD_SERVICE_STAFF_TRANSACTIONS fst
WHERE fst.SHORT_NAME='DEPOSIT'
AND fst.STAFF_ID='" . $staff['STAFF_ID'] . "'
AND SYEAR='" . UserSyear() . "'
ORDER BY fst.TRANSACTION_ID DESC LIMIT 1" ), array( 'DATE' => 'ProperDate' ) );
ORDER BY fst.TRANSACTION_ID DESC LIMIT 1", array( 'DATE' => 'ProperDate' ) );
$last_deposit = $last_deposit[1];
$staff['SCHOOL_TITLE'] = SchoolInfo( 'TITLE' );
......
......@@ -24,7 +24,7 @@ if ( $_REQUEST['modfunc'] === 'submit' )
$items_RET = DBGet(DBQuery("SELECT DESCRIPTION,SHORT_NAME,PRICE_STAFF FROM FOOD_SERVICE_ITEMS WHERE SCHOOL_ID='".UserSchool()."'"),array(),array('SHORT_NAME'));
// get next transaction id
$id = DBGet(DBQuery('SELECT '.db_seq_nextval('FOOD_SERVICE_STAFF_TRANSACTIONS_SEQ').' AS SEQ_ID'));
$id = DBGet( 'SELECT '.db_seq_nextval('FOOD_SERVICE_STAFF_TRANSACTIONS_SEQ').' AS SEQ_ID' );
$id = $id[1]['SEQ_ID'];
$item_id = 0;
......@@ -62,11 +62,11 @@ if ( $_REQUEST['modfunc'] === 'submit' )
if ( UserStaffID()
&& ! $_REQUEST['modfunc'] )
{
$staff = DBGet( DBQuery( "SELECT s.STAFF_ID," . DisplayNameSQL( 's' ) . " AS FULL_NAME,
$staff = DBGet( "SELECT s.STAFF_ID," . DisplayNameSQL( 's' ) . " AS FULL_NAME,
(SELECT STAFF_ID FROM FOOD_SERVICE_STAFF_ACCOUNTS WHERE STAFF_ID=s.STAFF_ID) AS ACCOUNT_ID,
(SELECT BALANCE FROM FOOD_SERVICE_STAFF_ACCOUNTS WHERE STAFF_ID=s.STAFF_ID) AS BALANCE
FROM STAFF s
WHERE s.STAFF_ID='" . UserStaffID() . "'" ) );
WHERE s.STAFF_ID='" . UserStaffID() . "'" );
$staff = $staff[1];
......
......@@ -13,11 +13,11 @@ Search('staff_id',$extra);
if (UserStaffID() && ! $_REQUEST['modfunc'])
{
$staff = DBGet( DBQuery( "SELECT s.STAFF_ID," . DisplayNameSQL( 's' ) . " AS FULL_NAME,
$staff = DBGet( "SELECT s.STAFF_ID," . DisplayNameSQL( 's' ) . " AS FULL_NAME,
(SELECT STAFF_ID FROM FOOD_SERVICE_STAFF_ACCOUNTS WHERE STAFF_ID=s.STAFF_ID) AS ACCOUNT_ID,
(SELECT BALANCE FROM FOOD_SERVICE_STAFF_ACCOUNTS WHERE STAFF_ID=s.STAFF_ID) AS BALANCE
FROM STAFF s
WHERE s.STAFF_ID='" . UserStaffID() . "'" ) );
WHERE s.STAFF_ID='" . UserStaffID() . "'" );
$staff = $staff[1];
......@@ -41,7 +41,7 @@ if (UserStaffID() && ! $_REQUEST['modfunc'])
if ( $_REQUEST['detailed_view']=='true')
{
$RET = DBGet( DBQuery( "SELECT fst.TRANSACTION_ID AS TRANS_ID,fst.TRANSACTION_ID,
$RET = DBGet( "SELECT fst.TRANSACTION_ID AS TRANS_ID,fst.TRANSACTION_ID,
(SELECT sum(AMOUNT) FROM FOOD_SERVICE_STAFF_TRANSACTION_ITEMS WHERE TRANSACTION_ID=fst.TRANSACTION_ID) AS AMOUNT,
fst.STAFF_ID,fst.BALANCE,fst.TIMESTAMP AS DATE,fst.DESCRIPTION," .
db_case( array(
......@@ -55,7 +55,7 @@ if (UserStaffID() && ! $_REQUEST['modfunc'])
AND fst.SYEAR='" . UserSyear() . "'
AND fst.TIMESTAMP BETWEEN '" . $start_date . "' AND date '" . $end_date . "' +1".
$where . "
ORDER BY fst.TRANSACTION_ID DESC" ), array( 'DATE' => 'ProperDateTime', 'BALANCE' => 'red' ) );
ORDER BY fst.TRANSACTION_ID DESC", array( 'DATE' => 'ProperDateTime', 'BALANCE' => 'red' ) );
foreach ( (array) $RET as $RET_key => $RET_val) {
$RET[ $RET_key ]=array_map('types_locale', $RET_val);
......@@ -64,7 +64,7 @@ if (UserStaffID() && ! $_REQUEST['modfunc'])
// get details of each transaction
foreach ( (array) $RET as $key => $value)
{