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

<div class="card">
    <div class="card-header">
        <h4 class="mb-0">Start UP And Commissioning Report</h4>
    </div>

    <div class="card-body">
        <form method="POST" action="<?php echo e(route("admin.commission-datas.update", [$commissionData->id])); ?>" enctype="multipart/form-data">
            <?php echo method_field('PUT'); ?>
            <?php echo csrf_field(); ?>
            <input type="hidden" name="commission_id" id="commission_id" value=<?php echo e($commissionData->commission_id); ?>>
            <input type="hidden" name="commission_category_name_id" id="commission_category_name_id" value="6">


            <div class="container px-0">
            <?php $__currentLoopData = $commission_types; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $id => $entry): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <?php echo e($id); ?>

            <?php if($id != 608): ?>
                <div class="mb-4">
                    <div class="card shadow-sm mb-3">
                        <div class="card-header bg-light">

                            <h5 class="mb-0 fw-bold"><?php echo e($entry); ?></h5>

                        </div>
                    </div>
            <?php endif; ?>
                    <input type="hidden" name="commission_type_id" id="commission_type_id" value="<?php echo e($id); ?>">
                    <input type="hidden" name="commission_type_id_<?php echo e($id); ?>" id="commission_type_id_<?php echo e($id); ?>" value="<?php echo e($id); ?>">

                    <?php if($id == 539): ?>
                    <div class="mb-3">
                        <div class="card">
                            <div class="card-body pb-0">
                                <div class="row">
                                    <div class="col-lg-3" style="background-color: #d9534f; padding: 10px; border-radius: 5px; margin-bottom: 5px; color: white;">
                                        <div class="form-floating">
                                            <input class="form-control <?php echo e($errors->has('commission_value') ? 'is-invalid' : ''); ?>" type="text"
                                                name="commission_value_<?php echo e($id); ?>" id="commission_value_<?php echo e($id); ?>"
                                                <?php $__currentLoopData = $existing_val; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <?php if($key['commission_type_id'] == $id): ?>
                                                        value="<?php echo e($key['commission_value']); ?>"
                                                    <?php endif; ?>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            >Compressor Run Hrs
                                        </div>
                                    </div>
                                    <div class="col-lg-3" style="background-color: #5bc0de; padding: 10px; border-radius: 5px; margin-bottom: 5px;">
                                        <div class="form-floating">
                                            <input class="form-control <?php echo e($errors->has('commission_value') ? 'is-invalid' : ''); ?>" type="text"
                                                name="commission_value_text_1_<?php echo e($id); ?>" id="commission_value_text_1_<?php echo e($id); ?>"
                                                <?php $__currentLoopData = $existing_val; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <?php echo e($existing_val); ?>

                                                    <?php if($key['commission_type_id'] == $id): ?>
                                                        value="<?php echo e($key['commission_value_text_1']); ?>"
                                                    <?php endif; ?>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            >Dryer Run Hrs
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php endif; ?>
                        <!-- 2 Box Load Hrs. compressor Air Dryer -->
                    <?php if($id == 540): ?>
                    <div class="mb-3">
                        <div class="card">
                            <div class="card-body pb-0">
                                <div class="row">
                                    <div class="col-lg-3" style="background-color: #d9534f; padding: 10px; border-radius: 5px; margin-bottom: 5px; color: white;">
                                        <div class="form-floating">
                                            <input class="form-control <?php echo e($errors->has('commission_value') ? 'is-invalid' : ''); ?>" type="text"
                                                name="commission_value_<?php echo e($id); ?>" id="commission_value_<?php echo e($id); ?>"
                                                <?php $__currentLoopData = $existing_val; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <?php if($key['commission_type_id'] == $id): ?>
                                                        value="<?php echo e($key['commission_value']); ?>"
                                                    <?php endif; ?>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                placeholder="Compressor Run Hrs"
                                            >Compressor Load Hrs
                                        </div>
                                    </div>
                                    <div class="col-lg-3" style="background-color: #5bc0de; padding: 10px; border-radius: 5px; margin-bottom: 5px;">
                                        <div class="form-floating">
                                            <input class="form-control <?php echo e($errors->has('commission_value') ? 'is-invalid' : ''); ?>" type="text"
                                                name="commission_value_text_1_<?php echo e($id); ?>" id="commission_value_text_1_<?php echo e($id); ?>"
                                                <?php $__currentLoopData = $existing_val; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <?php echo e($existing_val); ?>

                                                    <?php if($key['commission_type_id'] == $id): ?>
                                                        value="<?php echo e($key['commission_value_text_1']); ?>"
                                                    <?php endif; ?>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            >Dryer Load Hrs
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php endif; ?>

                    <!-- 4 Boxs -->
                    <?php if($id == 553 || $id == 554 || $id == 567 || $id == 568 || $id == 555): ?>
                    <div class="mb-3">
                        <div class="card">
                            <div class="card-body pb-0">
                                <div class="row">
                                    <div class="col-lg-3" style="background-color: #d9534f; padding: 10px; border-radius: 5px; margin-bottom: 5px; color: white;">
                                        <div class="form-floating">
                                            <input class="form-control <?php echo e($errors->has('commission_value') ? 'is-invalid' : ''); ?>" type="text"
                                                name="commission_value_<?php echo e($id); ?>" id="commission_value_<?php echo e($id); ?>"
                                                <?php $__currentLoopData = $existing_val; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <?php if($key['commission_type_id'] == $id): ?>
                                                        value="<?php echo e($key['commission_value']); ?>"
                                                    <?php endif; ?>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            >
                                        </div>
                                    </div>
                                    <div class="col-lg-3" style="background-color: #5bc0de; padding: 10px; border-radius: 5px; margin-bottom: 5px;">
                                        <div class="form-floating">
                                            <input class="form-control <?php echo e($errors->has('commission_value') ? 'is-invalid' : ''); ?>" type="text"
                                                name="commission_value_text_1_<?php echo e($id); ?>" id="commission_value_text_1_<?php echo e($id); ?>"
                                                <?php $__currentLoopData = $existing_val; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <?php echo e($existing_val); ?>

                                                    <?php if($key['commission_type_id'] == $id): ?>
                                                        value="<?php echo e($key['commission_value_text_1']); ?>"
                                                    <?php endif; ?>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            >
                                        </div>
                                    </div>
                                    <div class="col-lg-3" style="background-color: #5cb85c; padding: 10px; border-radius: 5px; margin-bottom: 5px;">
                                        <div class="form-floating">
                                            <input class="form-control" type="text"
                                                name="commission_value_text_2_<?php echo e($id); ?>" id="commission_value_text_2_<?php echo e($id); ?>"
                                                <?php $__currentLoopData = $existing_val; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <?php if($key['commission_type_id'] == $id): ?>
                                                        value="<?php echo e($key['commission_value_text_2']); ?>"
                                                    <?php endif; ?>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            >
                                        </div>
                                    </div>
                                    <div class="col-lg-3" style="background-color: #ceec0c; padding: 10px; border-radius: 5px; margin-bottom: 5px;">
                                        <div class="form-floating">
                                            <input class="form-control" type="text"
                                                name="commission_value_text_3_<?php echo e($id); ?>" id="commission_value_text_3_<?php echo e($id); ?>"
                                                <?php $__currentLoopData = $existing_val; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <?php if($key['commission_type_id'] == $id): ?>
                                                        value="<?php echo e($key['commission_value_text_3']); ?>"
                                                    <?php endif; ?>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            >
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php endif; ?>

            <!-- 1 Boxs -->
            <?php if(($id < 582) && $id != 542 && $id != 543 && $id != 576 &&
                 $id != 546 && $id != 547 && $id != 548 && $id != 549 &&
                 $id != 550 && $id != 551 && $id != 608 && $id != 545 &&
                 $id != 539 && $id != 540 && $id != 553 && $id != 554 &&
                 $id != 567 && $id != 568 && $id != 555
                 ): ?>

                 <div class="mb-3">
                    <div class="card">
                        <div class="card-body pb-0">
                            <div class="row">
                                <div class="col-lg-4" style="background-color: #d9534f; padding: 10px; border-radius: 5px; margin-bottom: 5px; color: white;">
                                    <div class="form-floating">
                                        <input class="form-control <?php echo e($errors->has('commission_value') ? 'is-invalid' : ''); ?>" type="text"
                                            name="commission_value_<?php echo e($id); ?>" id="commission_value_<?php echo e($id); ?>"
                                            <?php $__currentLoopData = $existing_val; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <?php if($key['commission_type_id'] == $id): ?>
                                                    value="<?php echo e($key['commission_value']); ?>"
                                                <?php endif; ?>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        >
                                        <label for="commission_value_<?php echo e($id); ?>">Value</label>
                                    </div>
                                </div>

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





            <!-- Location -->
                <?php if($id == 542): ?>
                <div class="mb-3">
                    <div class="card">
                        <div class="card-body pb-0">
                            <div class="row">
                                <div class="col-12 mb-3">
                                    <div class="btn-group w-100" role="group">
                                        <?php
                                            $indoorActive = false;
                                            $outdoorActive = false;

                                            foreach ($existing_val as $key) {
                                                if($key['commission_type_id'] == $id) {
                                                    if($key['commission_value'] == 'Indoor') $indoorActive = true;
                                                    if($key['commission_value'] == 'Outdoor') $outdoorActive = true;
                                                }
                                            }
                                        ?>

                                        <button type="button" class="btn <?php echo e($indoorActive ? 'btn-primary' : 'btn-outline-primary'); ?>"
                                                onclick="setCommissionValue('<?php echo e($id); ?>', 'Indoor')">Indoor</button>

                                        <button type="button" class="btn <?php echo e($outdoorActive ? 'btn-success' : 'btn-outline-success'); ?>"
                                                onclick="setCommissionValue('<?php echo e($id); ?>', 'Outdoor')">Outdoor</button>

                                        <input type="hidden" id="commission_value_input_<?php echo e($id); ?>" name="commission_value_<?php echo e($id); ?>"
                                               value="<?php echo e($indoorActive ? 'Indoor' : ($outdoorActive ? 'Outdoor' : '')); ?>">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <?php endif; ?>

                <!-- Environment-->
                <?php if($id == 543): ?>
                <div class="mb-3">
                    <div class="card">
                        <div class="card-body pb-0">
                            <div class="row">
                                <div class="col-12 mb-3">
                                    <div class="btn-group w-100" role="group">
                                        <?php
                                            $cleanActive = false;
                                            $averageActive = false;
                                            $dustyActive = false;

                                            foreach ($existing_val as $key) {
                                                if($key['commission_type_id'] == $id) {
                                                    if($key['commission_value'] == 'Clean') $cleanActive = true;
                                                    if($key['commission_value'] == 'Average') $averageActive = true;
                                                    if($key['commission_value'] == 'Dusty') $dustyActive = true;
                                                }
                                            }
                                        ?>

                                        <button type="button" class="btn <?php echo e($cleanActive ? 'btn-success' : 'btn-outline-success'); ?>"
                                                onclick="setCommissionValue('<?php echo e($id); ?>', 'Clean')">Clean</button>

                                        <button type="button" class="btn <?php echo e($averageActive ? 'btn-warning' : 'btn-outline-warning'); ?>"
                                                onclick="setCommissionValue('<?php echo e($id); ?>', 'Average')">Average</button>

                                        <button type="button" class="btn <?php echo e($dustyActive ? 'btn-danger' : 'btn-outline-danger'); ?>"
                                                onclick="setCommissionValue('<?php echo e($id); ?>', 'Dusty')">Dusty</button>

                                        <input type="hidden" id="commission_value_input_<?php echo e($id); ?>" name="commission_value_<?php echo e($id); ?>"
                                               value="<?php echo e($cleanActive ? 'Clean' : ($averageActive ? 'Average' : ($dustyActive ? 'Dusty' : ''))); ?>">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <?php endif; ?>

                <!-- Room Ventilation -->
                <?php if($id == 545): ?>
                <div class="mb-3">
                    <div class="card">
                        <div class="card-body pb-0">
                            <div class="row">
                                <div class="col-12 mb-3">
                                    <div class="btn-group w-100" role="group">
                                        <?php
                                            $goodActive = false;
                                            $averageActive = false;
                                            $poorActive = false;

                                            foreach ($existing_val as $key) {
                                                if($key['commission_type_id'] == $id) {
                                                    if($key['commission_value'] == 'Good') $goodActive = true;
                                                    if($key['commission_value'] == 'Average') $averageActive = true;
                                                    if($key['commission_value'] == 'Poor') $poorActive = true;
                                                }
                                            }
                                        ?>

                                        <button type="button" class="btn <?php echo e($goodActive ? 'btn-primary' : 'btn-outline-primary'); ?>"
                                                onclick="setCommissionValue('<?php echo e($id); ?>', 'Good')">Good</button>

                                        <button type="button" class="btn <?php echo e($averageActive ? 'btn-warning' : 'btn-outline-warning'); ?>"
                                                onclick="setCommissionValue('<?php echo e($id); ?>', 'Average')">Average</button>

                                        <button type="button" class="btn <?php echo e($poorActive ? 'btn-danger' : 'btn-outline-danger'); ?>"
                                                onclick="setCommissionValue('<?php echo e($id); ?>', 'Poor')">Poor</button>

                                        <input type="hidden" id="commission_value_input_<?php echo e($id); ?>" name="commission_value_<?php echo e($id); ?>"
                                               value="<?php echo e($goodActive ? 'Good' : ($averageActive ? 'Average' : ($poorActive ? 'Poor' : ''))); ?>">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <?php endif; ?>
                <!-- Radio Buttons -->
                <?php if(($id > 582 && $id < 602) || ($id > 545 && $id < 552) || $id == 576): ?>

                <div class="row mb-3">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
                                <div class="btn-group w-100" role="group">
                                    <?php
                                        $yesActive = false;
                                        $noActive = false;
                                        $okActive = false;

                                        foreach ($existing_val as $key) {
                                            if($key['commission_type_id'] == $id) {
                                                if($key['commission_value'] == 'Yes') $yesActive = true;
                                                if($key['commission_value'] == 'No') $noActive = true;
                                                if($key['commission_value'] == 'Ok') $okActive = true;
                                            }
                                        }
                                    ?>

                                    <button type="button" class="btn <?php echo e($yesActive ? 'btn-success' : 'btn-secondary'); ?>"
                                            onclick="setCommissionValue('<?php echo e($id); ?>', 'Yes')">Yes</button>

                                    <button type="button" class="btn <?php echo e($noActive ? 'btn-danger' : 'btn-secondary'); ?>"
                                            onclick="setCommissionValue('<?php echo e($id); ?>', 'No')">No</button>

                                    <button type="button" class="btn <?php echo e($okActive ? 'btn-primary' : 'btn-secondary'); ?>"
                                            onclick="setCommissionValue('<?php echo e($id); ?>', 'Ok')">Ok</button>

                                    <input type="hidden" id="commission_value_input_<?php echo e($id); ?>" name="commission_value_<?php echo e($id); ?>"
                                           value="<?php echo e($yesActive ? 'Yes' : ($noActive ? 'No' : ($okActive ? 'Ok' : ''))); ?>">
                                </div>

                        </div>
                    </div>
                </div>
                <input type="hidden" name="commission_value_text_1_<?php echo e($id); ?>">
                <input type="hidden" name="commission_value_text_2_<?php echo e($id); ?>">
                <input type="hidden" name="commission_value_text_3_<?php echo e($id); ?>">
                <?php endif; ?>
                </div>
                <!-- end entry div -->

                <!-- From 602 Checklists -->
                <?php if(($id >= 602 && $id < 608)): ?>
                <div class="mb-3">
                   <div class="card">
                       <div class="card-body pb-0">
                           <div class="row">
                            <div class="col-lg-4" style="background-color: #d9534f; padding: 10px; border-radius: 5px; margin-bottom: 5px; color: white;">
                                <div class="form-floating">
                                       <input class="form-control <?php echo e($errors->has('commission_value') ? 'is-invalid' : ''); ?>" type="text"
                                           name="commission_value_<?php echo e($id); ?>" id="commission_value_<?php echo e($id); ?>"
                                           <?php $__currentLoopData = $existing_val; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                               <?php if($key['commission_type_id'] == $id): ?>
                                                   value="<?php echo e($key['commission_value']); ?>"
                                               <?php endif; ?>
                                           <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                       >
                                   </div>
                               </div>

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

               <!-- From Signature Checklists -->

