This commit is contained in:
heama 2023-09-05 17:16:30 +05:30
parent 892d142f43
commit 51536fb769
17 changed files with 1030 additions and 158 deletions

View File

@ -77,6 +77,25 @@ $routes->get("scheme_list/", "Scheme::index");
$routes->get("new_scheme/(:any)", "Scheme::new_scheme/$1");
$routes->post("insert_scheme/", "Scheme::insert_scheme");
$routes->get("delete_scheme/(:any)", "Scheme::delete_scheme/$1");
#subscription Routes
$routes->get("subscribers_list/", "Subscription::index");
$routes->get("new_subscription/", "Subscription::new_subscription/");
$routes->post("add_subscription/", "Subscription::add_subscription/");
#adres priknt
$routes->get('addressprint/', 'Address::index');
$routes->post('address/generatePdf', 'Address::generatePdf');
#evnts
$routes->get("event_list/", "Event::index");
$routes->get("new_event/(:any)", "Event::new_event/$1");
$routes->post("insert_event/", "Event::insert_event");
#invoices
$routes->get("invoice_list/", "Invoice::index");
$routes->get("new_invoice/", "Invoice::new_invoice/");
# Api integration Routes
$routes->get("apiintegration", "Home::apiintegration");

View File

@ -0,0 +1,54 @@
<?php
namespace App\Controllers;
use App\Models\CustomerModel;
class Address extends BaseController
{
public function index()
{
helper('session');
$customerModel = new CustomerModel();
$data['page_name'] = 'Customer Listing';
$data['customers'] = $customerModel->findAll();
return view('address_list', $data);
}
}
// public function generatePdf()
// {
// $customerModel = new CustomerModel();
// $customer_id = $this->request->getPost('customer_id');
// $customerData = $customerModel->find($customer_id);
// if ($customerData) {
// $options->set('isHtml5ParserEnabled', true);
// $options->set('isPhpEnabled', true);
// $dompdf = new Dompdf($options);
// $html = view('address_list', ['customerData' => $customerData]);
// $dompdf->loadHtml($html);
// $dompdf->setPaper('A4', 'portrait');
// $dompdf->render();
// $dompdf->stream('customer_information.pdf', ['Attachment' => 0]);
// } else {
// return redirect()->to('index');
// }
// }
// }

94
app/Controllers/Event.php Normal file
View File

