FEATURE SUBSCRIPTION RENEWAL ADDED

This commit is contained in:
Srinivas-Saravanan 2024-11-05 16:05:44 +05:30
parent a5b98afcb7
commit aa15c5ad80
11 changed files with 357 additions and 17 deletions

View File

@ -187,7 +187,10 @@ $routes->post('api/(:any)', 'ApiIntegration::api_integration/$1');
$routes->get('get_country', 'Customer::get_country_list');
$routes->post('qucik_add_addresses', 'Customer::qucik_add_addresses');
#Payment Routes
$routes->match(['get','post'],'/subscription_renewal','Payment::index/');
$routes->match(['get','post'],'/transaction','Payment::transaction/');
$routes->match(['get','post'],'/subscription_renewal/(:any)','Payment::index/$1');
// $routes->group("api", function ($routes) {
// // $routes->post("create_products/", "ApiIntegration::save_book_details");

View File

@ -65,7 +65,7 @@ abstract class BaseController extends Controller
echo "This is a command-line request.";
// echo $requestedRoute;
} else {
if ($requestedRoute !== '/login' && $requestedRoute !== '/authenticate' && $requestedRoute !== '/auth_confirm_mail' && $requestedRoute !== '/auth_reset_password' && $requestedRoute !== 'auth_reset_password_save' && $uri->getSegment(1) != 'getExpCustomerDetail'&& $uri->getSegment(1) != 'download_invoice_pdf') {
if ($requestedRoute !== '/login' && $requestedRoute !== '/authenticate' && $requestedRoute !== '/auth_confirm_mail' && $requestedRoute !== '/auth_reset_password' && $requestedRoute !== 'auth_reset_password_save' && $requestedRoute !== '/subscription_renewal' && strpos($requestedRoute, '/subscription_renewal/') === false && $uri->getSegment(1) != 'getExpCustomerDetail'&& $uri->getSegment(1) != 'download_invoice_pdf') {
$this->authData = $this->session_log();
}
}

View File

@ -622,7 +622,7 @@ class Notifications extends BaseController
$emailContent = str_replace("{USER_NAME}", $fullName, $emailContent);
$emailContent = str_replace("{SCHEME_NAME}", $schemename, $emailContent);
$emailContent = str_replace("{EXPIRY_DATE}", $expirydate, $emailContent);
$emailData = [
'template_name' => 'EXPIRAY_NOTIFY_TEMPLATE_EMAIL',
'recipient_email' => $row['email'],

View File

@ -0,0 +1,60 @@
<?php
namespace App\Controllers;
use App\Models\CustomerModel;
use App\Models\SchemeModel;
use App\Models\SubscriptionModel;
class Payment extends BaseController
{
public function index($subscriptionID = null)
{
$model = new CustomerModel();
$model2 = new SubscriptionModel();
if ($subscriptionID != null){
$customer_details = $model->get_customer_details_by_customer_id($subscriptionID);
$scheme = $model2->get_subscription_details_by_customerID($subscriptionID);
$response = [
'customer_details' => $customer_details,
'scheme' => $scheme,
'subscriptionID' =>$subscriptionID
];
return view('subscription_renewal',$response);
}
else{
if ($this->request->getMethod() == 'get') {
return view('subscription_renewal');
}
else {
//echo "inside else";die();
$customer_id = $this->request->getPost('customerID');
$customer_details = $model->get_customer_details_by_customer_id($customer_id);
$scheme = $model2->get_subscription_details_by_customerID($customer_id);
$response = [
'customer_details' => $customer_details,
'scheme' => $scheme
];
//var_dump($response);die();
return $this->response->setJSON($response);
}
}
}
public function transaction(){
$price = $this->request->getPost('subscriptionPrice');
$result = [
'price'=>$price
];
//var_dump($price);die();
return view('transaction',$result);
}
}

View File

@ -259,5 +259,16 @@ public function storeCustomerAddresses($billingAddress, $shippingAddress)
return ["billing_addr_id"=>$billing_addr_id,"shipping_addr_id"=>$shipping_addr_id]; // Return true indicating successful insertion
}
public function get_customer_details_by_customer_id($customer_id)
{
$builder = $this->db->table('customers'); // Specify the main table
$builder->select('customers.customer_id, customers.mobile_no,customers.first_name, customers.last_name,customers.mobile_no,customer_addresses.address_1, customer_addresses.city, customer_addresses.state, customer_addresses.postal_code, customer_addresses.country',customer);
$builder->join('customer_addresses', 'customers.customer_id = customer_addresses.customer_address_id');
$builder->where('customers.customer_id', $customer_id);
$result = $builder->get()->getRowArray(); // Fetch the first matching record as an associative array
return $result;
}
}
?>

View File

@ -338,7 +338,17 @@ public function getQueryforSubscriptionDetailsBySchemeName($flag,$condition, $va
$query = $builder->get();
return $query->getResult();
}
public function get_subscription_details_by_customerID($customerID)
{
$builder = $this->db->table('subscription');
$builder->select('subscription.from_subscription, subscription.to_subscription, subscription.scheme_id,books.price ,books.short_code');
$builder->join('books', 'subscription.scheme_id = books.book_id', 'left');
$builder->where('subscription.customer_id', $customerID);
$result = $builder->get()->getRowArray();
return $result;
}

