EVOLUTION-NINJA
Edit File: project_payment_edit.php
<?php echo view('includes/sidebar'); ?> <script type="text/javascript" src="<?php echo base_url('public/assets/js/jquery-3.6.0.min.js'); ?>"></script> <script src="<?php echo base_url('public/assets/toastr/toastr.min.js');?>"></script> <link rel="stylesheet" href="<?php echo base_url('public/assets/toastr/toastr.min.css');?>"> <link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css"> <!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script> --> <script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script> <link rel="stylesheet" href="<?php echo base_url('public/assets/css/createproject.css');?>"> <link rel="stylesheet" href="<?php echo base_url('public/assets/css/font-awesome.min.css');?>"> <link rel="stylesheet" href="<?php echo base_url('public/assets/css/bootstrap.min.css');?>"> <link rel="stylesheet" href="<?php echo base_url('public/assets/css/sidebar.css');?>"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" href="<?php echo base_url('public/assets/images/constituency.png');?>"> <link rel="stylesheet" href="<?php echo base_url('public/assets/images/Logo.png');?>"> <link rel="stylesheet" href="<?php echo base_url('public/assets/images/employee.png');?>"> <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script> <section class="home-section"> <div class="home-content"> <i class='bx bx-menu'></i> <!-- <span class="text">Drop Down Sidebar</span> --> </div> <div class="row m-0"> <div class="col-sm-12"> <h1 class="crt-pjt">Project Payment</h1> </div> </div> <!-- <div class="col-sm-3">--> <!-- <form id="excel" enctype="multipart/form-data" class="excel">--> <!-- <input type="file" name="import_file" class="form-control excelFile" />--> <!-- <button type="submit" class="btn btn-primary ">Import</button>--> <!-- </form>--> <!--</div>--> <style> .inpfieldname { font-family: Poppins; font-size: 18px; font-weight: 500; text-align: left; color: #1F1F21; } .excelFile{ padding:5px !important; } .excel{ display:flex; justify-content:space-evenly; } .plus { background-color: transparent !important; padding: 2px; margin: 15px 15px; } .fieldsbox { border-radius: 23px !important; padding: 5px 10px !important; height: 45px; width: 85% } .projdetail { margin-inline: auto; margin-top: 15px; } .constuency_page { width: 100%; padding: 20px 16px; } .textfields { border-radius: 14px; } .file-list { display: flex; flex-wrap: wrap; /* Allows items to wrap to the next line if needed */ margin-top: 10px; gap: 3px } .file-item { display: flex; align-items: center; margin-right: 10px; font-size: 14px; /* Space between items */ background: #fff; /* Background color for visibility */ padding: 5px 10px; border-radius: 5px; /* Rounded corners */ } .delete-icon { margin-left: 8px; cursor: pointer; /* Show pointer on hover */ } .mul { font-size: 14px; color: red } .buttns-cnl { margin-inline: 15px !important; } @media (min-width: 768px) and (max-width: 1024px) { .inpfieldname { font-size: 15px; } .fieldsbox { border-radius: 23px !important; padding: 5px 10px !important; height: 45px; width: 100%; } } @media only screen and (max-width:620px) { .fieldsbox { width: 100% } .home-section { height: 100% } } /* ----------------------header styles */ body { margin: 0px; padding: 0px; overflow-x: hidden; } /* CSS adjustments */ @media (max-width: 767px) { .logo-mobile { margin-right: auto; /* Align logo to the left */ } .navbar-toggler { margin-left: auto; /* Align hamburger menu to the right */ } } /* Logo styling */ .logo { width: 100%; height: auto; } /* Image styling */ .header-image { width: 100%; height: auto; } /* Center the search bar */ .search-container { flex: 1; display: flex; justify-content: center; } .search-bar { max-width: 500px; width: 100%; } /* Align items on the right side */ .right-side { display: flex; align-items: center; } /* Hide elements in mobile view for header */ @media (max-width: 767px) { .desktop-only { display: none; } .header-image { width: 50% !important; height: auto; } .navbar-nav { display: grid !important; grid-template-columns: auto auto auto !important; margin-left: 11px !important; } .navbar-nav .nav-item { margin-bottom: 10px; } .navbar-toggler { margin-left: auto; } .logo-mobile { display: block; margin-bottom: 10px; text-align: center; } .search-container { margin-bottom: 10px; } } @media (min-width: 768px) { .navbar-toggler { display: none; } .navbar-brand { margin-right: auto; } .rem { width: 100% !important; } } .img-notf, .notify-number { position: absolute; } .notify-number { position: relative; left: 13px; font-size: 11px; top: -8px; } .notify-number { position: relative !important; top: -6px; left: -11px; font-size: small; border-radius: 50%; color: red; } .notify-number { position: relative; left: 14px; top: -6px; } .search-bar { border-radius: 18px !important; border: none; box-shadow: 1px 1px 6px 0px #00000040; height: 35px; } .lang { font-family: Poppins; font-size: 17px; font-weight: 600; line-height: 30px; text-align: left; position: relative; color: #464646; } .admin { font-family: Poppins; font-size: 17px; font-weight: 600; line-height: 30px; text-align: left; position: relative; color: #464646; } .lang:hover { color: #464646; } .searc-top { position: relative; top: 8px; left: -27px; font-size: 18px; } .rem { width: 70% !important; } @media only screen and (max-width: 600px) { .header-image { width: 50% !important; height: auto; } .rem { width: 100% !important; } } @media (min-width: 768px) and (max-width: 1024px) { .logo { width: 80% !important; height: auto; } .rem { width: 93% !important; } } /* --------------------only for tablets-------------------------------- */ @media (min-width: 768px) and (max-width: 1024px) {} /* --------------------only for tablets-------------------------------- */ /* ---------------- header style end */ </style> <!-- forms --> <form id="project-edit-form"> <div class="createproject"> <div class="row projdetail"> <div class="col-sm-5"> <label class="form-label inpfieldname" for="ReleaseAmount">Released Amount</label> <?php if (!empty($releasedAmounts)): ?> <?php foreach ($releasedAmounts as $index => $releasedAmountData): ?> <div class="input-group mb-2" id="released-amount-<?= $index; ?>"> <input type="text" name="released_amount[]" class="form-control fieldsbox" id="ReleaseAmount" value="<?= $releasedAmountData['released_amount'] ?>"> <input type="text" name="released_date[]" class="form-control fieldsbox datepicker ml-2" id="ReleaseDate-<?= $index; ?>" value="<?= isset($releasedAmountData['released_date']) ? (new DateTime($releasedAmountData['released_date']))->format('d/m/Y') : '' ?>"> <i class="fa fa-minus-square-o remove-field removeReleasedAmount" aria-hidden="true" style="cursor: pointer;" data-index="<?= $index; ?>"></i> </div> <?php endforeach; ?> <?php else: ?> <div class="input-group mb-2" id="released-amount-0"> <input type="text" name="released_amount[]" class="form-control fieldsbox" id="ReleaseAmount"> <input type="text" name="released_date[]" class="form-control fieldsbox datepicker ml-2" id="ReleaseDate-0" placeholder="dd/mm/yy"> <i class="fa fa-minus-square-o remove-field removeReleasedAmount" aria-hidden="true" style="cursor: pointer;" data-index="0"></i> </div> <?php endif; ?> <i class="fa fa-plus-square-o" aria-hidden="true" id="add-more-field" style="cursor: pointer;"></i> <div id="file-add-div3"></div> </div> <div class="col-sm-1"></div> <div class="col-sm-5"> <label for="Expenditure" class="form-label inpfieldname">Expenditure</label> <?php if (!empty($expenditures)): ?> <?php foreach ($expenditures as $index => $expenditureData): ?> <div class="input-group mb-2" id="expenditure-<?= $index; ?>"> <input type="text" name="expenditure[]" class="form-control fieldsbox" id="Expenditure" value="<?= $expenditureData['expenditure_amount'] ?>"> <input type="text" name="expenditure_date[]" class="form-control fieldsbox datepicker ml-2" id="ExpenditureDate-<?= $index; ?>" value="<?= isset($expenditureData['expenditure_date']) ? (new DateTime($expenditureData['expenditure_date']))->format('d/m/Y') : '' ?>"> <i class="fa fa-minus-square-o remove-field removeExpenditure" aria-hidden="true" style="cursor: pointer;" data-index="<?= $index; ?>"></i> </div> <?php endforeach; ?> <?php else: ?> <div class="input-group mb-2" id="expenditure-0"> <input type="text" name="expenditure[]" class="form-control fieldsbox" id="Expenditure"> <input type="text" placeholder="dd/mm/yy" name="expenditure_date[]" class="form-control fieldsbox datepicker ml-2" id="ExpenditureDate-0"> <i class="fa fa-minus-square-o remove-field removeExpenditure" aria-hidden="true" style="cursor: pointer;" data-index="0"></i> </div> <?php endif; ?> <i class="fa fa-plus-square-o" aria-hidden="true" id="add-more-expenditure-field" style="cursor: pointer;"></i> <div id="expenditure-add-div"></div> </div> <div class="col-sm-1"></div> </div> <div class="row projdetail"> </div> <!-- --------------------------------- --> <!-- Seventh Row --> <!-- Eighth Row --> <div class="projdetail row"> <div class="col-sm-12"> <label for="Remarks" class="form-label inpfieldname ">Remarks</label><br> <textarea name="remarks" id="Remarks" class="form-control textfields rem" required><?= isset($project['remarks']) ? $project['remarks'] : '' ?></textarea> </div> </div> <!-- Button Row --> <div class="row"> <div class="col-sm-6 buttns-cnl"> <button type="submit" class="submit">Submit</button> <button type="button" id="btn-cancel" class="cancel">Cancel</button> </div> </div> </div> </form> <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 () { $('#project-edit-form').submit(function (e) { e.preventDefault(); function formatDate(date) { var dateParts = date.split('/'); // Split by '/' return dateParts[2] + '-' + dateParts[1] + '-' + dateParts[0]; // Return as yyyy-mm-dd } // Loop through each 'released_date[]' input field $('input[name="released_date[]"]').each(function () { var currentDate = $(this).val(); // Get the current value of the field if (currentDate) { var formattedDate = formatDate(currentDate); // Format the date $(this).val(formattedDate); // Set the formatted date back to the input field } }); // Loop through each 'expenditure_date[]' input field $('input[name="expenditure_date[]"]').each(function () { var currentDate = $(this).val(); // Get the current value of the field if (currentDate) { var formattedDate = formatDate(currentDate); // Format the date $(this).val(formattedDate); // Set the formatted date back to the input field } }); // Create FormData object to submit the form via AJAX var formData = new FormData($(this)[0]); $.ajax({ url: "<?php echo base_url('project-update-payment/' . $project['id']) ?>", 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 }); // window.location.href = '<?php echo base_url("projectlist"); ?>'; } else { alert(response.message); } }, error: function (xhr, status, error) { alert('An error occurred: ' + xhr.responseText); } }); }); }); </script> <script> $(document).on('click', '.removeReleasedAmount', function () { var index = $(this).data('index'); var releasedAmountValue = $('#released-amount-' + index + ' input').val(); if (confirm('Are you sure you want to delete this released amount?')) { $.ajax({ url: '<?= base_url("project/delete_released_amount"); ?>', type: 'POST', data: { project_id: <?= $project['id'] ?>, released_amount: releasedAmountValue, '<?= csrf_token() ?>': '<?= csrf_hash() ?>' }, success: function (response) { if (response.success) { $('#released-amount-' + index).remove(); alert('Released amount deleted successfully.'); } else { alert('Error deleting released amount: ' + response.message); } }, error: function (xhr, status, error) { console.error('Error:', error); } }); } }); </script> <script> $(document).on('click', '.removeExpenditure', function () { var index = $(this).data('index'); var expenditureValue = $('#expenditure-' + index + ' input').val(); if (confirm('Are you sure you want to delete this expenditure amount?')) { $.ajax({ url: '<?= base_url("project/delete-expenditure-amount"); ?>', type: 'POST', data: { project_id: <?= $project['id'] ?>, expenditure_amount: expenditureValue, '<?= csrf_token() ?>': '<?= csrf_hash() ?>' }, success: function (response) { if (response.success) { $('#expenditure-' + index).remove(); alert('Expenditure amount deleted successfully.'); } else { alert('Error deleting expenditure amount: ' + response.message); } }, error: function (xhr, status, error) { console.error('Error:', error); } }); } }); </script> <script> $(document).ready(function () { $('#btn-cancel').click(function (e) { e.preventDefault(); window.location.href = '<?php echo base_url("projectlist"); ?>'; }); }); </script> <script> $(document).ready(function () { // Initialize datepicker for all fields with the class "datepicker" $('.datepicker').datepicker({ dateFormat: 'dd/mm/yy', // Set date format to dd/mm/yy changeMonth: true, // Allow changing month changeYear: true // Allow changing year }); // Dynamically add Released Amount fields $('#add-more-field').click(function () { let index = $('.input-group[id^="released-amount-"]').length; $('#file-add-div3').append(` <div class="input-group mb-2" id="released-amount-${index}"> <input type="text" name="released_amount[]" class="form-control fieldsbox" id="ReleaseAmount"> <input type="text" name="released_date[]" class="form-control fieldsbox datepicker ml-2" id="ReleaseDate-${index}"> <i class="fa fa-minus-square-o remove-field removeReleasedAmount" aria-hidden="true" style="cursor: pointer;" data-index="${index}"></i> </div> `); // Reinitialize datepicker for newly added date fields $(`#ReleaseDate-${index}`).datepicker({ dateFormat: 'dd/mm/yy', changeMonth: true, changeYear: true }); }); // Dynamically add Expenditure fields $('#add-more-expenditure-field').click(function () { let index = $('.input-group[id^="expenditure-"]').length; $('#expenditure-add-div').append(` <div class="input-group mb-2" id="expenditure-${index}"> <input type="text" name="expenditure[]" class="form-control fieldsbox" id="Expenditure"> <input type="text" name="expenditure_date[]" class="form-control fieldsbox datepicker ml-2" id="ExpenditureDate-${index}"> <i class="fa fa-minus-square-o remove-field removeExpenditure" aria-hidden="true" style="cursor: pointer;" data-index="${index}"></i> </div> `); // Reinitialize datepicker for newly added date fields $(`#ExpenditureDate-${index}`).datepicker({ dateFormat: 'dd/mm/yy', changeMonth: true, changeYear: true }); }); }); </script> <!--<script>--> <!-- let moreField = document.querySelector("#add-more-field");--> <!-- let fileDiv3 = document.querySelector("#file-add-div3");--> <!-- moreField.addEventListener("click", function () {--> <!-- var inputContainer3 = document.createElement('div');--> <!-- inputContainer3.classList.add('input-group', 'mb-2');--> <!-- var amountInput = document.createElement('input');--> <!-- amountInput.classList.add('form-control', 'fieldsbox');--> <!-- amountInput.type = 'number';--> <!-- amountInput.name = 'released_amount[]';--> <!-- amountInput.min = '0';--> <!-- var dateInput = document.createElement('input');--> <!-- dateInput.classList.add('form-control', 'fieldsbox', 'ml-2');--> <!-- dateInput.type = 'date';--> <!-- dateInput.name = 'released_date[]';--> <!-- var removeIcon3 = document.createElement('i');--> <!-- removeIcon3.classList.add('fa', 'fa-minus-square', 'remove-file-icon');--> <!-- removeIcon3.style.cursor = 'pointer';--> <!-- removeIcon3.style.marginLeft = '15px';--> <!-- removeIcon3.style.marginTop = '15px';--> <!-- removeIcon3.addEventListener("click", function () {--> <!-- fileDiv3.removeChild(inputContainer3);--> <!-- });--> <!-- inputContainer3.appendChild(amountInput);--> <!-- inputContainer3.appendChild(dateInput);--> <!-- inputContainer3.appendChild(removeIcon3);--> <!-- fileDiv3.appendChild(inputContainer3);--> <!-- });--> <!-- let addMoreExpenditureField = document.querySelector("#add-more-expenditure-field");--> <!-- let expenditureDiv = document.querySelector("#expenditure-add-div");--> <!-- addMoreExpenditureField.addEventListener("click", function () {--> <!-- var expenditureContainer = document.createElement('div');--> <!-- expenditureContainer.classList.add('input-group', 'mb-2');--> <!-- var expenditureInput = document.createElement('input');--> <!-- expenditureInput.classList.add('form-control', 'fieldsbox');--> <!-- expenditureInput.type = 'number';--> <!-- expenditureInput.name = 'expenditure[]';--> <!-- expenditureInput.min = '0';--> <!-- var expenditureDateInput = document.createElement('input');--> <!-- expenditureDateInput.classList.add('form-control', 'fieldsbox', 'ml-2');--> <!-- expenditureDateInput.type = 'date';--> <!-- expenditureDateInput.name = 'expenditure_date[]';--> <!-- var removeExpenditureIcon = document.createElement('i');--> <!-- removeExpenditureIcon.classList.add('fa', 'fa-minus-square', 'remove-file-icon');--> <!-- removeExpenditureIcon.style.cursor = 'pointer';--> <!-- removeExpenditureIcon.style.marginLeft = '15px';--> <!-- removeExpenditureIcon.style.marginTop = '15px';--> <!-- removeExpenditureIcon.addEventListener("click", function () {--> <!-- expenditureDiv.removeChild(expenditureContainer);--> <!-- });--> <!-- expenditureContainer.appendChild(expenditureInput);--> <!-- expenditureContainer.appendChild(expenditureDateInput);--> <!-- expenditureContainer.appendChild(removeExpenditureIcon);--> <!-- expenditureDiv.appendChild(expenditureContainer);--> <!-- });--> <!--</script>--> <script> let arrow = document.querySelectorAll(".arrow"); for (var i = 0; i < arrow.length; i++) { arrow[i].addEventListener("click", (e) => { let arrowParent = e.target.parentElement.parentElement; arrowParent.classList.toggle("showMenu"); }); } let sidebar = document.querySelector(".sidebar"); let sidebarBtn = document.querySelector(".bx-menu"); console.log(sidebarBtn); sidebarBtn.addEventListener("click", () => { sidebar.classList.toggle("close"); }); </script> <script> $(document).ready(function() { $('#excel').submit(function(e) { e.preventDefault(); var formData = new FormData($(this)[0]); $.ajax({ url: "<?php echo base_url('Excel/import1') ?>", type: "POST", data: formData, processData: false, contentType: false, success: function(response) { if (response.result === 1) { toastr.success(response.message, "Success"); $('#excel')[0].reset(); // Optional: Redirect to another page after success // window.location.href = '<?php echo base_url("createproject"); ?>'; } else { toastr.error(response.message, "Error"); } }, error: function(xhr, status, error) { toastr.error('An error occurred: ' + xhr.responseText, "Error"); } }); }); }); </script> <?php echo view('includes/footer'); ?>