Server IP : 162.214.80.37 / Your IP : 216.73.216.83 Web Server : Apache System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 User : imyrqtmy ( 2189) PHP Version : 8.2.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home2/imyrqtmy/public_html/dts/vendor/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php session_start(); $se = $_SESSION["id"]; if (!isset($_SESSION['id'])) { header("Location: login.php"); } include("inc/config.php"); ?> <!DOCTYPE html> <html lang="en"> <?php require "inc/head.php"; ?> <body> <!-- header--> <?php require "inc/header.php"; ?> <!-- End Main-content Top bar--> <!-- main-content--> <div class="wrapper"> <?php require "inc/sidebar.php"; ?> <div id="content"> <div class="row mb-4"> <div class="col-12"> <div class="card redial-border-light redial-shadow"> <div class="card-body"> <h6 class="header-title pl-3 redial-relative">Invoice</h6> <form action="add_invoice.php" method="post" enctype="multipart/form-data"> <div class="row"> <!-- Left Section: Invoice Details --> <div class="col-md-6"> <input type="hidden" name="status" value="Pending"> <div class="mb-2"> <label class="redial-font-weight-600">Invoice Number</label> <input type="text" name="invoice_number" class="form-control" placeholder="Invoice No" > </div> <!-- Invoice Date --> <div class="mb-2"> <label class="redial-font-weight-600">Invoice Date</label> <input type="date" name="invoice_date" class="form-control"> </div> <!-- Due Date --> <div class="mb-2"> <label class="redial-font-weight-600">Due Date</label> <input type="date" name="due_date" class="form-control"> </div> </div> <!-- Right Section: Logo --> <div class="col-md-6 text-center align-self-center"> <img src="dist/images/logo-v2.png" alt="" class="img-fluid" /> </div> </div> <!-- Billing Details --> <div class="card billing"> <div class="row mt-4"> <!-- Billed By --> <?php if (isset($_SESSION['id'])) { // User is logged in, fetch user information $se = $_SESSION['id']; $query = "SELECT * FROM `admin` WHERE id='$se'"; $query_run = mysqli_query($conn, $query); if (mysqli_num_rows($query_run) > 0) { $row = mysqli_fetch_assoc($query_run); ?> <div class="col-md-6"> <h6 class="redial-font-weight-600">Billed By <span style="font-size:11px">(Your Detail)</span></h6> <div class="mb-2"> <label for="">Your Company Name</label> <input type="text" name="own_company" class="form-control" value="<?php echo $row['own_company']; ?>" placeholder="Your Company Name"> </div> <div class="mb-2"> <label for="">Your Phone</label> <input type="text" name="own_phone" value="<?php echo $row['phone']; ?>" class="form-control" placeholder="Your Phone"> </div> <div class="mb-2"> <label for="">Your Email</label> <input type="email" name="own_email" value="<?php echo $row['username']; ?>" class="form-control" placeholder="Your Email"> </div> <div class="mb-2"> <label for="">Your GSTIN</label> <input type="text" name="own_gst" value="<?php echo $row['own_gst']; ?>" class="form-control" placeholder="Your Phone"> </div> </div> <?php }} ?> <!-- Billed To --> <div class="col-md-6"> <h6 class="redial-font-weight-600">Billed To <span style="font-size:11px">(Client Detail)</span></h6> <!-- Dropdown for selecting client name --> <div class="mb-2"> <label for="client_name">Client Name</label> <select id="client_name" name="client_name" class="form-control"> <option value="">Select Client</option> <?php $query = "SELECT * FROM clients"; $query_run = mysqli_query($conn, $query); if (mysqli_num_rows($query_run) > 0) { foreach ($query_run as $row) { echo "<option value='" . $row['id'] . "'>" . $row['client_name'] . "</option>"; } } ?> </select> </div> <!-- Fields to display client details --> <div class="mb-2"> <label for="cli_company">Company Name</label> <input type="text" id="cli_company" name="cli_company" class="form-control" placeholder="Company Name" readonly> </div> <div class="mb-2"> <label for="cli_phone">Phone</label> <input type="text" id="cli_phone" name="cli_phone" class="form-control" placeholder="Phone" readonly> </div> <div class="mb-2"> <label for="cli_email">Email</label> <input type="email" id="cli_email" name="cli_email" class="form-control" placeholder="Email" readonly> </div> <div class="mb-2"> <label for="cli_gst">GSTIN</label> <input type="text" id="cli_gst" name="cli_gst" class="form-control" placeholder="GSTIN" readonly> </div> </div> <!-- Product Details Table --> <!-- <div class="row mt-4"> <div class="col-12"> <h6 class="redial-font-weight-600">Product Details</h6> <table class="table table-bordered" id="productTable"> <thead> <tr> <th>Product Name</th> <th>Quantity</th> <th>Price</th> <th>Description</th> <th>Actions</th> </tr> </thead> <tbody> <tr> <td> <input type="text" name="product_name[]" class="form-control" placeholder="Product Name"> </td> <td> <input type="number" name="quantity[]" class="form-control" placeholder="Quantity"> </td> <td> <input type="text" name="price[]" class="form-control" placeholder="Price"> </td> <td> <input type="text" name="description[]" class="form-control" placeholder="Description"> </td> <td> <button type="button" class="btn btn-outline-danger removeRow"> <i class='fa fa-trash'></i></button> </td> </tr> </tbody> </table> <button type="button" id="addRow" class="btn btn-outline-primary">Add More</button> </div> </div> --> <?php include("inc/config.php"); // Fetch products $product_query = "SELECT id, product_name, product_price FROM products"; $product_result = mysqli_query($conn, $product_query); $products = []; while ($row = mysqli_fetch_assoc($product_result)) { $products[] = $row; } ?> <div class="row mt-4"> <div class="col-12"> <h6 class="redial-font-weight-600">Product Details</h6> <table class="table table-bordered" id="productTable"> <thead> <tr> <th>Product Name</th> <th>Quantity</th> <th>Price</th> <th>Description</th> <th>Actions</th> </tr> </thead> <tbody> <tr> <td> <select name="product_name[]" class="form-control productSelect"> <option value="">Select Product</option> <?php foreach ($products as $product) { ?> <option value="<?php echo $product['product_name']; ?>" data-price="<?php echo $product['product_price']; ?>"> <?php echo $product['product_name']; ?> </option> <?php } ?> </select> </td> <td> <input type="number" name="quantity[]" class="form-control" placeholder="Quantity"> </td> <td> <input type="text" name="price[]" class="form-control priceField" placeholder="Price" readonly> </td> <td> <input type="text" name="description[]" class="form-control" placeholder="Description"> </td> <td> <button type="button" class="btn btn-outline-danger removeRow"><i class='fa fa-trash'></i></button> </td> </tr> </tbody> </table> <button type="button" id="addRow" class="btn btn-outline-primary">Add More</button> </div> </div> </div> <!-- Submit Button --> <div class="row mt-4"> <div class="col-12 text-center"> <button type="submit" name="add_invoice" class="btn btn-outline-success">Submit Invoice</button> </div> </div> </div> </form> </div> </div> </div> </div> </div> <!-- </div> --> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script> $(document).ready(function() { // Auto-fill price when product is selected $(document).on('change', '.productSelect', function() { var price = $(this).find(':selected').data('price'); $(this).closest('tr').find('.priceField').val(price); }); // Add new row $("#addRow").click(function() { var newRow = `<tr> <td> <select name="product_name[]" class="form-control productSelect"> <option value="">Select Product</option> <?php foreach ($products as $product) { ?> <option value="<?php echo $product['product_name']; ?>" data-price="<?php echo $product['product_price']; ?>"> <?php echo $product['product_name']; ?> </option> <?php } ?> </select> </td> <td> <input type="number" name="quantity[]" class="form-control" placeholder="Quantity"> </td> <td> <input type="text" name="price[]" class="form-control priceField" placeholder="Price" readonly> </td> <td> <input type="text" name="description[]" class="form-control" placeholder="Description"> </td> <td> <button type="button" class="btn btn-outline-danger removeRow"><i class='fa fa-trash'></i></button> </td> </tr>`; $("#productTable tbody").append(newRow); }); // Remove row $(document).on("click", ".removeRow", function() { $(this).closest("tr").remove(); }); }); </script> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script> $(document).ready(function () { $('#client_name').change(function () { var client_id = $(this).val(); if (client_id !== "") { $.ajax({ url: 'fetch_client_details.php', // PHP script to fetch data type: 'POST', data: { id: client_id }, dataType: 'json', success: function (response) { if (response.status === 'success') { $('#cli_company').val(response.data.company_name); $('#cli_phone').val(response.data.phone); $('#cli_email').val(response.data.email); $('#cli_gst').val(response.data.gstin); } else { alert('Client details not found.'); } }, error: function () { alert('Error fetching data.'); } }); } else { // Clear fields if no client is selected $('#cli_company').val(''); $('#cli_phone').val(''); $('#cli_email').val(''); $('#cli_gst').val(''); } }); }); </script> <script src="dist/js/plugins.min.js"></script> <script src="dist/js/common.js"></script> </body> </html>