@ -0,0 +1,94 @@
<?php
namespace App\Controllers;
use App\Models\EventModel;
class Event 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 = ['events.business_id' => (int)$session_bid];
} else {
$where = ['events.business_id != ' => NULL];
}
$EventModel = new EventModel();
$data['page_name'] = 'Event Details';
// $events = $EventModel->where($where)->orderBy('id', 'desc')->findAll(); // Retrieve the events
$events = $EventModel->where($where)->findAll(); // Retrieve the events
// Sort the events by ID in descending order (newest first)
// usort($events, function ($a, $b) {
// return $b['id'] - $a['id'];
// });
$data['event'] = $events; // Assign the sorted array to $data['event']
$this->render_page('event_list', $data);
} else {
return redirect()->to('login');
}
}
public function new_event($id)
{
helper('session');
$session_bid = get_business_id();
if ($id === '0') {
$data['page_name'] = 'Add Event';
$data['event'] = [];
} else if ($id !== '0') {
$data['page_name'] = 'Edit Scheme';
$model = new EventModel();
$model->setTable('events');
$edit_event_details = $model->where(['id' => $id])->first();
$data['event'] = $edit_event_details;
}
$data['session_bid'] = $session_bid;
$this->render_page('event_form', $data);
}
public function insert_event()
{
helper('session');
$session_bid = get_business_id();
$session_uid = get_logged_user_id();
$EventModel = new EventModel();
$data = [
'event_name' => $this->request->getPost('ename'),
'next_id' => $this->request->getPost('nextid'),
'left_pad' => $this->request->getPost('leftpad'),
'id_formating' => $this->request->getPost('formating'),
'business_id' => $this->request->getPost('business_id')
];
$event_id = $this->request->getPost('id'); // Get the business ID for update
if (empty($event_id)) {
// It's an insert operation
$data['created_by'] = $session_uid;
$EventModel->insert($data);
} else {
// It's an update operation
$data['updated_by'] = $session_uid;
$EventModel->update($event_id, $data);
}
return redirect()->route('event_list');
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace App\Controllers;
use App\Models\InvoiceModel;
class Invoice extends BaseController
{
public function index()
{
$data['page_name'] = 'Invoice Details';
$data['invoice'] = [];
$this->render_page('invoice_list', $data);
}
public function new_invoice()
{
$data['page_name'] = 'Invoice Details';
$this->render_page('invoice_form',$data);
}
}

View File

@ -0,0 +1,79 @@
<?php
namespace App\Controllers;
// use App\Models\SubscriptionModel;
use App\Models\CustomerModel;
use App\Models\SubscriptionModel;
use App\Models\SchemeModel;
class Subscription 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 = ['subscription.business_id'=>(int)$session_bid];
}else{ $where = ['subscription.business_id != '=>NULL];}
$SubscriptionModel = new SubscriptionModel();
$data['page_name'] = 'Subscription Details';
// $data['subscriber'] = $SubscriptionModel->where($where)->findAll();;
$data['subscriber'] = $SubscriptionModel->getAllSubscribersWithNames($where);
$this->render_page('subscribers_list', $data);
}else {
return redirect()->to('login');
}
}
public function new_subscription() {
helper('session');
helper('session');
$session_bid = get_business_id();
$data['page_name'] = 'Subscription Details';
$customerModel = new CustomerModel();
$schemeModel = new SchemeModel();
$business_id = get_business_id();
// Get scheme names and durations from the SchemeModel
$data['customers'] = $customerModel->getCustomerNamesByBusiness($business_id);
$data['scheme_names'] = $schemeModel->getSchemeNamesAndDurationsByBusiness($business_id);
//print_r($data);die();
$this->render_page('subscription_form', $data);
}
// Subscription Controller (Subscription.php)
public function add_subscription() {
helper('session');
$session_bid = get_business_id();
$session_uid = get_logged_user_id();
$SubscriptionModel = new SubscriptionModel();
$data = [
'scheme_id' =>$this->request->getPost('scheme'),
'customer_id' =>$this->request->getPost('customer'),
'from_subscription' => $this->request->getPost('from_date'),
'to_subscription' => $this->request->getPost('to_date'),
'mode' => $this->request->getPost('mode'),
'business_id'=>$session_bid
];
$SubscriptionModel->insert($data);
// $data['subscriber'] = $subscriberModel->getAllSubscribersWithNames();
// print_r($data);die();
return redirect()->to('subscribers_list')->with('data', $data);
}
}

View File

@ -15,5 +15,38 @@ class CustomerModel extends Model
{
return $this->insert($data);
}
}
?>
public function getCustomerNamesByBusiness($business_id)
{
$this->builder()->select('customer_id,CONCAT(first_name, " ", last_name) as full_name', false);
$this->builder()->where('business_id ', $business_id); // Filter by business_id
$query = $this->builder()->get(); // Use findAll() instead of get()
return ($query->getResult());
// $customerNames = [];
// foreach ($query->getResult() as $row) {
// $customerNames[] = [ $row->full_name ];
// }
// print_r($customerNames);
// die();
}
// public function getCustomerIdByName($customerName, $businessId)
// {
// $customer = $this->builder()
// ->select('customer_id')
// ->where('CONCAT(first_name, " ", last_name)', $customerName)
// ->where('business_id', $businessId)
// ->get()
// ->getRow();
// if ($customer) {
// return $customer->customer_id;
// }
// return null; // Customer not found
// }
}

16
app/Models/EventModel.php Normal file
View File

@ -0,0 +1,16 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
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'];
}
?>

View File

@ -15,5 +15,42 @@ class SchemeModel extends Model
{
return $this->insert($data);
}
public function getSchemeNamesAndDurationsByBusiness($business_id)
{
$builder = $this->builder();
$builder->select('scheme_id, scheme_name, duration');
$builder->where('business_id', $business_id);
$query = $builder->get();
$schemes = [];
foreach ($query->getResult() as $row) {
$schemes[$row->scheme_id] = [
'scheme_name' => $row->scheme_name,
'duration' => $row->duration,
];
}
return $schemes;
}
// public function getSchemeDuration($schemeId)
// {
// $query = $this->select('duration')
// ->where('scheme_id', $schemeId)
// ->get();
// if ($query->getNumRows() === 1) {
// $row = $query->getRow();
// return $row->duration;
// } else {
// return null;
// }
// }
}
?>

