92 lines
2.6 KiB
PHP
92 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use CodeIgniter\API\ResponseTrait;
|
|
|
|
class Users extends BaseController
|
|
{
|
|
|
|
use ResponseTrait;
|
|
|
|
var $request;
|
|
|
|
function __construct()
|
|
{
|
|
$this->request = \Config\Services::request();
|
|
}
|
|
|
|
public function userDash(){
|
|
$statusDetail[2] =[
|
|
"text" => "Pending",
|
|
"button" => false,
|
|
"advise" => 'Awaiting employers verification'
|
|
];
|
|
$statusDetail[4] =[
|
|
"text" => "Add Card",
|
|
"button" => true,
|
|
"advise" => 'Add payment card to continue'
|
|
];
|
|
|
|
$statusDetail[7] =[
|
|
"text" => "Canceled",
|
|
"button" => false,
|
|
"advise" => 'Application is cancelled'
|
|
];
|
|
|
|
$in = $this->request->getGet();
|
|
$data = [];
|
|
if ($in['uid'] !=''){
|
|
$query = $this->db->query("SELECT * FROM customers WHERE uid = '".$in['uid']."' ");
|
|
|
|
$row = $query->getRowArray();
|
|
|
|
$loanResult = $this->userLoan($in['uid']);
|
|
$processLoan = [];
|
|
foreach ($loanResult as $value) {
|
|
$value["status_text"] = $statusDetail[ $value["status"] ];
|
|
$processLoan[] = $value;
|
|
}
|
|
|
|
$data = [
|
|
'call_return' => '100',
|
|
'customer' => $row,
|
|
'loans' => $processLoan,
|
|
];
|
|
return $this->respond($data, 200);
|
|
//'loans' => $loanResult,
|
|
}
|
|
else{
|
|
return $this->respond(['error'=>'empty uid'], 400);
|
|
}
|
|
|
|
//return $this->respond([], 400);
|
|
}
|
|
|
|
private function userLoan($uid){
|
|
$query = $this->db->query("SELECT a.uid AS application_uid,a.loan_amount,
|
|
a.payment_month,a.status,a.added,
|
|
a.updated
|
|
FROM applications a
|
|
LEFT JOIN customers c ON c.uid = a.customer_uid WHERE a.customer_uid='".$uid."' ");
|
|
return $query->getResult('array');
|
|
}
|
|
public function userProfile(){
|
|
$in = $this->request->getGet();
|
|
$data = [];
|
|
if ($in['uid'] !=''){
|
|
$query = $this->db->query("SELECT * FROM customers WHERE uid = '".$in['uid']."' ");
|
|
$row = $query->getRowArray();
|
|
$data = [
|
|
'call_return' => '100',
|
|
'customer' => $row
|
|
];
|
|
return $this->respond($data, 200);
|
|
}else{
|
|
return $this->respond(['error'=>'empty uid'], 400);
|
|
}
|
|
|
|
// return $this->respond([], 400);
|
|
}
|
|
|
|
} |