Files
HotLunches/supplier_products_update.message.form.php
2026-10-19 15:22:52 -07:00

146 lines
4.4 KiB
PHP

<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
?>
<br>
<form method='post' action='/' name='updateform'>
<?php
$form_width = '80%';
$message_width = $form_width;
include "form.messages.php";
$numDataCols = 3;
?>
<table width='95%' class='content-table'>
<tr>
<td align='center' class='heading'>Supplier Product Message Update</td>
</tr>
<tr>
<td align='center'>
<br>
<table width='95%' cellpadding='1' cellspacing='1' border='0' class='content-table'>
<?php
// Get suppliers to process
$swhere = "";
if (isset($selected_supplier)) $swhere = "and record_num = $selected_supplier ";
$query = "select * from suppliers " .
"where school_num = $supplier_school_num " .
"and status = 'Active' " .
$swhere .
"order by supplier_name";
$suppliers = db_query($query);
while ($supplier = db_fetch_array($suppliers)) {
$supplier_num = $supplier['record_num'];
$supplier_name = $supplier['supplier_name'];
// Get products for this supplier
$query = "select * from supplier_products " .
"where school_num = $supplier_school_num " .
"and supplier_num = $supplier_num " .
"AND status = 'Active' " .
"order by sequence,product_name";
$products = db_query($query);
if (db_num_rows($products) == 0) continue;
?>
<tr>
<td align='left' colspan='<?php echo($numDataCols) ?>' class='success'>
<table width='100%' cellspacing='0' cellpadding='0' border='0'>
<tr>
<td align='left' class='success'><b><?php echo($supplier_name) ?></td>
</tr>
</td>
</table>
</tr>
<tr>
<td width='22%' align='left' class='oitem'><b>SUPPLIER</b></td>
<td width='23%' align='left' class='oitem'><b>ITEM NAME</b></td>
<td align='left' class='oitem'><b>MESSAGE</b></td>
</tr>
<?php
while ($product = db_fetch_array($products)) {
extract($product);
$product_num = $record_num;
// Setup field names
$sfield = "supplier_$product_num";
$nfield = "name_$product_num";
$mfield = "item_message_$product_num";
?>
<tr>
<!--
<td align='left' class='oitem'><?php echo($product_name) ?> ::</td>
-->
<td align='left' class='oitem'>
<select name='<?php echo($sfield) ?>'>
<?php
$results = db_query("SELECT * FROM suppliers WHERE school_num = $supplier_school_num AND status = 'Active' ORDER BY supplier_name");
while ($row = db_fetch_array($results)) {
$snum = $row['record_num'];
$sname = $row['supplier_name'];
$selected = "";
if ($snum == $supplier_num) $selected = " selected='selected'";
echo(" <option value='$snum'$selected>$sname</option>\n");
}
?>
</select>
</td>
<td align='left' class='oitem'><input type='text' name='<?php echo($nfield) ?>' value="<?php echo(str_replace("'","&#39;",$product_name)) ?>" size='30'></td>
<td align='left' class='oitem'><input type='text' name='<?php echo($mfield) ?>' value="<?php echo(str_replace("'","&#39;",$item_message)) ?>" size='80'></td>
</tr>
<?php
}
}
?>
</table>
</td>
</tr>
<tr>
<td align='center'>
<br>
<input type='submit' class='btn btn--primary' value='Update'>
<input type='hidden' name='action' value='supplier-products-update-message'>
<input type='hidden' name='naction' value='update'>
<?php if (isset($selected_supplier)) { ?>
<input type='hidden' name='selected_supplier' value='<?php echo($selected_supplier) ?>'>
<?php } ?>
<br>
<br>
</td>
</tr>
</table>
</form>
<?php
if (isset($selected_supplier)) {
$smode = 'secondary';
include "supplier_products.buttons.php";
}
?>
<table cellspacing='1' cellpadding='5' border='0'>
<tr>
<?php if (isset($selected_supplier)) { ?>
<td align='center'><a href='/?action=supplier-products&naction=list&supplier_num=<?php echo($selected_supplier) ?>' class='btn btn--primary>'>Supplier Products</a></td>
<?php } ?>
<td align='center'><a href='/?action=suppliers&naction=list' class='btn btn--primary>'>Suppliers List</a></td>
<td align='center'><a href='/?action=supplier-products-post&selected_supplier=<?php echo($selected_supplier) ?>' class='btn btn--primary>'>Post Products to Menu</a></td>
</tr>
</table>