<?php include("../Header/Session.php"); ?>
<?php include("../Header/Connection.php"); ?>

<!DOCTYPE html>
<html lang="en">
<?php include ("../Header/head.php"); ?>
<body class="skin-default fixed-layout">

<!-- Main wrapper - style you can find in pages.scss -->
<div id="main-wrapper">    
<?php include ("../Header/header.php"); ?>
<?php include ("../Header/left_menu.php"); ?>
<?php include ("../Header/right_sidebar.php"); ?>
        
<!-- Page wrapper  -->
<div class="page-wrapper">
<!-- Container fluid  -->
<div class="container-fluid">
<!-- Bread crumb and right sidebar toggle -->
<!--?php include ("../Header/breadcumb.php"); ?-->
<br><br>
<!-- End Bread crumb and right sidebar toggle -->
<!-- Start Page Content -->
<!-- ============================================================== -->

<?php
if ($ref_code != "MGP10000") 
{
    echo "<script type='text/javascript'>alert('You are not authorized');</script>";
    unset($_SESSION['sess_user']);
    session_destroy();
    echo "<script type='text/javascript'> document.location='https://mygoldsdnbhd.com/log-masuk/'; </script>";
} 
?>

<?php
$year = $_GET['year'];

$year = "2023";
?>

<div class="row">
<div class="col-lg-12">
<div class="card">
    <div class="card-body">
        <form method="post" action="../Controller/Database_sql.php" enctype="multipart/form-data">
            <div class="form-body">
                <h3 class="card-title">Add New Item</h3>
                <hr>
                <div class="row p-t-20">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label">Item Name</label>
                            <input type="text" class="form-control" name="item_name" required>
                        </div>
                    </div>  
                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label">For Year</label>
                            <input type="number" class="form-control" name="item_year" required>
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-actions">
                <button name="Add_Inventory_Setting" class="btn btn-success"><i class="fa fa-check"></i> Add</button>
            </div>
        </form>
    </div>
</div>
</div>
</div>

