heama
This commit is contained in:
parent
1fbef1b7ed
commit
8ea1d07d0f
@ -290,4 +290,5 @@ class Customer extends BaseController
|
||||
echo "<center><a href=".$go_to_list_page.">go to list page</a></center>";
|
||||
// return $message;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,27 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
|
||||
use App\Models\EventModel;
|
||||
use App\Models\CustomerModel;
|
||||
use App\Models\InvoiceModel;
|
||||
|
||||
|
||||
class Invoice extends BaseController
|
||||
{
|
||||
public function index()
|
||||
|
||||
{
|
||||
|
||||
$data['page_name'] = 'Invoice Details';
|
||||
$data['invoice'] = [];
|
||||
public function index()
|
||||
{
|
||||
helper('session');
|
||||
if (is_session_active()) {
|
||||
$session_role = get_user_role();
|
||||
$session_bid = get_business_id();
|
||||
|
||||
if (!empty($session_role) && $session_role !== "sadmin") {
|
||||
$where = ['invoice.business_id'=>(int)$session_bid];
|
||||
}else{ $where = ['invoice.business_id != '=>NULL];}
|
||||
|
||||
$InvoiceModel = new InvoiceModel();
|
||||
$data['page_name'] = 'Invoice Details';
|
||||
// $data['subscriber'] = $SubscriptionModel->where($where)->findAll();;
|
||||
// $data['invoice'] = $InvoiceModel->getAllSubscribersWithNames($where);
|
||||
|
||||
$this->render_page('invoice_list', $data);
|
||||
|
||||
}else {
|
||||
return redirect()->to('login');
|
||||
}
|
||||
}
|
||||
public function new_invoice()
|
||||
{
|
||||
$data['page_name'] = 'Invoice Details';
|
||||
|
||||
$this->render_page('invoice_form',$data);
|
||||
|
||||
|
||||
public function new_invoice()
|
||||
{
|
||||
helper('session');
|
||||
$session_bid = get_business_id();
|
||||
$data['page_name'] = 'Invoice Details';
|
||||
$customerModel = new CustomerModel();
|
||||
$eventModel = new EventModel();
|
||||
|
||||
$business_id = get_business_id();
|
||||
|
||||
// Get customer names for the dropdown
|
||||
$data['customers'] = $customerModel->getCustomerNamesByBusiness($business_id);
|
||||
$data['events']= $eventModel->getEventnamesByBusiness($business_id);
|
||||
// Initialize billing and shipping addresses as empty
|
||||
$data['billingAddress'] = '';
|
||||
$data['shippingAddress'] = '';
|
||||
|
||||
$this->render_page('invoice_form', $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -26,7 +26,7 @@ class Subscription extends BaseController
|
||||
$data['subscriber'] = $SubscriptionModel->getAllSubscribersWithNames($where);
|
||||
|
||||
$this->render_page('subscribers_list', $data);
|
||||
}else {
|
||||
}else {
|
||||
return redirect()->to('login');
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,5 +90,6 @@ class CustomerModel extends Model
|
||||
$dataToUpdate = ['isactive' => 0];
|
||||
$this->db->table('customer_addresses')->where($where)->whereIn('customer_address_id',$missingValues)->update($dataToUpdate);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@ -10,7 +10,16 @@ class EventModel extends Model
|
||||
protected $table = 'events';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = ['id','event_name','next_id','left_pad','id_formating','created_by','created_on','updated_on' ,'updated_by','business_id'];
|
||||
|
||||
|
||||
|
||||
|
||||
public function getEventnamesByBusiness($business_id)
|
||||
{
|
||||
$this->builder()->select('id,event_name');
|
||||
$this->builder()->where('business_id ', $business_id); // Filter by business_id
|
||||
$query = $this->builder()->get(); // Use findAll() instead of get()
|
||||
return ($query->getResult());
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
16
app/Models/InvoiceModel.php
Normal file
16
app/Models/InvoiceModel.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
|
||||
class InvoiceModel extends Model
|
||||
{
|
||||
protected $table = 'invoice';
|
||||
protected $primaryKey = 'invoice_id';
|
||||
protected $allowedFields = ['invoice_id','invoice_number','customer_id','invoice_date','event_id','business_id','created_on','business_id'];
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,218 +1,240 @@
|
||||
<html>
|
||||
<body>
|
||||
<style>
|
||||
.align-to-right {
|
||||
float: right;
|
||||
padding:30px;
|
||||
|
||||
}
|
||||
.btn btn-primary{
|
||||
text-align:right;
|
||||
}
|
||||
<body>
|
||||
<style>
|
||||
.align-to-right {
|
||||
float: right;
|
||||
padding: 30px;
|
||||
|
||||
</style>
|
||||
|
||||
}
|
||||
|
||||
.btn btn-primary {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title"><?= $page_name; ?></h4>
|
||||
<p class="sub-header"> </p>
|
||||
<form class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?php echo base_url(); ?>insert_event">
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="customerName">Customer Name</label>
|
||||
<select class="form-control" id="customerName">
|
||||
<!-- Populate this dropdown with customer names -->
|
||||
<option>Customer 1</option>
|
||||
<option>Customer 2</option>
|
||||
<!-- Add more options as needed -->
|
||||
</select>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title"><?= $page_name; ?></h4>
|
||||
<p class="sub-header"> </p>
|
||||
<form class="needs-validation" novalidate method="POST" enctype="multipart/form-data"
|
||||
action="<?php echo base_url(); ?>insert_event">
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="customerName">Customer Name</label>
|
||||
<select class="form-control" id="customerName" onchange="updateCustomerDetails()">
|
||||
<option value="">Select a customer</option>
|
||||
<?php foreach ($customers as $customer): ?>
|
||||
<option value="<?= $customer->customer_id ?>"><?= $customer->full_name ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="shipping">Shipping Address</label>
|
||||
<select class="form-control" id="shipping">
|
||||
<!-- Populate this dropdown with customer names -->
|
||||
<option>Address 1</option>
|
||||
<option>Address 2</option>
|
||||
<!-- Add more options as needed -->
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="customerAddress">Billing Address</label>
|
||||
<textarea class="form-control"id="customerAddress" readonly></textarea>
|
||||
<!-- JavaScript will populate this field based on the selected customer -->
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="subject">Shipping Address</label>
|
||||
<textarea class="form-control" id="shippingaaddress"></textarea>
|
||||
</div>
|
||||
<label for="shipping">Shipping Address</label>
|
||||
<select class="form-control" id="shipping">
|
||||
<!-- Populate this dropdown with customer names -->
|
||||
<option>Address 1</option>
|
||||
<option>Address 2</option>
|
||||
<!-- Add more options as needed -->
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="customerAddress">Billing Address</label>
|
||||
<textarea class="form-control" id="customerAddress" readonly></textarea>
|
||||
<!-- JavaScript will populate this field based on the selected customer -->
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="subject">Shipping Address</label>
|
||||
<textarea class="form-control" id="shippingaaddress"></textarea>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="invoiceNumber">Invoice Number</label>
|
||||
<input type="text" class="form-control" id="invoiceNumber">
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="orderNumber">Order Number</label>
|
||||
<input type="text" class="form-control" id="orderNumber">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="invoiceNumber">Invoice Number</label>
|
||||
<input type="text" class="form-control" id="invoiceNumber">
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="orderNumber">Order Number</label>
|
||||
<input type="text" class="form-control" id="orderNumber">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="invoiceDate">Invoice Date</label>
|
||||
<input type="date" class="form-control" id="invoiceDate">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="dueDate">Due Date</label>
|
||||
<input type="date" class="form-control" id="dueDate">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<label for="invoiceDate">Invoice Date</label>
|
||||
<input type="date" class="form-control" id="invoiceDate">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="dueDate">Due Date</label>
|
||||
<input type="date" class="form-control" id="dueDate">
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<div class="row">
|
||||
|
||||
<!-- <button style="float: right;"><i class="fa fa-plus" aria-hidden="true"></i></button> -->
|
||||
<div class="col-lg-12">
|
||||
<h5>Item Details</h5>
|
||||
<button style="float:right;" id="addItem"><i class="fa fa-plus" aria-hidden="true"></i></button>
|
||||
<br>
|
||||
<table class="table table-bordered"id="itemTable">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Item Details</th>
|
||||
<th>Quantity</th>
|
||||
<th>Rate</th>
|
||||
<th>Tax</th>
|
||||
<th>Amount </th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- Dynamically add rows for item details -->
|
||||
<tr>
|
||||
<td><input type="text" class="form-control" name="itemDetails[]"></td>
|
||||
<td><input type="text" class="form-control" name="quantity[]"></td>
|
||||
<td><input type="text" class="form-control" name="rate[]"></td>
|
||||
<td><input type="text" class="form-control" name="tax[]"></td>
|
||||
<td><input type="text" class="form-control" name="amount[]"></td>
|
||||
<td><i class="fa fa-trash remove-item "></td>
|
||||
|
||||
</tr>
|
||||
<!-- You can add more rows as needed using JavaScript -->
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Calculation Card -->
|
||||
|
||||
<div class="align-to-right">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4>Calculation</h4>
|
||||
<div class="form-group">
|
||||
<label for="subtotal">Subtotal</label>
|
||||
<input type="text" class="form-control" id="subtotal" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="tax">Tax Amount</label>
|
||||
<input type="text" class="form-control" id="tax" readonly>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="events" class="col-form-label">Events<span
|
||||
class="text-danger">*</span></label>
|
||||
<select class="form-control" id="event" name="events" required>
|
||||
<option value="">Select Events</option>
|
||||
<?php foreach ($events as $event): ?>
|
||||
<option value="<?= $event->id ?>"><?= $event->event_name ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<div class="invalid-feedback"> Please select a customer. </div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="discount">Discount</label>
|
||||
<input type="text" class="form-control" id="discount">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="total">Total</label>
|
||||
<input type="text" class="form-control" id="total" readonly>
|
||||
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
<div class="row">
|
||||
|
||||
<!-- <button style="float: right;"><i class="fa fa-plus" aria-hidden="true"></i></button> -->
|
||||
<div class="col-lg-12">
|
||||
<h5>Item Details</h5>
|
||||
|
||||
<br>
|
||||
<table class="table table-bordered" id="itemTable">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Item Details</th>
|
||||
<th>Quantity</th>
|
||||
<th>Rate</th>
|
||||
<th>Tax</th>
|
||||
<th>Amount </th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- Dynamically add rows for item details -->
|
||||
<tr>
|
||||
<td><input type="text" class="form-control" name="itemDetails[]"></td>
|
||||
<td><input type="text" class="form-control" name="quantity[]"></td>
|
||||
<td><input type="text" class="form-control" name="rate[]"></td>
|
||||
<td><input type="text" class="form-control" name="tax[]"></td>
|
||||
<td><input type="text" class="form-control" name="amount[]"></td>
|
||||
<td><i class="fa fa-trash remove-item "></td>
|
||||
|
||||
</tr>
|
||||
<!-- You can add more rows as needed using JavaScript -->
|
||||
</tbody>
|
||||
</table>
|
||||
<button style="float:left;" id="addItem"><i class="fa fa-plus"
|
||||
aria-hidden="true"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Calculation Card -->
|
||||
|
||||
<div class="align-to-right">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4>Calculation</h4>
|
||||
<div class="form-group">
|
||||
<label for="subtotal">Subtotal</label>
|
||||
<input type="text" class="form-control" id="subtotal" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="tax">Tax Amount</label>
|
||||
<input type="text" class="form-control" id="tax" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="discount">Discount</label>
|
||||
<input type="text" class="form-control" id="discount">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="total">Total</label>
|
||||
<input type="text" class="form-control" id="total" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="form-group text-left col-md-5 ">
|
||||
<label for="terms">Terms & Conditions</label>
|
||||
<textarea class="form-control" id="terms" readonly></textarea>
|
||||
<label for="terms">Terms & Conditions</label>
|
||||
<textarea class="form-control" id="terms" readonly></textarea>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button class="btn btn-success waves-effect waves-light mr-1" type="submit">
|
||||
Submit
|
||||
</button>
|
||||
<button type="reset" class="btn btn-primary waves-effect mr-1">
|
||||
Reset
|
||||
</button>
|
||||
|
||||
<!-- Save Button -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button class="btn btn-success waves-effect waves-light mr-1" type="submit">
|
||||
Submit
|
||||
</button>
|
||||
<button type="reset" class="btn btn-primary waves-effect mr-1">
|
||||
Reset
|
||||
</button>
|
||||
|
||||
<!-- Save Button --> </div>
|
||||
|
||||
</div>
|
||||
<script>
|
||||
document.getElementById("addItem").addEventListener("click", function() {
|
||||
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
|
||||
var newRow = table.insertRow(table.rows.length);
|
||||
|
||||
</div>
|
||||
var cell1 = newRow.insertCell(0);
|
||||
var cell2 = newRow.insertCell(1);
|
||||
var cell3 = newRow.insertCell(2);
|
||||
var cell4 = newRow.insertCell(3);
|
||||
var cell5 = newRow.insertCell(4);
|
||||
var cell6 = newRow.insertCell(5);
|
||||
cell1.innerHTML = '<input type="text" class="form-control" name="itemDetails[]">';
|
||||
cell2.innerHTML = '<input type="text" class="form-control" name="quantity[]">';
|
||||
cell3.innerHTML = '<input type="text" class="form-control" name="rate[]">';
|
||||
cell4.innerHTML = '<input type="text" class="form-control" name="tax[]">';
|
||||
cell5.innerHTML = '<input type="text" class="form-control" name="amount[]">';
|
||||
cell6.innerHTML = '<i class="fa fa-trash remove-item ">';
|
||||
|
||||
|
||||
// Attach the calculateInvoice function to new input fields' change events
|
||||
cell1.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
cell2.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
cell3.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
cell4.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<script>
|
||||
document.getElementById("addItem").addEventListener("click", function () {
|
||||
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
|
||||
var newRow = table.insertRow(table.rows.length);
|
||||
|
||||
var cell1 = newRow.insertCell(0);
|
||||
var cell2 = newRow.insertCell(1);
|
||||
var cell3 = newRow.insertCell(2);
|
||||
var cell4 = newRow.insertCell(3);
|
||||
var cell5 = newRow.insertCell(4);
|
||||
var cell6 = newRow.insertCell(5);
|
||||
cell1.innerHTML = '<input type="text" class="form-control" name="itemDetails[]">';
|
||||
cell2.innerHTML = '<input type="text" class="form-control" name="quantity[]">';
|
||||
cell3.innerHTML = '<input type="text" class="form-control" name="rate[]">';
|
||||
cell4.innerHTML = '<input type="text" class="form-control" name="tax[]">';
|
||||
cell5.innerHTML = '<input type="text" class="form-control" name="amount[]">';
|
||||
cell6.innerHTML = '<i class="fa fa-trash remove-item ">';
|
||||
|
||||
|
||||
// Attach the calculateInvoice function to new input fields' change events
|
||||
cell1.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
cell2.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
cell3.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
cell4.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<!-- JavaScript for removing a row from the table -->
|
||||
<script>
|
||||
<script>
|
||||
// Function to remove a row from the table
|
||||
function removeItem(row) {
|
||||
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
|
||||
@ -221,26 +243,15 @@ document.getElementById("addItem").addEventListener("click", function () {
|
||||
}
|
||||
|
||||
// Attach the removeItem function to the Remove buttons using event delegation
|
||||
document.querySelector("#itemTable tbody").addEventListener("click", function (event) {
|
||||
document.querySelector("#itemTable tbody").addEventListener("click", function(event) {
|
||||
if (event.target.classList.contains("remove-item")) {
|
||||
var row = event.target.closest("tr"); // Find the closest row to the clicked button
|
||||
removeItem(row);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</html>
|
||||
Loading…
Reference in New Issue
Block a user