EVOLUTION-NINJA
Edit File: project_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="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">Create Product</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; } .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 } .projectinputs { width: 93% !important; } .input-group { width: 93% !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%; } .projectinputs { width: 100% !important; } .input-group { width: 100% !important; } } @media only screen and (max-width:620px) { .fieldsbox { width: 100% } .home-section { height: 100% } .projectinputs { width: 100% !important; } .input-group { width: 100% !important; } } </style> <!-- forms --> <?php $isEdit = isset($product); $action = $isEdit ? base_url('products/update/'.$product['product_id']) : base_url('products/store'); ?> <form method="post" action="<?= $action ?>" id="product-form"> <input type="hidden" name="product_id" value="<?= isset($product['product_id']) ? $product['product_id'] : '' ?>"> <!-- 1st Row --> <div class="row projdetail"> <!-- Model Name --> <div class="col-sm-4"> <label class="form-label inpfieldname"> Model Name <span style="color:red">*</span> </label> <input type="text" name="model_name" class="form-control fieldsbox" placeholder="Enter Model Name" value="<?= isset($product['model_name']) ? $product['model_name'] : '' ?>" required> </div> <!-- Product Type --> <div class="col-sm-4"> <label class="form-label inpfieldname"> Product Type <span style="color:red">*</span> </label> <!-- Show Product Type --> <input type="text" class="form-control fieldsbox" value="<?= isset($product['product_category']) ? $product['product_category'] : '' ?>" readonly> <!-- Hidden field for submit --> <input type="hidden" name="product_category" value="<?= isset($product['product_category']) ? $product['product_category'] : '' ?>"> </div> <!-- RC Price --> <div class="col-sm-4"> <label class="form-label inpfieldname"> RC Price <span style="color:red">*</span> </label> <input type="number" step="0.01" name="rc_price" class="form-control fieldsbox" placeholder="Enter RC Price" value="<?= isset($product['rc_price']) ? $product['rc_price'] : '' ?>" required> </div> </div> <!-- 2nd Row --> <div class="row projdetail"> <!-- Basic Price --> <div class="col-sm-4"> <label class="form-label inpfieldname"> Basic Price <span style="color:red">*</span> </label> <input type="number" step="0.01" name="basic_price" class="form-control fieldsbox" placeholder="Enter Basic Price" value="<?= isset($product['basic_price']) ? $product['basic_price'] : '' ?>" required> </div> <!-- NDP --> <div class="col-sm-4"> <label class="form-label inpfieldname"> NDP <span style="color:red">*</span> </label> <input type="number" step="0.01" name="ndp" class="form-control fieldsbox" placeholder="Enter NDP" value="<?= isset($product['ndp']) ? $product['ndp'] : '' ?>" required> </div> <!-- GST % --> <div class="col-sm-4"> <label class="form-label inpfieldname"> GST % <span style="color:red">*</span> </label> <input type="number" step="0.01" name="gst_percent" id="gst_percent" class="form-control fieldsbox" placeholder="Enter GST %" value="<?= isset($product['gst_percent']) ? $product['gst_percent'] : '' ?>" required> </div> </div> <!-- 3rd Row --> <div class="row projdetail"> <!-- Status --> <div class="col-sm-4"> <label class="form-label inpfieldname"> Status <span style="color:red">*</span> </label> <select name="status" class="form-control fieldsbox" required> <option value="">Select Status</option> <option value="active" <?= (isset($product) && $product['status'] == 'active') ? 'selected' : '' ?>> Active </option> <option value="inactive" <?= (isset($product) && $product['status'] == 'inactive') ? 'selected' : '' ?>> Inactive </option> </select> </div> </div> <!-- Buttons --> <!--<br><br>--> <!--<div class="col-sm-6 buttns-cnl">--> <!-- <button type="submit" class="submit">--> <!-- <?= isset($product) ? 'Update Product' : 'Add Product' ?>--> <!-- </button>--> <!-- <button type="button" id="btn-cancel" class="cancel">--> <!-- Cancel--> <!-- </button>--> <!--</div>--> <!-- Buttons --> <div class="row mt-4"> <div class="col-sm-12 d-flex gap-3"> <button type="submit" class="submit"> Update </button> <button type="button" id="btn-cancel" class="cancel"> Cancel </button> </div> </div> </form> </div> </div> </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 () { $('#product-form').submit(function (e) { e.preventDefault(); let formData = new FormData(this); $.ajax({ url: $('#product-form').attr('action'), type: "POST", data: formData, processData: false, contentType: false, success: function (response) { if (response.status == 1) { // ✅ Success popup Swal.fire({ icon: 'success', title: response.message, showConfirmButton: false, timer: 2000 }); // ✅ Reset form // $('#product-form')[0].reset(); window.location.href = "<?= base_url('projectlist') ?>"; } else { Swal.fire({ icon: 'error', title: response.message }); } }, error: function (xhr) { console.log(xhr.responseText); alert('Something went wrong!'); } }); }); }); </script> <script> $(document).ready(function () { $('#btn-cancel').click(function (e) { e.preventDefault(); window.location.href = '<?php echo base_url("projectlist"); ?>'; }); }); </script> <?php echo view('includes/footer'); ?>