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

$formname = 'Outward / Used';
$maindb = 'outmain';
$trandb = 'outtran';
$stkdb = 'transacn';
$printfile = "outwardprint.php";
$file = 'outward.php';
$source = "OU";
$trandbexist = 1;

/* $grid = 'salemain.php'; */

$keyfld = "vouchno";

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

$admin = $_SESSION["admin_" . $dbname];

include("includes/vouchno_generate.php");
include("includes/prev&next.php");

if (isset($_POST["submit"])) {
    $a = 1;
    $billdate = $_POST["vouchdt"];
    $engine = trim($_POST["engine"]);
    $site = trim($_POST["site"]);
    $staff = trim($_POST["staff"]);
    $rem1 = trim($_POST["rem1"]);
    $rem2 = trim($_POST["rem2"]);

    $count = $_POST["items"];
    $mvouch = $qvouch;

    $mgroup = $source . $qvouch;

    if (empty($billdate)) {
        browse("Voucher Date Cannot Be Empty");
        $a = 0;
    }


    if ($a == 1) {

        ###################### TRAN PART #####################################################


        mysqli_query($conn, "DELETE FROM `$trandb` WHERE vouchno='$mvouch'") or die(mysqli_error($conn));

        $cnt = 0;
        $cntamt = 0;
        for ($i = 0; $i < $count; $i++) {
            $msrno = $_POST["srno_$i"];
            $mitem = $_POST["item_$i"];
            $mlocation = $_POST["location_$i"];
            $mqty = $_POST["qty_$i"];
            
            if (!empty($mqty) && !empty($mitem)) {
                $geti = mysqli_query($conn, "SELECT * FROM `item` WHERE `name`='$mitem' ") or die(mysqli_error($conn));
                $iget = mysqli_fetch_assoc($geti);
                $mitemcode = $iget['code'];
                $grp = $iget['group'];
                
                $getlo = mysqli_query($conn, "SELECT * FROM `location` WHERE `name`='$mlocation' ") or die(mysqli_error($conn));
                $loget = mysqli_fetch_array($getlo);
                $mloc = $loget['code'];
                
                $cnt = $cnt + 1;
                /* $cntamt = $cntamt + $mamt; */

                mysqli_query($conn, "INSERT INTO `$trandb`(`vouchno`,`srno`, `itemcode`, 
                                    location, qty )
                        VALUES('$mvouch', '$cnt','$mitemcode', '$mloc' , '$mqty')") or die(mysqli_error($conn));
            }
        }

        ######################### STOCK PART ####################################################

        mysqli_query($conn, "DELETE FROM `$stkdb` WHERE vouchno='$mvouch' AND `source`='$source'") or die(mysqli_error($conn));

        $cnt = 0;
        for ($i = 0; $i < $count; $i++) {
            $msrno = $_POST["srno_$i"];
            $mitem = $_POST["item_$i"];
            $mqty = $_POST["qty_$i"] * -1;
            $mlocation = $_POST["location_$i"];

            if (!empty($mitem)) {
                $geti = mysqli_query($conn, "SELECT * FROM `item` WHERE `name`='$mitem' ") or die(mysqli_error($conn));
                $iget = mysqli_fetch_assoc($geti);
                $mitemcode = $iget['code'];                
                $grp = $iget['group'];
                
                $getlo = mysqli_query($conn, "SELECT * FROM `location` WHERE `name`='$mlocation' ") or die(mysqli_error($conn));
                $loget = mysqli_fetch_array($getlo);
                $mloc = $loget['code'];

                $cnt = $cnt + 1;

                mysqli_query($conn, "INSERT INTO `$stkdb`(`vouchno`, `vouchdt`, `source`,  `srno`, `itemcode`, 
                                   `itemgrp`, qty, `location`, `site`, `engine`)
                        VALUES('$mvouch', '$billdate', '$source', '$cnt', '$mitemcode', '$grp', 
                                   '$mqty', '$mloc', '$site', '$engine')") or die(mysqli_error($conn));
            }
        }

        ############################## MAIN  ######################################################

        if ($addflag == 1) {
            mysqli_query($conn, "INSERT INTO `$maindb`(vouchno, `vouchdt`, `engine`, `site`, `staff`, `rem1`, `rem2`)
                                        VALUES($qvouch, '$billdate', '$engine', '$site', '$staff', '$rem1', '$rem2')") or die(mysqli_error($conn));
            insmess();
            $mvouch = $qvouch; //1
            header("refresh: 1; $file?mode=edit&vouchno=$mvouch");
        } else {
            $mvouch = $qvouch; //1

            mysqli_query($conn, "UPDATE `$maindb` SET `vouchno`='$qvouch',`vouchdt`='$billdate', `engine`='$engine', `site`='$site',
                        `staff`='$staff',`rem1`='$rem1', `rem2`='$rem2' WHERE vouchno = '$mvouch' ") or die(mysqli_error($conn));
            updmess();
            header("refresh: 1; $file?mode=edit&vouchno=$mvouch");
        }
    }
}

if ($addflag != 1) {

    $getvouch = '';
    if ($addflag == 0) {
        $getvouch = $_GET[$keyfld];
    } else {
        $getvouch = $qvouch;
    }


    $result = mysqli_query($conn, "SELECT *, DATE_FORMAT(`vouchdt`, '%d-%m-%Y') as mydt FROM `$maindb`
                           WHERE vouchno='$getvouch'") or die(mysqli_error($conn));
    $get = mysqli_fetch_array($result);

    $getengine = mysqli_query($conn, "SELECT * FROM `engine` WHERE `code`= '$get[engine]'") or die(mysqli_error($conn));
    $geteng = mysqli_fetch_object($getengine);

    $getsite = mysqli_query($conn, "SELECT * FROM `site` WHERE `code`= '$get[site]'") or die(mysqli_error($conn));
    $getst = mysqli_fetch_object($getsite);

    $getstaff = mysqli_query($conn, "SELECT * FROM `staff` WHERE `code`= '$get[staff]'") or die(mysqli_error($conn));
    $getsf = mysqli_fetch_object($getstaff);
}

$senable = "";
$cenable = "";

/* DELETE */
if (isset($_GET["delete"])) {
    delete($zdb, "$maindb", "vouchno", $_GET["vouchno"], "$file?mode=last");
    delete($zdb, "$trandb", "vouchno", $_GET["vouchno"], "$file?mode=last");

    $delcond = " source = '$source' and vouchno = '$_GET[vouchno]' ";
    delnew($zdb, "$stkdb", "$delcond", "$file?mode=last");
}
include("includes/files.php");
?>
<script type='text/javascript'>
    $(document).ready(function () {
        $('#data').on('blur', '.item', showqty);
        $('body').on('click', '.record_select', select_row);
        $('#data').on('click', 'td', tdSelect);
        $('#data').on('blur', '.qty', maxqty);

        function tdSelect() {
            var col = $(this).parent().children().index($(this));
            var row = $(this).parent().parent().children().index($(this).parent());
            return row;
        }

        function addrow2() {
            if ($(this).closest("tr").is(":last-child")) {
                addrows();
            }
        }

        function remove() {
            $(this).closest("tr").remove();
        }


        function check() {
            $('#submit').removeAttr("disabled");
            var $row = $(this).closest("tr");
            var item = $row.find('.item').val();
            if ($row.find('.item').children(":selected").val() === "") {
                alert("ITEM CANNOT BE EMPTY");
                $('#submit').attr("disabled", true);
            }
        }

        function addrows() {
            var ctr = $('#items').val();
            var hide_check = "";
            if ($("#del_all").prop("checked")) {
                hide_check = 0;
            } else {
                hide_check = 1;
            }
            $.post('outward_add.php', {ctr: ctr, hide: hide_check}, function (data) {
                $(data).appendTo('#data');
                ctr++;
                $('#items').val(ctr);
            });
        }

        $('#addnew').click(function () {
            addrows();
        });

        function showqty() {
            $('#browdata').empty();
            var $row = $(this).closest("tr");
            var $rowIndex = $(this).closest("tr").index();
            var article = $row.find(".item").val();
            var mrowId = tdSelect();
            $("#rowindex").val('');
            var stkLocation = $row.find(".location").val();
            $.get('show_qty.php', {item: article, location: stkLocation}, function (data) {
                $('#browdata').append(data);
                $("#rowindex").val($rowIndex);
            });
            $("#overlay_form").fadeIn(100);
            positionPopup();

        }

        function stkModal() {
            var $row = $(this).closest("tr");
            var stkItem = $row.find('.item').val();
            var stkPack = $row.find('.location').val();
            var vdate = $('#vouchdt').val();
            $.get('get_balance_stock.php', {item: stkItem, location: stkPack, vouchdt: vdate}, function (data) {
                $("#balanceStk").html(data);
                $("#myModal").modal('show');
                $(".qty").focus();
            });
        }

        /*Delete All Part*/
        function show_hide_delete() {
            if ($("#del_all").prop("checked")) {
                $(".remove").hide();
            } else {
                $(".remove").show();
            }
        }

        $("#del_all").attr("checked", true);
        show_hide_delete();
        $("#del_all").click(function () {
            show_hide_delete();
        });
        function select_row() {
            var code = $(this).attr("id");
            var mrel = $(this).attr("rel");
            var qRow = $("#rowindex").val();
            var $mlocRow = $("#data tr").eq(qRow);
            $mlocRow.find(".location").val(code);
            $mlocRow.find(".maxqty").val(mrel);
            $mlocRow.find(".location").focus();
            $("#overlay_form").fadeOut();

        }
        function maxqty() {
            var $row = $(this).closest("tr");
            var lqty = parseInt($row.find('.qty').val());
            var maxqty = parseInt($row.find('.maxqty').val());
            if (lqty > maxqty) {
                alert("Quantity Cannot Be Greater Than Quantity in Selected Location");
                $row.find('.qty').val(0);
                maxqty = 0;
            }
        }
    });
</script>
<script type="text/javascript">

    $(document).ready(function () {
        //open popup
        $("#pop").click(function () {
            $("#overlay_form").fadeIn(1000);
            positionPopup();
        });

        //close popup
        $("#close").click(function () {
            $("#overlay_form").fadeOut(500);
        });



    });

    //position the popup at the center of the page
    function positionPopup() {
        if (!$("#overlay_form").is(':visible')) {
            return;
        }
        $("#overlay_form").css({
            left: '200px',
            top: ($(window).width() - $('#overlay_form').width()) / 7,
            position: 'absolute'
        });
    }

    //maintain the popup at center of the page when browser resized
    $(window).bind('resize', positionPopup);

</script>
<style>
    #data td{
        padding:0px;

    }
    #overlay_form{
        position: absolute;
        border: 1px solid #428BCA;
        padding: 15px;
        background: white;
        width: 550px;
        max-height: 900px;
        overflow: auto;
        font-size:20px;
    }
    #pop{
        display: block;
        border: 1px solid gray;
        width: 70px;
        text-align: center;
        font-size:20px;
        padding: 6px;
        border-radius: 5px;
        text-decoration: none;
        margin: 0 auto;
    }
