FIX_INCEPTION_EXPORT : RV
This commit is contained in:
parent
dd2131ff55
commit
7d934d781d
@ -2477,7 +2477,8 @@ class EmployeeController extends AdminController
|
|||||||
//------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
public function test_members_list(){
|
public function test_members_list()
|
||||||
|
{
|
||||||
// $model = new EmployeeModel();
|
// $model = new EmployeeModel();
|
||||||
// $list = [
|
// $list = [
|
||||||
// ['relationship' => 'spouse','emp_code' => 'TEST002', 'name' => 'Lakshmi','email_personal' => 'lakshmi@gmail.com','mobile'=>'6382156701','gender'=>'female','dob'=>'1996-05-19','doj'=>'2022-02-01','basic_pay'=>'100000','emp_status'=>'enrolled'],
|
// ['relationship' => 'spouse','emp_code' => 'TEST002', 'name' => 'Lakshmi','email_personal' => 'lakshmi@gmail.com','mobile'=>'6382156701','gender'=>'female','dob'=>'1996-05-19','doj'=>'2022-02-01','basic_pay'=>'100000','emp_status'=>'enrolled'],
|
||||||
@ -2500,7 +2501,8 @@ class EmployeeController extends AdminController
|
|||||||
return $this->loadLayout('test_members_list',$data);
|
return $this->loadLayout('test_members_list',$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mapEmployees(){
|
public function mapEmployees()
|
||||||
|
{
|
||||||
$client_id = $this->request->getPost('client_id');
|
$client_id = $this->request->getPost('client_id');
|
||||||
$branch_id = $this->request->getPost('branch_id');
|
$branch_id = $this->request->getPost('branch_id');
|
||||||
$policy_id = $this->request->getPost('client_policy_id');
|
$policy_id = $this->request->getPost('client_policy_id');
|
||||||
@ -2534,7 +2536,8 @@ class EmployeeController extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDataForMapping(){
|
public function getDataForMapping()
|
||||||
|
{
|
||||||
$policy_id = $this->request->getPost('policy_id');log_message('error',$policy_id);
|
$policy_id = $this->request->getPost('policy_id');log_message('error',$policy_id);
|
||||||
$data['policy_start_date'] = $this->clientPolicyModel->select('policy_start_date')->where('id',$policy_id)->first()['policy_start_date'];
|
$data['policy_start_date'] = $this->clientPolicyModel->select('policy_start_date')->where('id',$policy_id)->first()['policy_start_date'];
|
||||||
$data['si_amt'] = $this->PolicyPremium2Model->select('si')->where('client_policy_id', $policy_id)->groupBy('si')->findAll();
|
$data['si_amt'] = $this->PolicyPremium2Model->select('si')->where('client_policy_id', $policy_id)->groupBy('si')->findAll();
|
||||||
@ -2542,7 +2545,8 @@ class EmployeeController extends AdminController
|
|||||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $data], 200);
|
return $this->respond(['status' => true, 'code' => 200, 'data' => $data], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function unmapEmployees($actionType){
|
public function unmapEmployees($actionType)
|
||||||
|
{
|
||||||
$selected_employees = (array)$this->request->getPost('selected');
|
$selected_employees = (array)$this->request->getPost('selected');
|
||||||
if($actionType == 0){
|
if($actionType == 0){
|
||||||
for($i = 0;$i<count($selected_employees);$i++){log_message('error',$selected_employees[$i]);
|
for($i = 0;$i<count($selected_employees);$i++){log_message('error',$selected_employees[$i]);
|
||||||
@ -2636,7 +2640,6 @@ class EmployeeController extends AdminController
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
public function generateAcmAndMForEcard($client_id)
|
public function generateAcmAndMForEcard($client_id)
|
||||||
{
|
{
|
||||||
$db = db_connect();
|
$db = db_connect();
|
||||||
@ -2675,9 +2678,8 @@ class EmployeeController extends AdminController
|
|||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getEmpHistory()
|
||||||
|
{
|
||||||
public function getEmpHistory(){
|
|
||||||
|
|
||||||
$emp_id = $this->request->getPost('emp_id');
|
$emp_id = $this->request->getPost('emp_id');
|
||||||
|
|
||||||
@ -2712,7 +2714,8 @@ class EmployeeController extends AdminController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formatFieldName($unformattedString){
|
public function formatFieldName($unformattedString)
|
||||||
|
{
|
||||||
|
|
||||||
if (str_contains($unformattedString, '_')) {
|
if (str_contains($unformattedString, '_')) {
|
||||||
$data = str_replace('_', ' ', $unformattedString);
|
$data = str_replace('_', ' ', $unformattedString);
|
||||||
@ -2726,88 +2729,88 @@ class EmployeeController extends AdminController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
public function download_inception()
|
||||||
|
{
|
||||||
|
$client = $this->request->getPost('client');
|
||||||
|
$branch = $this->request->getPost('branch');
|
||||||
|
$policies = $this->request->getPost('policies');
|
||||||
|
$status = $this->request->getPost('status');
|
||||||
|
$empCode = $this->request->getPost('empCode');
|
||||||
|
$empName = $this->request->getPost('empName');
|
||||||
|
|
||||||
public function download_inception()
|
$result = $this->employeePolicyModel->download_inception(
|
||||||
{
|
$client, $branch, $policies, $status, $empCode, $empName
|
||||||
$client = $this->request->getPost('client');
|
);
|
||||||
$branch = $this->request->getPost('branch');
|
|
||||||
$policies = $this->request->getPost('policies');
|
|
||||||
$status = $this->request->getPost('status');
|
|
||||||
$empCode = $this->request->getPost('empCode');
|
|
||||||
$empName = $this->request->getPost('empName');
|
|
||||||
|
|
||||||
$result = $this->employeePolicyModel->download_inception(
|
if (empty($result)) {
|
||||||
$client, $branch, $policies, $status, $empCode, $empName
|
return $this->response->setStatusCode(204)->setBody('No data found');
|
||||||
);
|
}
|
||||||
|
|
||||||
if (empty($result)) {
|
$formatted = [];
|
||||||
return $this->response->setStatusCode(204)->setBody('No data found');
|
foreach ($result as $index => $row) {
|
||||||
}
|
$rowWithSerial = ['S.NO' => $index + 1] + $row;
|
||||||
|
$formatted[] = $rowWithSerial;
|
||||||
|
}
|
||||||
|
$result = $formatted;
|
||||||
|
|
||||||
$formatted = [];
|
$spreadsheet = new Spreadsheet();
|
||||||
foreach ($result as $index => $row) {
|
$sheet = $spreadsheet->getActiveSheet();
|
||||||
$rowWithSerial = ['S.NO' => $index + 1] + $row;
|
|
||||||
$formatted[] = $rowWithSerial;
|
|
||||||
}
|
|
||||||
$result = $formatted;
|
|
||||||
|
|
||||||
$spreadsheet = new Spreadsheet();
|
$headers = array_keys($result[0]);
|
||||||
$sheet = $spreadsheet->getActiveSheet();
|
$columnWidth = 20; // standard column width
|
||||||
|
|
||||||
$headers = array_keys($result[0]);
|
|
||||||
$columnWidth = 20; // standard column width
|
|
||||||
|
|
||||||
$colIndex = 1;
|
|
||||||
foreach ($headers as $header) {
|
|
||||||
$columnLetter = Coordinate::stringFromColumnIndex($colIndex);
|
|
||||||
$cellCoordinate = $columnLetter . '1';
|
|
||||||
|
|
||||||
$sheet->setCellValue($cellCoordinate, ucfirst(str_replace('_', ' ', $header)));
|
|
||||||
|
|
||||||
$sheet->getColumnDimension($columnLetter)->setWidth($columnWidth);
|
|
||||||
|
|
||||||
$style = $sheet->getStyle($cellCoordinate);
|
|
||||||
$style->getFont()->setBold(true);
|
|
||||||
$style->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
|
|
||||||
$style->getBorders()->getAllBorders()->setBorderStyle(Border::BORDER_THIN);
|
|
||||||
|
|
||||||
$colIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$rowNum = 2;
|
|
||||||
foreach ($result as $row) {
|
|
||||||
$colIndex = 1;
|
$colIndex = 1;
|
||||||
foreach ($row as $cell) {
|
foreach ($headers as $header) {
|
||||||
$columnLetter = Coordinate::stringFromColumnIndex($colIndex);
|
$columnLetter = Coordinate::stringFromColumnIndex($colIndex);
|
||||||
$cellCoordinate = $columnLetter . $rowNum;
|
$cellCoordinate = $columnLetter . '1';
|
||||||
$sheet->setCellValue($cellCoordinate, $cell);
|
|
||||||
|
$sheet->setCellValue($cellCoordinate, ucfirst(str_replace('_', ' ', $header)));
|
||||||
|
|
||||||
|
$sheet->getColumnDimension($columnLetter)->setWidth($columnWidth);
|
||||||
|
|
||||||
|
$style = $sheet->getStyle($cellCoordinate);
|
||||||
|
$style->getFont()->setBold(true);
|
||||||
|
$style->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
|
||||||
|
$style->getBorders()->getAllBorders()->setBorderStyle(Border::BORDER_THIN);
|
||||||
|
|
||||||
$colIndex++;
|
$colIndex++;
|
||||||
}
|
}
|
||||||
$rowNum++;
|
|
||||||
|
$rowNum = 2;
|
||||||
|
foreach ($result as $row) {
|
||||||
|
$colIndex = 1;
|
||||||
|
foreach ($row as $cell) {
|
||||||
|
$columnLetter = Coordinate::stringFromColumnIndex($colIndex);
|
||||||
|
$cellCoordinate = $columnLetter . $rowNum;
|
||||||
|
$sheet->setCellValue($cellCoordinate, $cell);
|
||||||
|
$colIndex++;
|
||||||
|
}
|
||||||
|
$rowNum++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$exportDir = WRITEPATH . 'exports';
|
||||||
|
if (!is_dir($exportDir)) {
|
||||||
|
mkdir($exportDir, 0777, true);
|
||||||
|
} else {
|
||||||
|
chmod($exportDir, 0777);
|
||||||
|
}
|
||||||
|
|
||||||
|
$filename = 'inception_export_' . date('Ymd_His') . '.xlsx';
|
||||||
|
$filepath = $exportDir . '/' . $filename;
|
||||||
|
|
||||||
|
$writer = new Xlsx($spreadsheet);
|
||||||
|
$writer->save($filepath);
|
||||||
|
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'status' => 'success',
|
||||||
|
'downloadUrl' => base_url('employee/download_file?file=' . urlencode($filename))
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$exportDir = WRITEPATH . 'exports';
|
|
||||||
if (!is_dir($exportDir)) {
|
|
||||||
mkdir($exportDir, 0777, true);
|
|
||||||
} else {
|
|
||||||
chmod($exportDir, 0777);
|
|
||||||
}
|
|
||||||
|
|
||||||
$filename = 'inception_export_' . date('Ymd_His') . '.xlsx';
|
|
||||||
$filepath = $exportDir . '/' . $filename;
|
|
||||||
|
|
||||||
$writer = new Xlsx($spreadsheet);
|
|
||||||
$writer->save($filepath);
|
|
||||||
|
|
||||||
return $this->response->setJSON([
|
|
||||||
'status' => 'success',
|
|
||||||
'downloadUrl' => base_url('employee/download_file?file=' . urlencode($filename))
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function download_file()
|
public function download_file()
|
||||||
{
|
{
|
||||||
$filename = $this->request->getGet('file');
|
$filename = $this->request->getGet('file');
|
||||||
|
|||||||
@ -1862,15 +1862,18 @@ class EmployeePolicyModel extends Model
|
|||||||
|
|
||||||
'employee_polices.basic_cover_si As `Basic cover SI`',
|
'employee_polices.basic_cover_si As `Basic cover SI`',
|
||||||
|
|
||||||
|
"DATE_FORMAT(employee_polices.date_coverage, '%d-%b-%Y') AS `Date of Coverage`",
|
||||||
"DATE_FORMAT(emp.doj, '%d-%b-%Y') AS `DOJ`",
|
"DATE_FORMAT(emp.doj, '%d-%b-%Y') AS `DOJ`",
|
||||||
'emp.basic_pay As `Basic Pay`',
|
'emp.basic_pay As `Basic Pay`',
|
||||||
'emp.band As `Band/Grade`',
|
'emp.band As `Band/Grade`',
|
||||||
|
'emp.designation As `Designation`',
|
||||||
|
|
||||||
'emp.mobile as Phone',
|
'emp.mobile as Phone',
|
||||||
'emp.email_corporate As Email',
|
'emp.email_corporate As Email',
|
||||||
'emp.change_event',
|
|
||||||
|
|
||||||
'employee_polices.pre_existing_alignments as `PRE EXISTING AILMENTS`',
|
'COALESCE(employee_polices.pre_existing_alignments, 0) as `PRE EXISTING AILMENTS`',
|
||||||
|
|
||||||
|
'emp.change_event',
|
||||||
'employee_polices.date_of_exit',
|
'employee_polices.date_of_exit',
|
||||||
'employee_polices.reason_for_exit',
|
'employee_polices.reason_for_exit',
|
||||||
|
|
||||||
@ -1902,25 +1905,27 @@ class EmployeePolicyModel extends Model
|
|||||||
$result->where('employee_polices.client_policy_id', $policy_id);
|
$result->where('employee_polices.client_policy_id', $policy_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($status) && count($status) > 0) {
|
// if (is_array($status) && count($status) > 0) {
|
||||||
|
|
||||||
$result->where('employee_polices.status !=', 'expired');
|
// $result->where('employee_polices.status !=', 'expired');
|
||||||
|
|
||||||
if (in_array("active", $status)) {
|
// if (in_array("active", $status)) {
|
||||||
|
|
||||||
$result->where('employee_polices.tpa_id IS NOT NULL');
|
// $result->where('employee_polices.tpa_id IS NOT NULL');
|
||||||
$result->where('employee_polices.uhid IS NOT NULL');
|
// $result->where('employee_polices.uhid IS NOT NULL');
|
||||||
$result->whereIn('employee_polices.status', $status);
|
// $result->whereIn('employee_polices.status', $status);
|
||||||
} elseif (in_array("pending", $status)) {
|
// } elseif (in_array("pending", $status)) {
|
||||||
|
|
||||||
$result->where('employee_polices.tpa_id IS NULL');
|
// $result->where('employee_polices.tpa_id IS NULL');
|
||||||
$result->where('employee_polices.uhid IS NULL');
|
// $result->where('employee_polices.uhid IS NULL');
|
||||||
$result->whereIn('employee_polices.status', array_merge($status, ['active']));
|
// $result->whereIn('employee_polices.status', array_merge($status, ['active']));
|
||||||
} else {
|
// } else {
|
||||||
|
|
||||||
$result->whereIn('employee_polices.status', $status);
|
// $result->whereIn('employee_polices.status', $status);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
$result->where('employee_polices.status =', 'enrolled');
|
||||||
|
|
||||||
if (!empty(trim($emp_code))) {
|
if (!empty(trim($emp_code))) {
|
||||||
$result->where('emp.emp_code', $emp_code);
|
$result->where('emp.emp_code', $emp_code);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user