Merge branch 'main' of bitbucket.org:jubilian/nhance_partner_be

This commit is contained in:
sanjeev.p 2026-01-23 14:48:19 +05:30
commit 68ede6f3dd
4 changed files with 60 additions and 10 deletions

View File

@ -50,6 +50,7 @@ class EnquiryController extends ResourceController
$enquiry_status = $this->request->getGet('enquiry_status');
$only_policy_data = $this->request->getGet('only_policy_data') ?? false;
$show_policy_report = $this->request->getGet('show_policy_report') ?? 'All';
// Date filter handling
@ -69,15 +70,15 @@ class EnquiryController extends ResourceController
if (!empty($staff_id) && !empty($manager_id)) {
$data = $this->enquiryModel->getEnquiry('STAFF&MANAGER', [$staff_id,$manager_id], $only_policy_data, $from_date, $to_date, $status ,$enquiry_status);
$data = $this->enquiryModel->getEnquiry('STAFF&MANAGER', [$staff_id,$manager_id], $only_policy_data, $show_policy_report, $from_date, $to_date, $status ,$enquiry_status);
} elseif (!empty($agent_id)) {
$data = $this->enquiryModel->getEnquiry('AGENT', $agent_id, $only_policy_data, $from_date, $to_date, $status ,$enquiry_status);
$data = $this->enquiryModel->getEnquiry('AGENT', $agent_id, $only_policy_data, $show_policy_report, $from_date, $to_date, $status ,$enquiry_status);
} elseif (!empty($staff_id)) {
$data = $this->enquiryModel->getEnquiry('STAFF', $staff_id, $only_policy_data, $from_date, $to_date, $status ,$enquiry_status);
$data = $this->enquiryModel->getEnquiry('STAFF', $staff_id, $only_policy_data, $show_policy_report, $from_date, $to_date, $status ,$enquiry_status);
} elseif (!empty($enquiry_id)) {
$data = $this->enquiryModel->getEnquiry('ENQUIRY',$enquiry_id, $only_policy_data);
$data = $this->enquiryModel->getEnquiry('ENQUIRY',$enquiry_id, $only_policy_data, $show_policy_report);
} elseif (!empty($manager_id)) {
$data = $this->enquiryModel->getEnquiry('MANAGER',$manager_id, $only_policy_data, $from_date, $to_date, $status ,$enquiry_status);
$data = $this->enquiryModel->getEnquiry('MANAGER',$manager_id, $only_policy_data, $show_policy_report, $from_date, $to_date, $status ,$enquiry_status);
}elseif (!empty($handler_id)) {
$staffData = $this->db->table('partner_staff ps')
@ -90,7 +91,7 @@ class EnquiryController extends ResourceController
->get()->getResultArray();
$staffIds = array_column($staffData, 'id');
$data = $this->enquiryModel->getEnquiry('HANDLER',$staffIds, $only_policy_data, $from_date, $to_date, $status ,$enquiry_status);
$data = $this->enquiryModel->getEnquiry('HANDLER',$staffIds, $only_policy_data, $show_policy_report, $from_date, $to_date, $status ,$enquiry_status);
} else {
$data = $this->enquiryModel->getEnquiry('ALL');
}

View File

