<?php
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');

$formname = 'Change of Rates';
$maindb = 'item';
$file = 'openstock.php';
$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);


$itemgrp = $_GET['itemgrp'];
$subgrp = $_GET['subgrp'];


$itemgrpcond = "";
$subgrpcond = "";

if (!empty($itemgrp)) {
    $itemgrpcond = " and `itemgrp`='$itemgrp' ";
}

if (!empty($subgrp)) {
    $subgrpcond = " and `itemsubgrp`='$subgrp' ";
}
//PRINT "SELECT * FROM `item` where `code`!='' $itemgrpcond $subgrpcond  ORDER BY name";
$colorcode = "#FF8C00";
$result = mysqli_query($conn, "SELECT a.*,b.name,b.itemgrp,b.itemsubgrp FROM `prodsize` a 
                                             LEFT JOIN item b ON a.code = b.code   
                                             WHERE a.`code`!='' $itemgrpcond $subgrpcond  ORDER BY b.`name`") or die(mysqli_error($conn));
$ont = mysqli_num_rows($result);

$flag = "";

$ctr = 0;
?>

<?php
echo '<table id="openstock" border="1" width="75%" align="center">';
?>
<tr>
    <td width="5%"  align="center"><label class="control-label"><b>Sr.</b></label></td>
    <td width="35%" align="center"><label class="control-label"><b>Name</b></label></td>
    <td width="35%" align="center"><label class="control-label"><b>Size</b></label></td>
    <td width="10%" align="center"><label class="control-label"><b>Cost</b></label></td>
    <td width="10%" align="center"><label class="control-label"><b>Rate</b></label></td>
</tr>
<?php
$ctr = 0;
while ($row = mysqli_fetch_object($result)) {

    $ctr++;
    echo "<tr>";
    echo "<td align='center'>{$ctr}</td>";

    echo "<td align='center'>
            <input type='text'  class='form-control' name='name[]'    value='{$row->name}' readonly>
            <input type='hidden'                 name='code[]'    value='{$row->code}'>
          </td>";

    echo "<td align='center'>
            <input type='text'  class='form-control' name='size[]'    value='{$row->size}' readonly>
          </td>";

    echo "<td>
            <input type='text'  class='form-control' name='cost[]'    value='{$row->cost}'   style='text-align:right;'>
          </td>";

    echo "<td>
            <input type='text'  class='form-control' name='selling[]' value='{$row->rate}'   style='text-align:right;'>
          </td>";
    echo "</tr>";
}
echo '</table>';
?>

?>