View File

@ -162,17 +162,22 @@
<td><?= $e['short_code']; ?></td>
<td><span class="badge badge-success badge-pill"><?= $daysincountstring; ?></span> <span class="font-13"><br><?= $e['to_subscription_date_format']; ?></span></td>
<td>
<?php
$notifications = $e['notifications'];
$lastNotification = end($notifications);
$lastStartDateTime = (!$lastNotification)? '':['start_date_time'];
$startDateTime = isset($lastStartDateTime) ? $lastStartDateTime : '';
echo $startDateTime ? date('d/m/Y', strtotime($startDateTime)) : '';
?>
<script>
var lastNotification = <?=$lastNotification?>lastNotification
console.log(lastNotification);
</script>
<?php
$notifications = $e['notifications'];
$lastNotification = end($notifications);
$lastStartDateTime = ($lastNotification && isset($lastNotification['start_date_time'])) ? $lastNotification['start_date_time'] : '';
$startDateTime = $lastStartDateTime ? $lastStartDateTime : '';
echo ($startDateTime) ? date('d/m/Y', strtotime($startDateTime)) : '';
?>
<?php
/*
<script>
var lastNotification = <?= empty($lastNotification) ? '' : json_encode($lastNotification) ?>;
console.log(lastNotification);
</script>
*/
?>
</td>
</tr>
<?php endforeach; else : ?>

View File

