

<?php $__env->startSection('content'); ?>
    <?php Fun::lang() ?>
    <?php
    $rand_id = rand(1, 1000) . time() . rand(1, 1000);
    $id = isset($id) ? $id : null;
    $entry = null;
    if ($id > 0) {
        $entry = \App\Models\EmpLeave::find($id);
    }
    ?>
    <?php echo $__env->make('hr.page-breadcrumb',['l1'=>'Manage HR','l2'=>'ATTENDANCE','l3'=>'Take Leave'], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <div id="page" class="page">
        <?php echo $__env->make('hr.top-content',['l1'=>'Take Leave',
        'create'=> 1,
        'route' => 'take-leave',
        'btn_custom' => 0,
        'search' => 0,

        ], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
        <?php
        $d = isset($d) ? $d : null;
        ?>
        <?php if($d != null): ?>
            <form class="form" role="form" method="POST" action="<?php echo e(route('take-leave.update', $d->id)); ?>">
                <?php echo csrf_field(); ?>
                <?php echo method_field('PATCH'); ?>
                <?php else: ?>
                    <?php echo Form::open(array('route' => 'take-leave.store','method'=>'POST','enctype'=>'multipart/form-data')); ?>


                <?php endif; ?>
                <div class="row">

                    <div class="col-xs-12 col-sm-3 col-md-3 ">
                        <div class="form-group">
                            <label class="required">Employee Name</label>
                            <select id="select2_ajax_emp_id" class="select2 form-control" name="select2_ajax_emp_id">
                                <?php if($d !=null): ?>
                                    <option value="<?php echo e(optional($d->employee)->id); ?>"
                                            selected="selected"><?php echo e(optional($d->employee)->getName()); ?>111
                                    </option>
                                <?php endif; ?>
                            </select>
                        </div>
                    </div>

                    <div class="col-xs-12 col-sm-3 col-md-3 ">
                        <div class="form-group">
                            <label class="required">Form date</label>
                            <input type="text" name="from_date" class="form-control date_picker" placeholder="From date"
                                   autocomplete="off"
                                   value="<?php echo e($d!=null? date('Y-m-d', strtotime($d->from_date)):date('Y-m-d')); ?>">
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-3 col-md-3 ">
                        <div class="form-group">
                            <label class="required">To date</label>
                            <input type="text" name="to_date" class="form-control date_picker" placeholder="To date"
                                   autocomplete="off"
                                   value="<?php echo e($d!=null?date('Y-m-d', strtotime($d->to_date)):date('Y-m-d')); ?>">
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-3 col-md-3 ">
                        <div class="form-group">
                            <label>Request date</label>
                            <input type="text" name="request_date" class="form-control date_picker"
                                   placeholder="Request date"
                                   autocomplete="off"
                                   value="<?php echo e($d!=null? date('Y-m-d', strtotime($d->request_date)):date('Y-m-d')); ?>">
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-3 col-md-3 ">
                        <div class="form-group">
                            <label class="required">Leave Type</label>
                            <select id="leave_type" class="select2 form-control" name="leave_type">
                                <?php if($d !=null): ?>
                                    <option value="<?php echo e(optional(\App\Models\LeaveType::find($d->leave_type))->id); ?>"
                                            selected="selected"><?php echo e(str_replace('_',' ',optional(\App\Models\LeaveType::find($d->leave_type))->name)); ?>

                                    </option>
                                <?php endif; ?>
                            </select>
                        </div>
                    </div>

                    <div class="col-xs-12 col-sm-3 col-md-3 ">
                        <div class="form-group">
                            <label class="required">Request To</label>
                            <select id="request_to" class="select2 form-control" name="request_to">
                                <?php if($d !=null): ?>
                                    <option value="<?php echo e(optional(\App\Models\Employee::where('id',$d->request_to)->first())->id); ?>"
                                            selected="selected"><?php echo e(optional(\App\Models\Employee::where('id',$d->request_to)->first())->getName()); ?>

                                    </option>
                                <?php endif; ?>
                            </select>
                        </div>
                    </div>

                    <div class="col-xs-12 col-sm-9 col-md-9 ">
                        <div class="form-group">
                            <label>Reason</label>
                            <textarea class="form-control" rows="2" placeholder="Enter Your Reason" name="reason">
                        <?php if($d != null): ?>
                                    <?php echo $d->reason; ?>


                                <?php endif; ?>
                    </textarea>
                        </div>
                    </div>
                    <div class="col-xs-12 col-sm-3 col-md-3 ">
                        <div class="form-group">
                            <div class="checkbox">
                                <label>
                                    <input type="checkbox" title="Check it to approve authorize!" name="authorize" value="1"> Authorize

                                </label>
                            </div>
                        </div>
                    </div>


                    <?php echo $__env->make('hr.save_back', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

                </div>
                <?php if($d != null): ?>
            </form>
        <?php else: ?>
            <?php echo Form::close(); ?>

        <?php endif; ?>
    </div>

<?php $__env->stopSection(); ?>



<?php $__env->startSection('js'); ?>

    <script type="text/javascript" src="<?php echo e(asset('assets/controller/location.js')); ?>"></script>
    <script>
        $(function () {
            $('#select2_ajax_emp_id').select2({
                placeholder: 'Select Category',
                ajax: {
                    url: '<?php echo e(url('api/employee')); ?>',
                    dataType: 'json',
                    delay: 0,
                    processResults: function (data) {
                        return {
                            results: $.map(data, function (item) {
                                return {
                                    text: item.user_firstname + ' ' + item.user_lastname,
                                    id: item.id
                                }
                            })
                        };
                    },
                    cache: true
                },
                minimumInputLength: 0,
                autoClear: false,
                autoclose: true,
            });
            $('#request_to').select2({
                placeholder: 'Select Employee',
                ajax: {
                    url: '<?php echo e(url('api/employee')); ?>',
                    dataType: 'json',
                    delay: 0,
                    processResults: function (data) {
                        return {
                            results: $.map(data, function (item) {
                                return {
                                    text: item.user_firstname + ' ' + item.user_lastname,
                                    id: item.id
                                }
                            })
                        };
                    },
                    cache: true
                },
                minimumInputLength: 0,
                autoClear: false,
                autoclose: true,
            });

            $('#leave_type').select2({
                placeholder: 'Select Leave Type',
                ajax: {
                    url: '<?php echo e(url('api/leave-type')); ?>',
                    dataType: 'json',
                    delay: 0,
                    processResults: function (data) {
                        return {
                            results: $.map(data, function (item) {
                                return {
                                    text: item.name.substr(0, 1).toUpperCase() + item.name.substr(1),
                                    id: item.id
                                }
                            })
                        };
                    },
                    cache: true
                },
                minimumInputLength: 0,
                autoClear: false,
                autoclose: true,
            });

        });
    </script>


<?php $__env->stopSection(); ?>


<?php echo $__env->make('adminlte::page', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/nsowos/public_html/shr-brand/resources/views/hr/take-leave-authorize/create.blade.php ENDPATH**/ ?>