EVOLUTION-NINJA
Edit File: edit_batch.php
<?php echo view('includes/home_sidebar');?> <style> #leftDiv{ height: 960px !important; } .add-batch-block { display: flex; justify-content: space-between; padding: 8px; border-bottom: 3px solid #8D8D8D; } .add-batch-heading { margin: 0; padding: 3px; align-self: center; color: #003352; font-size: 20px; font-weight: 600; } .back-butt { color: #606060; font-size: 21px; font-weight: 500; outline: none; border: none } .add-batch { background-color: #EFF3FC; padding: 15px 25px; } .add-batch label { padding: 5px 10px; font-size: 15px; margin-block: 4px; font-weight: 500; color: #606060; } .star-mad { color: #c83434; font-size: 20px; position: relative; top: 2px; } .inp-boxes-addbatch { border: none; box-shadow: 0px 0px 3px #ccc; background-color: white !important; } .can-sub-button { display: flex; align-items: flex-end; justify-content: center; } </style> <main id="rightDiv"> <div class="container-fluid"> <div class="row"> <div class="col-sm-12"> <!-- -------FEE STRUCTURE AND BACK BUTTON---------- --> <section class="fee-structure"> <h3 style="color: rgba(0, 72, 76, 1);">Edit Batch</h3> <button class="btn back-butt" onclick="goBack()"><i class="fa fa-arrow-left" aria-hidden="true"></i> Back</button> </section> <section> <form id="update"> <input type="hidden" name="id" value="<?php echo $id;?>" id=""> <div class="add-batch"> <div class="row"> <div class="col-sm-3"> <label for="">Header<span class="star-mad">*</span></label></br> <select class="form-select inp-boxes-addbatch" id="header" name="header" required> </select> </div> <div class="col-sm-3"> <label for="">Value<span class="star-mad">*</span></label></br> <select class="form-select inp-boxes-addbatch" id="description" name="value" required> </select> </div> <div class="col-sm-3"> <label for="">Trainer<span class="star-mad">*</span></label></br> <select class="form-select inp-boxes-addbatch" name="trainer" id="trainer" required> </select> </div> <div class="col-sm-3"> </div> </div> <div class="row"> <div class="col-sm-3"> <label for="batch-startdate">Batch Start Date <span class="star-mad">*</span></label><input type="date" placeholder="" name="start_date" value="<?php echo $start_date;?>" id="startdate" class="form-control inp-boxes-attendance" required /> </div> <div class="col-sm-3"> <label for="batch-enddate">Batch End Date<span class="star-mad">*</span></label><input type="date" placeholder="" name="end_date" value="<?php echo $end_date;?>" id="enddate" class="form-control inp-boxes-attendance" required /> </div> <div class="col-sm-3 can-sub-button"> <button type="submit" class="submit-student-form view-submit-button mx-3" id="app-btn">Update Batch</button> <!-- <button type="submit" class=" col-sm-3 submit-student-form view-submit-button mx-3" id="expense-list-cancel">Cancel</button> --> </div> <div class="col-sm-3"></div> </div> </div> </form> </section> </div> </div> </div> </main> </section> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.10.8/dist/sweetalert2.all.min.js"></script> <link href="https://cdn.jsdelivr.net/npm/sweetalert2@11.10.8/dist/sweetalert2.min.css" rel="stylesheet"> <script> $(document).ready(function () { $('#update').submit(function (e) { e.preventDefault(); var formdata = new FormData($(this)[0]); $('#app-btn').text('Updating...'); $('#app-btn').attr('disabled', 'disabled'); $.ajax({ type: 'post', url: '<?php echo base_url("update-batch-form");?>', data: formdata, contentType: false, processData: false, success: function (response) { if (response.result == 1) { Swal.fire({ icon: "success", title: response.message, showConfirmButton: false, timer: 2000 }); $('#update')[0].reset(); // $('#datatable').DataTable().ajax.reload();\ window.location.href = '<?php echo base_url("add-batch");?>'; } else { Swal.fire({ icon: "error", title: response.message, showConfirmButton: false, timer: 1000 }); } $('#app-btn').removeAttr('disabled').text("Update Batch"); }, error: function (xhr, textStatus, errorThrown) { console.error(xhr.responseText); Swal.fire({ icon: "error", title: "An error occurred", showConfirmButton: false, timer: 1000 }); }, complete: function () { $('#app-btn').removeAttr('disabled').text("Update Batch"); } }); }); }); var selectedheader='<?php echo $header; ?>'; var selectedvalue='<?php echo $value; ?>'; //course select $(document).ready(function () { $.ajax({ type: 'GET', url: '<?php echo base_url("get-header");?>', dataType: 'json', success: function (response) { if (response.result == 1) { var options = response.data; var selectElement = $('#header'); selectElement.empty(); $('#header').html('<option value="" selected >Select course</option>'); $.each(options, function (index, option) { selectElement.append($('<option>', { value: option.id, text: option.header_name })); }); selectElement.val(selectedheader).trigger('change'); } else { $('#header').html('<option value="">Course not found</option>'); } }, error: function (xhr, status, error) { console.error(xhr.responseText); } }); // Second select dropdown $('#header').change(function () { var headerId = $(this).val(); $.ajax({ type: 'GET', url: '<?php echo base_url("get-value");?>?id=' + headerId, dataType: 'json', success: function (response) { if (response.result == 1) { var options = response.data; var selectElement = $('#description'); selectElement.empty(); $('#description').html('<option value="" selected >Select value</option>'); $.each(options, function (index, option) { selectElement.append($('<option>', { value: option.id, text: option.value_name })); }); selectElement.val(selectedvalue).trigger('change'); } else { $('#description').html('<option value="">value not found</option>'); } }, error: function (xhr, status, error) { console.error(xhr.responseText); } }); }); }); var trainer_id='<?php echo $trainer;?>'; // alert(trainer_id) $(document).ready(function(){ $.ajax({ type: 'GET', url: '<?php echo base_url("get-trainer");?>', dataType: 'json', success: function (response) { if (response.result == 1) { var options = response.data; var selectElement = $('#trainer'); selectElement.empty(); $('#trainer').html('<option value="" selected >Select Trainer</option>'); $.each(options, function (index, option) { selectElement.append($('<option>', { value: option.id, text: option.first_name })); }); selectElement.val(trainer_id).trigger('change'); } else { $('#trainer').html('<option value="">Employees Not Found</option>'); } }, error: function (xhr, status, error) { console.error(xhr.responseText); } }); }) </script> <script> window.onload = function () { const leftDiv = document.getElementById('leftDiv'); const rightDiv = document.getElementById('rightDiv'); const rightDivHeight = rightDiv.offsetHeight; leftDiv.style.height = rightDivHeight + 'px'; }; </script> <!-- BACK BUTTON SCRIPT --> <script> function goBack() { window.location.href = "<?php echo base_url('add-batch');?>"; } </script> <?php echo view('includes/footer'); ?>