<?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 `rawmatgrp`='$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 * FROM `rawmat` where `code`!='' $itemgrpcond  ORDER BY code") or die(mysqli_error($conn));
$ont = mysqli_num_rows($result);

$flag = "";

$ctr = 0;
?>
<!--<table class="table-condensed" style="margin: 0 auto;">
    <tr>
        <td>
            <input id="submit" type='button' name='submit'  value='Save   ' class="btn btn-success">
        </td>
        <td>
            <input class="btn btn-danger" type="button" onClick="window.location.href = '<?= $file ?>'" value="Exit   " />
        </td>
    </tr>
</table>-->
<?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="10%" align="center"><label class="control-label"><b>Barcode</b></label></td>
    <td width="35%" align="center"><label class="control-label"><b>Name</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>
<!--    <td width="10%" align="center"><label class="control-label"><b>MSP</b></label></td>
    <td width="10%" align="center"><label class="control-label"><b>MRP</b></label></td>-->
    <!--<td width="10%" align="center"><label class="control-label"><b>Opening</b></label></td>-->
</tr>
<?php
$mctr = 0;
while ($row = mysqli_fetch_object($result)) {

    $ctr++;
    echo "<tr>";
    echo "<td align='center'>";
    echo $ctr;
    echo "</td>";
    echo "<td>";
    echo "<input type='text' class='form-control' name='code_$mctr' value='$row->code' style='text-align:left;' readonly>";
    echo "</td>";
    echo "<td  align='center'>";
    echo "<input type='text' class='form-control' name='name_$mctr' value='$row->name' style='text-align:left;' readonly>";
    echo "</td>";
    echo "<td>";
    echo "<input type='text' class='form-control' name='cost_$mctr' value='$row->cost' style='text-align:right;'>";
    echo "</td>";
    echo "<td>";
    echo "<input type='text' class='form-control' name='selling_$mctr' value='$row->rate' style='text-align:right;'>";
    echo "</td>";
////    echo "<td>";
////    echo "<input type='text' class='form-control' name='msp_$mctr' value='$row->msp' style='text-align:right;'>";
////    echo "</td>";
////    echo "<td>";
//    echo "<input type='text' class='form-control' name='mrp_$mctr' value='$row->mrp' style='text-align:right;'>";
//    echo "</td>";
//    echo "<td>";
//    echo "<input type='text' class='form-control' name='opening_$mctr' value='$row->opening' style='text-align:right;'>";
//    echo "</td>";
    echo "</tr>";

    $mctr++;
}
echo "<input type='hidden' name='count' value='$mctr'>";
echo "</table>";
?>