View File

@ -0,0 +1,25 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class SubscriptionModel extends Model
{
protected $table = 'subscription';
protected $primaryKey = 'sub_id';
protected $allowedFields = ['sub_id','scheme_id','customer_id','to_subscription','from_subscription','mode','created_on','business_id'];
public function getAllSubscribersWithNames($where)
{
$builder = $this->db->table('subscription');
$builder->select('subscription.*, schemes.scheme_name, CONCAT(customers.first_name, " ", customers.last_name) as customer_name');
$builder->join('schemes', 'schemes.scheme_id = subscription.scheme_id');
$builder->join('customers', 'customers.customer_id = subscription.customer_id');
$builder->where($where);
return $builder->get()->getResultArray();
}
}

View File

@ -0,0 +1,66 @@
<!-- plugin css -->
<link href="<?= base_url()."public/assets/libs/admin-resources/jquery.vectormap/jquery-jvectormap-1.2.2.css" ?>" rel="stylesheet" type="text/css" />
<!-- third party css -->
<link href="<?= base_url()."public/assets/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css" ?>" rel="stylesheet" type="text/css" />
<link href="<?= base_url()."public/assets/libs/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css" ?>" rel="stylesheet" type="text/css" />
<link href="<?= base_url()."public/assets/libs/datatables.net-buttons-bs4/css/buttons.bootstrap4.min.css" ?>" rel="stylesheet" type="text/css" />
<link href="<?= base_url()."public/assets/libs/datatables.net-select-bs4/css//select.bootstrap4.min.css" ?>" rel="stylesheet" type="text/css" />
<!-- third party css end -->
<!-- App css -->
<link href="<?= base_url()."public/assets/css/bootstrap.min.css" ?>" rel="stylesheet" type="text/css" id="bs-default-stylesheet" />
<link href="<?= base_url()."public/assets/css/app.min.css" ?>" rel="stylesheet" type="text/css" id="app-default-stylesheet" />
<link href="<?= base_url()."public/assets/css/bootstrap-dark.min.css" ?>" rel="stylesheet" type="text/css" id="bs-dark-stylesheet" />
<link href="<?= base_url()."public/assets/css/app-dark.min.css" ?>" rel="stylesheet" type="text/css" id="app-dark-stylesheet" />
<!-- icons -->
<link href="<?= base_url()."public/assets/css/icons.min.css" ?>" rel="stylesheet" type="text/css" />
</head>
<body class="loading">
<!-- Begin page -->
<div id="wrapper"> <!-- close div on footer.php -->
<!-- ========== Left Sidebar Start ========== -->
<div class="left-side-menu">
<!-- LOGO -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="float-right">
</div>
<br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
<div class="table-responsive">
<!-- <table id="basic-datatable" class="table dt-responsive w-100"> -->
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="thead-light">
<tr>
<th>Name</th>
<th>Author</th>
<th>Category</th>
<th>Language</th>
<th>Year Of Release</th>
<th>Price of the Book</th>
<th>Description</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
</table>
</div>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
<!-- end row-->

57
app/Views/event_form.php Normal file
View File

@ -0,0 +1,57 @@
<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="ename" class="col-form-label">Events Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="ename" value="<?= isset($event['event_name']) ? $event['event_name'] : '' ?>" placeholder="Event Name" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="formating" class="col-form-label">Identifier formatting<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="formating" value="<?= isset($event['id_formating']) ? $event['id_formating'] : '' ?>" placeholder="INV{{-0-}}" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="nextid" class="col-form-label">Next ID<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="nextid" value="<?= isset($event['next_id']) ? $event['next_id'] : '' ?>" placeholder="" required />
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group col-md-6">
<label for="leftpad" class="col-form-label">Left Pad<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="leftpad" placeholder="000" value="<?= isset($event['left_pad']) ? $event['left_pad'] : '' ?>"required >
<div class="invalid-feedback"> Please provide. </div>
</div>
</div>
<input type="hidden" id="id" name="id" placeholder="hidden for scheme id" value="<?= isset($event['id']) ? $event['id'] : '' ?>" />
<input type="hidden" id="business_id" name="business_id" placeholder="hidden for business id" value="<?= $session_bid ?>" />
<br>
<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>
<a href="<?= base_url() . "event_list"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
</div>
</div>
</form>
</div> <!-- end card-body-->
</div> <!-- end card-->
</div> <!-- end col-->
</div>
</div>
<!-- end row -->

