\n"); $error_message = getLanguageText('ERRORMSG-ACCESS-DENIED'); include "form.messages.php"; return; } // Start the template and output buffering startTemplate(); $templatePageTitle = "School Referrals"; include "schools.options.php"; if (array_key_exists('naction',$_GET)) $naction = $_GET['naction']; if (array_key_exists('naction',$_POST)) $naction = $_POST['naction']; switch (strtolower($naction)) { case "edit": include "schools-referrals.form.php"; break; case "save": // Delete any existing entries $school_num = intval($_POST["school_num"]); db_query("DELETE FROM school_referrals WHERE school_num = $school_num"); $table = new Table("school_referrals"); // Save defined entries for ($n = 0; $n < 2; $n++) { if (array_key_exists("rschool$n",$_POST) && $_POST["rschool$n"] > 0) { $referring_school_num = intval($_POST["rschool$n"]); $credit_amount = $_POST["credit_amount$n"]; $credit_given = $_POST["credit_given$n"]; $invoice_num = $_POST["invoice_num$n"]; $sequence = $n; $query = $table->BuildInsert(); db_query($query); } } break; } // Get records to display $columnHeaders = array("School Name","Referred By","Credit Amount","Credited","Invoice Num"); $columnAlign = array('left','left','right','center','center'); $query = "select concat('',school_name,'') as name,record_num " . "from schools " . "where status in ('Pending','Trial','Active') " . "order by school_name"; $schools = db_query($query); $data = array(); $count = 0; while ($row = db_fetch_array($schools)) { $data[$count][0] = $row['name']; $data[$count]['record_num'] = $row['record_num']; $snum = $row['record_num']; $results = db_query("SELECT * FROM school_referrals WHERE school_num = $snum"); if (db_num_rows($results) == 0) { $count++; continue; } while ($referral = db_fetch_array($results)) { $data[$count][0] = $row['name']; $data[$count]['record_num'] = $row['record_num']; $data[$count][2] = $referral['credit_amount']; $data[$count][3] = $referral['credit_given']; $data[$count][4] = $referral['invoice_num']; $rnum = $referral['referring_school_num']; $data[$count][1] = db_getVal("SELECT school_name FROM schools WHERE record_num = $rnum"); $count++; } } $edit_icon = "Edit Referral"; $commands = array("$edit_icon"); listDataCustom($data,$columnHeaders,'schools-referrals',$commands,'N',$columnAlign); echo("
\n"); include "schools.options.php"; endTemplate(); ?>