 <?php $__env->startSection('content'); ?>
<?php echo $__env->make('administrator.construction.warehouse.create', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php echo $__env->make('administrator.construction.warehouse.edit', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php Fun::lang()?>
<div class="title-page">
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Dashboard</a></li>
            <li><a href="#">Warehouse</a></li>
            <li><a href="#">List</a></li>
        </ul>
    </div>
</div>
    <div class="page">
        <div class="top-content">
            <div class="row">
                <div class="col-sm-12 col-xs-12">
                    <div class="title-page">
                        <div class="pull-left">
                            <h3>Warehouse List</h3>
                        </div>
                    </div>
                    <div class="pull-right">
                        <a class="button_sm button_primary" href="#form-modal-create-warehouse" data-toggle="modal"><span class="fa fa-plus"></span>  Create New</a>
                    </div>
                </div>
            </div>
        </div>
        <div class="box-body table-responsive">
                        
            <table id="datatable_warehouse" width="100%" class="table table-striped table-bordered table-hover nowrap">
                <thead>
                    <tr>
                        <th>NO</th>
                        <th>Name</th>
                        <th>Project</th>
                        <th>Description</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                   
                </tbody>
            </table>

        </div>
    </div>
    <?php $__env->stopSection(); ?>
    <?php $__env->startSection('js'); ?>
    <script type="text/javascript">
            function edit(id)
            {
                $("#main-spinner").show();
                var route = "<?php echo e(route('warehouse-construction.get_for_edit',':id')); ?>";
                route = route.replace(":id",id);
                $.ajax({
                    url:route,
                    type:"GET",
                    dataType:"JSON",
                    success:function(data){
                        $("#main-spinner").hide();
                        $("#form-modal-edit-warehouse").modal('show');
                        $("#warehouse-id").val(id);
                        $("#warehouse-name").val(data['warehouse'].name);
                        $("#warehouse-description").val(data['warehouse'].description);
                        $("#warehouse-project_id").empty();
                        $("#warehouse-project_id").append(`<option value="">Please Select</option>`);
                        $.each(data['projects'],function(index,value)
                        {
                            if(value.id==data['warehouse'].project_id){
                                $("#warehouse-project_id").append(`<option value="${value.id}" selected>${value.project_name}</option>`);
                            }
                            else{
                                $("#warehouse-project_id").append(`<option value="${value.id}" selected>${value.project_name}</option>`);
                            }
                        });
                    }
                });
            }
            $(document).ready(function() {
                $('#main-spinner').show();
                var table = $('#datatable_warehouse').DataTable({
                    ordering: false,
                    "serverSide": true,
                    "lengthMenu": [
                    [20, 25, 50, 100, 500],
                    [20, 25, 50, 100, 500]
                ],
                    ajax: "<?php echo e(route('warehouse-construction.get_data_index')); ?>",
                    columns: [
                    {
                        data: 'DT_RowIndex'
                    }, {
                        data: 'name'
                    }, {
                        data: 'project_name'
                    }
                    ,{
                        data: 'description'
                    }
                    , {
                        data: 'action'
                    }, ],
                    "initComplete": function(settings, json) {
                        $('#main-spinner').hide();
                    }
                });

                $.fn.dataTable.ext.errMode = 'throw';
            });
    </script>
    
    <?php $__env->stopSection(); ?>
<?php echo $__env->make('adminlte::page', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>