51
app/Views/event_list.php Normal file
View File

@ -0,0 +1,51 @@
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="float-right">
<a href="new_event/0" class="btn btn-primary"><i class="fe-shopping-bag"></i> Add New </a>
</div><!-- end col-->
<br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
<div class="table-responsive">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="thead-light">
<tr>
<th>Event Name</th>
<th>Next ID</th>
<th>Left Pad</th>
<th>Action</th>
</tr>
</thead>
<?php foreach ($event as $value) :?>
<tr>
<td><?= $value['event_name']; ?></td>
<td><?= $value['next_id']; ?></td>
<td><?= $value['left_pad']; ?></td>
<td>
<a href="<?= "new_event/" . $value['id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div><!-- end row-->
<script>
$(document).ready(function() {
var table = $('#scroll-horizontal-datatable').DataTable({
"order": [[0, "dsc"]] // Sort by the first (index 0) column (id) in ascending order
});
});
</script>

246
app/Views/invoice_form.php Normal file
View File

@ -0,0 +1,246 @@
<html>
<body>
<style>
.align-to-right {
float: right;
padding:30px;
}
.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="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>
</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>
</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>
<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 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">
<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>
<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>
// Function to remove a row from the table
function removeItem(row) {
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
table.removeChild(row);
calculateInvoice(); // Call the calculation function to update the totals
}
// Attach the removeItem function to the Remove buttons using event delegation
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>
</body>
</html>

View File

@ -0,0 +1,39 @@
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="float-right">
<a href="new_invoice" class="btn btn-primary"><i class="fe-file-text"></i> Add New </a>
</div><!-- end col-->
<br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
<div class="table-responsive">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="thead-light">
<tr>
<th>Invoice Number</th>
<th>Invoice Date</th>
<th>Customer Name</th>
<th>Book Name</th>
<th>Quantity</th>
<th>Price</th>
<th>Discount</th>
<th>Tax</th>
<th>Total Value</th>
</tr>
</thead>
</table>
</div>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div><!-- end row-->

View File

