| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/adeetie_hellogtx/application/modules/testimonial/models/ |
Upload File : |
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Lendermodel extends CI_Model {
public $tableName = 'bank_applications';
public $tableName2 = 'application_statuses';
function create() {
$this->db->where('application_id', $this->input->post('applicationId'));
$this->db->where('bank_id', $this->session->user_id);
$sql = $this->db->get($this->tableName);
if($sql->num_rows() > 0) {
$this->output->set_status_header(400);
return json_encode(['message' => 'You already accpted this lead, Please check in Recived bucket list', 'status' => 'failed']);
}
$userdetail = (array)$this->session->company;
$arr = array(
'id' => uniqid(),
'application_id' => $this->input->post('applicationId'),
'bank_id' => $this->session->user_id,
'bank_code' => $userdetail['bank_code'],
'status' => $this->input->post('status'),
'created_at' => global_datetime(),
);
$userdetail = [];
if(!empty($userdetail) && !empty($userdetail['bank_code'])) {
unset( $userdetail['password']);
}
$arr['created_by'] = json_encode($userdetail);
$this->db->insert($this->tableName, $arr);
if( $this->db->affected_rows() > 0 ) {
return json_encode(['message' => 'Created successfully', 'status' => 'success']);
} else {
$this->output->set_status_header(400);
return json_encode(['message' => 'Unknown Error', 'status' => 'failed']);
}
}
function get_app_status($banking_app_id) {
$this->db->where('id', $banking_app_id);
$sql = $this->db->get($this->tableName);
if($sql->num_rows() > 0) {
return $sql->row_array();
}
}
function update() {
if(empty($this->session->user_id)) {
$this->output->set_status_header(401);
return json_encode(['message' => 'Unauthorized action', 'status' => 'failed']);
}
$arr = array(
'status' => $this->input->post('status'),
'loan_number' => $this->input->post('loan_number'),
'updated_at' => global_datetime(),
);
$this->db->where('application_id', $this->input->post('applicationId'));
$this->db->where('bank_id', $this->session->user_id);
$this->db->update($this->tableName, $arr);
if( $this->db->affected_rows() > 0 ) {
return json_encode(['message' => 'Created successfully', 'status' => 'success']);
} else {
$this->output->set_status_header(400);
return json_encode(['message' => 'Unknown Error', 'status' => 'failed']);
}
}
function add_appstatus($type = 'status') {
if(empty($this->session->user_id)) {
$this->session->set_flashdata("error", "UnAuthorised data");
}
$banking_app_id = $this->session->userdata('banking_app_id');
$appNumber = $this->session->userdata('appNumber');
$lenderid = $this->session->userdata('lender_id');
$statusarr = array(
'id' => uniqid(),
'status' => $this->input->post('status'),
'comment' => $this->input->post('comment'),
'created_at' => global_datetime(),
'banking_app_id' => $banking_app_id,
'type' => $this->input->post('type')
);
$this->db->trans_start();
$userdetail = [];
if(!empty($this->session->company)) {
$userdetail = (array)$this->session->company;
unset( $userdetail['password']);
}
$statusarr['created_by'] = json_encode($userdetail);
$this->db->insert($this->tableName2, $statusarr);
$this->update_banking_application($banking_app_id);
$this->update_disbursed($appNumber);
$this->db->trans_complete();
redirect('bank/lender/application/'.$appNumber.'/'.$banking_app_id,);
}
function update_banking_application($banking_app_id) {
$apparray = array(
'status' => $this->input->post('status'),
'updated_at' => global_datetime(),
);
if($this->input->post('status') == 'processstart') {
$apparray['loan_number'] = $this->input->post('loan_number');
}
$this->db->where('id', $banking_app_id);
$this->db->update($this->tableName, $apparray);
}
function update_disbursed($appNumber) {
if($this->input->post('status') == 'disbursed') {
$app['loan_requested'] = $this->input->post('loan_requested');
$app['loan_approved'] = $this->input->post('loan_approved');
$app['loan_disbursed'] = $this->input->post('loan_disbursed');
$app['status'] = 'completed';
$this->db->where('application_num', $appNumber);
$this->db->update('applications', $app);
$this->lenderModel->create_disbursement($appNumber);
}
}
function fetch_status($baid) {
$this->db->where('banking_app_id', $baid);
$this->db->order_by('created_at', 'ASC');
$sql = $this->db->get($this->tableName2);
if($sql->num_rows() > 0) {
$this->output->set_status_header(200);
return $sql->result_array();
}
}
function get_all_project() {
}
function create_disbursement($appnumber) {
$disburse = [
'disbursed_amount' => $this->input->post('loan_disbursed'),
'remarks' => $this->input->post('remarks'),
'application_number' => $appnumber,
'created_by' => $this->session->user_id
];
$this->db->insert('disburse_details', $disburse);
}
public function get_disburse_detail($appNumber) {
$this->db->where('application_number', $appNumber);
$this->db->order_by('created_at', 'ASC');
$sql = $this->db->get('disburse_details');
if($sql->num_rows() > 0) {
return $sql->result_array();
}
}
}