@extends('adminlte::page') @section('content')
    @include('administrator.construction.warehouse.create')
    @include('administrator.construction.warehouse.edit')
    <?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="#">Bill of Quantities (BOQ)</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>Financial Request BOQ</h3>
                        </div>
                    </div>
                    <div class="pull-right">
                        <a class="button_sm button_primary" href="{{ route('construction-boq.create') }}"
                           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_boq_index" width="100%" class="table table-striped table-bordered table-hover nowrap">
                <thead>
                <tr>
                    <th>NO</th>
                    <th>Date</th>
                    <th>Type of Building</th>
                    <th>Project</th>
                    <th>Prepared By</th>
                    <th>Description</th>
                    <th>Status</th>
                    <th>Action</th>
                </tr>
                </thead>
                <tbody>

                </tbody>
            </table>

        </div>
    </div>

@endsection
@section('js')
    <script type="text/javascript">
        $(document).on("keyup", "#amount_all_house_used", function () {
            $(".amount-house-used").html($("#amount_all_house_used").val() + " houses");
        });
        let product = '{!! json_encode($products) !!}';
        $(document).ready(function () {
            if (product == "") {
                $('#main-spinner').show();
            }

            let table = $('#datatable_boq_index').DataTable({
                ordering: false,
                "serverSide": true,
                "lengthMenu": [
                    [20, 25, 50, 100, 500],
                    [20, 25, 50, 100, 500]
                ],
                ajax: "{{ route('construction-ceo-approval-boq.index') }}",
                columns: [
                    {
                        data: 'DT_RowIndex'
                    }, {
                        data: 'date'
                    }
                    , {
                        data: 'building_type'
                    }
                    , {
                        data: 'project_name'
                    }
                    , {
                        data: 'prepared_by'
                    }
                    , {
                        data: 'description'
                    }
                    , {
                        data: 'status'
                    }, {
                        data: 'action'
                    },],
                "initComplete": function (settings, json) {
                    $('#main-spinner').hide();
                }
            });

            $.fn.dataTable.ext.errMode = 'throw';
        });

        $(document).ready(function () {
            $(document).on('click','.boq_approval',function () {
                let status = $(this).data('status');
                let id = $(this).data('id');
                let text = '';
                let btn = '';
                if(status===1){
                    text = 'Approve';
                    btn = 'success';
                }else{
                    text = 'Reject';
                    btn = 'danger';
                }
                $.confirm({
                    title:'Are you sure ?',
                    content:'',
                    theme:'modern',
                    buttons:{
                        cancel:{
                            btnClass:'btn btn-warning',
                            text:'Cancel',
                            action:function () {

                            }
                        },
                        submit:{
                            btnClass:'btn btn-'+btn,
                            text:text,
                            action:function () {
                                    window.location.replace('{{route('construction-ceo-approval-boq-update-status')}}?status='+status+'&r_id='+id);
                            }
                        },
                    },
                });
            });
        });
    </script>
@endsection