<div class="row">
    <div class="col-md-12">
                                
        <div id="change_stock" class="modal fade" tabindex="-1" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                        <h4 class="modal-title">Change <?php echo $stock_name; ?> Balance</h4>
                    </div>
                    <form id="change_stock_balance" class="form-horizontal" method="post">
                        <input type="hidden" id="stock_name" name="stock_name" value="<?php echo $stock_name; ?>">
                        <div class="modal-body">
                            <div id="response_msg_modal"></div>
                            <div class="scroller" style="height:200px" data-always-visible="1" data-rail-visible1="1">
                                <div class="row">
                                    <div class="col-md-12">
                                        <div class="form-body">
                                            <div class="row form-group">
                                                <label class="col-md-3 control-label pull-left">Action</label>
                                                <div class="col-md-6">
                                                    <select name="credit_debit_balance" class="form-control select2me">
                                                        <option value="Credited">Credit</option>
                                                        <option value="Debited">Debit</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="row form-group">
                                                <label class="col-md-3 control-label pull-left">Balance</label>
                                                <div class="col-md-6">
                                                    <div class="input-group input-small">
                                                        <?php if($stock_name == 'DXB Cash' || $stock_name == 'BOX Cash'){ ?>
                                                            <span class="input-group-addon">
                                                                Rs
                                                            </span>
                                                        <?php } ?>
                                                        <input type="number" name="stock_balance" id="stock_balance" class="form-control input-small"/>
                                                        <?php if($stock_name == 'DXB 22K Gold' || $stock_name == 'DXB 24K Gold' || $stock_name == 'BOX 22K Gold' || $stock_name == 'BOX 24K Gold'){ ?>
                                                            <span class="input-group-addon">
                                                                g
                                                            </span>
                                                        <?php } ?>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="row form-group">
                                                <label class="col-md-3 control-label pull-left">Description</label>
                                                <div class="col-md-6">
                                                    <textarea name="description" class="form-control"></textarea>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" data-dismiss="modal" class="btn default">Close</button>
                            <button type="submit" class="btn green">Save changes</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
                                
        <div class="modal fade" id="success_modal" tabindex="-1" role="basic" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                        <h4 class="modal-title">Success!</h4>
                    </div>
                    <div class="modal-body">
                        <?php echo $stock_name; ?> Balance Changed Sent Successfully
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn green" data-dismiss="modal" onclick="window.location.reload()">Ok</button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
        
        <div class="pull-right">
            <a class="btn default green-stripe"  data-toggle="modal" href="#change_stock"> Change <?php echo $stock_name; ?> Balance</a>
        </div>
        <h4><?php echo $stock_name; ?> Balance Details</h4>
        <hr>
        <div class="col-md-offset-2 col-md-8">
            <div id="response_msg"></div>

            <table class="table table-hover table-bordered table-striped" style="font-size: initial;">
                <tr>
                    <td>
                        <strong><?php echo $stock_name; ?> Balance </strong>
                    </td>
                    <td>
                        <strong>
                            <?php 
                            if($stock_name == 'DXB Cash'){
                                echo 'Rs '.number_format($stock_details->cash_in_hand,2,'.',',');
                            }elseif($stock_name == 'DXB 22K Gold'){
                                echo $stock_details->tt_gold_in_hand.' g';
                            }elseif($stock_name == 'DXB 24K Gold'){
                                echo $stock_details->tf_gold_in_hand.' g';
                            }elseif($stock_name == 'BOX Cash'){
                                echo 'Rs '.number_format($stock_details->box_cash_in_hand,2,'.',',');
                            }elseif($stock_name == 'BOX 22K Gold'){
                                echo $stock_details->box_tt_gold_in_hand.' g';
                            }elseif($stock_name == 'BOX 24K Gold'){
                                echo $stock_details->box_tf_gold_in_hand.' g';
                            }
                            ?>
                        </strong>
                    </td>
                </tr>
                <?php if($stock_log){ ?>
                <tr>
                    <td>
                        <strong>Last Updated On </strong>
                    </td>
                    <td>
                        <strong><?php echo $stock_log->added_on; ?></strong>
                    </td>
                </tr>
                <tr>
                    <td>
                        <strong>Last Updated By </strong>
                    </td>
                    <td>
                        <strong>
                            <?php
                            $admin_details = $this->admin_db->get_admin_detail($stock_log->added_by);    
                            
                            echo $admin_details->contact_name.' - '.$admin_details->user_privilege;
                            
                            ?>
                        </strong>
                    </td>
                </tr>
                <?php } ?>
            </table>
        </div>
    </div>
    <div class="col-md-12">

        <h4><?php echo $stock_name; ?> Balance Logs</h4>
        <hr>
                                                
        <script type="text/javascript" language="javascript" >
            $(document).ready(function () {
                var dataTable = $('#stock_logs').DataTable({
                    order: [[ 0, "desc" ]],
                    select: true,
                    pageLength: 10,
                    processing: true,
                    serverSide: true,
                    ajax: {
                        url: "Json_data/json_data_records?json_type=stock_logs&stock=<?php echo $stock_name; ?>", // json datasource
                        type: "post", // method  , by default get
                        error: function () {  // error handling
                            $(".employee-grid-error").html("");
                            $("#employee-grid").append('<tbody class="employee-grid-error"><tr><th colspan="6">No data found in the server</th></tr></tbody>');
                            $("#employee-grid_processing").css("display", "none");

                        }
                    }, "aoColumns": [
                        {"sTitle": "", "sClass": "hidden"},
                        {"sTitle": "ID"},
                        {"sTitle": "Action"},
                        {"sTitle": "Description"},
                        {"sTitle": "Amount", "Classname": "dt[-head|-body]-right"},
                        {"sTitle": "Action By"},
                        {"sTitle": "Action On"},
                    ], "fnCreatedRow": function (nRow, aData, iDataIndex) {
                        $(nRow).attr('id', '' + aData[0]);

                    }
                });

            });
        </script>
        
        <table id="stock_logs" class="table table-striped table-bordered table-hover"></table>
    </div>
</div>