<div class="row">
<div class="col-12">
<div class="card">
    <div class="card-body">
        <h4 class="card-title">Stock Inventory For <?php echo $year; ?></h4>
        <div class="table-responsive m-t-40">            
            <table class="display nowrap table table-hover table-striped table-bordered" cellspacing="0" width="100%">
                <thead>
                    <tr>
                        <th>No.</th>
                        <th>Item Description <font color="white">___________</font></th>
                        <th>Jan In<font color="white">_/font></th>
                        <th>Jan Out<font color="white">_/font></th>
                        <th>Jan Balance</th>
                        <th>Feb In<font color="white">_/font></th>
                        <th>Feb Out<font color="white">_/font></th>
                        <th>Feb Balance</th>
                        <th>Mac In<font color="white">_/font></th>
                        <th>Mac Out<font color="white">_/font></th>
                        <th>Mac Balance</th>
                        <th>Apr In<font color="white">_/font></th>
                        <th>Apr Out<font color="white">_/font></th>
                        <th>Apr Balance</th>
                        <th>May In<font color="white">_/font></th>
                        <th>May Out<font color="white">_/font></th>
                        <th>May Balance</th>
                        <th>June In<font color="white">_/font></th>
                        <th>June Out<font color="white">_/font></th>
                        <th>June Balance</th>
                        <th>July In<font color="white">_/font></th>
                        <th>July Out<font color="white">_/font></th>
                        <th>July Balance</th>
                        <th>Aug In<font color="white">_/font></th>
                        <th>Aug Out<font color="white">_/font></th>
                        <th>Aug Balance</th>
                        <th>Sept In<font color="white">_/font></th>
                        <th>Sept Out<font color="white">_/font></th>
                        <th>Sept Balance</th>
                        <th>Okt In<font color="white">_/font></th>
                        <th>Okt Out<font color="white">_/font></th>
                        <th>Okt Balance</th>
                        <th>Nov In<font color="white">_/font></th>
                        <th>Nov Out<font color="white">_/font></th>
                        <th>Nov Balance</th>
                        <th>Dec In<font color="white">_/font></th>
                        <th>Dec Out<font color="white">_/font></th>
                        <th>Dec Balance</th>
                        <th>Action</th>
                    </tr>
                </thead>                                      
                <tbody>
                    <?php
                    $no = 0;

                    $q = "SELECT *
                    FROM item_inventory
                    Where status='1'
                    order by id Asc";
                    $result = $mysqli->query($q);
                    if ($result ->num_rows > 0)
                    {
                        while($record = $result -> fetch_assoc())
                        {    
						    $id = $record['id'];
                            $item_ref_code = $record['item_ref_code'];
                            $item_year= $record['item_year'];
                            $item_name = $record['item_name']; 
                            $in_1 = $record['in_1']; 
                            $out_1 = $record['out_1']; 
                            $balance_1 = $record['balance_1']; 
                            $in_2 = $record['in_2']; 
                            $out_2 = $record['out_2']; 
                            $balance_2 = $record['balance_2']; 
                            $in_3 = $record['in_3']; 
                            $out_3 = $record['out_3']; 
                            $balance_3 = $record['balance_3']; 
                            $in_4 = $record['in_4']; 
                            $out_4 = $record['out_4']; 
                            $balance_4 = $record['balance_4']; 
                            $in_5 = $record['in_5']; 
                            $out_5 = $record['out_5']; 
                            $balance_5 = $record['balance_5']; 
                            $in_6 = $record['in_6']; 
                            $out_6 = $record['out_6']; 
                            $balance_6 = $record['balance_6']; 
                            $in_7 = $record['in_7']; 
                            $out_7 = $record['out_7']; 
                            $balance_7 = $record['balance_7']; 
                            $in_8 = $record['in_8']; 
                            $out_8 = $record['out_8']; 
                            $balance_8 = $record['balance_8']; 
                            $in_9 = $record['in_9']; 
                            $out_9 = $record['out_9']; 
                            $balance_9 = $record['balance_9']; 
                            $in_10 = $record['in_10']; 
                            $out_10 = $record['out_10']; 
                            $balance_10 = $record['balance_10']; 
                            $in_11 = $record['in_11']; 
                            $out_11 = $record['out_11']; 
                            $balance_11 = $record['balance_11']; 
                            $in_12 = $record['in_12']; 
                            $out_12 = $record['out_12']; 
                            $balance_12 = $record['balance_12']; 

                            $no = $no + 1; 
                    ?>
                    <form method="post" onsubmit="return confirm('Do you want to proceed?');" action="../Controller/Database_sql.php" enctype="multipart/form-data">
                    <tr>
                        <td><?php echo $no; ?></td>
                        <td><input type="text" class="form-control" name="item_name" value="<?php echo $item_name; ?>"></td>
                        <td><input type="number" class="form-control" name="in_1" value="<?php echo $in_1; ?>"></td>  
                        <td><input type="number" class="form-control" name="out_1" value="<?php echo $out_1; ?>"></td>
                        <td><input type="number" class="form-control" name="balance_1" value="<?php echo $balance_1; ?>"></td>
                        <td><input type="number" class="form-control" name="in_2" value="<?php echo $in_2; ?>"></td>  
                        <td><input type="number" class="form-control" name="out_2" value="<?php echo $out_2; ?>"></td>
                        <td><input type="number" class="form-control" name="balance_2" value="<?php echo $balance_2; ?>"></td>
                        <td><input type="number" class="form-control" name="in_3" value="<?php echo $in_3; ?>"></td>  
                        <td><input type="number" class="form-control" name="out_3" value="<?php echo $out_3; ?>"></td>
                        <td><input type="number" class="form-control" name="balance_3" value="<?php echo $balance_3; ?>"></td>
                        <td><input type="number" class="form-control" name="in_4" value="<?php echo $in_4; ?>"></td>  
                        <td><input type="number" class="form-control" name="out_4" value="<?php echo $out_4; ?>"></td>
                        <td><input type="number" class="form-control" name="balance_4" value="<?php echo $balance_4; ?>"></td>
                        <td><input type="number" class="form-control" name="in_5" value="<?php echo $in_5; ?>"></td>  
                        <td><input type="number" class="form-control" name="out_5" value="<?php echo $out_5; ?>"></td>
                        <td><input type="number" class="form-control" name="balance_5" value="<?php echo $balance_5; ?>"></td>
                        <td><input type="number" class="form-control" name="in_6" value="<?php echo $in_6; ?>"></td>  
                        <td><input type="number" class="form-control" name="out_6" value="<?php echo $out_6; ?>"></td>
                        <td><input type="number" class="form-control" name="balance_6" value="<?php echo $balance_6; ?>"></td>
                        <td><input type="number" class="form-control" name="in_7" value="<?php echo $in_7; ?>"></td>  
                        <td><input type="number" class="form-control" name="out_7" value="<?php echo $out_7; ?>"></td>
                        <td><input type="number" class="form-control" name="balance_7" value="<?php echo $balance_7; ?>"></td>
                        <td><input type="number" class="form-control" name="in_8" value="<?php echo $in_8; ?>"></td>  
                        <td><input type="number" class="form-control" name="out_8" value="<?php echo $out_8; ?>"></td>
                        <td><input type="number" class="form-control" name="balance_8" value="<?php echo $balance_8; ?>"></td>
                        <td><input type="number" class="form-control" name="in_9" value="<?php echo $in_9; ?>"></td>  
                        <td><input type="number" class="form-control" name="out_9" value="<?php echo $out_9; ?>"></td>
                        <td><input type="number" class="form-control" name="balance_9" value="<?php echo $balance_9; ?>"></td>
                        <td><input type="number" class="form-control" name="in_10" value="<?php echo $in_10; ?>"></td>  
                        <td><input type="number" class="form-control" name="out_10" value="<?php echo $out_10; ?>"></td>
                        <td><input type="number" class="form-control" name="balance_10" value="<?php echo $balance_10; ?>"></td>
                        <td><input type="number" class="form-control" name="in_11" value="<?php echo $in_11; ?>"></td>  
                        <td><input type="number" class="form-control" name="out_11" value="<?php echo $out_11; ?>"></td>
                        <td><input type="number" class="form-control" name="balance_11" value="<?php echo $balance_11; ?>"></td>
                        <td><input type="number" class="form-control" name="in_12" value="<?php echo $in_12; ?>"></td>  
                        <td><input type="number" class="form-control" name="out_12" value="<?php echo $out_12; ?>"></td>
                        <td><input type="number" class="form-control" name="balance_12" value="<?php echo $balance_12; ?>"></td>
                        <input type="hidden" class="form-control"  name="id" value="<?php echo $id; ?>">
                        <td>
                            <button name="Update_Inventory_Setting" class="btn btn-success"><i class="fa fa-check"></i> Update</button>
                            <button name="Delete_Inventory_Setting" class="btn btn-danger"> Remove</button>                                   
                        </td>
                    </form> 
                    </tr>
                    <?php 
                    }
                    }
                    ?>
                </tbody>
            </table>
            </form>                                 
        </div>
    </div>
</div>                      
</div>
</div>
<!-- ============================================================== -->
<!-- End PAge Content -->

</div>
<!-- End Container fluid  -->
</div>
<!-- End Page wrapper  -->

<!-- Footer Start-->
<?php include ("../Footer/footer.php"); ?>
<!-- Footer End-->

</div>
<!-- End Wrapper -->
<!-- All Jquery -->
    

<!-- All Jquery Start-->
<?php include ("../Header/all_jquery.php"); ?>
<!-- All Jquery End-->

</body>

</html>