@ -3,7 +3,7 @@
<div class="card">
<div class="card-body">
<div class="float-right">
<a href="add_subscribers" class="btn btn-primary"><i class="ri-shield-user-line"></i> Add New </a>
<a href="new_subscription" class="btn btn-primary"><i class="ri-shield-user-line"></i> Add New </a>
</div><!-- end col-->
<br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
@ -12,164 +12,27 @@
<!-- <table id="alternative-page-datatable" class="table table-borderless table-hover table-centered m-0"> -->
<!-- <table class="table table-borderless table-hover table-centered m-0"> -->
<!-- <table id="basic-datatable" class="table dt-responsive w-100"> -->
<table id="datatable-buttons" class="table dt-responsive w-100">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="thead-light">
<tr>
<th>Name</th>
<th>Author</th>
<th>Publisher</th>
<th>State/Country</th>
<th>Year Of Release</th>
<th>Status</th>
<th>Action</th>
<th>Scheme Name</th>
<th>Customer Name</th>
<th>Subscription From</th>
<th>Subscription To</th>
<th>Mode</th>
</tr>
</thead>
<tbody>
<?php foreach ($subscriber as $value) :?>
<tr>
<td>Tamil Book Term 1</td>
<td>Tiger Nixon</td>
<td>TamilNadu Education System</td>
<td>TamilNadu/India</td>
<td>2023</td>
<td>
<span class="badge badge-soft-danger">In-Active</span>
</td>
<td>
<a href="edit_subscribers" class="btn btn-xs btn-secondary"><i class="ri-pencil-line"></i></a>
</td>
</tr>
<tr>
<td>English Book term 1</td>
<td>Garrett</td>
<td>TamilNadu Education System</td>
<td>TamilNadu/India</td>
<td>2020</td>
<td>
<span class="badge badge-soft-success">Active</span>
</td>
<td>
<a href="edit_subscribers" class="btn btn-xs btn-secondary"><i class="ri-pencil-line"></i></a>
</td>
</tr>
<tr>
<td>Mathematics Book term 1</td>
<td>Tiger Nixon</td>
<td>TamilNadu Education System</td>
<td>TamilNadu/India</td>
<td>2023</td>
<td>
<span class="badge badge-soft-danger">In-Active</span>
</td>
<td>
<a href="edit_book" class="btn btn-xs btn-secondary"><i class="ri-pencil-line"></i></a>
</td>
</tr>
<tr>
<td>Sciences Book term 1</td>
<td>Garrett</td>
<td>TamilNadu Education System</td>
<td>TamilNadu/India</td>
<td>2020</td>
<td>
<span class="badge badge-soft-success">Active</span>
</td>
<td>
<a href="edit_book" class="btn btn-xs btn-secondary"><i class="ri-pencil-line"></i></a>
</td>
</tr>
<tr>
<td>Social Book term 1</td>
<td>Tiger Nixon</td>
<td>TamilNadu Education System</td>
<td>TamilNadu/India</td>
<td>2023</td>
<td>
<span class="badge badge-soft-danger">In-Active</span>
</td>
<td>
<a href="edit_book" class="btn btn-xs btn-secondary"><i class="ri-pencil-line"></i></a>
</td>
</tr>
<tr>
<td>Social Book term 2</td>
<td>Garrett</td>
<td>TamilNadu Education System</td>
<td>TamilNadu/India</td>
<td>2020</td>
<td>
<span class="badge badge-soft-success">Active</span>
</td>
<td>
<a href="edit_book" class="btn btn-xs btn-secondary"><i class="ri-pencil-line"></i></a>
</td>
</tr>
<tr>
<td>Science Book term 2 </td>
<td>Tiger Nixon</td>
<td>TamilNadu Education System</td>
<td>TamilNadu/India</td>
<td>2023</td>
<td>
<span class="badge badge-soft-danger">In-Active</span>
</td>
<td>
<a href="edit_book" class="btn btn-xs btn-secondary"><i class="ri-pencil-line"></i></a>
</td>
</tr>
<tr>
<td>Tamil Book Term 2</td>
<td>Tiger Nixon</td>
<td>TamilNadu Education System</td>
<td>TamilNadu/India</td>
<td>2023</td>
<td>
<span class="badge badge-soft-danger">In-Active</span>
</td>
<td>
<a href="edit_book" class="btn btn-xs btn-secondary"><i class="ri-pencil-line"></i></a>
</td>
</tr>
<tr>
<td>English Book term 2</td>
<td>Garrett</td>
<td>TamilNadu Education System</td>
<td>TamilNadu/India</td>
<td>2020</td>
<td>
<span class="badge badge-soft-success">Active</span>
</td>
<td>
<a href="edit_book" class="btn btn-xs btn-secondary"><i class="ri-pencil-line"></i></a>
</td>
</tr>
<tr>
<td>Science Book term 3 </td>
<td>Tiger Nixon</td>
<td>TamilNadu Education System</td>
<td>TamilNadu/India</td>
<td>2023</td>
<td>
<span class="badge badge-soft-danger">In-Active</span>
</td>
<td>
<a href="edit_book" class="btn btn-xs btn-secondary"><i class="ri-pencil-line"></i></a>
</td>
</tr>
<tr>
<td>Social Book term 3</td>
<td>Garrett</td>
<td>TamilNadu Education System</td>
<td>TamilNadu/India</td>
<td>2020</td>
<td>
<span class="badge badge-soft-success">Active</span>
</td>
<td>
<a href="edit_book" class="btn btn-xs btn-secondary"><i class="ri-pencil-line"></i></a>
</td>
</tr>
<td><?= $value['scheme_name']; ?></td>
<td><?= $value['customer_name']; ?></td>
<td><?= $value['from_subscription']; ?></td>
<td><?= $value['to_subscription']; ?></td>
<td><?= $value['mode']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
@ -177,4 +40,3 @@
</div> <!-- end card -->
</div><!-- end col-->
</div>
<!-- end row-->

View File

