<div>
    <table class="table">
        <thead>
        <tr>
            <th><?php echo e(__('administrator.no.')); ?></th>
            <th><?php echo e(__('administrator.language')); ?></th>
            <th><?php echo e(__('administrator.level')); ?></th>
            <th style="width: 100px;">  <a href="javascript:void(0)"  class="btn btn-xs btn-default r-add-lang-lang-lang"><i class="fa fa-plus"></i> + </a> </th>
        </tr>
        </thead>
        <tbody class="tbody-lan">
        <?php if(isset($emp->language)): ?>
            <?php if(is_array($emp->language)): ?>
                <?php if(count($emp->language)>0): ?>
                    <?php $__currentLoopData = $emp->language; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k => $r): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <?php
                        $name = isset($r['name'])?$r['name']:'';
                        $type = isset($r['type'])?$r['type']:'';
                        ?>
                        <tr>
                            <td class="r-no-lan">1</td>
                            <td>
                                <input class="form-control" value="<?php echo e($name); ?>" type="text" name="language[<?php echo e($k); ?>][name]">
                            </td>
                            <td>
                                <select class="form-control" name="language[<?php echo e($k); ?>][type]">
                                    <option value=""></option>
                                    <option <?php echo e($type=='Beginner'?' selected="selected" ':''); ?>  value="Beginner">Beginner</option>
                                    <option <?php echo e($type=='Advance'?' selected="selected" ':''); ?>  value="Advance">Advnace</option>
                                    <option <?php echo e($type=='Intermediate'?' selected="selected" ':''); ?>  value="Intermediate">Intermediate</option>
                                </select>
                            </td>
                            <td style="text-align:center">
                                <a href="javascript:void(0)"  class="btn btn-xs btn-default r-del"><i class="fa fa-trash"></i> - </a>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <?php endif; ?>
            <?php endif; ?>
        <?php endif; ?>
        </tbody>
    </table>
</div>

<?php $__env->startPush('script'); ?>
    <script>
        $(function () {

            $('body').on('click', '.r-del-lang', function (e) {
                e.preventDefault();
                $(this).parent().parent().remove();
                //updateNo();
            });

            $('body').on('click', '.r-add-lang-lang-lang', function (e) {
                e.preventDefault();
                var r =  Math.floor(Math.random() * 26) + Date.now();

                var tr = '<tr>\n' +
                    '                <td class="r-no-lan">1</td>\n' +
                    '                <td>\n' +
                    '                    <input class="form-control" type="text" name="language['+r+'][name]">\n' +
                    '                </td>\n' +
                    '                <td>\n' +
                    '                    <select class="form-control" name="language['+r+'][type]">\n' +
                    '                        <option value=""></option>\n' +
                    '                        <option value="Beginner">Beginner </option>\n' +
                    '                        <option value="Advance">Advance </option>\n' +
                    '                        <option value="Intermediate">Intermediate</option>\n' +
                    '                    </select>\n' +
                    '                </td>\n' +
                    '                <td style="text-align:center">\n' +
                    '                    <a href="javascript:void(0)"  class="btn btn-xs btn-default r-del-lang"><i class="fa fa-trash"></i> - </a>\n' +
                    '                </td>\n' +
                    '            </tr>';

                $('.tbody-lan').append(tr);

                updateNo();
            });

            updateNo();

            <?php if(!isset($emp->language)): ?>
                $('.r-add-lang-lang-lang').trigger('click');
            <?php endif; ?>
        });

        function updateNo() {
            $('.r-no-lan').each(function (i,item) {
                $(this).text(i+1);
            });
        }
    </script>
<?php $__env->stopPush(); ?>
<?php /**PATH /home/nsowos/public_html/shr-brand/resources/views/hr/employee/emp-language-script.blade.php ENDPATH**/ ?>