First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
require_once("include/globals.php");
|
||||
|
||||
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','Supplier');
|
||||
if (checkPermission($AllowedUserTypes) != 1) {
|
||||
echo("<br>\n");
|
||||
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
||||
include "form.messages.php";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$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 ";
|
||||
}
|
||||
|
||||
|
||||
// Start the template and output buffering
|
||||
startTemplate();
|
||||
$templatePageTitle = getLanguageText('TEXT-SUPPLIER-PRODUCT-ADMIN') . $subtitle;
|
||||
$headerArgs = "";
|
||||
|
||||
|
||||
//
|
||||
// Process all actions to list and edit records
|
||||
//
|
||||
$naction = "";
|
||||
|
||||
|
||||
|
||||
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 sp.supplier_num = s.record_num " .
|
||||
$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
|
||||
$qfield = "qty_$product_num";
|
||||
$cfield = "cost_$product_num";
|
||||
$afield = "margin_$product_num";
|
||||
$tfield = "tax_$product_num";
|
||||
$ofield = "oprice_$product_num";
|
||||
$pfield = "pprice_$product_num";
|
||||
|
||||
$entered_qty = sprintf("%0d",$_POST[$qfield]);
|
||||
$entered_cost = sprintf("%0.2f",str_replace('$','',$_POST[$cfield]));
|
||||
$entered_margin = sprintf("%0.2f",str_replace('$','',$_POST[$afield]));
|
||||
$entered_oprice = sprintf("%0.2f",str_replace('$','',$_POST[$ofield]));
|
||||
$entered_pprice = sprintf("%0.2f",str_replace('$','',$_POST[$pfield]));
|
||||
$taxable_product = $_POST[$tfield];
|
||||
|
||||
// Handle any additional fields
|
||||
$additionalSQL = "";
|
||||
|
||||
// BC Food Guidelines
|
||||
if ($school_record['display_bc_food_guidelines'] == 'Y') {
|
||||
if (array_key_exists("bc_guideline_rating_$product_num", $_POST) && strlen($_POST["bc_guideline_rating_$product_num"]) > 0) {
|
||||
$additionalSQL .= ", bc_guideline_rating = '" . $_POST["bc_guideline_rating_$product_num"] . "' ";
|
||||
}
|
||||
}
|
||||
|
||||
$query = "update supplier_products " .
|
||||
"set package_qty = $entered_qty, " .
|
||||
"package_cost = $entered_cost, " .
|
||||
"margin_cost = $entered_margin, " .
|
||||
"taxable_product = '$taxable_product', " .
|
||||
"standard_online_price = $entered_oprice, " .
|
||||
"standard_offline_price = $entered_pprice " .
|
||||
$additionalSQL .
|
||||
"where school_num = $supplier_school_num " .
|
||||
"and record_num = $product_num";
|
||||
db_query($query);
|
||||
}
|
||||
|
||||
$form_message = "Prices Have Been Updated";
|
||||
break;
|
||||
|
||||
case "update-special":
|
||||
|
||||
// Loop through the products and update the special prices
|
||||
$query = "select s.supplier_name,sp.* from supplier_products as sp, suppliers as s " .
|
||||
"where sp.school_num = $supplier_school_num " .
|
||||
"and sp.supplier_num = s.record_num " .
|
||||
$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
|
||||
$field1 = "price1_$product_num";
|
||||
$field2 = "price2_$product_num";
|
||||
$field3 = "price3_$product_num";
|
||||
|
||||
$entered_price1 = sprintf("%0.2f",str_replace('$','',$_POST[$field1]));
|
||||
$entered_price2 = sprintf("%0.2f",str_replace('$','',$_POST[$field2]));
|
||||
$entered_price3 = sprintf("%0.2f",str_replace('$','',$_POST[$field3]));
|
||||
|
||||
$query = "update supplier_products " .
|
||||
"set special_price1 = $entered_price1, " .
|
||||
"special_price2 = $entered_price2, " .
|
||||
"special_price3 = $entered_price3 " .
|
||||
"where school_num = $supplier_school_num " .
|
||||
"and record_num = $product_num";
|
||||
db_query($query);
|
||||
}
|
||||
|
||||
$form_message = "Prices Have Been Updated";
|
||||
break;
|
||||
}
|
||||
|
||||
// Display the selected menu form
|
||||
if ($action == 'supplier-products-update') include "supplier_products_update.form.php";
|
||||
if ($action == 'supplier-products-update-special') include "supplier_products_update.special.form.php";
|
||||
|
||||
endTemplate();
|
||||
?>
|
||||
Reference in new issue
Block a user