<?php session_start();

if($_SESSION[invcox] == ""){

header("location:login.php?action=need");

}else{



include("config.php");?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Accounting Software</title>

<link href="style.css" rel="stylesheet" type="text/css" />

<?php include("calendar.php");?>

<script language="javascript">

function show_product_name(){

	var ajaxRequest;  // The variable that makes Ajax possible!

	

	try{

		// Opera 8.0+, Firefox, Safari

		ajaxRequest = new XMLHttpRequest();

	} catch (e){

		// Internet Explorer Browsers

		try{

			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");

		} catch (e) {

			try{

				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");

			} catch (e){

				// Something went wrong

				alert("Your browser broke!");

				return false;

			}

		}

	}

	// Create a function that will receive data sent from the server

	ajaxRequest.onreadystatechange = function(){

		if(ajaxRequest.readyState == 4){

		

			var ajaxDisplay = document.getElementById('product_show');

			ajaxDisplay.innerHTML = ajaxRequest.responseText;	

			prouct_list();

		}

	}



  //-------------------------

var category = document.getElementById('category').value;

var queryString = "?category=" + category;

		



	ajaxRequest.open("GET", "ajax_show_product2.php" + queryString, true);

	ajaxRequest.send(null); 

}



function avai(){

	var ajaxRequest;  // The variable that makes Ajax possible!

	

	try{

		// Opera 8.0+, Firefox, Safari

		ajaxRequest = new XMLHttpRequest();

	} catch (e){

		// Internet Explorer Browsers

		try{

			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");

		} catch (e) {

			try{

				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");

			} catch (e){

				// Something went wrong

				alert("Your browser broke!");

				return false;

			}

		}

	}

	// Create a function that will receive data sent from the server

	ajaxRequest.onreadystatechange = function(){

		if(ajaxRequest.readyState == 4){

		

			var ajaxDisplay = document.getElementById('stock_available');

			ajaxDisplay.innerHTML = ajaxRequest.responseText;	

		}

	}



  //-------------------------

var product = document.getElementById('product').value;

var queryString = "?product=" + product;

		



	ajaxRequest.open("GET", "ajax_show_stock.php" + queryString, true);

	ajaxRequest.send(null); 

}



function avai2(){

	var ajaxRequest;  // The variable that makes Ajax possible!

	

	try{

		// Opera 8.0+, Firefox, Safari

		ajaxRequest = new XMLHttpRequest();

	} catch (e){

		// Internet Explorer Browsers

		try{

			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");

		} catch (e) {

			try{

				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");

			} catch (e){

				// Something went wrong

				alert("Your browser broke!");

				return false;

			}

		}

	}

	// Create a function that will receive data sent from the server

	ajaxRequest.onreadystatechange = function(){

		if(ajaxRequest.readyState == 4){

		

			var ajaxDisplay = document.getElementById('stock_available');

			ajaxDisplay.innerHTML = ajaxRequest.responseText;	

		}

	}



  //-------------------------

var product = document.getElementById('product2').value;

var queryString = "?product=" + product;

		



	ajaxRequest.open("GET", "ajax_show_stock.php" + queryString, true);

	ajaxRequest.send(null); 

}



function prouct_list(){



 var config = {

      '.product'           : {},

      '.chosen-select-deselect'  : {allow_single_deselect:true},

      '.chosen-select-no-single' : {disable_search_threshold:10},

      '.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},

      '.chosen-select-width'     : {width:"95%"}

    }

  

    for (var selector in config) {

      $(selector).chosen(config[selector]);

    }	

	}

</script>

</head>

<body>

<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="box-wrap">

  <tr>

    <td><?php include("top.php");?></td>

  </tr>

  <tr>

    <td><table width="100%" border="0" cellspacing="1" cellpadding="0">

        <tr>

          <td height="15" align="left" class="link2">&nbsp;</td>

        </tr>

        <tr>

          <td height="30" align="left" class="location"><strong>&nbsp;<a href="index.php">Home</a> &gt; <a href="laundry.php">Inventory</a></strong> &gt; <a href="add_product.php"><strong> Current Laundry Stock</strong></a></td>

        </tr>

        <tr>

          <td align="center">&nbsp;</td>

        </tr>

        <tr>

          <td align="center"><?php if($_GET[info]!=""){echo '<span class="red"><strong>'.$_GET[info].'</strong></span>';}?></td>

        </tr>

	

        <tr>

          <td><form action="current_laundry_stock.php" method="post" enctype="multipart/form-data" name="enquiryform" class="round_box" id="enquiryform2">

            <table width="100%" border="0" cellspacing="0" cellpadding="0">

              <tr>

                <td width="11%">Date From <?php 

$date1=$_POST[date1]; if($date1 == ""){$date1=date("Y-m-d");}else{$date1=dtformat($_POST[date1]);}

$date2=$_POST[date2]; if($date2 == ""){$date2=date("Y-m-d");}else{$date2=dtformat($_POST[date2]);}

				?></td>

                <td width="16%"><table width="168" border="0" cellspacing="0" cellpadding="0">

                  <tr>

                    <td width="48%"><input name="date1" type="text" id="date1" size="15" value="<?php echo dtformat($date1);?>" required="required"/></td>

                    <td width="52%" align="center"><a title="Calendar" onclick="displayDatePicker('date1', this);" href="javascript:;"><img src="images/calendar.gif" width="20" height="20" border="0" /></a></td>

                  </tr>

                </table></td>

                <td width="5%">Date to </td>

                <td width="14%"><table width="156" border="0" cellspacing="0" cellpadding="0">

                  <tr>

                    <td width="47%"><input name="date2" type="text" id="date2" size="15" value="<?php echo dtformat($date2);?>" required="required"/></td>

                    <td width="53%" align="center"><a title="Calendar" onclick="displayDatePicker('date2', this);" href="javascript:;"><img src="images/calendar.gif" width="20" height="20" border="0" /></a></td>

                  </tr>

                </table></td>

                <td width="9%" align="center">Product: </td>

                <td width="18%"><select name="category" id="category" data-placeholder="Select Product Category" class="category">

                    <option value="">Select Product Category</option>

                    <?php 

				  $cresult=mysql_query("select * from laundry_category  order by name ASC");

			$crow=mysql_fetch_array($cresult);

			if($_POST[name]!=""){$category=$_POST[name];}

if($_GET[name]!=""){$category=$_GET[name];}

			do{

				  ?>

                    <option value="<?php echo $crow[id]; ?>" <?php if($category == $crow[id]){echo 'selected="selected"';}?>><?php echo $crow[name]; ?></option>

                    <?php }while($crow=mysql_fetch_array($cresult));?>

                  </select>

                    <script language="javascript" type="text/javascript">

				   var config = {

      '.category'           : {},

      '.chosen-select-deselect'  : {allow_single_deselect:true},

      '.chosen-select-no-single' : {disable_search_threshold:10},

      '.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},

      '.chosen-select-width'     : {width:"95%"}

    }

  

    for (var selector in config) {

      $(selector).chosen(config[selector]);

    }

				  </script></td>

                <td width="27%"><input type="submit" name="button" id="button" value="Show" /></td>

              </tr>

            </table>

          </form></td>

        </tr>

		

        <tr>

          <td>&nbsp;</td>

        </tr>

        <tr>

          <td class="round_box"><table width="100%" border="0" cellpadding="3" cellspacing="1"  class="list_table">

            <tr>

              <td colspan="6" bgcolor="#6EA749" class="location"><strong>Current Laundry Stock </strong>(From <?php echo dtformat($date1);?> to <?php echo dtformat($date2);?>) </td>

            </tr>

            <tr>

              <td ><strong>Sr.</strong></td>

              <td width="10%" align="center" ><strong>Category</strong></td>

              

              <td width="10%" align="center" ><strong>Opening Stock</strong></td>

              <td width="10%" align="center" ><strong>Stock In <br />

              </strong></td>

              <td width="10%" align="center" ><strong>Stock Out <br />

              </strong></td>

              

              <td width="10%" align="center" ><strong>Current Stock</strong></td>

          

            </tr>

            <?php 

if($_POST[category]!=""){$category=$_POST[category];}

if($_GET[category]!=""){$category=$_GET[category];}





$dresult=mysql_query("SELECT 

    stock.category,

    laundry_category.name

FROM laundry

JOIN laundry_category 

    ON stock_category.id = laundry.category

GROUP BY laundry.category, laundry_category.name

ORDER BY laundry.category ASC;");

$drow=mysql_fetch_array($dresult);

			





			do{



             



?>

            <tr>

              <td width="4%" ><?php echo $sr;?></td>

              <td ><?php 

 

			  echo $drow[name];?></td>

              

              <td align="center" ><?php 

		 

$aresult=mysql_query("select sum(qty)as qty from laundry WHERE category='$drow[category]' and stype='0' and date1<'$date1'");

$arow=mysql_fetch_array($aresult);

				

$nresult=mysql_query("select sum(qty)as qty from laundry WHERE category='$drow[category]' and stype='1' and date1<'$date1'");

$nrow=mysql_fetch_array($nresult);



$opening=$arow[qty]-$nrow[qty];

				

echo number_format($opening);

$sx1=$sx1+$opening;

?></td>

              <td align="center"  class="link"><?php 

		 

$aresult=mysql_query("select sum(qty)as qty from laundry WHERE category='$drow[category]' and stype='0' and date1>='$date1'  and date1<='$date2'");

$arow=mysql_fetch_array($aresult);

			 

$nresult=mysql_query("select sum(qty)as qty from laundry WHERE category='$drow[category]' and stype='1'  and date1>='$date1'  and date1<='$date2' ");

$nrow=mysql_fetch_array($nresult);



$stockin=$arow[qty];

$stockout=$nrow[qty];

				

echo number_format($stockin);

$sx2=$sx2+$stockin;

?></td>

              <td align="center"  class="link"><?php 

 

				

echo number_format($stockout);

$sx3=$sx3+$stockout;



?></td>

            

              <td align="center" ><?php $current_stock=$stockin-$stockout;

echo number_format($current_stock);

$sx4=$sx4+$current_stock;?></td>

             

            </tr>



            <?php 



         }while($drow=mysql_fetch_array($dresult));?>

<tr>

              <td colspan="2" >Total </td>

              <td align="center" ><?php echo number_format($sx1); ?></td>

              <td align="center" ><?php echo number_format($sx2); ?></td>

              <td align="center" ><?php echo number_format($sx3); ?></td>

           

           

              <td >&nbsp;</td>

            </tr>

            <tr>

              <td colspan="9" ></td>

            </tr>

         

  

          </table>

          <br /></td>

        </tr>

    </table></td>

  </tr>

  <tr>

    <td><?php include("bot.php");?></td>

  </tr>

</table>

</body>

</html>

<?php }?>