corrections in customer,user,invoice
This commit is contained in:
parent
3c42c1c089
commit
d6b2908dd3
@ -3,6 +3,7 @@
|
|||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Models\CustomerModel;
|
use App\Models\CustomerModel;
|
||||||
|
use App\Models\SubscriptionModel;
|
||||||
|
|
||||||
class Customer extends BaseController
|
class Customer extends BaseController
|
||||||
{
|
{
|
||||||
@ -38,23 +39,36 @@ class Customer extends BaseController
|
|||||||
helper('session');
|
helper('session');
|
||||||
$session_bid = get_business_id();
|
$session_bid = get_business_id();
|
||||||
if ($id === '0') {
|
if ($id === '0') {
|
||||||
|
// Add Customer
|
||||||
$data['page_name'] = 'Add Customer';
|
$data['page_name'] = 'Add Customer';
|
||||||
$data['customer'] = [];
|
$data['customer'] = [];
|
||||||
$data['customer_billing'] = [];
|
$data['customer_billing'] = [];
|
||||||
$data['customer_shipping'] = [];
|
$data['customer_shipping'] = [];
|
||||||
|
$data['subscriptionData'] = [];
|
||||||
|
$data['invoices'] = [];
|
||||||
} else if ($id !== '0') {
|
} else if ($id !== '0') {
|
||||||
|
// Edit Customer
|
||||||
$data['page_name'] = 'Edit Customer';
|
$data['page_name'] = 'Edit Customer';
|
||||||
|
$subscriptionModel = new SubscriptionModel();
|
||||||
|
$subscriptionData = $subscriptionModel->getSubscriptionsByCustomerId($id);
|
||||||
$model = new CustomerModel();
|
$model = new CustomerModel();
|
||||||
$model->setTable('customers');
|
$model->setTable('customers');
|
||||||
$edit_user_details = $model->where(['customer_id' => $id])->first();
|
$edit_user_details = $model->where(['customer_id' => $id])->first();
|
||||||
$data['customer'] = $edit_user_details;
|
$data['customer'] = $edit_user_details;
|
||||||
$data['customer_billing'] = $this->get_customer_address($id, 1);
|
$data['customer_billing'] = $this->get_customer_address($id, 1);
|
||||||
$data['customer_shipping'] = $this->get_customer_address($id, 2);
|
$data['customer_shipping'] = $this->get_customer_address($id, 2);
|
||||||
|
$data['subscriptionData'] = $subscriptionData;
|
||||||
|
|
||||||
|
// Fetch invoice data for the customer
|
||||||
|
$CustomerModel = new CustomerModel();
|
||||||
|
$invoices = $CustomerModel->getInvoicesByCustomerId($id);
|
||||||
|
$data['invoices'] = $invoices;
|
||||||
}
|
}
|
||||||
$data['session_bid'] = $session_bid;
|
$data['session_bid'] = $session_bid;
|
||||||
$this->render_page('customer_form', $data);
|
$this->render_page('customer_form', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
## For inserting/updating details of customer
|
## For inserting/updating details of customer
|
||||||
public function insert_customer()
|
public function insert_customer()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -278,14 +278,27 @@ class Invoice extends BaseController
|
|||||||
if ($existed) {
|
if ($existed) {
|
||||||
$data['isactive'] = 0;
|
$data['isactive'] = 0;
|
||||||
$data['updated_by'] = get_logged_user_id();
|
$data['updated_by'] = get_logged_user_id();
|
||||||
$model->update($id, $data);
|
|
||||||
|
if ($model->update($id, $data)) {
|
||||||
|
session()->setFlashdata('success', 'Deleted successfully.');
|
||||||
|
$this->logger->info("Invoice: has been Inactived successfully. Inactived ID = " . $id);
|
||||||
|
} else {
|
||||||
|
$this->logger->error("Invoice: Not able to Inactive ID =" . $id);
|
||||||
|
throw new \Exception("Data Not able to Deleted");
|
||||||
|
}
|
||||||
$getInvoiceItemDetails = $this->get_invoice_item($id);
|
$getInvoiceItemDetails = $this->get_invoice_item($id);
|
||||||
if ($getInvoiceItemDetails) {
|
if ($getInvoiceItemDetails) {
|
||||||
$update_where = ['invoice_id' => (int)$id];
|
$update_where = ['invoice_id' => (int)$id];
|
||||||
$model->updateData('invoiceitems', $data, $update_where);
|
$model->updateData('invoiceitems', $data, $update_where);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$this->logger->error("Invoice: Does Not Exist To Inactive, ID = " . $id);
|
||||||
|
throw new \Exception("Invoice Already Deleted");
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->logger->error("Invoice: Err Occur = " . $e->getMessage());
|
||||||
|
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->route('invoice_list');
|
return redirect()->route('invoice_list');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -90,6 +90,13 @@ class CustomerModel extends Model
|
|||||||
$dataToUpdate = ['isactive' => 0];
|
$dataToUpdate = ['isactive' => 0];
|
||||||
$this->db->table('customer_addresses')->where($where)->whereIn('customer_address_id',$missingValues)->update($dataToUpdate);
|
$this->db->table('customer_addresses')->where($where)->whereIn('customer_address_id',$missingValues)->update($dataToUpdate);
|
||||||
}
|
}
|
||||||
|
public function getInvoicesByCustomerId($customer_id)
|
||||||
|
{
|
||||||
|
return $this->db->table('invoice')
|
||||||
|
->select('invoice_number, subtotal, invoice_date')
|
||||||
|
->where('customer_id', $customer_id)
|
||||||
|
->get()
|
||||||
|
->getResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@ -116,6 +116,7 @@ public function updateData($table, $data, $where)
|
|||||||
->get()
|
->get()
|
||||||
->getResult();
|
->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -147,7 +147,14 @@ public function getAllCustomerDetailsBySchemeName($schemeName)
|
|||||||
|
|
||||||
return $customerDetails;
|
return $customerDetails;
|
||||||
}
|
}
|
||||||
|
public function getSubscriptionsByCustomerId($customerId)
|
||||||
|
{
|
||||||
|
$builder = $this->db->table('subscription');
|
||||||
|
$builder->select('schemes.scheme_name,from_subscription,to_subscription');
|
||||||
|
$builder->join('schemes', 'schemes.scheme_id = subscription.scheme_id');
|
||||||
|
// Query to retrieve subscription records for a specific customer
|
||||||
|
return $builder->get()->getResultArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,9 +4,34 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h4 class="header-title"><?= $page_name; ?></h4>
|
<h4 class="header-title"><?= $page_name; ?></h4>
|
||||||
<p class="sub-header"> </p>
|
<p class="sub-header"> </p>
|
||||||
|
|
||||||
|
<ul class="nav nav-tabs" id="customerTabs" role="tablist">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" id="customerDetails-tab" data-toggle="tab" href="#customerDetails"
|
||||||
|
role="tab" aria-controls="customerDetails" aria-selected="true">Customer Details</a>
|
||||||
|
</li>
|
||||||
|
<?php if ($page_name === 'Edit Customer'): ?>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link active" id="subscriptionDetails-tab" data-toggle="tab"
|
||||||
|
href="#subscriptionDetails" role="tab" aria-controls="subscriptionDetails"
|
||||||
|
aria-selected="false">Subscription Details</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" id="invoiceDetails-tab" data-toggle="tab" href="#invoiceDetails"
|
||||||
|
role="tab" aria-controls="invoiceDetails" aria-selected="false">Invoice Details</a>
|
||||||
|
</li>
|
||||||
|
<?php endif; ?>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class="tab-content">
|
||||||
|
<!-- Customer Details Tab -->
|
||||||
|
<div class="tab-pane fade show active" id="customerDetails" role="tabpanel" aria-labelledby="customerDetails-tab">
|
||||||
|
<!-- Customer details form fields -->
|
||||||
<form class="needs-validation" novalidate method="POST" enctype="multipart/form-data"
|
<form class="needs-validation" novalidate method="POST" enctype="multipart/form-data"
|
||||||
action="<?php echo base_url(); ?>insert_customer">
|
action="<?php echo base_url(); ?>insert_customer">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
||||||
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="cfname" class="col-form-label">First Name<span
|
<label for="cfname" class="col-form-label">First Name<span
|
||||||
@ -58,9 +83,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="gen" class="col-form-label">Gender<span class="text-danger">*</span></label>
|
<label for="gen" class="col-form-label">Gender<span class="text-danger">*</span></label>
|
||||||
<input type="rad" class="form-control" name="gen"
|
<select class="form-control" name="gen" required>
|
||||||
value="<?= isset($customer['gender']) ? $customer['gender'] : '' ?>"
|
<option> Select the Gender</option>
|
||||||
placeholder="Gender" required />
|
<option value="male" <?= isset($customer['gender']) && $customer['gender'] == 'male' ? 'selected' : '' ?>>Male</option>
|
||||||
|
<option value="female" <?= isset($customer['gender']) && $customer['gender'] == 'female' ? 'selected' : '' ?>>Female</option>
|
||||||
|
</select>
|
||||||
<div class="invalid-feedback"> Please provide. </div>
|
<div class="invalid-feedback"> Please provide. </div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -68,16 +95,18 @@
|
|||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="ctype" class="col-form-label">Type<span class="text-danger">*</span></label>
|
<label for="ctype" class="col-form-label">Type<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" name="ctype"
|
<select class="form-control" name="ctype" required>
|
||||||
value="<?= isset($customer['type']) ? $customer['type'] : '' ?>"
|
<option value="customer" <?= isset($customer['type']) && $customer['type'] == 'customer' ? 'selected' : '' ?>>Customer</option>
|
||||||
placeholder="Customer/Subscriebr" required />
|
<option value="subscriber" <?= isset($customer['type']) && $customer['type'] == 'subscriber' ? 'selected' : '' ?>>Subscriber</option>
|
||||||
|
</select>
|
||||||
<div class="invalid-feedback"> Please provide. </div>
|
<div class="invalid-feedback"> Please provide. </div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="cmode" class="col-form-label">Mode<span class="text-danger">*</span></label>
|
<label for="cmode" class="col-form-label">Mode<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" name="cmode"
|
<select class="form-control" name="cmode" required>
|
||||||
value="<?= isset($customer['mode']) ? $customer['mode'] : '' ?>"
|
<option value="online" <?= isset($customer['mode']) && $customer['mode'] == 'online' ? 'selected' : '' ?>>Online</option>
|
||||||
placeholder="Mode (Online/Offline)" required />
|
<option value="offline" <?= isset($customer['mode']) && $customer['mode'] == 'offline' ? 'selected' : '' ?>>Offline</option>
|
||||||
|
</select>
|
||||||
<div class="invalid-feedback"> Please provide. </div>
|
<div class="invalid-feedback"> Please provide. </div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -240,6 +269,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
<input type="hidden" id="scustomer_address_id" name="scustomer_address_id[]"
|
<input type="hidden" id="scustomer_address_id" name="scustomer_address_id[]"
|
||||||
@ -273,10 +303,72 @@
|
|||||||
<a href="<?= base_url() . "customer_list"; ?>"
|
<a href="<?= base_url() . "customer_list"; ?>"
|
||||||
class="btn btn-secondary waves-effect">Cancel</a>
|
class="btn btn-secondary waves-effect">Cancel</a>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Display Subscription Details -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Add subscription details content here -->
|
||||||
|
<!-- You can fetch and display subscription details here -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div> <!-- end card-body-->
|
</div> <!-- end card-body-->
|
||||||
</div> <!-- end card-->
|
|
||||||
</div> <!-- end col-->
|
<div class="tab-pane fade show active" id="subscriptionDetails" role="tabpanel" aria-labelledby="subscriptionDetails-tab">
|
||||||
|
<?php if (!empty($subscriptionData)): ?>
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Subscription Name</th>
|
||||||
|
<th>Duration</th>
|
||||||
|
<th>Amount</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($subscriptionData as $subscription): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?= $subscription['scheme_name']; ?></td>
|
||||||
|
<td><?= $subscription['from_subscription']; ?></td>
|
||||||
|
<td><?= $subscription['to_subscription']; ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php else : ?>
|
||||||
|
<p>No subscriptions found for this customer.</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<div class="tab-pane fade" id="invoiceDetails" role="tabpanel" aria-labelledby="invoiceDetails-tab">
|
||||||
|
<?php if (!empty($invoices)): ?>
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Invoice Number</th>
|
||||||
|
<th>Invoice Date</th>
|
||||||
|
<th>Subtotal</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($invoices as $value): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?= $value->invoice_number ?></td>
|
||||||
|
<td><?= $value->invoice_date ?></td>
|
||||||
|
<td><?= $value->subtotal ?></td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php else : ?>
|
||||||
|
<p>No subscriptions found for this customer.</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
$("#copyToBillingCheckbox").on("change", function() {
|
$("#copyToBillingCheckbox").on("change", function() {
|
||||||
@ -391,3 +483,15 @@
|
|||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
// Show the Subscription Details tab by default
|
||||||
|
$('#subscriptionDetails-tab').tab('show');
|
||||||
|
|
||||||
|
// Handle tab switching
|
||||||
|
$('#customerTabs a').on('click', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
$(this).tab('show');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@ -1,3 +1,13 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.discount-header {
|
||||||
|
text-align: center; /* Add this to center-align the content */
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@ -9,7 +19,7 @@
|
|||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="customerName">Customer Name</label>
|
<label for="customerName">Customer Name</label>
|
||||||
<select class="form-control" id="customerName" name="customer_name">
|
<select class="form-control" id="customerName" name="customer_name"required>
|
||||||
<option value="">Select a customer</option>
|
<option value="">Select a customer</option>
|
||||||
<?php foreach ($customers as $customer) : ?>
|
<?php foreach ($customers as $customer) : ?>
|
||||||
<option value="<?= $customer->customer_id ?>"
|
<option value="<?= $customer->customer_id ?>"
|
||||||
@ -17,13 +27,16 @@
|
|||||||
<?= $customer->first_name.' '.$customer->last_name; ?></option>
|
<?= $customer->first_name.' '.$customer->last_name; ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="invalid-feedback"> Please select customer. </div>
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="loadShippingDropdown">Shipping Address</label>
|
<label for="loadShippingDropdown">Shipping Address</label>
|
||||||
<select class="form-control" id="loadShippingDropdown" name="shipping_address_id">
|
<select class="form-control" id="loadShippingDropdown" name="shipping_address_id"required>
|
||||||
<option value="">Select an address</option>
|
<option value="">Select an address</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="invalid-feedback"> Please select shipping address. </div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
@ -95,7 +108,7 @@
|
|||||||
<th>Rate</th>
|
<th>Rate</th>
|
||||||
<th>Tax</th>
|
<th>Tax</th>
|
||||||
<th>Amount </th>
|
<th>Amount </th>
|
||||||
<th colspan="2">Discount</th>
|
<th class="discount-header" colspan="2">Discount</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -104,7 +117,7 @@
|
|||||||
<?php if(!empty($invoice_item_details)){ foreach ($invoice_item_details as $ii_details): ?>
|
<?php if(!empty($invoice_item_details)){ foreach ($invoice_item_details as $ii_details): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><select class="form-control" id="book" name="item_details[]"
|
<td><select class="form-control" id="book" name="item_details[]"
|
||||||
onchange="displayBookTag(this)">
|
onchange="displayBookTag(this)"required>
|
||||||
<option value="">Select a book</option>
|
<option value="">Select a book</option>
|
||||||
<?php foreach ($books as $book) : ?>
|
<?php foreach ($books as $book) : ?>
|
||||||
<option value="<?= $book->book_id ?>"
|
<option value="<?= $book->book_id ?>"
|
||||||
@ -159,7 +172,7 @@
|
|||||||
id="tax" name="tax[]" /></td>
|
id="tax" name="tax[]" /></td>
|
||||||
<td style="width:12%;"><input type="text" class="form-control item-amount"
|
<td style="width:12%;"><input type="text" class="form-control item-amount"
|
||||||
id="amount" name="amount[]" /></td>
|
id="amount" name="amount[]" /></td>
|
||||||
<td style="width:12%;"><input type="text"
|
<td class="discount-cell" style="width:12%;"><input type="text"
|
||||||
class="form-control item-discount-amount" name="discount_amount[]"
|
class="form-control item-discount-amount" name="discount_amount[]"
|
||||||
oninput="calculateInvoice(this)" />
|
oninput="calculateInvoice(this)" />
|
||||||
|
|
||||||
@ -205,6 +218,11 @@
|
|||||||
readonly
|
readonly
|
||||||
value="<?= isset($invoice_details['tax']) ? $invoice_details['tax'] : '' ?>">
|
value="<?= isset($invoice_details['tax']) ? $invoice_details['tax'] : '' ?>">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="shippingCharges">Shipping Charges:</label>
|
||||||
|
<input type="number" class="form-control" id="shippingCharges" name="shippingCharges" oninput="calculateOverallTotals()">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="discount">Discount</label>
|
<label for="discount">Discount</label>
|
||||||
@ -223,7 +241,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group text-left col-md-12 ">
|
<div class="form-group text-left col-md-12 ">
|
||||||
<label for="terms">Terms & Conditions</label>
|
<label for="terms">Notes</label>
|
||||||
<textarea class="form-control" id="terms" name="terms"></textarea>
|
<textarea class="form-control" id="terms" name="terms"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -347,13 +365,13 @@ function calculateInvoice(inputElement) {
|
|||||||
if (discountType === '₹') {
|
if (discountType === '₹') {
|
||||||
// Calculate discount based on ₹
|
// Calculate discount based on ₹
|
||||||
var discountedAmount = amount - discountAmount;
|
var discountedAmount = amount - discountAmount;
|
||||||
row.querySelector('#amount').value = discountedAmount.toFixed(2); // Format to two decimal places
|
row.querySelector('#amount').value = amount.toFixed(2);
|
||||||
} else if (discountType === '%') {
|
} else if (discountType === '%') {
|
||||||
// Calculate discount based on %
|
// Calculate discount based on %
|
||||||
var discountPercentage = discountAmount;
|
var discountPercentage = discountAmount;
|
||||||
var discountValue = (amount * discountPercentage) / 100;
|
var discountValue = (amount * discountPercentage) / 100;
|
||||||
var discountedAmount = amount - discountValue;
|
var discountedAmount = amount - discountValue;
|
||||||
row.querySelector('#amount').value = discountedAmount.toFixed(2);
|
row.querySelector('#amount').value = amount.toFixed(2);
|
||||||
} else {
|
} else {
|
||||||
// Invalid discount type
|
// Invalid discount type
|
||||||
row.querySelector('#amount').value = amount.toFixed(2); // No discount applied
|
row.querySelector('#amount').value = amount.toFixed(2); // No discount applied
|
||||||
@ -393,7 +411,15 @@ function calculateOverallTotals() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update the overall amount, tax, and discount in the calculation card
|
// Get the shipping charges value, tax, and discount values
|
||||||
|
var shippingCharges = parseFloat(document.getElementById('shippingCharges').value) || 0;
|
||||||
|
var tax = parseFloat($("#invoicetax").val()) || 0;
|
||||||
|
var discount = parseFloat($("#discount").val()) || 0;
|
||||||
|
|
||||||
|
// Calculate the total using the formula: subtotal - tax + shipping - discount
|
||||||
|
var total = overallAmount - overallTax + shippingCharges - overallDiscount;
|
||||||
|
|
||||||
|
// Update the subtotal, tax, shipping charges, discount, and total in the calculation card
|
||||||
var subtotalElement = overallAmount.toFixed(2);
|
var subtotalElement = overallAmount.toFixed(2);
|
||||||
$("#subtotal").val(subtotalElement);
|
$("#subtotal").val(subtotalElement);
|
||||||
|
|
||||||
@ -403,9 +429,11 @@ function calculateOverallTotals() {
|
|||||||
var discountElement = overallDiscount.toFixed(2);
|
var discountElement = overallDiscount.toFixed(2);
|
||||||
$("#discount").val(discountElement);
|
$("#discount").val(discountElement);
|
||||||
|
|
||||||
// Calculate the grand total using the overall amount, tax, and discount
|
var totalElement = total.toFixed(2);
|
||||||
calculateGrandTotal(overallAmount, overallTax, overallDiscount);
|
$("#grandtotal").val(totalElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Define a function to calculate the grand total
|
// Define a function to calculate the grand total
|
||||||
// Define a function to calculate the grand total
|
// Define a function to calculate the grand total
|
||||||
function calculateGrandTotal() {
|
function calculateGrandTotal() {
|
||||||
@ -698,3 +726,5 @@ $(document).ready(function() {
|
|||||||
document.getElementById('status').value = 'Approved';
|
document.getElementById('status').value = 'Approved';
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|||||||
@ -117,17 +117,42 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="<?= base_url()."user_list"; ?>">
|
<a href="<?= base_url()."invoice_list"; ?>">
|
||||||
<i class="ri-user-line"></i>
|
<i class="fe-file-text"></i>
|
||||||
<span> Users </span>
|
<span> Invoices </span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="<?= base_url()."customer_list"; ?>">
|
||||||
|
<i class="ri-map-pin-user-fill"></i>
|
||||||
|
<span> Customer </span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="<?= base_url()."subscribers_list"; ?>">
|
||||||
|
<i class="ri-shield-user-line"></i>
|
||||||
|
<span>Subscription </span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="<?= base_url()."scheme_list"; ?>">
|
||||||
|
<i class="ri-currency-line"></i>
|
||||||
|
<span> Scheme </span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="<?= base_url()."book_list"; ?>">
|
<a href="<?= base_url()."book_list"; ?>">
|
||||||
<i class=" ri-book-open-line"></i>
|
<i class=" ri-book-open-line"></i>
|
||||||
<span> Books </span>
|
<span> Products </span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="<?= base_url()."user_list"; ?>">
|
||||||
|
<i class="ri-user-line"></i>
|
||||||
|
<span> Users </span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
<?php if($loggedin_person_role === 'sadmin'){ ?>
|
<?php if($loggedin_person_role === 'sadmin'){ ?>
|
||||||
<li>
|
<li>
|
||||||
<a href="<?= base_url()."sitesetting_list"; ?>">
|
<a href="<?= base_url()."sitesetting_list"; ?>">
|
||||||
@ -142,12 +167,7 @@
|
|||||||
<span> Business </span>
|
<span> Business </span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<a href="<?= base_url()."customer_list"; ?>">
|
|
||||||
<i class="ri-map-pin-user-fill"></i>
|
|
||||||
<span> Customer </span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<a href="<?= base_url()."event_list"; ?>">
|
<a href="<?= base_url()."event_list"; ?>">
|
||||||
|
|
||||||
@ -155,29 +175,13 @@
|
|||||||
<span> Campaign </span>
|
<span> Campaign </span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<a href="<?= base_url()."invoice_list"; ?>">
|
|
||||||
<i class="fe-file-text"></i>
|
|
||||||
<span> Invoices </span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<li>
|
|
||||||
<a href="<?= base_url()."scheme_list"; ?>">
|
|
||||||
<i class="ri-currency-line"></i>
|
|
||||||
<span> Scheme </span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li>
|
|
||||||
<a href="<?= base_url()."subscribers_list"; ?>">
|
|
||||||
<i class="ri-shield-user-line"></i>
|
|
||||||
<span>Subscription </span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a href="<?= base_url()."mail_custom_notifications"; ?>">
|
<a href="<?= base_url()."mail_custom_notifications"; ?>">
|
||||||
|
|||||||
@ -38,10 +38,10 @@
|
|||||||
<input data-parsley-type="alphanum" type="text" class="form-control" id="last_name" name="last_name" placeholder="Last Name" value="<?= isset($details['last_name']) ? $details['last_name'] : '' ?>" required />
|
<input data-parsley-type="alphanum" type="text" class="form-control" id="last_name" name="last_name" placeholder="Last Name" value="<?= isset($details['last_name']) ? $details['last_name'] : '' ?>" required />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="date_of_birth" class="col-form-label">Date Of Birth<span class="text-danger"></span></label>
|
<label for="date_of_birth" class="col-form-label">Date Of Birth<span class="text-danger">*</span></label>
|
||||||
<input type="date" class="form-control" id="date_of_birth" name="date_of_birth" placeholder="Date Of birth (format : DD/MM/YYYY)" data-toggle="input-mask" data-mask-format="00/00/0000" value="<?= isset($details['date_of_birth']) ? $details['date_of_birth'] : '' ?>" />
|
<input type="date" class="form-control" id="date_of_birth" name="date_of_birth" placeholder="Date Of birth (format : DD/MM/YYYY)" data-toggle="input-mask" data-mask-format="00/00/0000" required />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
|
|
||||||
@ -51,16 +51,29 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- ... (other form elements) ... -->
|
||||||
|
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="gender" class="col-form-label">Gender</label>
|
<label for="gender" class="col-form-label">Gender<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" id="gender" name="gender" placeholder="Gender" value="<?= isset($details['gender']) ? $details['gender'] : '' ?>" />
|
<select id="gender" name="gender" class="form-control" required>
|
||||||
|
<option value="">Select Gender</option>
|
||||||
|
<option value="male" <?= isset($details['gender']) && $details['gender'] === 'male' ? 'selected' : '' ?>>Male</option>
|
||||||
|
<option value="female" <?= isset($details['gender']) && $details['gender'] === 'female' ? 'selected' : '' ?>>Female</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="role" class="col-form-label">Role<span class="text-danger">*</span></label>
|
<label for="role" class="col-form-label">Role<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" id="role" name="role" placeholder="Role" required value="<?= isset($details['role']) ? $details['role'] : '' ?>" autofocus />
|
<select id="role" name="role" class="form-control" required>
|
||||||
|
<option value="">Select Role</option>
|
||||||
|
<option value="admin" <?= isset($details['role']) && $details['role'] === 'admin' ? 'selected' : '' ?>>Admin</option>
|
||||||
|
<option value="manager" <?= isset($details['role']) && $details['role'] === 'manager' ? 'selected' : '' ?>>Manager</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- ... (rest of the form) ... -->
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="address" class="col-form-label">Address<span class="text-danger">*</span></label>
|
<label for="address" class="col-form-label">Address<span class="text-danger">*</span></label>
|
||||||
@ -136,3 +149,29 @@
|
|||||||
</div> <!-- end card-->
|
</div> <!-- end card-->
|
||||||
</div> <!-- end col-->
|
</div> <!-- end col-->
|
||||||
</div><!-- end row -->
|
</div><!-- end row -->
|
||||||
|
<script>
|
||||||
|
// Get the current date in "yyyy-mm-dd" format
|
||||||
|
function getCurrentDate() {
|
||||||
|
const today = new Date();
|
||||||
|
const year = today.getFullYear();
|
||||||
|
let month = today.getMonth() + 1;
|
||||||
|
let day = today.getDate();
|
||||||
|
|
||||||
|
// Add leading zeros if month or day is less than 10
|
||||||
|
if (month < 10) {
|
||||||
|
month = '0' + month;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (day < 10) {
|
||||||
|
day = '0' + day;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${year}-${month}-${day}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the max attribute of the date input field to the current date
|
||||||
|
document.getElementById('date_of_birth').setAttribute('max', getCurrentDate());
|
||||||
|
|
||||||
|
// Set the min attribute of the date input field to "1965-01-01"
|
||||||
|
document.getElementById('date_of_birth').setAttribute('min', '1965-01-01');
|
||||||
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user