From 53aba4d3facc86de98b88dc3cdb4b0fdbd919dd0 Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Tue, 27 Oct 2020 14:39:51 +0530 Subject: [PATCH] SMC EXCEL LIB ADDED --- .../helpers/readexceldata_helper.php | 79 +++++++++++++++++++ api/application/libraries/Myspreadsheet.php | 29 +++++++ 2 files changed, 108 insertions(+) create mode 100644 api/application/helpers/readexceldata_helper.php create mode 100644 api/application/libraries/Myspreadsheet.php diff --git a/api/application/helpers/readexceldata_helper.php b/api/application/helpers/readexceldata_helper.php new file mode 100644 index 00000000..8cdffece --- /dev/null +++ b/api/application/helpers/readexceldata_helper.php @@ -0,0 +1,79 @@ +load->library('myspreadsheet'); + + + // $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName); + $spreadsheet_io_fact = $CI->myspreadsheet->getIOFactory($file_path_withname); + //$curr_spreadshett = $spreadsheet_io_fact::load($file_path_withname); + //echo $spreadsheet_io_fact->getSheetCount(); + $spreadsheet_io_fact->setActiveSheetIndex(0); + $sheetData = $spreadsheet_io_fact->getActiveSheet()->toArray(null, false, false, true); + // print_r($sheetData); + return SELF::seperateSectionData($section_id,$sheetData); + + // $CI->load->model('PD_Model'); + //return ( $CI->PD_Model->selectCustomRecords(array('pd_co_applicant_id','applicant_name'),array('fk_pd_id' => $pd_id),PDAPPLICANTSDETAILS)); + + // return array('sam'=>'dsnlskdnm'); + // print_r(array('sam'=>'dsnlskdnm')); + + + } + + static function seperateSectionData($section_id,$sheetData) + { + //echo 'worked';die(); + $CI =&get_instance(); + $CI->load->model('PD_Model'); + $section_ref_data = $CI->PD_Model->selectCustomRecords(array('*'),array('isactive' => 1,'section_id' => $section_id),EXCEL_COLUMN_REF_NAME); + $return_data = array(); + if($section_id == null) + { + unset($sheetData[1]); + foreach ($sheetData as $key => $value) + { + + // print_r($value['C']);die(); + $temp['key_name'] = SELF::returnMatchedData($section_ref_data,$value); + $temp['value'] = $value['C']; + $return_data[] = $temp; + if($key == 5) + { + break; + } + } + } + return ($return_data); + + } + + static function returnMatchedData($arr,$val) + { + foreach ($arr as $key => $value) + { + if($val['A'] == $value['ref']) + { + return $value['key_name']; + } + } + } + + public static function getApplicantsNameById($id,$latest_applicants_names,$type = 1) //$type i for return name only, 2 for return title only, and 3 for return both + { + foreach ($latest_applicants_names as $key => $value) { + + if($id == $value['pd_co_applicant_id']) + { + return $type == 1 ? $value['applicant_name'] : ($type == 2 ? $value['title'] : ($value['title'].' '.$value['applicant_name'])); + } + } + } +} +?> \ No newline at end of file diff --git a/api/application/libraries/Myspreadsheet.php b/api/application/libraries/Myspreadsheet.php new file mode 100644 index 00000000..e0cf28d0 --- /dev/null +++ b/api/application/libraries/Myspreadsheet.php @@ -0,0 +1,29 @@ +