FIX_code redo isactive sub-table
This commit is contained in:
parent
150f7ae976
commit
11eae83e0f
@ -564,19 +564,22 @@ public function create_or_update_subscription($invoice_id,$invoice_status, $msg_
|
|||||||
'updated_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,
|
||||||
|
'isactive' =>$invoice_status === 'Approved' ? 1 : 0
|
||||||
];
|
];
|
||||||
|
|
||||||
$check_existing_customer_id = $subModel->where('invoice_id',$invoice_id)->findAll();
|
$check_existing_customer_id = $subModel->where('invoice_id',$invoice_id)->findAll();
|
||||||
//dd($check_existing_customer_id);
|
//dd($check_existing_customer_id);
|
||||||
if($check_existing_customer_id){
|
if($check_existing_customer_id){
|
||||||
|
unset($data['created_by']);
|
||||||
log_message('info',json_encode($subscription_data));
|
log_message('info',json_encode($subscription_data));
|
||||||
$where = ['invoice_id'=>$invoice_id];
|
$where = ['invoice_id'=>$invoice_id];
|
||||||
$subModel->updateData($subscription_data,$where);//update the data
|
$subModel->updateData($subscription_data,$where);//update the data
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
//insert the data
|
//insert the data
|
||||||
$model->insertSubscriptionData($subscription_data,$invoice_status);
|
unset($data['updated_by']);
|
||||||
|
$model->insertSubscriptionData($subscription_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -350,26 +350,10 @@ public function getJoinedData($where, $orderby = [])
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function insertSubscriptionData($data,$invoice_status)
|
public function insertSubscriptionData($data)
|
||||||
{
|
{
|
||||||
if (!empty($data)) {
|
|
||||||
$invoice_id = $data['invoice_id'];
|
|
||||||
$customer_id = $data['customer_id'];
|
|
||||||
$scheme_id = $data['scheme_id'];
|
|
||||||
$data['isactive'] = $invoice_status === 'Approved' ? 1 : 0 ;
|
|
||||||
$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 $this->db->table('subscription')->insert($data);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ***********************REPORT**********************
|
// ***********************REPORT**********************
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user