Invoice : ps
This commit is contained in:
parent
0b8144a952
commit
1f4a0b8d51
@ -481,7 +481,17 @@ class Invoice extends BaseController
|
||||
public function subscription_inactive(){
|
||||
$model = new InvoiceModel();
|
||||
$details = $model->subscription_inactive();
|
||||
return $details;
|
||||
$now = date('d-m-Y');
|
||||
if(strtolower(gettype($details)) == "string"){
|
||||
$this->logger->info("Subscription Inactive : " . $details);
|
||||
$result = $details ;
|
||||
}else{
|
||||
$this->logger->info("Subscription Inactive : " .count($details) . " Subscription Records ". json_encode($details));
|
||||
$success_rating = isset($details['success_rating'])?$details['success_rating']:0;
|
||||
$error_rating = isset($details['error_rating'])?$details['error_rating']:0;
|
||||
$result = "Total ". count($details) . " Subscription Records.\n success rating = ".$success_rating."\n fail rating = ".$error_rating ."\n Note : Check Your Log File";
|
||||
}
|
||||
return $now." ".$result;
|
||||
}
|
||||
|
||||
public function approve_notifications($invoice_id)
|
||||
|
||||
@ -117,23 +117,31 @@ public function existsSubscriptionDetails($where){
|
||||
|
||||
## subscription_inactive
|
||||
public function subscription_inactive(){
|
||||
|
||||
$now = date('Y-m-d');
|
||||
|
||||
$result = $this->db->table('subscription as S')
|
||||
->select('S.sub_id, S.scheme_id, S.customer_id, S.business_id,S.invoice_id,S.mode,S.from_subscription, S.to_subscription, S.is_renew, S.isactive')
|
||||
->where("S.isactive",1)
|
||||
->where("S.to_subscription <= ",$now)
|
||||
->get()
|
||||
->getResultArray();
|
||||
if(!empty($result)){
|
||||
foreach ($result as $row) {
|
||||
$this->db->table('subscription')
|
||||
->set('isactive', 0)
|
||||
->where('to_subscription < ',$now)
|
||||
->update();
|
||||
}
|
||||
return "Updated";
|
||||
}else{
|
||||
// echo "<pre>";print_r($result);echo "</pre>";
|
||||
$returnMessages = [];$i = 0 ;$j = 0;
|
||||
if (!empty($result)) {
|
||||
foreach ($result as $row) {
|
||||
$this->db->table('invoiceitems')->where(['invoice_id' => $row['invoice_id']])->update(['from_subscription' => NULL,'to_subscription' => NULL]);//first child
|
||||
$this->db->table('subscription')->where(['sub_id' => $row['sub_id']])->update(['isactive' => 0]);//second child
|
||||
$affectedRows = $this->db->affectedRows();
|
||||
if ($affectedRows) {
|
||||
$returnMessages['message'] = "Success for sub_id: " . $row['sub_id'];
|
||||
$returnMessages['success_rating'] = $i++;
|
||||
}else {
|
||||
$returnMessages['message'] = 'Failed to update subscription with sub_id ' . $row['sub_id'] . '. No rows were affected.';
|
||||
$returnMessages['error_rating'] = $j++;
|
||||
}
|
||||
}
|
||||
return $returnMessages;
|
||||
// return implode("\n", $returnMessages);
|
||||
} else {
|
||||
return "No data";
|
||||
}
|
||||
}
|
||||
@ -220,7 +228,7 @@ public function existsSubscriptionDetails($where){
|
||||
->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(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')
|
||||
->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.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')
|
||||
|
||||
@ -792,9 +792,14 @@
|
||||
},
|
||||
success: function(response) {
|
||||
cm = response['data']['customer_membership'];
|
||||
cm.sort(function(a, b) {
|
||||
return b.is_renew - a.is_renew;
|
||||
});
|
||||
if (cm.length > 0) {
|
||||
text1 = cm[0].is_renew == 1 ? " - Renewal" : "";
|
||||
text2 = cm[0].isactive == 0 ? " - Expried" : "";
|
||||
$(".subscribedetails").show(); // Change this line to use the class selector
|
||||
$("#schemeName").text("Earlier Membership : "+cm[0].title + " ( From: " + cm[0].formatted_from_subscription + " To: " + cm[0].formatted_to_subscription+" )");
|
||||
$("#schemeName").text("Earlier Membership : "+cm[0].title + " ( From: " + cm[0].formatted_from_subscription + " To: " + cm[0].formatted_to_subscription+" )"+text1+text2);
|
||||
} else {
|
||||
$(".subscribedetails").show(); // Change this line to use the class selector
|
||||
$("#schemeName").text("No Earlier Membership found");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user