 
<?php $__env->startSection('title', 'Data Entry Operator Form'); ?>
<?php $__env->startSection('content'); ?>  
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>  
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap-datepicker.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/css/bootstrap-datetimepicker.min.css">

<?php 
    $getstatecodedata = DB::table('state_master')->get();
    $getdistrictcodedata = DB::table('district_master')->get();
    $getbtamasterdata = DB::table('bta_master')->get();
    $getintmasterdata = DB::table('int_master')->get();
    $getadhmasterdata = DB::table('adh_master')->get();

    $adminstatecode = auth()->user()->state_code;
    $admindistcode = auth()->user()->dist_code;
    $role_name  = auth()->user()->roles->pluck('name');
    if($role_name[0] == "Super Admin" || $role_name[0] == "Admin")
    {
        $getpatregdata = DB::table('patient_register')->get();
    }
    else
    {
        $getpatregdata = DB::table('patient_register')->where(['state_code'=>$adminstatecode,'dist_code'=>$admindistcode])->get();
    }
?>

<div class="container-fluid">
    <div class="page-header">
        <div class="row align-items-end">
            <div class="col-lg-8">
                <div class="page-header-title">
                    <i class="ik ik-edit bg-blue"></i>
                    <div class="d-inline">
                        <h5><?php echo e(__('Data Entry Operator Form')); ?></h5>
                    </div>
                </div>
            </div>
            <div class="col-lg-4">
                <nav class="breadcrumb-container" aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item">
                            <a href="<?php echo e(route('dashboard')); ?>"><i class="ik ik-home"></i></a>
                        </li>
                        <li class="breadcrumb-item"><a href="#"><?php echo e(__('Forms')); ?></a></li>
                    </ol>
                </nav>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-7 mx-auto">
            <div class="card">
                <div class="card-header"><h3><?php echo e(__('Data Entry Operator Form')); ?></h3></div>
                <div class="card-body">
                    <form class="forms-sample"  method='POST' <?php if(!empty($showdata)): ?> action="<?php echo e(url('updatedeoinput')); ?>" <?php else: ?> action="<?php echo e(url('insertdeoinput')); ?>" <?php endif; ?> name='patientregister'>
                        <?php echo csrf_field(); ?>
                        
                        <?php if(!empty($showdata)): ?>
                        <input type='hidden' name='id' value='<?php echo e($showdata[0]->id); ?>'>
                        <?php endif; ?>

                        <div class="form-group">
                            <label for="date"><?php echo e(__('1. Employee Code')); ?></label>
                            <input type="text" class="form-control" id="emp_code" name='emp_code' value='<?php echo e(auth()->user()->emp_code); ?>' placeholder="Enter Staff code" readonly>
                        </div>
                        <div class="form-group">
                            <label for="date"><?php echo e(__('2. Employee Name')); ?></label>
                            <input type="text" class="form-control" id="emp_name" name='emp_name' value='<?php echo e(auth()->user()->name); ?>' placeholder="Enter Employee Name" readonly>
                        </div>

                        <div class="form-group">
                            <label for="date"><?php echo e(__('3. Date')); ?></label>
                            <div class='input-group date datetimepicker'>
                                <input type='text' id='date' <?php if(!empty($showdata)): ?> value='<?php echo e($showdata[0]->date); ?>' <?php else: ?> value="<?php echo e(date('d-m-Y')); ?>" <?php endif; ?> class="form-control" name="date" placeholder="dd-mm-yyyy" required/>
                                <span class="input-group-addon">
                                  <span class="glyphicon glyphicon-calendar"></span>
                                </span>
                            </div>
                            <span style="color: red;display: none;" id="deo_error">Date of Entry Already Submitted</span>
                        </div>
                        <div class="form-group">
                            <label for="day"><?php echo e(__('4. Day')); ?></label>
                            <select name='day' id='day' class='form-control' required>
                                <option value="">Select Day</option>
                                <option value="Sunday" <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->day == "Sunday" ? 'selected' : ''); ?> <?php endif; ?>>Sunday</option>
                                <option value="Monday" <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->day == "Monday" ? 'selected' : ''); ?> <?php endif; ?>>Monday</option>
                                <option value="Tuesday" <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->day == "Tuesday" ? 'selected' : ''); ?> <?php endif; ?>>Tuesday</option>
                                <option value="Wednesday" <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->day == "Wednesday" ? 'selected' : ''); ?> <?php endif; ?>>Wednesday</option>
                                <option value="Thursday" <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->day == "Thursday" ? 'selected' : ''); ?> <?php endif; ?>>Thursday</option>
                                <option value="Friday" <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->day == "Friday" ? 'selected' : ''); ?> <?php endif; ?>>Friday</option>
                                <option value="Saturday" <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->day == "Saturday" ? 'selected' : ''); ?> <?php endif; ?>>Saturday</option>
                            </select>
                        </div>

                        <input type="hidden" class="form-control" id="state_code" name='state_code' <?php if(!empty($showdata)){ ?> value='<?php echo e($showdata[0]->state_code); ?>' <?php } else{?> value='<?php echo e(auth()->user()->state_code); ?>'<?php } ?> placeholder="Enter State code" readonly>
                        <input type="hidden" class="form-control" id="dist_code" name='dist_code' <?php if(!empty($showdata)){ ?> value='<?php echo e($showdata[0]->dist_code); ?>' <?php } else{?> value='<?php echo e(auth()->user()->dist_code); ?>'<?php } ?> placeholder="Enter District code" readonly>
                        <input type="hidden" class="form-control" id="art_centre_code" name='art_centre_code' <?php if(!empty($showdata)){ ?> value='<?php echo e($showdata[0]->art_centre_code); ?>' <?php } else{?> value='<?php echo e(auth()->user()->art_centre_code); ?>'<?php } ?> placeholder="Enter Staff code" readonly>

                        <table border="1" width="100%" style="border: 1px solid #ccc;" class="mb-5 mt-5">
                            <tr>
                                <td width="50%" style="padding: 5px 10px;">
                                    <label for="vl_entry" class="mb-0"><?php echo e(__('5. Viral Load Entry')); ?></label>
                                </td>
                                <td width="50%" style="padding: 5px 10px;">
                                    <input type='radio' value="Yes" name="vl_entry" required  <?php if(!empty($showdata)): ?><?php echo e(($showdata[0]->vl_entry == 'Yes')? "checked" : ""); ?> <?php endif; ?>><span class="pl-5 pr-10">Yes</span>
                                    <input type='radio' value="No" name="vl_entry"  <?php if(!empty($showdata)): ?><?php echo e(($showdata[0]->vl_entry == 'No')? "checked" : ""); ?> <?php endif; ?>><span class="pl-5 pr-10">No</span>
                                </td>
                            </tr>
                            <tr>
                                <td width="50%" style="padding: 5px 10px;">
                                    <label for="cd4_entry" class="mb-0"><?php echo e(__('6. CD4 Entry')); ?></label>
                                </td>
                                <td width="50%" style="padding: 5px 10px;">
                                    <input type='radio' value="Yes" name="cd4_entry" required  <?php if(!empty($showdata)): ?><?php echo e(($showdata[0]->cd4_entry == 'Yes')? "checked" : ""); ?> <?php endif; ?>><span class="pl-5 pr-10">Yes</span>
                                    <input type='radio' value="No" name="cd4_entry"  <?php if(!empty($showdata)): ?><?php echo e(($showdata[0]->cd4_entry == 'No')? "checked" : ""); ?> <?php endif; ?>><span class="pl-5 pr-10">No</span>
                                </td>
                            </tr>
                            <tr>
                                <td width="50%" style="padding: 5px 10px;">
                                    <label for="ipt_entry" class="mb-0"><?php echo e(__('7. IPT Entry')); ?></label>
                                </td>
                                <td width="50%" style="padding: 5px 10px;">
                                    <input type='radio' value="Yes" name="ipt_entry" required  <?php if(!empty($showdata)): ?><?php echo e(($showdata[0]->ipt_entry == 'Yes')? "checked" : ""); ?> <?php endif; ?>><span class="pl-5 pr-10">Yes</span>
                                    <input type='radio' value="No" name="ipt_entry"  <?php if(!empty($showdata)): ?><?php echo e(($showdata[0]->ipt_entry == 'No')? "checked" : ""); ?> <?php endif; ?>><span class="pl-5 pr-10">No</span>
                                </td>
                            </tr>
                            <tr>
                                <td width="50%" style="padding: 5px 10px;">
                                    <label for="white_cards_entry" class="mb-0"><?php echo e(__('8. White Cards Entry')); ?></label>
                                </td>
                                <td width="50%" style="padding: 5px 10px;">
                                    <input type='radio' value="Yes" name="white_cards_entry" required  <?php if(!empty($showdata)): ?><?php echo e(($showdata[0]->white_cards_entry == 'Yes')? "checked" : ""); ?> <?php endif; ?>><span class="pl-5 pr-10">Yes</span>
                                    <input type='radio' value="No" name="white_cards_entry"  <?php if(!empty($showdata)): ?><?php echo e(($showdata[0]->white_cards_entry == 'No')? "checked" : ""); ?> <?php endif; ?>><span class="pl-5 pr-10">No</span>
                                </td>
                            </tr>
                            <tr>
                                <td width="50%" style="padding: 5px 10px;">
                                    <label for="pals_entry" class="mb-0"><?php echo e(__('9. PALS Entry')); ?></label>
                                </td>
                                <td width="50%" style="padding: 5px 10px;">
                                    <input type='radio' value="Yes" name="pals_entry" required  <?php if(!empty($showdata)): ?><?php echo e(($showdata[0]->pals_entry == 'Yes')? "checked" : ""); ?> <?php endif; ?>><span class="pl-5 pr-10">Yes</span>
                                    <input type='radio' value="No" name="pals_entry"  <?php if(!empty($showdata)): ?><?php echo e(($showdata[0]->pals_entry == 'No')? "checked" : ""); ?> <?php endif; ?>><span class="pl-5 pr-10">No</span>
                                </td>
                            </tr>
                            <tr>
                                <td width="50%" style="padding: 5px 10px;">
                                    <label for="soch_entry" class="mb-0"><?php echo e(__('10. SOCH Entry')); ?></label>
                                </td>
                                <td width="50%" style="padding: 5px 10px;">
                                    <input type='radio' value="Yes" name="soch_entry" required  <?php if(!empty($showdata)): ?><?php echo e(($showdata[0]->soch_entry == 'Yes')? "checked" : ""); ?> <?php endif; ?>><span class="pl-5 pr-10">Yes</span>
                                    <input type='radio' value="No" name="soch_entry"  <?php if(!empty($showdata)): ?><?php echo e(($showdata[0]->soch_entry == 'No')? "checked" : ""); ?> <?php endif; ?>><span class="pl-5 pr-10">No</span>
                                </td>
                            </tr>
                            <tr>
                                <td width="50%" style="padding: 5px 10px;">
                                    <label for="mll_entry" class="mb-0"><?php echo e(__('11. MLL Entry')); ?></label>
                                </td>
                                <td width="50%" style="padding: 5px 10px;">
                                    <input type='radio' value="Yes" name="mll_entry" required  <?php if(!empty($showdata)): ?><?php echo e(($showdata[0]->mll_entry == 'Yes')? "checked" : ""); ?> <?php endif; ?>><span class="pl-5 pr-10">Yes</span>
                                    <input type='radio' value="No" name="mll_entry"  <?php if(!empty($showdata)): ?><?php echo e(($showdata[0]->mll_entry == 'No')? "checked" : ""); ?> <?php endif; ?>><span class="pl-5 pr-10">No</span>
                                </td>
                            </tr>
                            <tr>
                                <td width="50%" style="padding: 5px 10px;">
                                    <label for="disp_entry" class="mb-0"><?php echo e(__('12. Dispassion Entry')); ?></label>
                                </td>
                                <td width="50%" style="padding: 5px 10px;">
                                    <input type='radio' value="Yes" name="disp_entry" required  <?php if(!empty($showdata)): ?><?php echo e(($showdata[0]->disp_entry == 'Yes')? "checked" : ""); ?> <?php endif; ?>><span class="pl-5 pr-10">Yes</span>
                                    <input type='radio' value="No" name="disp_entry"  <?php if(!empty($showdata)): ?><?php echo e(($showdata[0]->disp_entry == 'No')? "checked" : ""); ?> <?php endif; ?>><span class="pl-5 pr-10">No</span>
                                </td>
                            </tr>
                            <tr>
                                <td width="50%" style="padding: 5px 10px;">
                                    <label for="other_work" class="mb-0"><?php echo e(__('13. Other Work')); ?></label>
                                </td>
                                <td width="50%" style="padding: 5px 10px;">
                                    <input type='radio' value="Yes" name="other_work" required  <?php if(!empty($showdata)): ?><?php echo e(($showdata[0]->other_work == 'Yes')? "checked" : ""); ?> <?php endif; ?>><span class="pl-5 pr-10">Yes</span>
                                    <input type='radio' value="No" name="other_work"  <?php if(!empty($showdata)): ?><?php echo e(($showdata[0]->other_work == 'No')? "checked" : ""); ?> <?php endif; ?>><span class="pl-5 pr-10">No</span>
                                </td>
                            </tr>
                            <tr style="width: 100%">
                                <td width="50%" style="padding: 5px 10px;" id="td_1">
                                    <label for="specify_other_work" class="mb-0"><?php echo e(__('14. Specify Other')); ?></label>
                                </td>
                                <td width="50%" style="padding: 5px 10px;" id="td_2">
                                    <input type="text" class="form-control" id="specify_other_work" name='specify_other_work' <?php if(!empty($showdata)){ ?> value='<?php echo e($showdata[0]->specify_other_work); ?>' <?php } ?> placeholder="Enter Specify Other Work">
                                </td>
                            </tr>
                        </table>
                        <br><br>
                        <button type="submit" id="submit" class="btn btn-primary mr-2"><?php echo e(__('Submit')); ?></button>
                        <?php if(empty($showdata)): ?>
                        <a href="<?php echo e('deo-input-data'); ?>" class="btn btn-light"><?php echo e(__('Cancel')); ?></a>
                        <?php endif; ?>
                      </form>
                </div>
            </div>
        </div>
    </div>
