EVOLUTION-NINJA
Edit File: internship.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; } .view-submit-button { color: white; width: 40%; background: linear-gradient(#4E79FF, #71ACFF); border: none; outline: none; font-size: 18px; padding: 5px 4px; font-weight: 500; } .can-sub-button { display: flex; align-items: flex-end; justify-content: center; } .crud--buttons { display: grid; grid-template-columns: repeat(2, 105px); grid-auto-rows: auto; gap: 5px; } .edit--butt, .delete--butt, .add--value { font-size: 10px; font-weight: 500; background-color: #E44A24; color: #F2F6FF; padding: 3px 0px; } .add--value { background-color: #0065A3 !important; } @media screen and (max-width:728px) { .add-batch-block, .add-batch { width: 97vw; } .can-sub-button { margin-top: 15px; } .view-submit-button { color: white; width: 60%; margin-top: 15px; } } #datatable thead tr { /* background-color: #9191a1 !important; */ background-color: rgba(0, 72, 76, 1) !important; color: white; } .tb-batstd{ background-color: #B0EBB4 !important; /* color: white !important; */ } .thead-std{ background-color: #A8DF65 !important; /* color: white !important; */ } </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);">Internship</h3> <button class="btn back-butt" onclick="goBack()"><i class="fa fa-arrow-left" aria-hidden="true"></i> Back</button> </section> <section> <form id="internship"> <div class="add-batch"> <div class="row"> <div class="col-sm-3"> <label for="">Name<span class="star-mad">*</span></label></br> <input type="Text" placeholder="" name="name" id="name" class="form-control inp-boxes-attendance" required /> </div> <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" 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" id="enddate" class="form-control inp-boxes-attendance" required /> </div> <div class="col-sm-3"> </div> </div> <div class="row"> <div class="col-sm-3"> <label for="">Project<span class="star-mad">*</span></label></br> <input type="Text" placeholder="" name="project" id="project" class="form-control inp-boxes-attendance" required /> </div> <div class="col-sm-3"> </div> </div> <br><br> <div class="row"> <div class="col-sm-3 can-sub-button"> <button type="submit" class="submit-student-form view-submit-button mx-3" id="app-btn">Add Internship</button> </div> <div class="col-sm-3"> </div> </div> </form> <br> <table id="datatable" class="display" style="width:100%"> <thead> <tr> <th>SL no</th> <th>ID</th> <th>Name</th> <th>Start Date</th> <th>End Date</th> <th>Project Name</th> <th>Action</th> </tr> </thead> <tbody> </tbody> </table> <div id="resultID"></div> </div> <div class="modal fade" id="editInternModal" tabindex="-1" role="dialog" aria-labelledby="editSyllabusModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="editSyllabusModalLabel">Edit Syllabus</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <form id="editInternForm"> <div class="modal-body"> <input type="hidden" name="intern" id="intern_id"> <div class="col-sm-12"> <label for="">Name</label></br> <input type="Text" placeholder="Enter Your Name" name="name_model" id="name_model" class="form-control inp-boxes-attendance" required /> </div> <br> <div class="col-sm-12"> <label for="batch-startdate"> Start Date </label><input type="date" placeholder="" name="start_date_model" id="startdate_model" class="form-control inp-boxes-attendance" required /> </div> <br> <div class="col-sm-12"> <label for="batch-enddate"> End Date</label><input type="date" placeholder="" name="end_date_model" id="enddate_model" class="form-control inp-boxes-attendance" required /> </div> <br> <div class="col-sm-12"> <label for="">Project</label></br> <input type="Text" placeholder="Enter Project Name" name="project_model" id="project_model" class="form-control inp-boxes-attendance" required /> </div> <br> </div> <div class="modal-footer"> <button type="submit" class="btn btn-primary submit">Update</button> </div> </form> </div> </div> </div> </section> </div> </div> </div> </main> </section> </div> <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> // Application form $(document).ready(function () { $('#internship').submit(function (e) { e.preventDefault(); var formdata = new FormData($(this)[0]); $.ajax({ type: 'post', url: '<?php echo base_url("add-internship");?>', data: formdata, contentType: false, processData: false, success: function (response) { if (response.result == 1) { Swal.fire({ icon: "success", title: response.message, showConfirmButton: false, timer: 2000 }); $('#internship')[0].reset(); $('#datatable').DataTable().ajax.reload(); } else { Swal.fire({ icon: "error", title: response.message, showConfirmButton: false, timer: 1000 }); } }, error: function (xhr, textStatus, errorThrown) { console.error(xhr.responseText); Swal.fire({ icon: "error", title: "An error occurred", showConfirmButton: false, timer: 1000 }); }, complete: function () { } }); }); }); </script> <script> $(document).ready(function () { var table = $('#datatable').DataTable({ ajax: { url: '<?php echo base_url("internship-list"); ?>', dataSrc: '' }, columns: [ { data: null }, { data: 'id', visible: false }, { data: 'name' }, { data: 'start_date' }, { data: 'end_date' }, { data: 'project' }, { data: null, render: function (data, type, row) { return `<div class="crud--buttons" > <button class="btn edit--butt v-e-d" id="Edit--button" onclick='Edit(${row.id})' >Edit </button> <button class="btn delete--butt v-e-d" id="delete--button" onclick='Delete(${row.id})'>Delete </button> </div>`; } } ], rowCallback: function (row, data, index) { $('td:eq(0)', row).html(index + 1); }, language: { emptyTable: "No data available" } }); }); function Delete(id) { // console.log(id) Swal.fire({ title: "Are you sure?", text: "You won't be able to revert this!", icon: "warning", showCancelButton: true, confirmButtonColor: "#3085d6", cancelButtonColor: "#d33", confirmButtonText: "Yes, delete it!" }).then((result) => { if (result.isConfirmed) { $.ajax({ type: 'post', url: '<?php echo base_url("delete-internship");?>?id=' + id, contentType: false, processData: false, success: function (response) { if (response.result == 1) { Swal.fire({ title: "Deleted!", text: "Data has been deleted.", icon: "success", }).then(function () { $('#datatable').DataTable().ajax.reload(); }) } } }) } }); } </script> <script> function Edit(Id) { $.ajax({ url: "<?php echo base_url('edit-internship'); ?>/" + Id, type: "GET", success: function(response) { if (response.result === 1) { let data = response.data[0]; console.log(data); $('#intern_id').val(data.id); $('#name_model').val(data.name); $('#startdate_model').val(data.start_date); $('#enddate_model').val(data.end_date); $('#project_model').val(data.project); $('#editInternModal').modal('show'); } else { alert(response.message); } }, error: function(xhr, status, error) { console.error('Error fetching department data:', error); } }); } </script> <script> $(document).ready(function () { $('#editInternForm').submit(function (e) { e.preventDefault(); var formData = new FormData($(this)[0]); $.ajax({ url: "<?php echo base_url('update-intern') ?>", type: "POST", data: formData, processData: false, contentType: false, success: function (response) { if (response.result === 1) { Swal.fire({ icon: "success", title: response.message, showConfirmButton: false, timer: 2000 }); $('#editInternModal').modal('hide'); $('#datatable').DataTable().ajax.reload(null, false); } else { alert(response.message); } }, error: function (xhr, status, error) { alert('An error occurred: ' + 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> <script> function goBack() { window.location.href = 'dashboard'; } </script> <?php echo view('includes/footer'); ?>