<!-- Signature Block -->
    <?php if($id == 608): ?>
<!-- Signature Block -->
    <div class="form-group" style="background-color: #efefef; margin-top:10px;">
<h3> Customer Signature</h3>
<div style="text-align:center;background-color:yellow;">
<script src="https://cdn.jsdelivr.net/npm/signature_pad@4.1.7/dist/signature_pad.umd.min.js"></script>
<canvas id="signature-pad" class="signature-pad"></canvas>
</div>
<input type="button" value="Clear Sign" onclick="javascript: clearsign();"/>
</div>
<!-- Signature Block -->
<?php endif; ?>
<!-- Signature Block -->

               <!-- From Signature Checklists -->


                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div><!-- end container -->
        </div><!-- end card-body -->


            <div class="row mt-4 mb-4">
                <div class="col-12">
                    <div class="card card-body">
                        <div class="d-grid gap-3">
                            <button id='save' class="btn btn-danger btn-lg  btn-block py-3" type="submit">
                                <?php echo e(trans('global.save')); ?>

                            </button>
                            <a href="/admin/assets/<?php echo e($commissionData->commission_id); ?>" class="btn btn-primary   btn-block btn-lg py-3">
                                Back to Commissioning
                            </a>
                        </div>
                    </div>
                </div>
            </div>

        </form>
    </div>
