First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
require_once("include/globals.php");
|
||||
|
||||
// Start the template and output buffering
|
||||
startTemplate();
|
||||
$templatePageTitle = getLanguageText('TEXT-SUPPLIER-LOG');
|
||||
$headerArgs = "";
|
||||
|
||||
|
||||
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
||||
header("Location: /");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// Ensure that only valid user types have access to this module
|
||||
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Administration Team','Schedule Team');
|
||||
if (checkPermission($AllowedUserTypes) != 1) {
|
||||
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
||||
$action = '';
|
||||
$naction = '';
|
||||
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Get supplier info
|
||||
//
|
||||
if (array_key_exists('supplier_num',$_GET)) $supplier_num = intval($_GET['supplier_num']);
|
||||
if (array_key_exists('supplier_num',$_POST)) $supplier_num = intval($_POST['supplier_num']);
|
||||
|
||||
if (!isset($supplier_num)) {
|
||||
$error_message = getLanguageText('ERRORMSG-MISSING-DATA');
|
||||
$naction = '';
|
||||
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
|
||||
$query = "select * from suppliers " .
|
||||
"where school_num = $supplier_school_num " .
|
||||
"and record_num = $supplier_num";
|
||||
$results = db_query($query);
|
||||
|
||||
if (db_num_rows($results) == 0) {
|
||||
$error_message = getLanguageText('ERRORMSG-MISSING-DATA');
|
||||
$naction = '';
|
||||
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
|
||||
$supplier = db_fetch_array($results);
|
||||
$supplier_name = $supplier['supplier_name'];
|
||||
|
||||
|
||||
//
|
||||
// Process all actions to list and edit records
|
||||
//
|
||||
$CurrentTable = "supplier_log";
|
||||
$DeleteField = "log_type,log_time,log_title";
|
||||
$dSeparator = "<br> ";
|
||||
$FormFile = "supplier_log.form.php";
|
||||
$TitleText = "Supplier Log";
|
||||
$OrderBy = "supplier_time";
|
||||
|
||||
|
||||
|
||||
|
||||
if (array_key_exists('naction',$_GET)) $naction = $_GET['naction'];
|
||||
if (array_key_exists('naction',$_POST)) $naction = $_POST['naction'];
|
||||
|
||||
$school_num = $school_record['record_num'];
|
||||
|
||||
|
||||
switch (strtolower($naction)) {
|
||||
case "add":
|
||||
$PageTitle = "Create a New $TitleText";
|
||||
$ButtonText = "Add $TitleText";
|
||||
$next_naction = "insert";
|
||||
|
||||
$active = 'Y';
|
||||
|
||||
include $FormFile;
|
||||
break;
|
||||
|
||||
case "insert":
|
||||
extract($_POST);
|
||||
|
||||
// Save the record
|
||||
$table = new Table("$CurrentTable");
|
||||
$query = $table->BuildInsert();
|
||||
db_query($query);
|
||||
$form_message = "$TitleText Has Been Inserted";
|
||||
$naction = "list";
|
||||
break;
|
||||
|
||||
case "edit":
|
||||
$PageTitle = "Edit an Existing $TitleText";
|
||||
$ButtonText = "Update $TitleText";
|
||||
$next_naction = "update";
|
||||
|
||||
// Get current record
|
||||
$record_num = intval($_GET['record_num']);
|
||||
$query = "select * from $CurrentTable " .
|
||||
"where school_num = $school_num " .
|
||||
"and record_num = $record_num";
|
||||
$results = db_query($query);
|
||||
if (db_num_rows($results) == 1) {
|
||||
$row = db_fetch_array($results);
|
||||
extract($row);
|
||||
include $FormFile;
|
||||
}
|
||||
else {
|
||||
$error_message = "Error: Record Not Found";
|
||||
}
|
||||
break;
|
||||
|
||||
case "update":
|
||||
extract($_POST);
|
||||
|
||||
if ($status != 'Deleted') $deleted_date = '';
|
||||
if ($status == 'Deleted') $deleted_date = date("Y-m-d",time());
|
||||
|
||||
$table = new Table("$CurrentTable");
|
||||
$query = $table->BuildUpdate();
|
||||
db_query($query);
|
||||
$form_message = "$TitleText Has Been Updated";
|
||||
$naction = "list";
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
$record_num = intval($_GET['record_num']);
|
||||
|
||||
|
||||
$query = "select * from $CurrentTable " .
|
||||
"where school_num = $school_num " .
|
||||
"and record_num = $record_num";
|
||||
$results = db_query($query);
|
||||
if (db_num_rows($results) == 1) {
|
||||
$row = db_fetch_array($results);
|
||||
extract($row);
|
||||
|
||||
$dFields = explode(",",$DeleteField);
|
||||
$dTitle = "$TitleText ";
|
||||
for ($i = 0; $i < count($dFields); $i++) {
|
||||
$dTitle .= $row[$dFields[$i]] . $dSeparator;
|
||||
}
|
||||
|
||||
$HiddenFields = " <input type='hidden' name='supplier_num' value='$supplier_num'>";
|
||||
include "delete.form.php";
|
||||
}
|
||||
else {
|
||||
$error_message = "Error: Record Not Found";
|
||||
}
|
||||
break;
|
||||
|
||||
case "delete-confirmed":
|
||||
$record_num = intval($_GET['record_num']);
|
||||
|
||||
// Delete the current record
|
||||
$today = date("Y-m-d",time());
|
||||
$query = "delete from $CurrentTable " .
|
||||
"where school_num = $school_num " .
|
||||
"and record_num = $record_num";
|
||||
db_query($query);
|
||||
|
||||
$form_message = "$TitleText Has Been Deleted";
|
||||
$naction = "list";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// List all records if naction is "list"
|
||||
//
|
||||
if ($naction == "list" || $naction == 'list-all') {
|
||||
|
||||
// Handle sub selections
|
||||
$swhere = "";
|
||||
if (array_key_exists('show_type',$_POST)) {
|
||||
$show_type = $_POST['show_type'];
|
||||
$swhere .= "and log_type = '$show_type' ";
|
||||
}
|
||||
|
||||
if (array_key_exists('show_status',$_POST)) {
|
||||
$show_status = $_POST['show_status'];
|
||||
$swhere .= "and status = '$show_status' ";
|
||||
}
|
||||
|
||||
// Get records to display
|
||||
$columnHeaders = array(getLanguageText('TEXT-TIME'),
|
||||
getLanguageText('TEXT-TYPE'),
|
||||
getLanguageText('TEXT-STATUS'),
|
||||
getLanguageText('TEXT-TITLE')
|
||||
);
|
||||
$query = "select log_time,log_type,status,log_title,record_num " .
|
||||
"from supplier_log " .
|
||||
"where school_num = $school_num " .
|
||||
"and supplier_num = $supplier_num " .
|
||||
"order by log_time,log_type";
|
||||
$results = db_query($query);
|
||||
|
||||
$message_width = $default_data_width;
|
||||
include "form.messages.php";
|
||||
|
||||
echo("<center>\n");
|
||||
echo("<p><b>$TitleText List</b></p>\n");
|
||||
if (isset($page_links) && strlen($page_links) > 0) echo("<p>$page_links</p>\n");
|
||||
echo("</center>\n");
|
||||
|
||||
$action = "$action&supplier_num=$supplier_num";
|
||||
listData($results,$columnHeaders,$action);
|
||||
|
||||
}
|
||||
|
||||
endTemplate();
|
||||
?>
|
||||
Reference in new issue
Block a user