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()
|
||||
{
|
||||
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['invoice'] = [];
|
||||
// $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()
|
||||
{
|
||||
|
||||
|
||||
public function new_invoice()
|
||||
{
|
||||
helper('session');
|
||||
$session_bid = get_business_id();
|
||||
$data['page_name'] = 'Invoice Details';
|
||||
$customerModel = new CustomerModel();
|
||||
$eventModel = new EventModel();
|
||||
|
||||
$this->render_page('invoice_form',$data);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@ -12,5 +12,14 @@ class EventModel extends Model
|
||||
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,40 +1,43 @@
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<body>
|
||||
<style>
|
||||
.align-to-right {
|
||||
float: right;
|
||||
padding:30px;
|
||||
padding: 30px;
|
||||
|
||||
}
|
||||
.btn btn-primary{
|
||||
text-align:right;
|
||||
}
|
||||
}
|
||||
|
||||
.btn btn-primary {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="row">
|
||||
<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">
|
||||
<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 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>
|
||||
@ -47,31 +50,32 @@
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="form-row">
|
||||
</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>
|
||||
<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>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-6">
|
||||
</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">
|
||||
</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>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -81,25 +85,40 @@
|
||||
<div class="form-group col-md-6">
|
||||
<label for="invoiceDate">Invoice Date</label>
|
||||
<input type="date" class="form-control" id="invoiceDate">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="dueDate">Due Date</label>
|
||||
<input type="date" class="form-control" id="dueDate">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
|
||||
</form>
|
||||
<div class="row">
|
||||
|
||||
<!-- <button style="float: right;"><i class="fa fa-plus" aria-hidden="true"></i></button> -->
|
||||
|
||||
</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">
|
||||
<table class="table table-bordered" id="itemTable">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
@ -125,7 +144,8 @@
|
||||
<!-- 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>
|
||||
|
||||
@ -155,14 +175,19 @@
|
||||
</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>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group text-right m-b-0">
|
||||
</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>
|
||||
@ -170,19 +195,17 @@
|
||||
Reset
|
||||
</button>
|
||||
|
||||
<!-- Save Button --> </div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- Save Button -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<script>
|
||||
document.getElementById("addItem").addEventListener("click", function () {
|
||||
</div>
|
||||
<script>
|
||||
document.getElementById("addItem").addEventListener("click", function() {
|
||||
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
|
||||
var newRow = table.insertRow(table.rows.length);
|
||||
|
||||
@ -207,12 +230,11 @@ document.getElementById("addItem").addEventListener("click", function () {
|
||||
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>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user