</div>

<?php $__env->startSection('scripts'); ?>
<script>
// Signature Block
var signaturePad = new SignaturePad(document.getElementById('signature-pad'), {
  backgroundColor: 'rgba(200, 200, 255, 0)',
  penColor: 'rgb(0, 0, 0)'
});
//Need this save button to get the signature value
//else the signature will not be POSTED to controller
var saveButton = document.getElementById('save');
var cancelButton = document.getElementById('clear');

saveButton.addEventListener('click', function (event) {
  var data = signaturePad.toDataURL('image/svg+xml');
  //signaturePad.toDataURL('image/png');
  // Send data to server instead...
  //window.open(data);
  //alert(data);

  //Sending client signature to Commissoin Datas - Commission_Customer_Signature id:608
  // Ensure the signature is properly added to the form
  // Check if an existing input exists and remove it to prevent duplicates
  $('#client_signature').remove();

  // Create and append the signature data to the form
  $('<input>', {
    type: 'hidden',
    id: 'client_signature',
    name: 'client_signature',
    value: data
  }).appendTo('form');

  // Log to console to verify the signature is being captured
  console.log('Signature captured and added to form');

});

cancelButton.addEventListener('click', function (event) {
  signaturePad.clear();
});

function clearsign(){
    signaturePad.clear();
}

