First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
require_once("include/globals.php");
|
||||
|
||||
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
||||
header("Location: /");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// Start the template and output buffering
|
||||
startTemplate();
|
||||
$templatePageTitle = "";
|
||||
$headerArgs = "";
|
||||
|
||||
|
||||
// Ensure that only valid user types have access to this module
|
||||
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Administration Team','Schedule Team','Supplier');
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
$subtitle = "";
|
||||
$swhere = "";
|
||||
unset($selected_supplier);
|
||||
if (array_key_exists('selected_supplier',$_GET) && strlen($_GET['selected_supplier']) > 0) $selected_supplier = $_GET['selected_supplier'];
|
||||
if (array_key_exists('selected_supplier',$_POST) && strlen($_POST['selected_supplier']) > 0) $selected_supplier = $_POST['selected_supplier'];
|
||||
|
||||
if (isset($selected_supplier)) {
|
||||
$results = db_query("select * from suppliers where school_num = $school_num and record_num = $selected_supplier");
|
||||
if (db_num_rows($results) != 1) {
|
||||
echo("<br>\n");
|
||||
$error_message = "Invalid supplier number";
|
||||
include "form.messages.php";
|
||||
return;
|
||||
}
|
||||
|
||||
$supplier = db_fetch_array($results);
|
||||
$subtitle = " - " . $supplier['supplier_name'];
|
||||
$swhere = "and supplier_num = $selected_supplier ";
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Process all actions to list and edit records
|
||||
//
|
||||
$naction = "";
|
||||
|
||||
$templatePageTitle = getLanguageText('TEXT-SUPPLIER-PRODUCT-UPDATE');
|
||||
|
||||
|
||||
if (array_key_exists('naction',$_GET)) $naction = $_GET['naction'];
|
||||
if (array_key_exists('naction',$_POST)) $naction = $_POST['naction'];
|
||||
|
||||
|
||||
switch (strtolower($naction)) {
|
||||
case "update":
|
||||
|
||||
// Loop through the products and update the prices
|
||||
$query = "select s.supplier_name,sp.* from supplier_products as sp, suppliers as s " .
|
||||
"where sp.school_num = $supplier_school_num " .
|
||||
"and s.school_num = $supplier_school_num " .
|
||||
"and sp.supplier_num = s.record_num " .
|
||||
"AND sp.status = 'Active' " .
|
||||
$swhere .
|
||||
"order by supplier_name,product_name";
|
||||
$products = db_query($query);
|
||||
|
||||
while ($product = db_fetch_array($products)) {
|
||||
$product_num = $product['record_num'];
|
||||
|
||||
// Setup field names
|
||||
$sfield = "supplier_$product_num";
|
||||
$nfield = "name_$product_num";
|
||||
$mfield = "item_message_$product_num";
|
||||
|
||||
$snum = $_POST[$sfield];
|
||||
$name = db_escape_string($_POST[$nfield]);
|
||||
$msg = db_escape_string($_POST[$mfield]);
|
||||
|
||||
// Update database
|
||||
$query = "update supplier_products " .
|
||||
"set supplier_num = $snum, " .
|
||||
"product_name = '$name', " .
|
||||
"item_message = '$msg' " .
|
||||
"where school_num = $supplier_school_num " .
|
||||
"and record_num = $product_num";
|
||||
db_query($query);
|
||||
}
|
||||
|
||||
$form_message = "Products Have Been Updated";
|
||||
break;
|
||||
}
|
||||
|
||||
// Display the selected menu form
|
||||
include "supplier_products_update.message.form.php";
|
||||
|
||||
endTemplate();
|
||||
?>
|
||||
Reference in new issue
Block a user