FIX_Draft implementation for subcription
This commit is contained in:
parent
9bcefd7aff
commit
bc41e5173a
@ -405,7 +405,7 @@ class Invoice extends BaseController
|
|||||||
|
|
||||||
// Handle subscription if invoice type is subscription
|
// Handle subscription if invoice type is subscription
|
||||||
if ((int)$invoiceType === 2) {
|
if ((int)$invoiceType === 2) {
|
||||||
$this->create_or_update_subscription($invoice_id, $msg_flag_name);
|
$this->create_or_update_subscription($invoice_id,$invoice_status, $msg_flag_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send notification if invoice is approved
|
// Send notification if invoice is approved
|
||||||
@ -521,7 +521,7 @@ public function generate_membership_id($length = 6) {
|
|||||||
return $randomString;
|
return $randomString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create_or_update_subscription($invoice_id, $msg_flag_name = null)
|
public function create_or_update_subscription($invoice_id,$invoice_status, $msg_flag_name = null)
|
||||||
{
|
{
|
||||||
$model = new InvoiceModel();
|
$model = new InvoiceModel();
|
||||||
$subModel = new SubscriptionModel();
|
$subModel = new SubscriptionModel();
|
||||||
@ -547,13 +547,14 @@ public function create_or_update_subscription($invoice_id, $msg_flag_name = null
|
|||||||
'to_subscription' => $to_sub_date,
|
'to_subscription' => $to_sub_date,
|
||||||
'business_id' => get_business_id(),
|
'business_id' => get_business_id(),
|
||||||
'created_by' => get_logged_user_id(),
|
'created_by' => get_logged_user_id(),
|
||||||
|
'updated_by' => get_logged_user_id(),
|
||||||
'is_renew' => $renewal,
|
'is_renew' => $renewal,
|
||||||
'membership_id'=>$membership_id,
|
'membership_id'=>$membership_id,
|
||||||
'status' =>1
|
'status' =>1
|
||||||
];
|
];
|
||||||
|
|
||||||
// Insert the subscription data
|
// Insert the subscription data
|
||||||
$model->insertSubscriptionData($subscription_data);
|
$model->insertSubscriptionData($subscription_data,$invoice_status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -596,6 +596,7 @@ class Notifications extends BaseController
|
|||||||
}
|
}
|
||||||
$db = \Config\Database::connect();
|
$db = \Config\Database::connect();
|
||||||
$queryResult = $db->query($modifiedQuery)->getResultArray();
|
$queryResult = $db->query($modifiedQuery)->getResultArray();
|
||||||
|
|
||||||
|
|
||||||
$notification = new NotificationHelper();
|
$notification = new NotificationHelper();
|
||||||
if (empty($queryResult)) {
|
if (empty($queryResult)) {
|
||||||
|
|||||||
@ -348,13 +348,29 @@ public function getJoinedData($where, $orderby = [])
|
|||||||
->getResult();
|
->getResult();
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function insertSubscriptionData($data)
|
public function insertSubscriptionData($data,$invoice_status)
|
||||||
{
|
{
|
||||||
return $this->db->table('subscription')->insert($data);
|
if (!empty($data)) {
|
||||||
|
$invoice_id = $data['invoice_id'];
|
||||||
|
$customer_id = $data['customer_id'];
|
||||||
|
$scheme_id = $data['scheme_id'];
|
||||||
|
// $data['isactive'] = $invoice_status !== 'Draft' ? 0 : 1 ;
|
||||||
|
|
||||||
|
$where = ['invoice_id' => $invoice_id,'customer_id' => $customer_id,'scheme_id' => $scheme_id];
|
||||||
|
|
||||||
|
$query = $this->db->table('subscription')->select('sub_id')->where($where)->get()->getRow();
|
||||||
|
|
||||||
|
if (!empty($query)) {
|
||||||
|
unset($data['created_by']);
|
||||||
|
return $this->db->table('subscription')->where('sub_id', $query->sub_id)->update($data);
|
||||||
|
} else {
|
||||||
|
unset($data['updated_by']);
|
||||||
|
return $this->db->table('subscription')->insert($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***********************REPORT**********************
|
// ***********************REPORT**********************
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user