Merge branch 'uat' of bitbucket.org:venbainformationtechnology/vb_book into uat
This commit is contained in:
commit
4cb8a45994
@ -197,7 +197,6 @@ $routes->match(['get','post'],'/response','Payment::response/');
|
||||
$routes->get('/payment_failure', 'Payment::payment_failure');
|
||||
$routes->get('/payment_success','Payment::payment_success');
|
||||
$routes->match(['get','post'],'/subscription_renewal/(:any)','Payment::index/$1');
|
||||
|
||||
// $routes->group("api", function ($routes) {
|
||||
// // $routes->post("create_products/", "ApiIntegration::save_book_details");
|
||||
// // $routes->match(['put', 'post', 'get', 'delete'], 'products', 'ApiIntegration::book_api_integration');
|
||||
|
||||
@ -130,7 +130,6 @@ class Invoice extends BaseController
|
||||
$data['customer_shipping_arr'] = $this->get_customer_address($where, $select);
|
||||
$data['invoice_item_details'] = $this->get_invoice_item($id);
|
||||
}
|
||||
|
||||
$this->render_page('invoice_form', $data);
|
||||
}
|
||||
|
||||
@ -380,7 +379,6 @@ class Invoice extends BaseController
|
||||
helper('session');
|
||||
helper('financial_year_helper');
|
||||
$this->logger->info("Invoice: Insert/Update Details");
|
||||
|
||||
try {
|
||||
// Retrieve form data
|
||||
$invoice_status = $this->request->getPost('status');
|
||||
@ -404,7 +402,9 @@ class Invoice extends BaseController
|
||||
|
||||
// Handle subscription if invoice type is subscription
|
||||
if ((int)$invoiceType === 2) {
|
||||
$this->create_or_update_subscription($invoice_id,$invoice_status, $msg_flag_name);
|
||||
$membership = (!empty($this->request->getPost('membership_id'))) ? $this->request->getPost('membership_id') : "";
|
||||
$membership_id = substr($membership,0,6);
|
||||
$this->create_or_update_subscription($invoice_id,$invoice_status, $msg_flag_name,$membership_id);
|
||||
}
|
||||
|
||||
// Send notification if invoice is approved
|
||||
@ -523,14 +523,16 @@ public function generate_membership_id($length = 6) {
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
public function create_or_update_subscription($invoice_id,$invoice_status, $msg_flag_name = null)
|
||||
public function create_or_update_subscription($invoice_id,$invoice_status, $msg_flag_name = null,$membership_id = null)
|
||||
{
|
||||
$model = new InvoiceModel();
|
||||
$subModel = new SubscriptionModel();
|
||||
$customer_id = (int)$this->request->getPost('customer_name');
|
||||
$invoiceItems = $this->get_invoice_item($invoice_id);
|
||||
$renewal = 0;
|
||||
|
||||
if (!empty($membership_id)){
|
||||
$sub_id = $subModel->select('sub_id')->where('membership_id',$membership_id)->first();
|
||||
}
|
||||
foreach ($invoiceItems as $item) {
|
||||
$product_id = $item['product'];
|
||||
$from_sub_date = $item['from_subscription'];
|
||||
@ -556,7 +558,7 @@ public function create_or_update_subscription($invoice_id,$invoice_status, $msg_
|
||||
'business_id' => get_business_id(),
|
||||
'created_by' => get_logged_user_id(),
|
||||
'updated_by' => get_logged_user_id(),
|
||||
'is_renew' => $renewal,
|
||||
'is_renew' => isset($sub_id)?$sub_id['sub_id']:$renewal,
|
||||
'membership_id'=>$membership_id,
|
||||
'status' =>1,
|
||||
'isactive' =>$invoice_status === 'Approved' ? 1 : 0
|
||||
|
||||
@ -81,7 +81,6 @@ class Payment extends BaseController
|
||||
$ORDER_ID = (string) uniqid($CUST_ID . "_".$membership_id."_");
|
||||
$CHANNEL_ID = ($payment_method == "mobile") ? (string) env('Channel_ID_Mobile') : (string) env('Channel_ID_WEB');
|
||||
$TXN_AMOUNT = (string) $this->request->getPost("amount");
|
||||
|
||||
$paramList["MID"] = (string) env('Merchant_ID');
|
||||
$paramList["ORDER_ID"] = $ORDER_ID;
|
||||
$paramList["CUST_ID"] = $CUST_ID;
|
||||
@ -103,7 +102,7 @@ class Payment extends BaseController
|
||||
public function tresponse() {
|
||||
$paytmChecksum = "";
|
||||
$paramList = $_POST;
|
||||
print_r($paramList);
|
||||
//print_r($paramList);
|
||||
$isValidChecksum = "FALSE";
|
||||
$paramList = $_POST;
|
||||
// dd($paramList);
|
||||
@ -165,7 +164,7 @@ public function payment_success() {
|
||||
$ORDER_ID = $this->request->getVar('ORDERID');
|
||||
$parts = explode('_', $ORDER_ID);
|
||||
$customer_id = (int)$parts[0];
|
||||
$past_membership_id = (int)$parts[1];
|
||||
$past_membership_id = $parts[1];
|
||||
$payment_method = $this->request->getVar('PAYMENTMODE');
|
||||
//dd($past_membership_id);
|
||||
// $parts = explode('_', $ORDER_ID);
|
||||
@ -253,19 +252,19 @@ public function payment_success() {
|
||||
// $membership_id = $invoice->generate_membership_id(6);
|
||||
// }
|
||||
|
||||
$subscription = $subModel->select('sub_id')->where('membersip_id',$past_membership_id)->first();
|
||||
$subscription = $subModel->select('sub_id')->where('membership_id',$past_membership_id)->first();
|
||||
$subscriptionData = [
|
||||
'scheme_id' =>3,
|
||||
'customer_id' => $customer_id,
|
||||
'invoice_id' => $invoice_id,
|
||||
'from_subscription'=>$fsubscription,
|
||||
'to_subscription'=>$tsubscription,
|
||||
'is_renew' => $subscription['sub_id'],
|
||||
'business_id'=>2,
|
||||
'status' =>1,
|
||||
'membership_id' =>$membership_id,
|
||||
'isactive' =>1,
|
||||
'business_id' =>2
|
||||
'scheme_id' => 3,
|
||||
'customer_id' => $customer_id,
|
||||
'invoice_id' => $invoice_id,
|
||||
'from_subscription'=> $fsubscription,
|
||||
'to_subscription' => $tsubscription,
|
||||
'is_renew' => $subscription['sub_id'],
|
||||
'business_id' => 2,
|
||||
'status' => 1,
|
||||
'membership_id' => $membership_id,
|
||||
'isactive' => 1,
|
||||
'business_id' => 2
|
||||
|
||||
];
|
||||
$db->table('subscription')->insert($subscriptionData);
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Controllers\Books;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
|
||||
@ -291,7 +293,7 @@ public function getJoinedData($where, $orderby = [])
|
||||
->join('books as BK', 'BK.book_id = S.scheme_id', 'left')
|
||||
->join('book_categories as BC', 'BC.book_id = S.scheme_id', 'left')
|
||||
->join('category as CM', 'CM.id = BC.category_id', 'left')
|
||||
->select('S.customer_id, CONCAT_WS(" ", C.first_name, C.last_name) as customer_name, S.sub_id, S.scheme_id, DATE_FORMAT(S.from_subscription, "%d/%m/%Y") AS formatted_from_subscription, DATE_FORMAT(S.to_subscription, "%d/%m/%Y") AS formatted_to_subscription, S.from_subscription, S.to_subscription,S.isactive,S.is_renew, S.created_on, CM.name, BK.title, BK.book_id')
|
||||
->select('S.customer_id,BK.short_code,S.membership_id ,CONCAT_WS(" ", C.first_name, C.last_name) as customer_name, S.sub_id, S.scheme_id, DATE_FORMAT(S.from_subscription, "%d/%m/%Y") AS formatted_from_subscription, DATE_FORMAT(S.to_subscription, "%d/%m/%Y") AS formatted_to_subscription, S.from_subscription, S.to_subscription,S.isactive,S.is_renew, S.created_on, CM.name ,BK.title, BK.book_id')
|
||||
->where('LOWER(CM.name)', strtolower($category))
|
||||
->where('S.customer_id', $id)
|
||||
->orderBy('S.to_subscription', 'ASC')
|
||||
|
||||
@ -245,6 +245,12 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-5">
|
||||
<label for="event" class="col-form-label">Select Membership ID to Renew</label>
|
||||
<select class="form-control" id="membership_id" name="membership_id">
|
||||
<option value="">No Existing Membership ID</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
@ -1579,20 +1585,58 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
|
||||
success: function(response) {
|
||||
cm = response['data']['customer_membership'];
|
||||
console.log(cm);
|
||||
console.log(cm);
|
||||
cm.sort(function(a, b) {
|
||||
return b.is_renew - a.is_renew;n
|
||||
return b.is_renew - a.is_renew;
|
||||
});
|
||||
if (cm.length > 0) {
|
||||
$(".subscribedetails").show();
|
||||
let messages = "Earlier Membership : <br>";
|
||||
text1 = cm[0].is_renew >0 ? " - Renewed" : "";
|
||||
text2 = cm[0].status == 0 ? " - Expried" : "";
|
||||
$(".subscribedetails").show(); // Change this line to use the class selector
|
||||
let messages = "Earlier Membership : <br>";
|
||||
for (let i = 0; i < cm.length; i++) {
|
||||
let text1 = cm[i].is_renew == 1 ? " - Renewal" : "";
|
||||
let text2 = cm[i].isactive == 1 ? " - Active" : " - Draft ";
|
||||
messages += cm[i].title + "<br> ( From: " + cm[i].formatted_from_subscription + " To: " + cm[i].formatted_to_subscription + " )" + text1 + text2 + " <br>";
|
||||
}
|
||||
showAlert(messages.trim());
|
||||
}
|
||||
else {
|
||||
// $("#schemeName").text(message);
|
||||
$('#membership_id').empty();
|
||||
$('#membership_id').prop('required',true);
|
||||
$('#membership_id').append('<option value = "">Select a Existing Membership ID</option>');
|
||||
for(i=0;i<cm.length;i++){
|
||||
membership_id = cm[i].membership_id;
|
||||
|
||||
console.log(membership_id);
|
||||
$('#membership_id').append('<option value="' + membership_id+i + '">' +cm[i].short_code + ' - '+ membership_id+' ' +cm[i].formatted_from_subscription + " To: " + cm[i].formatted_to_subscription +'</option>');
|
||||
}
|
||||
$('#membership_id').on('change', function () {
|
||||
var output = $('#membership_id').val();console.log(membership_choice);
|
||||
var membership_choice = output.charAt(output.length-1);
|
||||
var rawDate = cm[membership_choice].formatted_to_subscription;
|
||||
var dateParts = rawDate.split('/');
|
||||
var prev_fsubscription = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
|
||||
|
||||
prev_fsubscription.setDate(prev_fsubscription.getDate() + 1);
|
||||
var fsubscription = (prev_fsubscription.getDate()).toString().padStart(2, '0') + '/' +
|
||||
(prev_fsubscription.getMonth() + 1).toString().padStart(2, '0') + '/' +
|
||||
prev_fsubscription.getFullYear();
|
||||
|
||||
$('#fromsubcription').val(fsubscription).prop('readonly', true);
|
||||
|
||||
prev_fsubscription.setFullYear(prev_fsubscription.getFullYear() + 1);
|
||||
var tsubscription = (prev_fsubscription.getDate()).toString().padStart(2, '0') + '/' +
|
||||
(prev_fsubscription.getMonth() + 1).toString().padStart(2, '0') + '/' +
|
||||
prev_fsubscription.getFullYear();
|
||||
|
||||
$('#tosubcription').val(tsubscription).prop('readonly', true);
|
||||
$('#book0').empty();
|
||||
$('#book0').append('<option value="<?= $books[1]->book_id ?>"><?= $books[1]->title; ?></option>');
|
||||
$('#book0').prop('readonly',true);
|
||||
var element = $('#book0')[0]; // Get the actual DOM element (not the value)
|
||||
displayBookTag(element, 0);
|
||||
});
|
||||
showAlert(messages.trim());
|
||||
} else {
|
||||
$(".subscribedetails").show(); // Change this line to use the class selector
|
||||
let message = "No Earlier Membership found";
|
||||
//$("#schemeName").text(message);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user