EVOLUTION-NINJA
Edit File: customer_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="<?php echo base_url('public/assets/images/project-management.png');?>"> <link rel="stylesheet" href="<?php echo base_url('public/assets/images/arrows-up.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> <!----> <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" /> <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.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">EDIT Project</h1> </div> </div> <style> .select2-container .select2-selection--single { height: 40px; border-radius: 50px !important; border: 1px solid #ccc; padding: 6px 15px; /* spacing inside */ } .select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 26px; /* adjust to match height */ } .select2-container--default .select2-selection--single .select2-selection__arrow { height: 100%; right: 10px; /* spacing for arrow */ } #mlc.select2-hidden-accessible + .select2 , #mp.select2-hidden-accessible + .select2{ width: 500px !important; } .inpfieldname { font-family: Poppins; font-size: 18px; font-weight: 500; text-align: left; color: #1F1F21; } .buttns-cnl { margin-left: 20px; } .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 } .projectinputs { width: 93%; } .totpag { width: 100% } .input-group { width: 93%; } /*.remarks{*/ /* margin-left:150px !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; } } .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; } .required-star::after { content: " *"; color: red; font-weight: bold; } @media only screen and (max-width: 600px) { .header-image { width: 50% !important; height: auto; } } @media (min-width: 768px) and (max-width: 1024px) { .logo { width: 80% !important; height: auto; } } /* --------------------only for tablets-------------------------------- */ @media (min-width: 768px) and (max-width: 1024px) {} /* --------------------only for tablets-------------------------------- */ /* ---------------- header style end */ </style> <!-- forms --> <!--<form id="customer-form">--> <form id="customer-form" enctype="multipart/form-data"> <input type="hidden" name="id" value="<?= $project['id'] ?>"> <div class="createproject"> <div class="row projdetail"> <div class="col-sm-4"> <label class="form-label inpfieldname required-star">FARMER NAME</label> <input type="text" name="farmer_name" id="farmer_name" class="form-control fieldsbox" placeholder="Enter Farmer Name" value="<?= isset($project['farmer_name']) ? $project['farmer_name'] : '' ?>" oninput="this.value=this.value.replace(/[^A-Za-z\s]/g,'')" required> </div> <!--<div class="col-sm-4">--> <!-- <label class="form-label inpfieldname">FARMER SHARE AMT</label>--> <!-- <input type="number" name="share_amount" id="share_amount" class="form-control fieldsbox" placeholder="Enter Amount" value="<?= isset($project['share_amount']) ? $project['share_amount'] : '' ?>" required>--> <!--</div>--> <div class="col-sm-4"> <label class="form-label inpfieldname required-star">TALUK</label> <input type="text" name="taluk" id="taluk" class="form-control fieldsbox" placeholder="Enter Taluk" value="<?= isset($project['taluk']) ? $project['taluk'] : '' ?>" required> </div> <div class="col-sm-4"> <label class="form-label inpfieldname required-star">CAT</label> <select name="category" id="category" class="form-control fieldsbox"> <option value="">Select Category</option> <option value="SC" <?= (isset($project['category']) && $project['category'] == 'SC') ? 'selected' : '' ?>>SC</option> <option value="ST" <?= (isset($project['category']) && $project['category'] == 'ST') ? 'selected' : '' ?>>ST</option> <option value="General" <?= (isset($project['category']) && $project['category'] == 'General') ? 'selected' : '' ?>>General</option> <option value="OBC" <?= (isset($project['category']) && $project['category'] == 'OBC') ? 'selected' : '' ?>>OBC</option> </select> </div> </div> <div class="row projdetail"> <div class="col-sm-4"> <label class="form-label inpfieldname required-star">FARMER ADDRESS</label> <input type="text" name="address" id="address" class="form-control fieldsbox" placeholder="Enter Farmer Address" value="<?= isset($project['address']) ? $project['address'] : '' ?>" required> </div> <!-- <div class="col-sm-4"> <label class="form-label inpfieldname">DEALER</label> <select name="dealer_id" id="dealer_id" class="form-control fieldsbox"> <option value="">Select Dealer</option> </select> </div> --> <div class="col-sm-4"> <label class="form-label inpfieldname required-star">DEALER</label> <input type="text" class="form-control fieldsbox" value="<?= $project['dealer_name'] ?>" readonly> <!-- hidden field to send value --> <input type="hidden" name="dealer_name" value="<?= $project['dealer_name'] ?>"> </div> <div class="col-sm-4"> <label class="form-label inpfieldname required-star">Phone No</label> <input type="text" name="phone_no" id="phone_no" value="<?= $project['phone_no'] ?? '' ?>" class="form-control fieldsbox" placeholder="Enter Mobile Number" required> </div> </div> <div class="row projdetail"> <!--<div class="col-sm-4">--> <!-- <label class="form-label inpfieldname required-star">FID NO.</label>--> <!-- <input type="text" name="fid_no" id="fid_no" value="<?= $project['fid_no'] ?? '' ?>" class="form-control fieldsbox" placeholder="Enter FID No" >--> <!--</div>--> <div class="col-sm-4"> <label class="form-label inpfieldname required-star">FARMER ID</label> <!-- Visible but NOT editable --> <input type="text" class="form-control fieldsbox" value="<?= $project['farmer_id'] ?>" readonly> <!-- Hidden field (IMPORTANT to send value if needed) --> <input type="hidden" name="farmer_id" value="<?= $project['farmer_id'] ?>"> </div> <div class="col-sm-4"> <label class="form-label inpfieldname required-star">AADHAAR NO.</label> <!--<input type="text" name="aadhar_no" id="aadhar_no" class="form-control fieldsbox" placeholder="Enter 12 digit Aadhaar" maxlength="12">--> <input type="text" name="aadhar_no" id="aadhar_no" class="form-control fieldsbox" placeholder="Enter 12 digit Aadhaar" maxlength="12" value="<?= $project['aadhar_no'] ?? '' ?>"> </div> <div class="col-sm-4"> <label class="form-label inpfieldname required-star"> PRODUCT TYPE </label> <select name="product_type" id="product_type" class="form-control fieldsbox"> <option value=""> Select Product Type </option> </select> </div> </div> <div class="row projdetail"> <!-- PRODUCT MODEL --> <div class="col-sm-4"> <label class="form-label inpfieldname required-star"> PRODUCT MODEL </label> <select name="product_id" id="product_id" class="form-control fieldsbox"> <option value=""> Select Product Model </option> </select> </div> <div class="col-sm-4"> <label class="form-label inpfieldname"> RC PRICE </label> <input type="text" name="rc_price" id="rc_price" value="<?= $project['rc_price'] ?? '' ?>" class="form-control fieldsbox" readonly> </div> <div class="col-sm-4"> <label class="form-label inpfieldname"> GST % </label> <input type="text" name="gst_percent" id="gst_percent" value="<?= $project['gst_percent'] ?? '' ?>" class="form-control fieldsbox" readonly> </div> </div> <div class="row projdetail"> <div class="col-sm-4"> <label class="form-label inpfieldname"> BASIC PRICE </label> <input type="text" name="basic_price" id="basic_price" value="<?= $project['basic_price'] ?? '' ?>" class="form-control fieldsbox" readonly> </div> <div class="col-sm-4"> <label class="form-label inpfieldname">Engine No.</label> <input type="text" name="engine_no" id="engine_no" value="<?= $project['engine_no'] ?? '' ?>" class="form-control fieldsbox" placeholder="Enter Engine No."> </div> <div class="col-sm-4"> <label class="form-label inpfieldname">Chasis No.</label> <input type="text" name="chasis_no" id="chasis_no" value="<?= $project['chasis_no'] ?? '' ?>" class="form-control fieldsbox" placeholder="Enter Chasis No."> </div> </div> <div class="row projdetail"> <div class="col-sm-4"> <label class="form-label inpfieldname"> UPLOAD PHOTO </label> <input type="file" name="photo" id="photo" class="form-control fieldsbox"> <?php if(!empty($project['photo'])): ?> <br> <img src="<?= base_url('public/uploads/customer_photos/'.$project['photo']) ?>" width="120" style="border-radius:10px;"> <?php endif; ?> </div> <div class="col-sm-4"> <label class="form-label inpfieldname"> UPLOAD INVOICE </label> <input type="file" name="invoice_file" id="invoice_file" class="form-control fieldsbox" accept=".pdf,.jpg,.jpeg,.png"> <?php if(!empty($project['invoice_file'])): ?> <br> <a href="<?= base_url('public/uploads/invoices/'.$project['invoice_file']) ?>" target="_blank" class="btn btn-success btn-sm mt-2"> View Existing Invoice </a> <?php endif; ?> </div> </div> <div class="col-sm-6 buttns-cnl mt-4"> <button type="submit" class="submit">Submit</button> <button type="button" id="btn-cancel" class="cancel">Cancel</button> </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 () { $('#btn-cancel').click(function (e) { e.preventDefault(); window.location.href = '<?php echo base_url("customer-list"); ?>'; }); }); </script> <script> let moreFile = document.querySelector("#add-more-file"); let fileDiv = document.querySelector("#file-add-div"); moreFile.addEventListener("click", function () { var inputContainer = document.createElement('div'); inputContainer.classList.add('input-group', 'mb-2'); var newInput = document.createElement('input'); newInput.classList.add('form-control', 'fieldsbox'); newInput.type = 'file'; newInput.name = 'proposal[]'; var removeIcon = document.createElement('i'); removeIcon.classList.add('fa', 'fa-minus-square', 'remove-file-icon'); removeIcon.style.marginLeft = '15px'; removeIcon.style.marginRight = '15px'; removeIcon.style.marginTop = '15px';; removeIcon.addEventListener("click", function () { fileDiv.removeChild(inputContainer); }); inputContainer.appendChild(newInput); inputContainer.appendChild(removeIcon); fileDiv.appendChild(inputContainer); }); </script> <script> let moreFile1 = document.querySelector("#add-more-file1"); let fileDiv1 = document.querySelector("#file-add-div1"); moreFile1.addEventListener("click", function () { var inputContainer1 = document.createElement('div'); inputContainer1.classList.add('input-group', 'mb-2'); var newInput1 = document.createElement('input'); newInput1.classList.add('form-control', 'fieldsbox'); newInput1.type = 'file'; newInput1.name = 'estimate[]'; var removeIcon1 = document.createElement('i'); removeIcon1.classList.add('fa', 'fa-minus-square', 'remove-file-icon'); removeIcon1.style.marginLeft = '15px'; removeIcon1.style.marginRight = '15px'; removeIcon1.style.marginTop = '15px'; removeIcon1.addEventListener("click", function () { fileDiv1.removeChild(inputContainer1); }); inputContainer1.appendChild(newInput1); inputContainer1.appendChild(removeIcon1); fileDiv1.appendChild(inputContainer1); }); </script> <script> let moreFile2 = document.querySelector("#add-more-file2"); let fileDiv2 = document.querySelector("#file-add-div2"); moreFile2.addEventListener("click", function () { var inputContainer2 = document.createElement('div'); inputContainer2.classList.add('input-group', 'mb-2'); var newInput2 = document.createElement('input'); newInput2.classList.add('form-control', 'fieldsbox'); newInput2.type = 'file'; newInput2.name = 'approval[]'; var removeIcon2 = document.createElement('i'); removeIcon2.classList.add('fa', 'fa-minus-square', 'remove-file-icon'); removeIcon2.style.cursor = 'pointer'; removeIcon2.style.marginLeft = '15px'; removeIcon2.style.marginRight = '15px'; removeIcon2.style.marginTop = '15px'; removeIcon2.addEventListener("click", function () { fileDiv2.removeChild(inputContainer2); }); inputContainer2.appendChild(newInput2); inputContainer2.appendChild(removeIcon2); fileDiv2.appendChild(inputContainer2); }); </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 () { $('#customer-form').on('submit', function (e) { e.preventDefault(); let formData = new FormData(this); let id = $('input[name="id"]').val(); // ✅ GET ID HERE $.ajax({ url: "<?= base_url('project-update') ?>", type: "POST", data: formData, processData: false, contentType: false, dataType: "JSON", success: function (response) { if (response.result == 1) { Swal.fire("Success", response.message, "success").then(() => { window.location.href = "<?= base_url('customer-list') ?>"; }); } else { Swal.fire("Error", response.message, "error"); } } }); }); }); </script> <script> $(document).ready(function () { // ===================================== // LOAD PRODUCT TYPES // ===================================== $.ajax({ url: "<?= base_url('get-product-types') ?>", type: "POST", dataType: "JSON", success: function (response) { let options = '<option value="">Select Product Type</option>'; $.each(response, function(index, row){ let selected = ''; if( row.product_type == "<?= $project['product_type'] ?? '' ?>" ){ selected = 'selected'; } options += ` <option value="${row.product_type}" ${selected}> ${row.product_type} </option> `; }); $('#product_type').html(options); // AUTO LOAD MODELS loadProductModels(); } }); }); // ===================================== // LOAD PRODUCT MODELS // ===================================== function loadProductModels() { let product_type = $('#product_type').val(); $.ajax({ url: "<?= base_url('get-products-by-type') ?>", type: "POST", data: { product_type: product_type }, dataType: "JSON", success: function(products){ let options = '<option value="">Select Product Model</option>'; $.each(products, function(index, product){ let selected = ''; if( product.product_id == "<?= $project['product_id'] ?? '' ?>" ){ selected = 'selected'; } options += ` <option value="${product.product_id}" ${selected}> ${product.model_name} </option> `; }); $('#product_id').html(options); } }); } // ===================================== // CHANGE PRODUCT TYPE // ===================================== $('#product_type').change(function(){ loadProductModels(); }); // ===================================== // PRODUCT DETAILS // ===================================== $('#product_id').change(function(){ let product_id = $(this).val(); $.ajax({ url: "<?= base_url('get-product-details-far') ?>", type: "POST", data: { product_id: product_id }, dataType: "JSON", success: function(product){ $('#rc_price') .val(product.rc_price); $('#gst_percent') .val(product.gst_percent); $('#basic_price') .val(product.basic_price); } }); }); </script> <?php echo view('includes/footer'); ?>