<?php
$pageRef='Stock';
include('includes/header.php');
?>
<script>
function reloadFrame(){
$('tableIframe').src="./ordersTable.php";
}
function orderReload(){
var pSup=$F('pSupplier');
var pNum=$F('pNumber');
var pSta=$F('pStatus');
var pPro=$F('pProduct');
document.getElementById('tableIframe').src='ordersTable.php?pSup='+pSup+'&pSta='+pSta+'&pPro='+pPro+'&pNum='+pNum;
}
function showOrderDetails(elem){
var args = elem.name.split("_");
var orderId = args[0];
var numOfOrderRows = args[1];
var orderRow = new Array();
for(var i = 0; i < numOfOrderRows; i++){
orderRow[i] = orderId+'_'+i;
if($(orderRow[i]).style.display == 'inline'){
$(orderRow[i]).style.display = 'none';
$(orderId).value=0;
}else{
$(orderRow[i]).style.display = 'inline'
$(orderId).value=1;
}
}
}
function successInDeletingOrderF(transport){
var args=transport.responseText.evalJSON();
//Success in delete request
//Operation result advice
$('qResult').style.display='block';
$('qResult').innerHTML=args.opText;
if(parseInt(args.opResult) == 0){
//Success in delete operation
OL_orderTableLoad($F('pSupplier'), $F('pNumber'), $F('pStatus'), $F('pProduct'), {elementToFill: 'orderTable', onSuccess: setOrderEventHandlers});
}else{
//Failure in delete operation
}
}
function failureInDeletingOrderF(){
//Failure in delete request
alert('<?php echo _T("NI_orders_"); ?>');
}
function deleteOrder(elem){
var args = elem.getAttribute("name").split("_");
var orderId = args[0];
result = confirm(<?php echo _T("NI_orders_") ?>);
if(result != 0){
OL_deleteOrder(orderId, {onSuccess: successInDeletingOrderF, onFailure: failureInDeletingOrderF});
}else{
}
}
function modifyOrder(elem){
var args = elem.name.split("_");
var orderId = args[0];
window.location.href='http://<?php echo $_SERVER['SERVER_ADDR']?>/Oreste/viewOrderDetailed.php?oid='+orderId;
}
function setOrderEventHandlers(){
setTimeout("$$('a.aOrderTitle').each(function(s){Event.observe(s,'click',function(){showOrderDetails(s);})})", 1);
setTimeout("$$('a.aOrderModify').each(function(s){Event.observe(s,'click',function(){modifyOrder(s);})})", 1);
setTimeout("$$('a.aOrderDelete').each(function(s){Event.observe(s,'click',function(){deleteOrder(s);})})", 1);
}
function goToStock(){
window.location.href = 'http://<?php echo $_SERVER['SERVER_ADDR']?>/Oreste/stock.php';
}
</script>
<div id="qResult" class="OpResult"></div>
<div class="Columns">
<div class="Column1">
<div class="Block"><div class="BlockBL"><div></div></div><div class="BlockBR"><div></div></div><div class="BlockTL"></div><div class="BlockTR"><div></div></div><div class="BlockT"></div><div class="BlockR"><div></div></div><div class="BlockB"><div></div></div><div class="BlockL"></div><div class="BlockC"></div><div class="BlockContent"><span class="BlockHeader"><span><?php echo _T("Actions") ?></span></span><div class="BlockContentBorder">
<ul>
<?php echo "<li><a href=\"javascript:goToStock();\">" . _T("Stock") . "</a></li>"; ?>
</ul>
</div>
</div>
</div>
<div class="Block"><div class="BlockBL"><div></div></div><div class="BlockBR"><div></div></div><div class="BlockTL"></div><div class="BlockTR"><div></div></div><div class="BlockT"></div><div class="BlockR"><div></div></div><div class="BlockB"><div></div></div><div class="BlockL"></div><div class="BlockC"></div><div class="BlockContent"><span class="BlockHeader"><span><?php echo _T("Search for product") ?></span></span><div class="BlockContentBorder">
<table width="100%" style="font-size:0.8em;">
<tr><td style="width:10%;" colspan="2"> <?php echo _T("Supplier") ?></td> <td align="center" style="width:90%;"><input style="width:80%;" name="pSupplier" id="pSupplier" type="text"/></td></tr>
<tr><td style="width:10%;" colspan="2"> <?php echo _T("Number") ?></td> <td align="center" style="width:90%;"><input style="width:80%;" name="pNumber" id="pNumber" type="text"/></td></tr>
<tr><td style="width:10%;" colspan="2"> <?php echo _T("Status") ?></td> <td align="center" style="width:90%;"><select style="width:80%;" name="pStatus" id="pStatus"><option value=""></option><option value="0"><?php echo _T("Aperto") ?></option><option value="1"><?php echo _T("Incomplete") ?></option><option value="2"><?php echo _T("Closed") ?></option></select></td></tr>
<tr><td style="width:10%;" colspan="2"> <?php echo _T("Product") ?></td> <td align="center" style="width:90%;">
<?php
echo "<select style=\"width:80%; font-size:0.8em;\" name=\"pProduct\" id=\"pProduct\">";
echo "<option value=\"\"></option>";
mysql_query("BEGIN");
$getProducts = mysql_query("SELECT * FROM products ORDER BY productName");
while($row = mysql_fetch_array($getProducts)) {
echo "<option value=\"" . $row[productID] . "\">" . $row[productName] . "</option>";
}
mysql_query("COMMIT");
echo "</select>";
?>
</td></tr>
</table>
</div>
</div>
</div>
</div>
<div class="MainColumn">
<div class="Block"><div class="BlockBL"><div></div></div><div class="BlockBR"><div></div></div><div class="BlockTL"></div><div class="BlockTR"><div></div></div><div class="BlockT"></div><div class="BlockR"><div></div></div><div class="BlockB"><div></div></div><div class="BlockL"></div><div class="BlockC"></div><div class="BlockContent"><span class="BlockHeader"><span><?php echo _T("Orders") ?></span></span><div class="BlockContentBorder" id="orderTable">
</div>
</div>
</div>
</div>
<?php
mysql_query("BEGIN");
$getOrders = mysql_query("SELECT * FROM orders ORDER BY orderStatus, orderTime DESC");
while($row = mysql_fetch_array($getOrders)) {
echo "<input type=\"text\" id=\"" . $row[orderID] . "\" style=\"display:none;\" value=\"0\">";
}
mysql_query("COMMIT");
?>
</div>
<script>
// ************************************************************
// * Observe window load event to call the init page function *
// ************************************************************
Event.observe(window, 'load', function(){
// *****************************************
// * Load clients table for the first time *
// *****************************************
OL_orderTableLoad('', '', '', '', {elementToFill: 'orderTable', onSuccess: setOrderEventHandlers});
// **************************
// * Install event handlers *
// **************************
Event.observe('pSupplier', 'keyup', function(){OL_orderTableLoad($F('pSupplier'), $F('pNumber'), $F('pStatus'), $F('pProduct'), {elementToFill: 'orderTable', onSuccess: setOrderEventHandlers});});
Event.observe('pNumber', 'keyup', function(){OL_orderTableLoad($F('pSupplier'), $F('pNumber'), $F('pStatus'), $F('pProduct'), {elementToFill: 'orderTable', onSuccess: setOrderEventHandlers});});
Event.observe('pStatus', 'change', function(){OL_orderTableLoad($F('pSupplier'), $F('pNumber'), $F('pStatus'), $F('pProduct'), {elementToFill: 'orderTable', onSuccess: setOrderEventHandlers});});
Event.observe('pProduct', 'change', function(){OL_orderTableLoad($F('pSupplier'), $F('pNumber'), $F('pStatus'), $F('pProduct'), {elementToFill: 'orderTable', onSuccess: setOrderEventHandlers});});
Event.observe('qResult', 'mouseover', function(){OL_makeThisElementInvisible('qResult');});
});
</script>
<!-- tags opened in the header -->
</div>
</div>
</div>
</body>
</html>