Current File : /home/inlingua/public_html/sales/available.select.php
<?php

include "header.php";
echo "<br>";
echo"<a href='admin.php'><span class='n_text'>Home</span></a> <span class='n_text'>>> Available Products</a> ";
echo"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
//echo"<a href='prodcat.main.php'><span class='n_text'>Add new Category</span></a>";
echo"<br><br>";
// Include the database connection details
require('dbConnection.php');

// Include common functions
require('commonFunc.php');

// Include common functions
require('globalVars.php');

$tableName = "subprodcat";
$tableConf = $tableName . ".conf.php";
$dataForm = $tableName . ".form.php";
$viewForm = $tableName . ".view.php";

// Include table configuration details
require($tableConf);

// Include the table handler class
require('dbHandler.class.php');

$dbObject = new dbHandler();
$dbObject->setTableName($tableName);
$dbObject->setDbFieldList($dbFieldList);
$dbObject->setKeyFieldName("recNo");
$dbObject->connect();
// Retrieve parameters from request
$dbObject->getDbFieldsFromRequest();

// Records selection sql
$sqlQuery = "SELECT * FROM prodcat order by serialNo";

// Prepare page navigation
$resultsPerPage = 20; // number of rows to return per page

// Prepare add on URL
$addOnUrl = "";

if ($resultsPerPage > 0)
{	$prev_next_links = $dbObject->prev123Next($sqlQuery, $resultsPerPage,$addOnUrl);
	$sqlQuery .= " limit " . $offset . "," . $resultsPerPage ;
}

// Print navigation bar
function printArray($element) { echo "$element"; }

if ($resultsPerPage > 0 && $prev_next_links)
{	echo "Page: ";
	array_walk($prev_next_links, 'printArray'); 
}

// Select records from table
$selectedRecords = $dbObject->Select($sqlQuery);

echo "<table border='0'  cellspacing='2' cellpadding='5' width='600'>";
echo "<tr valign='top' class='dataTableHeadingRow'>";
echo "<td class='dataTableHeadingContent'>Sr. No</td>";

echo "<td class='dataTableHeadingContent'>Category</td>";

//echo "<td bgcolor='#E9E9E9'>Description</td>";

//echo "<td bgcolor='#E9E9E9'>Pic</td>";

echo "<td class='dataTableHeadingContent'>Action</td>";
echo "</tr>";

// If no records selected, print message
if (!$selectedRecords)
{	echo "<tr><td colspan='5' class='dataTableContent'>There are no selected records</td></tr>"; }
$i=1;	
while($objectData=$dbObject->SelectNext())
{	
	if($i%2==0) $bgcolor='#F3F3F3';
else $bgcolor='#EBEBEB';
	
	$query1="select * from subprodcat where prodNo='$objectData[recNo]'";
$result1=mysql_query($query1);
$no1=mysql_num_rows($result1);

	echo "<tr valign='top' style='background:$bgcolor;height:25px;'>";
	echo "<td class='dataTableContent'>$objectData[serialNo]</td>";
echo "<td class='dataTableContent'><a title='$num[name]' href='javascript:;' id='maindivT$objectData[recNo]'><span style='color: #369;'>$objectData[name]($no1 )</a></td>";

		//echo "<td>$objectData[description]</td>";

		//echo "<td>$objectData[pic]</td>";

	echo "<td class='dataTableContent'>&nbsp;";
	//echo "<a href='prodcat.main.php?aC=sV&kV=". $objectData['recNo'] ."'>View</a> |";
	//echo " <a href='prodcat.main.php?aC=sD&kV=". $objectData['recNo'] ."'>Delete</a> |";
	echo "  ";
	
	echo"</td>";	
	echo "</tr>";
	echo"<tr><td colspan='4' class='dataTableContent'>";
	?>
<div id='maindivnewT<?php echo  $objectData[recNo]  ?>' style="width: 100%; padding: 5px; background-color: #ffc; border: 1px solid #ccc; 
<?php
	if($_REQUEST[prodNo]==$objectData[recNo])
	{
	}
	else
	{
	?>
display: none; 
<?php
	}
	?>
">
 Product Under Category "<b><?php echo $objectData[name]  ?></b>"
<?php
	echo "<table border='1' cellspacing='0' width='100%'>";
echo "<tr valign='top' class='dataTableHeadingRow'>";
echo "<td class='dataTableHeadingContent'>Sr.No</td>";
echo "<td class='dataTableHeadingContent'>Products</td>";
echo "<td class='dataTableHeadingContent'>Description</td>";

echo "<td class='dataTableHeadingContent'>Total</td>";


echo "<td class='dataTableHeadingContent'>Action</td>";
echo "</tr>";
$query="select * from subprodcat where prodNo='$objectData[recNo]' order by serialNo";
$result=mysql_query($query);
$no=mysql_num_rows($result);
if ($no<=0)
{	echo "<tr><td colspan='5' class='dataTableContent'>There are no products under this category</td></tr>"; }
while($num=mysql_fetch_array($result))
	{
	
	$queryP="select sum(quality_passed) as  quality_passed from store_rcv_products where product='".$num['recNo']."'";
	$resultP=mysql_query($queryP);
	$numP=mysql_fetch_array($resultP);
	
	echo "<tr valign='top' >";
	echo "<td class='dataTableContent'>$num[serialNo]</td>";
echo "<td class='dataTableContent'>$num[name]</td>";
echo "<td class='dataTableContent'>$num[description]</td>";

	
	echo "<td class='dataTableContent'>".$numP[quality_passed]."</td>";

	echo "<td class='dataTableContent'>";
	//echo "<a href='subprodcat.main.php?aC=sV&kV=". $num['recNo'] ."&prodNo=". $num['prodNo'] ."' target='_blank'>View</a>";
	//echo " <a href='subprodcat.main.php?aC=sD&kV=". $num['recNo'] ."&prodNo=". $num['prodNo'] ."' >Delete</a></td>";	
	echo "</tr>";
	

	}
	echo"</table>";
	?>
</div>
<div id='maindivnew<?php echo  $objectData[recNo]  ?>' style="width: 100%; padding: 5px; background-color: #ffc; border: 1px solid #ccc; display: none; ">
Add New Product Under Category "<b><?php echo $objectData[name]  ?></b>"
<?php
	$currentMode="Add";
	?>


</div>
	<?php
		echo"</td>";	
	echo "</tr>";
	?>
	<script>
$('#<?php echo "maindiv$objectData[recNo]";?>').click(
		function(){
            $('#<?php echo "maindivnew$objectData[recNo]";?>').toggle("slow");
        }); 
		$('#<?php echo "maindivT$objectData[recNo]";?>').click(
		function(){
            $('#<?php echo "maindivnewT$objectData[recNo]";?>').toggle("slow");
        });
		
		</script>
		<?php
		$i++;
}
print "</table>";

// Print navigation bar
if ($resultsPerPage > 0 && $prev_next_links)
{	echo "Page: ";
	array_walk($prev_next_links, 'printArray'); 
}
?>
<br>

<br>

<?php 
$dbObject->CloseConnection();

// Include footer
include "footer.php";
?>