<div>
    
    <table class="table">
        <thead>
        <tr>
            <th><?php echo e(__('administrator.no.')); ?></th>
            <th><?php echo e(__('administrator.company_name')); ?></th>
            <th><?php echo e(__('administrator.position_duties')); ?></th>
            <th><?php echo e(__('administrator.location')); ?></th>
            <th><?php echo e(__('administrator.joined_date')); ?></th>
            <th><?php echo e(__('administrator.resign_date')); ?></th>
            <th style="width: 100px;">  <a href="javascript:void(0)"  class="btn btn-xs btn-default r-add-exp"><i class="fa fa-plus"></i> + </a> </th>
        </tr>
        </thead>
        <tbody class="tbody-family-exp">
        <?php if(isset($emp->work_experience)): ?>
            <?php if(is_array($emp->work_experience)): ?>
                <?php if(count($emp->work_experience)>0): ?>
                    <?php $__currentLoopData = $emp->work_experience; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k => $r): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <?php
                        $company_name = isset($r['company_name'])?$r['company_name']:'';
                        $position = isset($r['position'])?$r['position']:'';
                        $location = isset($r['location'])?$r['location']:'';
                        $join_date_w = isset($r['join_date_w'])?$r['join_date_w']:'';
                        $end_date_w = isset($r['end_date_w'])?$r['end_date_w']:'';
                        ?>
                        <tr>
                            <td class="r-no-exp">1</td>
                            <td>
                                <input class="form-control" value="<?php echo e($company_name); ?>" name="work_experience[<?php echo e($k); ?>][company_name]" >
                            </td>
                            <td>
                                <input class="form-control" value="<?php echo e($position); ?>" type="text" name="work_experience[<?php echo e($k); ?>][position]">
                            </td>
                            <td>
                                <input class="form-control" value="<?php echo e($location); ?>" type="text" name="work_experience[<?php echo e($k); ?>][location]">
                            </td>
                            <td>
                                <input class="form-control join_date_w" value="<?php echo e($join_date_w); ?>" type="text" name="work_experience[<?php echo e($k); ?>][join_date_w]">
                            </td>
                            <td>
                                <input class="form-control end_date_w" value="<?php echo e($end_date_w); ?>" type="text" name="work_experience[<?php echo e($k); ?>][end_date_w]">
                            </td>
                            <td style="text-align:center">
                                <a href="javascript:void(0)"  class="btn btn-xs btn-default r-del-exp"><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-exp', function (e) {
                e.preventDefault();
                $(this).parent().parent().remove();
                //updateNoExp();
            });

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

                var tr = '<tr>\n' +
                    '    <td class="r-no-exp">1</td>\n' +
                    '    <td>\n' +
                    '        <input class="form-control"  name="work_experience['+r+'][company_name]" >\n' +
                    '    </td>\n' +
                    '    <td>\n' +
                    '        <input class="form-control"  type="text" name="work_experience['+r+'][position]">\n' +
                    '    </td>\n' +
                    '    <td>\n' +
                    '        <input class="form-control"  type="text" name="work_experience['+r+'][location]">\n' +
                    '    </td>\n' +
                    '    <td>\n' +
                    '        <input class="form-control join_date_w"  type="text" name="work_experience['+r+'][join_date_w]">\n' +
                    '    </td>\n' +
                    '    <td>\n' +
                    '        <input class="form-control end_date_w"  type="text" name="work_experience['+r+'][end_date_w]">\n' +
                    '    </td>\n' +
                    '    <td style="text-align:center">\n' +
                    '        <a href="javascript:void(0)"  class="btn btn-xs btn-default r-del-exp"><i class="fa fa-trash"></i> - </a>\n' +
                    '    </td>\n' +
                    '</tr>';

                $('.tbody-family-exp').append(tr);


                // $('.join_date_w,.end_date_w').bootstrapDP({
                //     format: 'yyyy-mm-dd'
                // });
                updateNoExp();
            });

            // $('.join_date_w,.end_date_w ').bootstrapDP({
            //     format: 'yyyy-mm-dd'
            // });

            updateNoExp();

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

        function updateNoExp() {
            $('.r-no-exp').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-work-experience-script.blade.php ENDPATH**/ ?>