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'];
|
||||
$from_sub_date = $item['from_subscription'];
|
||||
$to_sub_date = $item['to_subscription'];
|
||||
$membership_id = $this->generate_membership_id(6);
|
||||
$result = $subModel->where('membership_id',$membership_id)->findAll();
|
||||
if (count($result)>0){
|
||||
$membership_id = $this->generate_membership_id(6);
|
||||
}
|
||||
//check if membership id is already set for the customer
|
||||
|
||||
$get_exists_subscription_where = ['S.customer_id' => (int)$customer_id, 'S.scheme_id' => $product_id, 'I.status' => 'Approved', 'I.isactive' => 1];
|
||||
$get_exists_subscription_dtls = $model->existsSubscriptionDetails($get_exists_subscription_where);
|
||||
|
||||
// the scheme is already exists to the customer
|
||||
if ($get_exists_subscription_dtls) {
|
||||
$this->logger->info($msg_flag_name . ": This Scheme Already Existing in this Customer. ");
|
||||
$renewal = 1;
|
||||
$membership = $subModel->check_existing_membership_id($customer_id);
|
||||
//dd($membership);
|
||||
if (count($membership)>0){
|
||||
$member = (array)$membership[0];
|
||||
//dd($member);
|
||||
$membership_id = $member['membership_id'];
|
||||
//dd($membership_id);
|
||||
}
|
||||
else{
|
||||
$membership_id = $this->generate_membership_id(6);
|
||||
// To check if the generated membership is already created for another customer
|
||||
$result = $subModel->where('membership_id',$membership_id)->findAll();
|
||||
if (count($result)>0){
|
||||
$membership_id = $this->generate_membership_id(6);
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare subscription data
|
||||
$subscription_data = [
|
||||
@ -563,8 +567,18 @@ public function create_or_update_subscription($invoice_id,$invoice_status, $msg_
|
||||
'status' =>1
|
||||
];
|
||||
|
||||
// Insert the subscription data
|
||||
$model->insertSubscriptionData($subscription_data,$invoice_status);
|
||||
$check_existing_customer_id = $subModel->where('invoice_id',$invoice_id)->findAll();
|
||||
//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');
|
||||
|
||||
// Assuming the model is used for database interactions
|
||||
$bookModel = new BooksModel();
|
||||
$model = new InvoiceModel();
|
||||
$db = \Config\Database::connect();
|
||||
$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();
|
||||
$invoice_number = $result['serial_number'];
|
||||
$next_id_numeric = $result['next_id'];
|
||||
|
||||
$price = $bookModel->select('price')->where('book_id', 3)->first();
|
||||
$amount = $price['price'];
|
||||
$data = [
|
||||
'invoice_number' => $invoice_number,
|
||||
'invoice_type' => 2,
|
||||
'customer_id' => $customer_id,
|
||||
'payment_status' => 'Paid',
|
||||
'sub_total' => 1500,
|
||||
'exact_total_amount' => 1500.00,
|
||||
'grand_total' => 1500.00,
|
||||
'status'=>'Approved',
|
||||
'sub_total' => $amount,
|
||||
'exact_total_amount' => $amount,
|
||||
'grand_total' => $amount,
|
||||
'invoice_date' => $currentDate,
|
||||
'billing_address'=> $address['address_1'],
|
||||
'billing_address_id' => isset($address['customer_address_id']) ? $address['customer_address_id'] : ''
|
||||
|
||||
@ -7,7 +7,7 @@ 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','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;
|
||||
}
|
||||
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 custid = "<?= isset($invoice_details['customer_id']) ? $invoice_details['customer_id'] : ""; ?>";
|
||||
var inv_number = "<?= isset($invoice_details['invoice_number']) ? $invoice_details['invoice_number'] : ""; ?>";
|
||||
console.log(inv_number);
|
||||
//alert(inv_number);
|
||||
var ship_addrid = "";
|
||||
if (custid != '') {
|
||||
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);
|
||||
$('#customer_name').onchange(function(){
|
||||
get_customer_membership_details(custid);
|
||||
|
||||
})
|
||||
get_customer_membership_details(custid);
|
||||
|
||||
// get_customer_membership_details(custid);
|
||||
}
|
||||
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);
|
||||
} else {
|
||||
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) {
|
||||
return item.id === '1';
|
||||
});
|
||||
var final_sno = generateSerialNumber(filtered_data);
|
||||
|
||||
$("#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) {
|
||||
|
||||
var next_id_string = filtered_data[0].next_id;
|
||||
console.log(next_id_string);
|
||||
var left_pad_string = filtered_data[0].left_pad;
|
||||
// var prefix_string = String(filtered_data[0].id_formating); // don't remove
|
||||
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
|
||||
function get_customer_billing_details(cust_id) {
|
||||
|
||||
|
||||
@ -129,7 +129,15 @@
|
||||
var remaining = new Date(response.scheme.to_subscription);
|
||||
var remainingDays = Math.ceil((remaining - date) / (1000 * 60 * 60 * 24));
|
||||
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 +
|
||||
' days on ' + remaining.toLocaleDateString('en-GB') + '.';
|
||||
} else {
|
||||
@ -184,19 +192,28 @@
|
||||
var remaining = new Date(response.scheme.to_subscription);
|
||||
var remainingDays = Math.ceil((remaining - date) / (1000 * 60 * 60 * 24));
|
||||
console.log(response.scheme.to_subscription);
|
||||
console.log(remainingDays);
|
||||
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 +
|
||||
' days on ' + remaining.toLocaleDateString('en-GB') + '.';
|
||||
} else if (remainingDays < 0) {
|
||||
} else {
|
||||
remainingDays = Math.abs(remainingDays);
|
||||
expirationMessage = 'Your Subscription plan "' + response.scheme.short_code + '" has already expired ' + remainingDays +
|
||||
' days ago on ' + remaining.toLocaleDateString('en-GB') + '.';
|
||||
}else{
|
||||
|
||||
}
|
||||
$('#expirationMessage').text(expirationMessage);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user