
<?php $__env->startSection('content'); ?>
    <!-- begin::main content -->
    <style>
        textarea{
    min-height: 30px !important;
}

.form-control, .swal-modal input.swal-content__input{
    height: 43px !important;
}

.btn.btn-add, .btn.btn-add-payment {
    padding-left: 2.8571428571em;
    background-repeat: no-repeat;
    background-position: 1.4285714286em center;
}




input{
    border: 1px solid #c6d9e0 !important;
}

.search-btn {
    position: relative;
    right: 31px;
    top: 1px;
    color: #bdbdbd;
}

label {
    display: block;
    font-size: 13px;
    line-height: 1.3846153846em;
    color: #526069;
    margin-bottom: 0.7692307692em;
    user-select: none;
    cursor: pointer;
    font-weight: 500;
    width: 10.7692307692em;
}

.search-card{
    width:100%;
    border:none;
}
.tab {
    display: inline-block;
    padding: 16px 12px;
    cursor: pointer;
    
    background-color: #E6EAED;
    margin-right: -4px; /* Remove spacing between tabs */
  }

  /* Style for highlighted tab */
  .tab.active {
    background-color: white;
  }

  /* Content area style */
  .tab-content {
    
    padding: 20px;
    border-radius: 0 0 5px 5px;
    display: none; /* Hide all content areas by default */
  }

  /* Show active content area */
  .tab-content.active {
    display: block;
  }
    </style>

    <main class="main-content">

        <div class="container">

            <!-- begin::page header -->
            <div class="page-header">
                <h3><?php echo e(__('message.edit')); ?> Promotion Details</h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="<?php echo e(asset('dashboard')); ?>"><?php echo e(__('message.dashboard')); ?></a></li>
                        <li class="breadcrumb-item" aria-current="page"><a href="<?php echo e(asset('hrms/promotion')); ?>">Promotion</a></li>
                        <li class="breadcrumb-item active" aria-current="page"><?php echo e(__('message.add')); ?></li>
                    </ol>
                </nav>
            </div>
            <!-- end::page header -->

            <div class="row">
                <div class="col-md-12">

                    <?php if (isset($component)) { $__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74 = $component; } ?>
<?php $component = $__env->getContainer()->make(App\View\Components\FlashMessage::class, []); ?>
<?php $component->withName('flashMessage'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74)): ?>
<?php $component = $__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74; ?>
<?php unset($__componentOriginal8a5ba9c90b64d384232e9948b1023e746ba08e74); ?>
<?php endif; ?>
                    <?php if($errors->any()): ?>
                        <div class="alert alert-danger">
                            <ul>
                                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <li><?php echo e($error); ?></li>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </ul>
                        </div>
                    <?php endif; ?>
                    
                    <div class="card">
                    
                        <div class="card-body py-0">
                        
                            <div class="bg-white ">
                                   
                                <div class="row pb-5">
                                    <div class="col-md-6" style="border-right: 1px solid #e5e5e5;">
                                              
                                            <div class="card-body">
                                                 
                                                <form action="<?php echo e(asset('hrms/add-promotion')); ?>"  method="post" enctype="multipart/form-data">
                                                    <?php echo csrf_field(); ?>
                                                    <input type="hidden" value="<?php echo e($promotion->id); ?>" name="promotion_id">
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="promotion_title">Promotion Title</label>
                                                        <input type="text" class="form-control" value="<?php echo e($promotion->promotion_title); ?>" id="promotion_title" name="promotion_title">
                                                       
                                                    </div>  

                                                   
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="name">Department</label>
                                                        <select name="department" class="form-control select2 text-capitalize department_change" >
                                                            <option disabled >SELECT</option>
                                                           
                                                            <?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dpt): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <option value="<?php echo e($dpt->id); ?>" <?php echo e($promotion->department == $dpt->id ? 'selected' : ''); ?>><?php echo e($dpt->name); ?></option>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                       </select>
                                                    </div>

                                                    <div class="d-flex justify-content-end px-3">
                                                        <?php if($errors->has('department_id')): ?>
                                                            <div class="text-danger">
                                                                <p><?php echo e($errors->first('department_id')); ?></p>
                                                            </div>
                                                        <?php endif; ?>
                                                    </div>  

                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="name">Employee</label>
                                                        <select name="user_unique_id" class="form-control select2 text-capitalize employee_select" >
                                                           
                                                           
                                                            
                                                       </select>
                                                    </div>

                                                    <div class="d-flex justify-content-end px-3">
                                                        <?php if($errors->has('employee_id')): ?>
                                                            <div class="text-danger">
                                                                <p><?php echo e($errors->first('employee_id')); ?></p>
                                                            </div>
                                                        <?php endif; ?>
                                                    </div>
                                                    

                                                    
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="name">Designation</label>
                                                        <input type="text" class="form-control" value="<?php echo e($promotion->designation); ?>" id="designation" name="designation">
                                                       
                                                    </div>                       
                                                    
                                                    <div class="form-group d-flex align-items-center">
                                                        <label for="promotion_date">Promotion Date</label>
                                                        <input type="date" name="promotion_date" value="<?php echo e($promotion->promotion_date); ?>" class="form-control">
                                                       
                                                    </div>

                                                   
                         
                                               
                                            </div>
                                    </div>
                                    <div class="col-md-6 py-4">
                                       
                                        <div class="form-group d-flex align-items-center">
                                            <label for="old_ctc">Old CTC</label>
                                            <input type="number" readonly name="old_ctc" value="<?php echo e($promotion->old_ctc); ?>" class="form-control old_ctc">
                                            
                                        </div>

                                        <div class="form-group d-flex align-items-center">
                                            <label for="increment_percentage">Increment (%)</label>
                                            <input type="number" name="increment_percentage" value="<?php echo e($promotion->increment_percentage); ?>" class="form-control increment_percentage">
                                            
                                        </div>

                                        <div class="form-group d-flex justify-content-between align-items-center">
                                            <label>New CTC</label>
                                            
                                            <input type="number" name="ctc" class="form-control ctc_input" value="<?php echo e($promotion->new_ctc); ?>">
                                        </div>

                                        <div class="form-group d-flex align-items-center">
                                            <label for="note">Note</label>
                                            <textarea rows="3" name="note" class="w-100 border px-2"><?php echo e($promotion->note); ?></textarea>
                                            
                                        </div>                                              
                                               
                                        
                                        <div class="row bg-white py-4 w-100"  style="position:fixed;bottom:0;left:266px">
                                            <div class="col-12 py-2 px-4">
                                                <button class="btn btn-success text-white mx-4" type="submit">
                                                <i class="fa fa-check fa-lg"></i>&nbsp SAVE
                                                </button>
                                                <button class="btn btn-primary" type="button">CANCEL</button>
                                            </div>
                                        </div>
                                    </form>
                                    </div>
                                </div>
                        
                                
                                       
                                   
                                
                            </div>
                            
                        </div>
                    </div>



                </div>

            </div>

                     
        </div>

    </main>
    <!-- end::main content -->
