First SubScription in invoice : ps

This commit is contained in:
VE10-Sanjeev 2023-11-02 12:35:06 +05:30
parent 589a0a58f5
commit 23eccf46c9
4 changed files with 110 additions and 1 deletions

View File

@ -105,6 +105,7 @@ class Invoice extends BaseController
$select = ["customer_address_id", "CONCAT(address_1,' ',address_2) as address"];
$where['address_type'] = 2;
$data['customer_shipping'] = $this->get_customer_address($where, $select);
$data['customer_membership'] = $this->get_customer_membership("membership",(int)$id);
return $this->response->setJSON(['data' => $data]);
}
@ -131,6 +132,12 @@ class Invoice extends BaseController
return $address_details;
}
public function get_customer_membership($category,$id){
$model = new InvoiceModel();
$result = $model->getMembershipListForCustomer($category,$id);
return $result;
}
## To insert or update the details of the invoice
public function save_invoice()
{

View File

@ -69,7 +69,8 @@ class HomeModel extends Model
->select('CM.name, CONCAT(C.first_name, " ", C.last_name) as customer_name, C.email as customer_email, C.mobile_no as customer_mobile, S.sub_id, S.scheme_id, S.customer_id, S.from_subscription, S.to_subscription, S.business_id, S.to_subscription, S.from_subscription, BK.title, BK.book_id,DATEDIFF(S.to_subscription, CURDATE()) as countdays')
->where('S.to_subscription >=', $now)
->where('S.to_subscription <=', $last30days)
->where('BC.category_id', 5)
// ->where('BC.category_id', 5)
->where('LOWER(BC.category_name)', strtolower('Membership'), FALSE)
->groupBy('S.sub_id')
->get()
->getResultArray();

View File

@ -171,6 +171,25 @@ public function updateData($table, $data, $where)
return $data;
}
public function getMembershipListForCustomer($category,$id)
{
$data = $this->db->table('subscription as S')
->join('customers as C','C.customer_id = S.customer_id','left')
->join('category as CM', 'CM.id = S.scheme_id', 'left')
->join('book_categories as BC', 'BC.category_id = S.scheme_id', 'left')
->join('books as BK', 'BC.book_id = BK.book_id', 'left')
->select('S.customer_id,concat(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.created_on,CM.name,BK.title,BK.book_id')
->where('LOWER(CM.name)', strtolower("'".$category."'"), FALSE)
->where('S.customer_id', $id)
->groupBy('S.sub_id')
->orderBy('S.created_on','ASC')
->get()
->getResultArray();
// print_r($this->db->getLastQuery());die;
return $data;
}
public function getProductImgs($productId)
{
$data = $this->db->table('book_images')

View File

@ -27,6 +27,70 @@
</div>
</div>
<?php if ($invoice_type === '2') : ?>
<div id="subscribedetails" style="display: none">
<br/>
<div class="form-row">
<div class="col-12 border-bottom bg-transparent">
<h5 class="header-title mb-2">First Subscription Details</h5>
</div>
<!-- <div class="col-lg-3 col-sm-6">
<div class="media mt-2 mb-2">
<div class="mr-2 align-self-center">
<i class="ri-hashtag h2 m-0 text-muted"></i>
</div>
<div class="media-body">
<p class="mb-1">ID No.</p>
<h5 class="mt-0">
#MN2048
</h5>
</div>
</div>
</div> -->
<div class="col-lg-6 col-sm-12">
<div class="media mt-2 mb-2">
<div class="mr-2 align-self-center">
<i class="ri-shield-star-line h2 m-0 text-muted"></i>
</div>
<div class="media-body">
<p class="mb-1">Scheme Name</p>
<h5 class="mt-0" id="schemeName"></h5>
</div>
</div>
</div>
<div class="col-lg-3 col-sm-6">
<div class="media mt-2 mb-2">
<div class="mr-2 align-self-center">
<i class="ri-calendar-event-line h2 m-0 text-muted"></i>
</div>
<div class="media-body">
<p class="mb-1">From Date</p>
<h5 class="mt-0" id="fromDate"> </h5>
<!-- <h5 class="mt-0">
Apr 16 2020 <small class="text-muted">10:29 PM</small>
</h5> -->
</div>
</div>
</div>
<div class="col-lg-3 col-sm-6">
<div class="media mt-2 mb-2">
<div class="mr-2 align-self-center">
<i class="ri-calendar-event-line h2 m-0 text-muted"></i>
</div>
<div class="media-body">
<p class="mb-1">To Date</p>
<h5 class="mt-0" id="toDate"> </h5>
</div>
</div>
</div>
</div>
<br/>
</div>
<?php endif; ?>
<div class="form-row">
<div class="form-group col-md-6">
<label for="storeBillingAddress"> Billing Address &ensp;( <input type="checkbox" id="editAddressesCheckbox" /> Do you want to edit/change addresses?)</label>
@ -657,6 +721,7 @@
success: function(response) {
cs = response['data']['customer_shipping'];
cb = response['data']['customer_billing'];
cm = response['data']['customer_membership'];
$('#hiddenBillingAddressId').val('');
customer_billing = "";
if (cb.length > 0) {
@ -667,6 +732,23 @@
customer_billing_id = v.customer_address_id
});
}
if (cm.length > 0) {
$("#subscribedetails").show();
$("#schemeName").text(cm[0].title);
$("#fromDate").text(cm[0].formatted_from_subscription);
$("#toDate").text(cm[0].formatted_to_subscription);
// $.each(cm, function(k, v) {});
// "formatted_from_subscription": "12/10/2023",
// "formatted_to_subscription": "12/11/2023",
// "from_subscription": "2023-10-12",
// "to_subscription": "2023-11-12",
// "title": "First Std Tamil Book",
}else{
$("#subscribedetails").hide();
$("#schemeName").text('');
$("#fromDate").text('');
$("#toDate").text('');
}
// var address_compare = bill_addr == customer_billing ? customer_billing : bill_addr
//