Merge branch 'uat' of bitbucket.org:venbainformationtechnology/vb_book into uat
This commit is contained in:
commit
eddb83856d
@ -533,20 +533,24 @@ public function create_or_update_subscription($invoice_id,$invoice_status, $msg_
|
|||||||
$product_id = $item['product'];
|
$product_id = $item['product'];
|
||||||
$from_sub_date = $item['from_subscription'];
|
$from_sub_date = $item['from_subscription'];
|
||||||
$to_sub_date = $item['to_subscription'];
|
$to_sub_date = $item['to_subscription'];
|
||||||
$membership_id = $this->generate_membership_id(6);
|
//check if membership id is already set for the customer
|
||||||
$result = $subModel->where('membership_id',$membership_id)->findAll();
|
|
||||||
if (count($result)>0){
|
$membership = $subModel->check_existing_membership_id($customer_id);
|
||||||
$membership_id = $this->generate_membership_id(6);
|
//dd($membership);
|
||||||
|
if (count($membership)>0){
|
||||||
|
$member = (array)$membership[0];
|
||||||
|
//dd($member);
|
||||||
|
$membership_id = $member['membership_id'];
|
||||||
|
//dd($membership_id);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
$get_exists_subscription_where = ['S.customer_id' => (int)$customer_id, 'S.scheme_id' => $product_id, 'I.status' => 'Approved', 'I.isactive' => 1];
|
$membership_id = $this->generate_membership_id(6);
|
||||||
$get_exists_subscription_dtls = $model->existsSubscriptionDetails($get_exists_subscription_where);
|
// To check if the generated membership is already created for another customer
|
||||||
|
$result = $subModel->where('membership_id',$membership_id)->findAll();
|
||||||
// the scheme is already exists to the customer
|
if (count($result)>0){
|
||||||
if ($get_exists_subscription_dtls) {
|
$membership_id = $this->generate_membership_id(6);
|
||||||
$this->logger->info($msg_flag_name . ": This Scheme Already Existing in this Customer. ");
|
|
||||||
$renewal = 1;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Prepare subscription data
|
// Prepare subscription data
|
||||||
$subscription_data = [
|
$subscription_data = [
|
||||||
@ -563,8 +567,18 @@ public function create_or_update_subscription($invoice_id,$invoice_status, $msg_
|
|||||||
'status' =>1
|
'status' =>1
|
||||||
];
|
];
|
||||||
|
|
||||||
// Insert the subscription data
|
$check_existing_customer_id = $subModel->where('invoice_id',$invoice_id)->findAll();
|
||||||
$model->insertSubscriptionData($subscription_data,$invoice_status);
|
//dd($check_existing_customer_id);
|
||||||
|
if($check_existing_customer_id){
|
||||||
|
log_message('info',json_encode($subscription_data));
|
||||||
|
$where = ['invoice_id'=>$invoice_id];
|
||||||
|
$subModel->updateData($subscription_data,$where);//update the data
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//insert the data
|
||||||
|
$model->insertSubscriptionData($subscription_data,$invoice_status);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -167,6 +167,7 @@ public function payment_success() {
|
|||||||
$currentDate = date('Y-m-d');
|
$currentDate = date('Y-m-d');
|
||||||
|
|
||||||
// Assuming the model is used for database interactions
|
// Assuming the model is used for database interactions
|
||||||
|
$bookModel = new BooksModel();
|
||||||
$model = new InvoiceModel();
|
$model = new InvoiceModel();
|
||||||
$db = \Config\Database::connect();
|
$db = \Config\Database::connect();
|
||||||
$address = $db->table('customer_addresses')->select('address_1','customer_address_id')->where('customer_id',$customer_id)->get()->getRowArray();
|
$address = $db->table('customer_addresses')->select('address_1','customer_address_id')->where('customer_id',$customer_id)->get()->getRowArray();
|
||||||
@ -184,15 +185,17 @@ public function payment_success() {
|
|||||||
//var_dump($result);die();
|
//var_dump($result);die();
|
||||||
$invoice_number = $result['serial_number'];
|
$invoice_number = $result['serial_number'];
|
||||||
$next_id_numeric = $result['next_id'];
|
$next_id_numeric = $result['next_id'];
|
||||||
|
$price = $bookModel->select('price')->where('book_id', 3)->first();
|
||||||
|
$amount = $price['price'];
|
||||||
$data = [
|
$data = [
|
||||||
'invoice_number' => $invoice_number,
|
'invoice_number' => $invoice_number,
|
||||||
'invoice_type' => 2,
|
'invoice_type' => 2,
|
||||||
'customer_id' => $customer_id,
|
'customer_id' => $customer_id,
|
||||||
'payment_status' => 'Paid',
|
'payment_status' => 'Paid',
|
||||||
'sub_total' => 1500,
|
'status'=>'Approved',
|
||||||
'exact_total_amount' => 1500.00,
|
'sub_total' => $amount,
|
||||||
'grand_total' => 1500.00,
|
'exact_total_amount' => $amount,
|
||||||
|
'grand_total' => $amount,
|
||||||
'invoice_date' => $currentDate,
|
'invoice_date' => $currentDate,
|
||||||
'billing_address'=> $address['address_1'],
|
'billing_address'=> $address['address_1'],
|
||||||
'billing_address_id' => isset($address['customer_address_id']) ? $address['customer_address_id'] : ''
|
'billing_address_id' => isset($address['customer_address_id']) ? $address['customer_address_id'] : ''
|
||||||
|
|||||||
@ -7,7 +7,7 @@ class SubscriptionModel extends Model
|
|||||||
{
|
{
|
||||||
protected $table = 'subscription';
|
protected $table = 'subscription';
|
||||||
protected $primaryKey = 'sub_id';
|
protected $primaryKey = 'sub_id';
|
||||||
protected $allowedFields = ['sub_id','scheme_id','customer_id','to_subscription','from_subscription','mode','created_on','created_by','updated_by','updated_on','business_id','status'];
|
protected $allowedFields = ['sub_id','invoice_id','scheme_id','customer_id','to_subscription','from_subscription','mode','created_on','created_by','updated_by','updated_on','business_id','status'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -349,6 +349,23 @@ public function getQueryforSubscriptionDetailsBySchemeName($flag,$condition, $va
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
public function check_existing_membership_id($customer_id){
|
||||||
|
$builder = $this->db->table('subscription');
|
||||||
|
$builder->select('membership_id');
|
||||||
|
$builder->where('customer_id', $customer_id);
|
||||||
|
$builder->orderBy('sub_id', 'DESC');
|
||||||
|
$builder->limit(1);
|
||||||
|
$output = $builder->get()->getResult();
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateData($data, $where)
|
||||||
|
{
|
||||||
|
$this->db->table('subscription')->update($data, $where);
|
||||||
|
$affected_rows = $this->db->affectedRows();
|
||||||
|
return $affected_rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1277,6 +1277,8 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
|
|||||||
var iid_arr = <?php echo json_encode($invoice_item_details); ?>;
|
var iid_arr = <?php echo json_encode($invoice_item_details); ?>;
|
||||||
var custid = "<?= isset($invoice_details['customer_id']) ? $invoice_details['customer_id'] : ""; ?>";
|
var custid = "<?= isset($invoice_details['customer_id']) ? $invoice_details['customer_id'] : ""; ?>";
|
||||||
var inv_number = "<?= isset($invoice_details['invoice_number']) ? $invoice_details['invoice_number'] : ""; ?>";
|
var inv_number = "<?= isset($invoice_details['invoice_number']) ? $invoice_details['invoice_number'] : ""; ?>";
|
||||||
|
console.log(inv_number);
|
||||||
|
//alert(inv_number);
|
||||||
var ship_addrid = "";
|
var ship_addrid = "";
|
||||||
if (custid != '') {
|
if (custid != '') {
|
||||||
ship_addrid = "<?= isset($invoice_details['shipping_address_id']) ? $invoice_details['shipping_address_id'] : ""; ?>";
|
ship_addrid = "<?= isset($invoice_details['shipping_address_id']) ? $invoice_details['shipping_address_id'] : ""; ?>";
|
||||||
@ -1299,21 +1301,23 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
|
|||||||
|
|
||||||
}
|
}
|
||||||
$('#hiddenBillingAddressId').val(bill_addrid);
|
$('#hiddenBillingAddressId').val(bill_addrid);
|
||||||
$('#customer_name').onchange(function(){
|
|
||||||
get_customer_membership_details(custid);
|
|
||||||
|
|
||||||
})
|
// get_customer_membership_details(custid);
|
||||||
get_customer_membership_details(custid);
|
|
||||||
}
|
}
|
||||||
if (inv_number != '') {
|
if (inv_number != '') {
|
||||||
|
var numbering_arr = <?php echo json_encode($invoice_number_formatting); ?>;
|
||||||
|
var next_id_string = numbering_arr[0].next_id;
|
||||||
|
//alert('Hi');
|
||||||
|
$('#hiddenNextId').val(next_id_string).prop('readonly',true);
|
||||||
$("#invoiceNumber").val(inv_number).prop("readonly", true);
|
$("#invoiceNumber").val(inv_number).prop("readonly", true);
|
||||||
} else {
|
} else {
|
||||||
var numbering_arr = <?php echo json_encode($invoice_number_formatting); ?>;
|
var numbering_arr = <?php echo json_encode($invoice_number_formatting); ?>;
|
||||||
// console.log(numbering_arr);
|
console.log("numbering arr = "+numbering_arr);
|
||||||
var filtered_data = $.grep(numbering_arr, function(item) {
|
var filtered_data = $.grep(numbering_arr, function(item) {
|
||||||
return item.id === '1';
|
return item.id === '1';
|
||||||
});
|
});
|
||||||
var final_sno = generateSerialNumber(filtered_data);
|
var final_sno = generateSerialNumber(filtered_data);
|
||||||
|
|
||||||
$("#invoiceNumber").val(final_sno).prop("readonly", true);
|
$("#invoiceNumber").val(final_sno).prop("readonly", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1370,6 +1374,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
|
|||||||
function generateSerialNumber(filtered_data) {
|
function generateSerialNumber(filtered_data) {
|
||||||
|
|
||||||
var next_id_string = filtered_data[0].next_id;
|
var next_id_string = filtered_data[0].next_id;
|
||||||
|
console.log(next_id_string);
|
||||||
var left_pad_string = filtered_data[0].left_pad;
|
var left_pad_string = filtered_data[0].left_pad;
|
||||||
// var prefix_string = String(filtered_data[0].id_formating); // don't remove
|
// var prefix_string = String(filtered_data[0].id_formating); // don't remove
|
||||||
var prefix_string = <?= json_encode($financial_year); ?>;
|
var prefix_string = <?= json_encode($financial_year); ?>;
|
||||||
@ -1395,6 +1400,10 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// $('#customer_name').onchange(function(){
|
||||||
|
// get_customer_membership_details(custid);
|
||||||
|
|
||||||
|
// })
|
||||||
// Billing ajax call
|
// Billing ajax call
|
||||||
function get_customer_billing_details(cust_id) {
|
function get_customer_billing_details(cust_id) {
|
||||||
|
|
||||||
|
|||||||
@ -129,7 +129,15 @@
|
|||||||
var remaining = new Date(response.scheme.to_subscription);
|
var remaining = new Date(response.scheme.to_subscription);
|
||||||
var remainingDays = Math.ceil((remaining - date) / (1000 * 60 * 60 * 24));
|
var remainingDays = Math.ceil((remaining - date) / (1000 * 60 * 60 * 24));
|
||||||
var expirationMessage = '';
|
var expirationMessage = '';
|
||||||
if (remainingDays > 0) {
|
if (remainingDays == 0){
|
||||||
|
remainingDays = Math.abs(remainingDays);
|
||||||
|
expirationMessage = 'Your Subscription plan, "' + response.scheme.short_code + '" expires today, ' + remaining.toLocaleDateString('en-GB') + '.';
|
||||||
|
}
|
||||||
|
else if(remainingDays == 1){
|
||||||
|
remainingDays = Math.abs(remainingDays);
|
||||||
|
expirationMessage = 'Your Subscription plan, "' + response.scheme.short_code + '" will expire tomorrow, ' + remaining.toLocaleDateString('en-GB') + '.';
|
||||||
|
}
|
||||||
|
else if (remainingDays > 0) {
|
||||||
expirationMessage = 'Your Subscription plan "' + response.scheme.short_code + '" is going to expire in ' + remainingDays +
|
expirationMessage = 'Your Subscription plan "' + response.scheme.short_code + '" is going to expire in ' + remainingDays +
|
||||||
' days on ' + remaining.toLocaleDateString('en-GB') + '.';
|
' days on ' + remaining.toLocaleDateString('en-GB') + '.';
|
||||||
} else {
|
} else {
|
||||||
@ -184,19 +192,28 @@
|
|||||||
var remaining = new Date(response.scheme.to_subscription);
|
var remaining = new Date(response.scheme.to_subscription);
|
||||||
var remainingDays = Math.ceil((remaining - date) / (1000 * 60 * 60 * 24));
|
var remainingDays = Math.ceil((remaining - date) / (1000 * 60 * 60 * 24));
|
||||||
console.log(response.scheme.to_subscription);
|
console.log(response.scheme.to_subscription);
|
||||||
|
console.log(remainingDays);
|
||||||
var expirationMessage = '';
|
var expirationMessage = '';
|
||||||
if (remainingDays > 0) {
|
if (remainingDays == 0){
|
||||||
|
remainingDays = Math.abs(remainingDays);
|
||||||
|
expirationMessage = 'Your Subscription plan, "' + response.scheme.short_code + '" expires today, ' + remaining.toLocaleDateString('en-GB') + '.';
|
||||||
|
}
|
||||||
|
else if(remainingDays == 1){
|
||||||
|
remainingDays = Math.abs(remainingDays);
|
||||||
|
expirationMessage = 'Your Subscription plan, "' + response.scheme.short_code + '" will expire tomorrow, ' + remaining.toLocaleDateString('en-GB') + '.';
|
||||||
|
}
|
||||||
|
else if (remainingDays > 0) {
|
||||||
expirationMessage = 'Your Subscription plan "' + response.scheme.short_code + '" is going to expire in ' + remainingDays +
|
expirationMessage = 'Your Subscription plan "' + response.scheme.short_code + '" is going to expire in ' + remainingDays +
|
||||||
' days on ' + remaining.toLocaleDateString('en-GB') + '.';
|
' days on ' + remaining.toLocaleDateString('en-GB') + '.';
|
||||||
} else if (remainingDays < 0) {
|
} else {
|
||||||
remainingDays = Math.abs(remainingDays);
|
remainingDays = Math.abs(remainingDays);
|
||||||
expirationMessage = 'Your Subscription plan "' + response.scheme.short_code + '" has already expired ' + remainingDays +
|
expirationMessage = 'Your Subscription plan "' + response.scheme.short_code + '" has already expired ' + remainingDays +
|
||||||
' days ago on ' + remaining.toLocaleDateString('en-GB') + '.';
|
' days ago on ' + remaining.toLocaleDateString('en-GB') + '.';
|
||||||
}else{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
$('#expirationMessage').text(expirationMessage);
|
$('#expirationMessage').text(expirationMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user