<?php $__env->stopSection(); ?>
<?php $__env->startPush('footer-script'); ?>
    <!-- begin::select2 -->
    <link rel="stylesheet" href="<?php echo e(asset('public/admin/vendors/select2/css/select2.min.css')); ?>" type="text/css">
    <script src="<?php echo e(asset('public/admin/vendors/select2/js/select2.min.js')); ?>"></script>
    <!-- end::select2 -->
    <script>

        $(window).on('load',function(){
            var promotion = <?php echo json_encode($promotion, 15, 512) ?>;
            var user_unique_id = promotion.user_unique_id;
            var id = promotion.department;

            

            $.ajaxSetup({
                                headers: {
                                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                                }
                            });

                    $.ajax({
                        type: "post",
                        url: "<?php echo e(asset('hrms/fetch-department-employee')); ?>",
                        data:{
                            id:id
                        },
                        dataType: "html",
                        success: function(result) 
                        {
                            $(".employee_select").html('');
                            var allData = JSON.parse(result);
                            var emp = allData.data;
                            var i;

                            $(".employee_select").append("<option selected disabled>SELECT</option>");
                            for(i=0;i<emp.length;i++)
                            {
                                var selected = emp[i].user_unique_id == user_unique_id ? 'selected' : '';
                                var option = `                                        
                                        <option value="${emp[i].user_unique_id}" ${selected} >${emp[i].name}</option>
                                        `;
                                $(".employee_select").append(option);
                            }
                            
                                                       
                        },
                        error:function(xhr,status,error)
                        {
                            $(".employee_select").html('');
                            console.log(xhr);
                           
                        }
                    });
        });
       
        $(document).ready(function() {
            
            $('#js-example-basic-roles').select2({});

           //ctc calculation
           $(".ctc_input").on('input',function(){
                              
                var ctc = $(this).val(); 
                
               

            });

            
            
           
            $(".employee_select").on('change',function(){
                    var user_unique_id = $(this).val(); 
                   
                    $.ajaxSetup({
                                headers: {
                                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                                }
                            });

                    $.ajax({
                        type: "post",
                        url: "<?php echo e(asset('hrms/fetch-emp-salary')); ?>",
                        data:{
                            user_unique_id:user_unique_id
                        },
                        dataType: "html",
                        success: function(result) 
                        {
                            var res = JSON.parse(result);
                            var allData = res.data;

                            console.log(allData);
                         
                            if(res.message === "not_salary")
                            {
                                $("#gross_salary").val("");
                                $("#net_salary").val("");
                                $("#designation").val(allData.designation);
                                return false;
                            }
                            if(res.message === "success")
                            {
                                var gross_salary = allData.gross_salary;
                                var net_salary = allData.net_salary;
                                var ctc = allData.ctc;
                                
                                $(".ctc_input").val(ctc);
                                $(".old_ctc").val(ctc);
                                $("#designation").val(allData.designation);
                               
                            }
                            
                                                       
                        },
                        error:function(xhr,status,error)
                        {
                            console.log(xhr);
                          
                        }
                    });

            }); 
            
            $(".department_change").on('change',function(){
                    var id = $(this).val(); 
                   
                    $.ajaxSetup({
                                headers: {
                                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                                }
                            });

                    $.ajax({
                        type: "post",
                        url: "<?php echo e(asset('hrms/fetch-department-employee')); ?>",
                        data:{
                            id:id
                        },
                        dataType: "html",
                        success: function(result) 
                        {
                            $(".employee_select").html('');
                            var allData = JSON.parse(result);
                            var emp = allData.data;
                            var i;
                            $(".employee_select").append("<option selected disabled>SELECT</option>");
                            for(i=0;i<emp.length;i++)
                            {
                                var option = `                                        
                                        <option value="${emp[i].user_unique_id}">${emp[i].name}</option>
                                        `;
                                $(".employee_select").append(option);
                            }
                            
                                                       
                        },
                        error:function(xhr,status,error)
                        {
                            $(".employee_select").html('');
                            console.log(xhr);
                           
                        }
                    });

            });

            //increments
            $(".increment_percentage").on("input",function(){
                let percentage = $(this).val();
                let old_ctc = $(".old_ctc").val();
                let new_ctc = Number(old_ctc) + ((old_ctc*percentage)/100);
                $(".ctc_input").val(new_ctc);

                salaryHeadCalculation(new_ctc);
            });    
        });    

    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\blurb_erp\resources\views/hrms/promotion/edit.blade.php ENDPATH**/ ?>