function resizeCanvas() {
    const ratio =  Math.max(window.devicePixelRatio || 1, 1);
    canvas.width = canvas.offsetWidth * ratio;
    canvas.height = canvas.offsetHeight * ratio;
    canvas.getContext("2d").scale(ratio, ratio);
    signaturePad.clear(); // otherwise isEmpty() might return incorrect value
}
// Signature Block

//Toogle Buttons

function setCommissionValue(id, value) {
                                        // Set the hidden input value
                                        document.getElementById('commission_value_input_' + id).value = value;

                                        // Update button styles
                                        const btnGroup = event.target.parentElement;
                                        const buttons = btnGroup.querySelectorAll('button');

                                        buttons.forEach(btn => {
                                            if (btn.textContent === 'Yes') {
                                                btn.className = value === 'Yes' ? 'btn btn-success' : 'btn btn-outline-success';
                                            } else if (btn.textContent === 'No') {
                                                btn.className = value === 'No' ? 'btn btn-danger' : 'btn btn-outline-danger';
                                            } else if (btn.textContent === 'Ok') {
                                                btn.className = value === 'Ok' ? 'btn btn-primary' : 'btn btn-outline-primary';
                                            }
                                        });
                                    }
</script>
<?php $__env->stopSection(); ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/newrhytha2/public_html/sfm.fusionengg.in/resources/views/admin/commissionDatas/edit.blade.php ENDPATH**/ ?>