147 lines
4.2 KiB
PHP
147 lines
4.2 KiB
PHP
<?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');
|
|
if (checkPermission($AllowedUserTypes) != 1) {
|
|
echo("<br>\n");
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
|
|
// Start the template and output buffering
|
|
startTemplate();
|
|
$templatePageTitle = getLanguageText('TEXT-COPY-SUPPLIER');
|
|
$headerArgs = "";
|
|
|
|
|
|
?>
|
|
<br>
|
|
<form method='post' action='/'>
|
|
<?php
|
|
$message_width = $default_form_width;
|
|
include "form.messages.php";
|
|
?>
|
|
<table width='<?php echo($default_form_width) ?>' id='supplier-copy-table' class='content-table'>
|
|
<tr>
|
|
<td align='center' class='heading'><?php displayLanguageText('TEXT-SUPPLIERS-AVAILABLE-FOR-COPY'); ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='center'>
|
|
<table>
|
|
<tr>
|
|
<td align='left' valign='top'><?php displayLanguageText('TEXT-SEARCH'); ?>:<br>
|
|
<input name='supplier_search' id='supplier_search' size='80'> <a href='#' id='clear-search' class='btn btn--primary btn--xsmall'><?php displayLanguageText('TEXT-CLEAR'); ?></a></td>
|
|
</tr>
|
|
<td align='center'>
|
|
<br>
|
|
<div id='supplier-products-div'></div>
|
|
</td>
|
|
<tr>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='2' align='center'>
|
|
<br>
|
|
<input type='submit' id='copy-supplier-to-current-school' class='btn btn--primary' value='Copy Supplier'>
|
|
<input type='hidden' name='action' value='suppliers'>
|
|
<input type='hidden' name='naction' value='copy'>
|
|
<input type='hidden' name='source_supplier' id='source_supplier'>
|
|
<br>
|
|
<br>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</form>
|
|
<div id='spinner-div'></div>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
|
|
<?php include "include/ajax.Setup.php" ?>
|
|
|
|
$("#supplier_search").autocomplete({
|
|
source: "ajax.supplierSearch.php",
|
|
dataType: "json",
|
|
minLength: 2,
|
|
width: 750,
|
|
selectFirst: false,
|
|
data: {
|
|
mode: 'all-schools'
|
|
},
|
|
select: function( event, results ) {
|
|
var supplier_num = results.item.supplier_num;
|
|
$("#source_supplier").val(supplier_num);
|
|
loadProducts(supplier_num);
|
|
}
|
|
});
|
|
|
|
$("#clear-search").click(function(e) {
|
|
e.preventDefault();
|
|
$("#supplier_search").val('');
|
|
$("#source_supplier").val(0);
|
|
});
|
|
|
|
function loadProducts(supplier_num) {
|
|
var data = "table_name=supplier_products"+
|
|
"&sequence_flag=N"+
|
|
"&action=supplier-products-select"+
|
|
"&supplier_num="+supplier_num+
|
|
"&mode=no-select"+
|
|
"&table_id=supplier-products";
|
|
$.getJSON( "ajax.DataTable.Fetch.php",data,
|
|
function(results) {
|
|
$("#supplier-products-div").html(results.content);
|
|
if (results.ajax_return_code == 0) {
|
|
$("#supplier_search").val('');
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
$("#copy-supplier-to-current-school").click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var source_supplier_num = $("#source_supplier").val();
|
|
|
|
$("#supplier-copy-table").hide();
|
|
$("#supplier-products-div").html('');
|
|
$("#spinner-div").html("<p><img src='images/spinner.gif'></p>");
|
|
|
|
$.ajax({
|
|
url: "ajax.SupplierCopy.php",
|
|
data: {
|
|
source_supplier_num: source_supplier_num
|
|
},
|
|
dataType: "json"
|
|
}).done(function(data) {
|
|
$("#supplier-products-div").html("");
|
|
$("#supplier-copy-table").show();
|
|
$("#spinner-div").html("");
|
|
|
|
if (data.ajax_return_code != 0) {
|
|
$("#error-msg-div").html(data.ajax_message);
|
|
return false;
|
|
}
|
|
|
|
alert(data.ajax_message);
|
|
});
|
|
});
|
|
|
|
});
|
|
</script>
|
|
|
|
<?php
|
|
endTemplate();
|
|
?>
|