@ -13,7 +13,7 @@ use App\Models\StaffModel;
use App\Models\PartnerBrokerModel;
use App\Models\PaymentModeModel;
use App\Models\PartnerPosModel;
use App\Models\PolicyModel;
class MasterController extends ResourceController
@ -30,6 +30,7 @@ class MasterController extends ResourceController
protected $PartnerBrokerModel;
protected $PaymentModeModel;
protected $PartnerPosModel;
protected $PolicyModel;
public function __construct()
@ -45,6 +46,7 @@ class MasterController extends ResourceController
$this->PartnerBrokerModel = new PartnerBrokerModel();
$this->PaymentModeModel = new PaymentModeModel();
$this->PartnerPosModel = new PartnerPosModel();
$this->PolicyModel = new PolicyModel();
}
@ -126,7 +128,16 @@ class MasterController extends ResourceController
//Vehicle type CRUD---------------------------------------------------------------------
public function getVehicleTypeMaster()
{
$data = $this->VehicleTypeMasterModel->findAll();
$valueFor = $this->request->getGet('value_for');
if(isset($valueFor) && $valueFor == 'dropdown')
{
$isActive = [1];
}else{
$isActive = [0,1];
}
$data = $this->VehicleTypeMasterModel->whereIn('is_active',$isActive)->findAll();
if (!$data) {
return $this->failNotFound('No data found');
@ -594,6 +605,10 @@ class MasterController extends ResourceController
$tableName = $this->request->getGet('table_name');
$pk = $this->request->getGet('pk');
$policy = $this->PolicyModel->where('enquiry_id',$pk)->first();
$pk = $policy['id'];
if (!$tableName || !$pk) {
return $this->response->setJSON([
'status' => 'failed',

View File

@ -21,6 +21,17 @@ class PolicyReportController extends Controller
$toDate = $this->request->getGet('to_date');
$fromDate = DateTime::createFromFormat('d-m-Y', $fromDate)->format('Y-m-d 00:00:00');
$toDate = DateTime::createFromFormat('d-m-Y', $toDate)->format('Y-m-d 23:59:59');
$show_policy_report = $this->request->getGet('show_policy_report') ?? 'All';
if ($show_policy_report === 'Verified') {
$statusValues = [1];
} elseif ($show_policy_report === 'Not Verified') {
$statusValues = [0];
} else {
$statusValues = [0, 1];
}
if (!$managerId || !$fromDate || !$toDate) {
return $this->response->setJSON([
@ -189,7 +200,14 @@ class PolicyReportController extends Controller
AND pp.created_on BETWEEN ? AND ?
AND pe.manager_id = ?";
$bindings = [$fromDate, $toDate, $managerId];
$bindings = [$fromDate, $toDate, $managerId ];
$whereIn = implode(',', array_fill(0, count($statusValues), '?'));
if (!empty($statusValues)) {
$sql .= " AND pp.is_data_accuracy_checked IN ($whereIn)";
$bindings = array_merge($bindings, $statusValues);
}
$search = $this->request->getGet('search');
@ -228,6 +246,8 @@ class PolicyReportController extends Controller
$data = $query->getResultArray();
// dd($whereIn, $bindings,$query,$data);
// -----------------------------
// EXCEL GENERATION
// -----------------------------
@ -252,6 +272,8 @@ class PolicyReportController extends Controller
'PARTNER NAME',
'BOOKING REF NO',
'INSURED DATE',
'INSURER',
'PLAN TYPE',
'POLICY NO',
'INSURED NAME',
'REG NO',
@ -299,6 +321,8 @@ class PolicyReportController extends Controller
$d['partner_name'],
$d['booking_ref_no'],
$d['issued_date'],
$d['insurer'],
$d['plan_type'],
$d['policy_number'],
$d['insured_name'],
$d['reg_no'],

View File

@ -40,7 +40,7 @@ class EnquiryModel extends Model
protected $updatedField = 'updated_on';
public function getEnquiry($getBy = null , $Id = null , $only_policy_data = false, $from_date = null, $to_date = null , $status = null , $enquiry_status = null)
public function getEnquiry($getBy = null , $Id = null , $only_policy_data = false, $show_policy_report = 'All', $from_date = null, $to_date = null , $status = null , $enquiry_status = null)
{
$data = $this->select('partner_enquiry.*, partner_enquiry.name as insured_name,
VT.vehicle_type as vehicle_type,
@ -88,11 +88,21 @@ class EnquiryModel extends Model
if($only_policy_data){
$data->where('P.id IS NOT NULL');
if($from_date != null){
$data->where("P.created_on >=", $from_date)
->where("P.created_on <=", $to_date);
}
if($show_policy_report == 'Verified')
{
$data->where("P.is_data_accuracy_checked", "1");
}else if($show_policy_report == 'Not Verified')
{
$data->where("P.is_data_accuracy_checked", "0");
}
}else{
if($from_date != null){
$data->where("partner_enquiry.created_on >=", $from_date)