This commit is contained in:
Gowtham M 2025-10-17 09:50:54 +05:30
parent 584e6e1f22
commit d2106e5d70
3 changed files with 45 additions and 4 deletions

View File

@ -82,6 +82,8 @@ class DashboardController extends ResourceController
// --- Un assigned enquiry ---
$unassignedEnquiry = $this->db->table('partner_enquiry pe')
->select('pe.reg_no , pe.name as insured_name , pa.name as agent_name')
->join('partner_agent pa', 'pa.id = pe.agent_id', 'left')
->where('pe.assigned_to', 0)
->where('pe.manager_id', $manager_id)
->get()
@ -216,6 +218,8 @@ class DashboardController extends ResourceController
// --- Un assigned enquiry ---
$unassignedEnquiry = $this->db->table('partner_enquiry pe')
->select('pe.reg_no , pe.name as insured_name , pa.name as agent_name')
->join('partner_agent pa', 'pa.id = pe.agent_id', 'left')
->where('pe.assigned_to', 0)
->where('pe.manager_id', $manager_id)
->get()

View File

@ -88,8 +88,9 @@ class EnquiryController extends ResourceController
}
//Get enquiry details
$enquiry = $this->enquiryModel->select('partner_enquiry.* , I.name as insurer_name ')
$enquiry = $this->enquiryModel->select('partner_enquiry.* , I.name as insurer_name , VT.vehicle_type as vehicle_type')
->join('insurers I', 'I.id = partner_enquiry.insurer_id', 'left')
->join('vehicle_type VT', 'VT.id = partner_enquiry.vehicle_type_id', 'left')
->where('partner_enquiry.id', $enquiry_id)
->where('partner_enquiry.is_active', 1)
->first();

View File

@ -280,6 +280,10 @@ class StaffController extends ResourceController
$result = $builder->get()->getResultArray();
foreach ($result as $key => $value) {
$result[$key]['month'] = date('M Y', strtotime($value['month']));
}
return $this->respond(['status' => 'success', 'code' => 200, 'month' => $month, 'data' => $result], 200);
}
@ -309,9 +313,12 @@ class StaffController extends ResourceController
$formatted = [];
foreach ($records as $row) {
$formatted[] = [
'id' => $row['id'],
'login_date' => $row['first_login'] ? date('d, M Y h:i A', strtotime($row['first_login'])) : null,
'logout_date' => $row['last_logout'] ? date('d, M Y h:i A', strtotime($row['last_logout'])) : null,
'id' => $row['id'],
'date' => $row['first_login'] ? date('d, M Y', strtotime($row['first_login'])) : null,
'login_time' => $row['first_login'] ? date('h:i A', strtotime($row['first_login'])) : null,
'logout_time' => $row['last_logout'] ? date('h:i A', strtotime($row['last_logout'])) : null,
'no_of_logged_in_time' => $this->getLoginDuration($row['first_login'], $row['last_logout'])
];
}
@ -324,6 +331,35 @@ class StaffController extends ResourceController
}
private function getLoginDuration($login, $logout)
{
if (empty($login) || empty($logout)) {
return null;
}
$loginTime = strtotime($login);
$logoutTime = strtotime($logout);
$diffSeconds = $logoutTime - $loginTime;
if ($diffSeconds < 0) {
return null; // Invalid data
}
$hours = floor($diffSeconds / 3600);
$minutes = floor(($diffSeconds % 3600) / 60);
if ($hours > 0 && $minutes > 0) {
return "{$hours}h {$minutes}m";
} elseif ($hours > 0) {
return "{$hours}h";
} elseif ($minutes > 0) {
return "{$minutes}m";
} else {
return "0m";
}
}