</style>
</head>
<hr/>
<body onLoad="document.boq.vouchdt.focus()" id="main_container">
    <div id="overlay_form" style="display:none;z-index:999;">
        <a href="#" id="close" style="float: right;font-weight: bold;font-size: 20px;color:red;" >X</a>
        <input type="hidden" id="rowindex">
        <div style='width:100%;' id='browdata'>
        </div>
    </div>
    <div id="div-1" class="accordion-body collapse in body">

        <form action=''  name="invoice" method="POST">
            <div class="row">
                <div class="col-lg-6" style='width:100%;'>
                    <div class="box dark">
                        <header class="navbar navbar-default navbar-fixed-top" style="padding-top: 10px">
                            <div class="icons"><i class="fa fa-edit"></i></div>
                            <h5><?php echo $flag . " " . $formname; ?></h5>
                            <div class="toolbar" >
                                <ul class="nav">
                                    <li>
                                        <?php
                                        include_once("includes/buttons.php");
                                        ?>
                                    </li>
                                    <li>
                                        <a class="accordion-toggle minimize-box" data-toggle="collapse" href="#div-1">
                                            <i class="fa fa-chevron-up"></i>
                                        </a>
                                    </li>
                                </ul>
                            </div>
                        </header>
                        <br>

                        <table border="0">
                            <tr>
                                <th> &nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;
                                    Voucher No.&nbsp;&nbsp;
                                </th>  
                                <td>
                                    <input type="text"  name="vouchno" value="<?php echo ($addflag == 0) ? $get['vouchno'] : $qvouch; ?>"  class="form-control" disabled /> 
                                </td>
                                <th style="width:150px;"></th>
                                <th> &nbsp;
                                    Voucher Date.&nbsp;&nbsp;
                                </th>  
                                <td>
                                    <input type="date" size="" id="vouchdt" name="vouchdt" value="<?php echo ($addflag == 0) ? $get['vouchdt'] : date("Y-m-d"); ?>" class="form-control form"  required/>  
                                </td>
                                <th style="width:150px;"></th>

                            </tr>
                            <tr style="height:10px;">
                            </tr>
                            <tr>
                                <th> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    Engine
                                    &nbsp;
                                </th>  
                                <td colspan ="2">
                                    <select id="engine" name="engine" class="form-control form" style='height:33px;' required>
                                        <option value="<?php echo ($addflag != 1) ? $geteng->code : " "; ?>"><?php echo ($addflag != 1) ? $geteng->name : ''; ?></option>
                                        <?php
                                        $mown = mysqli_query($conn, "SELECT code, `name` FROM `engine` WHERE code != '' ORDER BY name") or die(mysqli_error($conn));
                                        while ($trow = mysqli_fetch_array($mown)) {
                                            echo "<option value=$trow[code]>$trow[name]</option>";
                                        }
                                        ?>
                                    </select>
                                </td>
                                <th> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    Site
                                    &nbsp;
                                </th>  
                                <td colspan ="2">
                                    <select id="site" name="site" class="form-control form" style='height:33px;' required>
                                        <option value="<?php echo ($addflag != 1) ? $getst->code : ''; ?>"><?php echo ($addflag != 1) ? $getst->name : ''; ?></option>
                                        <?php
                                        $sown = mysqli_query($conn, "SELECT code, `name` FROM `site` WHERE code != '' ORDER BY name") or die(mysqli_error($conn));
                                        while ($prow = mysqli_fetch_array($sown)) {
                                            echo "<option value=$prow[code]>$prow[name]</option>";
                                        }
                                        ?>
                                    </select>
                                </td>
                            </tr>    
                            <tr style="height:10px;">
                            </tr>
                            <tr>
                                <th> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    Staff
                                    &nbsp;&nbsp; 
                                </th>  
                                <td colspan ="2">
                                    <select id="staff" name="staff" class="form-control form" style='height:33px;' required>
                                        <option value="<?php echo ($addflag != 1) ? $getsf->code : " "; ?>"><?php echo ($addflag != 1) ? $getsf->name : ''; ?></option>
                                        <?php
                                        $fown = mysqli_query($conn, "SELECT code, `name` FROM `staff` WHERE code != '' ORDER BY name") or die(mysqli_error($conn));
                                        while ($frow = mysqli_fetch_array($fown)) {
                                            echo "<option value=$frow[code]>$frow[name]</option>";
                                        }
                                        ?>
                                    </select>
                                </td>
                            </tr>
                        </table>
                        <br/>
                        <table id="data" border="1px" width="60%">
                            <tr>
                                <td width="8%" align="center"> <label class="control-label">Sr.</label></td>
                                <td width="50%" align="center"><label class="control-label">Item Name</label></td>
                                <td width="20%" align="center"><label class="control-label">Location</label></td>
                                <td width="12%" align="center"><label class="control-label">Qty.</label></td>
                            </tr>
                            <?php
                            if ($addflag != 1) {

                                $qry = mysqli_query($conn, "SELECT * FROM  `$trandb` WHERE $keyfld='$qvouch' ORDER BY srno") or die(mysqli_error($conn));
                                $ctr = 0;
                                while ($row = mysqli_fetch_array($qry)) {
                                    $getitem = mysqli_query($conn, "SELECT * FROM `item` WHERE code='$row[itemcode]'") or die(mysqli_error($conn));
                                    $gitem = mysqli_fetch_array($getitem);

                                    $getloc = mysqli_query($conn, "SELECT * FROM `location` WHERE code='$row[location]'") or die(mysqli_error($conn));
                                    $loc = mysqli_fetch_array($getloc);

                                    echo "<tr>";
                                    echo "<td align='left' valign='top'><input type='text' size='6' maxlength='6' name='srno_0' class='sno form-control form' style='height:33px;' value='$row[srno]'/></td>";

                                    echo "<td align='left'>";
                                    echo "<input list='item_$ctr' name='item_$ctr' class='item form-control form'  value='$gitem[name]' style='height:33px;'>";
                                    echo "<datalist id='item_$ctr'>";
                                    echo "<option value='$gitem->name'>";
                                    $mitem = mysqli_query($conn, "SELECT `name` FROM `item` ORDER BY `name`") or die(mysqli_error($conn));
                                    while ($trow1 = mysqli_fetch_array($mitem)) {
                                        echo "<option value='$trow1[name]'>";
                                    }
                                    echo "</datalist>";
                                    echo "</td>";
//                                    echo "<td align='center' valign='top'>";
                                    echo "<td align='center' valign='top'><input type='text' name='location_$ctr' class='location form-control form'  style='text-align:left;height:33px;' value='$loc[name]'></td>";
//                                    echo "<select name='location_$ctr' style='height:34px;' class='location form-control form'>";
//                                    echo "<option value='$loc->code'>$loc->name</option>";
//                                    $getlocation = mysqli_query($conn, "SELECT `code`, `name` FROM `location` ORDER BY `name`") or die(mysqli_error($conn));
//                                    while ($wloc = mysqli_fetch_array($getlocation)) {
//                                        echo "<option value='$wloc[code]' >$wloc[name]</option>";
//                                    }
//                                    echo "</select>";
//                                    echo "</td>";
                                    echo "<td align='center' valign='top'><input type='text' size='4'  name='qty_$ctr' class='qty form-control form'  style='text-align:right;height:33px;' value='$row[qty]'></td>";
                                    echo "</tr>";
                                    $ctr++;
                                }
                                //browse($ctr);
                            } else {
                                ?>
                                <tr>
                                    <td align="left" valign="top"><input type="text" size="6" maxlength="6" maxlength="6" name="srno_0" class="sno form-control form" style="height:33px;" value="1"/></td>

                                    <td align="left">
                                        <input list="item_0" name="item_0"  class="item form-control form" style="height:33px;">
                                        <datalist id="item_0"> 
                                            <option value=""></option>
                                            <?php
                                            $mitem = mysqli_query($conn, "SELECT `name` FROM `item` ORDER BY `name`") or die(mysqli_error($conn));
                                            while ($trow1 = mysqli_fetch_array($mitem)) {
                                                echo "<option value='$trow1[name]'>";
                                            }
                                            ?>
                                        </datalist>
                                    </td>
                                    <td align="center" valign="top">
                                        <input type="text" name="location_0" class="location form-control form"  style="height:33px;"> 
                                    </td>
                                    <td align="center" valign="top">
                                        <input type="text" size="4"  name="qty_0" class="qty form-control form"  style="text-align:right;height:33px;" value="0">
                                        <input type="hidden" size="4"  name="maxqty_0" class="maxqty form-control form"  style="text-align:right;height:33px;" value="0">
                                    </td>
                                </tr>
                            <?php } ?>
                        </table>
                    </div>  

                </div>
                <table id="" border='0' width='90%'>
                    <tr>

                        <td width="150px">
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="button" id="addnew" class="btn btn-success btn-lg form" accode="addnew" value="+" />
                            <input type="hidden" id="items" name="items" value="<?php echo ($addflag != 1) ? $ctr : 1; ?>" />  
                        </td><td width="240px"></td><td width="140px"></td>

                    </tr>
                    <tr>
                        <td align="right" valign="top"><b>Remarks</b></td>
                        <td colspan="2">
                            <input type="text" name="rem1" value="<?php echo ($addflag == 0) ? $get['rem1'] : ""; ?>" class="form-control form">
                            <input type="text" name="rem2" value="<?php echo ($addflag == 0) ? $get['rem2'] : ""; ?>" class="form-control form">
                        </td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>

                    </tr>
                </table>

                <!--SEARCH PART-->

                <div class="modal fade in slacker-modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="false">
                    <div class="modal-dialog modal-slacker">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                <h4 class="modal-title" id="myLargeModalLabel"></h4>
                            </div>
                            <div class="modal-body" style="height: 100%;white-space: nowrap;">
                                <div class="row">
                                    <div class="col-md-12">
                                        <div class="col-lg-12">
                                            <div class="box">
                                                <div id="collapse4" class="body">
                                                    <table id="dataTable" class="table table-bordered table-condensed table-hover table-striped">
                                                        <thead>
                                                            <tr>
                                                                <th align='left'>Bill No.</th>
                                                                <th align='left'>Bill Date</th>
                                                                <th align='left'>Engine</th>
                                                                <th align='left'>Site</th>
                                                                <th align='left'>Staff</th>
                                                                <th align='left'>Action</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <?php
                                                            $result = mysqli_query($conn, "SELECT *, DATE_FORMAT(`vouchdt`, '%d-%m-%Y')as invdt FROM `$maindb`  ORDER BY $keyfld") or die(mysqli_error($conn));
                                                            while ($row = mysqli_fetch_array($result)) {
                                                                $geteng1 = mysqli_query($conn, "SELECT `name` FROM `engine` WHERE code='$row[engine]'") or die(mysqli_error($conn));
                                                                $engine1 = mysqli_fetch_object($geteng1);

                                                                $getsite1 = mysqli_query($conn, "SELECT `name` FROM `site` WHERE code='$row[site]'") or die(mysqli_error($conn));
                                                                $site1 = mysqli_fetch_object($getsite1);

                                                                $getstaff1 = mysqli_query($conn, "SELECT `name` FROM `staff` WHERE code='$row[site]'") or die(mysqli_error($conn));
                                                                $staff1 = mysqli_fetch_object($getstaff1);
                                                                echo "<tr>";
                                                                echo "<td align='left'>$row[vouchno]</td>";
                                                                echo "<td align='left'>$row[vouchdt]</td>";
                                                                echo "<td align='left'>$engine1->name</td>";
                                                                echo "<td align='left'>$site1->name</td>";
                                                                echo "<td align='left'>$staff1->name</td>";
                                                                echo "<td align='left'><a href=\"$file?mode=edit&$keyfld=$row[vouchno]\"><img src='images/edit.png'></a>&nbsp;&nbsp;&nbsp;&nbsp;
                                                                </td>";
                                                                echo "</tr>";
                                                            }
                                                            ?>
                                                        </tbody>
                                                    </table>

                                                    <script>
                                                        $(function () {
                                                            metisTable();
                                                            metisSortable();
                                                        });
                                                    </script>

                                                </div>

                                            </div>

                                        </div>

                                    </div><!-- /.row -->

                                </div>
                            </div>  
                            <div class="modal-footer" style="bottom: 0px;position: absolute;padding:0px;">
                                <!--"This is where i want to load my salemain.php"-->
                            </div>
                        </div>
                    </div>
                </div>



            </div>
    </div>        
    <!--</div>        
    
    </div>    
    
    </div>-->
    <div id="myModal" class="modal fade in" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog"  style="width: 300px;">
            <div class="modal-content">

                <div class="modal-header">
                    <a class="btn btn-default" data-dismiss="modal"style="float: right;"><span class="glyphicon glyphicon-remove"></span></a>
                    <h4 class="modal-title" id="myModalLabel"></h4>
                </div>
                <div class="modal-body text-center">
                    <h4>Balance : <span id="balanceStk"></span></h4>
                </div>
                <div class="modal-footer">
                </div>

            </div><!-- /.modal-content -->
        </div><!-- /.modal-dalog -->
    </div>
    <!--</div>
    </div>
    </div>            -->

</form>
<?php
include("includes/files_footer.php");
?>
<script>
    $(function () {
        formGeneral();
        metisTable();
        metisSortable();
    });
</script>

</body>
</html>