@ -0,0 +1,135 @@
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<!-- < -->
<p class="sub-header"> </p>
<form class="needs-validation" method="POST" enctype="multipart/form-data"
action="<?php echo base_url(); ?>add_subscription">
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-6">
<label for="scheme" class="col-form-label">Scheme<span
class="text-danger">*</span></label>
<select class="form-control" id="scheme" name="scheme" required>
<option value="">Select Scheme</option>
<?php foreach ($scheme_names as $scheme_id => $scheme_info): ?>
<option value="<?= $scheme_id ?>" data-duration="<?= $scheme_info['duration'] ?>">
<?= $scheme_info['scheme_name'] ?>
</option>
<?php endforeach; ?>
</select>
<div class="invalid-feedback"> Please select a scheme. </div>
</div>
<div class="form-group col-md-6">
<label for="customer" class="col-form-label">Customer<span
class="text-danger">*</span></label>
<select class="form-control" id="customer" name="customer" required>
<option value="">Select Customer</option>
<?php foreach ($customers as $customer): ?>
<option value="<?= $customer->customer_id ?>"><?= $customer->full_name ?></option>
<?php endforeach; ?>
</select>
<div class="invalid-feedback"> Please select a customer. </div>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="from_date" class="col-form-label">From Date<span
class="text-danger">*</span></label>
<input type="date" class="form-control" id="from_date" name="from_date" required
onchange="calculateToDate()">
<div class="invalid-feedback"> Please provide a from date. </div>
</div>
<input type="hidden" class="form-control" id="scheme_duration" name="scheme_duration"
required readonly>
<div class="form-group col-md-6">
<label for="to_date" class="col-form-label">To Date<span
class="text-danger">*</span></label>
<input type="date" class="form-control" id="to_date" name="to_date" required readonly>
<div class="invalid-feedback"> The "to date" will be auto-calculated based on the scheme
duration and "from date." </div>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="mode" class="col-form-label">Mode<span class="text-danger">*</span></label>
<select class="form-control" name="mode" required>
<option value="selct">select</option>
<option value="ONLINE">online</option>
<option value="OFFLINE">ofline</option>
</selct>
<div class="invalid-feedback"> Please provide. </div>
</div>
<div class="form-group text-right m-b-0 checkbox checkbox-purple">
<input type="hidden" id="isactive" name="isactive" class="form-control">
</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>
<a href="<?= base_url() . "subscribers_list"; ?>"
class="btn btn-secondary waves-effect">Cancel</a>
</div>
</div>
</form>
</div> <!-- end card-body-->
</div> <!-- end card-->
</div> <!-- end col-->
</div>
</div>
<!-- end row -->
<script>
function calculateToDate() {
const schemeSelect = document.getElementById('scheme');
const fromDatePicker = document.getElementById('from_date');
const schemeDurationInput = document.getElementById('scheme_duration');
const toDatePicker = document.getElementById('to_date');
// Check if a scheme is selected and a from date is provided
if (schemeSelect.value && fromDatePicker.value) {
const schemeDuration = parseInt(schemeSelect.options[schemeSelect.selectedIndex].getAttribute('data-duration'));
const fromDate = new Date(fromDatePicker.value);
// Calculate the "to date" based on the scheme duration
const toDate = new Date(fromDate);
toDate.setMonth(toDate.getMonth() + schemeDuration);
// Format the to date as 'YYYY-MM-DD' and set it in the toDatePicker
const year = toDate.getFullYear();
const month = String(toDate.getMonth() + 1).padStart(2, '0');
const day = String(toDate.getDate()).padStart(2, '0');
const formattedToDate = `${year}-${month}-${day}`;
toDatePicker.value = formattedToDate;
// Populate the scheme duration input
schemeDurationInput.value = schemeDuration;
} else {
// Clear the to date and scheme duration if no scheme or from date is selected
toDatePicker.value = '';
schemeDurationInput.value = '';
}
}
// Attach the 'calculateToDate' function to the 'from_date' input's change event
const fromDatePicker = document.getElementById('from_date');
fromDatePicker.addEventListener('change', calculateToDate);
</script>

View File

@ -150,14 +150,45 @@
<span> Customer </span>
</a>
</li>
<li>
<a href="<?= base_url()."event_list"; ?>">
<i class="fe-shopping-bag"></i>
<span> Events </span>
</a>
</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>
<a href="<?= base_url()."addressprint"; ?>">
<i class="bx bx-file"></i>
<span>Address Print </span>
</a>
</li>
</ul>
</div>
<!-- End Sidebar -->
@ -177,4 +208,5 @@
<div class="content-page"> <!-- close div on footer.php -->
<!-- ========== Header-file content-class Start here ========== -->
<div class="content"> <!-- close div on footer.php -->
<div class="content"> <!-- close div on footer.php -->