</div>
    
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/js/bootstrap-datetimepicker.min.js"></script>
<script>  
    $(function() {  
        var default_date=  new Date();
        $('.datetimepicker').datetimepicker({  
           format: 'DD-MM-YYYY', 
            useCurrent:false, 
            defaultDate: default_date
        });

        var other_work = $('input[name="other_work"]:checked').val();
        if(other_work == "Yes")
        {
            $("#td_1").show();
            $("#td_2").show();
        }
        else
        {
            $("#td_1").hide();
            $("#td_2").hide();
        }

    });  

    function isNumber(evt)
    {
        evt = (evt) ? evt : window.event;
        var charCode = (evt.which) ? evt.which : evt.keyCode;
        if (charCode > 31 && (charCode < 48 || charCode > 57)) {
            return false;
        }
        return true; 
    }

    $("#date").blur(function() {
        var selectedDate = $('#date').val(); 

        $.ajax({
            type: "POST",
            url: "<?php echo e(url('checkdeodate')); ?>",
            data: {date:selectedDate, _token: '<?php echo e(csrf_token()); ?>' },
            dataType: "json",
            success: function(res) { 
                var count = res.showdata;
                if(count > 0)
                {
                    $('#deo_error').css('display', 'block');
                    $('#submit').prop('disabled', true);
                }
                else
                {
                    $('#deo_error').css('display', 'none');
                    $('#submit').prop('disabled', false);
                }
            },
            error: function (jqXHR, exception) {

            }
        });
        console.log('ok');
        var datearray = selectedDate.split("-");
        var selectedDate = new Date(datearray[2], datearray[1], datearray[0]);
        var d = new Date(selectedDate);
        var day = d.getDay(); 
        var dayno = day;

        if(dayno == 2){
            dayname = "Sunday";
        }
        else if(dayno == 3){
            dayname = "Monday";
        }
        else if(dayno == 4){
            dayname = "Tuesday";
        }
        else if(dayno == 5){
            dayname = "Wednesday";
        }
        else if(dayno == 6){
            dayname = "Thursday";
        }
        else if(dayno == 0){
            dayname = "Friday";
        }
        else if(dayno == 1){
            dayname = "Saturday";
        }
        
        $("#day").val(dayname).change();
    });

    $( "#pat_uid" ).change(function() { 
        var pat_uid = $(this).val();
        $.ajax({
            type: "POST",
            url: "<?php echo e(url('checkpatdata')); ?>",
            data: {pat_uid:pat_uid, _token: '<?php echo e(csrf_token()); ?>' },
            dataType: "json",
            success: function(res) { 
                console.log(res);
                var art_centre = res.showdata.art_centre;
                var art_centre_name = res.showdata.art_centre_name;
                var pre_art_reg_num = res.showdata.pre_art_reg_num;
                var art_reg_num = res.showdata.art_reg_num;
                var pat_name = res.showdata.pat_name;
                var pat_age = res.showdata.pat_age;
                var pat_sex = res.showdata.pat_sex;
                $('#art_centre').val(art_centre);
                $('#art_centre_name').val(art_centre_name);
                $('#pre_art_reg_num').val(pre_art_reg_num);
                $('#art_reg_num').val(art_reg_num);
                $('#pat_name').val(pat_name);
                $('#pat_age').val(pat_age);
                $('#pat_sex').val(pat_sex);
            },
            error: function (jqXHR, exception) {

            }
        });
    });

    $('input[type=radio][name=other_work]').change(function() { 
        var other_work = $(this).val();
        if(other_work == "Yes")
        {
            $("#td_1").show();
            $("#td_2").show();
        }
        else
        {
            
            $("#td_1").hide();
            $("#td_2").hide();
        }
    });
</script>
<?php $__env->startPush('script'); ?>
    <script src="<?php echo e(asset('js/form-components.js')); ?>"></script>
<?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/virutha/treatbuddy.virutha.xyz/resources/views/pages/deo-input.blade.php ENDPATH**/ ?>