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

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn,$zdb);

if ($_REQUEST["ctr"]) {
    $ctr = $_REQUEST["ctr"];
    $hide = $_REQUEST["hide"];
    $hide_var = "";
    $mctr = $ctr;
    $mctr++;
    echo "<tr>";
    if ($hide == 0) {
        $hide_var = 'style="display:none;"';
    }
    echo "<tr>";
    echo "<td style='height:30px;' align='left' valign='center'><input type='text' size='6' maxlength='6' name='srno_$ctr' class='sno form-control form' style='height:29px;' value='$mctr'/></td>";
    echo "<td align='left' style='height:30px;'>";
    ?>
    <select name = "supplier_<?= $ctr ?>" class = "supplier form-control form" style = 'height:29px;width:100%;'>
        <option value = ""></option>
        <?php
        $mitem = mysqli_query($conn,"SELECT * FROM `accmast` where `grpcode`='009' ORDER BY `name`") or die(mysqli_error($conn));
        while ($trow1 = mysqli_fetch_array($mitem)) {
            echo "<option value='$trow1[name]' >$trow1[name]</option>";
        }
        ?>
    </select>
    <?php
    echo "</td>";
    echo "<td align='center' style='height:30px;' valign='center'><input type='text' size=''  name='particulars_$ctr' class='particulars form-control' style='height:29px;text-align:left;' value='' /></td>";
    echo "<td align='center' style='height:30px;' valign='center'><input type='number' step='any' size=''  name='amt_$ctr' class='amt form-control ' style='height:29px;text-align:right;' value='0'/></td>";
    echo "<td align='left' style='height:30px;'>";
    ?>
    <select name = "currency_<?= $ctr ?>" class = "currency form-control" style = 'height:29px;width:100%;'>
        <option value = "INR">INR</option>
        <?php
        $mcurrency = mysqli_query($conn,"SELECT * FROM `currency` ORDER BY `name`") or die(mysqli_error($conn));
        while ($tcurrency = mysqli_fetch_array($mcurrency)) {
            echo "<option value='$tcurrency[name]' >$tcurrency[name]</option>";
        }
        ?> 
    </select>
    <?php
    echo "</td>";
//    echo "<td align='center' style='height:30px;' valign='center'><input type='text' size=''  name='curr_$ctr' class='curr form-control form' style='height:29px;text-align:left;' value=''></td>";
    echo "<td align='center' style='height:30px;' valign='center'><input type='number' step='any' size=''  name='roe_$ctr' class='roe form-control ' style='height:29px;text-align:right;' value='1'/></td>";
    echo "<td align='center' style='height:30px;' valign='center'><input type='number' step='any' size=''  name='amtrs_$ctr' class='amtrs form-control' style='height:29px;text-align:right;' value='0'  readonly/></td>";
    echo "<td style='height:30px;' align='center' valign='center'><input type='number' step='any' size=''  name='acntamt_$ctr' class='acntamt form-control ' style='height:29px;text-align:right;' value='0' readonly/></td>";
    echo "<td style='height:30px;' align='center' valign='center'><input type='text' size=''  name='sbillno_$ctr' class='sbillno form-control ' style='height:29px;text-align:left;' value=''  /></td>";
    echo "<td style='height:30px;' align='center' valign='center'><input type='date' size=''  name='sbilldt_$ctr' class='sbilldt form-control ' style='height:29px;text-align:left;' value=''/></td>";

    echo "<td>";
    ?>
    <button type="button" class="btn btn-square billupload" name="billupload_<?= $ctr ?>" style="background-color:#D4744D; color:white;">
        Bill Updload & Download
    </button>
    <!--<button class="btn btn-square "><a href="demopdf.php?vouchno=<?= $qvouch ?> "></a>Download</button>--> 
    <?php
    echo "</td>";

    echo "<td>";
    ?>
    <button type="button" class="btn btn-square ledgupload" name="ledgupload_<?= $ctr ?>" style="background-color:#64CCFC; color:white;">
        Ledger Updload & Download
    </button>
    <!--<button class="btn btn-square "><a href="demopdf.php?vouchno=<?= $qvouch ?> "></a>Download</button>--> 

    <?php
    echo "</td>";
    echo "</tr>";
} else {
    echo "ERROR";
}
?>
