JezK
Edit File: businessConfig.php
<?php include("header.php"); if($_SESSION['signup_type']!=1){ echo "<script>window.location='dashboard.php'</script>"; } $professionals = $videocon->getProfessionalsList(); $configDet=$videocon->business_config(); if(isset($_POST['action']) && $_POST['action']=='businessrights') { $business_config=$videocon->businessConfig($_POST); if($business_config){ echo "<script>alert('Successfully Updated');window.location='businessConfig.php'</script>"; }else{ echo "<script>alert('Updation Was Failed');</script>"; } } ?> <style> div.dataTables_wrapper div.dataTables_filter { position: absolute; top: 132px; } </style> <section class="section-padding"> <div class="container m-3 bg-white"> <div class=""> <div class="calender-Right pt-4 mb-2 invisible"> <label class="fieldName mt-2 mr-2">Select Date Range</label> <div id="reportrange" class="col-xl-5 col-md-6 col-lg-8 formField-control" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc;"> <i class="fa fa-calendar float-right pt-1"></i> <span></span> </div> </div> <form method="POST" action="" name="businessConfig" id="businessConfig"> <input type="submit" name="submit" value="Submit" class="btn btn-sm btn-primary px-5"> <div class="table-responsive"> <!-- <form method="POST" action="" name="businessConfig" id="businessConfig"> --> <table id="dataTable" class="table table-striped table-borderless " style="width:100%"> <thead class="tableBackground"> <tr> <th>Sl no.</th> <th>Professional Name</th> <th>Appointments</th> <th>Profession Management</th> <th>Add Availability</th> <th>Add Profession</th> <th>Edit Profession</th> </tr> </thead> <tbody> <?php if(is_array($professionals) && count($professionals)>0){ $i=0; foreach($professionals as $k=>$v){ $i++; ?> <tr> <td><?php echo $i;?></td> <td><?php echo $v['professional_name'];?></td> <td> <label class="container1"> <input type="checkbox" name="appointments[<?php echo $v['id']?>]" class="checkmark" <?php if(isset($configDet[$v['id']]['appointments']) && $configDet[$v['id']]['appointments']==1){ echo "checked";};?> value="1"> <span class="checkmark1"></span> </label> </td> <td> <label class="container1"> <input type="checkbox" name="professional_management[<?php echo $v['id']?>]" class="checkmark" <?php if(isset($configDet[$v['id']]['professional_management']) && $configDet[$v['id']]['professional_management']==1){ echo "checked";};?> value="1"> <span class="checkmark1"></span> </label> </td> <td> <label class="container1"> <input type="checkbox" name="add_availability[<?php echo $v['id']?>]" class="checkmark" <?php if(isset($configDet[$v['id']]['add_availability']) && $configDet[$v['id']]['add_availability']==1){ echo "checked";};?> value="1"> <span class="checkmark1"></span> </label> </td> <td> <label class="container1"> <input type="checkbox" name="add_profession[<?php echo $v['id']?>]" class="checkmark" <?php if(isset($configDet[$v['id']]['add_profession']) && $configDet[$v['id']]['add_profession']==1){ echo "checked";};?> value="1"> <span class="checkmark1"></span> </label> </td> <input type="hidden" name="action" value="businessrights"> <input type="hidden" name="businessids[]" value="<?php echo $v['id'];?>"> <td> <label class="container1"> <input type="checkbox" name="edit_profession[<?php echo $v['id']?>]" class="checkmark" <?php if(isset($configDet[$v['id']]['edit_profession']) && $configDet[$v['id']]['edit_profession']==1){ echo "checked";};?> value="1"> <span class="checkmark1"></span> </label> </td> </tr> <?php }?> <!-- <input type="submit" name="submit" value="Submit" class="btn btn-sm btn-primary px-5"> --> <?php } ?> </tbody> </table> <!-- </form> --> </div> </form> </div> </div> </section> <?php include("footer.php");?> <script> document.addEventListener("DOMContentLoaded", function () { // Select all Professional Management checkboxes document.querySelectorAll("input[name^='professional_management']").forEach(pmCheckbox => { let id = pmCheckbox.name.match(/\d+/)[0]; // Extract ID of professional let addProfession = document.querySelector(`input[name='add_profession[${id}]']`); let editProfession = document.querySelector(`input[name='edit_profession[${id}]']`); function checkPermission(event) { if (!pmCheckbox.checked) { alert("Please select 'Professional Management' first."); event.preventDefault(); // Prevent checkbox from being checked } } // Add event listeners to Add/Edit Profession checkboxes addProfession.addEventListener("click", checkPermission); editProfession.addEventListener("click", checkPermission); }); }); </script>