JFIF   ( %!1!%)+...383,7(-.+  ++-+++++-++-++--+--+-+-------+-++-+--+---+++--+7+-+"F!1AQaq"2BRb#3Sr$CDsT&!Q1Aa"2Rbq ?򉄘ǷLR HR,nNb .&W)fJbMOYxj-\bT2(4CQ"qiC/ " %0Jl"e2V  0SDd2@TV^{cW&F͉x9#l,.XɳvRZ C8S 6ml!@!E! `FS!M #(d)Q lml1ml Ų&x(ʨ2NFmj@D<dN5UN˄uTB emLAy#` ` ` I!I 6āHBxL & J#7BQ.$hv h q+tC"EJ) 8R e2U2Y@j%6PF^4LnNBp"8)4JI-ֲvK ^؊)hz[T5˗",Rҥf8ڤS4ʘ!`D ` X+ L,(hl)*S##`6[`0*L T H*HA@I&&r1kr*r*)N$#L  1#ZFSl `[( ("((he`4 Ch [="A R / 0I`twCDcWh"i) cLad\BcLKHZ"ZEW$Ƚ@A~i^`S *A&h:+c Y6vϕGClRPs.`H`(@<$qDe pL@DpLX, E2MP A  `II m& AQ "AT rbg# g2!SiLj*3L \ G;TFL`K BMy 2S`YLh1 d >-"ZfD^Q DH" RAbEV#Lfq,(rETp64-IJ!*p4F$q;G8DQ/TKP2$jp3KW]FtLtƉ1ol]VBgػJH6 )h61GJR7Nj.Z4piJRDd]t]0dP]:N.b'⹙SvDSz]L,_#ugT&[~?cS^"{Bh{/=ۑxOk̳O59o dar793`)SeYM@\ "$E(Tm&)N2Ih)F5EDed(FS,Pa @!@#@lea HCD$11jCLJqcod S3yd*,lL+QEfsgW1nw)cT#dS HXkFJB"6(ʝH)H"#EZh:Y`khݳh%Sc<mlAko2]gDqQtro=3OƸU9_-t8UvW3sGəg*#:c)><"wc\ASmT|6Ę>9~#1Ƈ~ڒE1vVi# I MM#u$8W 5ǍfƬΜg*Qpi1ȩFOf۔S,/⎯(Lrմ`(Z LsbA \6 6dm[I=!r:REI.wgzG)ԇSbӑxuׇTyyL^e'x^ty4Z&eB]I|v59Jjhm;Ng񷫳n<ϞҼѝjk;׹DlY^ҍ\+x9V!j([cmS.NO6jxNζrm&oײizT$N>?~ Sl-:iڥk\at#E!CL`.O0a*w/WV7/r)DŽt7'Nĵ#7O1 ]{[/-2bA<$&Gm_4t)_>)mjG;V^'k59o>ɌM,ؾf9z6 4v_3T.5V/RD-5 %T5XTޫ4TaZ`U *ƱUƲ UG"5+sJJ2E9#܎kr2G3Bb,XM6H: ?@p!'\4V02aԙ) hbZ]:` ev3ʘ'}!ohȒ*TJjr[RFyQ*#{h{R]J]Lr-.D-.җfo$D ?X0%~1P.Og{cWϫ22&Ϭ_V.W3nmiOl}+!˫#`kR33aUb0-g:qmsέ+0HO|&nhOn+}n5QF_"gvLm/z'+r'n_oC语i|1}Gi|}_D~9JZ_%DVQp\koۅjAs~/c0ksUJi^W9W5!>?O:q|ˣSIB/&K<(lg(%Wg$|LW7vߤW߇q|jef3D H\S6(eJb*@&sTKTW/*@v:.N- @ITʓ1Zg&-eꓝM r]EMס{q$b]'7Z7N:O~lNlP7iͲk)$O^퉢<YSD*hr'Z#5e6t[Fdh AJǔP9P 1\R).Il+jI*,(ܢ22N*OwKFX gc?\mB7iA+εe8 "ġ/p5pW-$މ-[a 5ViAW/V{/&UsF./՞ҕ*)rZg.^_+gt_z-oAbqQn*WlHyZ*\TaEewlLR3ԹȭN}MM}aih"5ܕRT$:~'TcT|*)xGC>n+r{XU xuF"<~67у'fxlf`r3D*#Z1ђfH`2dIWo/qB| 63xxW6^m%Kvg>\>x>!H5Nr8J/FJ9Wx(Hou" S'kWاC\9ְ#^OaҮ+~gnkuЉ,aWU*1 읍jnb|e= :2.UL`Q}YS&gI.c=a`%j:C%2@^>])25/ܙ<lzwɛ)ݣS4h3=J tyϬ.E7 8ڞGZu\_JHsݢϑ}IZ"ӳ=X<Ɖ2{a:{7L+>V}c)*lo Yv&+|L;>+/Sj26K+澡*;>-s"}M2] Ig5aCL*r"&\} #^R.7_Mgf}.ߌy(}Z\gP&ʠHj%</{.]rߙQ`>;5g;u6dԛ %xb|oՋTJ5Ϥ(]XqP>f{Jk2,8'~ZU6tMQsg XKg^2ϓ3},[wo۴I|ܷ%[Ol\Pkr]Y//cg6U⧻/VПi8ys_n<\~cze!!H~x;QJZKȮ^ȧG|cS~8ji,Fo+,y~?pk)u /in3JmkX(Mj1N 4c Epc>BO *LfQO&` c;LjcYf 1ɻ)CLsY^Y5" lP/wuEln&dav,(;'W9ej ku`-KHI՟%ԁʁ 1\}?OjsF^Xn$Ё.օC>D:?I @aGE.ĩ1 $ et~T`߸Ir'RX.Zwc%~U=r>-UaFbǺ?R=Z?i'[ASS;siJrzy>nxu$[_B\4}:r'ҵj1_v-[;y?ֹ0I16 . M%4^!S&t ! h !zQð.bBT ?@]?CHq(rd!.$>/x+bnʎNN#w)` )*f!-ɂ\(طYLHzc`Uq7BfCcE0ԉ4Fم쏠ce5T r͸GVlФ?ѣ} mhrkly.Ts㷖)Mө S^%'g>wk%bP[}j~ǾV#K -Fgv켼ǨgɼeSz/6{M=BPZFu\Q75n3Iݤ.W9QfF{vJwF't[@iVj4G~KOnH߿_Do=.c.One?E+GfGN⧭H?4;u`ua|V-+j4?48n ɦ=-]puv&Jc}K>b%U x8pz6L8AXFsW]N55ҦbIWZQ7ï Ԗ3cjz匩ӺOTɖƴ%a'MI}cdR$ݚIζ̝ LIu>J3{^෠㜦˯xܿe\b"2y'x{ RDW b+o2KFhR0:U늞En>լRӉt Iڹ\ wշQEv"v;EJ)yl[5:F0=b4,\PqKtv4{bQz:>C7"8W#Zjdd| cjz%K %Z 9dD{=NFʳAƩtI)kS*s$`:A\ʬ*ֹ9{Nl|eJ١rQnM%z_#x_•TO><)kyD %GN<~y>vfǧB)F)c\lې(#\ h`fgfjTBdhhHL2Y0^ Y0^-"D!QaI15 m~ gՒd|;#gMn(P$l H.R2^PU")pN` N8󫅂OJ;^jz\uumJMF|ηq[]$Vrrt:Q^;QPkHՠ{]HwˆMuIr7!r&- j%"9LtUb56+^TWBqdhHAD7 HwKH^F3LIq #hK`]IWKiH?کǴeԥQ>g{^q^>HKoOB||8aݏS}{S_]ϸ/X~ܵw'OSPAf֩ܟ[>7 @[ֵ;G߇QU*Cթ *OKU^zz[fRnpcJX9u<iq8B]u8 ]I,;[G#2W.¸D8rPG Y%PBJ= wo;PJgx6;yB`3zZGPAͫy{5Nb_re*ONHR]Ji)U{Ӓ:qqɏ[mB4࢒I$ 2vpBADY`DIVAn"Bh$&&cMbdB 鮆wHR'E(ѸZA*H~{B M҅n\@N{7ISCp Vd( r+bg|ns:qg:|J|ɪV.UVaAS͓FyRuLѦT騬 `3􏳕{eo/Tz8DkW?,cl~TqLne֠[B*D +t 6˦S;5KjV3e WBrT.XSHm sl5F%NGM`Y )": J!W4]HTrPX2 QYɕ\m2VLd+`,^ѺiPztUGY6+cӧ6] U%u/ˈFOiB*nFF#ұJ Z/c')?Q͟5.8E~G6e<\?}GkhMFUظOqhEA - "`dQ#(4Ԧf VLmc@q5J8K; M^JZnn)9Zm\ qIJqS: i[9~Oaƒ]Z4F&+666( N]쁼LM(oyvUI/Χ[ھ]hTˉG".SeYgu;hRDtڬv=5 ׁqMS\Ȭi5D]1$*0UL1QY`QdLb[+z9";'yi`OT/4{@EZ'Y0>4I*d nM#5hі.vrM[]Ä;]\ʦS,叕DQZq0fӌI͋]TNK"#;?F;aURx_4WDm+F*0XJE@){ 1R-E2(@Qh l D rT.Q;[J;[`30`ɀ 2#=JeSsxRjG=`H rLJ@ Y$JaB2/x( "Id'6O0CI$:Ol+}I>[L|iK+]ZrH*2Aʶ uHRd)OrrbSx=5dmue1neܬ"e>Lw94勲u ҏ_4GuоJw]QtgSk(qW(6h|v= 1=P/\YZ|R>"*5W/ίR'o %R$5= .!VIRMf4*aR5nv% Usj:V Lj]Bn/TZ&.2„ܒBP)aYRʌW!#ErGf';tW$czI*\KI,c7Zc-ўj|p+-ђ{eg 2;R_{VLM]7sؒFmԻy853gҾqJG!E̤ӏqzs༿? U#R)ŧU(,>,&,-^e^۔.b EW^n<)\9.QeJuFiSh2"EL8yeCKQD\5R,D5.P]c1STt*ZFJ.T:N #%]M}khOe(͓iEMsɆ3( YF<"Ly^*[ry6.ɸm k݊iT%nM8 $Q#F# q 1*?% iS^4oܗ wWPS,aNޖxOxڽqp#F6&o,7LJuMΤK(Td{U Ƹf|q5U{3[FLNK6ӵQY5+'>Q3FSk).&:5z yZq/*q$d+Ge+$lO@Nڤy5eBvˌ䖥shS:JksgksF ꧸oi-FYxy9[Vȼĝ'_.[y2U*c?E+:TsWՀgOS> z75>ncߏ-Kz8ԋ,Ϧ70Z9_1h$Xiu10)0$+$! qsE4wRkh2*T.s%DH:`:=k.'WB{ ȮRGҷ7чVg)CHS}1ݍԳۂ<8g_4y*-Ml\]mZT)mJ~|k<6zWjf4'*u%RNRȉZA) .VLtp 4 V&mtJ#l˅;&{]8>TmhoLXOeD^_J>]jsSej﫦iOM SK([!Vc5zn-A@p]Ӄ \3kmK>#-sܧ?NLar@Js?…Xldny]݌E5•9.8hh69#7js׳R,'pqt:kgPhRԄ+ՕG9}="ֲ\kǁm R73pg$t3+o |o\]'ee5ɐ.7ѐ|ZعSF{qkx5-$Q h5*1yM$ 7)hJ2Kg`-hn*>)EYDIkBpȩAzfǪ>7O K#lߤg]:u~huُ۵u}(mjGIj܏6ES~/5CiRy|kVKGBޭ3;w /jꏈUu>iƪi:WRo'yr4C/?c:w!?\'?#Q:>u/?uEeuG*xY2)?־CAr*23_ץ}գk1%(_ _6aԗ _4 $ϗ+ϫɆzǾIgu?Y<#_xS>i\uɇ۽r}[ͫyRoWCC!H,iD։"Cj5 4] cTk2YZRBvRY~FqQt^RO-g"QP]Ih/t:ljs YӹqI] wqXp KV+8j} uu8PGP&zF:;8+ Sx9(. Q}:ƻWr,Ũ*'shfƧ-6__5,DH{* qp묘G MA}QRe{dyMucǨɾ7߈Avϩe͜jmUi p3\5,ާbf:o+7#ܾ~iU#up=}˄k{NV8m!ҌiptޜBvKi}!ש3UK)`igӞVMR'J[ky~g&6vǍ7ķ>uXd(3瓓[]QTTqnͮz1~_͓k俸0~Z1գ =18cL 5^lf^k^<ҲJɬcC-[^;J8j_q=WpeA_6 4.Ntc>Sv2Jf;G8. 5[,;ArSTˬmpmzjGe EoǩOgDWaGhz<|kT\$Q=u/ci˜S mN&Ok~'0,a} s + NC-G'(*>vw~&*wYG Ŷ K-L/$߮l/A/^:Z@X- Q-D2`@M2+w$Q"胊"47&+Dh'9Y* L7VhT+ -?K]Ik \Ϣgy) s v z)Z ˦2&ލ OjmG9@8F_u䊜r>3K%Yg-FFI]e+Kxkzװy"\Q4Ri'0+P=V&Sw3N/U|UEt*uS c M*tsBE 2ʃ@Kir(˫LRr璜Zy@].%NbXvz덟 hӰNMe#|g͒po9^licxB[e' {U? mlt%?霋ǒxZc X]ϗ15SeE{-Ӕi~DƯO|ë5a@G=%<ƧAs*+tzo, IpȔ|:X6J3Z5JXd]2 3%v*GvE@(S&SX7D0^{5t Z{ﮄsh- ]ɑqEV=^Ki9äBtI@&pEg*O<`F-}ǎ51H,<~qibQѓɳx#l$G9td1U+Sq%B[jOq+^ޏ7K >YY  $KK{*˝e"|$g"6v,,9.DaA,qэI~ܨ|kdv; hz2]x5{M5M~yלqTzUl9Mӏ.WVnkun !jzKO!v|& ;gۇ2BrI閵C tqHe[Zkގ=Q;OԶiᵞBcIU eN cOGz S__>.hNgG6).J$_Taѯ5^LqeB]O?A]H;ò{^0ٺuޚxB|:q'xu4"9Ο7k^eZ_fQOmzm̗{c3ٵKO|m*ek(8"yO(ٵ{LJb2Ǩkgg1_/qrDՆ[_l\ I~Bsc/x ),,̿@PFޞ>O)<<=5m=^x6}~6qoYGޣiY{uN+<,CǚwVxe~c!,5R4u/9In=G•^PF6ɼM򿶤$"\|78ؖYU cXFOKc4s-=6O<;.ϴ޶$q>e? qY}StirX?e/&R'ʑ[ѯMi{?8\g^>\!-VZCf.ȾzRWMh_{^H)mz}V%չM.EJUz7z>ZW6\BW~:W3!S_4~m ǚ! ;VeGKFڵ858Buj:ZZ(/H׭eav!$gpLV)țAJO~YBꤞ厅XJdjg{hR9~_f '5U+}W5%ZjzgTtozYD @%JK\qymeЪKIIp"xoz\B1$G)8Ԅ Jeyc".yyVBR-%BEA-k^Luj cYwԄ%X!e-4ZRḡlJvYsB԰˗0?RM\TlaߏVu4BmY!UyYylgd!m2$i=[hN,6)_~7͖CDF2zÕ{?l;Hܲk׋!/XAłrCXEI{]P[e! ?%Ktqܱ5! jַĞ*TvAG)fuxTҖV7~ 4=r! ob%jTwU$Bnqed䤿@0P&V]HJ)^YrޯĿbsY8=1! n}UD*7uƫi~!s[W{V9J;~Ӯ|[3s۷dڔIj?qJ'O,IkE]G(5\ۖ7)-g,ŶǗ=~e>k쐁%(g˦o[fxN_baGBm:܆VGЗ,G_D!/og,ҢVܤ_iS_~@ SkidSec Webshell

SkidSec WebShell

Server Address : 172.31.38.4

Web Server : Apache/2.4.58 (Ubuntu)

Uname : Linux ip-172-31-38-4 6.14.0-1017-aws #17~24.04.1-Ubuntu SMP Wed Nov 5 10:48:17 UTC 2025 x86_64

PHP Version : 7.4.33



Current Path : /var/www/html/milestone/application/modules/excel/controllers/



Current File : /var/www/html/milestone/application/modules/excel/controllers/Excel-old.php
<?php defined('BASEPATH') OR exit('No direct script access allowed');

require_once APPPATH.'modules/generic/controllers/Generic.php';
require FCPATH . '/vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\IOFactory;

/**
 * 	Author : Amit Kashte
 */
class Excel extends Generic{

	function __construct() {
		parent::__construct();
		$this->load->model('Mdl_excel');
	}

	function downloadExcel(){
		// if(! Modules::run('security/isAdmin')){
		// 	redirect('admin','refresh');
		// }
		
		$template = 'admin';
		$data['viewFile'] = "account/excel-download";
		$data['module'] = "admin";
		echo Modules::run('template/'.$template, $data);
	}

	//code for export excel registration with limit
	function registrationWithLimit(){
		$content = $this->input->post();
		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
		$spreadsheet->getProperties()->setCreator("NASSCOM Foundation ‘TechForGood’ Awards")
			->setLastModifiedBy("NASSCOM Foundation ‘TechForGood’ Awards")
			->setTitle('Applications Master')
			->setSubject('')
			->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:CH1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A','AS') as $columnID){
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}

		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Registration Date');
		$sheet->setCellValue('C1', 'Registration ID');
		$sheet->setCellValue('D1', 'Registration Status');
		$sheet->setCellValue('E1', 'UID');
		$sheet->setCellValue('F1', 'Full Name');
		$sheet->setCellValue('G1', 'Email');
		$sheet->setCellValue('H1', 'Company Name');
		$sheet->setCellValue('I1', 'Contact Number');
		$sheet->setCellValue('J1', 'Password');
		$sheet->setCellValue('K1', 'Email Verification');
		
		if(isset($content['limit']) && isset($content['offset']) && $content['limit'] != "" && $content['offset'] != ""){
			$start = $content['limit'];
			$end = $content['offset'];
		} else {
			$start = 10000;
			$end = 0;
		}
		$registrationQuery = "SELECT * FROM registration as r limit $start offset $end ";
		$records = $this->Mdl_excel->customQuery($registrationQuery);
		$excel_row = 2;
		$nos = 1;

		if( $records !== "NA" ){
			foreach($records as $r){
				$date = date("Y-m-d H:i:s", strtotime($r->created_at));
				
				$sheet->setCellValue('A'.$excel_row, $nos);
				$sheet->setCellValue('B'.$excel_row, $date);
				$sheet->setCellValue('C'.$excel_row, $r->registration_id);
				$sheet->setCellValue('D'.$excel_row, ucfirst($r->status));
				$sheet->setCellValue('E'.$excel_row, $r->uid);
				$sheet->setCellValue('F'.$excel_row, $r->full_name);
				$sheet->setCellValue('G'.$excel_row, $r->email);
				$sheet->setCellValue('H'.$excel_row, $r->company_name	);
				$sheet->setCellValue('I'.$excel_row, $r->contact_no);
				$sheet->setCellValue('J'.$excel_row, $r->password_txt);
				$sheet->setCellValue('K'.$excel_row, ucfirst($r->email_verification));

				$excel_row++;
				$nos++;
			}
		}
		//ob_clean();
		//$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Registration Master.xlsx"'); 
		header('Cache-Control: max-age=0');

		// download file 
		$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, "Xlsx");
		$writer->save('php://output'); 
	}
	/////end

	//code for export excel application with limit
	function applicationWithLimit(){
		$content = $this->input->post();
		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
		$spreadsheet->getProperties()->setCreator("NASSCOM Foundation ‘TechForGood’ Awards")
			->setLastModifiedBy("NASSCOM Foundation ‘TechForGood’ Awards")
			->setTitle('Applications Master')
			->setSubject('')
			->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:CH1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A','AS') as $columnID){
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}

		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Date');
		$sheet->setCellValue('C1', 'Application Status');
		$sheet->setCellValue('D1', 'EY Assessment');
		$sheet->setCellValue('E1', 'Application Number');
		$sheet->setCellValue('F1', 'Application Code');
		$sheet->setCellValue('G1', 'Selected Segment');
		$sheet->setCellValue('H1', 'Selected Category');
		$sheet->setCellValue('I1', 'Name of the Company / Organization');
		$sheet->setCellValue('J1', 'Give a brief about your NGP/NPO');
		$sheet->setCellValue('K1', 'Full Name');
		$sheet->setCellValue('L1', 'Email');
		$sheet->setCellValue('M1', 'Designation');
		$sheet->setCellValue('N1', 'Contact Number');
		$sheet->setCellValue('O1', 'Year of Incorporation');
		$sheet->setCellValue('P1', 'Legal status of the NGO/NPO');
		$sheet->setCellValue('Q1', 'Website link');
		$sheet->setCellValue('R1', 'Registered office address');
		//segment A and C (All Category)
		$sheet->setCellValue('S1', 'Company Revenue in Crore (INR)(Standalone) (2023-2024)');
		$sheet->setCellValue('T1', 'Company Revenue in Crore (INR)(Standalone) (2022-2023)');
		//All Segment (all Category)
		$sheet->setCellValue('U1', 'Number of employees (2023-2024)');
		$sheet->setCellValue('V1', 'Number of employees (2022-2023)');
		//segment A and C (All Category)
		$sheet->setCellValue('W1', '% of annual budget allocated to Tech (2023-2024)');
		$sheet->setCellValue('X1', '% of annual budget allocated to Tech (2022-2023)');
		//segment A and B
		$sheet->setCellValue('Y1', 'Number of technology-driven initiatives for social good undertaken (2023-2024)');
		$sheet->setCellValue('Z1', 'Number of technology-driven initiatives for social good undertaken (2022-2023)');
		//segment A and C (All Category)
		$sheet->setCellValue('AA1', 'Total financial investment allocated to technology-driven initiatives for social good (2023-2024)');
		$sheet->setCellValue('AB1', 'Total financial investment allocated to technology-driven initiatives for social good (2022-2023)');
		//segment B
		$sheet->setCellValue('AC1', 'Type of funding received for technology-driven initiatives for social good (2023-2024)');
		$sheet->setCellValue('AD1', 'Type of funding received for technology-driven initiatives for social good (2022-2023)');
		//segment C Category (social_innovation_through_tech,excellence_in_tech_volunteering)
		$sheet->setCellValue('AE1', 'Number of technology-driven initiatives undertaken for social good (2023-2024)');
		$sheet->setCellValue('AF1', 'Number of technology-driven initiatives undertaken for social good (2022-2023)');
		//segment C Category (excellence_in_tech_volunteering)
		$sheet->setCellValue('AG1', 'Number of employees that have volunteered for the technology-driven initiatives for social good (2023-2024)');
		$sheet->setCellValue('AH1', 'Number of employees that have volunteered for the technology-driven initiatives for social good (2022-2023)');
		$sheet->setCellValue('AI1', 'Total number of hours volunteered by your organization`s employees for technology-driven initiatives for social good (2023-2024)');
		$sheet->setCellValue('AJ1', 'Total number of hours volunteered by your organization`s employees for technology-driven initiatives for social good (2022-2023)');
		
		$sheet->setCellValue('AK1', 'Initiative Name (Please keep this concise as it will appear on the website if you are shortlisted)');
		$sheet->setCellValue('AL1', 'Initiative Start Date');
		$sheet->setCellValue('AM1', 'Initiative End Date');
		$sheet->setCellValue('AN1', 'Target Group/Audience');
		$sheet->setCellValue('AO1', 'Estimated Implementation Budget (in INR Lakhs)');
		$sheet->setCellValue('AP1', 'Name of the Government body partnered with');
		$sheet->setCellValue('AQ1', 'Describe the nature and scope of partnership');
		$sheet->setCellValue('AR1', 'Duration of partnership (in months)');
		$sheet->setCellValue('AS1', '% of funding received from the government, if applicable');
		//segment A and B
		$sheet->setCellValue('AT1', 'Describe the problem statement that you aimed to address through your initiative');
		$sheet->setCellValue('AU1', 'Give a brief summary of the initiative. Highlight the key aspects of the initiative that differentiates you from your competitors');
		//segment A,B C (All Category)
		$sheet->setCellValue('AV1', 'Describe the role of technology in your initiative. How did you leverage technology in making the initiative unique?');
		$sheet->setCellValue('AW1', 'Highlight the specific measurable impact/outcomes your initiative has achieved with respect to the category selected. Please provide quantifiable data and examples');
		$sheet->setCellValue('AX1', 'Explain the sustainability and scalability plan of the initiative and mention the steps taken to make it inclusive and replicable in the future.');
		//segment C (social_innovation_through_tech and excellence_in_tech_volunteering category)
		$sheet->setCellValue('AY1', 'What is the problem statement that you aimed to address and how has technology played a role?');
		$sheet->setCellValue('AZ1', 'Give a brief summary of the initiative undertaken by your organization. Explain how does it align with your organization`s CSR policy');
		//segment C (public_and_private_collaboration category)
		$sheet->setCellValue('BA1', 'Provide a detailed description of the initiative');		
		$sheet->setCellValue('BB1', 'Describe how you have collaborated with the government body/ public entity to enable a transformation that is scalable and sustainable through the initiative. (financial, technical, manpower, etc.)');
		//segment C (social_innovation_through_tech and excellence_in_tech_volunteering category)
		$sheet->setCellValue('BC1', 'Highlight any collaborations or partnerships your organization has engaged in to support this initiative');
		//segment C (excellence_in_tech_volunteering category)
		$sheet->setCellValue('BD1', 'Describe the level of employee engagement and participation in the initiative');
 
		//$_APPLICATIONS_QUERY = "SELECT * FROM application_personal_details limit 12000";
		if(isset($content['status']) && $content['status'] != ""){
			$status = $content['status'];
		}
		if(isset($content['limit']) && isset($content['offset']) && $content['limit'] != "" && $content['offset'] != ""){
			$start = $content['limit'];
			$end = $content['offset'];
		} else {
			$start = 10000;
			$end = 0;
		}
		$applicationQuery = "SELECT a.applications_id, a.uid, a.code, a.application_number, a.segment_type, a.full_name, a.company_name, a.company_org_brief,a.phone_code, a.contact, a.address, a.email, a.designation, a.nominee_incorporation_year, a.legal_status_ngo, a.website_link, a.nominee_office_address, a.particular, a.financial_year_23_24, a.financial_year_22_23, a.initiativedetails, a.applicationQuestion, a.sustainDevelopement, a.sustainable_development_goal, a.sustain_initiative_name, a.sustain_initiative_start_date, a.sustain_initiative_end_date, a.sustain_estimated_badget, a.sustain_details, a.status, a.created_at, a.created_by, a.ey_assessment, c.category, c.category_name, c.definition FROM users_application_details as a LEFT JOIN category_master as c on c.Category = a.category_name and c.segment_type = a.segment_type limit $start offset $end ";
		$records = $this->Mdl_excel->customQuery($applicationQuery);
		$excel_row = 2;
		$nos = 1;
		// echo "<pre>";
		// print_r($records);
		// echo "</pre>";die;
		if( $records !== "NA" ){
			foreach($records as $r){
				$date = date("Y-m-d H:i:s", strtotime($r->created_at));
				$created_at = date("Y-m-d H:i:s", strtotime($r->created_at));

				if($r->segment_type == 'for_profit'){
					$segment_type = 'Segment A - For Profit';
				}elseif($r->segment_type == 'not_for_profit'){
					$segment_type = 'Segment B - Not For Profit';
				}else{
					$segment_type = 'Segment C - Corporate';
				}

				$financialyear_22_23 = json_decode($r->financial_year_22_23, true);
				$financialyear_23_24 = json_decode($r->financial_year_23_24, true);
				$financial_year_22_23 = array();
				$financial_year_23_24 = array();
				if (is_array($financialyear_22_23) || is_object($financialyear_22_23)){
					foreach ($financialyear_22_23 as $key => $fin23){
						$financial_year_22_23[] = $fin23;
					}
				}
				if (is_array($financialyear_23_24) || is_object($financialyear_23_24)){
					foreach ($financialyear_23_24 as $key => $fin24){
						$financial_year_23_24[] = $fin24;
					}
				}
				if($r->segment_type == 'for_profit' || $r->segment_type == 'corporate'){
					$finyear2224_1 = isset($financial_year_22_23[0]) ? $financial_year_22_23[0] : null;
					$finyear2324_1 = isset($financial_year_23_24[0]) ? $financial_year_23_24[0] : null;
					$finyear2224_3 = isset($financial_year_22_23[2]) ? $financial_year_22_23[2] : null;
					$finyear2324_3 = isset($financial_year_23_24[2]) ? $financial_year_23_24[2] : null;
					$finyear2224_5 = isset($financial_year_22_23[4]) ? $financial_year_22_23[4] : null;
					$finyear2324_5 = isset($financial_year_23_24[4]) ? $financial_year_23_24[4] : null;
				}else{
					$finyear2224_1 = "NA";
					$finyear2324_1 = "NA";
					$finyear2224_3 = "NA";
					$finyear2324_3 = "NA";
					$finyear2224_5 = "NA";
					$finyear2324_5 = "NA";
				}
				// echo "<pre>";
				// print_r($financial_year_22_23[0]);
				// echo "</pre>";die;
				if($r->segment_type == 'not_for_profit'){
					$finyear2224_2 = isset($financial_year_22_23[0]) ? $financial_year_22_23[0] : null;
					$finyear2324_2 = isset($financial_year_23_24[0]) ? $financial_year_23_24[0] : null;
				}else{
					$finyear2224_2 = isset($financial_year_22_23[1]) ? $financial_year_22_23[1] : null;
					$finyear2324_2 = isset($financial_year_23_24[1]) ? $financial_year_23_24[1] : null;
				}
				if($r->segment_type == 'not_for_profit'){
					$finyear2224_6 = isset($financial_year_22_23[2]) ? $financial_year_22_23[2] : null;
					$finyear2324_6 = isset($financial_year_23_24[2]) ? $financial_year_23_24[2] : null;
				}else{
					$finyear2224_6 = "NA";
					$finyear2324_6 = "NA";
				}
				if($r->segment_type == 'for_profit'){
					$finyear2224_4 = isset($financial_year_22_23[3]) ? $financial_year_22_23[3] : null;
					$finyear2324_4 = isset($financial_year_23_24[3]) ? $financial_year_23_24[3] : null;
				}elseif($r->segment_type == 'not_for_profit'){
					$finyear2224_4 = isset($financial_year_22_23[1]) ? $financial_year_22_23[1] : null;
					$finyear2324_4 = isset($financial_year_23_24[1]) ? $financial_year_23_24[1] : null;
				}else{
					$finyear2224_4 = "NA";
					$finyear2324_4 = "NA";
				}
				if($r->segment_type == 'corporate' && ($r->category == 'social_innovation_through_tech' || $r->category == 'excellence_in_tech_volunteering')){
					$finyear2224_7 = isset($financial_year_22_23[3]) ? $financial_year_22_23[3] : null;
					$finyear2324_7 = isset($financial_year_23_24[3]) ? $financial_year_23_24[3] : null;
				}else{
					$finyear2224_7 = "NA";
					$finyear2324_7 = "NA";
				}
				if($r->segment_type == 'corporate' && $r->category == 'excellence_in_tech_volunteering'){
					$finyear2224_8 = isset($financial_year_22_23[5]) ? $financial_year_22_23[5] : null;
					$finyear2324_8 = isset($financial_year_23_24[5]) ? $financial_year_23_24[5] : null;
					$finyear2224_9 = isset($financial_year_22_23[6]) ? $financial_year_22_23[6] : null;
					$finyear2324_9 = isset($financial_year_23_24[6]) ? $financial_year_23_24[6] : null;
				}else{
					$finyear2224_8 = "NA";
					$finyear2324_8 = "NA";
					$finyear2224_9 = "NA";
					$finyear2324_9 = "NA";
				}
				
				$initiativedetails = json_decode($r->initiativedetails, true);
				if($r->category == 'public_and_private_collaboration'){
					$initiative_1 = isset($initiativedetails[0]) ? $initiativedetails[0] : null;
					$initiative_2 = isset($initiativedetails[1]) ? $initiativedetails[1] : null;
					$initiative_3 = isset($initiativedetails[2]) ? $initiativedetails[2] : null;
					$initiative_4 = isset($initiativedetails[3]) ? $initiativedetails[3] : null;
					$initiative_5 = isset($initiativedetails[4]) ? $initiativedetails[4] : null;
					$initiative_6 = isset($initiativedetails[5]) ? $initiativedetails[5] : null;
					$initiative_7 = isset($initiativedetails[6]) ? $initiativedetails[6] : null;
					$initiative_8 = isset($initiativedetails[7]) ? $initiativedetails[7] : null;
					$initiative_9 = isset($initiativedetails[8]) ? $initiativedetails[8] : null;
				}else{
					$initiative_1 = isset($initiativedetails[0]) ? $initiativedetails[0] : null;
					$initiative_2 = isset($initiativedetails[1]) ? $initiativedetails[1] : null;
					$initiative_3 = isset($initiativedetails[2]) ? $initiativedetails[2] : null;
					$initiative_4 = isset($initiativedetails[3]) ? $initiativedetails[3] : null;
					$initiative_5 = isset($initiativedetails[4]) ? $initiativedetails[4] : null;
					$initiative_6 = "NA";
					$initiative_7 = "NA";
					$initiative_8 = "NA";
					$initiative_9 = "NA";
				}

				$applicationQuestion = json_decode($r->applicationQuestion, true);
				if($r->segment_type == 'for_profit' || $r->segment_type == 'not_for_profit'){
					$appQuestion1 = isset($applicationQuestion[0]) ? $applicationQuestion[0] : null;
					$appQuestion2 = isset($applicationQuestion[1]) ? $applicationQuestion[1] : null;
					$appQuestion3 = isset($applicationQuestion[2]) ? $applicationQuestion[2] : null;//segment A,B,C
					$appQuestion4 = isset($applicationQuestion[3]) ? $applicationQuestion[3] : null;//segment A,B,C
					$appQuestion5 = isset($applicationQuestion[4]) ? $applicationQuestion[4] : null;//segment A,B,C
					$appQuestionAY = "NA";
					$appQuestionAZ = "NA";
					$appQuestionBA = "NA";
					$appQuestionBB = "NA";
					$appQuestionBC = "NA";
					$appQuestionBD = "NA";
				}else{
					$appQuestion1 = "NA";
					$appQuestion2 = "NA";
					$appQuestion3 = isset($applicationQuestion[2]) ? $applicationQuestion[2] : null;//segment A,B,C
					//$appQuestion4 = isset($applicationQuestion[7]) ? $applicationQuestion[7] : null;//segment A,B,C
					//$appQuestion5 = isset($applicationQuestion[8]) ? $applicationQuestion[8] : null;//segment A,B,C
					if($r->category == 'excellence_in_tech_volunteering'){
						$appQuestion4 = isset($applicationQuestion[5]) ? $applicationQuestion[5] : null;//segment A,B,C
						$appQuestion5 = isset($applicationQuestion[6]) ? $applicationQuestion[6] : null;//segment A,B,C
					}elseif($r->category == 'public_and_private_collaboration'){
						$appQuestion4 = isset($applicationQuestion[3]) ? $applicationQuestion[3] : null;//segment A,B,C
						$appQuestion5 = isset($applicationQuestion[4]) ? $applicationQuestion[4] : null;//segment A,B,C
					}else{
						$appQuestion4 = isset($applicationQuestion[4]) ? $applicationQuestion[4] : null;//segment A,B,C
						$appQuestion5 = isset($applicationQuestion[5]) ? $applicationQuestion[5] : null;//segment A,B,C
					}

					if($r->category == 'social_innovation_through_tech' || $r->category == 'excellence_in_tech_volunteering'){
						$appQuestionAY = isset($applicationQuestion[0]) ? $applicationQuestion[0] : null;
						$appQuestionAZ = isset($applicationQuestion[1]) ? $applicationQuestion[1] : null;
						$appQuestionBC = isset($applicationQuestion[3]) ? $applicationQuestion[3] : null;
					}else{
						$appQuestionAY = "NA";
						$appQuestionAZ = "NA";
						$appQuestionBC = "NA";
					}
					if($r->category == 'public_and_private_collaboration'){
						$appQuestionBA = isset($applicationQuestion[0]) ? $applicationQuestion[0] : null;
						$appQuestionBB = isset($applicationQuestion[1]) ? $applicationQuestion[1] : null;
					}else{
						$appQuestionBA = "NA";
						$appQuestionBB = "NA";
					}
					if($r->category == 'excellence_in_tech_volunteering'){
						$appQuestionBD = isset($applicationQuestion[4]) ? $applicationQuestion[4] : null;
					}else{
						$appQuestionBD = "NA";
					}
				}
				
				$sheet->setCellValue('A'.$excel_row, $nos);
				$sheet->setCellValue('B'.$excel_row, $date);
				$sheet->setCellValue('C'.$excel_row, $r->status);
				$sheet->setCellValue('D'.$excel_row, ucfirst($r->ey_assessment));
				$sheet->setCellValue('E'.$excel_row, $r->application_number);
				$sheet->setCellValue('F'.$excel_row, $r->code);
				$sheet->setCellValue('G'.$excel_row, $segment_type);
				$sheet->setCellValue('H'.$excel_row, $r->category_name);
				$sheet->setCellValue('I'.$excel_row, $r->company_name);
				$sheet->setCellValue('J'.$excel_row, $r->company_org_brief);
				$sheet->setCellValue('K'.$excel_row, $r->full_name);
				$sheet->setCellValue('L'.$excel_row, $r->email);
				$sheet->setCellValue('M'.$excel_row, $r->designation);
				$sheet->setCellValue('N'.$excel_row, $r->phone_code.'-'.$r->contact);
				$sheet->setCellValue('O'.$excel_row, $r->nominee_incorporation_year);
				$sheet->setCellValue('P'.$excel_row, $r->legal_status_ngo);
				$sheet->setCellValue('Q'.$excel_row, $r->website_link);
				$sheet->setCellValue('R'.$excel_row, $r->nominee_office_address);
				//segment A and C (All Category)
				$sheet->setCellValue('S'.$excel_row, $finyear2324_1);
				$sheet->setCellValue('T'.$excel_row, $finyear2224_1);
				//All Segment (all Category)
				$sheet->setCellValue('U'.$excel_row, $finyear2324_2);
				$sheet->setCellValue('V'.$excel_row, $finyear2224_2);
				//segment A and C (All Category)
				$sheet->setCellValue('W'.$excel_row, $finyear2324_3);
				$sheet->setCellValue('X'.$excel_row, $finyear2224_3);
				//segment A and B
				$sheet->setCellValue('Y'.$excel_row, $finyear2324_4);
				$sheet->setCellValue('Z'.$excel_row, $finyear2224_4);
				//segment A and C (All Category)
				$sheet->setCellValue('AA'.$excel_row, $finyear2324_5);
				$sheet->setCellValue('AB'.$excel_row, $finyear2224_5);
				//segment B
				$sheet->setCellValue('AC'.$excel_row, $finyear2324_6);
				$sheet->setCellValue('AD'.$excel_row, $finyear2224_7);
				//segment C Category (social_innovation_through_tech,excellence_in_tech_volunteering)
				$sheet->setCellValue('AE'.$excel_row, $finyear2324_7);
				$sheet->setCellValue('AF'.$excel_row, $finyear2224_7);
				//segment C Category excellence_in_tech_volunteering
				$sheet->setCellValue('AG'.$excel_row, $finyear2324_8);
				$sheet->setCellValue('AH'.$excel_row, $finyear2224_8);
				$sheet->setCellValue('AI'.$excel_row, $finyear2324_9);
				$sheet->setCellValue('AJ'.$excel_row, $finyear2224_9);

				$sheet->setCellValue('AK'.$excel_row, $initiative_1);
				$sheet->setCellValue('AL'.$excel_row, $initiative_2);
				$sheet->setCellValue('AM'.$excel_row, $initiative_3);
				$sheet->setCellValue('AN'.$excel_row, $initiative_4);
				$sheet->setCellValue('AO'.$excel_row, $initiative_5);
				$sheet->setCellValue('AP'.$excel_row, $initiative_6);
				$sheet->setCellValue('AQ'.$excel_row, $initiative_7);
				$sheet->setCellValue('AR'.$excel_row, $initiative_8);
				$sheet->setCellValue('AS'.$excel_row, $initiative_9);
				//segment A and B
				$sheet->setCellValue('AT'.$excel_row, $appQuestion1);
				$sheet->setCellValue('AU'.$excel_row, $appQuestion2);
				$sheet->setCellValue('AV'.$excel_row, $appQuestion3);
				$sheet->setCellValue('AW'.$excel_row, $appQuestion4);
				$sheet->setCellValue('AX'.$excel_row, $appQuestion5);
				$sheet->setCellValue('AY'.$excel_row, $appQuestionAY);
				$sheet->setCellValue('AZ'.$excel_row, $appQuestionAZ);
				$sheet->setCellValue('BA'.$excel_row, $appQuestionBA);
				$sheet->setCellValue('BB'.$excel_row, $appQuestionBB);
				$sheet->setCellValue('BC'.$excel_row, $appQuestionBC);
				$sheet->setCellValue('BD'.$excel_row, $appQuestionBD);
				
				$excel_row++;
				$nos++;
			}
		}
		//ob_clean();
		//$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Applications Master.xlsx"'); 
		header('Cache-Control: max-age=0');

		// download file 
		$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, "Xlsx");
		$writer->save('php://output'); 
	}
	/////end

	/**
	 * 	Nomination
	 */
	function nomination(){

		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
    	$spreadsheet->getProperties()->setCreator('Global Nursing Award 2022')
      ->setLastModifiedBy('Global Nursing Award 2022')
      ->setTitle('Nomination Master')
      ->setSubject('')
      ->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:P1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A', 'P') as $columnID) {
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}

		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Date');
		$sheet->setCellValue('C1', 'Nominator\'s Name');
		$sheet->setCellValue('D1', 'Relationship with the Nurse');
		$sheet->setCellValue('E1', 'Institute / Hospital name');
		$sheet->setCellValue('F1', 'Email');
		$sheet->setCellValue('G1', 'Country');
		$sheet->setCellValue('H1', 'Mobile Number');
		$sheet->setCellValue('I1', 'Candidate\'s name');
		$sheet->setCellValue('J1', 'Institute / Hospital name');
		$sheet->setCellValue('K1', 'Institute / Hospital address');
		$sheet->setCellValue('L1', 'Email');
		$sheet->setCellValue('M1', 'Country');
		$sheet->setCellValue('N1', 'Mobile Number');
		$sheet->setCellValue('O1', 'Years of experience');
		$sheet->setCellValue('P1', 'Reason for nomination');

		$records = $this->Mdl_excel->retrieve("nomination",array("1"=>"1"));
		$excel_row = 2;
		$nos = 1;

		if( $records !== "NA" ){
			foreach($records as $r){
				$date = date("d-m-Y H:i:s",strtotime($r->created_at));
				$nominatorCounty = Modules::run('api/application/personal/country', $r->country);
				$candidateCountry = Modules::run('api/application/personal/country', $r->cand_country);

				$sheet->setCellValue('A'.$excel_row, $nos);
				$sheet->setCellValue('B'.$excel_row, $date);
				$sheet->setCellValue('C'.$excel_row, $r->fullname);
				$sheet->setCellValue('D'.$excel_row, $r->relationship);
				$sheet->setCellValue('E'.$excel_row, $r->institute);
				$sheet->setCellValue('F'.$excel_row, $r->email);
				$sheet->setCellValue('G'.$excel_row, $nominatorCounty);
				$sheet->setCellValue('H'.$excel_row, $r->phone_code.'-'.$r->contact);
				$sheet->setCellValue('I'.$excel_row, $r->cand_name);
				$sheet->setCellValue('J'.$excel_row, $r->cand_institute);
				$sheet->setCellValue('K'.$excel_row, $r->cand_address);
				$sheet->setCellValue('L'.$excel_row, $r->cand_email);
				$sheet->setCellValue('M'.$excel_row, $candidateCountry);
				$sheet->setCellValue('N'.$excel_row, $r->cand_code.'-'.$r->cand_contact);
				$sheet->setCellValue('O'.$excel_row, $r->experience);
				$sheet->setCellValue('P'.$excel_row, $r->reason);
				$excel_row++;
				$nos++;
			}
		}

		$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Nomination Master.xlsx"'); 
		header('Cache-Control: max-age=0');

		// download file 
		$writer->save('php://output'); 
	}
	function nominationFilter(){

		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
    	$spreadsheet->getProperties()->setCreator('Global Nursing Award 2022')
      ->setLastModifiedBy('Global Nursing Award 2022')
      ->setTitle('Nomination Master')
      ->setSubject('')
      ->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:P1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A', 'P') as $columnID) {
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}

		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Date');
		$sheet->setCellValue('C1', 'Nominator\'s Name');
		$sheet->setCellValue('D1', 'Relationship with the Nurse');
		$sheet->setCellValue('E1', 'Institute / Hospital name');
		$sheet->setCellValue('F1', 'Email');
		$sheet->setCellValue('G1', 'Country');
		$sheet->setCellValue('H1', 'Mobile Number');
		$sheet->setCellValue('I1', 'Candidate\'s name');
		$sheet->setCellValue('J1', 'Institute / Hospital name');
		$sheet->setCellValue('K1', 'Institute / Hospital address');
		$sheet->setCellValue('L1', 'Email');
		$sheet->setCellValue('M1', 'Country');
		$sheet->setCellValue('N1', 'Mobile Number');
		$sheet->setCellValue('O1', 'Years of experience');
		$sheet->setCellValue('P1', 'Reason for nomination');

		$content = $this->input->post();
		$_APPLICATIONS_QUERY = '';
		if(isset($content['nom_start']) ){
			$start = $content['nom_start'];
		} else {
			return false;
		}
		if(isset($content['nom_end']) ){
			
			$end = $content['nom_end'];
		} else {
			return false;
		}
		
		if(isset($content['nom_edition'])){
			if($content['nom_edition'] == 'all'){
				$_APPLICATIONS_QUERY = "select * from nomination limit $end offset $start";
			} else if($content['nom_edition'] == 'one-two'){
				$edition = 'one';
				$_APPLICATIONS_QUERY = "select * from nomination where `edition` = 'two' limit $end offset $start";
			
			} else {
					$edition = 'three';
					$_APPLICATIONS_QUERY = "select * from nomination where `edition` = '$edition'  limit $end offset $start";
				}
		} 
		$records = $this->Mdl_excel->customQuery($_APPLICATIONS_QUERY);
		//$records = $this->Mdl_excel->retrieve("nomination",array("1"=>"1"));
		$excel_row = 2;
		$nos = 1;

		if( $records !== "NA" ){
			foreach($records as $r){
				$date = date("d-m-Y H:i:s",strtotime($r->created_at));
				$nominatorCounty = Modules::run('api/application/personal/country', $r->country);
				$candidateCountry = Modules::run('api/application/personal/country', $r->cand_country);

				$sheet->setCellValue('A'.$excel_row, $nos);
				$sheet->setCellValue('B'.$excel_row, $date);
				$sheet->setCellValue('C'.$excel_row, $r->fullname);
				$sheet->setCellValue('D'.$excel_row, $r->relationship);
				$sheet->setCellValue('E'.$excel_row, $r->institute);
				$sheet->setCellValue('F'.$excel_row, $r->email);
				$sheet->setCellValue('G'.$excel_row, $nominatorCounty);
				$sheet->setCellValue('H'.$excel_row, $r->phone_code.'-'.$r->contact);
				$sheet->setCellValue('I'.$excel_row, $r->cand_name);
				$sheet->setCellValue('J'.$excel_row, $r->cand_institute);
				$sheet->setCellValue('K'.$excel_row, $r->cand_address);
				$sheet->setCellValue('L'.$excel_row, $r->cand_email);
				$sheet->setCellValue('M'.$excel_row, $candidateCountry);
				$sheet->setCellValue('N'.$excel_row, $r->cand_code.'-'.$r->cand_contact);
				$sheet->setCellValue('O'.$excel_row, $r->experience);
				$sheet->setCellValue('P'.$excel_row, $r->reason);
				$excel_row++;
				$nos++;
			}
		}

		$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Nomination Master.xlsx"'); 
		header('Cache-Control: max-age=0');

		// download file 
		$writer->save('php://output'); 
	}
	
	/**
	 * 	Nurses
	 */
	function nurses(){

		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
      $spreadsheet->getProperties()->setCreator('Global Nursing Award 2022')
      ->setLastModifiedBy('Global Nursing Award 2022')
      ->setTitle('Nurse Registration Master')
      ->setSubject('')
      ->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:M1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A', 'L') as $columnID) {
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}

		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Date');
		$sheet->setCellValue('C1', 'First Name');
		$sheet->setCellValue('D1', 'Middle Name');
		$sheet->setCellValue('E1', 'Last Name');
		$sheet->setCellValue('F1', 'Institute / Hospital name');
		$sheet->setCellValue('G1', 'Email');
		$sheet->setCellValue('H1', 'Country');
		$sheet->setCellValue('I1', 'Contact No 1');
		$sheet->setCellValue('J1', 'Contact No 2');
		$sheet->setCellValue('K1', 'Email Verification');
		$sheet->setCellValue('L1', 'Region');
		$sheet->setCellValue('M1', 'Status');

		//$records = $this->Mdl_excel->retrieve("registration",array("1"=>"1"));
		$_APPLICATIONS_QUERY = "SELECT r.*, apd.region FROM `registration` as r 
								left join master_country as apd
								on r.country = apd.country_id";
		$records = $this->Mdl_excel->customQuery($_APPLICATIONS_QUERY);
		$excel_row = 2;
		$nos = 1;

		if( $records !== "NA" ){
			foreach($records as $r){
				$date = date("d-m-Y H:i:s",strtotime($r->created_at));
				$country = Modules::run('api/application/personal/country', $r->country);
				$mailVerification = $r->email_verification == "yes" ? "Verified" : "Pending";

				$sheet->setCellValue('A'.$excel_row, $nos);
				$sheet->setCellValue('B'.$excel_row, $date);
				$sheet->setCellValue('C'.$excel_row, $r->first_name);
				$sheet->setCellValue('D'.$excel_row, $r->middle_name);
				$sheet->setCellValue('E'.$excel_row, $r->last_name);
				$sheet->setCellValue('F'.$excel_row, $r->institute);
				$sheet->setCellValue('G'.$excel_row, $r->email);
				$sheet->setCellValue('H'.$excel_row, $country);
				$sheet->setCellValue('I'.$excel_row, $r->phone_code_one.'-'.$r->contact_one);
				$sheet->setCellValue('J'.$excel_row, $r->phone_code_two.'-'.$r->contact_two);
				$sheet->setCellValue('K'.$excel_row, $mailVerification);
				$sheet->setCellValue('L'.$excel_row, $r->region);
				$sheet->setCellValue('M'.$excel_row, ucfirst($r->status));
				$excel_row++;
				$nos++;
			}
		}

		$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Nurse Registration Master.xlsx"'); 
		header('Cache-Control: max-age=0');

		// download file 
		$writer->save('php://output'); 
	}
	

	function nursesFilter(){

		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
      $spreadsheet->getProperties()->setCreator('Global Nursing Award 2022')
      ->setLastModifiedBy('Global Nursing Award 2022')
      ->setTitle('Nurse Registration Master')
      ->setSubject('')
      ->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:O1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A', 'L') as $columnID) {
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}

		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Date');
		$sheet->setCellValue('C1', 'First Name');
		$sheet->setCellValue('D1', 'Middle Name');
		$sheet->setCellValue('E1', 'Last Name');
		$sheet->setCellValue('F1', 'Institute / Hospital name');
		$sheet->setCellValue('G1', 'Email');
		$sheet->setCellValue('H1', 'Gender');
		$sheet->setCellValue('I1', 'Country');
		$sheet->setCellValue('J1', 'Contact No 1');
		$sheet->setCellValue('K1', 'Contact No 2');
		$sheet->setCellValue('L1', 'Email Verification');
		$sheet->setCellValue('M1', 'Region');
		$sheet->setCellValue('N1', 'Status');
		$sheet->setCellValue('O1', 'Google or Regular Registration');
		//$records = $this->Mdl_excel->retrieve("registration",array("1"=>"1"));
		$content = $this->input->post();
		$_APPLICATIONS_QUERY = '';
		if(isset($content['reg_start']) ){
			$start = $content['reg_start'];
		} else {
			return false;
		}
		if(isset($content['reg_end']) ){
			
			$end = $content['reg_end'];
		} else {
			return false;
		}
		
		if(isset($content['reg_edition'])){
			if($content['reg_edition'] == 'all'){
				$_APPLICATIONS_QUERY = "SELECT r.*, apd.region FROM `registration` as r 
				left join master_country as apd
				on r.country = apd.country_id  limit $end offset $start";
			} else if($content['reg_edition'] == 'one-two'){
				$edition = 'one';
				$_APPLICATIONS_QUERY = "SELECT r.*, apd.region FROM `registration` as r 
				left join master_country as apd
				on r.country = apd.country_id where r.`edition` = 'one' or r.`edition` = 'two' limit $end offset $start";
			
			} else {
					$edition = 'three';
					$_APPLICATIONS_QUERY = "SELECT r.*, apd.region FROM `registration` as r 
					left join master_country as apd
					on r.country = apd.country_id where r.`edition` = '$edition'  limit $end offset $start";
				}
		} 
		
		// $_APPLICATIONS_QUERY = "SELECT r.*, apd.region FROM `registration` as r 
		// 						left join master_country as apd
		// 						on r.country = apd.country_id";
		$records = $this->Mdl_excel->customQuery($_APPLICATIONS_QUERY);
		$excel_row = 2;
		$nos = 1;
		
		if( $records !== "NA" ){
			foreach($records as $r){
				$date = date("d-m-Y H:i:s",strtotime($r->created_at));
				$country = Modules::run('api/application/personal/country', $r->country);
		
				$mailVerification = $r->email_verification == "yes" ? "Verified" : "Pending";
				$institute = '';$gender='';$region='';
				if(empty($r->institute)){
					$query = "SELECT apd.region,apd.institute,apd.gender,apd.country FROM `application_personal_details` as apd WHERE `uid` = '$r->uid'";
					$application = $this->Mdl_excel->customQuery($query);
					if($application != "NA"){
						$institute = $application[0]->institute;
						$gender = $application[0]->gender;
						$region = $application[0]->region;
						$country = Modules::run('api/application/personal/country', $application[0]->country);
						if(empty($region)){
							$region = $country[0]->region;
						}
					} 
				} else {
					$institute = $r->institute;
					$gender = $r->gender;
					$region = $r->region;
				}
				if(empty($region)){
					
					$region_data = Modules::run('api/application/personal/region', $r->country);
					$region = $region_data;
				}
				if(!empty($r->phone_code_one) && !empty($r->contact_one)){
					$phone_code_one = $r->phone_code_one.'-'.$r->contact_one;
				} else {
					$phone_code_one = '';
				}
				if(!empty($r->phone_code_two) && !empty($r->contact_two)){
					$phone_code_two = $r->phone_code_two.'-'.$r->contact_two;
				} else {
					$phone_code_two = '';
				}
				$is_gmail_login = '';
				$sheet->setCellValue('A'.$excel_row, $nos);
				$sheet->setCellValue('B'.$excel_row, $date);
				$sheet->setCellValue('C'.$excel_row, $r->first_name);
				$sheet->setCellValue('D'.$excel_row, $r->middle_name);
				$sheet->setCellValue('E'.$excel_row, $r->last_name);
				$sheet->setCellValue('F'.$excel_row, $institute);
				$sheet->setCellValue('G'.$excel_row, $r->email);
				$sheet->setCellValue('H'.$excel_row, $gender);
				$sheet->setCellValue('I'.$excel_row, $country);
				$sheet->setCellValue('J'.$excel_row, $phone_code_one);
				$sheet->setCellValue('K'.$excel_row, $phone_code_two);
				$sheet->setCellValue('L'.$excel_row, $mailVerification);
				$sheet->setCellValue('M'.$excel_row, $region);
				$sheet->setCellValue('N'.$excel_row, ucfirst($r->status));
				if($r->is_gmail_login == "Y"){
					$is_gmail_login = 'Gmail';
				} else {
					$is_gmail_login = 'Normal';
				}
				$sheet->setCellValue('O'.$excel_row, $is_gmail_login);
				$excel_row++;
				$nos++;
			}
		}

		$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Nurse Registration Master.xlsx"'); 
		header('Cache-Control: max-age=0');

		// download file 
		$writer->save('php://output'); 
	}
	
	/**
	 * 	Applications
	 */
	// function application(){

	// 	// Create new Spreadsheet object
	// 	$spreadsheet = new Spreadsheet();
	// 	$sheet = $spreadsheet->getActiveSheet();

	// 	// Set document properties
	// 	$spreadsheet->getProperties()->setCreator('Global Nursing Award 2022')
	// 		->setLastModifiedBy('Global Nursing Award 2022')
	// 		->setTitle('Applications Master')
	// 		->setSubject('')
	// 		->setDescription('');

	// 	// add style to the header
	// 	$styleArray = array(
	// 		'font' => array(
	// 			'bold' => true,
	// 		),
	// 		'alignment' => array(
	// 			'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
	// 			'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
	// 		),
	// 		'borders' => array(
	// 			'bottom' => array(
	// 				'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
	// 				'color' => array('rgb' => '333333'),
	// 			),
	// 		),
	// 		'fill' => array(
	// 			'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
	// 			'rotation'   => 90,
	// 			'startcolor' => array('rgb' => '0d0d0d'),
	// 			'endColor'   => array('rgb' => 'f2f2f2'),
	// 		),
	// 	);
	// 	$spreadsheet->getActiveSheet()->getStyle('A1:CJ1')->applyFromArray($styleArray);

	// 	// auto fit column to content
	// 	foreach(range('A','AS') as $columnID){
	// 		$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
	// 	}

	// 	// set the names of header cells
	// 	$sheet->setCellValue('A1', 'Sr. No.');
	// 	$sheet->setCellValue('B1', 'Date');
	// 	$sheet->setCellValue('C1', 'Application Status');
	// 	$sheet->setCellValue('D1', 'EY Assessment');
	// 	$sheet->setCellValue('E1', 'Application Number');
	// 	$sheet->setCellValue('F1', 'First name');
	// 	$sheet->setCellValue('G1', 'Middle name');
	// 	$sheet->setCellValue('H1', 'Last name');
	// 	$sheet->setCellValue('I1', 'Email');
	// 	$sheet->setCellValue('J1', 'Date of Birth');
	// 	$sheet->setCellValue('K1', 'Country');
	// 	$sheet->setCellValue('L1', 'Region');
	// 	$sheet->setCellValue('M1', 'Contact No');
	// 	$sheet->setCellValue('N1', 'Gender');
	// 	$sheet->setCellValue('O1', 'Address');
	// 	$sheet->setCellValue('P1', 'Register as');
	// 	$sheet->setCellValue('Q1', 'Institute / hospital name');
	// 	$sheet->setCellValue('R1', 'Contact Email ID');
	// 	$sheet->setCellValue('S1', 'Contact Number');
	// 	$sheet->setCellValue('T1', 'Website link');
	// 	$sheet->setCellValue('U1', 'Total years of work experience as a Nurse');
	// 	$sheet->setCellValue('V1', 'Years of experience in the current institute/hospital');

	// 	$sheet->setCellValue('W1', 'Educational Qualification (Highest degree)');
	// 	$sheet->setCellValue('X1', 'Educational Qualification Document');
	// 	$sheet->setCellValue('Y1', 'Medical/Nurse council registration name');
	// 	$sheet->setCellValue('Z1', 'Medical/Nurse council registration number');
	// 	$sheet->setCellValue('AA1', 'Medical/Nurse council registration document');
	// 	$sheet->setCellValue('AB1', 'Passport front copy');
	// 	$sheet->setCellValue('AC1', 'Passport back copy');
	// 	$sheet->setCellValue('AD1', 'Passport size Photograph');
	// 	$sheet->setCellValue('AE1', 'Valid national proof of identity of the country/region you are applying from (Govt. ID)');
	// 	$sheet->setCellValue('AF1', 'National proof of identity document');
	// 	$sheet->setCellValue('AG1', 'Proof of employment');
	// 	$sheet->setCellValue('AH1', 'Proof of employment document');
	// 	$sheet->setCellValue('AI1', 'Self declaration document');		

	// 	$sheet->setCellValue('AJ1', 'First Referrer full name');
	// 	$sheet->setCellValue('AK1', 'Referrer email ID');
	// 	$sheet->setCellValue('AL1', 'Referrer country');
	// 	$sheet->setCellValue('AM1', 'Referrer contact number');
	// 	$sheet->setCellValue('AN1', 'Relationship with the reference');
	// 	$sheet->setCellValue('AO1', 'Second Referrer full name');		
	// 	$sheet->setCellValue('AP1', 'Referrer email ID');
	// 	$sheet->setCellValue('AQ1', 'Referrer country');
	// 	$sheet->setCellValue('AR1', 'Referrer contact number');
	// 	$sheet->setCellValue('AS1', 'Relationship with the reference');

	// 	$sheet->setCellValue('AT1', 'Selected Segment');
	// 	$sheet->setCellValue('AU1', 'Primary Segment');
	// 	$sheet->setCellValue('AV1', 'Secondary Segment');
	// 	$sheet->setCellValue('AW1', 'Leadership Experience');
	// 	$sheet->setCellValue('AX1', 'Patient care in your daily work environment');
	// 	$sheet->setCellValue('AY1', 'Challenges faced and how you overcame them');		
	// 	$sheet->setCellValue('AZ1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
	// 	$sheet->setCellValue('BA1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

	// 	$sheet->setCellValue('BB1', 'Selected Segment');
	// 	$sheet->setCellValue('BC1', 'Primary Segment');
	// 	$sheet->setCellValue('BD1', 'Secondary Segment');
	// 	$sheet->setCellValue('BE1', 'Patient Experience');
	// 	$sheet->setCellValue('BF1', 'Patient care in your daily work environment');
	// 	$sheet->setCellValue('BG1', 'Challenges faced and how you overcame them');		
	// 	$sheet->setCellValue('BH1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
	// 	$sheet->setCellValue('BI1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

	// 	$sheet->setCellValue('BJ1', 'Selected Segment');
	// 	$sheet->setCellValue('BK1', 'Primary Segment');
	// 	$sheet->setCellValue('BL1', 'Secondary Segment');
	// 	$sheet->setCellValue('BM1', 'Education Experience');
	// 	$sheet->setCellValue('BN1', 'Patient care in your daily work environment');
	// 	$sheet->setCellValue('BO1', 'Challenges faced and how you overcame them');		
	// 	$sheet->setCellValue('BP1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
	// 	$sheet->setCellValue('BQ1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

	// 	$sheet->setCellValue('BR1', 'Selected Segment');
	// 	$sheet->setCellValue('BS1', 'Primary Segment');
	// 	$sheet->setCellValue('BT1', 'Secondary Segment');
	// 	$sheet->setCellValue('BU1', 'Social Experience');
	// 	$sheet->setCellValue('BV1', 'Patient care in your daily work environment');
	// 	$sheet->setCellValue('BW1', 'Challenges faced and how you overcame them');		
	// 	$sheet->setCellValue('BX1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
	// 	$sheet->setCellValue('BY1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

	// 	$sheet->setCellValue('BZ1', 'Selected Segment');
	// 	$sheet->setCellValue('CA1', 'Primary Segment');
	// 	$sheet->setCellValue('CB1', 'Secondary Segment');
	// 	$sheet->setCellValue('CC1', 'Research Experience');
	// 	$sheet->setCellValue('CD1', 'Patient care in your daily work environment');
	// 	$sheet->setCellValue('CE1', 'Challenges faced and how you overcame them');		
	// 	$sheet->setCellValue('CF1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
	// 	$sheet->setCellValue('CG1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');
	// 	$sheet->setCellValue('CH1', 'Reason');
	// 	$sheet->setCellValue('CI1', 'Language');
	// 	// $sheet->setCellValue('CJ1', 'Date and Time');


	// 	// $sheet->setCellValue('AI1', 'Selected segments');
	// 	// $sheet->setCellValue('AJ1', 'We believe nursing is about leading from the front. So, why would you consider yourself as a leader and what difference has that made?');
	// 	// $sheet->setCellValue('AK1', 'Help us understand the challenges faced and how did you overcome the same');
	// 	// $sheet->setCellValue('AL1', 'How do patients and peers respond to your leadership?');
	// 	// $sheet->setCellValue('AM1', 'Describe your story/unique instance pertaining to area of contribution selected');
	// 	// $sheet->setCellValue('AN1', 'Describe your contributions to nursing research, policy, and/or practice at the local regional, state, and /or national level');
	// 	// $sheet->setCellValue('AO1', 'Describe the challenges faced  and how did you overcome the same');
	// 	// $sheet->setCellValue('AP1', 'Describe the impact of the initiative on the patients, employer, peers, etc?');
	// 	// $sheet->setCellValue('AQ1', 'Describe your story/unique instance pertaining to area of contribution selected');
	// 	// $sheet->setCellValue('AR1', 'Describe the initiatives undertaken to facilitate positive changes in the work environment and improve the quality of patient care');
	// 	// $sheet->setCellValue('AS1', 'Describe the challenges faced  and how did you overcome the same');
	// 	// $sheet->setCellValue('AT1', 'Describe the impact of the initiative on the patients, employer, peers, etc?');
	// 	// $sheet->setCellValue('AU1', 'Describe your story/unique instance pertaining to area of contribution selected');
	// 	// $sheet->setCellValue('AV1', 'Describe the your contribution for the betterment of the community/society');
	// 	// $sheet->setCellValue('AW1', 'Describe the challenges faced  and how did you overcome the same');
	// 	// $sheet->setCellValue('AX1', 'Describe the impact of the initiative on the community and what was the change they witnessed?');
	// 	// $sheet->setCellValue('AY1', 'Describe your story/unique instance pertaining to area of contribution selected');
	// 	// $sheet->setCellValue('AZ1', 'Awards and certifications');
	// 	// $sheet->setCellValue('BA1', 'Awards and certifications');

	// 	$_APPLICATIONS_QUERY = "SELECT * FROM application_personal_details";
	// 	$records = $this->Mdl_excel->customQuery($_APPLICATIONS_QUERY);
	// 	$excel_row = 2;
	// 	$nos = 1;

	// 	if( $records !== "NA" ){
	// 		foreach($records as $r){

	// 			$date = date("Y-m-d H:i:s", strtotime($r->created_at));
	// 			$created_at = date("Y-m-d H:i:s", strtotime($r->created_at));
	// 			$dob = date("Y-m-d", strtotime($r->dob));
	// 			$country = Modules::run('api/application/personal/country',$r->country);
	// 			$refOneCountry = Modules::run('api/application/personal/country',$r->ref_country_one);
	// 			$refTwoCountry = Modules::run('api/application/personal/country',$r->ref_country_two);
	// 			$casestudies = Modules::run('api/application/personal/caseStudies',$r->uid);
	// 			if($casestudies != "NA"){
	// 				$leadership_segments = $casestudies[0]->selected_segments;
	// 				$leadership_segment = $casestudies[0]->primary_segment;
	// 				$leadership_segment = $casestudies[0]->secondary_segment;
	// 				$leadership_exp = $casestudies[0]->leadership_exp;
	// 				if(!empty($casestudies[0]->leadership_one) && $casestudies[0]->leadership_one != ""){
	// 					$leadership_one = json_decode($casestudies[0]->leadership_one);
	// 					$leadership_one = $leadership_one->text;
	// 					$leadership_two = json_decode($casestudies[0]->leadership_two);
	// 					$leadership_two = $leadership_two->text;
	// 					$leadership_three = json_decode($casestudies[0]->leadership_three);
	// 					$leadership_three = $leadership_three->text;
	// 					$leadership_four = json_decode($casestudies[0]->leadership_four);
	// 					$leadership_four = $leadership_four->text;
						
	// 				} else {
	// 					$leadership_one = '';
	// 					$leadership_two = '';
	// 					$leadership_three = '';
	// 					$leadership_four = '';
	// 				}
	// 				$patient_segments = $casestudies[0]->selected_segments;
	// 				$patient_segment = $casestudies[0]->primary_segment;
	// 				$patient_segment = $casestudies[0]->secondary_segment;
	// 				$patient_exp = $casestudies[0]->patient_exp;
	// 				if(!empty($casestudies[0]->patient_one) && $casestudies[0]->patient_one != ""){
	// 					$patient_one = json_decode($casestudies[0]->patient_one);
	// 					$patient_one = $patient_one->text;
	// 					$patient_two = json_decode($casestudies[0]->patient_two);
	// 					$patient_two = $patient_two->text;
	// 					$patient_three = json_decode($casestudies[0]->patient_three);
	// 					$patient_three = $patient_three->text;
	// 					$patient_four = json_decode($casestudies[0]->patient_four);
	// 					$patient_four = $patient_four->text;
						
	// 				} else {
	// 					$patient_one = '';
	// 					$patient_two = '';
	// 					$patient_three = '';
	// 					$patient_four = '';
	// 				}

	// 				$education_segments = $casestudies[0]->selected_segments;
	// 				$education_segment = $casestudies[0]->primary_segment;
	// 				$education_segment = $casestudies[0]->secondary_segment;
	// 				$education_exp = $casestudies[0]->education_exp;
	// 				if(!empty($casestudies[0]->education_one) && $casestudies[0]->education_one != ""){
	// 					$education_one = json_decode($casestudies[0]->education_one);
	// 					$education_one = $education_one->text;
	// 					$education_two = json_decode($casestudies[0]->education_two);
	// 					$education_two = $education_two->text;
	// 					$education_three = json_decode($casestudies[0]->education_three);
	// 					$education_three = $education_three->text;
	// 					$education_four = json_decode($casestudies[0]->education_four);
	// 					$education_four = $education_four->text;
	// 				} else {
	// 					$education_one = '';
	// 					$education_two = '';
	// 					$education_three = '';
	// 					$education_four ='';
	// 				}
					
	// 				$social_segments = $casestudies[0]->selected_segments;
	// 				$social_segment = $casestudies[0]->primary_segment;
	// 				$social_segment = $casestudies[0]->secondary_segment;
	// 				$social_exp = $casestudies[0]->social_exp;
	// 				if(!empty($casestudies[0]->social_one) && $casestudies[0]->social_one != ""){
	// 					$social_one = json_decode($casestudies[0]->social_one);
	// 					$social_one = $social_one->text;
	// 					$social_two = json_decode($casestudies[0]->social_two);
	// 					$social_two = $social_two->text;
	// 					$social_three = json_decode($casestudies[0]->social_three);
	// 					$social_three = $social_three->text;
	// 					$social_four = json_decode($casestudies[0]->social_four);
	// 					$social_four = $social_four->text;

	// 				} else {
	// 					$social_one = '';
	// 					$social_two = '';
	// 					$social_three = '';
	// 					$social_four = '';
	// 				}
					
	// 				$research_segments = $casestudies[0]->selected_segments;
	// 				$research_segment = $casestudies[0]->primary_segment;
	// 				$research_segment = $casestudies[0]->secondary_segment;
	// 				$research_exp = $casestudies[0]->research_exp;
	// 				if(!empty($casestudies[0]->research_one) && $casestudies[0]->research_one != ""){
	// 					$research_one = json_decode($casestudies[0]->research_one);
	// 					$research_one = $research_one->text;
	// 					$research_two = json_decode($casestudies[0]->research_two);
	// 					$research_two = $research_two->text;
	// 					$research_three = json_decode($casestudies[0]->research_three);
	// 					$research_three = $research_three->text;
	// 					$research_four = json_decode($casestudies[0]->research_four);
	// 					$research_four = $research_four->text;

	// 				} else {
	// 					$research_one = '';
	// 					$research_two = '';
	// 					$research_three = '';
	// 					$research_four = '';
	// 				}
					
	// 			} else {
	// 				$leadership_segments = '';;
	// 				$leadership_segment = '';
	// 				$leadership_segment = '';
	// 				$leadership_exp = '';
	// 				$leadership_one = '';
	// 				$leadership_two = '';
	// 				$leadership_three = '';
	// 				$leadership_four = '';

	// 				$patient_segments = '';
	// 				$patient_segment = '';
	// 				$patient_segment = '';
	// 				$patient_exp = '';					
	// 				$patient_one = '';
	// 				$patient_two = '';
	// 				$patient_three = '';
	// 				$patient_four = '';

	// 				$education_segments = '';;
	// 				$education_segment = '';
	// 				$education_segment = '';
	// 				$education_exp = '';
	// 				$education_one = '';
	// 				$education_two = '';
	// 				$education_three = '';
	// 				$education_four ='';

	// 				$social_segments = '';
	// 				$social_segment = '';
	// 				$social_segment = '';
	// 				$social_exp = '';
	// 				$social_one = '';
	// 				$social_two = '';
	// 				$social_three = '';
	// 				$social_four = '';

	// 				$research_segments = '';;
	// 				$research_segment = '';
	// 				$research_segment = '';
	// 				$research_exp = '';
	// 				$research_one = '';
	// 				$research_two = '';
	// 				$research_three = '';
	// 				$research_four = '';
	// 			}

	// 			$nurse = $this->Mdl_excel->retrieveByCol("email", "registration", array("uid"=>$r->uid));
	// 			$candEmail = $nurse !== "NA" ? $nurse[0]->email : "";

	// 			$documents = $this->Mdl_excel->retrieve(
	// 				"application_documents", 
	// 				array(
	// 					"uid" => $r->uid,
	// 					"code" => $r->code
	// 				)
	// 			);

	// 			$degreeName = $documents !== "NA" ? $documents[0]->degree_name : "";
	// 			$degreeDocumentName = $documents !== "NA" ? $documents[0]->degree_file_name : "";
	// 			$degreeDocument =  $documents !== "NA" && $documents[0]->degree_file_path !== "" ? base_url().$documents[0]->degree_file_path : "";

	// 			$councilName = $documents !== "NA" ? $documents[0]->council_name : "";
	// 			$councilRegistration = $documents !== "NA" ? $documents[0]->council_registration : "";
	// 			$medicalDocumentName = $documents !== "NA" ? $documents[0]->medical_file_name : "";
	// 			$medicalDocument = $documents !== "NA" && $documents[0]->medical_file_path !== "" ? base_url().$documents[0]->medical_file_path : "";

	// 			$passportFrontDocumentName = $documents !== "NA" ? $documents[0]->passport_front_file_name : "";
	// 			$passportFrontDocument = $documents !== "NA" && $documents[0]->passport_front_file_path !== "" ? base_url().$documents[0]->passport_front_file_path : "";

	// 			$passportBackDocumentName = $documents !== "NA" ? $documents[0]->passport_back_file_name : "";
	// 			$passportBackDocument = $documents !== "NA" && $documents[0]->passport_back_file_path !== "" ? base_url().$documents[0]->passport_back_file_path : "";
				
	// 			$nursePicName = $documents !== "NA" ? $documents[0]->nursepic_name : "";
	// 			$nursePic = $documents !== "NA" && $documents[0]->nursepic_path !== "" ? base_url().$documents[0]->nursepic_path : "";

	// 			$proofName = $documents !== "NA" ? $documents[0]->proof_name : "";
	// 			$proofDocumentName = $documents !== "NA" ? $documents[0]->proof_file_name : "";
	// 			$proofDocument = $documents !== "NA" && $documents[0]->proof_file_path !== "" ? base_url().$documents[0]->proof_file_path : "";

	// 			$employmentName = $documents !== "NA" ? $documents[0]->employment_name : "";
	// 			$employmentDocumentName = $documents !== "NA" ? $documents[0]->employment_file_name : "";
	// 			$employmentDocument = $documents !== "NA" && $documents[0]->employment_file_path !== "" ? base_url().$documents[0]->employment_file_path : "";

	// 			$declarationDocumentName = $documents !== "NA" ? $documents[0]->proof_name : "";
	// 			$declarationDocument = $documents !== "NA" && $documents[0]->declaration_file_path !== "" ? base_url().$documents[0]->declaration_file_path : "";

	// 			// $segmentStr = "";
	// 			// if( $r->selected_segments !== "" ){
	// 			// 	$segmentsArr = explode(",", $r->selected_segments);
	// 			// 	foreach($segmentsArr as $s){
	// 			// 		$segmentStr .= $segmentStr !== "" ? ', ' : '';
	// 			// 		switch($s){
	// 			// 			case 'leadership': $segmentStr .= "Leadership"; break;
	// 			// 			case 'patient': $segmentStr .= "Patient care"; break;
	// 			// 			case 'research': $segmentStr .= "Research/innovation"; break;
	// 			// 			case 'social': $segmentStr .= "Social/Community service"; break;
	// 			// 		}
	// 			// 	}
	// 			// }

	// 			// $supportingDocument1 = !is_null($r->award_one_path) && $r->award_one_path !== "" ? base_url().$r->award_one_path : "";
	// 			// $supportingDocument2 = !is_null($r->award_two_path) && $r->award_two_path !== "" ? base_url().$r->award_two_path : "";

	// 			$sheet->setCellValue('A'.$excel_row, $nos);
	// 			$sheet->setCellValue('B'.$excel_row, $date);
	// 			$sheet->setCellValue('C'.$excel_row, $r->status);
	// 			$sheet->setCellValue('D'.$excel_row, ucfirst($r->ey_assessment));
	// 			$sheet->setCellValue('E'.$excel_row, $r->application_number);
	// 			$sheet->setCellValue('F'.$excel_row, $r->first_name);
	// 			$sheet->setCellValue('G'.$excel_row, $r->middle_name);
	// 			$sheet->setCellValue('H'.$excel_row, $r->last_name);
	// 			$sheet->setCellValue('I'.$excel_row, $candEmail);
	// 			$sheet->setCellValue('J'.$excel_row, $dob);
	// 			$sheet->setCellValue('K'.$excel_row, $country);
	// 			$sheet->setCellValue('L'.$excel_row, $r->region);
	// 			$sheet->setCellValue('M'.$excel_row, $r->phone_code.'-'.$r->contact);
	// 			$sheet->setCellValue('N'.$excel_row, $r->gender);
	// 			$sheet->setCellValue('O'.$excel_row, $r->address);
	// 			$sheet->setCellValue('P'.$excel_row, $r->qualified_as);
	// 			$sheet->setCellValue('Q'.$excel_row, $r->institute);
	// 			$sheet->setCellValue('R'.$excel_row, $r->organisation_email);
	// 			$sheet->setCellValue('S'.$excel_row, $r->organisation_phonecode.'-'.$r->organisation_contact);
	// 			$sheet->setCellValue('T'.$excel_row, $r->organisation_website);
	// 			$sheet->setCellValue('U'.$excel_row, $r->total_exp);
	// 			$sheet->setCellValue('V'.$excel_row, $r->current_exp);

	// 			$sheet->setCellValue('W'.$excel_row, $degreeName);
	// 			$sheet->setCellValue('X'.$excel_row, $degreeDocumentName);
	// 			//$spreadsheet->getActiveSheet()->getCell('X'.$excel_row)->getHyperlink()->setUrl($degreeDocument);

	// 			$sheet->setCellValue('Y'.$excel_row, $councilName);
	// 			$sheet->setCellValue('Z'.$excel_row, $councilRegistration);
	// 			$sheet->setCellValue('AA'.$excel_row, $medicalDocumentName);
	// 			//$spreadsheet->getActiveSheet()->getCell('AA'.$excel_row)->getHyperlink()->setUrl($medicalDocument);

	// 			$sheet->setCellValue('AB'.$excel_row, $passportFrontDocumentName);
	// 			//$spreadsheet->getActiveSheet()->getCell('AB'.$excel_row)->getHyperlink()->setUrl($passportFrontDocument);

	// 			$sheet->setCellValue('AC'.$excel_row, $passportBackDocumentName);
	// 			//$sheet->getCell('AC'.$excel_row)->getHyperlink()->setUrl($passportBackDocument);

	// 			$sheet->setCellValue('AD'.$excel_row, $nursePicName);
	// 			//$sheet->getCell('AD'.$excel_row)->getHyperlink()->setUrl($nursePic);

	// 			$sheet->setCellValue('AE'.$excel_row, $proofName);
	// 			$sheet->setCellValue('AF'.$excel_row, $proofDocumentName);
	// 			//$sheet->getCell('AF'.$excel_row)->getHyperlink()->setUrl($proofDocument);
				
	// 			$sheet->setCellValue('AG'.$excel_row, $employmentName);
	// 			$sheet->setCellValue('AH'.$excel_row, $employmentDocumentName);
	// 			//$sheet->getCell('AH'.$excel_row)->getHyperlink()->setUrl($employmentDocument);

	// 			$sheet->setCellValue('AI'.$excel_row, $declarationDocumentName);
	// 			//$sheet->getCell('AI'.$excel_row)->getHyperlink()->setUrl($declarationDocument);

	// 			$sheet->setCellValue('AJ'.$excel_row, $r->ref_name_one);
	// 			$sheet->setCellValue('AK'.$excel_row, $r->ref_email_one);
	// 			$sheet->setCellValue('AL'.$excel_row, $refOneCountry);
	// 			$sheet->setCellValue('AM'.$excel_row, $r->ref_phone_code_one.'-'.$r->ref_contact_one);
	// 			$sheet->setCellValue('AN'.$excel_row, $r->ref_rel_one);

	// 			$sheet->setCellValue('AO'.$excel_row, $r->ref_name_two);
	// 			$sheet->setCellValue('AP'.$excel_row, $r->ref_email_two);
	// 			$sheet->setCellValue('AQ'.$excel_row, $refTwoCountry);
	// 			$sheet->setCellValue('AR'.$excel_row, $r->ref_phone_code_two.'-'.$r->ref_contact_two);
	// 			$sheet->setCellValue('AS'.$excel_row, $r->ref_rel_two);

	// 			$sheet->setCellValue('AT'.$excel_row, $leadership_segments);
	// 			$sheet->setCellValue('AU'.$excel_row, $leadership_segment);
	// 			$sheet->setCellValue('AV'.$excel_row, $leadership_segment);
	// 			$sheet->setCellValue('AW'.$excel_row, $leadership_exp);
	// 			$sheet->setCellValue('AX'.$excel_row, $leadership_one);
	// 			$sheet->setCellValue('AY'.$excel_row, $leadership_two);
	// 			$sheet->setCellValue('AZ'.$excel_row, $leadership_three);
	// 			$sheet->setCellValue('BA'.$excel_row, $leadership_four);

	// 			$sheet->setCellValue('BB'.$excel_row, $patient_segments);
	// 			$sheet->setCellValue('BC'.$excel_row, $patient_segment);
	// 			$sheet->setCellValue('BD'.$excel_row, $patient_segment);
	// 			$sheet->setCellValue('BE'.$excel_row, $patient_exp);
	// 			$sheet->setCellValue('BF'.$excel_row, $patient_one);
	// 			$sheet->setCellValue('BG'.$excel_row, $patient_two);
	// 			$sheet->setCellValue('BH'.$excel_row, $patient_three);
	// 			$sheet->setCellValue('BI'.$excel_row, $patient_four);
				
	// 			$sheet->setCellValue('BJ'.$excel_row, $education_segments);
	// 			$sheet->setCellValue('BK'.$excel_row, $education_segment);
	// 			$sheet->setCellValue('BL'.$excel_row, $education_segment);
	// 			$sheet->setCellValue('BM'.$excel_row, $education_exp);
	// 			$sheet->setCellValue('BN'.$excel_row, $education_one);
	// 			$sheet->setCellValue('BO'.$excel_row, $education_two);
	// 			$sheet->setCellValue('BP'.$excel_row, $education_three);
	// 			$sheet->setCellValue('BQ'.$excel_row, $education_four);

	// 			$sheet->setCellValue('BR'.$excel_row, $social_segments);
	// 			$sheet->setCellValue('BS'.$excel_row, $social_segment);
	// 			$sheet->setCellValue('BT'.$excel_row, $social_segment);
	// 			$sheet->setCellValue('BU'.$excel_row, $social_exp);
	// 			$sheet->setCellValue('BV'.$excel_row, $social_one);
	// 			$sheet->setCellValue('BW'.$excel_row, $social_two);
	// 			$sheet->setCellValue('BS'.$excel_row, $social_three);
	// 			$sheet->setCellValue('BX'.$excel_row, $social_four);

	// 			$sheet->setCellValue('BZ'.$excel_row, $research_segments);
	// 			$sheet->setCellValue('CA'.$excel_row, $research_segment);
	// 			$sheet->setCellValue('CB'.$excel_row, $research_segment);
	// 			$sheet->setCellValue('CC'.$excel_row, $research_exp);
	// 			$sheet->setCellValue('CD'.$excel_row, $research_one);
	// 			$sheet->setCellValue('CE'.$excel_row, $research_two);
	// 			$sheet->setCellValue('CF'.$excel_row, $research_three);
	// 			$sheet->setCellValue('CG'.$excel_row, $research_four);
	// 			$sheet->setCellValue('CH'.$excel_row, $r->reason);
	// 			$sheet->setCellValue('CI'.$excel_row, $r->language);
	// 			$sheet->setCellValue('JI'.$excel_row, $created_at);
				
				
	// 			// $sheet->setCellValue('AI'.$excel_row, $segmentStr);
	// 			// $sheet->setCellValue('AJ'.$excel_row, $r->leadership_casestudy_one);
	// 			// $sheet->setCellValue('AK'.$excel_row, $r->leadership_casestudy_two);
	// 			// $sheet->setCellValue('AL'.$excel_row, $r->leadership_casestudy_three);
	// 			// $sheet->setCellValue('AM'.$excel_row, $r->leadership_casestudy_four);
	// 			// $sheet->setCellValue('AN'.$excel_row, $r->research_casestudy_one);
	// 			// $sheet->setCellValue('AO'.$excel_row, $r->research_casestudy_two);
	// 			// $sheet->setCellValue('AP'.$excel_row, $r->research_casestudy_three);
	// 			// $sheet->setCellValue('AQ'.$excel_row, $r->research_casestudy_four);
	// 			// $sheet->setCellValue('AR'.$excel_row, $r->patient_casestudy_one);
	// 			// $sheet->setCellValue('AS'.$excel_row, $r->patient_casestudy_two);
	// 			// $sheet->setCellValue('AT'.$excel_row, $r->patient_casestudy_three);
	// 			// $sheet->setCellValue('AU'.$excel_row, $r->patient_casestudy_four);
	// 			// $sheet->setCellValue('AV'.$excel_row, $r->social_casestudy_one);
	// 			// $sheet->setCellValue('AW'.$excel_row, $r->social_casestudy_two);
	// 			// $sheet->setCellValue('AX'.$excel_row, $r->social_casestudy_three);
	// 			// $sheet->setCellValue('AY'.$excel_row, $r->social_casestudy_four);
	// 			// $sheet->setCellValue('AZ'.$excel_row, $supportingDocument1);
	// 			// $sheet->setCellValue('BA'.$excel_row, $supportingDocument2);

	// 			$excel_row++;
	// 			$nos++;
	// 		}
	// 	}

	// 	$writer = new Xlsx($spreadsheet);
	// 	header('Content-Type: application/vnd.ms-excel');
	// 	header('Content-Disposition: attachment;filename="Applications Master.xlsx"'); 
	// 	header('Cache-Control: max-age=0');

	// 	// download file 
	// 	$writer->save('php://output'); 
	// }
		
	function application(){
		//echo "<pre>";print_r($this->input->post());exit;
		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
		$spreadsheet->getProperties()->setCreator('Global Nursing Award 2024')
			->setLastModifiedBy('Global Nursing Award 2024')
			->setTitle('Applications Master')
			->setSubject('')
			->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:CJ1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A','AS') as $columnID){
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}
		
		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Date');
		$sheet->setCellValue('C1', 'Application Status');
		$sheet->setCellValue('D1', 'EY Assessment');
		$sheet->setCellValue('E1', 'Application Number');
		$sheet->setCellValue('F1', 'Application Code');
		$sheet->setCellValue('G1', 'Language');
		$sheet->setCellValue('H1', 'First name');
		$sheet->setCellValue('I1', 'Middle name');
		$sheet->setCellValue('J1', 'Last name');
		$sheet->setCellValue('K1', 'Email');
		$sheet->setCellValue('L1', 'Date of Birth');
		$sheet->setCellValue('M1', 'City');
		$sheet->setCellValue('N1', 'Country');
		$sheet->setCellValue('O1', 'Region');
		$sheet->setCellValue('P1', 'Contact No');
		$sheet->setCellValue('Q1', 'Gender');
		$sheet->setCellValue('R1', 'Address');
		$sheet->setCellValue('S1', 'Register as');
		$sheet->setCellValue('T1', 'Institute / hospital name');
		$sheet->setCellValue('U1', 'Job Title');
		$sheet->setCellValue('V1', 'Institute/ Hospital Country');
		$sheet->setCellValue('W1', 'Institute/ Hospital City');
		$sheet->setCellValue('X1', 'Contact Email ID');
		$sheet->setCellValue('Y1', 'Contact Number');
		$sheet->setCellValue('Z1', 'Reporting Manager Name');
		$sheet->setCellValue('AA1', 'Reporting Manager Designation');
		$sheet->setCellValue('AB1', 'Reporting Manager Email ID');
		$sheet->setCellValue('AC1', 'Reporting Manager Contact Number ');
		$sheet->setCellValue('AD1', 'Website link');
		$sheet->setCellValue('AE1', 'Total years of work experience as a Nurse');
		$sheet->setCellValue('AF1', 'Years of experience in the current institute/hospital');

		$sheet->setCellValue('AG1', 'Selected Segment');
		$sheet->setCellValue('AH1', 'Primary Segment');
		$sheet->setCellValue('AI1', 'Secondary Segment');
		$sheet->setCellValue('AJ1', 'Patient Experience');
		$sheet->setCellValue('AK1', 'Patient care in your daily work environment');
		$sheet->setCellValue('AL1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('AM1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('AN1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');
		$sheet->setCellValue('AO1', 'Leadership Experience');
		$sheet->setCellValue('AP1', 'Patient care in your daily work environment');
		$sheet->setCellValue('AQ1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('AR1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('AS1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('AT1', 'Education Experience');
		$sheet->setCellValue('AU1', 'Patient care in your daily work environment');
		$sheet->setCellValue('AV1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('AW1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('AX1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('AY1', 'Social Experience');
		$sheet->setCellValue('AZ1', 'Patient care in your daily work environment');
		$sheet->setCellValue('BA1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('BB1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('BC1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('BD1', 'Research Experience');
		$sheet->setCellValue('BE1', 'Patient care in your daily work environment');
		$sheet->setCellValue('BF1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('BG1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('BH1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');
		
		$sheet->setCellValue('BI1', 'Describe how do you intend to utilize the prize money if you win');

		$sheet->setCellValue('BJ1', 'First Referrer full name');
		$sheet->setCellValue('BK1', 'Referrer email ID');
		$sheet->setCellValue('BL1', 'Referrer country');
		$sheet->setCellValue('BM1', 'Referrer contact number');
		$sheet->setCellValue('BN1', 'Relationship with the reference');
		$sheet->setCellValue('BO1', 'Designation');

		$sheet->setCellValue('BP1', 'Second Referrer full name');		
		$sheet->setCellValue('BQ1', 'Referrer email ID');
		$sheet->setCellValue('BR1', 'Referrer country');
		$sheet->setCellValue('BS1', 'Referrer contact number');
		$sheet->setCellValue('BT1', 'Relationship with the reference');
		$sheet->setCellValue('BU1', 'Designation');

		$sheet->setCellValue('BV1', 'Educational Qualification (Highest degree)');
		$sheet->setCellValue('BW1', 'Educational Qualification (Highest degree) File Name');
		$sheet->setCellValue('BX1', 'Medical/Nurse council registration name');
		$sheet->setCellValue('BY1', 'Medical/Nurse council registration number');
		$sheet->setCellValue('BZ1', 'Medical/Nurse council registration File Name');
		$sheet->setCellValue('CA1', 'Passport Copy');
		$sheet->setCellValue('CB1', 'Valid national proof of identity of the country/region you are applying from (Government ID) ');
		$sheet->setCellValue('CC1', 'Minimum 2 years of employment proof as a registered nurse');
		$sheet->setCellValue('CD1', 'LinkedIn');
		$sheet->setCellValue('CE1', 'X (Twitter)');
		$sheet->setCellValue('CF1', 'Facebook');
		$sheet->setCellValue('CG1', 'Instagram ');
		
		$sheet->setCellValue('CH1', 'Collaterals doc');
		// $sheet->setCellValue('BY1', 'Collaterals doc 2');
		// $sheet->setCellValue('BZ1', 'Collaterals doc 3');
		// $sheet->setCellValue('CA1', 'Awards/ certifications  doc 1 name');
		// $sheet->setCellValue('CB1', 'Awards/ certifications  doc 1 ');
		// $sheet->setCellValue('CC1', 'Awards/ certifications  doc 2 name');
		// $sheet->setCellValue('CD1', 'Awards/ certifications  doc 2');
		// $sheet->setCellValue('CE1', 'Awards/ certifications  doc 3 name');
		// $sheet->setCellValue('CF1', 'Awards/ certifications  doc 3');

		$sheet->setCellValue('CI1', 'Reason');
		$sheet->setCellValue('CJ1', 'Section');
		$sheet->setCellValue('CK1', 'Modify Date');
		// $sheet->setCellValue('CJ1', 'Date and Time');


		// $sheet->setCellValue('AI1', 'Selected segments');
		// $sheet->setCellValue('AJ1', 'We believe nursing is about leading from the front. So, why would you consider yourself as a leader and what difference has that made?');
		// $sheet->setCellValue('AK1', 'Help us understand the challenges faced and how did you overcome the same');
		// $sheet->setCellValue('AL1', 'How do patients and peers respond to your leadership?');
		// $sheet->setCellValue('AM1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AN1', 'Describe your contributions to nursing research, policy, and/or practice at the local regional, state, and /or national level');
		// $sheet->setCellValue('AO1', 'Describe the challenges faced  and how did you overcome the same');
		// $sheet->setCellValue('AP1', 'Describe the impact of the initiative on the patients, employer, peers, etc?');
		// $sheet->setCellValue('AQ1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AR1', 'Describe the initiatives undertaken to facilitate positive changes in the work environment and improve the quality of patient care');
		// $sheet->setCellValue('AS1', 'Describe the challenges faced  and how did you overcome the same');
		// $sheet->setCellValue('AT1', 'Describe the impact of the initiative on the patients, employer, peers, etc?');
		// $sheet->setCellValue('AU1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AV1', 'Describe the your contribution for the betterment of the community/society');
		// $sheet->setCellValue('AW1', 'Describe the challenges faced  and how did you overcome the same');
		// $sheet->setCellValue('AX1', 'Describe the impact of the initiative on the community and what was the change they witnessed?');
		// $sheet->setCellValue('AY1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AZ1', 'Awards and certifications');
		// $sheet->setCellValue('BA1', 'Awards and certifications');
		//$_APPLICATIONS_QUERY = "SELECT * FROM application_personal_details limit 12000";
		$content = $this->input->post();
		$_APPLICATIONS_QUERY = '';
		
		$edition = 'three';
		$_APPLICATIONS_QUERY = "SELECT a.applications_id, a.uid, a.`code`,a.application_number,a.first_name,
						a.middle_name,a.last_name,a.dob,a.country,a.region,a.phone_code,a.contact,a.address,a.gender,a.qualified_as,
						a.institute,
						a.organisation_phonecode,a.organisation_contact,a.organisation_email,a.organisation_website,a.total_exp,
						a.current_exp,a.ref_name_one,a.ref_designation_one,a.ref_email_one,a.ref_country_one,a.ref_phone_code_one,ref_contact_one,
						a.ref_rel_one,a.ref_name_two,a.ref_designation_two,a.ref_email_two,a.ref_country_two,
						a.ref_phone_code_two,a.ref_contact_two,a.ref_rel_two,a.ref_rel_other_two,a.`status`,a.step,
						a.ey_assessment,a.is_recommended,a.reason,a.`language`,a.created_at,a.nurce_city,a.`city`,a.hospital_country,a.relational_manager_name,
						a.relational_manager_designation,a.relational_manager_email,a.relational_manager_mobile,a.job_title,a.modified_at,a.first_name_lang,a.middle_name_lang,
						a.last_name_lang,a.institute_lang,a.ref_name_one_lang,a.ref_designation_one_lang,a.ref_name_two_lang,a.ref_designation_two_lang
						FROM application_personal_details as a ";
			
		//echo $_APPLICATIONS_QUERY;exit;
		//limit 10000 offset 10000
		$records = $this->Mdl_excel->customQuery($_APPLICATIONS_QUERY);
		$excel_row = 2;
		$nos = 1;
		if( $records !== "NA" ){
			foreach($records as $r){

				$date = date("Y-m-d H:i:s", strtotime($r->created_at));
				$created_at = date("Y-m-d H:i:s", strtotime($r->created_at));
				$dob = date("Y-m-d", strtotime($r->dob));
				
				$country = Modules::run('api/application/personal/country',$r->country);
				$refOneCountry = Modules::run('api/application/personal/country',$r->ref_country_one);
				$refTwoCountry = Modules::run('api/application/personal/country',$r->ref_country_two);
				$casestudies = Modules::run('api/application/personal/caseStudies',$r->uid);
				if($casestudies != "NA"){
					$ledership_array = explode(',',$casestudies[0]->selected_segments);
					$leadership_segments = $casestudies[0]->selected_segments;
					$leadership_primary = $casestudies[0]->primary_segment;
					$leadership_secondary = $casestudies[0]->secondary_segment;
					$leadership_exp = $casestudies[0]->leadership_exp;
					if(in_array('leadership', $ledership_array)){
						
						if(!empty($casestudies[0]->leadership_one) && $casestudies[0]->leadership_one != ""){
							$leadership_one = json_decode($casestudies[0]->leadership_one);
							$leadership_one = $leadership_one->textEn;
							$leadership_two = json_decode($casestudies[0]->leadership_two);
							$leadership_two = $leadership_two->textEn;
							$leadership_three = json_decode($casestudies[0]->leadership_three);
							$leadership_three = $leadership_three->textEn;
							$leadership_four = json_decode($casestudies[0]->leadership_four);
							$leadership_four = $leadership_four->textEn;
							
						} else {
							$leadership_one = '';
							$leadership_two = '';
							$leadership_three = '';
							$leadership_four = '';
						}
					} else {
						$leadership_segments = '';
						$leadership_primary = '';
						$leadership_secondary = '';
						$leadership_exp = '';
						$leadership_one = '';
						$leadership_two = '';
						$leadership_three = '';
						$leadership_four = '';
					}
					$patient_array = explode(',',$casestudies[0]->selected_segments);
					//print_r($patient_array);
					//exit;
					if(in_array('patient', $patient_array)){
						$patient_segments = $casestudies[0]->selected_segments;
						$patient_primary = $casestudies[0]->primary_segment;
						$patient_secondary = $casestudies[0]->secondary_segment;
						$patient_exp = $casestudies[0]->patient_exp;
						if(!empty($casestudies[0]->patient_one) && $casestudies[0]->patient_one != ""){
							$patient_one = json_decode($casestudies[0]->patient_one);
							$patient_one = $patient_one->textEn;
							$patient_two = json_decode($casestudies[0]->patient_two);
							$patient_two = $patient_two->textEn;
							$patient_three = json_decode($casestudies[0]->patient_three);
							$patient_three = $patient_three->textEn;
							$patient_four = json_decode($casestudies[0]->patient_four);
							$patient_four = $patient_four->textEn;
							
						} else {
							$patient_one = '';
							$patient_two = '';
							$patient_three = '';
							$patient_four = '';
						}
					} else {
						$patient_segments = '';
						$patient_primary = '';
						$patient_secondary = '';
						$patient_exp = '';
						$patient_one = '';
						$patient_two = '';
						$patient_three = '';
						$patient_four = '';
					}

					$education_array = explode(',',$casestudies[0]->selected_segments);
					if(in_array('education', $education_array)){
						$education_segments = $casestudies[0]->selected_segments;
						$education_primary = $casestudies[0]->primary_segment;
						$education_secondary = $casestudies[0]->secondary_segment;
						$education_exp = $casestudies[0]->education_exp;
						if(!empty($casestudies[0]->education_one) && $casestudies[0]->education_one != ""){
							$education_one_t = json_decode($casestudies[0]->education_one);
							$education_one = $education_one_t->textEn;
							$education_two = json_decode($casestudies[0]->education_two);
							$education_two = $education_two->textEn;
							$education_three = json_decode($casestudies[0]->education_three);
							$education_three = $education_three->textEn;
							$education_four = json_decode($casestudies[0]->education_four);
							$education_four = $education_four->textEn;
						} else {
							$education_one = '';
							$education_two = '';
							$education_three = '';
							$education_four ='';
						}
					} else {
						$education_segments = '';
						$education_primary = '';
						$education_secondary = '';
						$education_exp = '';
						$education_one = '';
						$education_two = '';
						$education_three = '';
						$education_four ='';
					}
					
					$social_array = explode(',',$casestudies[0]->selected_segments);
					if(in_array('social', $social_array)){
						$social_segments = $casestudies[0]->selected_segments;
						$social_primary = $casestudies[0]->primary_segment;
						$social_secondary = $casestudies[0]->secondary_segment;
						$social_exp = $casestudies[0]->social_exp;
						if(!empty($casestudies[0]->social_one) && $casestudies[0]->social_one != ""){
							$social_one = json_decode($casestudies[0]->social_one);
							$social_one = $social_one->textEn;
							$social_two = json_decode($casestudies[0]->social_two);
							$social_two = $social_two->textEn;
							$social_three = json_decode($casestudies[0]->social_three);
							$social_three = $social_three->textEn;
							$social_four = json_decode($casestudies[0]->social_four);
							$social_four = $social_four->textEn;
	
						} else {
							$social_one = '';
							$social_two = '';
							$social_three = '';
							$social_four = '';
						}
					} else {
						$social_segments = '';
						$social_primary = '';
						$social_secondary = '';
						$social_exp = '';
						$social_one = '';
						$social_two = '';
						$social_three = '';
						$social_four = '';
					}
					
					$research_array = explode(',',$casestudies[0]->selected_segments);
					if(in_array('research', $research_array)){
						$research_segments = $casestudies[0]->selected_segments;
						$research_primary = $casestudies[0]->primary_segment;
						$research_secondary = $casestudies[0]->secondary_segment;
						$research_exp = $casestudies[0]->research_exp;
						if(!empty($casestudies[0]->research_one) && $casestudies[0]->research_one != ""){
							$research_one = json_decode($casestudies[0]->research_one);
							$research_one = $research_one->textEn;
							$research_two = json_decode($casestudies[0]->research_two);
							$research_two = $research_two->textEn;
							$research_three = json_decode($casestudies[0]->research_three);
							$research_three = $research_three->textEn;
							$research_four = json_decode($casestudies[0]->research_four);
							$research_four = $research_four->textEn;
	
						} else {
							$research_one = '';
							$research_two = '';
							$research_three = '';
							$research_four = '';
						}
					} else {
						$research_segments = '';
						$research_primary = '';
						$research_secondary = '';
						$research_exp = '';
						$research_one = '';
						$research_two = '';
						$research_three = '';
						$research_four = '';
					}
					
				} else {
					$leadership_segments = '';;
					$leadership_primary = '';
					$leadership_secondary = '';
					$leadership_exp = '';
					$leadership_one = '';
					$leadership_two = '';
					$leadership_three = '';
					$leadership_four = '';

					$patient_segments = '';
					$patient_primary = '';
					$patient_secondary = '';
					$patient_exp = '';					
					$patient_one = '';
					$patient_two = '';
					$patient_three = '';
					$patient_four = '';

					$education_segments = '';;
					$education_primary = '';
					$education_secondary = '';
					$education_exp = '';
					$education_one = '';
					$education_two = '';
					$education_three = '';
					$education_four ='';

					$social_segments = '';
					$social_primary = '';
					$social_secondary = '';
					$social_exp = '';
					$social_one = '';
					$social_two = '';
					$social_three = '';
					$social_four = '';

					$research_segments = '';;
					$research_primary = '';
					$research_secondary = '';
					$research_exp = '';
					$research_one = '';
					$research_two = '';
					$research_three = '';
					$research_four = '';
				}
				$prize_money_array = '';$prize_money = '';
				if(isset($casestudies[0]->prize_money) && !empty($casestudies[0]->prize_money)) {
					$prize_money_array = json_decode($casestudies[0]->prize_money);
					$prize_money = $prize_money_array->textEn;
				}
				$nurse = $this->Mdl_excel->retrieveByCol("email", "registration", array("uid"=>$r->uid));
				$candEmail = $nurse !== "NA" ? $nurse[0]->email : "";

				$_APPLICATIONS_DOCUMENTS_QUERY = "select ad.document_id,ad.uid,ad.`code`,ad.degree_name,ad.degree_file_name,
								ad.degree_file_path,ad.passport_front_file_name,ad.passport_front_file_path,ad.passport_back_file_name,
								ad.passport_back_file_path,ad.nursepic_name,ad.nursepic_path,ad.council_name,ad.council_registration,
								ad.medical_file_name,ad.medical_file_path,ad.proof_name,ad.proof_file_name,ad.proof_file_path,ad.proof_type,
								ad.employment_name,ad.employment_file_name,ad.employment_file_path,ad.declaration_name,ad.declaration_file_name,
								ad.declaration_file_path,ad.award_one,ad.award_one_name,ad.award_one_path,ad.award_two,ad.award_two_name,
								ad.award_two_path,ad.award_three,ad.award_three_name,ad.award_three_path,ad.sup_file_one_name,ad.sup_file_one_path,
								ad.sup_file_two_name,ad.sup_file_two_path,ad.sup_file_three_name,ad.sup_file_three_path,ad.created_at,ad.linkdin,ad.twitter,ad.facebook,ad.instagram,ad.wordFileName,ad.passport_check,ad.national_proof_check,ad.experience_check
								from application_documents as ad where ad.uid= '".$r->uid."' and ad.`code` = '".$r->code."'";
				$documents = $this->Mdl_excel->customQuery($_APPLICATIONS_DOCUMENTS_QUERY);
				

				$degreeName = $documents !== "NA" ? $documents[0]->degree_name : "";
				$degreeDocumentName = $documents !== "NA" ? $documents[0]->degree_file_name : "";
				$degreeDocument =  $documents !== "NA" && $documents[0]->degree_file_path !== "" ? base_url().$documents[0]->degree_file_path : "";

				$councilName = $documents !== "NA" ? $documents[0]->council_name : "";
				$councilRegistration = $documents !== "NA" ? $documents[0]->council_registration : "";
				$medicalDocumentName = $documents !== "NA" ? $documents[0]->medical_file_name : "";
				$medicalDocument = $documents !== "NA" && $documents[0]->medical_file_path !== "" ? base_url().$documents[0]->medical_file_path : "";

				$passportFrontDocumentName = $documents !== "NA" ? $documents[0]->passport_front_file_name : "";
				$passportFrontDocument = $documents !== "NA" && $documents[0]->passport_front_file_path !== "" ? base_url().$documents[0]->passport_front_file_path : "";

				$passportBackDocumentName = $documents !== "NA" ? $documents[0]->passport_back_file_name : "";
				$passportBackDocument = $documents !== "NA" && $documents[0]->passport_back_file_path !== "" ? base_url().$documents[0]->passport_back_file_path : "";
				
				$nursePicName = $documents !== "NA" ? $documents[0]->nursepic_name : "";
				$nursePic = $documents !== "NA" && $documents[0]->nursepic_path !== "" ? base_url().$documents[0]->nursepic_path : "";

				$proofName = $documents !== "NA" ? $documents[0]->proof_name : "";
				$proofDocumentName = $documents !== "NA" ? $documents[0]->proof_file_name : "";
				$proofDocument = $documents !== "NA" && $documents[0]->proof_file_path !== "" ? base_url().$documents[0]->proof_file_path : "";

				$employmentName = $documents !== "NA" ? $documents[0]->employment_name : "";
				$employmentDocumentName = $documents !== "NA" ? $documents[0]->employment_file_name : "";
				$employmentDocument = $documents !== "NA" && $documents[0]->employment_file_path !== "" ? base_url().$documents[0]->employment_file_path : "";

				$declarationDocumentName = $documents !== "NA" ? $documents[0]->proof_name : "";
				$declarationDocument = $documents !== "NA" && $documents[0]->declaration_file_path !== "" ? base_url().$documents[0]->declaration_file_path : "";

				$award_one = $documents !== "NA" ? $documents[0]->award_one : "";
				$award_one_name = $documents !== "NA" && $documents[0]->award_one_name !== "" ? $documents[0]->award_one_name : "";

				$award_two = $documents !== "NA" ? $documents[0]->award_two : "";
				$award_two_name = $documents !== "NA" && $documents[0]->award_two_name !== "" ? $documents[0]->award_two_name : "";

				$award_three = $documents !== "NA" ? $documents[0]->award_three : "";
				$award_three_name = $documents !== "NA" && $documents[0]->award_three_name !== "" ? $documents[0]->award_three_name : "";

				$sup_file_one_name = $documents !== "NA" && $documents[0]->sup_file_one_name !== "" ? $documents[0]->sup_file_one_name : "";
				$sup_file_two_name = $documents !== "NA" && $documents[0]->sup_file_two_name !== "" ? $documents[0]->sup_file_two_name : "";
				$sup_file_three_name = $documents !== "NA" && $documents[0]->sup_file_three_name !== "" ? $documents[0]->sup_file_three_name : "";

				$word_file_name = $documents !== "NA" && $documents[0]->wordFileName !== "" ? $documents[0]->wordFileName : "";
				
				$section = '';
				if($r->step == "personal-details"){
					$section = 'section 1';
				} else if($r->step == "professional-details"){
					$section = 'section 2';
				} else if($r->step == "references"){
					$section = 'section 3';
				} else if($r->step == "segments"){
					$section = 'section 4';
				} else {
					$section = 'section 5';
				}
				$first_name = '';
				if(isset($r->first_name_lang) && !empty($r->first_name_lang)){
					$first_name = $r->first_name.'/'.$r->first_name_lang;
				} else {
					$first_name = $r->first_name;
				}

				$middle_name = '';
				if(isset($r->middle_name_lang) && !empty($r->middle_name_lang)){
					$middle_name = $r->middle_name.'/'.$r->middle_name_lang;
				} else {
					$middle_name = $r->middle_name;
				}
				$last_name = '';
				if(isset($r->last_name_lang) && !empty($r->last_name_lang)){
					$last_name = $r->last_name.'/'.$r->last_name_lang;
				} else {
					$last_name = $r->last_name;
				}
				$institute = '';
				if(isset($r->institute_lang) && !empty($r->institute_lang)){
					$institute = $r->institute.'/'.$r->institute_lang;
				} else {
					$institute = $r->institute;
				}
				$ref_name_one = '';
				if(isset($r->ref_name_one_lang) && !empty($r->ref_name_one_lang)){
					$ref_name_one = $r->ref_name_one.'/'.$r->ref_name_one_lang;
				} else {
					$ref_name_one = $r->ref_name_one;
				}
				$ref_designation_one = '';
				if(isset($r->ref_designation_one_lang) && !empty($r->ref_designation_one_lang)){
					$ref_designation_one = $r->ref_designation_one.'/'.$r->ref_designation_one_lang;
				} else {
					$ref_designation_one = $r->ref_designation_one;
				}

				$ref_name_two = '';
				if(isset($r->ref_name_two_lang) && !empty($r->ref_name_two_lang)){
					$ref_name_two = $r->ref_name_two.'/'.$r->ref_name_two_lang;
				} else {
					$ref_name_two = $r->ref_name_two;
				}
				$ref_designation_two = '';
				if(isset($r->ref_designation_two_lang) && !empty($r->ref_designation_two_lang)){
					$ref_designation_two = $r->ref_designation_two.'/'.$r->ref_designation_two_lang;
				} else {
					$ref_designation_two = $r->ref_designation_two;
				}
				
				if(isset($documents[0]->passport_check) &&  $documents[0]->passport_check == "yes"){
					$passport_check = 'Agreed';
				} else {
					$passport_check = '';
				}
				
				if(isset($documents[0]->national_proof_check) && $documents[0]->national_proof_check=="yes"){
					$national_proof_check = 'Agreed';
				} else {
					$national_proof_check = '';
				}
				
				if(isset($documents[0]->experience_check) && $documents[0]->experience_check=="yes"){
					$experience_check = 'Agreed';
				} else {
					$experience_check = '';
				}

				$organisation_contact = '';
				if(!empty($r->organisation_contact)){
					$organisation_contact = $r->organisation_phonecode.'-'.$r->organisation_contact;
				} else {
					$organisation_contact = '';
				}

				if(!empty($r->contact)){
					$contact = $r->phone_code.'-'.$r->contact;
				} else {
					$contact = '';
				}
				$sheet->setCellValue('A'.$excel_row, $nos);
				$sheet->setCellValue('B'.$excel_row, $date);
				$sheet->setCellValue('C'.$excel_row, $r->status);
				$sheet->setCellValue('D'.$excel_row, ucfirst($r->ey_assessment));
				$sheet->setCellValue('E'.$excel_row, $r->application_number);
				$sheet->setCellValue('F'.$excel_row, $r->code);
				$sheet->setCellValue('G'.$excel_row, $r->language);
				$sheet->setCellValue('H'.$excel_row, $first_name);
				$sheet->setCellValue('I'.$excel_row, $middle_name);
				$sheet->setCellValue('J'.$excel_row, $last_name);
				$sheet->setCellValue('K'.$excel_row, $candEmail);
				$sheet->setCellValue('L'.$excel_row, $dob);
				$sheet->setCellValue('M'.$excel_row, $r->nurce_city);
				$sheet->setCellValue('N'.$excel_row, $country);
				$sheet->setCellValue('O'.$excel_row, $r->region);
				$sheet->setCellValue('P'.$excel_row, $contact);
				$sheet->setCellValue('Q'.$excel_row, $r->gender);
				$sheet->setCellValue('R'.$excel_row, $r->address);
				$sheet->setCellValue('S'.$excel_row, $r->qualified_as);
				$sheet->setCellValue('T'.$excel_row, $institute);
				$sheet->setCellValue('U'.$excel_row, $r->job_title);
				$sheet->setCellValue('V'.$excel_row, $r->hospital_country);
				$sheet->setCellValue('W'.$excel_row, $r->city);
				$sheet->setCellValue('X'.$excel_row, $r->organisation_email);
				$sheet->setCellValue('Y'.$excel_row, $organisation_contact);
				$sheet->setCellValue('Z'.$excel_row, $r->relational_manager_name);
				$sheet->setCellValue('AA'.$excel_row, $r->relational_manager_designation);
				$sheet->setCellValue('AB'.$excel_row, $r->relational_manager_email);
				$sheet->setCellValue('AC'.$excel_row, $r->relational_manager_mobile);
				$sheet->setCellValue('AD'.$excel_row, $r->organisation_website);
				$sheet->setCellValue('AE'.$excel_row, $r->total_exp);
				$sheet->setCellValue('AF'.$excel_row, $r->current_exp);
				
				$sheet->setCellValue('AG'.$excel_row, $leadership_segments);
				$sheet->setCellValue('AH'.$excel_row, $leadership_primary);
				$sheet->setCellValue('AI'.$excel_row, $leadership_secondary);
				$sheet->setCellValue('AJ'.$excel_row, $patient_exp);
				$sheet->setCellValue('AK'.$excel_row, $patient_one);
				$sheet->setCellValue('AL'.$excel_row, $patient_two);
				$sheet->setCellValue('AM'.$excel_row, $patient_three);
				$sheet->setCellValue('AN'.$excel_row, $patient_four);

				$sheet->setCellValue('AO'.$excel_row, $leadership_exp);
				$sheet->setCellValue('AP'.$excel_row, $leadership_one);
				$sheet->setCellValue('AQ'.$excel_row, $leadership_two);
				$sheet->setCellValue('AR'.$excel_row, $leadership_three);
				$sheet->setCellValue('AS'.$excel_row, $leadership_four);
				
				$sheet->setCellValue('AT'.$excel_row, $education_exp);
				$sheet->setCellValue('AU'.$excel_row, $education_one);
				$sheet->setCellValue('AV'.$excel_row, $education_two);
				$sheet->setCellValue('AW'.$excel_row, $education_three);
				$sheet->setCellValue('AX'.$excel_row, $education_four);

				$sheet->setCellValue('AY'.$excel_row, $social_exp);
				$sheet->setCellValue('AZ'.$excel_row, $social_one);
				$sheet->setCellValue('BA'.$excel_row, $social_two);
				$sheet->setCellValue('BS'.$excel_row, $social_three);
				$sheet->setCellValue('BC'.$excel_row, $social_four);

				$sheet->setCellValue('BD'.$excel_row, $research_exp);
				$sheet->setCellValue('BE'.$excel_row, $research_one);
				$sheet->setCellValue('BF'.$excel_row, $research_two);
				$sheet->setCellValue('BG'.$excel_row, $research_three);
				$sheet->setCellValue('BH'.$excel_row, $research_four);
				
				$sheet->setCellValue('BI'.$excel_row, $prize_money);

				$sheet->setCellValue('BJ'.$excel_row, $ref_name_one);
				$sheet->setCellValue('BK'.$excel_row, $r->ref_email_one);
				$sheet->setCellValue('BL'.$excel_row, $refOneCountry);
				$sheet->setCellValue('BM'.$excel_row, $r->ref_phone_code_one.'-'.$r->ref_contact_one);
				$sheet->setCellValue('BN'.$excel_row, $r->ref_rel_one);
				$sheet->setCellValue('BO'.$excel_row, $ref_designation_one);
				$sheet->setCellValue('BP'.$excel_row, $ref_name_two);
				$sheet->setCellValue('BQ'.$excel_row, $r->ref_email_two);
				$sheet->setCellValue('BR'.$excel_row, $refTwoCountry);
				$sheet->setCellValue('BS'.$excel_row, $r->ref_phone_code_two.'-'.$r->ref_contact_two);
				$sheet->setCellValue('BT'.$excel_row, $r->ref_rel_two);
				$sheet->setCellValue('BU'.$excel_row, $ref_designation_two);
				$sheet->setCellValue('BV'.$excel_row, $degreeName);
				$sheet->setCellValue('BW'.$excel_row, $degreeDocumentName);
				$sheet->setCellValue('BX'.$excel_row, $councilName);
				$sheet->setCellValue('BY'.$excel_row, $councilRegistration);
				$sheet->setCellValue('BZ'.$excel_row, $medicalDocumentName);
				$sheet->setCellValue('CA'.$excel_row, $passport_check);
				$sheet->setCellValue('CB'.$excel_row, $national_proof_check);
				$sheet->setCellValue('CC'.$excel_row, $experience_check);
				$sheet->setCellValue('CD'.$excel_row, isset($documents[0]->linkdin) ? $documents[0]->linkdin : '');
				$sheet->setCellValue('CE'.$excel_row, isset($documents[0]->twitter) ? $documents[0]->twitter : '');
				$sheet->setCellValue('CF'.$excel_row, isset($documents[0]->facebook) ? $documents[0]->facebook : '');
				$sheet->setCellValue('CG'.$excel_row, isset($documents[0]->instagram) ? $documents[0]->instagram : '');
				$sheet->setCellValue('CH'.$excel_row, $word_file_name);
				$sheet->setCellValue('CI'.$excel_row, $r->reason);
				$sheet->setCellValue('CJ'.$excel_row, $section);
				$sheet->setCellValue('CK'.$excel_row, $r->modified_at);
				$excel_row++;
				$nos++;
			}
		}
		//ob_clean();
		$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Applications Master Edition.xlsx"'); 
		header('Cache-Control: max-age=0');

		// download file 
		$writer->save('php://output');  
	}


	

	


	   
	/**
	 * 	Jury Applications Template
	 */
	function juryTemplate(){
		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
    	$spreadsheet->getProperties()->setCreator('Global Nursing Award 2022')
      ->setLastModifiedBy('Global Nursing Award 2022')
      ->setTitle('Jury Applications Mapping')
      ->setSubject('')
      ->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:I1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A', 'I') as $columnID) {
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}

		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Aplication No');
		$sheet->setCellValue('C1', 'Jury 1');
		$sheet->setCellValue('D1', 'Jury 2');
		$sheet->setCellValue('E1', 'Jury 3');
		$sheet->setCellValue('F1', 'Jury 4');
		$sheet->setCellValue('G1', 'Jury 5');
		$sheet->setCellValue('H1', 'Jury 6');
		// $sheet->setCellValue('I1', 'Jury 7');
		//$sheet->setCellValue('I1', 'Region');

		$get_applications = "SELECT applications_id, application_number FROM users_application_details WHERE ey_assessment='approved' AND status='submitted' ORDER BY application_number";
		$entries = $this->Mdl_excel->customQuery($get_applications);
		$excel_row = 2;
		$nos = 1;
		
		if( $entries !== "NA" ){
			foreach( $entries as $e ){
				$jury = $this->Mdl_excel->retrieve("jury_application_mapping",array("applications_id" => $e->applications_id ));
				if( $jury !== "NA" ){
					$sheet->setCellValue('A'.$excel_row, $nos);
					$sheet->setCellValue('B'.$excel_row, $e->application_number);
					$sheet->setCellValue('C'.$excel_row, $jury[0]->jury_one_code);
					$sheet->setCellValue('D'.$excel_row, $jury[0]->jury_two_code);
					$sheet->setCellValue('E'.$excel_row, $jury[0]->jury_three_code);
					$sheet->setCellValue('F'.$excel_row, $jury[0]->jury_four_code);
					$sheet->setCellValue('G'.$excel_row, $jury[0]->jury_five_code);
					$sheet->setCellValue('H'.$excel_row, $jury[0]->jury_six_code);
					//$sheet->setCellValue('I'.$excel_row, $jury[0]->jury_seven_code);
					//$sheet->setCellValue('I'.$excel_row, $jury[0]->region);
				}else{
					$sheet->setCellValue('A'.$excel_row, $nos);
					$sheet->setCellValue('B'.$excel_row, $e->application_number);
					$sheet->setCellValue('C'.$excel_row, "");
					$sheet->setCellValue('D'.$excel_row, "");
					$sheet->setCellValue('E'.$excel_row, "");
					$sheet->setCellValue('F'.$excel_row, "");
					$sheet->setCellValue('G'.$excel_row, "");
					$sheet->setCellValue('H'.$excel_row, "");
					//$sheet->setCellValue('I'.$excel_row, "");
					//$sheet->setCellValue('I'.$excel_row, "");
				}
				$excel_row++;
				$nos++;	
			}
		}

		$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Jury Applications Mapping.xlsx"'); 
		header('Cache-Control: max-age=0');

		// download file 
		$writer->save('php://output'); 
	}

	/**
	 * 	Jury Voting Master
	 */
	function juryVotes(){

		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();
	
		// Set document properties
		$spreadsheet->getProperties()->setCreator('Global Nursing Award 2022')
			->setLastModifiedBy('Global Nursing Award 2022')
			->setTitle('Jury Voting Master')
			->setSubject('')
			->setDescription('');
	
		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:J1')->applyFromArray($styleArray);
	
		// auto fit column to content
		foreach(range('A', 'I') as $columnID) {
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(false);
		}
	
		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Aplication No');
		$sheet->setCellValue('C1', 'Jury');
		$sheet->setCellValue('D1', 'Score 1');
		$sheet->setCellValue('E1', 'Score 2');
		$sheet->setCellValue('F1', 'Score 3');
		$sheet->setCellValue('G1', 'Comments');
		$sheet->setCellValue('H1', 'Feedback');
		$sheet->setCellValue('I1', 'Reason');
		$sheet->setCellValue('J1', 'Reason');
	
		$get_applications = "SELECT applications_id, application_number,region FROM application_personal_details WHERE ey_assessment='approved' AND status='submitted' ORDER BY application_number";
		$entries = $this->Mdl_excel->customQuery($get_applications);
		$excel_row = 2;
		$nos = 1;
	
		if( $entries !== "NA" ){
			foreach( $entries as $e ){
				$jury = $this->Mdl_excel->retrieve("jury_application_mapping",array("applications_id" => $e->applications_id ));
				if( $jury !== "NA" ){

					if( $jury[0]->jury_one_code !== "" ){
						$juryOneVoteOne = $juryOneVoteTwo = $juryOneVoteThree = $juryOneComments = $juryOneFeedback = $juryOneReason = "";
						$juryOneVotingInfo = $this->Mdl_excel->retrieve("jury_application_votes",array(
							"applications_id" => $e->applications_id,
							"jury_code" => $jury[0]->jury_one_code
						));
	
						if( $juryOneVotingInfo !== "NA" ){
							$juryOneVoteOne = $juryOneVotingInfo[0]->vote_one;
							$juryOneVoteTwo = $juryOneVotingInfo[0]->vote_two;
							$juryOneVoteThree = $juryOneVotingInfo[0]->vote_three;
							$juryOneComments = $juryOneVotingInfo[0]->comments;
							$juryOneFeedback = $juryOneVotingInfo[0]->feedback;
							$juryOneReason = $juryOneVotingInfo[0]->reason;
						}
	
						$sheet->setCellValue('A'.$excel_row, $nos);
						$sheet->setCellValue('B'.$excel_row, $e->application_number);
						$sheet->setCellValue('C'.$excel_row, $jury[0]->jury_one_code);
						$sheet->setCellValue('D'.$excel_row, $juryOneVoteOne);
						$sheet->setCellValue('E'.$excel_row, $juryOneVoteTwo);
						$sheet->setCellValue('F'.$excel_row, $juryOneVoteThree);
						$sheet->setCellValue('G'.$excel_row, $juryOneComments);
						$sheet->setCellValue('H'.$excel_row, $juryOneFeedback);
						$sheet->setCellValue('I'.$excel_row, $juryOneReason);
						$sheet->setCellValue('J'.$excel_row, $jury[0]->region);
						$excel_row++;
						$nos++;	
					}
	
					if( $jury[0]->jury_two_code !== "" ){
						$juryTwoVoteOne = $juryTwoVoteTwo = $juryTwoVoteThree = $juryTwoComments = $juryTwoFeedback = $juryTwoReason = "";
						$juryTwoVotingInfo = $this->Mdl_excel->retrieve("jury_application_votes",array(
							"applications_id" => $e->applications_id,
							"jury_code" => $jury[0]->jury_two_code
						));
	
						if( $juryTwoVotingInfo !== "NA" ){
							$juryTwoVoteOne = $juryTwoVotingInfo[0]->vote_one;
							$juryTwoVoteTwo = $juryTwoVotingInfo[0]->vote_two;
							$juryTwoVoteThree = $juryTwoVotingInfo[0]->vote_three;
							$juryTwoComments = $juryTwoVotingInfo[0]->comments;
							$juryTwoFeedback = $juryTwoVotingInfo[0]->feedback;
							$juryTwoReason = $juryTwoVotingInfo[0]->reason;
						}
	
						$sheet->setCellValue('A'.$excel_row, $nos);
						$sheet->setCellValue('B'.$excel_row, $e->application_number);
						$sheet->setCellValue('C'.$excel_row, $jury[0]->jury_two_code);
						$sheet->setCellValue('D'.$excel_row, $juryTwoVoteOne);
						$sheet->setCellValue('E'.$excel_row, $juryTwoVoteTwo);
						$sheet->setCellValue('F'.$excel_row, $juryTwoVoteThree);
						$sheet->setCellValue('G'.$excel_row, $juryTwoComments);
						$sheet->setCellValue('H'.$excel_row, $juryTwoFeedback);
						$sheet->setCellValue('I'.$excel_row, $juryTwoReason);
						$sheet->setCellValue('J'.$excel_row, $jury[0]->region);
						$excel_row++;
						$nos++;	
					}
	
					if( $jury[0]->jury_three_code !== "" ){
						$juryThreeVoteOne = $juryThreeVoteTwo = $juryThreeVoteThree = $juryThreeComments = $juryThreeFeedback = $juryThreeReason = "";
						$juryThreeVotingInfo = $this->Mdl_excel->retrieve("jury_application_votes",array(
							"applications_id" => $e->applications_id,
							"jury_code" => $jury[0]->jury_three_code
						));
						if( $juryThreeVotingInfo !== "NA" ){
							$juryThreeVoteOne = $juryThreeVotingInfo[0]->vote_one;
							$juryThreeVoteTwo = $juryThreeVotingInfo[0]->vote_two;
							$juryThreeVoteThree = $juryThreeVotingInfo[0]->vote_three;
							$juryThreeComments = $juryThreeVotingInfo[0]->comments;
							$juryThreeFeedback = $juryThreeVotingInfo[0]->feedback;
							$juryThreeReason = $juryThreeVotingInfo[0]->reason;
						}
	
						$sheet->setCellValue('A'.$excel_row, $nos);
						$sheet->setCellValue('B'.$excel_row, $e->application_number);
						$sheet->setCellValue('C'.$excel_row, $jury[0]->jury_three_code);
						$sheet->setCellValue('D'.$excel_row, $juryThreeVoteOne);
						$sheet->setCellValue('E'.$excel_row, $juryThreeVoteTwo);
						$sheet->setCellValue('F'.$excel_row, $juryThreeVoteThree);
						$sheet->setCellValue('G'.$excel_row, $juryThreeComments);
						$sheet->setCellValue('H'.$excel_row, $juryThreeFeedback);
						$sheet->setCellValue('I'.$excel_row, $juryThreeReason);
						$sheet->setCellValue('J'.$excel_row, $jury[0]->region);
	
						$excel_row++;
						$nos++;	
					}

					if( $jury[0]->jury_four_code !== "" ){
						$juryFourVoteOne = $juryFourVoteTwo = $juryFourVoteThree = $juryFourComments = $juryFourFeedback = $juryFourReason = "";
						$juryFourVotingInfo = $this->Mdl_excel->retrieve("jury_application_votes",array(
							"applications_id" => $e->applications_id,
							"jury_code" => $jury[0]->jury_four_code
						));

						if( $juryFourVotingInfo !== "NA" ){
							$juryFourVoteOne = $juryFourVotingInfo[0]->vote_one;
							$juryFourVoteTwo = $juryFourVotingInfo[0]->vote_two;
							$juryFourVoteThree = $juryFourVotingInfo[0]->vote_three;
							$juryFourComments = $juryFourVotingInfo[0]->comments;
							$juryFourFeedback = $juryFourVotingInfo[0]->feedback;
							$juryFourReason = $juryFourVotingInfo[0]->reason;
						}
	
						$sheet->setCellValue('A'.$excel_row, $nos);
						$sheet->setCellValue('B'.$excel_row, $e->application_number);
						$sheet->setCellValue('C'.$excel_row, $jury[0]->jury_four_code);
						$sheet->setCellValue('D'.$excel_row, $juryFourVoteOne);
						$sheet->setCellValue('E'.$excel_row, $juryFourVoteTwo);
						$sheet->setCellValue('F'.$excel_row, $juryFourVoteThree);
						$sheet->setCellValue('G'.$excel_row, $juryFourComments);
						$sheet->setCellValue('H'.$excel_row, $juryFourFeedback);
						$sheet->setCellValue('I'.$excel_row, $juryFourReason);
						$sheet->setCellValue('J'.$excel_row, $jury[0]->region);
	
						$excel_row++;
						$nos++;	
					}

					if( $jury[0]->jury_five_code !== "" ){
						$juryFiveVoteOne = $juryFiveVoteTwo = $juryFiveVoteThree = $juryFiveComments = $juryFiveFeedback = $juryFiveReason = "";
						$juryFiveVotingInfo = $this->Mdl_excel->retrieve("jury_application_votes",array(
							"applications_id" => $e->applications_id,
							"jury_code" => $jury[0]->jury_five_code
						));

						if( $juryFiveVotingInfo !== "NA" ){
							$juryFiveVoteOne = $juryFiveVotingInfo[0]->vote_one;
							$juryFiveVoteTwo = $juryFiveVotingInfo[0]->vote_two;
							$juryFiveVoteThree = $juryFiveVotingInfo[0]->vote_three;
							$juryFiveComments = $juryFiveVotingInfo[0]->comments;
							$juryFiveFeedback = $juryFiveVotingInfo[0]->feedback;
							$juryFiveReason = $juryFiveVotingInfo[0]->reason;
						}
	
						$sheet->setCellValue('A'.$excel_row, $nos);
						$sheet->setCellValue('B'.$excel_row, $e->application_number);
						$sheet->setCellValue('C'.$excel_row, $jury[0]->jury_five_code);
						$sheet->setCellValue('D'.$excel_row, $juryFiveVoteOne);
						$sheet->setCellValue('E'.$excel_row, $juryFiveVoteTwo);
						$sheet->setCellValue('F'.$excel_row, $juryFiveVoteThree);
						$sheet->setCellValue('G'.$excel_row, $juryFiveComments);
						$sheet->setCellValue('H'.$excel_row, $juryFiveFeedback);
						$sheet->setCellValue('I'.$excel_row, $juryFiveReason);
						$sheet->setCellValue('J'.$excel_row, $jury[0]->region);
						$excel_row++;
						$nos++;	
					}

					if( $jury[0]->jury_six_code !== "" ){
						$jurySixVoteOne = $jurySixVoteTwo = $jurySixVoteThree = $jurySixComments = $jurySixFeedback = $jurySixReason = "";
						$jurySixVotingInfo = $this->Mdl_excel->retrieve("jury_application_votes",array(
							"applications_id" => $e->applications_id,
							"jury_code" => $jury[0]->jury_six_code
						));

						if( $jurySixVotingInfo !== "NA" ){
							$jurySixVoteOne = $jurySixVotingInfo[0]->vote_one;
							$jurySixVoteTwo = $jurySixVotingInfo[0]->vote_two;
							$jurySixVoteThree = $jurySixVotingInfo[0]->vote_three;
							$jurySixComments = $jurySixVotingInfo[0]->comments;
							$jurySixFeedback = $jurySixVotingInfo[0]->feedback;
							$jurySixReason = $jurySixVotingInfo[0]->reason;
						}
	
						$sheet->setCellValue('A'.$excel_row, $nos);
						$sheet->setCellValue('B'.$excel_row, $e->application_number);
						$sheet->setCellValue('C'.$excel_row, $jury[0]->jury_six_code);
						$sheet->setCellValue('D'.$excel_row, $jurySixVoteOne);
						$sheet->setCellValue('E'.$excel_row, $jurySixVoteTwo);
						$sheet->setCellValue('F'.$excel_row, $jurySixVoteThree);
						$sheet->setCellValue('G'.$excel_row, $jurySixComments);
						$sheet->setCellValue('H'.$excel_row, $jurySixFeedback);
						$sheet->setCellValue('I'.$excel_row, $jurySixReason);
						$sheet->setCellValue('J'.$excel_row, $jury[0]->region);
						$excel_row++;
						$nos++;	
					}

				}
			}
		}
	
		$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Jury Voting Master.xlsx"'); 
		header('Cache-Control: max-age=0');
	
		// download file 
		$writer->save('php://output'); 
	}

	/**
	 * 	Jury Round One Master
	 */
	function juryRoundOneVotes(){

		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();
	
		// Set document properties
		$spreadsheet->getProperties()->setCreator('Global Nursing Award 2022')
			->setLastModifiedBy('Global Nursing Award 2022')
			->setTitle('Jury Round 1 Voting Master')
			->setSubject('')
			->setDescription('');
	
		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:I1')->applyFromArray($styleArray);
	
		// auto fit column to content
		foreach(range('A', 'H') as $columnID) {
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(false);
		}
	
		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Aplication No');
		$sheet->setCellValue('C1', 'Jury');
		$sheet->setCellValue('D1', 'initiative');
		$sheet->setCellValue('E1', 'impact');
		$sheet->setCellValue('F1', 'Feedback');
		$sheet->setCellValue('G1', 'Reason');
		// $sheet->setCellValue('I1', 'Reason');
		// $sheet->setCellValue('I1', 'Region');
	
		$get_applications = "SELECT applications_id, application_number FROM application_personal_details WHERE ey_assessment='approved' AND status='submitted' ORDER BY application_number";
		$entries = $this->Mdl_excel->customQuery($get_applications);
		$excel_row = 2;
		$nos = 1;
	
		if( $entries !== "NA" ){
			foreach( $entries as $e ){
				$applicationId = $e->applications_id;
				//$votingMasterQuery = "SELECT application_no, jury_code, vote_one, vote_two, vote_three, feedback, reason FROM jury_application_votes WHERE applications_id='$applicationId' AND jury_code IN ('AST1','AST2','AST3','AST4','GNA23-SJ-1','GNA23-SJ-2','GNA23-SJ-4','GNA23-SJ-5','GNA23-SJ-6','GNA23-SJ-7') ORDER BY application_no";
				$votingMasterQuery = "SELECT application_no, jury_code, vote_one, vote_two, vote_three, feedback, reason FROM jury_application_votes WHERE applications_id='$applicationId' AND jury_code IN ('AGGNA-GJ-1','AGGNA-GJ-2','AGGNA-GJ-3','AGGNA-GJ-4','AGGNA-GJ-5','AGGNA-GJ-6') ORDER BY application_no";
				$votingMaster = $this->Mdl_excel->customQuery($votingMasterQuery);

				if( $votingMaster !== "NA" ){
					foreach( $votingMaster as $vm ){

						$sheet->setCellValue('A'.$excel_row, $nos);
						$sheet->setCellValue('B'.$excel_row, $vm->application_no);
						$sheet->setCellValue('C'.$excel_row, $vm->jury_code);
						$sheet->setCellValue('D'.$excel_row, $vm->vote_one);
						$sheet->setCellValue('E'.$excel_row, $vm->vote_two);
						$sheet->setCellValue('F'.$excel_row, $vm->feedback);
						$sheet->setCellValue('G'.$excel_row, $vm->reason);
						// $sheet->setCellValue('H'.$excel_row, $vm->reason);
						// $sheet->setCellValue('I'.$excel_row, $vm->region);
						$excel_row++;
						$nos++;	
					}
				}
			}
		}
	
		$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Jury Round 1 Voting Master.xlsx"'); 
		header('Cache-Control: max-age=0');
	
		// download file 
		$writer->save('php://output'); 
	}

	/**
	 * 	Jury Round Two Master
	 */
	function juryRoundTwoVotes(){

		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();
	
		// Set document properties
		$spreadsheet->getProperties()->setCreator('Global Nursing Award 2022')
			->setLastModifiedBy('Global Nursing Award 2022')
			->setTitle('Jury Round 2 Voting Master')
			->setSubject('')
			->setDescription('');
	
		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:I1')->applyFromArray($styleArray);
	
		// auto fit column to content
		foreach(range('A', 'H') as $columnID) {
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(false);
		}
	
		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Aplication No');
		$sheet->setCellValue('C1', 'Jury');
		$sheet->setCellValue('D1', 'initiative');
		$sheet->setCellValue('E1', 'impact');
		$sheet->setCellValue('F1', 'Feedback');
		$sheet->setCellValue('G1', 'Reason');
		// $sheet->setCellValue('H1', 'Reason');
		// $sheet->setCellValue('I1', 'Region');
	
		$get_applications = "SELECT applications_id, application_number,region FROM application_personal_details WHERE ey_assessment='approved' AND status='submitted' ORDER BY application_number";
		$entries = $this->Mdl_excel->customQuery($get_applications);
		$excel_row = 2;
		$nos = 1;
	
		if( $entries !== "NA" ){
			foreach( $entries as $e ){
				$applicationId = $e->applications_id;
				//$votingMasterQuery = "SELECT application_no, jury_code, vote_one, vote_two, vote_three, feedback, reason FROM jury_application_votes WHERE applications_id='$applicationId' AND jury_code IN ('AST1','AST2','AST3','AST4','GNA23-SJ-1','GNA23-SJ-2','GNA23-SJ-4','GNA23-SJ-5','GNA23-SJ-6','GNA23-SJ-7') ORDER BY application_no";
				$votingMasterQuery = "SELECT application_no, jury_code, vote_one, vote_two, vote_three, feedback, reason FROM jury_application_votes WHERE applications_id='$applicationId' AND jury_code IN ('AGGNA-GJ-1','AGGNA-GJ-2','AGGNA-GJ-3','AGGNA-GJ-4','AGGNA-GJ-5','AGGNA-GJ-6') ORDER BY application_no";
				
				$votingMaster = $this->Mdl_excel->customQuery($votingMasterQuery);

				if( $votingMaster !== "NA" ){
					foreach( $votingMaster as $vm ){

						$sheet->setCellValue('A'.$excel_row, $nos);
						$sheet->setCellValue('B'.$excel_row, $vm->application_no);
						$sheet->setCellValue('C'.$excel_row, $vm->jury_code);
						$sheet->setCellValue('D'.$excel_row, $vm->vote_one);
						$sheet->setCellValue('E'.$excel_row, $vm->vote_two);
						$sheet->setCellValue('F'.$excel_row, $vm->feedback);
						$sheet->setCellValue('G'.$excel_row, $vm->reason);
						// $sheet->setCellValue('H'.$excel_row, $vm->reason);
						// $sheet->setCellValue('I'.$excel_row, $vm->region);
						$excel_row++;
						$nos++;	
					}
				}
			}
		}
	
		$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Jury Round 2 Voting Master.xlsx"'); 
		header('Cache-Control: max-age=0');
	
		// download file 
		$writer->save('php://output'); 
	}

	/**
	 * 	Jury voting status
	 */
	function juryEvaluation(){
		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
		$spreadsheet->getProperties()->setCreator('Global Nursing Award 2022')
		->setLastModifiedBy('Global Nursing Award 2022')
		->setTitle('Jury Evaluation')
		->setSubject('')
		->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:F1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A', 'F') as $columnID) {
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}

		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Jury Code');
		$sheet->setCellValue('C1', 'Jury Name');
		$sheet->setCellValue('D1', 'Entries allocated');
		$sheet->setCellValue('E1', 'Entries evaluated');
		$sheet->setCellValue('F1', 'Entries pending');

		$jury = $this->Mdl_excel->retrieveByCol("jury_id, code, name", "jury_master", array("status"=>"active"));
		$excel_row = 2;
		$nos = 1;

		if( $jury !== "NA" ){
			foreach( $jury as $j ){
				$juryId = $j->jury_id;
				$juryCode = $j->code;

				$get_applications = "SELECT DISTINCT applications_id FROM jury_application_mapping WHERE jury_one_code='$juryCode' OR jury_two_code='$juryCode' OR jury_three_code='$juryCode' OR jury_four_code='$juryCode' OR jury_five_code='$juryCode' OR jury_six_code='$juryCode' "; 
				$applications = $this->Mdl_excel->customQuery($get_applications);
				$allocated = $applications !== "NA" ? sizeof($applications) : 0;

				$get_votes = "SELECT votes_id FROM jury_application_votes WHERE jury_id='$juryId' AND is_voted='Y' AND applications_id IN ( $get_applications )"; 
				$vortes = $this->Mdl_excel->customQuery($get_votes);

				$evaluated = $vortes !== "NA" ? sizeof($vortes) : 0;
				$pending = $allocated - $evaluated;

				$sheet->setCellValue('A'.$excel_row, $nos);
				$sheet->setCellValue('B'.$excel_row, $juryCode);
				$sheet->setCellValue('C'.$excel_row, $j->name);
				$sheet->setCellValue('D'.$excel_row, $allocated);
				$sheet->setCellValue('E'.$excel_row, $evaluated);
				$sheet->setCellValue('F'.$excel_row, $pending);
				$excel_row++;
				$nos++;	
			}
		}

		$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Jury Evaluation.xlsx"'); 
		header('Cache-Control: max-age=0');

		// download file 
		$writer->save('php://output'); 
	}

	/**
	 * 	Country Master
	 */
	function country(){

		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
    	$spreadsheet->getProperties()->setCreator('Global Nursing Award 2023')
      ->setLastModifiedBy('Global Nursing Award 2023')
      ->setTitle('Country Master')
      ->setSubject('')
      ->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:C1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A', 'C') as $columnID) {
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}

		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Country Name');
		$sheet->setCellValue('C1', 'Code');

		$records = $this->Mdl_excel->retrieve("master_country",array("1"=>"1"));
		$excel_row = 2;
		$nos = 1;

		if( $records !== "NA" ){
			foreach($records as $r){
				$sheet->setCellValue('A'.$excel_row, $nos);
				$sheet->setCellValue('B'.$excel_row, $r->country_name);
				$sheet->setCellValue('C'.$excel_row, $r->code);

				$excel_row++;
				$nos++;
			}
		}

		$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Country Master.xlsx"'); 
		header('Cache-Control: max-age=0');

		// download file 
		$writer->save('php://output'); 
	}

	function voting_master(){

		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
    	$spreadsheet->getProperties()->setCreator('Global Nursing Award 2023')
      ->setLastModifiedBy('Global Nursing Award 2023')
      ->setTitle('Voting Master')
      ->setSubject('')
      ->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:K1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A', 'K') as $columnID) {
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}

		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Date');
		$sheet->setCellValue('C1', 'User Id');
		$sheet->setCellValue('D1', 'Email of the voter');
		$sheet->setCellValue('E1', 'Nurse they have voted for');
		$sheet->setCellValue('F1', 'Nurses Application ID');
		$sheet->setCellValue('G1', 'Voted Person Uid');
		$sheet->setCellValue('H1', 'Country of the voter');
		$sheet->setCellValue('I1', 'Ip Address of the vote');
		$sheet->setCellValue('J1', 'Status');
		$sheet->setCellValue('K1', 'Registered For Event');

		$records = $this->Mdl_excel->retrieve("voting_master",array("1"=>"1"));
		$excel_row = 2;
		$nos = 1;

		if( $records !== "NA" ){
			foreach($records as $r){
				$data = $this->Mdl_excel->retrieve("application_personal_details",array("uid"=>$r->candidate_uid));
				$sheet->setCellValue('A'.$excel_row, $nos);
				$sheet->setCellValue('B'.$excel_row, $r->created_at);
				$sheet->setCellValue('C'.$excel_row, $r->uid);
				$sheet->setCellValue('D'.$excel_row, $r->email);
				$sheet->setCellValue('E'.$excel_row, $data[0]->first_name.' '.$data[0]->middle_name.' '.$data[0]->last_name);
				$sheet->setCellValue('F'.$excel_row, $data[0]->application_number );
				$sheet->setCellValue('G'.$excel_row, $r->candidate_uid );
				$sheet->setCellValue('H'.$excel_row, $r->country);
				$sheet->setCellValue('I'.$excel_row, $r->ip_address);
				$sheet->setCellValue('J'.$excel_row, $r->status);
				$sheet->setCellValue('K'.$excel_row, $r->is_checked);

				$excel_row++;
				$nos++;
			}
		}

		$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Voting Master.xlsx"'); 
		header('Cache-Control: max-age=0');

		// download file 
		$writer->save('php://output'); 
	}


	function applicationStatus(){
		$content = $this->input->post();
		//echo "<pre>";print_r($content);exit;
		$app_status = $content['app_status'];
		if(empty($app_status)){
			return false;
		}
		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
		$spreadsheet->getProperties()->setCreator('Global Nursing Award 2024')
			->setLastModifiedBy('Global Nursing Award 2024')
			->setTitle('Applications Master')
			->setSubject('')
			->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:CG1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A','AS') as $columnID){
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}

		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Date');
		$sheet->setCellValue('C1', 'Application Status');
		$sheet->setCellValue('D1', 'EY Assessment');
		$sheet->setCellValue('E1', 'Application Number');
		$sheet->setCellValue('F1', 'Application Code');
		$sheet->setCellValue('G1', 'Language');
		$sheet->setCellValue('H1', 'First name');
		$sheet->setCellValue('I1', 'Middle name');
		$sheet->setCellValue('J1', 'Last name');
		$sheet->setCellValue('K1', 'Email');
		$sheet->setCellValue('L1', 'Date of Birth');
		$sheet->setCellValue('M1', 'Country');
		$sheet->setCellValue('N1', 'Region');
		$sheet->setCellValue('O1', 'Contact No');
		$sheet->setCellValue('P1', 'Gender');
		$sheet->setCellValue('Q1', 'Address');
		$sheet->setCellValue('R1', 'Register as');
		$sheet->setCellValue('S1', 'Institute / hospital name');
		$sheet->setCellValue('T1', 'Contact Email ID');
		$sheet->setCellValue('U1', 'Contact Number');
		$sheet->setCellValue('V1', 'Website link');
		$sheet->setCellValue('W1', 'Total years of work experience as a Nurse');
		$sheet->setCellValue('X1', 'Years of experience in the current institute/hospital');

		$sheet->setCellValue('Y1', 'Educational Qualification (Highest degree)');
		$sheet->setCellValue('Z1', 'Educational Qualification Document');
		$sheet->setCellValue('AA1', 'Medical/Nurse council registration name');
		$sheet->setCellValue('AB1', 'Medical/Nurse council registration number');
		$sheet->setCellValue('AC1', 'Medical/Nurse council registration document');
		$sheet->setCellValue('AD1', 'Passport front copy');
		$sheet->setCellValue('AE1', 'Passport back copy');
		$sheet->setCellValue('AF1', 'Passport size Photograph');
		$sheet->setCellValue('AG1', 'Valid national proof of identity of the country/region you are applying from (Govt. ID)');
		$sheet->setCellValue('AH1', 'National proof of identity document');
		$sheet->setCellValue('AI1', 'Proof of employment');
		$sheet->setCellValue('AJ1', 'Proof of employment document');
		$sheet->setCellValue('AK1', 'Self declaration document');		

		$sheet->setCellValue('AL1', 'Selected Segment');
		$sheet->setCellValue('AM1', 'Primary Segment');
		$sheet->setCellValue('AN1', 'Secondary Segment');
		$sheet->setCellValue('AO1', 'Patient Experience');
		$sheet->setCellValue('AP1', 'Patient care in your daily work environment');
		$sheet->setCellValue('AQ1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('AR1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('AS1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('AT1', 'Leadership Experience');
		$sheet->setCellValue('AU1', 'Patient care in your daily work environment');
		$sheet->setCellValue('AV1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('AW1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('AX1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('AY1', 'Education Experience');
		$sheet->setCellValue('AZ1', 'Patient care in your daily work environment');
		$sheet->setCellValue('BA1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('BB1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('BC1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('BD1', 'Social Experience');
		$sheet->setCellValue('BE1', 'Patient care in your daily work environment');
		$sheet->setCellValue('BF1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('BG1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('BH1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('BI1', 'Research Experience');
		$sheet->setCellValue('BJ1', 'Patient care in your daily work environment');
		$sheet->setCellValue('BK1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('BL1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('BM1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');
		
		$sheet->setCellValue('BN1', 'First Referrer full name');
		$sheet->setCellValue('BO1', 'Referrer email ID');
		$sheet->setCellValue('BP1', 'Referrer country');
		$sheet->setCellValue('BQ1', 'Referrer contact number');
		$sheet->setCellValue('BR1', 'Relationship with the reference');
		$sheet->setCellValue('BS1', 'Second Referrer full name');		
		$sheet->setCellValue('BT1', 'Referrer email ID');
		$sheet->setCellValue('BU1', 'Referrer country');
		$sheet->setCellValue('BV1', 'Referrer contact number');
		$sheet->setCellValue('BW1', 'Relationship with the reference');

		$sheet->setCellValue('BX1', 'Collaterals doc 1');
		$sheet->setCellValue('BY1', 'Collaterals doc 2');
		$sheet->setCellValue('BZ1', 'Collaterals doc 3');
		$sheet->setCellValue('CA1', 'Awards/ certifications  doc 1 name');
		$sheet->setCellValue('CB1', 'Awards/ certifications  doc 1 ');
		$sheet->setCellValue('CC1', 'Awards/ certifications  doc 2 name');
		$sheet->setCellValue('CD1', 'Awards/ certifications  doc 2');
		$sheet->setCellValue('CE1', 'Awards/ certifications  doc 3 name');
		$sheet->setCellValue('CF1', 'Awards/ certifications  doc 3');

		$sheet->setCellValue('CG1', 'Reason');
		
		// $sheet->setCellValue('CJ1', 'Date and Time');


		// $sheet->setCellValue('AI1', 'Selected segments');
		// $sheet->setCellValue('AJ1', 'We believe nursing is about leading from the front. So, why would you consider yourself as a leader and what difference has that made?');
		// $sheet->setCellValue('AK1', 'Help us understand the challenges faced and how did you overcome the same');
		// $sheet->setCellValue('AL1', 'How do patients and peers respond to your leadership?');
		// $sheet->setCellValue('AM1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AN1', 'Describe your contributions to nursing research, policy, and/or practice at the local regional, state, and /or national level');
		// $sheet->setCellValue('AO1', 'Describe the challenges faced  and how did you overcome the same');
		// $sheet->setCellValue('AP1', 'Describe the impact of the initiative on the patients, employer, peers, etc?');
		// $sheet->setCellValue('AQ1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AR1', 'Describe the initiatives undertaken to facilitate positive changes in the work environment and improve the quality of patient care');
		// $sheet->setCellValue('AS1', 'Describe the challenges faced  and how did you overcome the same');
		// $sheet->setCellValue('AT1', 'Describe the impact of the initiative on the patients, employer, peers, etc?');
		// $sheet->setCellValue('AU1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AV1', 'Describe the your contribution for the betterment of the community/society');
		// $sheet->setCellValue('AW1', 'Describe the challenges faced  and how did you overcome the same');
		// $sheet->setCellValue('AX1', 'Describe the impact of the initiative on the community and what was the change they witnessed?');
		// $sheet->setCellValue('AY1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AZ1', 'Awards and certifications');
		// $sheet->setCellValue('BA1', 'Awards and certifications');
 
		//$_APPLICATIONS_QUERY = "SELECT * FROM application_personal_details limit 12000";
		$_APPLICATIONS_QUERY = "SELECT a.applications_id, a.uid, a.`code`,a.application_number,a.first_name,
								a.middle_name,a.last_name,a.dob,a.country,a.region,a.phone_code,a.contact,a.address,a.gender,a.qualified_as,
								a.institute,
								a.organisation_phonecode,a.organisation_contact,a.organisation_email,a.organisation_website,a.total_exp,
								a.current_exp,a.ref_name_one,a.ref_designation_one,a.ref_email_one,a.ref_country_one,a.ref_phone_code_one,ref_contact_one,
								a.ref_rel_one,a.ref_name_two,a.ref_designation_two,a.ref_email_two,a.ref_country_two,
								a.ref_phone_code_two,a.ref_contact_two,a.ref_rel_two,a.ref_rel_other_two,a.`status`,a.step,
								a.ey_assessment,a.is_recommended,a.reason,a.`language`,a.created_at
								FROM application_personal_details as a where a.`status` = '$app_status'";//limit 10000 offset 10000
		$records = $this->Mdl_excel->customQuery($_APPLICATIONS_QUERY);
		//echo count($records);exit;
		$excel_row = 2;
		$nos = 1;

		if( $records !== "NA" ){
			foreach($records as $r){

				$date = date("Y-m-d H:i:s", strtotime($r->created_at));
				$created_at = date("Y-m-d H:i:s", strtotime($r->created_at));
				$dob = date("Y-m-d", strtotime($r->dob));
				// $_APPLICATIONS_COUNTRY_QUERY = "select c.country_id,c.country_name,c.`code` from master_country as c where country_id = '".$r->country."'";
				// $country_data = $this->Mdl_excel->customQuery($_APPLICATIONS_COUNTRY_QUERY);
				// $country = $country_data !== "NA" ? $country_data[0]->country_name : "NA";
				// $refOneCountry = $country_data !== "NA" ? $country_data[0]->country_name : "NA";
				// $refTwoCountry = $country_data !== "NA" ? $country_data[0]->country_name : "NA";
				$country = Modules::run('api/application/personal/country',$r->country);
				$refOneCountry = Modules::run('api/application/personal/country',$r->ref_country_one);
				$refTwoCountry = Modules::run('api/application/personal/country',$r->ref_country_two);
				$casestudies = Modules::run('api/application/personal/caseStudies',$r->uid);
				if($casestudies != "NA"){
					$ledership_array = explode(',',$casestudies[0]->selected_segments);
					$leadership_segments = $casestudies[0]->selected_segments;
					$leadership_primary = $casestudies[0]->primary_segment;
					$leadership_secondary = $casestudies[0]->secondary_segment;
					$leadership_exp = $casestudies[0]->leadership_exp;
					if(in_array('leadership', $ledership_array)){
						
						if(!empty($casestudies[0]->leadership_one) && $casestudies[0]->leadership_one != ""){
							$leadership_one = json_decode($casestudies[0]->leadership_one);
							$leadership_one = $leadership_one->textEn;
							$leadership_two = json_decode($casestudies[0]->leadership_two);
							$leadership_two = $leadership_two->textEn;
							$leadership_three = json_decode($casestudies[0]->leadership_three);
							$leadership_three = $leadership_three->textEn;
							$leadership_four = json_decode($casestudies[0]->leadership_four);
							$leadership_four = $leadership_four->textEn;
							
						} else {
							$leadership_one = '';
							$leadership_two = '';
							$leadership_three = '';
							$leadership_four = '';
						}
					} else {
						$leadership_segments = '';
						$leadership_primary = '';
						$leadership_secondary = '';
						$leadership_exp = '';
						$leadership_one = '';
						$leadership_two = '';
						$leadership_three = '';
						$leadership_four = '';
					}
					$patient_array = explode(',',$casestudies[0]->selected_segments);
					//print_r($patient_array);
					//exit;
					if(in_array('patient', $patient_array)){
						$patient_segments = $casestudies[0]->selected_segments;
						$patient_primary = $casestudies[0]->primary_segment;
						$patient_secondary = $casestudies[0]->secondary_segment;
						$patient_exp = $casestudies[0]->patient_exp;
						if(!empty($casestudies[0]->patient_one) && $casestudies[0]->patient_one != ""){
							$patient_one = json_decode($casestudies[0]->patient_one);
							$patient_one = $patient_one->textEn;
							$patient_two = json_decode($casestudies[0]->patient_two);
							$patient_two = $patient_two->textEn;
							$patient_three = json_decode($casestudies[0]->patient_three);
							$patient_three = $patient_three->textEn;
							$patient_four = json_decode($casestudies[0]->patient_four);
							$patient_four = $patient_four->textEn;
							
						} else {
							$patient_one = '';
							$patient_two = '';
							$patient_three = '';
							$patient_four = '';
						}
					} else {
						$patient_segments = '';
						$patient_primary = '';
						$patient_secondary = '';
						$patient_exp = '';
						$patient_one = '';
						$patient_two = '';
						$patient_three = '';
						$patient_four = '';
					}

					$education_array = explode(',',$casestudies[0]->selected_segments);
					if(in_array('education', $education_array)){
						$education_segments = $casestudies[0]->selected_segments;
						$education_primary = $casestudies[0]->primary_segment;
						$education_secondary = $casestudies[0]->secondary_segment;
						$education_exp = $casestudies[0]->education_exp;
						if(!empty($casestudies[0]->education_one) && $casestudies[0]->education_one != ""){
							$education_one_t = json_decode($casestudies[0]->education_one);
							$education_one = $education_one_t->textEn;
							$education_two = json_decode($casestudies[0]->education_two);
							$education_two = $education_two->textEn;
							$education_three = json_decode($casestudies[0]->education_three);
							$education_three = $education_three->textEn;
							$education_four = json_decode($casestudies[0]->education_four);
							$education_four = $education_four->textEn;
						} else {
							$education_one = '';
							$education_two = '';
							$education_three = '';
							$education_four ='';
						}
					} else {
						$education_segments = '';
						$education_primary = '';
						$education_secondary = '';
						$education_exp = '';
						$education_one = '';
						$education_two = '';
						$education_three = '';
						$education_four ='';
					}
					
					$social_array = explode(',',$casestudies[0]->selected_segments);
					if(in_array('social', $social_array)){
						$social_segments = $casestudies[0]->selected_segments;
						$social_primary = $casestudies[0]->primary_segment;
						$social_secondary = $casestudies[0]->secondary_segment;
						$social_exp = $casestudies[0]->social_exp;
						if(!empty($casestudies[0]->social_one) && $casestudies[0]->social_one != ""){
							$social_one = json_decode($casestudies[0]->social_one);
							$social_one = $social_one->textEn;
							$social_two = json_decode($casestudies[0]->social_two);
							$social_two = $social_two->textEn;
							$social_three = json_decode($casestudies[0]->social_three);
							$social_three = $social_three->textEn;
							$social_four = json_decode($casestudies[0]->social_four);
							$social_four = $social_four->textEn;
	
						} else {
							$social_one = '';
							$social_two = '';
							$social_three = '';
							$social_four = '';
						}
					} else {
						$social_segments = '';
						$social_primary = '';
						$social_secondary = '';
						$social_exp = '';
						$social_one = '';
						$social_two = '';
						$social_three = '';
						$social_four = '';
					}
					
					$research_array = explode(',',$casestudies[0]->selected_segments);
					if(in_array('research', $research_array)){
						$research_segments = $casestudies[0]->selected_segments;
						$research_primary = $casestudies[0]->primary_segment;
						$research_secondary = $casestudies[0]->secondary_segment;
						$research_exp = $casestudies[0]->research_exp;
						if(!empty($casestudies[0]->research_one) && $casestudies[0]->research_one != ""){
							$research_one = json_decode($casestudies[0]->research_one);
							$research_one = $research_one->textEn;
							$research_two = json_decode($casestudies[0]->research_two);
							$research_two = $research_two->textEn;
							$research_three = json_decode($casestudies[0]->research_three);
							$research_three = $research_three->textEn;
							$research_four = json_decode($casestudies[0]->research_four);
							$research_four = $research_four->textEn;
	
						} else {
							$research_one = '';
							$research_two = '';
							$research_three = '';
							$research_four = '';
						}
					} else {
						$research_segments = '';
						$research_primary = '';
						$research_secondary = '';
						$research_exp = '';
						$research_one = '';
						$research_two = '';
						$research_three = '';
						$research_four = '';
					}
					
				} else {
					$leadership_segments = '';;
					$leadership_primary = '';
					$leadership_secondary = '';
					$leadership_exp = '';
					$leadership_one = '';
					$leadership_two = '';
					$leadership_three = '';
					$leadership_four = '';

					$patient_segments = '';
					$patient_primary = '';
					$patient_secondary = '';
					$patient_exp = '';					
					$patient_one = '';
					$patient_two = '';
					$patient_three = '';
					$patient_four = '';

					$education_segments = '';;
					$education_primary = '';
					$education_secondary = '';
					$education_exp = '';
					$education_one = '';
					$education_two = '';
					$education_three = '';
					$education_four ='';

					$social_segments = '';
					$social_primary = '';
					$social_secondary = '';
					$social_exp = '';
					$social_one = '';
					$social_two = '';
					$social_three = '';
					$social_four = '';

					$research_segments = '';;
					$research_primary = '';
					$research_secondary = '';
					$research_exp = '';
					$research_one = '';
					$research_two = '';
					$research_three = '';
					$research_four = '';
				}

				$nurse = $this->Mdl_excel->retrieveByCol("email", "registration", array("uid"=>$r->uid));
				$candEmail = $nurse !== "NA" ? $nurse[0]->email : "";

				$_APPLICATIONS_DOCUMENTS_QUERY = "select ad.document_id,ad.uid,ad.`code`,ad.degree_name,ad.degree_file_name,
								ad.degree_file_path,ad.passport_front_file_name,ad.passport_front_file_path,ad.passport_back_file_name,
								ad.passport_back_file_path,ad.nursepic_name,ad.nursepic_path,ad.council_name,ad.council_registration,
								ad.medical_file_name,ad.medical_file_path,ad.proof_name,ad.proof_file_name,ad.proof_file_path,ad.proof_type,
								ad.employment_name,ad.employment_file_name,ad.employment_file_path,ad.declaration_name,ad.declaration_file_name,
								ad.declaration_file_path,ad.award_one,ad.award_one_name,ad.award_one_path,ad.award_two,ad.award_two_name,
								ad.award_two_path,ad.award_three,ad.award_three_name,ad.award_three_path,ad.sup_file_one_name,ad.sup_file_one_path,
								ad.sup_file_two_name,ad.sup_file_two_path,ad.sup_file_three_name,ad.sup_file_three_path,ad.created_at
								from application_documents as ad where ad.uid= '".$r->uid."' and ad.`code` = '".$r->code."'";
				$documents = $this->Mdl_excel->customQuery($_APPLICATIONS_DOCUMENTS_QUERY);
				// $documents = $this->Mdl_excel->retrieve(
				// 	"application_documents", 
				// 	array(
				// 		"uid" => $r->uid,
				// 		"code" => $r->code
				// 	)
				// );

				$degreeName = $documents !== "NA" ? $documents[0]->degree_name : "";
				$degreeDocumentName = $documents !== "NA" ? $documents[0]->degree_file_name : "";
				$degreeDocument =  $documents !== "NA" && $documents[0]->degree_file_path !== "" ? base_url().$documents[0]->degree_file_path : "";

				$councilName = $documents !== "NA" ? $documents[0]->council_name : "";
				$councilRegistration = $documents !== "NA" ? $documents[0]->council_registration : "";
				$medicalDocumentName = $documents !== "NA" ? $documents[0]->medical_file_name : "";
				$medicalDocument = $documents !== "NA" && $documents[0]->medical_file_path !== "" ? base_url().$documents[0]->medical_file_path : "";

				$passportFrontDocumentName = $documents !== "NA" ? $documents[0]->passport_front_file_name : "";
				$passportFrontDocument = $documents !== "NA" && $documents[0]->passport_front_file_path !== "" ? base_url().$documents[0]->passport_front_file_path : "";

				$passportBackDocumentName = $documents !== "NA" ? $documents[0]->passport_back_file_name : "";
				$passportBackDocument = $documents !== "NA" && $documents[0]->passport_back_file_path !== "" ? base_url().$documents[0]->passport_back_file_path : "";
				
				$nursePicName = $documents !== "NA" ? $documents[0]->nursepic_name : "";
				$nursePic = $documents !== "NA" && $documents[0]->nursepic_path !== "" ? base_url().$documents[0]->nursepic_path : "";

				$proofName = $documents !== "NA" ? $documents[0]->proof_name : "";
				$proofDocumentName = $documents !== "NA" ? $documents[0]->proof_file_name : "";
				$proofDocument = $documents !== "NA" && $documents[0]->proof_file_path !== "" ? base_url().$documents[0]->proof_file_path : "";

				$employmentName = $documents !== "NA" ? $documents[0]->employment_name : "";
				$employmentDocumentName = $documents !== "NA" ? $documents[0]->employment_file_name : "";
				$employmentDocument = $documents !== "NA" && $documents[0]->employment_file_path !== "" ? base_url().$documents[0]->employment_file_path : "";

				$declarationDocumentName = $documents !== "NA" ? $documents[0]->proof_name : "";
				$declarationDocument = $documents !== "NA" && $documents[0]->declaration_file_path !== "" ? base_url().$documents[0]->declaration_file_path : "";

				$award_one = $documents !== "NA" ? $documents[0]->award_one : "";
				$award_one_name = $documents !== "NA" && $documents[0]->award_one_name !== "" ? $documents[0]->award_one_name : "";

				$award_two = $documents !== "NA" ? $documents[0]->award_two : "";
				$award_two_name = $documents !== "NA" && $documents[0]->award_two_name !== "" ? $documents[0]->award_two_name : "";

				$award_three = $documents !== "NA" ? $documents[0]->award_three : "";
				$award_three_name = $documents !== "NA" && $documents[0]->award_three_name !== "" ? $documents[0]->award_three_name : "";

				$sup_file_one_name = $documents !== "NA" && $documents[0]->sup_file_one_name !== "" ? $documents[0]->sup_file_one_name : "";
				$sup_file_two_name = $documents !== "NA" && $documents[0]->sup_file_two_name !== "" ? $documents[0]->sup_file_two_name : "";
				$sup_file_three_name = $documents !== "NA" && $documents[0]->sup_file_three_name !== "" ? $documents[0]->sup_file_three_name : "";
				// $segmentStr = "";
				// if( $r->selected_segments !== "" ){
				// 	$segmentsArr = explode(",", $r->selected_segments);
				// 	foreach($segmentsArr as $s){
				// 		$segmentStr .= $segmentStr !== "" ? ', ' : '';
				// 		switch($s){
				// 			case 'leadership': $segmentStr .= "Leadership"; break;
				// 			case 'patient': $segmentStr .= "Patient care"; break;
				// 			case 'research': $segmentStr .= "Research/innovation"; break;
				// 			case 'social': $segmentStr .= "Social/Community service"; break;
				// 		}
				// 	}
				// }

				// $supportingDocument1 = !is_null($r->award_one_path) && $r->award_one_path !== "" ? base_url().$r->award_one_path : "";
				// $supportingDocument2 = !is_null($r->award_two_path) && $r->award_two_path !== "" ? base_url().$r->award_two_path : "";

				$sheet->setCellValue('A'.$excel_row, $nos);
				$sheet->setCellValue('B'.$excel_row, $date);
				$sheet->setCellValue('C'.$excel_row, $r->status);
				$sheet->setCellValue('D'.$excel_row, ucfirst($r->ey_assessment));
				$sheet->setCellValue('E'.$excel_row, $r->application_number);
				$sheet->setCellValue('F'.$excel_row, $r->code);
				$sheet->setCellValue('G'.$excel_row, $r->language);
				$sheet->setCellValue('H'.$excel_row, $r->first_name);
				$sheet->setCellValue('I'.$excel_row, $r->middle_name);
				$sheet->setCellValue('J'.$excel_row, $r->last_name);
				$sheet->setCellValue('K'.$excel_row, $candEmail);
				$sheet->setCellValue('L'.$excel_row, $dob);
				$sheet->setCellValue('M'.$excel_row, $country);
				$sheet->setCellValue('N'.$excel_row, $r->region);
				$sheet->setCellValue('O'.$excel_row, $r->phone_code.'-'.$r->contact);
				$sheet->setCellValue('P'.$excel_row, $r->gender);
				$sheet->setCellValue('Q'.$excel_row, $r->address);
				$sheet->setCellValue('R'.$excel_row, $r->qualified_as);
				$sheet->setCellValue('S'.$excel_row, $r->institute);
				$sheet->setCellValue('T'.$excel_row, $r->organisation_email);
				$sheet->setCellValue('U'.$excel_row, $r->organisation_phonecode.'-'.$r->organisation_contact);
				$sheet->setCellValue('V'.$excel_row, $r->organisation_website);
				$sheet->setCellValue('W'.$excel_row, $r->total_exp);
				$sheet->setCellValue('X'.$excel_row, $r->current_exp);

				$sheet->setCellValue('Y'.$excel_row, $degreeName);
				$sheet->setCellValue('Z'.$excel_row, $degreeDocumentName);
				//$spreadsheet->getActiveSheet()->getCell('X'.$excel_row)->getHyperlink()->setUrl($degreeDocument);

				$sheet->setCellValue('AA'.$excel_row, $councilName);
				$sheet->setCellValue('AB'.$excel_row, $councilRegistration);
				$sheet->setCellValue('AC'.$excel_row, $medicalDocumentName);
				//$spreadsheet->getActiveSheet()->getCell('AA'.$excel_row)->getHyperlink()->setUrl($medicalDocument);

				$sheet->setCellValue('AD'.$excel_row, $passportFrontDocumentName);
				//$spreadsheet->getActiveSheet()->getCell('AB'.$excel_row)->getHyperlink()->setUrl($passportFrontDocument);

				$sheet->setCellValue('AE'.$excel_row, $passportBackDocumentName);
				//$sheet->getCell('AC'.$excel_row)->getHyperlink()->setUrl($passportBackDocument);

				$sheet->setCellValue('AF'.$excel_row, $nursePicName);
				//$sheet->getCell('AD'.$excel_row)->getHyperlink()->setUrl($nursePic);

				$sheet->setCellValue('AG'.$excel_row, $proofName);
				$sheet->setCellValue('AH'.$excel_row, $proofDocumentName);
				//$sheet->getCell('AF'.$excel_row)->getHyperlink()->setUrl($proofDocument);
				
				$sheet->setCellValue('AI'.$excel_row, $employmentName);
				$sheet->setCellValue('AJ'.$excel_row, $employmentDocumentName);
				//$sheet->getCell('AH'.$excel_row)->getHyperlink()->setUrl($employmentDocument);

				$sheet->setCellValue('AK'.$excel_row, $declarationDocumentName);
				//$sheet->getCell('AI'.$excel_row)->getHyperlink()->setUrl($declarationDocument);

				$sheet->setCellValue('AL'.$excel_row, $leadership_segments);
				$sheet->setCellValue('AM'.$excel_row, $leadership_primary);
				$sheet->setCellValue('AN'.$excel_row, $leadership_secondary);
				$sheet->setCellValue('AO'.$excel_row, $patient_exp);
				$sheet->setCellValue('AP'.$excel_row, $patient_one);
				$sheet->setCellValue('AQ'.$excel_row, $patient_two);
				$sheet->setCellValue('AR'.$excel_row, $patient_three);
				$sheet->setCellValue('AS'.$excel_row, $patient_four);

				$sheet->setCellValue('AT'.$excel_row, $leadership_exp);
				$sheet->setCellValue('AU'.$excel_row, $leadership_one);
				$sheet->setCellValue('AV'.$excel_row, $leadership_two);
				$sheet->setCellValue('AW'.$excel_row, $leadership_three);
				$sheet->setCellValue('AX'.$excel_row, $leadership_four);
				
				$sheet->setCellValue('AY'.$excel_row, $education_exp);
				$sheet->setCellValue('AZ'.$excel_row, $education_one);
				$sheet->setCellValue('BA'.$excel_row, $education_two);
				$sheet->setCellValue('BB'.$excel_row, $education_three);
				$sheet->setCellValue('BC'.$excel_row, $education_four);

				$sheet->setCellValue('BD'.$excel_row, $social_exp);
				$sheet->setCellValue('BE'.$excel_row, $social_one);
				$sheet->setCellValue('BF'.$excel_row, $social_two);
				$sheet->setCellValue('BG'.$excel_row, $social_three);
				$sheet->setCellValue('BH'.$excel_row, $social_four);

				$sheet->setCellValue('BI'.$excel_row, $research_exp);
				$sheet->setCellValue('BJ'.$excel_row, $research_one);
				$sheet->setCellValue('BK'.$excel_row, $research_two);
				$sheet->setCellValue('BL'.$excel_row, $research_three);
				$sheet->setCellValue('BM'.$excel_row, $research_four);

				$sheet->setCellValue('BN'.$excel_row, $r->ref_name_one);
				$sheet->setCellValue('BO'.$excel_row, $r->ref_email_one);
				$sheet->setCellValue('BP'.$excel_row, $refOneCountry);
				$sheet->setCellValue('BQ'.$excel_row, $r->ref_phone_code_one.'-'.$r->ref_contact_one);
				$sheet->setCellValue('BR'.$excel_row, $r->ref_rel_one);
				$sheet->setCellValue('BS'.$excel_row, $r->ref_name_two);
				$sheet->setCellValue('BT'.$excel_row, $r->ref_email_two);
				$sheet->setCellValue('BU'.$excel_row, $refTwoCountry);
				$sheet->setCellValue('BV'.$excel_row, $r->ref_phone_code_two.'-'.$r->ref_contact_two);
				$sheet->setCellValue('BW'.$excel_row, $r->ref_rel_two);

				$sheet->setCellValue('BX'.$excel_row, $sup_file_one_name);
				$sheet->setCellValue('BY'.$excel_row, $sup_file_two_name);
				$sheet->setCellValue('BZ'.$excel_row, $sup_file_three_name);
				$sheet->setCellValue('CA'.$excel_row, $award_one);
				$sheet->setCellValue('CB'.$excel_row, $award_one_name);
				$sheet->setCellValue('CC'.$excel_row, $award_two);
				$sheet->setCellValue('CD'.$excel_row, $award_two_name);
				$sheet->setCellValue('CE'.$excel_row, $award_three);
				$sheet->setCellValue('CF'.$excel_row, $award_three_name);
				$sheet->setCellValue('CG'.$excel_row, $r->reason);
				// $sheet->setCellValue('CJ'.$excel_row, $created_at);
				
				
				// $sheet->setCellValue('AI'.$excel_row, $segmentStr);
				// $sheet->setCellValue('AJ'.$excel_row, $r->leadership_casestudy_one);
				// $sheet->setCellValue('AK'.$excel_row, $r->leadership_casestudy_two);
				// $sheet->setCellValue('AL'.$excel_row, $r->leadership_casestudy_three);
				// $sheet->setCellValue('AM'.$excel_row, $r->leadership_casestudy_four);
				// $sheet->setCellValue('AN'.$excel_row, $r->research_casestudy_one);
				// $sheet->setCellValue('AO'.$excel_row, $r->research_casestudy_two);
				// $sheet->setCellValue('AP'.$excel_row, $r->research_casestudy_three);
				// $sheet->setCellValue('AQ'.$excel_row, $r->research_casestudy_four);
				// $sheet->setCellValue('AR'.$excel_row, $r->patient_casestudy_one);
				// $sheet->setCellValue('AS'.$excel_row, $r->patient_casestudy_two);
				// $sheet->setCellValue('AT'.$excel_row, $r->patient_casestudy_three);
				// $sheet->setCellValue('AU'.$excel_row, $r->patient_casestudy_four);
				// $sheet->setCellValue('AV'.$excel_row, $r->social_casestudy_one);
				// $sheet->setCellValue('AW'.$excel_row, $r->social_casestudy_two);
				// $sheet->setCellValue('AX'.$excel_row, $r->social_casestudy_three);
				// $sheet->setCellValue('AY'.$excel_row, $r->social_casestudy_four);
				// $sheet->setCellValue('AZ'.$excel_row, $supportingDocument1);
				// $sheet->setCellValue('BA'.$excel_row, $supportingDocument2);

				$excel_row++;
				$nos++;
			}
		}
		//ob_clean();
		$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Applications Master Submitted Application.xlsx"'); 
		header('Cache-Control: max-age=0');

		// download file 
		$writer->save('php://output'); 
	}

	/////end
	//Edition Three
	function applicationThree(){ 
		//echo "<pre>";print_r($this->input->post());exit;
		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
		$spreadsheet->getProperties()->setCreator('Global Nursing Award 2024')
			->setLastModifiedBy('Global Nursing Award 2024')
			->setTitle('Applications Master')
			->setSubject('')
			->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:CJ1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A','AS') as $columnID){
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}
		
		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Date');
		$sheet->setCellValue('C1', 'Application Status');
		$sheet->setCellValue('D1', 'EY Assessment');
		$sheet->setCellValue('E1', 'Application Number');
		$sheet->setCellValue('F1', 'Application Code');
		$sheet->setCellValue('G1', 'Language');
		$sheet->setCellValue('H1', 'First name');
		$sheet->setCellValue('I1', 'Middle name');
		$sheet->setCellValue('J1', 'Last name');
		$sheet->setCellValue('K1', 'Email');
		$sheet->setCellValue('L1', 'Date of Birth');
		$sheet->setCellValue('M1', 'City');
		$sheet->setCellValue('N1', 'Country');
		$sheet->setCellValue('O1', 'Region');
		$sheet->setCellValue('P1', 'Contact No');
		$sheet->setCellValue('Q1', 'Gender');
		$sheet->setCellValue('R1', 'Address');
		$sheet->setCellValue('S1', 'Register as');
		$sheet->setCellValue('T1', 'Institute / hospital name');
		$sheet->setCellValue('U1', 'Job Title');
		$sheet->setCellValue('V1', 'Institute/ Hospital Country');
		$sheet->setCellValue('W1', 'Institute/ Hospital City');
		$sheet->setCellValue('X1', 'Contact Email ID');
		$sheet->setCellValue('Y1', 'Contact Number');
		$sheet->setCellValue('Z1', 'Reporting Manager Name');
		$sheet->setCellValue('AA1', 'Reporting Manager Designation');
		$sheet->setCellValue('AB1', 'Reporting Manager Email ID');
		$sheet->setCellValue('AC1', 'Reporting Manager Contact Number ');
		$sheet->setCellValue('AD1', 'Website link');
		$sheet->setCellValue('AE1', 'Total years of work experience as a Nurse');
		$sheet->setCellValue('AF1', 'Years of experience in the current institute/hospital');

		$sheet->setCellValue('AG1', 'Selected Segment');
		$sheet->setCellValue('AH1', 'Primary Segment');
		$sheet->setCellValue('AI1', 'Secondary Segment');
		$sheet->setCellValue('AJ1', 'Patient Experience');
		$sheet->setCellValue('AK1', 'Patient care in your daily work environment');
		$sheet->setCellValue('AL1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('AM1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('AN1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');
		$sheet->setCellValue('AO1', 'Leadership Experience');
		$sheet->setCellValue('AP1', 'Patient care in your daily work environment');
		$sheet->setCellValue('AQ1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('AR1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('AS1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('AT1', 'Education Experience');
		$sheet->setCellValue('AU1', 'Patient care in your daily work environment');
		$sheet->setCellValue('AV1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('AW1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('AX1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('AY1', 'Social Experience');
		$sheet->setCellValue('AZ1', 'Patient care in your daily work environment');
		$sheet->setCellValue('BA1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('BB1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('BC1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('BD1', 'Research Experience');
		$sheet->setCellValue('BE1', 'Patient care in your daily work environment');
		$sheet->setCellValue('BF1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('BG1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('BH1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');
		
		$sheet->setCellValue('BI1', 'Describe how do you intend to utilize the prize money if you win');

		$sheet->setCellValue('BJ1', 'First Referrer full name');
		$sheet->setCellValue('BK1', 'Referrer email ID');
		$sheet->setCellValue('BL1', 'Referrer country');
		$sheet->setCellValue('BM1', 'Referrer contact number');
		$sheet->setCellValue('BN1', 'Relationship with the reference');
		$sheet->setCellValue('BO1', 'Designation');

		$sheet->setCellValue('BP1', 'Second Referrer full name');		
		$sheet->setCellValue('BQ1', 'Referrer email ID');
		$sheet->setCellValue('BR1', 'Referrer country');
		$sheet->setCellValue('BS1', 'Referrer contact number');
		$sheet->setCellValue('BT1', 'Relationship with the reference');
		$sheet->setCellValue('BU1', 'Designation');

		$sheet->setCellValue('BV1', 'Educational Qualification (Highest degree)');
		$sheet->setCellValue('BW1', 'Educational Qualification (Highest degree) File Name');
		$sheet->setCellValue('BX1', 'Medical/Nurse council registration name');
		$sheet->setCellValue('BY1', 'Medical/Nurse council registration number');
		$sheet->setCellValue('BZ1', 'Medical/Nurse council registration File Name');
		$sheet->setCellValue('CA1', 'Passport Copy');
		$sheet->setCellValue('CB1', 'Valid national proof of identity of the country/region you are applying from (Government ID) ');
		$sheet->setCellValue('CC1', 'Minimum 2 years of employment proof as a registered nurse');
		$sheet->setCellValue('CD1', 'LinkedIn');
		$sheet->setCellValue('CE1', 'X (Twitter)');
		$sheet->setCellValue('CF1', 'Facebook');
		$sheet->setCellValue('CG1', 'Instagram ');
		
		$sheet->setCellValue('CH1', 'Collaterals doc');
		// $sheet->setCellValue('BY1', 'Collaterals doc 2');
		// $sheet->setCellValue('BZ1', 'Collaterals doc 3');
		// $sheet->setCellValue('CA1', 'Awards/ certifications  doc 1 name');
		// $sheet->setCellValue('CB1', 'Awards/ certifications  doc 1 ');
		// $sheet->setCellValue('CC1', 'Awards/ certifications  doc 2 name');
		// $sheet->setCellValue('CD1', 'Awards/ certifications  doc 2');
		// $sheet->setCellValue('CE1', 'Awards/ certifications  doc 3 name');
		// $sheet->setCellValue('CF1', 'Awards/ certifications  doc 3');

		$sheet->setCellValue('CI1', 'Reason');
		$sheet->setCellValue('CJ1', 'Section');
		$sheet->setCellValue('CK1', 'Modify Date');
		// $sheet->setCellValue('CJ1', 'Date and Time');


		// $sheet->setCellValue('AI1', 'Selected segments');
		// $sheet->setCellValue('AJ1', 'We believe nursing is about leading from the front. So, why would you consider yourself as a leader and what difference has that made?');
		// $sheet->setCellValue('AK1', 'Help us understand the challenges faced and how did you overcome the same');
		// $sheet->setCellValue('AL1', 'How do patients and peers respond to your leadership?');
		// $sheet->setCellValue('AM1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AN1', 'Describe your contributions to nursing research, policy, and/or practice at the local regional, state, and /or national level');
		// $sheet->setCellValue('AO1', 'Describe the challenges faced  and how did you overcome the same');
		// $sheet->setCellValue('AP1', 'Describe the impact of the initiative on the patients, employer, peers, etc?');
		// $sheet->setCellValue('AQ1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AR1', 'Describe the initiatives undertaken to facilitate positive changes in the work environment and improve the quality of patient care');
		// $sheet->setCellValue('AS1', 'Describe the challenges faced  and how did you overcome the same');
		// $sheet->setCellValue('AT1', 'Describe the impact of the initiative on the patients, employer, peers, etc?');
		// $sheet->setCellValue('AU1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AV1', 'Describe the your contribution for the betterment of the community/society');
		// $sheet->setCellValue('AW1', 'Describe the challenges faced  and how did you overcome the same');
		// $sheet->setCellValue('AX1', 'Describe the impact of the initiative on the community and what was the change they witnessed?');
		// $sheet->setCellValue('AY1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AZ1', 'Awards and certifications');
		// $sheet->setCellValue('BA1', 'Awards and certifications');
		//$_APPLICATIONS_QUERY = "SELECT * FROM application_personal_details limit 12000";
		$content = $this->input->post();
		$_APPLICATIONS_QUERY = '';
		if(isset($content['start']) ){
			$start = $content['start'];
		} else {
			return false;
		}
		if(isset($content['end']) ){
			
			$end = $content['end'];
		} else {
			return false;
		}
		
		if(isset($content['edition'])){
			if($content['edition'] == 'one-two'){
				$edition = 'one';
				$_APPLICATIONS_QUERY = "SELECT a.applications_id, a.uid, a.`code`,a.application_number,a.first_name,
								a.middle_name,a.last_name,a.dob,a.country,a.region,a.phone_code,a.contact,a.address,a.gender,a.qualified_as,
								a.institute,
								a.organisation_phonecode,a.organisation_contact,a.organisation_email,a.organisation_website,a.total_exp,
								a.current_exp,a.ref_name_one,a.ref_designation_one,a.ref_email_one,a.ref_country_one,a.ref_phone_code_one,ref_contact_one,
								a.ref_rel_one,a.ref_name_two,a.ref_designation_two,a.ref_email_two,a.ref_country_two,
								a.ref_phone_code_two,a.ref_contact_two,a.ref_rel_two,a.ref_rel_other_two,a.`status`,a.step,
								a.ey_assessment,a.is_recommended,a.reason,a.`language`,a.created_at,a.nurce_city,a.`city`,a.hospital_country,a.relational_manager_name,
								a.relational_manager_designation,a.relational_manager_email,a.relational_manager_mobile,a.job_title,a.modified_at,a.first_name_lang,a.middle_name_lang,
								a.last_name_lang,a.institute_lang,a.ref_name_one_lang,a.ref_designation_one_lang,a.ref_name_two_lang,a.ref_designation_two_lang
								FROM application_personal_details as a where a.`edition` = 'one' or a.`edition` = 'two' limit $end offset $start";
			} else {
				$edition = 'three';
				$_APPLICATIONS_QUERY = "SELECT a.applications_id, a.uid, a.`code`,a.application_number,a.first_name,
								a.middle_name,a.last_name,a.dob,a.country,a.region,a.phone_code,a.contact,a.address,a.gender,a.qualified_as,
								a.institute,
								a.organisation_phonecode,a.organisation_contact,a.organisation_email,a.organisation_website,a.total_exp,
								a.current_exp,a.ref_name_one,a.ref_designation_one,a.ref_email_one,a.ref_country_one,a.ref_phone_code_one,ref_contact_one,
								a.ref_rel_one,a.ref_name_two,a.ref_designation_two,a.ref_email_two,a.ref_country_two,
								a.ref_phone_code_two,a.ref_contact_two,a.ref_rel_two,a.ref_rel_other_two,a.`status`,a.step,
								a.ey_assessment,a.is_recommended,a.reason,a.`language`,a.created_at,a.nurce_city,a.`city`,a.hospital_country,a.relational_manager_name,
								a.relational_manager_designation,a.relational_manager_email,a.relational_manager_mobile,a.job_title,a.modified_at,a.first_name_lang,a.middle_name_lang,
								a.last_name_lang,a.institute_lang,a.ref_name_one_lang,a.ref_designation_one_lang,a.ref_name_two_lang,a.ref_designation_two_lang
								FROM application_personal_details as a where a.`edition` = '$edition' limit $end offset $start";
			}
		} 
		//echo $_APPLICATIONS_QUERY;exit;
		//limit 10000 offset 10000
		$records = $this->Mdl_excel->customQuery($_APPLICATIONS_QUERY);
		$excel_row = 2;
		$nos = 1;

		if( $records !== "NA" ){
			foreach($records as $r){

				$date = date("Y-m-d H:i:s", strtotime($r->created_at));
				$created_at = date("Y-m-d H:i:s", strtotime($r->created_at));
				$dob = date("Y-m-d", strtotime($r->dob));
				// $_APPLICATIONS_COUNTRY_QUERY = "select c.country_id,c.country_name,c.`code` from master_country as c where country_id = '".$r->country."'";
				// $country_data = $this->Mdl_excel->customQuery($_APPLICATIONS_COUNTRY_QUERY);
				// $country = $country_data !== "NA" ? $country_data[0]->country_name : "NA";
				// $refOneCountry = $country_data !== "NA" ? $country_data[0]->country_name : "NA";
				// $refTwoCountry = $country_data !== "NA" ? $country_data[0]->country_name : "NA";
				$country = Modules::run('api/application/personal/country',$r->country);
				$refOneCountry = Modules::run('api/application/personal/country',$r->ref_country_one);
				$refTwoCountry = Modules::run('api/application/personal/country',$r->ref_country_two);
				$casestudies = Modules::run('api/application/personal/caseStudies',$r->uid);
				if($casestudies != "NA"){
					$ledership_array = explode(',',$casestudies[0]->selected_segments);
					$leadership_segments = $casestudies[0]->selected_segments;
					$leadership_primary = $casestudies[0]->primary_segment;
					$leadership_secondary = $casestudies[0]->secondary_segment;
					$leadership_exp = $casestudies[0]->leadership_exp;
					if(in_array('leadership', $ledership_array)){
						
						if(!empty($casestudies[0]->leadership_one) && $casestudies[0]->leadership_one != ""){
							$leadership_one = json_decode($casestudies[0]->leadership_one);
							$leadership_one = $leadership_one->textEn;
							$leadership_two = json_decode($casestudies[0]->leadership_two);
							$leadership_two = $leadership_two->textEn;
							$leadership_three = json_decode($casestudies[0]->leadership_three);
							$leadership_three = $leadership_three->textEn;
							$leadership_four = json_decode($casestudies[0]->leadership_four);
							$leadership_four = $leadership_four->textEn;
							
						} else {
							$leadership_one = '';
							$leadership_two = '';
							$leadership_three = '';
							$leadership_four = '';
						}
					} else {
						$leadership_segments = '';
						$leadership_primary = '';
						$leadership_secondary = '';
						$leadership_exp = '';
						$leadership_one = '';
						$leadership_two = '';
						$leadership_three = '';
						$leadership_four = '';
					}
					$patient_array = explode(',',$casestudies[0]->selected_segments);
					//print_r($patient_array);
					//exit;
					if(in_array('patient', $patient_array)){
						$patient_segments = $casestudies[0]->selected_segments;
						$patient_primary = $casestudies[0]->primary_segment;
						$patient_secondary = $casestudies[0]->secondary_segment;
						$patient_exp = $casestudies[0]->patient_exp;
						if(!empty($casestudies[0]->patient_one) && $casestudies[0]->patient_one != ""){
							$patient_one = json_decode($casestudies[0]->patient_one);
							$patient_one = $patient_one->textEn;
							$patient_two = json_decode($casestudies[0]->patient_two);
							$patient_two = $patient_two->textEn;
							$patient_three = json_decode($casestudies[0]->patient_three);
							$patient_three = $patient_three->textEn;
							$patient_four = json_decode($casestudies[0]->patient_four);
							$patient_four = $patient_four->textEn;
							
						} else {
							$patient_one = '';
							$patient_two = '';
							$patient_three = '';
							$patient_four = '';
						}
					} else {
						$patient_segments = '';
						$patient_primary = '';
						$patient_secondary = '';
						$patient_exp = '';
						$patient_one = '';
						$patient_two = '';
						$patient_three = '';
						$patient_four = '';
					}

					$education_array = explode(',',$casestudies[0]->selected_segments);
					if(in_array('education', $education_array)){
						$education_segments = $casestudies[0]->selected_segments;
						$education_primary = $casestudies[0]->primary_segment;
						$education_secondary = $casestudies[0]->secondary_segment;
						$education_exp = $casestudies[0]->education_exp;
						if(!empty($casestudies[0]->education_one) && $casestudies[0]->education_one != ""){
							$education_one_t = json_decode($casestudies[0]->education_one);
							$education_one = $education_one_t->textEn;
							$education_two = json_decode($casestudies[0]->education_two);
							$education_two = $education_two->textEn;
							$education_three = json_decode($casestudies[0]->education_three);
							$education_three = $education_three->textEn;
							$education_four = json_decode($casestudies[0]->education_four);
							$education_four = $education_four->textEn;
						} else {
							$education_one = '';
							$education_two = '';
							$education_three = '';
							$education_four ='';
						}
					} else {
						$education_segments = '';
						$education_primary = '';
						$education_secondary = '';
						$education_exp = '';
						$education_one = '';
						$education_two = '';
						$education_three = '';
						$education_four ='';
					}
					
					$social_array = explode(',',$casestudies[0]->selected_segments);
					if(in_array('social', $social_array)){
						$social_segments = $casestudies[0]->selected_segments;
						$social_primary = $casestudies[0]->primary_segment;
						$social_secondary = $casestudies[0]->secondary_segment;
						$social_exp = $casestudies[0]->social_exp;
						if(!empty($casestudies[0]->social_one) && $casestudies[0]->social_one != ""){
							$social_one = json_decode($casestudies[0]->social_one);
							$social_one = $social_one->textEn;
							$social_two = json_decode($casestudies[0]->social_two);
							$social_two = $social_two->textEn;
							$social_three = json_decode($casestudies[0]->social_three);
							$social_three = $social_three->textEn;
							$social_four = json_decode($casestudies[0]->social_four);
							$social_four = $social_four->textEn;
	
						} else {
							$social_one = '';
							$social_two = '';
							$social_three = '';
							$social_four = '';
						}
					} else {
						$social_segments = '';
						$social_primary = '';
						$social_secondary = '';
						$social_exp = '';
						$social_one = '';
						$social_two = '';
						$social_three = '';
						$social_four = '';
					}
					
					$research_array = explode(',',$casestudies[0]->selected_segments);
					if(in_array('research', $research_array)){
						$research_segments = $casestudies[0]->selected_segments;
						$research_primary = $casestudies[0]->primary_segment;
						$research_secondary = $casestudies[0]->secondary_segment;
						$research_exp = $casestudies[0]->research_exp;
						if(!empty($casestudies[0]->research_one) && $casestudies[0]->research_one != ""){
							$research_one = json_decode($casestudies[0]->research_one);
							$research_one = $research_one->textEn;
							$research_two = json_decode($casestudies[0]->research_two);
							$research_two = $research_two->textEn;
							$research_three = json_decode($casestudies[0]->research_three);
							$research_three = $research_three->textEn;
							$research_four = json_decode($casestudies[0]->research_four);
							$research_four = $research_four->textEn;
	
						} else {
							$research_one = '';
							$research_two = '';
							$research_three = '';
							$research_four = '';
						}
					} else {
						$research_segments = '';
						$research_primary = '';
						$research_secondary = '';
						$research_exp = '';
						$research_one = '';
						$research_two = '';
						$research_three = '';
						$research_four = '';
					}
					
				} else {
					$leadership_segments = '';;
					$leadership_primary = '';
					$leadership_secondary = '';
					$leadership_exp = '';
					$leadership_one = '';
					$leadership_two = '';
					$leadership_three = '';
					$leadership_four = '';

					$patient_segments = '';
					$patient_primary = '';
					$patient_secondary = '';
					$patient_exp = '';					
					$patient_one = '';
					$patient_two = '';
					$patient_three = '';
					$patient_four = '';

					$education_segments = '';;
					$education_primary = '';
					$education_secondary = '';
					$education_exp = '';
					$education_one = '';
					$education_two = '';
					$education_three = '';
					$education_four ='';

					$social_segments = '';
					$social_primary = '';
					$social_secondary = '';
					$social_exp = '';
					$social_one = '';
					$social_two = '';
					$social_three = '';
					$social_four = '';

					$research_segments = '';;
					$research_primary = '';
					$research_secondary = '';
					$research_exp = '';
					$research_one = '';
					$research_two = '';
					$research_three = '';
					$research_four = '';
				}
				$prize_money_array = '';$prize_money = '';
				if(isset($casestudies[0]->prize_money) && !empty($casestudies[0]->prize_money)) {
					$prize_money_array = json_decode($casestudies[0]->prize_money);
					$prize_money = $prize_money_array->textEn;
				}
				$nurse = $this->Mdl_excel->retrieveByCol("email", "registration", array("uid"=>$r->uid));
				$candEmail = $nurse !== "NA" ? $nurse[0]->email : "";

				$_APPLICATIONS_DOCUMENTS_QUERY = "select ad.document_id,ad.uid,ad.`code`,ad.degree_name,ad.degree_file_name,
								ad.degree_file_path,ad.passport_front_file_name,ad.passport_front_file_path,ad.passport_back_file_name,
								ad.passport_back_file_path,ad.nursepic_name,ad.nursepic_path,ad.council_name,ad.council_registration,
								ad.medical_file_name,ad.medical_file_path,ad.proof_name,ad.proof_file_name,ad.proof_file_path,ad.proof_type,
								ad.employment_name,ad.employment_file_name,ad.employment_file_path,ad.declaration_name,ad.declaration_file_name,
								ad.declaration_file_path,ad.award_one,ad.award_one_name,ad.award_one_path,ad.award_two,ad.award_two_name,
								ad.award_two_path,ad.award_three,ad.award_three_name,ad.award_three_path,ad.sup_file_one_name,ad.sup_file_one_path,
								ad.sup_file_two_name,ad.sup_file_two_path,ad.sup_file_three_name,ad.sup_file_three_path,ad.created_at,ad.linkdin,ad.twitter,ad.facebook,ad.instagram,ad.wordFileName,ad.passport_check,ad.national_proof_check,ad.experience_check
								from application_documents as ad where ad.uid= '".$r->uid."' and ad.`code` = '".$r->code."'";
				$documents = $this->Mdl_excel->customQuery($_APPLICATIONS_DOCUMENTS_QUERY);
				// $documents = $this->Mdl_excel->retrieve(
				// 	"application_documents", 
				// 	array(
				// 		"uid" => $r->uid,
				// 		"code" => $r->code
				// 	)
				// );

				$degreeName = $documents !== "NA" ? $documents[0]->degree_name : "";
				$degreeDocumentName = $documents !== "NA" ? $documents[0]->degree_file_name : "";
				$degreeDocument =  $documents !== "NA" && $documents[0]->degree_file_path !== "" ? base_url().$documents[0]->degree_file_path : "";

				$councilName = $documents !== "NA" ? $documents[0]->council_name : "";
				$councilRegistration = $documents !== "NA" ? $documents[0]->council_registration : "";
				$medicalDocumentName = $documents !== "NA" ? $documents[0]->medical_file_name : "";
				$medicalDocument = $documents !== "NA" && $documents[0]->medical_file_path !== "" ? base_url().$documents[0]->medical_file_path : "";

				$passportFrontDocumentName = $documents !== "NA" ? $documents[0]->passport_front_file_name : "";
				$passportFrontDocument = $documents !== "NA" && $documents[0]->passport_front_file_path !== "" ? base_url().$documents[0]->passport_front_file_path : "";

				$passportBackDocumentName = $documents !== "NA" ? $documents[0]->passport_back_file_name : "";
				$passportBackDocument = $documents !== "NA" && $documents[0]->passport_back_file_path !== "" ? base_url().$documents[0]->passport_back_file_path : "";
				
				$nursePicName = $documents !== "NA" ? $documents[0]->nursepic_name : "";
				$nursePic = $documents !== "NA" && $documents[0]->nursepic_path !== "" ? base_url().$documents[0]->nursepic_path : "";

				$proofName = $documents !== "NA" ? $documents[0]->proof_name : "";
				$proofDocumentName = $documents !== "NA" ? $documents[0]->proof_file_name : "";
				$proofDocument = $documents !== "NA" && $documents[0]->proof_file_path !== "" ? base_url().$documents[0]->proof_file_path : "";

				$employmentName = $documents !== "NA" ? $documents[0]->employment_name : "";
				$employmentDocumentName = $documents !== "NA" ? $documents[0]->employment_file_name : "";
				$employmentDocument = $documents !== "NA" && $documents[0]->employment_file_path !== "" ? base_url().$documents[0]->employment_file_path : "";

				$declarationDocumentName = $documents !== "NA" ? $documents[0]->proof_name : "";
				$declarationDocument = $documents !== "NA" && $documents[0]->declaration_file_path !== "" ? base_url().$documents[0]->declaration_file_path : "";

				$award_one = $documents !== "NA" ? $documents[0]->award_one : "";
				$award_one_name = $documents !== "NA" && $documents[0]->award_one_name !== "" ? $documents[0]->award_one_name : "";

				$award_two = $documents !== "NA" ? $documents[0]->award_two : "";
				$award_two_name = $documents !== "NA" && $documents[0]->award_two_name !== "" ? $documents[0]->award_two_name : "";

				$award_three = $documents !== "NA" ? $documents[0]->award_three : "";
				$award_three_name = $documents !== "NA" && $documents[0]->award_three_name !== "" ? $documents[0]->award_three_name : "";

				$sup_file_one_name = $documents !== "NA" && $documents[0]->sup_file_one_name !== "" ? $documents[0]->sup_file_one_name : "";
				$sup_file_two_name = $documents !== "NA" && $documents[0]->sup_file_two_name !== "" ? $documents[0]->sup_file_two_name : "";
				$sup_file_three_name = $documents !== "NA" && $documents[0]->sup_file_three_name !== "" ? $documents[0]->sup_file_three_name : "";

				$word_file_name = $documents !== "NA" && $documents[0]->wordFileName !== "" ? $documents[0]->wordFileName : "";
				// $segmentStr = "";
				// if( $r->selected_segments !== "" ){
				// 	$segmentsArr = explode(",", $r->selected_segments);
				// 	foreach($segmentsArr as $s){
				// 		$segmentStr .= $segmentStr !== "" ? ', ' : '';
				// 		switch($s){
				// 			case 'leadership': $segmentStr .= "Leadership"; break;
				// 			case 'patient': $segmentStr .= "Patient care"; break;
				// 			case 'research': $segmentStr .= "Research/innovation"; break;
				// 			case 'social': $segmentStr .= "Social/Community service"; break;
				// 		}
				// 	}
				// }

				// $supportingDocument1 = !is_null($r->award_one_path) && $r->award_one_path !== "" ? base_url().$r->award_one_path : "";
				// $supportingDocument2 = !is_null($r->award_two_path) && $r->award_two_path !== "" ? base_url().$r->award_two_path : "";
				$section = '';
				if($r->step == "personal-details"){
					$section = 'section 1';
				} else if($r->step == "professional-details"){
					$section = 'section 2';
				} else if($r->step == "references"){
					$section = 'section 3';
				} else if($r->step == "segments"){
					$section = 'section 4';
				} else {
					$section = 'section 5';
				}
				$first_name = '';
				if(isset($r->first_name_lang) && !empty($r->first_name_lang)){
					$first_name = $r->first_name.'/'.$r->first_name_lang;
				} else {
					$first_name = $r->first_name;
				}

				$middle_name = '';
				if(isset($r->middle_name_lang) && !empty($r->middle_name_lang)){
					$middle_name = $r->middle_name.'/'.$r->middle_name_lang;
				} else {
					$middle_name = $r->middle_name;
				}
				$last_name = '';
				if(isset($r->last_name_lang) && !empty($r->last_name_lang)){
					$last_name = $r->last_name.'/'.$r->last_name_lang;
				} else {
					$last_name = $r->last_name;
				}
				$institute = '';
				if(isset($r->institute_lang) && !empty($r->institute_lang)){
					$institute = $r->institute.'/'.$r->institute_lang;
				} else {
					$institute = $r->institute;
				}
				$ref_name_one = '';
				if(isset($r->ref_name_one_lang) && !empty($r->ref_name_one_lang)){
					$ref_name_one = $r->ref_name_one.'/'.$r->ref_name_one_lang;
				} else {
					$ref_name_one = $r->ref_name_one;
				}
				$ref_designation_one = '';
				if(isset($r->ref_designation_one_lang) && !empty($r->ref_designation_one_lang)){
					$ref_designation_one = $r->ref_designation_one.'/'.$r->ref_designation_one_lang;
				} else {
					$ref_designation_one = $r->ref_designation_one;
				}

				$ref_name_two = '';
				if(isset($r->ref_name_two_lang) && !empty($r->ref_name_two_lang)){
					$ref_name_two = $r->ref_name_two.'/'.$r->ref_name_two_lang;
				} else {
					$ref_name_two = $r->ref_name_two;
				}
				$ref_designation_two = '';
				if(isset($r->ref_designation_two_lang) && !empty($r->ref_designation_two_lang)){
					$ref_designation_two = $r->ref_designation_two.'/'.$r->ref_designation_two_lang;
				} else {
					$ref_designation_two = $r->ref_designation_two;
				}
				if($documents[0]->passport_check == "yes"){
					$passport_check = 'Agreed';
				} else {
					$passport_check = '';
				}
				
				if( $documents[0]->national_proof_check=="yes"){
					$national_proof_check = 'Agreed';
				} else {
					$national_proof_check = '';
				}
				
				if($documents[0]->experience_check=="yes"){
					$experience_check = 'Agreed';
				} else {
					$experience_check = '';
				}
				$organisation_contact = '';
				if(!empty($r->organisation_contact)){
					$organisation_contact = $r->organisation_phonecode.'-'.$r->organisation_contact;
				} else {
					$organisation_contact = '';
				}
				if(!empty($r->contact)){
					$contact = $r->phone_code.'-'.$r->contact;
				} else {
					$contact = '';
				}
				$sheet->setCellValue('A'.$excel_row, $nos);
				$sheet->setCellValue('B'.$excel_row, $date);
				$sheet->setCellValue('C'.$excel_row, $r->status);
				$sheet->setCellValue('D'.$excel_row, ucfirst($r->ey_assessment));
				$sheet->setCellValue('E'.$excel_row, $r->application_number);
				$sheet->setCellValue('F'.$excel_row, $r->code);
				$sheet->setCellValue('G'.$excel_row, $r->language);
				$sheet->setCellValue('H'.$excel_row, $first_name);
				$sheet->setCellValue('I'.$excel_row, $middle_name);
				$sheet->setCellValue('J'.$excel_row, $last_name);
				$sheet->setCellValue('K'.$excel_row, $candEmail);
				$sheet->setCellValue('L'.$excel_row, $dob);
				$sheet->setCellValue('M'.$excel_row, $r->nurce_city);
				$sheet->setCellValue('N'.$excel_row, $country);
				$sheet->setCellValue('O'.$excel_row, $r->region);
				$sheet->setCellValue('P'.$excel_row, $contact);
				$sheet->setCellValue('Q'.$excel_row, $r->gender);
				$sheet->setCellValue('R'.$excel_row, $r->address);
				$sheet->setCellValue('S'.$excel_row, $r->qualified_as);
				$sheet->setCellValue('T'.$excel_row, $institute);
				$sheet->setCellValue('U'.$excel_row, $r->job_title);
				$sheet->setCellValue('V'.$excel_row, $r->hospital_country);
				$sheet->setCellValue('W'.$excel_row, $r->city);
				$sheet->setCellValue('X'.$excel_row, $r->organisation_email);
				//$sheet->setCellValue('Y'.$excel_row, $r->organisation_phonecode.'-'.$r->organisation_contact);
				$sheet->setCellValue('Y'.$excel_row, $organisation_contact);
				$sheet->setCellValue('Z'.$excel_row, $r->relational_manager_name);
				$sheet->setCellValue('AA'.$excel_row, $r->relational_manager_designation);
				$sheet->setCellValue('AB'.$excel_row, $r->relational_manager_email);
				$sheet->setCellValue('AC'.$excel_row, $r->relational_manager_mobile);
				$sheet->setCellValue('AD'.$excel_row, $r->organisation_website);
				$sheet->setCellValue('AE'.$excel_row, $r->total_exp);
				$sheet->setCellValue('AF'.$excel_row, $r->current_exp);
				
				$sheet->setCellValue('AG'.$excel_row, $leadership_segments);
				$sheet->setCellValue('AH'.$excel_row, $leadership_primary);
				$sheet->setCellValue('AI'.$excel_row, $leadership_secondary);
				$sheet->setCellValue('AJ'.$excel_row, $patient_exp);
				$sheet->setCellValue('AK'.$excel_row, $patient_one);
				$sheet->setCellValue('AL'.$excel_row, $patient_two);
				$sheet->setCellValue('AM'.$excel_row, $patient_three);
				$sheet->setCellValue('AN'.$excel_row, $patient_four);

				$sheet->setCellValue('AO'.$excel_row, $leadership_exp);
				$sheet->setCellValue('AP'.$excel_row, $leadership_one);
				$sheet->setCellValue('AQ'.$excel_row, $leadership_two);
				$sheet->setCellValue('AR'.$excel_row, $leadership_three);
				$sheet->setCellValue('AS'.$excel_row, $leadership_four);
				
				$sheet->setCellValue('AT'.$excel_row, $education_exp);
				$sheet->setCellValue('AU'.$excel_row, $education_one);
				$sheet->setCellValue('AV'.$excel_row, $education_two);
				$sheet->setCellValue('AW'.$excel_row, $education_three);
				$sheet->setCellValue('AX'.$excel_row, $education_four);

				$sheet->setCellValue('AY'.$excel_row, $social_exp);
				$sheet->setCellValue('AZ'.$excel_row, $social_one);
				$sheet->setCellValue('BA'.$excel_row, $social_two);
				$sheet->setCellValue('BS'.$excel_row, $social_three);
				$sheet->setCellValue('BC'.$excel_row, $social_four);

				$sheet->setCellValue('BD'.$excel_row, $research_exp);
				$sheet->setCellValue('BE'.$excel_row, $research_one);
				$sheet->setCellValue('BF'.$excel_row, $research_two);
				$sheet->setCellValue('BG'.$excel_row, $research_three);
				$sheet->setCellValue('BH'.$excel_row, $research_four);
				
				$sheet->setCellValue('BI'.$excel_row, $prize_money);

				$sheet->setCellValue('BJ'.$excel_row, $ref_name_one);
				$sheet->setCellValue('BK'.$excel_row, $r->ref_email_one);
				$sheet->setCellValue('BL'.$excel_row, $refOneCountry);
				$sheet->setCellValue('BM'.$excel_row, $r->ref_phone_code_one.'-'.$r->ref_contact_one);
				$sheet->setCellValue('BN'.$excel_row, $r->ref_rel_one);
				$sheet->setCellValue('BO'.$excel_row, $ref_designation_one);
				$sheet->setCellValue('BP'.$excel_row, $ref_name_two);
				$sheet->setCellValue('BQ'.$excel_row, $r->ref_email_two);
				$sheet->setCellValue('BR'.$excel_row, $refTwoCountry);
				$sheet->setCellValue('BS'.$excel_row, $r->ref_phone_code_two.'-'.$r->ref_contact_two);
				$sheet->setCellValue('BT'.$excel_row, $r->ref_rel_two);
				$sheet->setCellValue('BU'.$excel_row, $ref_designation_two);

				// $sheet->setCellValue('BX'.$excel_row, $sup_file_one_name);
				// $sheet->setCellValue('BY'.$excel_row, $sup_file_two_name);
				// $sheet->setCellValue('BZ'.$excel_row, $sup_file_three_name);
				// $sheet->setCellValue('CA'.$excel_row, $award_one);
				// $sheet->setCellValue('CB'.$excel_row, $award_one_name);
				// $sheet->setCellValue('CC'.$excel_row, $award_two);
				// $sheet->setCellValue('CD'.$excel_row, $award_two_name);
				// $sheet->setCellValue('CE'.$excel_row, $award_three);
				// $sheet->setCellValue('CF'.$excel_row, $award_three_name);

				$sheet->setCellValue('BV'.$excel_row, $degreeName);
				$sheet->setCellValue('BW'.$excel_row, $degreeDocumentName);
				//$spreadsheet->getActiveSheet()->getCell('X'.$excel_row)->getHyperlink()->setUrl($degreeDocument);

				$sheet->setCellValue('BX'.$excel_row, $councilName);
				$sheet->setCellValue('BY'.$excel_row, $councilRegistration);
				$sheet->setCellValue('BZ'.$excel_row, $medicalDocumentName);
				//$spreadsheet->getActiveSheet()->getCell('AA'.$excel_row)->getHyperlink()->setUrl($medicalDocument);

				$sheet->setCellValue('CA'.$excel_row, $passport_check );
				//$spreadsheet->getActiveSheet()->getCell('AB'.$excel_row)->getHyperlink()->setUrl($passportFrontDocument);

				$sheet->setCellValue('CB'.$excel_row, $national_proof_check);
				//$sheet->getCell('AC'.$excel_row)->getHyperlink()->setUrl($passportBackDocument);

				$sheet->setCellValue('CC'.$excel_row, $experience_check);
				//$sheet->getCell('AD'.$excel_row)->getHyperlink()->setUrl($nursePic);

				$sheet->setCellValue('CD'.$excel_row, $documents[0]->linkdin);
				$sheet->setCellValue('CE'.$excel_row, $documents[0]->twitter);
				//$sheet->getCell('AF'.$excel_row)->getHyperlink()->setUrl($proofDocument);
				
				$sheet->setCellValue('CF'.$excel_row, $documents[0]->facebook);
				$sheet->setCellValue('CG'.$excel_row, $documents[0]->instagram);
				//$sheet->getCell('AH'.$excel_row)->getHyperlink()->setUrl($employmentDocument);

				//$sheet->setCellValue('CG'.$excel_row, $declarationDocumentName);
				//$sheet->getCell('AI'.$excel_row)->getHyperlink()->setUrl($declarationDocument);

				$sheet->setCellValue('CH'.$excel_row, $word_file_name);
				$sheet->setCellValue('CI'.$excel_row, $r->reason);
				$sheet->setCellValue('CJ'.$excel_row, $section);
				$sheet->setCellValue('CK'.$excel_row, $r->modified_at);
				// $sheet->setCellValue('CJ'.$excel_row, $created_at);
				

				// $sheet->setCellValue('AI'.$excel_row, $segmentStr);
				// $sheet->setCellValue('AJ'.$excel_row, $r->leadership_casestudy_one);
				// $sheet->setCellValue('AK'.$excel_row, $r->leadership_casestudy_two);
				// $sheet->setCellValue('AL'.$excel_row, $r->leadership_casestudy_three);
				// $sheet->setCellValue('AM'.$excel_row, $r->leadership_casestudy_four);
				// $sheet->setCellValue('AN'.$excel_row, $r->research_casestudy_one);
				// $sheet->setCellValue('AO'.$excel_row, $r->research_casestudy_two);
				// $sheet->setCellValue('AP'.$excel_row, $r->research_casestudy_three);
				// $sheet->setCellValue('AQ'.$excel_row, $r->research_casestudy_four);
				// $sheet->setCellValue('AR'.$excel_row, $r->patient_casestudy_one);
				// $sheet->setCellValue('AS'.$excel_row, $r->patient_casestudy_two);
				// $sheet->setCellValue('AT'.$excel_row, $r->patient_casestudy_three);
				// $sheet->setCellValue('AU'.$excel_row, $r->patient_casestudy_four);
				// $sheet->setCellValue('AV'.$excel_row, $r->social_casestudy_one);
				// $sheet->setCellValue('AW'.$excel_row, $r->social_casestudy_two);
				// $sheet->setCellValue('AX'.$excel_row, $r->social_casestudy_three);
				// $sheet->setCellValue('AY'.$excel_row, $r->social_casestudy_four);
				// $sheet->setCellValue('AZ'.$excel_row, $supportingDocument1);
				// $sheet->setCellValue('BA'.$excel_row, $supportingDocument2);

				$excel_row++;
				$nos++;
			}
		}
		//ob_clean();
		$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Applications Master Edition.xlsx"'); 
		header('Cache-Control: max-age=0');

		// download file 
		$writer->save('php://output'); 
	}
	
	function applicationSaved(){

		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
		$spreadsheet->getProperties()->setCreator('Global Nursing Award 2024')
			->setLastModifiedBy('Global Nursing Award 2024')
			->setTitle('Applications Master')
			->setSubject('')
			->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:CG1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A','AS') as $columnID){
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}

		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Date');
		$sheet->setCellValue('C1', 'Application Status');
		$sheet->setCellValue('D1', 'EY Assessment');
		$sheet->setCellValue('E1', 'Application Number');
		$sheet->setCellValue('F1', 'Application Code');
		$sheet->setCellValue('G1', 'Language');
		$sheet->setCellValue('H1', 'First name');
		$sheet->setCellValue('I1', 'Middle name');
		$sheet->setCellValue('J1', 'Last name');
		$sheet->setCellValue('K1', 'Email');
		$sheet->setCellValue('L1', 'Date of Birth');
		$sheet->setCellValue('M1', 'Country');
		$sheet->setCellValue('N1', 'Region');
		$sheet->setCellValue('O1', 'Contact No');
		$sheet->setCellValue('P1', 'Gender');
		$sheet->setCellValue('Q1', 'Address');
		$sheet->setCellValue('R1', 'Register as');
		$sheet->setCellValue('S1', 'Institute / hospital name');
		$sheet->setCellValue('T1', 'Contact Email ID');
		$sheet->setCellValue('U1', 'Contact Number');
		$sheet->setCellValue('V1', 'Website link');
		$sheet->setCellValue('W1', 'Total years of work experience as a Nurse');
		$sheet->setCellValue('X1', 'Years of experience in the current institute/hospital');

		$sheet->setCellValue('Y1', 'Educational Qualification (Highest degree)');
		$sheet->setCellValue('Z1', 'Educational Qualification Document');
		$sheet->setCellValue('AA1', 'Medical/Nurse council registration name');
		$sheet->setCellValue('AB1', 'Medical/Nurse council registration number');
		$sheet->setCellValue('AC1', 'Medical/Nurse council registration document');
		$sheet->setCellValue('AD1', 'Passport front copy');
		$sheet->setCellValue('AE1', 'Passport back copy');
		$sheet->setCellValue('AF1', 'Passport size Photograph');
		$sheet->setCellValue('AG1', 'Valid national proof of identity of the country/region you are applying from (Govt. ID)');
		$sheet->setCellValue('AH1', 'National proof of identity document');
		$sheet->setCellValue('AI1', 'Proof of employment');
		$sheet->setCellValue('AJ1', 'Proof of employment document');
		$sheet->setCellValue('AK1', 'Self declaration document');		

		$sheet->setCellValue('AL1', 'Selected Segment');
		$sheet->setCellValue('AM1', 'Primary Segment');
		$sheet->setCellValue('AN1', 'Secondary Segment');
		$sheet->setCellValue('AO1', 'Patient Experience');
		$sheet->setCellValue('AP1', 'Patient care in your daily work environment');
		$sheet->setCellValue('AQ1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('AR1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('AS1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('AT1', 'Leadership Experience');
		$sheet->setCellValue('AU1', 'Patient care in your daily work environment');
		$sheet->setCellValue('AV1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('AW1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('AX1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('AY1', 'Education Experience');
		$sheet->setCellValue('AZ1', 'Patient care in your daily work environment');
		$sheet->setCellValue('BA1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('BB1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('BC1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('BD1', 'Social Experience');
		$sheet->setCellValue('BE1', 'Patient care in your daily work environment');
		$sheet->setCellValue('BF1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('BG1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('BH1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('BI1', 'Research Experience');
		$sheet->setCellValue('BJ1', 'Patient care in your daily work environment');
		$sheet->setCellValue('BK1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('BL1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('BM1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');
		
		$sheet->setCellValue('BN1', 'First Referrer full name');
		$sheet->setCellValue('BO1', 'Referrer email ID');
		$sheet->setCellValue('BP1', 'Referrer country');
		$sheet->setCellValue('BQ1', 'Referrer contact number');
		$sheet->setCellValue('BR1', 'Relationship with the reference');
		$sheet->setCellValue('BS1', 'Second Referrer full name');		
		$sheet->setCellValue('BT1', 'Referrer email ID');
		$sheet->setCellValue('BU1', 'Referrer country');
		$sheet->setCellValue('BV1', 'Referrer contact number');
		$sheet->setCellValue('BW1', 'Relationship with the reference');

		$sheet->setCellValue('BX1', 'Collaterals doc 1');
		$sheet->setCellValue('BY1', 'Collaterals doc 2');
		$sheet->setCellValue('BZ1', 'Collaterals doc 3');
		$sheet->setCellValue('CA1', 'Awards/ certifications  doc 1 name');
		$sheet->setCellValue('CB1', 'Awards/ certifications  doc 1 ');
		$sheet->setCellValue('CC1', 'Awards/ certifications  doc 2 name');
		$sheet->setCellValue('CD1', 'Awards/ certifications  doc 2');
		$sheet->setCellValue('CE1', 'Awards/ certifications  doc 3 name');
		$sheet->setCellValue('CF1', 'Awards/ certifications  doc 3');

		$sheet->setCellValue('CG1', 'Reason');
		
		// $sheet->setCellValue('CJ1', 'Date and Time');


		// $sheet->setCellValue('AI1', 'Selected segments');
		// $sheet->setCellValue('AJ1', 'We believe nursing is about leading from the front. So, why would you consider yourself as a leader and what difference has that made?');
		// $sheet->setCellValue('AK1', 'Help us understand the challenges faced and how did you overcome the same');
		// $sheet->setCellValue('AL1', 'How do patients and peers respond to your leadership?');
		// $sheet->setCellValue('AM1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AN1', 'Describe your contributions to nursing research, policy, and/or practice at the local regional, state, and /or national level');
		// $sheet->setCellValue('AO1', 'Describe the challenges faced  and how did you overcome the same');
		// $sheet->setCellValue('AP1', 'Describe the impact of the initiative on the patients, employer, peers, etc?');
		// $sheet->setCellValue('AQ1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AR1', 'Describe the initiatives undertaken to facilitate positive changes in the work environment and improve the quality of patient care');
		// $sheet->setCellValue('AS1', 'Describe the challenges faced  and how did you overcome the same');
		// $sheet->setCellValue('AT1', 'Describe the impact of the initiative on the patients, employer, peers, etc?');
		// $sheet->setCellValue('AU1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AV1', 'Describe the your contribution for the betterment of the community/society');
		// $sheet->setCellValue('AW1', 'Describe the challenges faced  and how did you overcome the same');
		// $sheet->setCellValue('AX1', 'Describe the impact of the initiative on the community and what was the change they witnessed?');
		// $sheet->setCellValue('AY1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AZ1', 'Awards and certifications');
		// $sheet->setCellValue('BA1', 'Awards and certifications');
 
		//$_APPLICATIONS_QUERY = "SELECT * FROM application_personal_details limit 12000";
		$_APPLICATIONS_QUERY = "SELECT a.applications_id, a.uid, a.`code`,a.application_number,a.first_name,
								a.middle_name,a.last_name,a.dob,a.country,a.region,a.phone_code,a.contact,a.address,a.gender,a.qualified_as,
								a.institute,
								a.organisation_phonecode,a.organisation_contact,a.organisation_email,a.organisation_website,a.total_exp,
								a.current_exp,a.ref_name_one,a.ref_designation_one,a.ref_email_one,a.ref_country_one,a.ref_phone_code_one,ref_contact_one,
								a.ref_rel_one,a.ref_name_two,a.ref_designation_two,a.ref_email_two,a.ref_country_two,
								a.ref_phone_code_two,a.ref_contact_two,a.ref_rel_two,a.ref_rel_other_two,a.`status`,a.step,
								a.ey_assessment,a.is_recommended,a.reason,a.`language`,a.created_at
								FROM application_personal_details as a where a.`status` = 'saved'";//limit 10000 offset 10000
		$records = $this->Mdl_excel->customQuery($_APPLICATIONS_QUERY);
		$excel_row = 2;
		$nos = 1;

		if( $records !== "NA" ){
			foreach($records as $r){

				$date = date("Y-m-d H:i:s", strtotime($r->created_at));
				$created_at = date("Y-m-d H:i:s", strtotime($r->created_at));
				$dob = date("Y-m-d", strtotime($r->dob));
				// $_APPLICATIONS_COUNTRY_QUERY = "select c.country_id,c.country_name,c.`code` from master_country as c where country_id = '".$r->country."'";
				// $country_data = $this->Mdl_excel->customQuery($_APPLICATIONS_COUNTRY_QUERY);
				// $country = $country_data !== "NA" ? $country_data[0]->country_name : "NA";
				// $refOneCountry = $country_data !== "NA" ? $country_data[0]->country_name : "NA";
				// $refTwoCountry = $country_data !== "NA" ? $country_data[0]->country_name : "NA";
				$country = Modules::run('api/application/personal/country',$r->country);
				$refOneCountry = Modules::run('api/application/personal/country',$r->ref_country_one);
				$refTwoCountry = Modules::run('api/application/personal/country',$r->ref_country_two);
				$casestudies = Modules::run('api/application/personal/caseStudies',$r->uid);
				if($casestudies != "NA"){
					$ledership_array = explode(',',$casestudies[0]->selected_segments);
					$leadership_segments = $casestudies[0]->selected_segments;
					$leadership_primary = $casestudies[0]->primary_segment;
					$leadership_secondary = $casestudies[0]->secondary_segment;
					$leadership_exp = $casestudies[0]->leadership_exp;
					if(in_array('leadership', $ledership_array)){
						
						if(!empty($casestudies[0]->leadership_one) && $casestudies[0]->leadership_one != ""){
							$leadership_one = json_decode($casestudies[0]->leadership_one);
							$leadership_one = $leadership_one->textEn;
							$leadership_two = json_decode($casestudies[0]->leadership_two);
							$leadership_two = $leadership_two->textEn;
							$leadership_three = json_decode($casestudies[0]->leadership_three);
							$leadership_three = $leadership_three->textEn;
							$leadership_four = json_decode($casestudies[0]->leadership_four);
							$leadership_four = $leadership_four->textEn;
							
						} else {
							$leadership_one = '';
							$leadership_two = '';
							$leadership_three = '';
							$leadership_four = '';
						}
					} else {
						$leadership_segments = '';
						$leadership_primary = '';
						$leadership_secondary = '';
						$leadership_exp = '';
						$leadership_one = '';
						$leadership_two = '';
						$leadership_three = '';
						$leadership_four = '';
					}
					$patient_array = explode(',',$casestudies[0]->selected_segments);
					//print_r($patient_array);
					//exit;
					if(in_array('patient', $patient_array)){
						$patient_segments = $casestudies[0]->selected_segments;
						$patient_primary = $casestudies[0]->primary_segment;
						$patient_secondary = $casestudies[0]->secondary_segment;
						$patient_exp = $casestudies[0]->patient_exp;
						if(!empty($casestudies[0]->patient_one) && $casestudies[0]->patient_one != ""){
							$patient_one = json_decode($casestudies[0]->patient_one);
							$patient_one = $patient_one->textEn;
							$patient_two = json_decode($casestudies[0]->patient_two);
							$patient_two = $patient_two->textEn;
							$patient_three = json_decode($casestudies[0]->patient_three);
							$patient_three = $patient_three->textEn;
							$patient_four = json_decode($casestudies[0]->patient_four);
							$patient_four = $patient_four->textEn;
							
						} else {
							$patient_one = '';
							$patient_two = '';
							$patient_three = '';
							$patient_four = '';
						}
					} else {
						$patient_segments = '';
						$patient_primary = '';
						$patient_secondary = '';
						$patient_exp = '';
						$patient_one = '';
						$patient_two = '';
						$patient_three = '';
						$patient_four = '';
					}

					$education_array = explode(',',$casestudies[0]->selected_segments);
					if(in_array('education', $education_array)){
						$education_segments = $casestudies[0]->selected_segments;
						$education_primary = $casestudies[0]->primary_segment;
						$education_secondary = $casestudies[0]->secondary_segment;
						$education_exp = $casestudies[0]->education_exp;
						if(!empty($casestudies[0]->education_one) && $casestudies[0]->education_one != ""){
							$education_one_t = json_decode($casestudies[0]->education_one);
							$education_one = $education_one_t->textEn;
							$education_two = json_decode($casestudies[0]->education_two);
							$education_two = $education_two->textEn;
							$education_three = json_decode($casestudies[0]->education_three);
							$education_three = $education_three->textEn;
							$education_four = json_decode($casestudies[0]->education_four);
							$education_four = $education_four->textEn;
						} else {
							$education_one = '';
							$education_two = '';
							$education_three = '';
							$education_four ='';
						}
					} else {
						$education_segments = '';
						$education_primary = '';
						$education_secondary = '';
						$education_exp = '';
						$education_one = '';
						$education_two = '';
						$education_three = '';
						$education_four ='';
					}
					
					$social_array = explode(',',$casestudies[0]->selected_segments);
					if(in_array('social', $social_array)){
						$social_segments = $casestudies[0]->selected_segments;
						$social_primary = $casestudies[0]->primary_segment;
						$social_secondary = $casestudies[0]->secondary_segment;
						$social_exp = $casestudies[0]->social_exp;
						if(!empty($casestudies[0]->social_one) && $casestudies[0]->social_one != ""){
							$social_one = json_decode($casestudies[0]->social_one);
							$social_one = $social_one->textEn;
							$social_two = json_decode($casestudies[0]->social_two);
							$social_two = $social_two->textEn;
							$social_three = json_decode($casestudies[0]->social_three);
							$social_three = $social_three->textEn;
							$social_four = json_decode($casestudies[0]->social_four);
							$social_four = $social_four->textEn;
	
						} else {
							$social_one = '';
							$social_two = '';
							$social_three = '';
							$social_four = '';
						}
					} else {
						$social_segments = '';
						$social_primary = '';
						$social_secondary = '';
						$social_exp = '';
						$social_one = '';
						$social_two = '';
						$social_three = '';
						$social_four = '';
					}
					
					$research_array = explode(',',$casestudies[0]->selected_segments);
					if(in_array('research', $research_array)){
						$research_segments = $casestudies[0]->selected_segments;
						$research_primary = $casestudies[0]->primary_segment;
						$research_secondary = $casestudies[0]->secondary_segment;
						$research_exp = $casestudies[0]->research_exp;
						if(!empty($casestudies[0]->research_one) && $casestudies[0]->research_one != ""){
							$research_one = json_decode($casestudies[0]->research_one);
							$research_one = $research_one->textEn;
							$research_two = json_decode($casestudies[0]->research_two);
							$research_two = $research_two->textEn;
							$research_three = json_decode($casestudies[0]->research_three);
							$research_three = $research_three->textEn;
							$research_four = json_decode($casestudies[0]->research_four);
							$research_four = $research_four->textEn;
	
						} else {
							$research_one = '';
							$research_two = '';
							$research_three = '';
							$research_four = '';
						}
					} else {
						$research_segments = '';
						$research_primary = '';
						$research_secondary = '';
						$research_exp = '';
						$research_one = '';
						$research_two = '';
						$research_three = '';
						$research_four = '';
					}
					
				} else {
					$leadership_segments = '';;
					$leadership_primary = '';
					$leadership_secondary = '';
					$leadership_exp = '';
					$leadership_one = '';
					$leadership_two = '';
					$leadership_three = '';
					$leadership_four = '';

					$patient_segments = '';
					$patient_primary = '';
					$patient_secondary = '';
					$patient_exp = '';					
					$patient_one = '';
					$patient_two = '';
					$patient_three = '';
					$patient_four = '';

					$education_segments = '';;
					$education_primary = '';
					$education_secondary = '';
					$education_exp = '';
					$education_one = '';
					$education_two = '';
					$education_three = '';
					$education_four ='';

					$social_segments = '';
					$social_primary = '';
					$social_secondary = '';
					$social_exp = '';
					$social_one = '';
					$social_two = '';
					$social_three = '';
					$social_four = '';

					$research_segments = '';;
					$research_primary = '';
					$research_secondary = '';
					$research_exp = '';
					$research_one = '';
					$research_two = '';
					$research_three = '';
					$research_four = '';
				}

				$nurse = $this->Mdl_excel->retrieveByCol("email", "registration", array("uid"=>$r->uid));
				$candEmail = $nurse !== "NA" ? $nurse[0]->email : "";

				$_APPLICATIONS_DOCUMENTS_QUERY = "select ad.document_id,ad.uid,ad.`code`,ad.degree_name,ad.degree_file_name,
								ad.degree_file_path,ad.passport_front_file_name,ad.passport_front_file_path,ad.passport_back_file_name,
								ad.passport_back_file_path,ad.nursepic_name,ad.nursepic_path,ad.council_name,ad.council_registration,
								ad.medical_file_name,ad.medical_file_path,ad.proof_name,ad.proof_file_name,ad.proof_file_path,ad.proof_type,
								ad.employment_name,ad.employment_file_name,ad.employment_file_path,ad.declaration_name,ad.declaration_file_name,
								ad.declaration_file_path,ad.award_one,ad.award_one_name,ad.award_one_path,ad.award_two,ad.award_two_name,
								ad.award_two_path,ad.award_three,ad.award_three_name,ad.award_three_path,ad.sup_file_one_name,ad.sup_file_one_path,
								ad.sup_file_two_name,ad.sup_file_two_path,ad.sup_file_three_name,ad.sup_file_three_path,ad.created_at
								from application_documents as ad where ad.uid= '".$r->uid."' and ad.`code` = '".$r->code."'";
				$documents = $this->Mdl_excel->customQuery($_APPLICATIONS_DOCUMENTS_QUERY);
				// $documents = $this->Mdl_excel->retrieve(
				// 	"application_documents", 
				// 	array(
				// 		"uid" => $r->uid,
				// 		"code" => $r->code
				// 	)
				// );

				$degreeName = $documents !== "NA" ? $documents[0]->degree_name : "";
				$degreeDocumentName = $documents !== "NA" ? $documents[0]->degree_file_name : "";
				$degreeDocument =  $documents !== "NA" && $documents[0]->degree_file_path !== "" ? base_url().$documents[0]->degree_file_path : "";

				$councilName = $documents !== "NA" ? $documents[0]->council_name : "";
				$councilRegistration = $documents !== "NA" ? $documents[0]->council_registration : "";
				$medicalDocumentName = $documents !== "NA" ? $documents[0]->medical_file_name : "";
				$medicalDocument = $documents !== "NA" && $documents[0]->medical_file_path !== "" ? base_url().$documents[0]->medical_file_path : "";

				$passportFrontDocumentName = $documents !== "NA" ? $documents[0]->passport_front_file_name : "";
				$passportFrontDocument = $documents !== "NA" && $documents[0]->passport_front_file_path !== "" ? base_url().$documents[0]->passport_front_file_path : "";

				$passportBackDocumentName = $documents !== "NA" ? $documents[0]->passport_back_file_name : "";
				$passportBackDocument = $documents !== "NA" && $documents[0]->passport_back_file_path !== "" ? base_url().$documents[0]->passport_back_file_path : "";
				
				$nursePicName = $documents !== "NA" ? $documents[0]->nursepic_name : "";
				$nursePic = $documents !== "NA" && $documents[0]->nursepic_path !== "" ? base_url().$documents[0]->nursepic_path : "";

				$proofName = $documents !== "NA" ? $documents[0]->proof_name : "";
				$proofDocumentName = $documents !== "NA" ? $documents[0]->proof_file_name : "";
				$proofDocument = $documents !== "NA" && $documents[0]->proof_file_path !== "" ? base_url().$documents[0]->proof_file_path : "";

				$employmentName = $documents !== "NA" ? $documents[0]->employment_name : "";
				$employmentDocumentName = $documents !== "NA" ? $documents[0]->employment_file_name : "";
				$employmentDocument = $documents !== "NA" && $documents[0]->employment_file_path !== "" ? base_url().$documents[0]->employment_file_path : "";

				$declarationDocumentName = $documents !== "NA" ? $documents[0]->proof_name : "";
				$declarationDocument = $documents !== "NA" && $documents[0]->declaration_file_path !== "" ? base_url().$documents[0]->declaration_file_path : "";

				$award_one = $documents !== "NA" ? $documents[0]->award_one : "";
				$award_one_name = $documents !== "NA" && $documents[0]->award_one_name !== "" ? $documents[0]->award_one_name : "";

				$award_two = $documents !== "NA" ? $documents[0]->award_two : "";
				$award_two_name = $documents !== "NA" && $documents[0]->award_two_name !== "" ? $documents[0]->award_two_name : "";

				$award_three = $documents !== "NA" ? $documents[0]->award_three : "";
				$award_three_name = $documents !== "NA" && $documents[0]->award_three_name !== "" ? $documents[0]->award_three_name : "";

				$sup_file_one_name = $documents !== "NA" && $documents[0]->sup_file_one_name !== "" ? $documents[0]->sup_file_one_name : "";
				$sup_file_two_name = $documents !== "NA" && $documents[0]->sup_file_two_name !== "" ? $documents[0]->sup_file_two_name : "";
				$sup_file_three_name = $documents !== "NA" && $documents[0]->sup_file_three_name !== "" ? $documents[0]->sup_file_three_name : "";
				// $segmentStr = "";
				// if( $r->selected_segments !== "" ){
				// 	$segmentsArr = explode(",", $r->selected_segments);
				// 	foreach($segmentsArr as $s){
				// 		$segmentStr .= $segmentStr !== "" ? ', ' : '';
				// 		switch($s){
				// 			case 'leadership': $segmentStr .= "Leadership"; break;
				// 			case 'patient': $segmentStr .= "Patient care"; break;
				// 			case 'research': $segmentStr .= "Research/innovation"; break;
				// 			case 'social': $segmentStr .= "Social/Community service"; break;
				// 		}
				// 	}
				// }

				// $supportingDocument1 = !is_null($r->award_one_path) && $r->award_one_path !== "" ? base_url().$r->award_one_path : "";
				// $supportingDocument2 = !is_null($r->award_two_path) && $r->award_two_path !== "" ? base_url().$r->award_two_path : "";

				$sheet->setCellValue('A'.$excel_row, $nos);
				$sheet->setCellValue('B'.$excel_row, $date);
				$sheet->setCellValue('C'.$excel_row, $r->status);
				$sheet->setCellValue('D'.$excel_row, ucfirst($r->ey_assessment));
				$sheet->setCellValue('E'.$excel_row, $r->application_number);
				$sheet->setCellValue('F'.$excel_row, $r->code);
				$sheet->setCellValue('G'.$excel_row, $r->language);
				$sheet->setCellValue('H'.$excel_row, $r->first_name);
				$sheet->setCellValue('I'.$excel_row, $r->middle_name);
				$sheet->setCellValue('J'.$excel_row, $r->last_name);
				$sheet->setCellValue('K'.$excel_row, $candEmail);
				$sheet->setCellValue('L'.$excel_row, $dob);
				$sheet->setCellValue('M'.$excel_row, $country);
				$sheet->setCellValue('N'.$excel_row, $r->region);
				$sheet->setCellValue('O'.$excel_row, $r->phone_code.'-'.$r->contact);
				$sheet->setCellValue('P'.$excel_row, $r->gender);
				$sheet->setCellValue('Q'.$excel_row, $r->address);
				$sheet->setCellValue('R'.$excel_row, $r->qualified_as);
				$sheet->setCellValue('S'.$excel_row, $r->institute);
				$sheet->setCellValue('T'.$excel_row, $r->organisation_email);
				$sheet->setCellValue('U'.$excel_row, $r->organisation_phonecode.'-'.$r->organisation_contact);
				$sheet->setCellValue('V'.$excel_row, $r->organisation_website);
				$sheet->setCellValue('W'.$excel_row, $r->total_exp);
				$sheet->setCellValue('X'.$excel_row, $r->current_exp);

				$sheet->setCellValue('Y'.$excel_row, $degreeName);
				$sheet->setCellValue('Z'.$excel_row, $degreeDocumentName);
				//$spreadsheet->getActiveSheet()->getCell('X'.$excel_row)->getHyperlink()->setUrl($degreeDocument);

				$sheet->setCellValue('AA'.$excel_row, $councilName);
				$sheet->setCellValue('AB'.$excel_row, $councilRegistration);
				$sheet->setCellValue('AC'.$excel_row, $medicalDocumentName);
				//$spreadsheet->getActiveSheet()->getCell('AA'.$excel_row)->getHyperlink()->setUrl($medicalDocument);

				$sheet->setCellValue('AD'.$excel_row, $passportFrontDocumentName);
				//$spreadsheet->getActiveSheet()->getCell('AB'.$excel_row)->getHyperlink()->setUrl($passportFrontDocument);

				$sheet->setCellValue('AE'.$excel_row, $passportBackDocumentName);
				//$sheet->getCell('AC'.$excel_row)->getHyperlink()->setUrl($passportBackDocument);

				$sheet->setCellValue('AF'.$excel_row, $nursePicName);
				//$sheet->getCell('AD'.$excel_row)->getHyperlink()->setUrl($nursePic);

				$sheet->setCellValue('AG'.$excel_row, $proofName);
				$sheet->setCellValue('AH'.$excel_row, $proofDocumentName);
				//$sheet->getCell('AF'.$excel_row)->getHyperlink()->setUrl($proofDocument);
				
				$sheet->setCellValue('AI'.$excel_row, $employmentName);
				$sheet->setCellValue('AJ'.$excel_row, $employmentDocumentName);
				//$sheet->getCell('AH'.$excel_row)->getHyperlink()->setUrl($employmentDocument);

				$sheet->setCellValue('AK'.$excel_row, $declarationDocumentName);
				//$sheet->getCell('AI'.$excel_row)->getHyperlink()->setUrl($declarationDocument);

				$sheet->setCellValue('AL'.$excel_row, $leadership_segments);
				$sheet->setCellValue('AM'.$excel_row, $leadership_primary);
				$sheet->setCellValue('AN'.$excel_row, $leadership_secondary);
				$sheet->setCellValue('AO'.$excel_row, $patient_exp);
				$sheet->setCellValue('AP'.$excel_row, $patient_one);
				$sheet->setCellValue('AQ'.$excel_row, $patient_two);
				$sheet->setCellValue('AR'.$excel_row, $patient_three);
				$sheet->setCellValue('AS'.$excel_row, $patient_four);

				$sheet->setCellValue('AT'.$excel_row, $leadership_exp);
				$sheet->setCellValue('AU'.$excel_row, $leadership_one);
				$sheet->setCellValue('AV'.$excel_row, $leadership_two);
				$sheet->setCellValue('AW'.$excel_row, $leadership_three);
				$sheet->setCellValue('AX'.$excel_row, $leadership_four);
				
				$sheet->setCellValue('AY'.$excel_row, $education_exp);
				$sheet->setCellValue('AZ'.$excel_row, $education_one);
				$sheet->setCellValue('BA'.$excel_row, $education_two);
				$sheet->setCellValue('BB'.$excel_row, $education_three);
				$sheet->setCellValue('BC'.$excel_row, $education_four);

				$sheet->setCellValue('BD'.$excel_row, $social_exp);
				$sheet->setCellValue('BE'.$excel_row, $social_one);
				$sheet->setCellValue('BF'.$excel_row, $social_two);
				$sheet->setCellValue('BG'.$excel_row, $social_three);
				$sheet->setCellValue('BH'.$excel_row, $social_four);

				$sheet->setCellValue('BI'.$excel_row, $research_exp);
				$sheet->setCellValue('BJ'.$excel_row, $research_one);
				$sheet->setCellValue('BK'.$excel_row, $research_two);
				$sheet->setCellValue('BL'.$excel_row, $research_three);
				$sheet->setCellValue('BM'.$excel_row, $research_four);

				$sheet->setCellValue('BN'.$excel_row, $r->ref_name_one);
				$sheet->setCellValue('BO'.$excel_row, $r->ref_email_one);
				$sheet->setCellValue('BP'.$excel_row, $refOneCountry);
				$sheet->setCellValue('BQ'.$excel_row, $r->ref_phone_code_one.'-'.$r->ref_contact_one);
				$sheet->setCellValue('BR'.$excel_row, $r->ref_rel_one);
				$sheet->setCellValue('BS'.$excel_row, $r->ref_name_two);
				$sheet->setCellValue('BT'.$excel_row, $r->ref_email_two);
				$sheet->setCellValue('BU'.$excel_row, $refTwoCountry);
				$sheet->setCellValue('BV'.$excel_row, $r->ref_phone_code_two.'-'.$r->ref_contact_two);
				$sheet->setCellValue('BW'.$excel_row, $r->ref_rel_two);

				$sheet->setCellValue('BX'.$excel_row, $sup_file_one_name);
				$sheet->setCellValue('BY'.$excel_row, $sup_file_two_name);
				$sheet->setCellValue('BZ'.$excel_row, $sup_file_three_name);
				$sheet->setCellValue('CA'.$excel_row, $award_one);
				$sheet->setCellValue('CB'.$excel_row, $award_one_name);
				$sheet->setCellValue('CC'.$excel_row, $award_two);
				$sheet->setCellValue('CD'.$excel_row, $award_two_name);
				$sheet->setCellValue('CE'.$excel_row, $award_three);
				$sheet->setCellValue('CF'.$excel_row, $award_three_name);
				$sheet->setCellValue('CG'.$excel_row, $r->reason);
				// $sheet->setCellValue('CJ'.$excel_row, $created_at);
				
				
				// $sheet->setCellValue('AI'.$excel_row, $segmentStr);
				// $sheet->setCellValue('AJ'.$excel_row, $r->leadership_casestudy_one);
				// $sheet->setCellValue('AK'.$excel_row, $r->leadership_casestudy_two);
				// $sheet->setCellValue('AL'.$excel_row, $r->leadership_casestudy_three);
				// $sheet->setCellValue('AM'.$excel_row, $r->leadership_casestudy_four);
				// $sheet->setCellValue('AN'.$excel_row, $r->research_casestudy_one);
				// $sheet->setCellValue('AO'.$excel_row, $r->research_casestudy_two);
				// $sheet->setCellValue('AP'.$excel_row, $r->research_casestudy_three);
				// $sheet->setCellValue('AQ'.$excel_row, $r->research_casestudy_four);
				// $sheet->setCellValue('AR'.$excel_row, $r->patient_casestudy_one);
				// $sheet->setCellValue('AS'.$excel_row, $r->patient_casestudy_two);
				// $sheet->setCellValue('AT'.$excel_row, $r->patient_casestudy_three);
				// $sheet->setCellValue('AU'.$excel_row, $r->patient_casestudy_four);
				// $sheet->setCellValue('AV'.$excel_row, $r->social_casestudy_one);
				// $sheet->setCellValue('AW'.$excel_row, $r->social_casestudy_two);
				// $sheet->setCellValue('AX'.$excel_row, $r->social_casestudy_three);
				// $sheet->setCellValue('AY'.$excel_row, $r->social_casestudy_four);
				// $sheet->setCellValue('AZ'.$excel_row, $supportingDocument1);
				// $sheet->setCellValue('BA'.$excel_row, $supportingDocument2);

				$excel_row++;
				$nos++;
			}
		}
		//ob_clean();
		$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Applications Master Saved Applicatios.xlsx"'); 
		header('Cache-Control: max-age=0');

		// download file 
		$writer->save('php://output'); 
	} 

	function applicationSubmitted(){

		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
		$spreadsheet->getProperties()->setCreator('Global Nursing Award 2024')
			->setLastModifiedBy('Global Nursing Award 2024')
			->setTitle('Applications Master')
			->setSubject('')
			->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:CG1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A','AS') as $columnID){
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}

		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Date');
		$sheet->setCellValue('C1', 'Application Status');
		$sheet->setCellValue('D1', 'EY Assessment');
		$sheet->setCellValue('E1', 'Application Number');
		$sheet->setCellValue('F1', 'Application Code');
		$sheet->setCellValue('G1', 'Language');
		$sheet->setCellValue('H1', 'First name');
		$sheet->setCellValue('I1', 'Middle name');
		$sheet->setCellValue('J1', 'Last name');
		$sheet->setCellValue('K1', 'Email');
		$sheet->setCellValue('L1', 'Date of Birth');
		$sheet->setCellValue('M1', 'Country');
		$sheet->setCellValue('N1', 'Region');
		$sheet->setCellValue('O1', 'Contact No');
		$sheet->setCellValue('P1', 'Gender');
		$sheet->setCellValue('Q1', 'Address');
		$sheet->setCellValue('R1', 'Register as');
		$sheet->setCellValue('S1', 'Institute / hospital name');
		$sheet->setCellValue('T1', 'Contact Email ID');
		$sheet->setCellValue('U1', 'Contact Number');
		$sheet->setCellValue('V1', 'Website link');
		$sheet->setCellValue('W1', 'Total years of work experience as a Nurse');
		$sheet->setCellValue('X1', 'Years of experience in the current institute/hospital');

		$sheet->setCellValue('Y1', 'Educational Qualification (Highest degree)');
		$sheet->setCellValue('Z1', 'Educational Qualification Document');
		$sheet->setCellValue('AA1', 'Medical/Nurse council registration name');
		$sheet->setCellValue('AB1', 'Medical/Nurse council registration number');
		$sheet->setCellValue('AC1', 'Medical/Nurse council registration document');
		$sheet->setCellValue('AD1', 'Passport front copy');
		$sheet->setCellValue('AE1', 'Passport back copy');
		$sheet->setCellValue('AF1', 'Passport size Photograph');
		$sheet->setCellValue('AG1', 'Valid national proof of identity of the country/region you are applying from (Govt. ID)');
		$sheet->setCellValue('AH1', 'National proof of identity document');
		$sheet->setCellValue('AI1', 'Proof of employment');
		$sheet->setCellValue('AJ1', 'Proof of employment document');
		$sheet->setCellValue('AK1', 'Self declaration document');		

		$sheet->setCellValue('AL1', 'Selected Segment');
		$sheet->setCellValue('AM1', 'Primary Segment');
		$sheet->setCellValue('AN1', 'Secondary Segment');
		$sheet->setCellValue('AO1', 'Patient Experience');
		$sheet->setCellValue('AP1', 'Patient care in your daily work environment');
		$sheet->setCellValue('AQ1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('AR1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('AS1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('AT1', 'Leadership Experience');
		$sheet->setCellValue('AU1', 'Patient care in your daily work environment');
		$sheet->setCellValue('AV1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('AW1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('AX1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('AY1', 'Education Experience');
		$sheet->setCellValue('AZ1', 'Patient care in your daily work environment');
		$sheet->setCellValue('BA1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('BB1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('BC1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('BD1', 'Social Experience');
		$sheet->setCellValue('BE1', 'Patient care in your daily work environment');
		$sheet->setCellValue('BF1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('BG1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('BH1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('BI1', 'Research Experience');
		$sheet->setCellValue('BJ1', 'Patient care in your daily work environment');
		$sheet->setCellValue('BK1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('BL1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('BM1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');
		
		$sheet->setCellValue('BN1', 'First Referrer full name');
		$sheet->setCellValue('BO1', 'Referrer email ID');
		$sheet->setCellValue('BP1', 'Referrer country');
		$sheet->setCellValue('BQ1', 'Referrer contact number');
		$sheet->setCellValue('BR1', 'Relationship with the reference');
		$sheet->setCellValue('BS1', 'Second Referrer full name');		
		$sheet->setCellValue('BT1', 'Referrer email ID');
		$sheet->setCellValue('BU1', 'Referrer country');
		$sheet->setCellValue('BV1', 'Referrer contact number');
		$sheet->setCellValue('BW1', 'Relationship with the reference');

		$sheet->setCellValue('BX1', 'Collaterals doc 1');
		$sheet->setCellValue('BY1', 'Collaterals doc 2');
		$sheet->setCellValue('BZ1', 'Collaterals doc 3');
		$sheet->setCellValue('CA1', 'Awards/ certifications  doc 1 name');
		$sheet->setCellValue('CB1', 'Awards/ certifications  doc 1 ');
		$sheet->setCellValue('CC1', 'Awards/ certifications  doc 2 name');
		$sheet->setCellValue('CD1', 'Awards/ certifications  doc 2');
		$sheet->setCellValue('CE1', 'Awards/ certifications  doc 3 name');
		$sheet->setCellValue('CF1', 'Awards/ certifications  doc 3');

		$sheet->setCellValue('CG1', 'Reason');
		
		// $sheet->setCellValue('CJ1', 'Date and Time');


		// $sheet->setCellValue('AI1', 'Selected segments');
		// $sheet->setCellValue('AJ1', 'We believe nursing is about leading from the front. So, why would you consider yourself as a leader and what difference has that made?');
		// $sheet->setCellValue('AK1', 'Help us understand the challenges faced and how did you overcome the same');
		// $sheet->setCellValue('AL1', 'How do patients and peers respond to your leadership?');
		// $sheet->setCellValue('AM1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AN1', 'Describe your contributions to nursing research, policy, and/or practice at the local regional, state, and /or national level');
		// $sheet->setCellValue('AO1', 'Describe the challenges faced  and how did you overcome the same');
		// $sheet->setCellValue('AP1', 'Describe the impact of the initiative on the patients, employer, peers, etc?');
		// $sheet->setCellValue('AQ1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AR1', 'Describe the initiatives undertaken to facilitate positive changes in the work environment and improve the quality of patient care');
		// $sheet->setCellValue('AS1', 'Describe the challenges faced  and how did you overcome the same');
		// $sheet->setCellValue('AT1', 'Describe the impact of the initiative on the patients, employer, peers, etc?');
		// $sheet->setCellValue('AU1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AV1', 'Describe the your contribution for the betterment of the community/society');
		// $sheet->setCellValue('AW1', 'Describe the challenges faced  and how did you overcome the same');
		// $sheet->setCellValue('AX1', 'Describe the impact of the initiative on the community and what was the change they witnessed?');
		// $sheet->setCellValue('AY1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AZ1', 'Awards and certifications');
		// $sheet->setCellValue('BA1', 'Awards and certifications');
 
		//$_APPLICATIONS_QUERY = "SELECT * FROM application_personal_details limit 12000";
		$_APPLICATIONS_QUERY = "SELECT a.applications_id, a.uid, a.`code`,a.application_number,a.first_name,
								a.middle_name,a.last_name,a.dob,a.country,a.region,a.phone_code,a.contact,a.address,a.gender,a.qualified_as,
								a.institute,
								a.organisation_phonecode,a.organisation_contact,a.organisation_email,a.organisation_website,a.total_exp,
								a.current_exp,a.ref_name_one,a.ref_designation_one,a.ref_email_one,a.ref_country_one,a.ref_phone_code_one,ref_contact_one,
								a.ref_rel_one,a.ref_name_two,a.ref_designation_two,a.ref_email_two,a.ref_country_two,
								a.ref_phone_code_two,a.ref_contact_two,a.ref_rel_two,a.ref_rel_other_two,a.`status`,a.step,
								a.ey_assessment,a.is_recommended,a.reason,a.`language`,a.created_at
								FROM application_personal_details as a where a.`status` = 'submitted'";//limit 10000 offset 10000
		$records = $this->Mdl_excel->customQuery($_APPLICATIONS_QUERY);
		$excel_row = 2;
		$nos = 1;

		if( $records !== "NA" ){
			foreach($records as $r){

				$date = date("Y-m-d H:i:s", strtotime($r->created_at));
				$created_at = date("Y-m-d H:i:s", strtotime($r->created_at));
				$dob = date("Y-m-d", strtotime($r->dob));
				// $_APPLICATIONS_COUNTRY_QUERY = "select c.country_id,c.country_name,c.`code` from master_country as c where country_id = '".$r->country."'";
				// $country_data = $this->Mdl_excel->customQuery($_APPLICATIONS_COUNTRY_QUERY);
				// $country = $country_data !== "NA" ? $country_data[0]->country_name : "NA";
				// $refOneCountry = $country_data !== "NA" ? $country_data[0]->country_name : "NA";
				// $refTwoCountry = $country_data !== "NA" ? $country_data[0]->country_name : "NA";
				$country = Modules::run('api/application/personal/country',$r->country);
				$refOneCountry = Modules::run('api/application/personal/country',$r->ref_country_one);
				$refTwoCountry = Modules::run('api/application/personal/country',$r->ref_country_two);
				$casestudies = Modules::run('api/application/personal/caseStudies',$r->uid);
				if($casestudies != "NA"){
					$ledership_array = explode(',',$casestudies[0]->selected_segments);
					$leadership_segments = $casestudies[0]->selected_segments;
					$leadership_primary = $casestudies[0]->primary_segment;
					$leadership_secondary = $casestudies[0]->secondary_segment;
					$leadership_exp = $casestudies[0]->leadership_exp;
					if(in_array('leadership', $ledership_array)){
						
						if(!empty($casestudies[0]->leadership_one) && $casestudies[0]->leadership_one != ""){
							$leadership_one = json_decode($casestudies[0]->leadership_one);
							$leadership_one = $leadership_one->textEn;
							$leadership_two = json_decode($casestudies[0]->leadership_two);
							$leadership_two = $leadership_two->textEn;
							$leadership_three = json_decode($casestudies[0]->leadership_three);
							$leadership_three = $leadership_three->textEn;
							$leadership_four = json_decode($casestudies[0]->leadership_four);
							$leadership_four = $leadership_four->textEn;
							
						} else {
							$leadership_one = '';
							$leadership_two = '';
							$leadership_three = '';
							$leadership_four = '';
						}
					} else {
						$leadership_segments = '';
						$leadership_primary = '';
						$leadership_secondary = '';
						$leadership_exp = '';
						$leadership_one = '';
						$leadership_two = '';
						$leadership_three = '';
						$leadership_four = '';
					}
					$patient_array = explode(',',$casestudies[0]->selected_segments);
					//print_r($patient_array);
					//exit;
					if(in_array('patient', $patient_array)){
						$patient_segments = $casestudies[0]->selected_segments;
						$patient_primary = $casestudies[0]->primary_segment;
						$patient_secondary = $casestudies[0]->secondary_segment;
						$patient_exp = $casestudies[0]->patient_exp;
						if(!empty($casestudies[0]->patient_one) && $casestudies[0]->patient_one != ""){
							$patient_one = json_decode($casestudies[0]->patient_one);
							$patient_one = $patient_one->textEn;
							$patient_two = json_decode($casestudies[0]->patient_two);
							$patient_two = $patient_two->textEn;
							$patient_three = json_decode($casestudies[0]->patient_three);
							$patient_three = $patient_three->textEn;
							$patient_four = json_decode($casestudies[0]->patient_four);
							$patient_four = $patient_four->textEn;
							
						} else {
							$patient_one = '';
							$patient_two = '';
							$patient_three = '';
							$patient_four = '';
						}
					} else {
						$patient_segments = '';
						$patient_primary = '';
						$patient_secondary = '';
						$patient_exp = '';
						$patient_one = '';
						$patient_two = '';
						$patient_three = '';
						$patient_four = '';
					}

					$education_array = explode(',',$casestudies[0]->selected_segments);
					if(in_array('education', $education_array)){
						$education_segments = $casestudies[0]->selected_segments;
						$education_primary = $casestudies[0]->primary_segment;
						$education_secondary = $casestudies[0]->secondary_segment;
						$education_exp = $casestudies[0]->education_exp;
						if(!empty($casestudies[0]->education_one) && $casestudies[0]->education_one != ""){
							$education_one_t = json_decode($casestudies[0]->education_one);
							$education_one = $education_one_t->textEn;
							$education_two = json_decode($casestudies[0]->education_two);
							$education_two = $education_two->textEn;
							$education_three = json_decode($casestudies[0]->education_three);
							$education_three = $education_three->textEn;
							$education_four = json_decode($casestudies[0]->education_four);
							$education_four = $education_four->textEn;
						} else {
							$education_one = '';
							$education_two = '';
							$education_three = '';
							$education_four ='';
						}
					} else {
						$education_segments = '';
						$education_primary = '';
						$education_secondary = '';
						$education_exp = '';
						$education_one = '';
						$education_two = '';
						$education_three = '';
						$education_four ='';
					}
					
					$social_array = explode(',',$casestudies[0]->selected_segments);
					if(in_array('social', $social_array)){
						$social_segments = $casestudies[0]->selected_segments;
						$social_primary = $casestudies[0]->primary_segment;
						$social_secondary = $casestudies[0]->secondary_segment;
						$social_exp = $casestudies[0]->social_exp;
						if(!empty($casestudies[0]->social_one) && $casestudies[0]->social_one != ""){
							$social_one = json_decode($casestudies[0]->social_one);
							$social_one = $social_one->textEn;
							$social_two = json_decode($casestudies[0]->social_two);
							$social_two = $social_two->textEn;
							$social_three = json_decode($casestudies[0]->social_three);
							$social_three = $social_three->textEn;
							$social_four = json_decode($casestudies[0]->social_four);
							$social_four = $social_four->textEn;
	
						} else {
							$social_one = '';
							$social_two = '';
							$social_three = '';
							$social_four = '';
						}
					} else {
						$social_segments = '';
						$social_primary = '';
						$social_secondary = '';
						$social_exp = '';
						$social_one = '';
						$social_two = '';
						$social_three = '';
						$social_four = '';
					}
					
					$research_array = explode(',',$casestudies[0]->selected_segments);
					if(in_array('research', $research_array)){
						$research_segments = $casestudies[0]->selected_segments;
						$research_primary = $casestudies[0]->primary_segment;
						$research_secondary = $casestudies[0]->secondary_segment;
						$research_exp = $casestudies[0]->research_exp;
						if(!empty($casestudies[0]->research_one) && $casestudies[0]->research_one != ""){
							$research_one = json_decode($casestudies[0]->research_one);
							$research_one = $research_one->textEn;
							$research_two = json_decode($casestudies[0]->research_two);
							$research_two = $research_two->textEn;
							$research_three = json_decode($casestudies[0]->research_three);
							$research_three = $research_three->textEn;
							$research_four = json_decode($casestudies[0]->research_four);
							$research_four = $research_four->textEn;
	
						} else {
							$research_one = '';
							$research_two = '';
							$research_three = '';
							$research_four = '';
						}
					} else {
						$research_segments = '';
						$research_primary = '';
						$research_secondary = '';
						$research_exp = '';
						$research_one = '';
						$research_two = '';
						$research_three = '';
						$research_four = '';
					}
					
				} else {
					$leadership_segments = '';;
					$leadership_primary = '';
					$leadership_secondary = '';
					$leadership_exp = '';
					$leadership_one = '';
					$leadership_two = '';
					$leadership_three = '';
					$leadership_four = '';

					$patient_segments = '';
					$patient_primary = '';
					$patient_secondary = '';
					$patient_exp = '';					
					$patient_one = '';
					$patient_two = '';
					$patient_three = '';
					$patient_four = '';

					$education_segments = '';;
					$education_primary = '';
					$education_secondary = '';
					$education_exp = '';
					$education_one = '';
					$education_two = '';
					$education_three = '';
					$education_four ='';

					$social_segments = '';
					$social_primary = '';
					$social_secondary = '';
					$social_exp = '';
					$social_one = '';
					$social_two = '';
					$social_three = '';
					$social_four = '';

					$research_segments = '';;
					$research_primary = '';
					$research_secondary = '';
					$research_exp = '';
					$research_one = '';
					$research_two = '';
					$research_three = '';
					$research_four = '';
				}

				$nurse = $this->Mdl_excel->retrieveByCol("email", "registration", array("uid"=>$r->uid));
				$candEmail = $nurse !== "NA" ? $nurse[0]->email : "";

				$_APPLICATIONS_DOCUMENTS_QUERY = "select ad.document_id,ad.uid,ad.`code`,ad.degree_name,ad.degree_file_name,
								ad.degree_file_path,ad.passport_front_file_name,ad.passport_front_file_path,ad.passport_back_file_name,
								ad.passport_back_file_path,ad.nursepic_name,ad.nursepic_path,ad.council_name,ad.council_registration,
								ad.medical_file_name,ad.medical_file_path,ad.proof_name,ad.proof_file_name,ad.proof_file_path,ad.proof_type,
								ad.employment_name,ad.employment_file_name,ad.employment_file_path,ad.declaration_name,ad.declaration_file_name,
								ad.declaration_file_path,ad.award_one,ad.award_one_name,ad.award_one_path,ad.award_two,ad.award_two_name,
								ad.award_two_path,ad.award_three,ad.award_three_name,ad.award_three_path,ad.sup_file_one_name,ad.sup_file_one_path,
								ad.sup_file_two_name,ad.sup_file_two_path,ad.sup_file_three_name,ad.sup_file_three_path,ad.created_at
								from application_documents as ad where ad.uid= '".$r->uid."' and ad.`code` = '".$r->code."'";
				$documents = $this->Mdl_excel->customQuery($_APPLICATIONS_DOCUMENTS_QUERY);
				// $documents = $this->Mdl_excel->retrieve(
				// 	"application_documents", 
				// 	array(
				// 		"uid" => $r->uid,
				// 		"code" => $r->code
				// 	)
				// );

				$degreeName = $documents !== "NA" ? $documents[0]->degree_name : "";
				$degreeDocumentName = $documents !== "NA" ? $documents[0]->degree_file_name : "";
				$degreeDocument =  $documents !== "NA" && $documents[0]->degree_file_path !== "" ? base_url().$documents[0]->degree_file_path : "";

				$councilName = $documents !== "NA" ? $documents[0]->council_name : "";
				$councilRegistration = $documents !== "NA" ? $documents[0]->council_registration : "";
				$medicalDocumentName = $documents !== "NA" ? $documents[0]->medical_file_name : "";
				$medicalDocument = $documents !== "NA" && $documents[0]->medical_file_path !== "" ? base_url().$documents[0]->medical_file_path : "";

				$passportFrontDocumentName = $documents !== "NA" ? $documents[0]->passport_front_file_name : "";
				$passportFrontDocument = $documents !== "NA" && $documents[0]->passport_front_file_path !== "" ? base_url().$documents[0]->passport_front_file_path : "";

				$passportBackDocumentName = $documents !== "NA" ? $documents[0]->passport_back_file_name : "";
				$passportBackDocument = $documents !== "NA" && $documents[0]->passport_back_file_path !== "" ? base_url().$documents[0]->passport_back_file_path : "";
				
				$nursePicName = $documents !== "NA" ? $documents[0]->nursepic_name : "";
				$nursePic = $documents !== "NA" && $documents[0]->nursepic_path !== "" ? base_url().$documents[0]->nursepic_path : "";

				$proofName = $documents !== "NA" ? $documents[0]->proof_name : "";
				$proofDocumentName = $documents !== "NA" ? $documents[0]->proof_file_name : "";
				$proofDocument = $documents !== "NA" && $documents[0]->proof_file_path !== "" ? base_url().$documents[0]->proof_file_path : "";

				$employmentName = $documents !== "NA" ? $documents[0]->employment_name : "";
				$employmentDocumentName = $documents !== "NA" ? $documents[0]->employment_file_name : "";
				$employmentDocument = $documents !== "NA" && $documents[0]->employment_file_path !== "" ? base_url().$documents[0]->employment_file_path : "";

				$declarationDocumentName = $documents !== "NA" ? $documents[0]->proof_name : "";
				$declarationDocument = $documents !== "NA" && $documents[0]->declaration_file_path !== "" ? base_url().$documents[0]->declaration_file_path : "";

				$award_one = $documents !== "NA" ? $documents[0]->award_one : "";
				$award_one_name = $documents !== "NA" && $documents[0]->award_one_name !== "" ? $documents[0]->award_one_name : "";

				$award_two = $documents !== "NA" ? $documents[0]->award_two : "";
				$award_two_name = $documents !== "NA" && $documents[0]->award_two_name !== "" ? $documents[0]->award_two_name : "";

				$award_three = $documents !== "NA" ? $documents[0]->award_three : "";
				$award_three_name = $documents !== "NA" && $documents[0]->award_three_name !== "" ? $documents[0]->award_three_name : "";

				$sup_file_one_name = $documents !== "NA" && $documents[0]->sup_file_one_name !== "" ? $documents[0]->sup_file_one_name : "";
				$sup_file_two_name = $documents !== "NA" && $documents[0]->sup_file_two_name !== "" ? $documents[0]->sup_file_two_name : "";
				$sup_file_three_name = $documents !== "NA" && $documents[0]->sup_file_three_name !== "" ? $documents[0]->sup_file_three_name : "";
				// $segmentStr = "";
				// if( $r->selected_segments !== "" ){
				// 	$segmentsArr = explode(",", $r->selected_segments);
				// 	foreach($segmentsArr as $s){
				// 		$segmentStr .= $segmentStr !== "" ? ', ' : '';
				// 		switch($s){
				// 			case 'leadership': $segmentStr .= "Leadership"; break;
				// 			case 'patient': $segmentStr .= "Patient care"; break;
				// 			case 'research': $segmentStr .= "Research/innovation"; break;
				// 			case 'social': $segmentStr .= "Social/Community service"; break;
				// 		}
				// 	}
				// }

				// $supportingDocument1 = !is_null($r->award_one_path) && $r->award_one_path !== "" ? base_url().$r->award_one_path : "";
				// $supportingDocument2 = !is_null($r->award_two_path) && $r->award_two_path !== "" ? base_url().$r->award_two_path : "";

				$sheet->setCellValue('A'.$excel_row, $nos);
				$sheet->setCellValue('B'.$excel_row, $date);
				$sheet->setCellValue('C'.$excel_row, $r->status);
				$sheet->setCellValue('D'.$excel_row, ucfirst($r->ey_assessment));
				$sheet->setCellValue('E'.$excel_row, $r->application_number);
				$sheet->setCellValue('F'.$excel_row, $r->code);
				$sheet->setCellValue('G'.$excel_row, $r->language);
				$sheet->setCellValue('H'.$excel_row, $r->first_name);
				$sheet->setCellValue('I'.$excel_row, $r->middle_name);
				$sheet->setCellValue('J'.$excel_row, $r->last_name);
				$sheet->setCellValue('K'.$excel_row, $candEmail);
				$sheet->setCellValue('L'.$excel_row, $dob);
				$sheet->setCellValue('M'.$excel_row, $country);
				$sheet->setCellValue('N'.$excel_row, $r->region);
				$sheet->setCellValue('O'.$excel_row, $r->phone_code.'-'.$r->contact);
				$sheet->setCellValue('P'.$excel_row, $r->gender);
				$sheet->setCellValue('Q'.$excel_row, $r->address);
				$sheet->setCellValue('R'.$excel_row, $r->qualified_as);
				$sheet->setCellValue('S'.$excel_row, $r->institute);
				$sheet->setCellValue('T'.$excel_row, $r->organisation_email);
				$sheet->setCellValue('U'.$excel_row, $r->organisation_phonecode.'-'.$r->organisation_contact);
				$sheet->setCellValue('V'.$excel_row, $r->organisation_website);
				$sheet->setCellValue('W'.$excel_row, $r->total_exp);
				$sheet->setCellValue('X'.$excel_row, $r->current_exp);

				$sheet->setCellValue('Y'.$excel_row, $degreeName);
				$sheet->setCellValue('Z'.$excel_row, $degreeDocumentName);
				//$spreadsheet->getActiveSheet()->getCell('X'.$excel_row)->getHyperlink()->setUrl($degreeDocument);

				$sheet->setCellValue('AA'.$excel_row, $councilName);
				$sheet->setCellValue('AB'.$excel_row, $councilRegistration);
				$sheet->setCellValue('AC'.$excel_row, $medicalDocumentName);
				//$spreadsheet->getActiveSheet()->getCell('AA'.$excel_row)->getHyperlink()->setUrl($medicalDocument);

				$sheet->setCellValue('AD'.$excel_row, $passportFrontDocumentName);
				//$spreadsheet->getActiveSheet()->getCell('AB'.$excel_row)->getHyperlink()->setUrl($passportFrontDocument);

				$sheet->setCellValue('AE'.$excel_row, $passportBackDocumentName);
				//$sheet->getCell('AC'.$excel_row)->getHyperlink()->setUrl($passportBackDocument);

				$sheet->setCellValue('AF'.$excel_row, $nursePicName);
				//$sheet->getCell('AD'.$excel_row)->getHyperlink()->setUrl($nursePic);

				$sheet->setCellValue('AG'.$excel_row, $proofName);
				$sheet->setCellValue('AH'.$excel_row, $proofDocumentName);
				//$sheet->getCell('AF'.$excel_row)->getHyperlink()->setUrl($proofDocument);
				
				$sheet->setCellValue('AI'.$excel_row, $employmentName);
				$sheet->setCellValue('AJ'.$excel_row, $employmentDocumentName);
				//$sheet->getCell('AH'.$excel_row)->getHyperlink()->setUrl($employmentDocument);

				$sheet->setCellValue('AK'.$excel_row, $declarationDocumentName);
				//$sheet->getCell('AI'.$excel_row)->getHyperlink()->setUrl($declarationDocument);

				$sheet->setCellValue('AL'.$excel_row, $leadership_segments);
				$sheet->setCellValue('AM'.$excel_row, $leadership_primary);
				$sheet->setCellValue('AN'.$excel_row, $leadership_secondary);
				$sheet->setCellValue('AO'.$excel_row, $patient_exp);
				$sheet->setCellValue('AP'.$excel_row, $patient_one);
				$sheet->setCellValue('AQ'.$excel_row, $patient_two);
				$sheet->setCellValue('AR'.$excel_row, $patient_three);
				$sheet->setCellValue('AS'.$excel_row, $patient_four);

				$sheet->setCellValue('AT'.$excel_row, $leadership_exp);
				$sheet->setCellValue('AU'.$excel_row, $leadership_one);
				$sheet->setCellValue('AV'.$excel_row, $leadership_two);
				$sheet->setCellValue('AW'.$excel_row, $leadership_three);
				$sheet->setCellValue('AX'.$excel_row, $leadership_four);
				
				$sheet->setCellValue('AY'.$excel_row, $education_exp);
				$sheet->setCellValue('AZ'.$excel_row, $education_one);
				$sheet->setCellValue('BA'.$excel_row, $education_two);
				$sheet->setCellValue('BB'.$excel_row, $education_three);
				$sheet->setCellValue('BC'.$excel_row, $education_four);

				$sheet->setCellValue('BD'.$excel_row, $social_exp);
				$sheet->setCellValue('BE'.$excel_row, $social_one);
				$sheet->setCellValue('BF'.$excel_row, $social_two);
				$sheet->setCellValue('BG'.$excel_row, $social_three);
				$sheet->setCellValue('BH'.$excel_row, $social_four);

				$sheet->setCellValue('BI'.$excel_row, $research_exp);
				$sheet->setCellValue('BJ'.$excel_row, $research_one);
				$sheet->setCellValue('BK'.$excel_row, $research_two);
				$sheet->setCellValue('BL'.$excel_row, $research_three);
				$sheet->setCellValue('BM'.$excel_row, $research_four);

				$sheet->setCellValue('BN'.$excel_row, $r->ref_name_one);
				$sheet->setCellValue('BO'.$excel_row, $r->ref_email_one);
				$sheet->setCellValue('BP'.$excel_row, $refOneCountry);
				$sheet->setCellValue('BQ'.$excel_row, $r->ref_phone_code_one.'-'.$r->ref_contact_one);
				$sheet->setCellValue('BR'.$excel_row, $r->ref_rel_one);
				$sheet->setCellValue('BS'.$excel_row, $r->ref_name_two);
				$sheet->setCellValue('BT'.$excel_row, $r->ref_email_two);
				$sheet->setCellValue('BU'.$excel_row, $refTwoCountry);
				$sheet->setCellValue('BV'.$excel_row, $r->ref_phone_code_two.'-'.$r->ref_contact_two);
				$sheet->setCellValue('BW'.$excel_row, $r->ref_rel_two);

				$sheet->setCellValue('BX'.$excel_row, $sup_file_one_name);
				$sheet->setCellValue('BY'.$excel_row, $sup_file_two_name);
				$sheet->setCellValue('BZ'.$excel_row, $sup_file_three_name);
				$sheet->setCellValue('CA'.$excel_row, $award_one);
				$sheet->setCellValue('CB'.$excel_row, $award_one_name);
				$sheet->setCellValue('CC'.$excel_row, $award_two);
				$sheet->setCellValue('CD'.$excel_row, $award_two_name);
				$sheet->setCellValue('CE'.$excel_row, $award_three);
				$sheet->setCellValue('CF'.$excel_row, $award_three_name);
				$sheet->setCellValue('CG'.$excel_row, $r->reason);
				// $sheet->setCellValue('CJ'.$excel_row, $created_at);
				
				
				// $sheet->setCellValue('AI'.$excel_row, $segmentStr);
				// $sheet->setCellValue('AJ'.$excel_row, $r->leadership_casestudy_one);
				// $sheet->setCellValue('AK'.$excel_row, $r->leadership_casestudy_two);
				// $sheet->setCellValue('AL'.$excel_row, $r->leadership_casestudy_three);
				// $sheet->setCellValue('AM'.$excel_row, $r->leadership_casestudy_four);
				// $sheet->setCellValue('AN'.$excel_row, $r->research_casestudy_one);
				// $sheet->setCellValue('AO'.$excel_row, $r->research_casestudy_two);
				// $sheet->setCellValue('AP'.$excel_row, $r->research_casestudy_three);
				// $sheet->setCellValue('AQ'.$excel_row, $r->research_casestudy_four);
				// $sheet->setCellValue('AR'.$excel_row, $r->patient_casestudy_one);
				// $sheet->setCellValue('AS'.$excel_row, $r->patient_casestudy_two);
				// $sheet->setCellValue('AT'.$excel_row, $r->patient_casestudy_three);
				// $sheet->setCellValue('AU'.$excel_row, $r->patient_casestudy_four);
				// $sheet->setCellValue('AV'.$excel_row, $r->social_casestudy_one);
				// $sheet->setCellValue('AW'.$excel_row, $r->social_casestudy_two);
				// $sheet->setCellValue('AX'.$excel_row, $r->social_casestudy_three);
				// $sheet->setCellValue('AY'.$excel_row, $r->social_casestudy_four);
				// $sheet->setCellValue('AZ'.$excel_row, $supportingDocument1);
				// $sheet->setCellValue('BA'.$excel_row, $supportingDocument2);

				$excel_row++;
				$nos++;
			}
		}
		//ob_clean();
		$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Applications Master Submitted Application.xlsx"'); 
		header('Cache-Control: max-age=0');

		// download file 
		$writer->save('php://output'); 
	}


	function fetchDataFromDatabase($offset, $batchSize) {
		// Replace this with your database query to fetch data
		$sql = "SELECT r.*, apd.region FROM `registration` as r left join master_country as apd on r.country = apd.country_id  limit $batchSize offset $offset";
		$data = $this->Mdl_excel->customQuery($sql);
		return $data; // Return the fetched data
	}
	function nursesAllData(){
		
		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
		$spreadsheet->getProperties()->setCreator('Global Nursing Award 2022')
		->setLastModifiedBy('Global Nursing Award 2022')
		->setTitle('Nurse Registration Master')
		->setSubject('')
		->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:O1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A', 'L') as $columnID) {
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}

		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Date');
		$sheet->setCellValue('C1', 'First Name');
		$sheet->setCellValue('D1', 'Middle Name');
		$sheet->setCellValue('E1', 'Last Name');
		$sheet->setCellValue('F1', 'Institute / Hospital name');
		$sheet->setCellValue('G1', 'Email');
		$sheet->setCellValue('H1', 'Gender');
		$sheet->setCellValue('I1', 'Country');
		$sheet->setCellValue('J1', 'Contact No 1');
		$sheet->setCellValue('K1', 'Contact No 2');
		$sheet->setCellValue('L1', 'Email Verification');
		$sheet->setCellValue('M1', 'Region');
		$sheet->setCellValue('N1', 'Status');
		$sheet->setCellValue('O1', 'Google or Regular Registration');
		//$records = $this->Mdl_excel->retrieve("registration",array("1"=>"1"));
		$content = $this->input->post();
		$_APPLICATIONS_QUERY = '';
		$_APPLICATIONS_QUERY = "SELECT r.*, apd.region FROM `registration` as r 
		left join master_country as apd
		on r.country = apd.country_id  limit 0 offset 100";

		$records = $this->Mdl_excel->customQuery($_APPLICATIONS_QUERY);
		$excel_row = 2;
		$nos = 1;
		$batchSize = 0; // Number of records to fetch in each batch
		$totalRecords = 100;
		// for ($offset = 0; $offset < $totalRecords; $offset += $batchSize) {
		// 	$data = $this->fetchDataFromDatabase($offset, $batchSize);
		// 	//echo "<pre>";print_r($data );exit;
		// 	// Add data to the spreadsheet
		// 	$row = $offset / $batchSize + 1; // Calculate the row number in the spreadsheet
		// 	foreach ($data as $index => $r) {
		// 		//echo "<pre>";print_r($r);exit;
		// 		$col = $index + 1; // Column index (adjust as needed)
		// 		$date = date("d-m-Y H:i:s",strtotime($r->created_at));
		// 		$country = Modules::run('api/application/personal/country', $r->country);
		
		// 		$mailVerification = $r->email_verification == "yes" ? "Verified" : "Pending";
		// 		$institute = '';$gender='';$region='';
		// 		if(empty($r->institute)){
		// 			$query = "SELECT apd.region,apd.institute,apd.gender,apd.country FROM `application_personal_details` as apd WHERE `uid` = '$r->uid'";
		// 			$application = $this->Mdl_excel->customQuery($query);
		// 			if($application != "NA"){
		// 				$institute = $application[0]->institute;
		// 				$gender = $application[0]->gender;
		// 				$region = $application[0]->region;
		// 				$country = Modules::run('api/application/personal/country', $application[0]->country);
		// 				if(empty($region)){
		// 					$region = $country[0]->region;
		// 				}
		// 			} 
		// 		} else {
		// 			$institute = $r->institute;
		// 			$gender = $r->gender;
		// 			$region = $r->region;
		// 		}
		// 		if(empty($region)){
					
		// 			$region_data = Modules::run('api/application/personal/region', $r->country);
		// 			$region = $region_data;
		// 		}

		// 		$is_gmail_login = '';
		// 		$sheet->setCellValue('A'.$excel_row, $nos);
		// 		$sheet->setCellValue('B'.$excel_row, $date);
		// 		$sheet->setCellValue('C'.$excel_row, $r->first_name);
		// 		$sheet->setCellValue('D'.$excel_row, $r->middle_name);
		// 		$sheet->setCellValue('E'.$excel_row, $r->last_name);
		// 		$sheet->setCellValue('F'.$excel_row, $institute);
		// 		$sheet->setCellValue('G'.$excel_row, $r->email);
		// 		$sheet->setCellValue('H'.$excel_row, $gender);
		// 		$sheet->setCellValue('I'.$excel_row, $country);
		// 		$sheet->setCellValue('J'.$excel_row, $r->phone_code_one.'-'.$r->contact_one);
		// 		$sheet->setCellValue('K'.$excel_row, $r->phone_code_two.'-'.$r->contact_two);
		// 		$sheet->setCellValue('L'.$excel_row, $mailVerification);
		// 		$sheet->setCellValue('M'.$excel_row, $region);
		// 		$sheet->setCellValue('N'.$excel_row, ucfirst($r->status));
		// 		if($r->is_gmail_login == "Y"){
		// 			$is_gmail_login = 'Gmail';
		// 		} else {
		// 			$is_gmail_login = 'Normal';
		// 		}
		// 		$sheet->setCellValue('O'.$excel_row, $is_gmail_login);
		// 		$excel_row++;
		// 		$nos++;
		// 	}
		// }
		if( $records !== "NA" ){
			foreach($records as $r){
				$date = date("d-m-Y H:i:s",strtotime($r->created_at));
				$country = Modules::run('api/application/personal/country', $r->country);
		
				$mailVerification = $r->email_verification == "yes" ? "Verified" : "Pending";
				$institute = '';$gender='';$region='';
				if(empty($r->institute)){
					$query = "SELECT apd.region,apd.institute,apd.gender,apd.country FROM `application_personal_details` as apd WHERE `uid` = '$r->uid'";
					$application = $this->Mdl_excel->customQuery($query);
					if($application != "NA"){
						$institute = $application[0]->institute;
						$gender = $application[0]->gender;
						$region = $application[0]->region;
						$country = Modules::run('api/application/personal/country', $application[0]->country);
						if(empty($region)){
							$region = $country[0]->region;
						}
					} 
				} else {
					$institute = $r->institute;
					$gender = $r->gender;
					$region = $r->region;
				}
				if(empty($region)){
					
					$region_data = Modules::run('api/application/personal/region', $r->country);
					$region = $region_data;
				}

				$is_gmail_login = '';
				$sheet->setCellValue('A'.$excel_row, $nos);
				$sheet->setCellValue('B'.$excel_row, $date);
				$sheet->setCellValue('C'.$excel_row, $r->first_name);
				$sheet->setCellValue('D'.$excel_row, $r->middle_name);
				$sheet->setCellValue('E'.$excel_row, $r->last_name);
				$sheet->setCellValue('F'.$excel_row, $institute);
				$sheet->setCellValue('G'.$excel_row, $r->email);
				$sheet->setCellValue('H'.$excel_row, $gender);
				$sheet->setCellValue('I'.$excel_row, $country);
				$sheet->setCellValue('J'.$excel_row, $r->phone_code_one.'-'.$r->contact_one);
				$sheet->setCellValue('K'.$excel_row, $r->phone_code_two.'-'.$r->contact_two);
				$sheet->setCellValue('L'.$excel_row, $mailVerification);
				$sheet->setCellValue('M'.$excel_row, $region);
				$sheet->setCellValue('N'.$excel_row, ucfirst($r->status));
				if($r->is_gmail_login == "Y"){
					$is_gmail_login = 'Gmail';
				} else {
					$is_gmail_login = 'Normal';
				}
				$sheet->setCellValue('O'.$excel_row, $is_gmail_login);
				$excel_row++;
				$nos++;
			}
		}

		$writer = new Xlsx($spreadsheet);
		$file_path = APPPATH . 'assets/excel/Nurse Registration Master.xlsx'; // Define the file path

        // Save the file to the server
        $writer->save($file_path);

		// header('Content-Type: application/vnd.ms-excel');
		// header('Content-Disposition: attachment;filename="Nurse Registration Master.xlsx"'); 
		// header('Cache-Control: max-age=0');

		// download file 
		$writer->save('php://output'); 
	}
	function nurse2024(){
		
		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
		$spreadsheet->getProperties()->setCreator('Global Nursing Award 2024')
		->setLastModifiedBy('Global Nursing Award 2024')
		->setTitle('Nurse Registration Master')
		->setSubject('')
		->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:O1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A', 'L') as $columnID) {
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}

		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Date');
		$sheet->setCellValue('C1', 'First Name');
		$sheet->setCellValue('D1', 'Middle Name');
		$sheet->setCellValue('E1', 'Last Name');
		$sheet->setCellValue('F1', 'Institute / Hospital name');
		$sheet->setCellValue('G1', 'Email');
		$sheet->setCellValue('H1', 'Gender');
		$sheet->setCellValue('I1', 'Country');
		$sheet->setCellValue('J1', 'Contact No 1');
		$sheet->setCellValue('K1', 'Contact No 2');
		$sheet->setCellValue('L1', 'Email Verification');
		$sheet->setCellValue('M1', 'Region');
		$sheet->setCellValue('N1', 'Status');
		$sheet->setCellValue('O1', 'Google or Regular Registration');
		//$records = $this->Mdl_excel->retrieve("registration",array("1"=>"1"));
		$content = $this->input->post();
		$_APPLICATIONS_QUERY = '';
		$_APPLICATIONS_QUERY = "SELECT r.*, apd.region FROM `registration` as r 
		left join master_country as apd
		on r.country = apd.country_id  where `edition` = 'three'";

		$records = $this->Mdl_excel->customQuery($_APPLICATIONS_QUERY);
		$excel_row = 2;
		$nos = 1;
		
		if( $records !== "NA" ){
			foreach($records as $r){
				$date = date("d-m-Y H:i:s",strtotime($r->created_at));
				$country = Modules::run('api/application/personal/country', $r->country);
		
				$mailVerification = $r->email_verification == "yes" ? "Verified" : "Pending";
				$institute = '';$gender='';$region='';
				if(empty($r->institute)){
					$query = "SELECT apd.region,apd.institute,apd.gender,apd.country FROM `application_personal_details` as apd WHERE `uid` = '$r->uid'";
					$application = $this->Mdl_excel->customQuery($query);
					if($application != "NA"){
						$institute = $application[0]->institute;
						$gender = $application[0]->gender;
						$region = $application[0]->region;
						$country = Modules::run('api/application/personal/country', $application[0]->country);
						if(empty($region)){
							$region = $country[0]->region;
						}
					} 
				} else {
					$institute = $r->institute;
					$gender = $r->gender;
					$region = $r->region;
				}
				if(empty($region)){
					$region_data = Modules::run('api/application/personal/region', $r->country);
					$region = $region_data;
				}
				if(!empty($r->phone_code_one) && !empty($r->contact_one)){
					$phone_code_one = $r->phone_code_one.'-'.$r->contact_one;
				} else {
					$phone_code_one = '';
				}
				if(!empty($r->phone_code_two) && !empty($r->contact_two)){
					$phone_code_two = $r->phone_code_two.'-'.$r->contact_two;
				} else {
					$phone_code_two = '';
				}
				$is_gmail_login = '';
				$sheet->setCellValue('A'.$excel_row, $nos);
				$sheet->setCellValue('B'.$excel_row, $date);
				$sheet->setCellValue('C'.$excel_row, $r->first_name);
				$sheet->setCellValue('D'.$excel_row, $r->middle_name);
				$sheet->setCellValue('E'.$excel_row, $r->last_name);
				$sheet->setCellValue('F'.$excel_row, $institute);
				$sheet->setCellValue('G'.$excel_row, $r->email);
				$sheet->setCellValue('H'.$excel_row, $gender);
				$sheet->setCellValue('I'.$excel_row, $country);
				$sheet->setCellValue('J'.$excel_row, $phone_code_one);
				$sheet->setCellValue('K'.$excel_row, $phone_code_two);
				$sheet->setCellValue('L'.$excel_row, $mailVerification);
				$sheet->setCellValue('M'.$excel_row, $region);
				$sheet->setCellValue('N'.$excel_row, ucfirst($r->status));
				if($r->is_gmail_login == "Y"){
					$is_gmail_login = 'Gmail';
				} else {
					$is_gmail_login = 'Normal';
				}
				$sheet->setCellValue('O'.$excel_row, $is_gmail_login);
				$excel_row++;
				$nos++;
			}
		}

		$writer = new Xlsx($spreadsheet);
		

		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Nurse Registration Master.xlsx"'); 
		header('Cache-Control: max-age=0');

		// download file 
		$writer->save('php://output'); 
	}

	function nomination2024(){

		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
    	$spreadsheet->getProperties()->setCreator('Global Nursing Award 2022')
      ->setLastModifiedBy('Global Nursing Award 2022')
      ->setTitle('Nomination Master')
      ->setSubject('')
      ->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:P1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A', 'P') as $columnID) {
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}

		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Date');
		$sheet->setCellValue('C1', 'Nominator\'s Name');
		$sheet->setCellValue('D1', 'Relationship with the Nurse');
		$sheet->setCellValue('E1', 'Institute / Hospital name');
		$sheet->setCellValue('F1', 'Email');
		$sheet->setCellValue('G1', 'Country');
		$sheet->setCellValue('H1', 'Mobile Number');
		$sheet->setCellValue('I1', 'Candidate\'s name');
		$sheet->setCellValue('J1', 'Institute / Hospital name');
		$sheet->setCellValue('K1', 'Institute / Hospital address');
		$sheet->setCellValue('L1', 'Email');
		$sheet->setCellValue('M1', 'Country');
		$sheet->setCellValue('N1', 'Mobile Number');
		$sheet->setCellValue('O1', 'Years of experience');
		$sheet->setCellValue('P1', 'Reason for nomination');

		$content = $this->input->post();
		$_APPLICATIONS_QUERY = '';
		

		$_APPLICATIONS_QUERY = "select * from nomination where `edition` = 'three'";
				
		$records = $this->Mdl_excel->customQuery($_APPLICATIONS_QUERY);
		//$records = $this->Mdl_excel->retrieve("nomination",array("1"=>"1"));
		$excel_row = 2;
		$nos = 1;

		if( $records !== "NA" ){
			foreach($records as $r){
				$date = date("d-m-Y H:i:s",strtotime($r->created_at));
				$nominatorCounty = Modules::run('api/application/personal/country', $r->country);
				$candidateCountry = Modules::run('api/application/personal/country', $r->cand_country);

				$sheet->setCellValue('A'.$excel_row, $nos);
				$sheet->setCellValue('B'.$excel_row, $date);
				$sheet->setCellValue('C'.$excel_row, $r->fullname);
				$sheet->setCellValue('D'.$excel_row, $r->relationship);
				$sheet->setCellValue('E'.$excel_row, $r->institute);
				$sheet->setCellValue('F'.$excel_row, $r->email);
				$sheet->setCellValue('G'.$excel_row, $nominatorCounty);
				$sheet->setCellValue('H'.$excel_row, $r->phone_code.'-'.$r->contact);
				$sheet->setCellValue('I'.$excel_row, $r->cand_name);
				$sheet->setCellValue('J'.$excel_row, $r->cand_institute);
				$sheet->setCellValue('K'.$excel_row, $r->cand_address);
				$sheet->setCellValue('L'.$excel_row, $r->cand_email);
				$sheet->setCellValue('M'.$excel_row, $candidateCountry);
				$sheet->setCellValue('N'.$excel_row, $r->cand_code.'-'.$r->cand_contact);
				$sheet->setCellValue('O'.$excel_row, $r->experience);
				$sheet->setCellValue('P'.$excel_row, $r->reason);
				$excel_row++;
				$nos++;
			}
		}

		$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Nomination Master.xlsx"'); 
		header('Cache-Control: max-age=0');

		// download file 
		$writer->save('php://output'); 
	}

	function application2024(){
		//echo "<pre>";print_r($this->input->post());exit;
		// Create new Spreadsheet object
		$spreadsheet = new Spreadsheet();
		$sheet = $spreadsheet->getActiveSheet();

		// Set document properties
		$spreadsheet->getProperties()->setCreator('Global Nursing Award 2024')
			->setLastModifiedBy('Global Nursing Award 2024')
			->setTitle('Applications Master')
			->setSubject('')
			->setDescription('');

		// add style to the header
		$styleArray = array(
			'font' => array(
				'bold' => true,
			),
			'alignment' => array(
				'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
				'vertical'   => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
			),
			'borders' => array(
				'bottom' => array(
					'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
					'color' => array('rgb' => '333333'),
				),
			),
			'fill' => array(
				'type'       => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
				'rotation'   => 90,
				'startcolor' => array('rgb' => '0d0d0d'),
				'endColor'   => array('rgb' => 'f2f2f2'),
			),
		);
		$spreadsheet->getActiveSheet()->getStyle('A1:CJ1')->applyFromArray($styleArray);

		// auto fit column to content
		foreach(range('A','AS') as $columnID){
			$spreadsheet->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
		}
		
		// set the names of header cells
		$sheet->setCellValue('A1', 'Sr. No.');
		$sheet->setCellValue('B1', 'Date');
		$sheet->setCellValue('C1', 'Application Status');
		$sheet->setCellValue('D1', 'EY Assessment');
		$sheet->setCellValue('E1', 'Application Number');
		$sheet->setCellValue('F1', 'Application Code');
		$sheet->setCellValue('G1', 'Language');
		$sheet->setCellValue('H1', 'First name');
		$sheet->setCellValue('I1', 'Middle name');
		$sheet->setCellValue('J1', 'Last name');
		$sheet->setCellValue('K1', 'Email');
		$sheet->setCellValue('L1', 'Date of Birth');
		$sheet->setCellValue('M1', 'City');
		$sheet->setCellValue('N1', 'Country');
		$sheet->setCellValue('O1', 'Region');
		$sheet->setCellValue('P1', 'Contact No');
		$sheet->setCellValue('Q1', 'Gender');
		$sheet->setCellValue('R1', 'Address');
		$sheet->setCellValue('S1', 'Register as');
		$sheet->setCellValue('T1', 'Institute / hospital name');
		$sheet->setCellValue('U1', 'Job Title');
		$sheet->setCellValue('V1', 'Institute/ Hospital Country');
		$sheet->setCellValue('W1', 'Institute/ Hospital City');
		$sheet->setCellValue('X1', 'Contact Email ID');
		$sheet->setCellValue('Y1', 'Contact Number');
		$sheet->setCellValue('Z1', 'Reporting Manager Name');
		$sheet->setCellValue('AA1', 'Reporting Manager Designation');
		$sheet->setCellValue('AB1', 'Reporting Manager Email ID');
		$sheet->setCellValue('AC1', 'Reporting Manager Contact Number ');
		$sheet->setCellValue('AD1', 'Website link');
		$sheet->setCellValue('AE1', 'Total years of work experience as a Nurse');
		$sheet->setCellValue('AF1', 'Years of experience in the current institute/hospital');

		$sheet->setCellValue('AG1', 'Selected Segment');
		$sheet->setCellValue('AH1', 'Primary Segment');
		$sheet->setCellValue('AI1', 'Secondary Segment');
		$sheet->setCellValue('AJ1', 'Patient Experience');
		$sheet->setCellValue('AK1', 'Patient care in your daily work environment');
		$sheet->setCellValue('AL1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('AM1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('AN1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');
		$sheet->setCellValue('AO1', 'Leadership Experience');
		$sheet->setCellValue('AP1', 'Patient care in your daily work environment');
		$sheet->setCellValue('AQ1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('AR1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('AS1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('AT1', 'Education Experience');
		$sheet->setCellValue('AU1', 'Patient care in your daily work environment');
		$sheet->setCellValue('AV1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('AW1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('AX1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('AY1', 'Social Experience');
		$sheet->setCellValue('AZ1', 'Patient care in your daily work environment');
		$sheet->setCellValue('BA1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('BB1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('BC1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');

		$sheet->setCellValue('BD1', 'Research Experience');
		$sheet->setCellValue('BE1', 'Patient care in your daily work environment');
		$sheet->setCellValue('BF1', 'Challenges faced and how you overcame them');		
		$sheet->setCellValue('BG1', 'Describe the impact on patients? How did they respond to the care and empathy you extend');
		$sheet->setCellValue('BH1', 'Describe your story/unique instance pertaining to the Area of Contribution selected and what differentiates you from other nurses');
		
		$sheet->setCellValue('BI1', 'Describe how do you intend to utilize the prize money if you win');

		$sheet->setCellValue('BJ1', 'First Referrer full name');
		$sheet->setCellValue('BK1', 'Referrer email ID');
		$sheet->setCellValue('BL1', 'Referrer country');
		$sheet->setCellValue('BM1', 'Referrer contact number');
		$sheet->setCellValue('BN1', 'Relationship with the reference');
		$sheet->setCellValue('BO1', 'Designation');

		$sheet->setCellValue('BP1', 'Second Referrer full name');		
		$sheet->setCellValue('BQ1', 'Referrer email ID');
		$sheet->setCellValue('BR1', 'Referrer country');
		$sheet->setCellValue('BS1', 'Referrer contact number');
		$sheet->setCellValue('BT1', 'Relationship with the reference');
		$sheet->setCellValue('BU1', 'Designation');

		$sheet->setCellValue('BV1', 'Educational Qualification (Highest degree)');
		$sheet->setCellValue('BW1', 'Educational Qualification (Highest degree) File Name');
		$sheet->setCellValue('BX1', 'Medical/Nurse council registration name');
		$sheet->setCellValue('BY1', 'Medical/Nurse council registration number');
		$sheet->setCellValue('BZ1', 'Medical/Nurse council registration File Name');
		$sheet->setCellValue('CA1', 'Passport Copy');
		$sheet->setCellValue('CB1', 'Valid national proof of identity of the country/region you are applying from (Government ID) ');
		$sheet->setCellValue('CC1', 'Minimum 2 years of employment proof as a registered nurse');
		$sheet->setCellValue('CD1', 'LinkedIn');
		$sheet->setCellValue('CE1', 'X (Twitter)');
		$sheet->setCellValue('CF1', 'Facebook');
		$sheet->setCellValue('CG1', 'Instagram ');
		
		$sheet->setCellValue('CH1', 'Collaterals doc');
		// $sheet->setCellValue('BY1', 'Collaterals doc 2');
		// $sheet->setCellValue('BZ1', 'Collaterals doc 3');
		// $sheet->setCellValue('CA1', 'Awards/ certifications  doc 1 name');
		// $sheet->setCellValue('CB1', 'Awards/ certifications  doc 1 ');
		// $sheet->setCellValue('CC1', 'Awards/ certifications  doc 2 name');
		// $sheet->setCellValue('CD1', 'Awards/ certifications  doc 2');
		// $sheet->setCellValue('CE1', 'Awards/ certifications  doc 3 name');
		// $sheet->setCellValue('CF1', 'Awards/ certifications  doc 3');

		$sheet->setCellValue('CI1', 'Reason');
		$sheet->setCellValue('CJ1', 'Section');
		$sheet->setCellValue('CK1', 'Modify Date');
		// $sheet->setCellValue('CJ1', 'Date and Time');


		// $sheet->setCellValue('AI1', 'Selected segments');
		// $sheet->setCellValue('AJ1', 'We believe nursing is about leading from the front. So, why would you consider yourself as a leader and what difference has that made?');
		// $sheet->setCellValue('AK1', 'Help us understand the challenges faced and how did you overcome the same');
		// $sheet->setCellValue('AL1', 'How do patients and peers respond to your leadership?');
		// $sheet->setCellValue('AM1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AN1', 'Describe your contributions to nursing research, policy, and/or practice at the local regional, state, and /or national level');
		// $sheet->setCellValue('AO1', 'Describe the challenges faced  and how did you overcome the same');
		// $sheet->setCellValue('AP1', 'Describe the impact of the initiative on the patients, employer, peers, etc?');
		// $sheet->setCellValue('AQ1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AR1', 'Describe the initiatives undertaken to facilitate positive changes in the work environment and improve the quality of patient care');
		// $sheet->setCellValue('AS1', 'Describe the challenges faced  and how did you overcome the same');
		// $sheet->setCellValue('AT1', 'Describe the impact of the initiative on the patients, employer, peers, etc?');
		// $sheet->setCellValue('AU1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AV1', 'Describe the your contribution for the betterment of the community/society');
		// $sheet->setCellValue('AW1', 'Describe the challenges faced  and how did you overcome the same');
		// $sheet->setCellValue('AX1', 'Describe the impact of the initiative on the community and what was the change they witnessed?');
		// $sheet->setCellValue('AY1', 'Describe your story/unique instance pertaining to area of contribution selected');
		// $sheet->setCellValue('AZ1', 'Awards and certifications');
		// $sheet->setCellValue('BA1', 'Awards and certifications');
		//$_APPLICATIONS_QUERY = "SELECT * FROM application_personal_details limit 12000";
		$content = $this->input->post();
		$_APPLICATIONS_QUERY = '';
		
		$edition = 'three';
		$_APPLICATIONS_QUERY = "SELECT a.applications_id, a.uid, a.`code`,a.application_number,a.first_name,
						a.middle_name,a.last_name,a.dob,a.country,a.region,a.phone_code,a.contact,a.address,a.gender,a.qualified_as,
						a.institute,
						a.organisation_phonecode,a.organisation_contact,a.organisation_email,a.organisation_website,a.total_exp,
						a.current_exp,a.ref_name_one,a.ref_designation_one,a.ref_email_one,a.ref_country_one,a.ref_phone_code_one,ref_contact_one,
						a.ref_rel_one,a.ref_name_two,a.ref_designation_two,a.ref_email_two,a.ref_country_two,
						a.ref_phone_code_two,a.ref_contact_two,a.ref_rel_two,a.ref_rel_other_two,a.`status`,a.step,
						a.ey_assessment,a.is_recommended,a.reason,a.`language`,a.created_at,a.nurce_city,a.`city`,a.hospital_country,a.relational_manager_name,
						a.relational_manager_designation,a.relational_manager_email,a.relational_manager_mobile,a.job_title,a.modified_at,a.first_name_lang,a.middle_name_lang,
						a.last_name_lang,a.institute_lang,a.ref_name_one_lang,a.ref_designation_one_lang,a.ref_name_two_lang,a.ref_designation_two_lang
						FROM application_personal_details as a where a.`edition` = '$edition' ";
			
		//echo $_APPLICATIONS_QUERY;exit;
		//limit 10000 offset 10000
		$records = $this->Mdl_excel->customQuery($_APPLICATIONS_QUERY);
		$excel_row = 2;
		$nos = 1;
		if( $records !== "NA" ){
			foreach($records as $r){
				$date = date("Y-m-d H:i:s", strtotime($r->created_at));
				$created_at = date("Y-m-d H:i:s", strtotime($r->created_at));
				$dob = date("Y-m-d", strtotime($r->dob));
				$country = Modules::run('api/application/personal/country',$r->country);
				$refOneCountry = Modules::run('api/application/personal/country',$r->ref_country_one);
				$refTwoCountry = Modules::run('api/application/personal/country',$r->ref_country_two);
				$casestudies = Modules::run('api/application/personal/caseStudies',$r->uid);
				if($casestudies != "NA"){
					$ledership_array = explode(',',$casestudies[0]->selected_segments);
					$leadership_segments = $casestudies[0]->selected_segments;
					$leadership_primary = $casestudies[0]->primary_segment;
					$leadership_secondary = $casestudies[0]->secondary_segment;
					$leadership_exp = $casestudies[0]->leadership_exp;
					if(in_array('leadership', $ledership_array)){
						
						if(!empty($casestudies[0]->leadership_one) && $casestudies[0]->leadership_one != ""){
							$leadership_one = json_decode($casestudies[0]->leadership_one);
							$leadership_one = $leadership_one->textEn;
							$leadership_two = json_decode($casestudies[0]->leadership_two);
							$leadership_two = $leadership_two->textEn;
							$leadership_three = json_decode($casestudies[0]->leadership_three);
							$leadership_three = $leadership_three->textEn;
							$leadership_four = json_decode($casestudies[0]->leadership_four);
							$leadership_four = $leadership_four->textEn;
							
						} else {
							$leadership_one = '';
							$leadership_two = '';
							$leadership_three = '';
							$leadership_four = '';
						}
					} else {
						$leadership_segments = '';
						$leadership_primary = '';
						$leadership_secondary = '';
						$leadership_exp = '';
						$leadership_one = '';
						$leadership_two = '';
						$leadership_three = '';
						$leadership_four = '';
					}
					$patient_array = explode(',',$casestudies[0]->selected_segments);
					//print_r($patient_array);
					//exit;
					if(in_array('patient', $patient_array)){
						$patient_segments = $casestudies[0]->selected_segments;
						$patient_primary = $casestudies[0]->primary_segment;
						$patient_secondary = $casestudies[0]->secondary_segment;
						$patient_exp = $casestudies[0]->patient_exp;
						if(!empty($casestudies[0]->patient_one) && $casestudies[0]->patient_one != ""){
							$patient_one = json_decode($casestudies[0]->patient_one);
							$patient_one = $patient_one->textEn;
							$patient_two = json_decode($casestudies[0]->patient_two);
							$patient_two = $patient_two->textEn;
							$patient_three = json_decode($casestudies[0]->patient_three);
							$patient_three = $patient_three->textEn;
							$patient_four = json_decode($casestudies[0]->patient_four);
							$patient_four = $patient_four->textEn;
							
						} else {
							$patient_one = '';
							$patient_two = '';
							$patient_three = '';
							$patient_four = '';
						}
					} else {
						$patient_segments = '';
						$patient_primary = '';
						$patient_secondary = '';
						$patient_exp = '';
						$patient_one = '';
						$patient_two = '';
						$patient_three = '';
						$patient_four = '';
					}

					$education_array = explode(',',$casestudies[0]->selected_segments);
					if(in_array('education', $education_array)){
						$education_segments = $casestudies[0]->selected_segments;
						$education_primary = $casestudies[0]->primary_segment;
						$education_secondary = $casestudies[0]->secondary_segment;
						$education_exp = $casestudies[0]->education_exp;
						if(!empty($casestudies[0]->education_one) && $casestudies[0]->education_one != ""){
							$education_one_t = json_decode($casestudies[0]->education_one);
							$education_one = $education_one_t->textEn;
							$education_two = json_decode($casestudies[0]->education_two);
							$education_two = $education_two->textEn;
							$education_three = json_decode($casestudies[0]->education_three);
							$education_three = $education_three->textEn;
							$education_four = json_decode($casestudies[0]->education_four);
							$education_four = $education_four->textEn;
						} else {
							$education_one = '';
							$education_two = '';
							$education_three = '';
							$education_four ='';
						}
					} else {
						$education_segments = '';
						$education_primary = '';
						$education_secondary = '';
						$education_exp = '';
						$education_one = '';
						$education_two = '';
						$education_three = '';
						$education_four ='';
					}
					
					$social_array = explode(',',$casestudies[0]->selected_segments);
					if(in_array('social', $social_array)){
						$social_segments = $casestudies[0]->selected_segments;
						$social_primary = $casestudies[0]->primary_segment;
						$social_secondary = $casestudies[0]->secondary_segment;
						$social_exp = $casestudies[0]->social_exp;
						if(!empty($casestudies[0]->social_one) && $casestudies[0]->social_one != ""){
							$social_one = json_decode($casestudies[0]->social_one);
							$social_one = $social_one->textEn;
							$social_two = json_decode($casestudies[0]->social_two);
							$social_two = $social_two->textEn;
							$social_three = json_decode($casestudies[0]->social_three);
							$social_three = $social_three->textEn;
							$social_four = json_decode($casestudies[0]->social_four);
							$social_four = $social_four->textEn;
	
						} else {
							$social_one = '';
							$social_two = '';
							$social_three = '';
							$social_four = '';
						}
					} else {
						$social_segments = '';
						$social_primary = '';
						$social_secondary = '';
						$social_exp = '';
						$social_one = '';
						$social_two = '';
						$social_three = '';
						$social_four = '';
					}
					
					$research_array = explode(',',$casestudies[0]->selected_segments);
					if(in_array('research', $research_array)){
						$research_segments = $casestudies[0]->selected_segments;
						$research_primary = $casestudies[0]->primary_segment;
						$research_secondary = $casestudies[0]->secondary_segment;
						$research_exp = $casestudies[0]->research_exp;
						if(!empty($casestudies[0]->research_one) && $casestudies[0]->research_one != ""){
							$research_one = json_decode($casestudies[0]->research_one);
							$research_one = $research_one->textEn;
							$research_two = json_decode($casestudies[0]->research_two);
							$research_two = $research_two->textEn;
							$research_three = json_decode($casestudies[0]->research_three);
							$research_three = $research_three->textEn;
							$research_four = json_decode($casestudies[0]->research_four);
							$research_four = $research_four->textEn;
	
						} else {
							$research_one = '';
							$research_two = '';
							$research_three = '';
							$research_four = '';
						}
					} else {
						$research_segments = '';
						$research_primary = '';
						$research_secondary = '';
						$research_exp = '';
						$research_one = '';
						$research_two = '';
						$research_three = '';
						$research_four = '';
					}
					
				} else {
					$leadership_segments = '';;
					$leadership_primary = '';
					$leadership_secondary = '';
					$leadership_exp = '';
					$leadership_one = '';
					$leadership_two = '';
					$leadership_three = '';
					$leadership_four = '';

					$patient_segments = '';
					$patient_primary = '';
					$patient_secondary = '';
					$patient_exp = '';					
					$patient_one = '';
					$patient_two = '';
					$patient_three = '';
					$patient_four = '';

					$education_segments = '';;
					$education_primary = '';
					$education_secondary = '';
					$education_exp = '';
					$education_one = '';
					$education_two = '';
					$education_three = '';
					$education_four ='';

					$social_segments = '';
					$social_primary = '';
					$social_secondary = '';
					$social_exp = '';
					$social_one = '';
					$social_two = '';
					$social_three = '';
					$social_four = '';

					$research_segments = '';;
					$research_primary = '';
					$research_secondary = '';
					$research_exp = '';
					$research_one = '';
					$research_two = '';
					$research_three = '';
					$research_four = '';
				}
				$prize_money_array = '';$prize_money = '';
				if(isset($casestudies[0]->prize_money) && !empty($casestudies[0]->prize_money)) {
					$prize_money_array = json_decode($casestudies[0]->prize_money);
					$prize_money = $prize_money_array->textEn;
				}
				$nurse = $this->Mdl_excel->retrieveByCol("email", "registration", array("uid"=>$r->uid));
				$candEmail = $nurse !== "NA" ? $nurse[0]->email : "";

				$_APPLICATIONS_DOCUMENTS_QUERY = "select ad.document_id,ad.uid,ad.`code`,ad.degree_name,ad.degree_file_name,
								ad.degree_file_path,ad.passport_front_file_name,ad.passport_front_file_path,ad.passport_back_file_name,
								ad.passport_back_file_path,ad.nursepic_name,ad.nursepic_path,ad.council_name,ad.council_registration,
								ad.medical_file_name,ad.medical_file_path,ad.proof_name,ad.proof_file_name,ad.proof_file_path,ad.proof_type,
								ad.employment_name,ad.employment_file_name,ad.employment_file_path,ad.declaration_name,ad.declaration_file_name,
								ad.declaration_file_path,ad.award_one,ad.award_one_name,ad.award_one_path,ad.award_two,ad.award_two_name,
								ad.award_two_path,ad.award_three,ad.award_three_name,ad.award_three_path,ad.sup_file_one_name,ad.sup_file_one_path,
								ad.sup_file_two_name,ad.sup_file_two_path,ad.sup_file_three_name,ad.sup_file_three_path,ad.created_at,ad.linkdin,ad.twitter,ad.facebook,ad.instagram,ad.wordFileName,ad.passport_check,ad.national_proof_check,ad.experience_check
								from application_documents as ad where ad.uid= '".$r->uid."' and ad.`code` = '".$r->code."'";
				$documents = $this->Mdl_excel->customQuery($_APPLICATIONS_DOCUMENTS_QUERY);
				

				$degreeName = $documents !== "NA" ? $documents[0]->degree_name : "";
				$degreeDocumentName = $documents !== "NA" ? $documents[0]->degree_file_name : "";
				$degreeDocument =  $documents !== "NA" && $documents[0]->degree_file_path !== "" ? base_url().$documents[0]->degree_file_path : "";

				$councilName = $documents !== "NA" ? $documents[0]->council_name : "";
				$councilRegistration = $documents !== "NA" ? $documents[0]->council_registration : "";
				$medicalDocumentName = $documents !== "NA" ? $documents[0]->medical_file_name : "";
				$medicalDocument = $documents !== "NA" && $documents[0]->medical_file_path !== "" ? base_url().$documents[0]->medical_file_path : "";

				$passportFrontDocumentName = $documents !== "NA" ? $documents[0]->passport_front_file_name : "";
				$passportFrontDocument = $documents !== "NA" && $documents[0]->passport_front_file_path !== "" ? base_url().$documents[0]->passport_front_file_path : "";

				$passportBackDocumentName = $documents !== "NA" ? $documents[0]->passport_back_file_name : "";
				$passportBackDocument = $documents !== "NA" && $documents[0]->passport_back_file_path !== "" ? base_url().$documents[0]->passport_back_file_path : "";
				
				$nursePicName = $documents !== "NA" ? $documents[0]->nursepic_name : "";
				$nursePic = $documents !== "NA" && $documents[0]->nursepic_path !== "" ? base_url().$documents[0]->nursepic_path : "";

				$proofName = $documents !== "NA" ? $documents[0]->proof_name : "";
				$proofDocumentName = $documents !== "NA" ? $documents[0]->proof_file_name : "";
				$proofDocument = $documents !== "NA" && $documents[0]->proof_file_path !== "" ? base_url().$documents[0]->proof_file_path : "";

				$employmentName = $documents !== "NA" ? $documents[0]->employment_name : "";
				$employmentDocumentName = $documents !== "NA" ? $documents[0]->employment_file_name : "";
				$employmentDocument = $documents !== "NA" && $documents[0]->employment_file_path !== "" ? base_url().$documents[0]->employment_file_path : "";

				$declarationDocumentName = $documents !== "NA" ? $documents[0]->proof_name : "";
				$declarationDocument = $documents !== "NA" && $documents[0]->declaration_file_path !== "" ? base_url().$documents[0]->declaration_file_path : "";

				$award_one = $documents !== "NA" ? $documents[0]->award_one : "";
				$award_one_name = $documents !== "NA" && $documents[0]->award_one_name !== "" ? $documents[0]->award_one_name : "";

				$award_two = $documents !== "NA" ? $documents[0]->award_two : "";
				$award_two_name = $documents !== "NA" && $documents[0]->award_two_name !== "" ? $documents[0]->award_two_name : "";

				$award_three = $documents !== "NA" ? $documents[0]->award_three : "";
				$award_three_name = $documents !== "NA" && $documents[0]->award_three_name !== "" ? $documents[0]->award_three_name : "";

				$sup_file_one_name = $documents !== "NA" && $documents[0]->sup_file_one_name !== "" ? $documents[0]->sup_file_one_name : "";
				$sup_file_two_name = $documents !== "NA" && $documents[0]->sup_file_two_name !== "" ? $documents[0]->sup_file_two_name : "";
				$sup_file_three_name = $documents !== "NA" && $documents[0]->sup_file_three_name !== "" ? $documents[0]->sup_file_three_name : "";

				$word_file_name = $documents !== "NA" && $documents[0]->wordFileName !== "" ? $documents[0]->wordFileName : "";
				
				$section = '';
				if($r->step == "personal-details"){
					$section = 'section 1';
				} else if($r->step == "professional-details"){
					$section = 'section 2';
				} else if($r->step == "references"){
					$section = 'section 3';
				} else if($r->step == "segments"){
					$section = 'section 4';
				} else {
					$section = 'section 5';
				}
				$first_name = '';
				if(isset($r->first_name_lang) && !empty($r->first_name_lang)){
					$first_name = $r->first_name.'/'.$r->first_name_lang;
				} else {
					$first_name = $r->first_name;
				}

				$middle_name = '';
				if(isset($r->middle_name_lang) && !empty($r->middle_name_lang)){
					$middle_name = $r->middle_name.'/'.$r->middle_name_lang;
				} else {
					$middle_name = $r->middle_name;
				}
				$last_name = '';
				if(isset($r->last_name_lang) && !empty($r->last_name_lang)){
					$last_name = $r->last_name.'/'.$r->last_name_lang;
				} else {
					$last_name = $r->last_name;
				}
				$institute = '';
				if(isset($r->institute_lang) && !empty($r->institute_lang)){
					$institute = $r->institute.'/'.$r->institute_lang;
				} else {
					$institute = $r->institute;
				}
				$ref_name_one = '';
				if(isset($r->ref_name_one_lang) && !empty($r->ref_name_one_lang)){
					$ref_name_one = $r->ref_name_one.'/'.$r->ref_name_one_lang;
				} else {
					$ref_name_one = $r->ref_name_one;
				}
				$ref_designation_one = '';
				if(isset($r->ref_designation_one_lang) && !empty($r->ref_designation_one_lang)){
					$ref_designation_one = $r->ref_designation_one.'/'.$r->ref_designation_one_lang;
				} else {
					$ref_designation_one = $r->ref_designation_one;
				}

				$ref_name_two = '';
				if(isset($r->ref_name_two_lang) && !empty($r->ref_name_two_lang)){
					$ref_name_two = $r->ref_name_two.'/'.$r->ref_name_two_lang;
				} else {
					$ref_name_two = $r->ref_name_two;
				}
				$ref_designation_two = '';
				if(isset($r->ref_designation_two_lang) && !empty($r->ref_designation_two_lang)){
					$ref_designation_two = $r->ref_designation_two.'/'.$r->ref_designation_two_lang;
				} else {
					$ref_designation_two = $r->ref_designation_two;
				}
				
				if($documents[0]->passport_check == "yes"){
					$passport_check = 'Agreed';
				} else {
					$passport_check = '';
				}
				
				if( $documents[0]->national_proof_check=="yes"){
					$national_proof_check = 'Agreed';
				} else {
					$national_proof_check = '';
				}
				
				if($documents[0]->experience_check=="yes"){
					$experience_check = 'Agreed';
				} else {
					$experience_check = '';
				}

				$organisation_contact = '';
				if(!empty($r->organisation_contact)){
					$organisation_contact = $r->organisation_phonecode.'-'.$r->organisation_contact;
				} else {
					$organisation_contact = '';
				}

				if(!empty($r->contact)){
					$contact = $r->phone_code.'-'.$r->contact;
				} else {
					$contact = '';
				}
				$sheet->setCellValue('A'.$excel_row, $nos);
				$sheet->setCellValue('B'.$excel_row, $date);
				$sheet->setCellValue('C'.$excel_row, $r->status);
				$sheet->setCellValue('D'.$excel_row, ucfirst($r->ey_assessment));
				$sheet->setCellValue('E'.$excel_row, $r->application_number);
				$sheet->setCellValue('F'.$excel_row, $r->code);
				$sheet->setCellValue('G'.$excel_row, $r->language);
				$sheet->setCellValue('H'.$excel_row, $first_name);
				$sheet->setCellValue('I'.$excel_row, $middle_name);
				$sheet->setCellValue('J'.$excel_row, $last_name);
				$sheet->setCellValue('K'.$excel_row, $candEmail);
				$sheet->setCellValue('L'.$excel_row, $dob);
				$sheet->setCellValue('M'.$excel_row, $r->nurce_city);
				$sheet->setCellValue('N'.$excel_row, $country);
				$sheet->setCellValue('O'.$excel_row, $r->region);
				$sheet->setCellValue('P'.$excel_row, $contact);
				$sheet->setCellValue('Q'.$excel_row, $r->gender);
				$sheet->setCellValue('R'.$excel_row, $r->address);
				$sheet->setCellValue('S'.$excel_row, $r->qualified_as);
				$sheet->setCellValue('T'.$excel_row, $institute);
				$sheet->setCellValue('U'.$excel_row, $r->job_title);
				$sheet->setCellValue('V'.$excel_row, $r->hospital_country);
				$sheet->setCellValue('W'.$excel_row, $r->city);
				$sheet->setCellValue('X'.$excel_row, $r->organisation_email);
				$sheet->setCellValue('Y'.$excel_row, $organisation_contact);
				$sheet->setCellValue('Z'.$excel_row, $r->relational_manager_name);
				$sheet->setCellValue('AA'.$excel_row, $r->relational_manager_designation);
				$sheet->setCellValue('AB'.$excel_row, $r->relational_manager_email);
				$sheet->setCellValue('AC'.$excel_row, $r->relational_manager_mobile);
				$sheet->setCellValue('AD'.$excel_row, $r->organisation_website);
				$sheet->setCellValue('AE'.$excel_row, $r->total_exp);
				$sheet->setCellValue('AF'.$excel_row, $r->current_exp);
				
				$sheet->setCellValue('AG'.$excel_row, $leadership_segments);
				$sheet->setCellValue('AH'.$excel_row, $leadership_primary);
				$sheet->setCellValue('AI'.$excel_row, $leadership_secondary);
				$sheet->setCellValue('AJ'.$excel_row, $patient_exp);
				$sheet->setCellValue('AK'.$excel_row, $patient_one);
				$sheet->setCellValue('AL'.$excel_row, $patient_two);
				$sheet->setCellValue('AM'.$excel_row, $patient_three);
				$sheet->setCellValue('AN'.$excel_row, $patient_four);

				$sheet->setCellValue('AO'.$excel_row, $leadership_exp);
				$sheet->setCellValue('AP'.$excel_row, $leadership_one);
				$sheet->setCellValue('AQ'.$excel_row, $leadership_two);
				$sheet->setCellValue('AR'.$excel_row, $leadership_three);
				$sheet->setCellValue('AS'.$excel_row, $leadership_four);
				
				$sheet->setCellValue('AT'.$excel_row, $education_exp);
				$sheet->setCellValue('AU'.$excel_row, $education_one);
				$sheet->setCellValue('AV'.$excel_row, $education_two);
				$sheet->setCellValue('AW'.$excel_row, $education_three);
				$sheet->setCellValue('AX'.$excel_row, $education_four);

				$sheet->setCellValue('AY'.$excel_row, $social_exp);
				$sheet->setCellValue('AZ'.$excel_row, $social_one);
				$sheet->setCellValue('BA'.$excel_row, $social_two);
				$sheet->setCellValue('BS'.$excel_row, $social_three);
				$sheet->setCellValue('BC'.$excel_row, $social_four);

				$sheet->setCellValue('BD'.$excel_row, $research_exp);
				$sheet->setCellValue('BE'.$excel_row, $research_one);
				$sheet->setCellValue('BF'.$excel_row, $research_two);
				$sheet->setCellValue('BG'.$excel_row, $research_three);
				$sheet->setCellValue('BH'.$excel_row, $research_four);
				
				$sheet->setCellValue('BI'.$excel_row, $prize_money);

				$sheet->setCellValue('BJ'.$excel_row, $ref_name_one);
				$sheet->setCellValue('BK'.$excel_row, $r->ref_email_one);
				$sheet->setCellValue('BL'.$excel_row, $refOneCountry);
				$sheet->setCellValue('BM'.$excel_row, $r->ref_phone_code_one.'-'.$r->ref_contact_one);
				$sheet->setCellValue('BN'.$excel_row, $r->ref_rel_one);
				$sheet->setCellValue('BO'.$excel_row, $ref_designation_one);
				$sheet->setCellValue('BP'.$excel_row, $ref_name_two);
				$sheet->setCellValue('BQ'.$excel_row, $r->ref_email_two);
				$sheet->setCellValue('BR'.$excel_row, $refTwoCountry);
				$sheet->setCellValue('BS'.$excel_row, $r->ref_phone_code_two.'-'.$r->ref_contact_two);
				$sheet->setCellValue('BT'.$excel_row, $r->ref_rel_two);
				$sheet->setCellValue('BU'.$excel_row, $ref_designation_two);
				$sheet->setCellValue('BV'.$excel_row, $degreeName);
				$sheet->setCellValue('BW'.$excel_row, $degreeDocumentName);
				$sheet->setCellValue('BX'.$excel_row, $councilName);
				$sheet->setCellValue('BY'.$excel_row, $councilRegistration);
				$sheet->setCellValue('BZ'.$excel_row, $medicalDocumentName);
				$sheet->setCellValue('CA'.$excel_row, $passport_check);
				$sheet->setCellValue('CB'.$excel_row, $national_proof_check);
				$sheet->setCellValue('CC'.$excel_row, $experience_check);
				$sheet->setCellValue('CD'.$excel_row, $documents[0]->linkdin);
				$sheet->setCellValue('CE'.$excel_row, $documents[0]->twitter);
				$sheet->setCellValue('CF'.$excel_row, $documents[0]->facebook);
				$sheet->setCellValue('CG'.$excel_row, $documents[0]->instagram);
				$sheet->setCellValue('CH'.$excel_row, $word_file_name);
				$sheet->setCellValue('CI'.$excel_row, $r->reason);
				$sheet->setCellValue('CJ'.$excel_row, $section);
				$sheet->setCellValue('CK'.$excel_row, $r->modified_at);
				$excel_row++;
				$nos++;
			}
		}
		//ob_clean();
		$writer = new Xlsx($spreadsheet);
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename="Applications Master Edition.xlsx"'); 
		header('Cache-Control: max-age=0');

		// download file 
		$writer->save('php://output'); 
	}

}