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

$formname = "Closing Stock";
$file = "closstk.php";

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

$profres = mysqli_query($conn, "SELECT * FROM `profit` ") or die(mysqli_error($conn));
$getprof = mysqli_fetch_object($profres);
$actprof = $getprof->amount;
if (empty($actprof)) {
    $actprof = 0.00;
}

$result = mysqli_query($conn, "SELECT * FROM `accmast` WHERE `accode`='23' ORDER BY name") or die(mysqli_error($conn));
$get = mysqli_fetch_array($result);

if (isset($_POST["submit"])) {
    $a = 1;
    $curbal = $_POST["curbal"];
    $curdc = $_POST["curdc"];


    if ($a == 1) {
        $ctr = 0;

        mysqli_query($conn, "UPDATE `accmast` SET `currbal`='$curbal',`currdc` = '$curdc'  WHERE `accode`= '23' ") or die(mysqli_error($conn));
        updmess();
        header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
    }
}


include("includes/linkshead.php");
?>
<link href="MyStyle/rep_format.css" rel="stylesheet">
<style>
    @media print {
        .noPrint {
            display:none;
        }
    }

</style>
<script>
    $(document).ready(function () {


    });

</script>
</head>
<body>
    <form name="" class="validation" id="form" action="" method="post">
        <div class="col-lg-5 col-md-5 col-sm-12 col-xs-12  pad">

            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><?php Echo $formname; ?></h3>

                </div>
                <div class="panel-body">
                    <div class="row pad">
                        <div class="col-g-3 col-md-3 col-sm-3 col-xs-3 text-right">         
                            <label class="label-control marg"><?php Echo $formname; ?></label>
                        </div>
                        <div class="col-g-3 col-md-3 col-sm-3 col-xs-3 pad">         
                            <input type="number" step="any" name="curbal" value="<?= $get['currbal'] ?>" class="form-control text-right">
                        </div>
                        <div class="col-g-2 col-md-2 col-sm-3 col-xs-3 pad">         
                            <select class="form-control" name="curdc">
                                <option value='D'<?php
                                if ($addflag != 1) {
                                    if ($get["curdc"] == "D") {
                                        echo "selected='selected'";
                                    }
                                }
                                ?> >D</option>
                                <option value='C'<?php
                                if ($addflag != 1) {
                                    if ($get["curdc"] == "C") {
                                        echo "selected='selected'";
                                    }
                                }
                                ?>>C</option>
                            </select>
                        </div>
                    </div>

                    <div style="overflow: auto; ">
                        <table class="table-condensed" style="margin: 0 auto;">
                            <tr>
                                <td class=" buttonform tooltip-bottom" id="ssubmit" style="display: <? Echo $savedisabled ?>" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Save Record">
                                    <button id='submit' type='submit' name='submit' value='<?php echo ($addflag == 0) ? "Update" : "Save"; ?>' class="btn btn-pad btn-square " style="background-color:#008D4C; ">
                                        <i class="fa fa-check" style="color:#ffffff"></i>
                                    </button>
                                </td>
                                <td class=" buttonform tooltip-bottom" id="hexit" style="display: <? Echo $exitdisabled ?>" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Exit">
                                    <button id='exit' type="button" class="btn btn-pad btn-square " style="background-color:#cccccc; "  onClick="window.location.href = 'default.php'">
                                        <i class="fa fa-power-off" style="color:red"></i>
                                    </button>
                                </td>
                            <input type="hidden" id="items" name="items" value="<?php echo ($addflag != 1) ? $ctr : $ctr; ?>" />  
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <?php include("includes/linksfoot.php"); ?>
</body>
</html>



