EVOLUTION-NINJA
Edit File: createProject.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">Add 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'] : '' ?>"> <div class="row projdetail"> <!------------------------------------------------------------------------------------------------------------------------> <!----------------------------------------------------------------------------------------------------> <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> <div class="col-sm-4"> <label class="form-label inpfieldname"> Product Type <span style="color:red">*</span> </label> <select name="product_category" class="form-control fieldsbox" required> <option value="">Select Product Type</option> <?php if (isset($product_types) && count($product_types) > 0): ?> <?php print_r($product_types); ?> <?php foreach ($product_types as $type): ?> <option value="<?= $type['product_type'] ?>"> <?= $type['product_type'] ?> </option> <?php endforeach; ?> <?php else: ?> <option disabled>No Product Types Found</option> <?php endif; ?> </select> </div> <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> <div class="row projdetail"> <!------------------------------------------------------------------------------------------------------------------------> <!----------------------------------------------------------------------------------------------------> <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> <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> <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 class="col-sm-4">--> <!-- <label class="form-label inpfieldname">NDP with GST</label>--> <!--<input type="number"--> <!-- step="0.01"--> <!-- name="ndp_with_gst"--> <!-- class="form-control fieldsbox"--> <!-- placeholder="Enter NDP with GST"--> <!-- value="<?= isset($product['ndp_with_gst']) ? $product['ndp_with_gst'] : '' ?>"--> <!-- required>--> <!-- </div>--> <!-- <div class="col-sm-4">--> <!-- <label class="form-label inpfieldname">GST Difference</label>--> <!--<input type="number"--> <!-- step="0.01"--> <!-- name="gst_difference"--> <!-- class="form-control fieldsbox"--> <!-- placeholder="Enter GST Difference"--> <!-- value="<?= isset($product['gst_difference']) ? $product['gst_difference'] : '' ?>"--> <!-- required>--> <!--</div>--> <!-- <div class="col-sm-4">--> <!-- <label class="form-label inpfieldname">AE Commission</label>--> <!--<input type="number"--> <!-- step="0.01"--> <!-- name="ae_commission"--> <!-- class="form-control fieldsbox"--> <!-- placeholder="Enter AE Commission"--> <!-- value="<?= isset($product['ae_commission']) ? $product['ae_commission'] : '' ?>"--> <!-- required>--> <!--</div>--> <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> <!-- 2nd row --> <!--<div class="row projdetail">--> <!-- <div class="col-sm-4">--> <!-- <label class="form-label inpfieldname">Status</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 class="col-sm-4 ">--> <!--</div>--> <!-- 8th row --> <div class=" projdetail row"> </div><br><br> <div class="col-sm-6 buttns-cnl"> <button type="submit" class="submit"> <?= isset($product) ? 'Update' : 'Add Product' ?> </button> <button type="button" id="btn-cancel" class="cancel">Cancel</button> </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(); // reload page so dropdown reloads from server location.reload(); } else { Swal.fire({ icon: 'error', title: response.message }); } }, error: function (xhr) { console.log(xhr.responseText); alert('Something went wrong!'); } }); }); }); </script> <script> $('#btn-cancel').click(function () { $('#product-form')[0].reset(); }); </script> <script> function calculateGST() { let rc_price = parseFloat($('input[name="rc_price"]').val()) || 0; let basic_price = parseFloat($('input[name="basic_price"]').val()) || 0; if (rc_price > 0 && basic_price > 0) { let gst_percent = ((rc_price - basic_price) / basic_price) * 100; $('#gst_percent').val(gst_percent.toFixed(2)); } else { $('#gst_percent').val(''); } } // Auto calculate while typing $('input[name="rc_price"], input[name="basic_price"]').on('keyup change', function () { calculateGST(); }); // For edit page auto load calculateGST(); </script> <?php echo view('includes/footer'); ?>