 <?php $__env->startSection('content'); ?>
<?php Fun::lang() ?>
<style>
    .form-control:disabled, .form-control[readonly] {
        background-color: transparent !important;
        opacity: 1 !important;
    }
    .table-inv-head td {
        border: none;
    }

    .table th {
        vertical-align: middle !important;
    }

    table tr:nth-child(even), table tr:hover {
        background: none;
    }

    .table > thead > tr > th {
        border: 1px solid white;
        text-align: center;
    }
</style>
<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="#">Construction</a></li>
            <li><a href="#">BOQ & Purchase Order</a></li>
            <li><a href="#">Request BOQ</a></li>
            <li><a href="#">Show</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>Show BOQ</h3>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12 col-xs-12">

            <div class="form-wrapper">
                <form acion="#">
                    <div class="row">
                        <div class="form-group col-sm-4 col-xs-12">
                            <label>Prepared By</label>
                            <?php echo Form::text('prepared_by', $data->prepared_by, array('placeholder' => 'Name','class' => 'form-control','required','readonly')); ?>

                        </div>
                        <div class="form-group col-sm-4 col-xs-12">
                            <label>Project Name </label>
                            <?php echo Form::text('project_id', $data->project_name, ['class' => 'form-control select2','required','readonly']); ?>

                        </div>
                        <div class="form-group col-sm-4 col-xs-12" style="display: none;">
                            <label>Zone Name </label>
                            <?php echo Form::text('zone_name', $data->zone_name, ['class' => 'form-control select2','required','readonly']); ?>

                        </div>
                        <div class="form-group col-sm-4 col-xs-12">
                            <label>Category House</label>
                            <?php echo Form::text('category_house', $data->sub_category_house, ['class' => 'form-control select2','required','readonly']); ?>

                        </div>
                        <div class="form-group col-sm-4 col-xs-12">
                            <label>Amount of house used (units) </label>
                            <?php echo Form::text('amount_of_house_used', $data->amount_of_house_used, array('placeholder' => 'Number','class' => 'form-control number-only','required','id'=>'amount_all_house_used','readonly')); ?>

                        </div>
                        <div class="form-group col-sm-4 col-xs-12">
                            <label>Date</label>
                            <?php echo Form::text('date', date('d-m-Y',strtotime($data->date)), array('laceholder'=>'Date','class' => 'form-control date_picker','required','readonly')); ?>

                        </div>
                        <div class="form-group col-sm-4 col-xs-12">
                            <label class="required">Building Type</label>
                            <?php echo Form::text('building_type', $data->building_type, array('placeholder' => 'Type','class' => 'form-control','required','readonly')); ?>

                        </div>
                        <div class="form-group col-sm-12 col-xs-12">
                            <label>Title</label>
                            <?php echo Form::textarea('title_boq', $data->title, array('placeholder' => 'Title','class' => 'form-control','rows'=>'2','readonly')); ?>

                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-12 col-sm-12 col-md-12 text-right">
                            <button type="button" class="button_primary btn-sm search"><a href="<?php echo e(route('construction.boq.print_boq',$data->id)); ?>" style="color:white;"><span class="fa fa-print"> Print</span></a></button>
                        </div>
                    </div>
                    <div class="row" >
                        
                        <div style="padding: 15px;" id="boq-table-form">
                            <table class="table" width="100%">
                                <thead>
                                    <tr>
                                        <th>No</th>
                                        <th>
                                            <label>
                                                Product Name
                                            </label>
                                        </th>
                                        <th>
                                            <label>
                                                Sub Category
                                            </label>
                                        </th>
                                        <th>
                                            <label>
                                                Unit
                                            </label>
                                        </th>
                                        <th>
                                            <label>
                                                Qty of using for one house
                                            </label>
                                        </th>
                                        <th>
                                            <label>
                                                Loss Percentage(%)
                                            </label>
                                        </th>
                                        <th>
                                            <label>
                                                Qty of using for <span><?php echo e($data->amount_of_house_used); ?></span>
                                            </label>
                                            
                                        </th>
                                        <th>Other</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $index = 1; ?>
                                    <?php $__currentLoopData = $titles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k=>$val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <tr>
                                            <td colspan="8" rowspan="2" style="text-align: center;">
                                                <u style="font-weight: bold;"><h5 style="font-size: 120%;"><?php echo e($val->title); ?></h5></u>
                                            </td>
                                        </tr>
                                        <tr>
                                        </tr>
                                        <?php $__currentLoopData = $data_detail; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <?php if($val->title==$value->title): ?>
                                                <tr>
                                                    <td><?php echo e($index++); ?></td>
                                                    <td>
                                                        <?php echo e($value->product_name); ?>

                                                    </td>
                                                    <td>
                                                        <?php echo e($value->subcategory_name); ?>

                                                    </td>
                                                    <td>
                                                        <?php echo e($value->unit_name); ?>

                                                    </td>
                                                    <td>
                                                        <?php echo e($value->qty_used_one_house); ?>

                                                    </td>
                                                    <td>
                                                        <?php echo e($value->loss_percentage); ?> %
                                                    </td>
                                                    <td>
                                                        <?php echo e($value->qty_used_all_amount_of_house); ?>

                                                        
                                                    </td>
                                                    <td><?php echo e($value->description); ?></td>
                                                </tr>
                                            <?php else: ?>
                                                <?php $index=1; ?>
                                            <?php endif; ?>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    
                                </tbody>
                            </table>
                        </div>
                    </div>
                    
                    <div class="row">
                        <div class="col-sm-12 col-xs-12">
                            <div class="form-group">
                            <?php if($approval_type=="ceo"): ?>
                                <?php if($data->status==1 || $data->status==3 ): ?>{
                                    <?php if(Gate::check('Construction-CEO-Approval-BOQ-Appove')): ?>
                                        <button type="button" data-status = '1' data-id='<?php echo e(Crypt::encrypt($data->id)); ?>' title='Approve'  class='button_sm button_success pull-right boq_approval_ceo' style='margin-left:5px !important;'>Approve</button>
                                    <?php endif; ?>
                                    <?php if(Gate::check('Construction-CEO-Approval-BOQ-Reject')): ?>
                                        <button type="button" data-status = '2' data-id='<?php echo e(Crypt::encrypt($data->id)); ?>'  title='Reject'  class='button_sm button_danger pull-right boq_approval_ceo' style='margin-left:5px !important;'>Reject</button>
                                    <?php endif; ?>
                                <?php endif; ?>
                            <?php endif; ?>
                                    
                            <?php if($approval_type=="financial"): ?>
                                <?php if($data->status==1 || $data->status==4 ): ?>
                                    <?php if(Gate::check('Construction-Financial-Approval-BOQ-Appove')): ?>
                                        <button type="button" data-status = '1' data-id='<?php echo e(Crypt::encrypt($data->id)); ?>' title='Approve'  class='button_sm button_success pull-right boq_approval_financial' style='margin-left:5px !important;'>Approve</button>
                                    <?php endif; ?>
                                    <?php if(Gate::check('Construction-Financial-Approval-BOQ-Reject')): ?>
                                        <button type="button" data-status = '2' data-id='<?php echo e(Crypt::encrypt($data->id)); ?>'  title='Reject'  class='button_sm button_danger pull-right boq_approval_financial' style='margin-left:5px !important;'>Reject</button>
                                    <?php endif; ?>
                                <?php endif; ?>
                            <?php endif; ?>
                                <button type="button" onClick="javascript:history.go(-1)" class="button_sm button_warning pull-right">
                                    <span class=" fa fa-arrow-circle-left"></span> Back</button>
                            </div>
                        </div>
                    </div>
                    <br/>

                </form>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?> 
<?php $__env->startSection('js'); ?>
<script>
    $(document).on('click','.boq_approval_financial',function () {
        let status = $(this).data('status');
        let id = $(this).data('id');
        let text = '';
        let btn = '';
        let content =   '<form action="" class="formName">' +
                            '<div class="form-group" style="text-align:left;">' +
                                '<label>Description</label>' +
                                '<textarea type="text" placeholder="Description" class="description form-control"></textarea>' +
                            '</div>' +
                        '</form>';
        if(status === 1){
            content = '';
        }
        if(status===1){
            text = 'Approve';
            btn = 'success';
        }else{
            text = 'Reject';
            btn = 'danger';
        }
        $.confirm({
            title:'Are you sure ?',
            content:''+content,
            theme:'modern',
            buttons:{
                cancel:{
                    btnClass:'btn btn-warning',
                    text:'Cancel',
                    action:function () {

                    }
                },
                submit:{
                    btnClass:'btn btn-'+btn,
                    text:text,
                    action:function () {
                        var description = this.$content.find('.description').val();
                        if(status === 1)
                        {
                            window.location.replace('<?php echo e(route('construction-financial-approval-update')); ?>?status='+status+'&r_id='+id);
                        }else{
                            window.location.replace('<?php echo e(route('construction-financial-approval-update')); ?>?status='+status+'&r_id='+id+'&description='+description);
                        }
                            
                    }
                },
            },
        });
    });
    $(document).on('click','.boq_approval_ceo',function () {
        let status = $(this).data('status');
        let id = $(this).data('id');
        let text = '';
        let btn = '';
        let content =   '<form action="" class="formName">' +
                            '<div class="form-group" style="text-align:left;">' +
                                '<label>Description</label>' +
                                '<textarea type="text" placeholder="Description" class="description form-control"></textarea>' +
                            '</div>' +
                        '</form>';
        if(status === 1){
            content = '';
        }
        if(status===1){
            text = 'Approve';
            btn = 'success';
        }else{
            text = 'Reject';
            btn = 'danger';
        }
        $.confirm({
            title:'Are you sure ?',
            content:''+content,
            theme:'modern',
            buttons:{
                cancel:{
                    btnClass:'btn btn-warning',
                    text:'Cancel',
                    action:function () {

                    }
                },
                submit:{
                    btnClass:'btn btn-'+btn,
                    text:text,
                    action:function () {
                        var description = this.$content.find('.description').val();
                        if(status === 1)
                        {
                            window.location.replace('<?php echo e(route('construction-ceo-approval-boq-update-status')); ?>?status='+status+'&r_id='+id);
                        }else{
                            window.location.replace('<?php echo e(route('construction-ceo-approval-boq-update-status')); ?>?status='+status+'&r_id='+id+'&description='+description);

                        }
                    }
                },
            },
        });
    });
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('adminlte::page', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>