@ -82,6 +82,15 @@ input[type=number] {
/* input[type="date"] {
-moz-appearance: textfield;
} */
.modal {
position: fixed;
top: 0; /* Adjust this value to move it further down */
left: 50%;
transform: translateX(-50%);
z-index: 1050; /* Ensure it appears above other content */
}
</style>
<?php $flag_name = $invoice_type === '1' ? " Books" : " Scheme";
@ -856,7 +865,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
<!-- Creating a model for new custome alert box -->
<!-- Custom Alert Modal -->
<div class="modal fade" id="customAlertModal" tabindex="-1" role="dialog" aria-labelledby="customAlertLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="customAlertLabel">Alert</h5>
@ -873,6 +882,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {

View File

@ -0,0 +1,202 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Subscription Renewal</title>
<!-- Bootstrap CSS -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
background-color: #f8f9fa;
margin: 0;
padding: 0;
font-size: 0.9rem;
}
.container {
padding: 10px;
}
.card {
margin: 20px auto;
max-width: 90%;
padding: 15px;
}
.card-header {
background-color: #007bff;
color: white;
padding: 10px;
font-size: 1.2rem;
}
.footer {
text-align: center;
margin-top: 20px;
font-size: 0.7rem;
}
.subscription-status {
font-size: 0.85rem;
color: #6c757d;
}
.hidden-details {
margin-top: 10px;
}
.form-group {
margin-bottom: 10px;
}
p {
margin: 0;
}
</style>
</head>
<body>
<div class="container">
<div class="card">
<div class="card-header text-center">
<h4 class="mb-1">Subscription Renewal</h4>
</div>
<!-- <p class="text-center" style="font-size: 0.8rem;">Please fill in your details to renew your subscription.</p> -->
<div class="card-body">
<form action="<?= base_url('transaction') ?>" method="post">
<div class="form-group">
<label for="CustomerID">Subscription ID</label>
<input type="text" value="<?= isset($subscriptionID) && ($subscriptionID != null) ? $subscriptionID : '' ?>" class="form-control" id="CustomerID" name="CustomerID" placeholder="Enter your Subscription ID" required>
</div>
<!-- Customer Information Section (Hidden Initially) -->
<div id="customerInfo" class="hidden-details d-none">
<div>
<p id="customerName">N/A</p>
<p id="customerMobile">N/A</p>
<p id="customerAddress">N/A</p>
</div>
</div>
<!-- Subscription Plans and Expiration Message -->
<div class="mt-3">
<h5 class="subscription-status text-center" id="expirationMessage"></h5><br>
<h5 class="mb-2">Renewal Options</h5>
<div class="form-group">
<select required class="form-control" id="subscriptionPlans">
<option value="" disabled selected>Select a plan</option>
<option value="1500">PUSTHAKAM Membership - 1 Year (RENEWAL) - ₹1500</option>
</select>
</div>
</div>
<div class="text-center">
<button type="submit" class="btn btn-primary btn-block">Proceed to Pay</button>
</div>
</form>
</div>
</div>
</div>
<div class="footer">
<p>&copy; 2023 - 2024 Vijayabharatham Prasuram. All rights reserved.</p>
</div>
<!-- AJAX Script -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script>
<?php
if (isset($subscriptionID)){?>
$(document).ready(function(){
var customerID = $('#CustomerID').val();
$.ajax({
type: 'POST',
url: "<?= base_url('/subscription_renewal') ?>",
data: {customerID: customerID},
dataType: 'json',
success: function(response) {
if (response.customer_details) {
// Populate the information
$('#customerName').text(response.customer_details.first_name+"," || 'N/A');
$('#customerMobile').text(response.customer_details.mobile_no+"," || 'N/A');
$('#customerAddress').text(
[
response.customer_details.address_1,
response.customer_details.city,
response.customer_details.state,
response.customer_details.country
].filter(Boolean).join(', ')
);
// Display customer information
$('#customerInfo').removeClass('d-none');
if (response.scheme) {
// Calculate expiration
var date = new Date();
var remaining = new Date(response.scheme.to_subscription);
var remainingDays = Math.ceil((remaining - date) / (1000 * 60 * 60 * 24));
var expirationMessage = '';
if (remainingDays > 0) {
expirationMessage = 'Your Subscription plan "' + response.scheme.short_code + '" is going to expire in ' + remainingDays +
' days on ' + remaining.toLocaleDateString('en-GB') + '.';
} else {
remainingDays = Math.abs(remainingDays);
expirationMessage = 'Your Subscription plan "' + response.scheme.short_code + '" has already expired ' + remainingDays +
' days ago on ' + remaining.toLocaleDateString('en-GB') + '.';
}
$('#expirationMessage').text(expirationMessage);
}
}
},
error: function() {
alert('Error retrieving customer details. Please try again.');
}
});
});
<?php } ?>
$(document).ready(function(){
$('#CustomerID').on('change', function(){
var customerID = $(this).val();
$.ajax({
type: 'POST',
url: "<?= base_url('/subscription_renewal') ?>",
data: {customerID: customerID},
dataType: 'json',
success: function(response) {
if (response.customer_details) {
// Populate the information
$('#customerName').text(response.customer_details.first_name+"," || 'N/A');
$('#customerMobile').text(response.customer_details.mobile_no+"," || 'N/A');
$('#customerAddress').text(
[
response.customer_details.address_1,
response.customer_details.city,
response.customer_details.state,
response.customer_details.country
].filter(Boolean).join(', ')
);
// Display customer information
$('#customerInfo').removeClass('d-none');
if (response.scheme) {
// Calculate expiration
var date = new Date();
var remaining = new Date(response.scheme.to_subscription);
var remainingDays = Math.ceil((remaining - date) / (1000 * 60 * 60 * 24));
var expirationMessage = '';
if (remainingDays > 0) {
expirationMessage = 'Your Subscription plan "' + response.scheme.short_code + '" is going to expire in ' + remainingDays +
' days on ' + remaining.toLocaleDateString('en-GB') + '.';
} else {
remainingDays = Math.abs(remainingDays);
expirationMessage = 'Your Subscription plan "' + response.scheme.short_code + '" has already expired ' + remainingDays +
' days ago on ' + remaining.toLocaleDateString('en-GB') + '.';
}
$('#expirationMessage').text(expirationMessage);
}
}
},
error: function() {
alert('Error retrieving customer details. Please try again.');
}
});
});
});
</script>
<!-- Bootstrap JS and dependencies -->
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.0.7/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>

View File

@ -139,7 +139,7 @@
<li>A breach or violation of any of the Terms will result in an immediate termination of your Services.</li>
</ul>
<p><strong>Section 2 General Conditions</strong></p>
<ul>
<ul>bro is this okay?
<li>We reserve the right to refuse service to anyone for any reason at any time.</li>
<li>You understand that your content (not including credit card information), may be transferred unencrypted and involve (a) transmissions over various networks; and (b) changes to conform and adapt to technical requirements of connecting networks or devices. Credit card information is always encrypted during transfer over networks.</li>
<li>You agree not to reproduce, duplicate, copy, sell, resell or exploit any portion of the Service, use of the Service, or access to the Service or any contact on the website through which the service is provided, without express written permission by us.</li>

39
app/Views/transaction.php Normal file
View File

@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Payment Response</title>
<!-- Bootstrap CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<style>
.payment-success {
margin-top: 50px;
text-align: center;
color: #28a745; /* Bootstrap's success color */
}
.info-text {
font-size: 1.1rem;
}
</style>
</head>
<body>
<div class="container payment-success">
<div class="card shadow-sm">
<div class="card-body">
<h2 class="card-title text-success">Payment Success!</h2>
<p class="card-text info-text">Thank you! Your payment of Rs. <strong><?= htmlspecialchars($price) ?></strong> has been received.</p>
<p class="card-text info-text">Order ID: <strong><?= htmlspecialchars(isset($orderID) ? $orderID : "") ?></strong></p>
<p class="card-text info-text">Transaction ID: <strong><?= htmlspecialchars(isset($transactionID) ? $transactionID : "") ?></strong></p>
<p class="card-text info-text">Your scheme <strong><?= htmlspecialchars(isset($scheme) ? $scheme : "") ?></strong> is renewed up to <strong>[Renewal Date]</strong>.</p>
</div>
</div>
</div>
<!-- Bootstrap JS and dependencies -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>