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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/applications/controllers/



Current File : /var/www/html/milestone/application/modules/applications/controllers/Applications.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
require_once APPPATH.'modules/generic/controllers/Generic.php';
require_once APPPATH.'dompdf/dompdf/autoload.inc.php';

use Dompdf\Dompdf;
use Dompdf\Options;

class Applications extends Generic{

	function __construct() {
		parent::__construct();
		$this->load->model('Mdl_applications');	
    define("DOMPDF_ENABLE_HTML5PARSER", true);
    define("DOMPDF_ENABLE_FONTSUBSETTING", true);
    define("DOMPDF_UNICODE_ENABLED", true);
    define("DOMPDF_DPI", 120);
    define("DOMPDF_ENABLE_REMOTE", true);
  }

  /**
   *  Listing Page
   */
  function listPage(){
    $this->adminSession('4');
    $data['scriptFile'] = 'applications';
    $data['viewFile'] = 'list';
    $data['module'] = "applications";
    echo Modules::run('template/admin', $data);
  }

  /**
   *  List Records
   */
  function records(){
    $records = $this->Mdl_applications->get_datatables("applications");
    $data = array();
    $no = $_POST['start']; 
    $admin_session = $this->session->userdata('admin');

    foreach ($records as $val){
      $categoryMaster = $this->Mdl_applications->retrieveByCol(
        "id, category_name, category", 
        "category_master", 
        array(
          "status"=>"active",
          "category"=>$val->category_name
        )
      );
      
      $registration = $this->Mdl_applications->retrieveByCol(
        "full_name, company_name, email", 
        "registration", 
        array(
          "status"=>"active",
          "email_verification"=>"yes",
          "uid"=>$val->uid
        )
      );
      
      if(isset($categoryMaster[0]->category_name)){
        $categoryName = $categoryMaster[0]->category_name;
      }else{
        $categoryName = "NA";
      }
      
      $row = array();
      $row[] = date("d-m-Y",strtotime($val->created_at));
      $uid = $val->uid;
      $url = base_url().'applications/view/'.$val->code;
      $url_pdf = base_url().'applications/generatePdf/'.$val->code;
      $row[] = '<a class="btn btn-circle btn-success" href="'.$url.'"><i class="ti-eye"></i></a>';
      if($val->status == 'submitted'){
        $row[] = '<span class="badge badge-success">SUBMITTED</span>';
      }else{
        $row[] = '<span class="badge badge-warning">SAVED</span>';
      }

      $row[] = $val->application_number;
      $row[] = $val->promoterName?$val->promoterName:$registration[0]->full_name;
      $row[] = $categoryName;
      //$row[] = $segment_type;
      if( $val->step == "category-selection" ){ 
        $row[] ='15%';
      } else if($val->step == "organizational-details" && $val->status == "saved") { 
        $row[] ='30%';
      } else if($val->step == "initiative-details" && $val->status == "saved"){  
        $row[] ='45%';
      } else if($val->step == "application-question" && $val->status == "saved"){  
        $row[] ='60%';
      } else if($val->step == "sustainable-development-goals" && $val->status == "saved") { 
        $row[] ='75%';
      } else if($val->step == "supporting-documents" && $val->status == "submitted") { 
        $row[] ='90%';
      } else if($val->step == "declaration" && $val->status == "submitted") { 
        $row[] ='100%';
      }  else {
        $row[] ='80%';
      }
      $data[] = $row;
    }

    $output = array(
      "draw" => $_POST['draw'],
      "recordsTotal" => $this->Mdl_applications->count_all("applications"),
      "recordsFiltered" => $this->Mdl_applications->count_filtered("applications"),
      "data" => $data,
    );
    echo json_encode($output);
  }

  /**
   *  View Details
   */
  function view($code){
    $this->adminSession('4');
    $personalDetails = $this->Mdl_applications->retrieve("users_application_details",array("code"=>$code));

    if($personalDetails == "NA"){
      redirect("applications/list","refresh");
    }else{
      $documents = $this->Mdl_applications->retrieve("application_documents", array("code"=>$code));
      $registration = $this->Mdl_applications->retrieve("registration", array("uid"=>$personalDetails[0]->uid));

      $query = "select * from category_master where `status`='active' order by id";
      $category_master = $this->Mdl_applications->customQuery($query);

      $data['personalDetails'] = $personalDetails;
      $data['documents'] = $documents;
      $data['category_master'] = $category_master;
      $data['registration'] = $registration;
      $data['scriptFile'] = "applications";
      $data['viewFile'] = "details";
      $data['module'] = "applications";
      echo Modules::run('template/admin', $data);
    }
  }

  /**
   *  Update Entry status
   */
  function update(){
    $content = $this->input->post();

    $this->form_validation->set_rules("assessment","Assessment","trim|xss_clean|required",
    array(
      'required' => "Select status"
    ));

    if( 
      $content['assessment'] == "return" || $content['assessment'] == "reject" 
    ){
      $this->form_validation->set_rules("reason","Reason","trim|xss_clean|required",
      array(
        'required' => "reason required"
      ));
    }else{
      $this->form_validation->set_rules("reason","Reason","trim|xss_clean");
    }

    if($this->form_validation->run() == FALSE){
      $errors = $this->form_validation->error_array();
      echo json_encode($errors); exit;
    }else{

      $code = $content['code'];
      $get_applicant = "SELECT r.full_name, r.email, a.application_number FROM registration r INNER JOIN users_application_details a ON a.uid = r.uid WHERE a.code='$code' ";
      $applicant = $this->Mdl_applications->customQuery($get_applicant);

      $admin_session = $this->session->userdata('admin');
      $assessment = strip_tags($content['assessment']) == "approve" ? "approved" : ( strip_tags($content['assessment']) == "reject" ? "rejected" : "returned" );

      if($assessment == "returned"){
        $updateData = array(
          "status" => "saved",
          "step" => "organizational-details",
          "ey_assessment" => $assessment,
          "reason" => strip_tags($content['reason']),
          "admin_id" => $admin_session['admin_id'],
          "modified_at" => date('Y-m-d H:i:s')
        );
        $update = $this->Mdl_applications->update("users_application_details",array("code"=>$code), $updateData);
        $link = base_url().'login';
        if( $applicant !== "NA" ){
          $mailData = array(
            "viewFile" => "user/application-returned",
            "to" => $applicant[0]->email,
            //"to" => 'rohit@kwebmaker.com',
            "cc" => "",
            "bcc" => "",
            "link" => $link,
            "subject" => "NASSCOM Foundation ‘TechForGood’ Awards - Application Returned",
            "name" => $applicant[0]->full_name,
            "applicationNumber" => $applicant[0]->application_number,
            "reason" => strip_tags($content["reason"]),
            "isAttachment" => false
          );
          $isSent = Modules::run('email/mailer', $mailData); 
        }

      }else{
        $updateData = array(
          "ey_assessment" => $assessment,
          "reason" => strip_tags($content['reason']),
          "admin_id" => $admin_session['admin_id'],
          "modified_at" => date('Y-m-d H:i:s')
        );
        $update = $this->Mdl_applications->update("users_application_details",array("code"=>$code), $updateData);
      }
      echo json_encode(array("status"=>"ENTRY_STATUS_UPDATED"));
    }
  }

  /**
   *  Update recommendation
   */
  function recommend(){
    $content = $this->input->post();
    $adminSession = $this->session->userdata('admin');

    if( 
      isset($content['recommend']) && 
      isset($content['applicationCode'])
    ){
      $update = $this->Mdl_applications->update(
        "users_application_details", 
        array(
          "code"=>$content['applicationCode']
        ), 
        array(
          "is_recommended"=>$content['recommend'], 
          "admin_id"=>$adminSession['admin_id']
        )
      );
      echo json_encode(array("status"=>"success")); exit;
    }else{
      echo json_encode(array("status"=>"fail")); exit;
    }
  }

  public function uploadApplicationDoc(){
    $content = $this->input->post();
    //print_r($content);exit;
    $token= $this->session->userdata("token");
    
    $this->form_validation->set_rules("juryRefFile","File","trim|xss_clean|callback_attachment_check_update[juryRefFile]");
    
    if($this->form_validation->run($this) == FALSE){
      $errors = $this->form_validation->error_array();
      echo json_encode($errors); exit;
    }else{
      $uid = $content['nurce_uid'];
      if(!isset($uid)){
        echo json_encode(array("status"=>"error"));exit;
      }
      
      $documents = $this->Mdl_applications->retrieve("users_application_details", array("uid"=>$uid));
      // if($documents == "NA"){
      //   echo json_encode(array("status"=>"fail"));
      // }
      $applicationCode = $documents[0]->code;
      $uploadPath = 'assets/jury_doc/'.$applicationCode;
      if (!is_dir($uploadPath)){
        mkdir($uploadPath, 0777, true);
      }
      if(!empty($_FILES['juryRefFile']['name'])){
        $juryRefFileName = $_FILES['juryRefFile']['name'];
        $juryRefFileExt = pathinfo($juryRefFileName, PATHINFO_EXTENSION);
        $juryRefFileFileName = 'ED-'.strtotime('now');
        $juryRefFileUpload = $this->uploadFile($juryRefFileFileName,$uploadPath,"jpeg|jpg|png|pdf|doc|docx|ppt|pptx|PNG|JPEG|JPG|PDF|DOC|DOCX|PPT|PPTX",5120,0,0,"juryRefFile");
        $juryRefFilePath = $uploadPath.'/'.$juryRefFileFileName.'.'.$juryRefFileExt;
        if($juryRefFileUpload !== 1){
          echo json_encode(array("juryRefFile"=>$juryRefFileUpload)); exit;
        }else{
          if(
            isset($content['juryRefFileLocation']) && 
            $content['juryRefFileLocation'] !== "" &&
            file_exists('./'.$content['juryRefFileLocation'])
          ){
            $this->removeFileFromServer($content['juryRefFileLocation']);
          }
        }
      }
      $updateData = array(
        "juryRefFileName" => $juryRefFileName,
        "juryRefFilePath" => $juryRefFilePath
      );
      $update = $this->Mdl_applications->update("application_documents",array("code"=>$applicationCode), $updateData);

      echo json_encode(array("status"=>"success"));exit;

    }
    
  }
 

  /**
   *  Callback : Attachment check ( Update )
   */
  public function attachment_check_update($val, $fileInput){
    $allowed_mime_type_arr = array('jpeg','jpg','png','pdf','doc','docx','ppt','pptx','PNG','JPEG','JPG','PDF','DOC','DOCX','PPT','PPTX');
    if(isset($_FILES[$fileInput]['name']) && $_FILES[$fileInput]['name'] !== ""){
      $filename = $_FILES[$fileInput]['name'];
      $size = $_FILES[$fileInput]['size'];
      $ext = pathinfo($filename, PATHINFO_EXTENSION);
      if( !in_array($ext, $allowed_mime_type_arr) ){
        $this->form_validation->set_message('attachment_check_update', 'Please upload a file in the above-mentioned accepted formats only');
        return false;
      }else if( $size > 5242880 ){
        $this->form_validation->set_message('attachment_check_update', 'You have exceeded the maximum file size limit of 5 Mb');
        return false;
      }else{
        return true;
      }
    }
  }


  public function generatePdf($code){
    //define("DOMPDF_ENABLE_REMOTE", false);
		if(empty($code)){
      redirect("entry/list","refresh");
    }
		$application_personal_details = $this->Mdl_applications->retrieve("users_application_details", array("code" => $code));
		if($application_personal_details == "NA"){
			echo json_encode(array("status"=>"fail"));
		}

    $documents = $this->Mdl_applications->retrieve("application_documents", array("code"=>$code));
		$casestudies = $this->Mdl_applications->retrieve("application_casestudies", array("code"=>$code));
		
    if(isset($application_personal_details[0]->application_number)){
      $application_number = str_replace('/', '-', $application_personal_details[0]->application_number);
      $filename = $application_number.' '.$application_personal_details[0]->first_name;
    } else {
      $filename = $application_personal_details[0]->code;
    }

    if(isset($application_personal_details[0]->application_number)){
      $heading = $application_personal_details[0]->application_number;
    } else {
      $heading = $application_personal_details[0]->code;
    }

		
		ob_start();
		$phone_number = $application_personal_details[0]->contact !== "" ? $application_personal_details[0]->phone_code.'-'.$application_personal_details[0]->contact : "";
		// Generate the PDF using Dompdf
		$options = new Options();
		$dompdf = new Dompdf(array('enable_remote' => true));
		$options->set('isRemoteEnabled', true);
    $options->set('isPhpEnabled', true);
    $segmentList = [
      array(
        "title" => "Patient care",
        "label" => "patient",
        "casestudies" => [
          array(
            "question"=> "2. Describe the initiatives undertaken to facilitate and improve the quality of patient care in your daily work environment?",
            "words" => 250,
            "placeholder"=> "I have suggested and led nurse resource management to match the specific needs of patients in two hospitals"
          ),
          array(
            "question"=> "3. Describe the challenges faced and how you overcame them",
            "words" => 250,
            "placeholder"=> "I found that most establishments don’t like a big change to a well-used process. The best way that I have found to tackle that  is by introducing it a little at a time"
          ),
          array(
            "question"=> "4. Describe the impact on patients? How did they respond to the care and empathy you extend?",
            "words" => 250,
            "placeholder"=> "My colleagues and peers have shown excitement at the new ideas to cater to patient needs better, while many patients have shown their appreciation vocally"
          ),
          array(
            "question"=> "5. Describe your story/unique instance pertaining to the area of contribution selected and what differentiates you from other nurses",
            "words" => 250,
            "placeholder"=> "In one instance, I rearranged the frequency of nurse visits so that the patients can be better monitored with a lessening of the burden on the nurse carers"
          )
        ]
      ),
      array(
        "title" => "Nursing Leadership",
        "label" => "leadership",
        "casestudies" => [
          array(
            "question"=> "2. We believe nursing is about leading from the front. So, why would you consider yourself as a leader and what difference that has made?",
            "words" => 250,
            "placeholder"=> "I believe in a confident leadership model that pushes my team and peers to higher standards of care and compassion – which has shown bigger results in my experience"
          ),
          array(
            "question"=> "3. Help us understand the challenges faced and how you overcame them",
            "words" => 250,
            "placeholder"=> "Each person in all the teams I work with have different strengths that I can channel right. Taking time to understand their individual strengths has proven to be very fruitful"
          ),
          array(
            "question"=> "4. How do patients and peers respond to your leadership?",
            "words" => 250,
            "placeholder"=> "After the long process of care that they go through, I have been appreciated for a job done well. My peers have been supportive of my initiatives and continue to extend their encouragement to me"
          ),
          array(
            "question"=> "5. Describe your story/unique instance pertaining to the area of contribution selected and what differentiates you from other nurses",
            "words" => 250,
            "placeholder"=> "I was tasked with setting up a new team of nurses for a new wing of my hospital dealing with a specialties focus. The challenge was to make sure the nurses have up to date knowledge skills for the to-be-treated conditions"
          )
        ]
      ),
      array(
        "title" => "Nursing Education",
        "label" => "education",
        "casestudies" => [
          array(
            "question"=> "2. Describe your contribution with respect to nursing education. Highlight the key initiatives undertaken for improving the quality of education, teaching methods, improving learning etc.",
            "words" => 250,
            "placeholder"=> ""
          ),
          array(
            "question"=> "3. Describe the challenges faced and how you overcame them",
            "words" => 250,
            "placeholder"=> ""
          ),
          array(
            "question"=> "4. Describe the measurable impact of the initiative on the students, nursing industry and communities",
            "words" => 250,
            "placeholder"=> ""
          ),
          array(
            "question"=> "5. Describe your story/unique instance pertaining to the area of contribution selected and what differentiates you from other nurses",
            "words" => 250,
            "placeholder"=> ""
          )
        ]
      ),
      array(
        "title" => "Social/Community service in Healthcare",
        "label" => "social",
        "casestudies" => [
          array(
            "question"=> "2. Describe your contribution for the betterment of the healthcare/nursing community",
            "words" => 250,
            "placeholder"=> "I have been involved with projects that work with sections of society that lack medical care and can’t afford it – who are building their way up now"
          ),
          array(
            "question"=> "3. Describe the challenges faced and how you overcame them",
            "words" => 250,
            "placeholder"=> "It takes a lot of commitment and dedication to stick with projects. It is difficult to find people who stick with me in the long run. To change that, I started an internship that resulted in more hands to work along"
          ),
          array(
            "question"=> "4. Describe the impact of the initiative on the healthcare/nursing community and what change they witnessed?",
            "words" => 250,
            "placeholder"=> "My last two projects resulted in a community that found it feet, felt safer & secure, and more healthy. Improving the health of a community sparks all round change"
          ),
          array(
            "question"=> "5. Describe your story/unique instance pertaining to the area of contribution selected and what differentiates you from other nurses",
            "words" => 250,
            "placeholder"=> "During my last project, I had the opportunity to work with a backward community from where a number of beneficiaries were inspired to join my line of work and take the mission forward"
          )
        ]
      ),
      array(
        "title" => "Research/Innovation/Entrepreneurship in Healthcare",
        "label" => "research",
        "casestudies" => [
          array(
            "question"=> "2. Describe your contributions to nursing research, policy, practice, or any innovation at the local/regional, state, and /or national level",
            "words" => 250,
            "placeholder"=> "I have led research individually, and as a  part of the team, building better changes in treatment methods that have growing application today across the country"
          ),
          array(
            "question"=> "3. Describe the challenges faced and how you overcame them",
            "words" => 250,
            "placeholder"=> "A project required me to learn a new language with a different community. It has been one of the best learning experiences of my career"
          ),
          array(
            "question"=> "4. Describe the impact of the initiative on the patients, organisation and the healthcare industry",
            "words" => 250,
            "placeholder"=> "Over the course of my career, people have been more receptive of new ideas with time. The success of my past research ideas has helped this"
          ),
          array(
            "question"=> "5. Describe your story/unique instance pertaining to the area of contribution selected and what differentiates you from other nurses",
            "words" => 250,
            "placeholder"=> "I was asked to look into finding ways of treatment that can be used in areas with lower medical resources. I was able to define a treatment model that is effectively used today"
          )
        ]
      )
    ];

    $labelList = ['one', 'two', 'three', 'four']; 

    $questionsList = array(
      "patient" => "1. Years of experience in active Patient Care as on September 30, 2023",
      "leadership" => "1. Years of experience in Nursing Leadership role as on September 30, 2023",
      "education" => "1. Years of experience as a Nursing Educator as on September 30, 2023",
      "social" => "1. Years of experience in Social/Community Nursing as on September 30, 2023",
      "research" => "1. Years of experience in Research/ Innovation as on September 30, 2023"
    ); 

    $segmentsArr = explode(",", $casestudies[0]->selected_segments); 
    $primaryArr = explode(",", $casestudies[0]->primary_segment);
    $secondaryArr = $casestudies[0]->secondary_segment !== "" ? explode(",", $casestudies[0]->secondary_segment) : []; 
    if(in_array("patient",$segmentsArr)) { $patient1  = "checked"; } else { $patient1  = ""; }
    if(in_array("patient", $primaryArr)) { $patient2  =  "checked"; } else { $patient2  =  ""; };
    if(in_array("patient",$segmentsArr)) { $patient3  = ""; } else {$patient3  = "disabled";};
    if(in_array("patient", $secondaryArr)) {$patient4 = "checked";} else {$patient4 = ""; }
    $patient5 = in_array("patient",$segmentsArr) ? "" : "disabled";

    $leadership1 = in_array("leadership",$segmentsArr) ? "checked" : "";
    $leadership2 = in_array("leadership", $primaryArr) ? "checked" : ""; 
    $leadership3 = in_array("leadership",$segmentsArr) ? "" : "disabled"; 
    $leadership4 = in_array("leadership", $secondaryArr) ? "checked" : ""; 
    $leadership5 = in_array("leadership",$segmentsArr) ? "" : "disabled"; 

    $education1 = in_array("education",$segmentsArr) ? "checked" : "";
    $education2 = in_array("education", $primaryArr) ? "checked" : ""; 
    $education3 = in_array("education",$segmentsArr) ? "" : "disabled"; 
    $education4 = in_array("education", $secondaryArr) ? "checked" : ""; 
    $education5 = in_array("education",$segmentsArr) ? "" : "disabled"; 

    $social1 =  in_array("social",$segmentsArr) ? "checked" : ""; 
    $social2 =   in_array("social", $primaryArr) ? "checked" : ""; 
    $social3 =  in_array("social",$segmentsArr) ? "" : "disabled"; 
    $social4 = in_array("social", $secondaryArr) ? "checked" : ""; 
    $social5 = in_array("social",$segmentsArr) ? "" : "disabled"; 

    $research1 = in_array("research",$segmentsArr) ? "checked" : ""; 
    $research2 =  in_array("research", $primaryArr) ? "checked" : "";
    $research3 =  in_array("research",$segmentsArr) ? "" : "disabled";
    $research4 = in_array("research", $secondaryArr) ? "checked" : ""; 
    $research5 = in_array("research",$segmentsArr) ? "" : "disabled"; 
        $area_html = '
        <thead>
          <tr>
            <th>Please tick your preferred area of contribution</th>
            <th>Mark as Primary</th>
            <th>Mark as Secondary</th>
            <th>Areas of contribution</th>
            <th>Definition</th>
          </tr>
        </thead>
        <tbody>

          <tr>
            <td width="10%">
              <input 
                type="checkbox"
                id="patient"
                name="segments[]"
                value="patient"
                class="form-control"
                 '.$patient1.'  />
            </td>

            <td width="10%">
              <input 
                type="checkbox"
                id="patient"
                name="primary[]"
                value="patient"
                class="form-control" 
                '.$patient2.'
                '.$patient3.'
              />
            </td>

            <td width="10%">
              <input 
                type="checkbox"
                id="patient"
                name="secondary[]"
                value="patient"
                class="form-control" 
                '.$patient4.'
                '.$patient5.'
              />
            </td>

            <td width="15%">
              Patient Care <br /> 
              <span class="primary patient">Primary</span>
              <span class="secondary patient">Secondary</span>
            </td>
            <td width="55%" class="text-left">Recognizes exemplary work by a registered nurse who has acted as a caregiver and has helped to address patient needs effectively, prevent illness and treat health conditions which has resulted in overall improvement and wellbeing of their patients. The nurse should have also contributed to the advancement of the nursing practice by demonstrating commitment towards his/her professional and personal development</td>
          </tr>  

          <tr>
            <td width="10%">
              <input 
                type="checkbox"
                id="leadership"
                name="segments[]"
                value="leadership"
                class="form-control"
                '.$leadership1.'
                />
            </td>
            <td width="10%">
              <input 
                type="checkbox"
                id="leadership"
                name="primary[]"
                value="leadership"
                class="form-control" 
               '.$leadership2.'
               '.$leadership3.'
              />
            </td>
            <td width="10%">
              <input 
                type="checkbox"
                id="leadership"
                name="secondary[]"
                value="leadership"
                class="form-control" 
                '.$leadership4.'
                '.$leadership5.'
              />
            </td>
            <td width="15%">
              Nursing Leadership <br /> 
              <span class="primary leadership">Primary</span>
              <span class="secondary leadership">Secondary</span>
            </td>
            <td width="55%" class="text-left">Recognizes exemplary leadership qualities demonstrated by a registered nurse who has the ability to inspire, influence and motivate healthcare professionals to enhance patient safety and improve overall healthcare. Nurses should provide motivational strategies to mentor subordinates, grants autonomy, possess high levels of emotional intelligence, demonstrate leadership skills in his/her daily practice and be a role model for others.</td>
          </tr> 

          <tr>
            <td width="10%">
              <input 
                type="checkbox"
                id="education"
                name="segments[]"
                value="education"
                class="form-control"
                '.$education1.'
            </td>
            <td width="10%">
              <input 
                type="checkbox"
                id="education"
                name="primary[]"
                value="education"
                class="form-control" 
                '.$education2.'
                '.$education3.'
              />
            </td>
            <td width="10%">
              <input 
                type="checkbox"
                id="education"
                name="secondary[]"
                value="education"
                class="form-control" 
                '.$education4.'
                '.$education5.'
              />
            </td>
            <td width="15%">
              Nursing Education <br /> 
              <span class="primary education">Primary</span>
              <span class="secondary education">Secondary</span>
            </td>
            <td width="55%" class="text-left">Recognizes the immense contribution made by a registered nurse who has experience in training and developing his/her team by imparting the necessary skills to improve patient care, health and/or operational efficiencies of the institute</td>
          </tr> 

          <tr>
            <td width="10%">
              <input 
                type="checkbox"
                id="social"
                name="segments[]"
                value="social"
                class="form-control"
                '.$social1.' />
            </td>

            <td width="10%">
              <input 
                type="checkbox"
                id="social"
                name="primary[]"
                value="social"
                class="form-control" 
                '.$social2.'
                '.$social3.'
              />
            </td>
            <td width="10%">
              <input 
                type="checkbox"
                id="social"
                name="secondary[]"
                value="social"
                class="form-control" 
                '.$social4.'
                '.$social5.'
              />
            </td>
            <td width="15%">
              Social/Community service in Healthcare <br /> 
              <span class="primary social">Primary</span>
              <span class="secondary social">Secondary</span>
            </td>
            <td width="55%" class="text-left">Recognizes a registered nurse who has made significant contribution towards social/community health nursing, also called public health nursing or community nursing. The nurse should provide details of initiatives taken towards improving health services, preventive care, intervention, and health education to communities or populations</td>
          </tr>  

        
          <tr>
            <td width="10%">
              <input 
                type="checkbox"
                id="research"
                name="segments[]"
                value="research"
                class="form-control"
                '.$research1.' />
            </td>
            <td width="10%">
              <input 
                type="checkbox"
                id="research"
                name="primary[]"
                value="research"
                class="form-control" 
                '.$research2.'
                '.$research3.'
              />
            </td>
            <td width="10%">
              <input 
                type="checkbox"
                id="research"
                name="secondary[]"
                value="research"
                class="form-control" 
                '.$research4.'
                '.$research5.'
              />
            </td>
            <td width="15%">
            Research/Innovation/Entrepreneurship in Healthcare <br /> 
              <span class="primary research">Primary</span>
              <span class="secondary research">Secondary</span>
            </td>
            <td width="55%" class="text-left">Recognizes a registered nurse who has focused on research, innovation and entrepreneurship to enhance knowledge and understanding of patient care and overall wellbeing in order to respond effectively to actual or potential health problems.This could also include initiatives implemented by the nurse as a healthcare entrepreneur focusing on creating value in health products or services, care delivery innovation, etc.</td>
          </tr> 

        </tbody>
      ';
      $seg_html = '';
      foreach( $segmentList as $segment ){ 
        if( in_array($segment['label'], $segmentsArr) ){ 
          //echo "<pre>";print_r($segmentsArr);exit;
              
          if($segment['label'] == 'Primary'){
            $label = "Primary";
          } 
          if($segment['label'] == 'Secondary'){
            $label = "Secondary";
          }
          $seg_html .= '<tr>
          <td>
            <table width="100%" cellpadding="5" cellspacing="0"><tr>
              <h4 style="background:###08bdae; color:#fff; margin:0; padding:5px;">'.ucfirst($segment['title']).' </h4>
          </tr>
          <tr>
              <td>'.$questionsList[$segment['label']].'</td>
          </tr>
          <tr>
              <td>'.$casestudies[0]->{$segment['label'].'_exp'}.'</td>
          </tr>';
          for($i=0; $i<4; $i++){
            $segmentArr = $casestudies[0]->{$segment['label'].'_'.$labelList[$i]} !== "" ? json_decode($casestudies[0]->{$segment['label'].'_'.$labelList[$i]}, true) : null;
            /// echo "<pre>";print_r($segmentArr);exit;
            $textEn = $segmentArr ? $segmentArr['textEn'] : '';
            $seg_html .= '<tr>
              <td>'.$segment['casestudies'][$i]['question'].'</td>
              </tr>
            <tr><td>'.$textEn.'</td></tr>';
          }
          $seg_html .='</table>
            </td>
            
          </tr>';
          /*for($i=0; $i<4; $i++){
            $segmentArr = $casestudies[0]->{$segment['label'].'_'.$labelList[$i]} !== "" ? json_decode($casestudies[0]->{$segment['label'].'_'.$labelList[$i]}, true) : null;
              $seg_html .= '      
                <div class="row align-items-center">
                  <div class="col-lg-12 field">
                    <label><'.$segment['casestudies'][$i]['question'].'></label>
                </div>
                <div class="col-lg-12">
                  '.$segmentArr ? $segmentArr['textEn'] : ''.'
                </div>
              </div>';
             }
          $seg_html .= '</div>'; */
        }
      }
      $country_ref = '';
      $ref_country = Modules::run('api/application/personal/country',$application_personal_details[0]->ref_country_one); 
      $country_ref == "NA" ? "" : $ref_country; 
      $ref_contact_one = $application_personal_details[0]->ref_contact_one !== "" ? $application_personal_details[0]->ref_phone_code_one."-".$application_personal_details[0]->ref_contact_one : "";
      $ref_rel_other_one = $application_personal_details[0]->ref_rel_one == "others" ? $application_personal_details[0]->ref_rel_other_one : ucfirst($application_personal_details[0]->ref_rel_one) ;
      $country_ref_two = '';
      $ref_country_two = Modules::run('api/application/personal/country',$application_personal_details[0]->ref_country_two); 
      $country_ref_two == "NA" ? "" : $ref_country_two; 
      $ref_contact_two = $application_personal_details[0]->ref_contact_two !== "" ? $application_personal_details[0]->ref_phone_code_two."-".$application_personal_details[0]->ref_contact_two : "";
      $ref_rel_other_two = $application_personal_details[0]->ref_rel_two == "others" ? $application_personal_details[0]->ref_rel_other_two : ucfirst($application_personal_details[0]->ref_rel_two);
      $proof_type = $documents[0]->proof_type == "employment" ? "Proof of employment along with validity of the document/ID card (Nurse ID card, letter from institute, etc.)" : "Self declaration if not associated with any institute/hospital";
      $proof_file_em_path = $documents[0]->proof_type == "employment" ? base_url().$documents[0]->employment_file_path : base_url().$documents[0]->declaration_file_path;
      $degree_file_path = !empty($documents[0]->degree_file_path) ? base_url().$documents[0]->degree_file_path : '';
      $medical_file_path = !empty($documents[0]->medical_file_path) ? base_url().$documents[0]->medical_file_path : '';
      $passport_front_file_path = !empty($documents[0]->passport_front_file_path) ? base_url().$documents[0]->passport_front_file_path : '';
      $passport_back_file_path = !empty($documents[0]->passport_back_file_path) ? base_url().$documents[0]->passport_back_file_path : '';
      $nursepic_path = !empty($documents[0]->nursepic_path) ? base_url().$documents[0]->nursepic_path : '';
      $proof_file_path = !empty($documents[0]->proof_file_path) ? base_url().$documents[0]->proof_file_path : '';
      $sup_file_one_path = !empty($documents[0]->wordFIlePath) ? base_url().$documents[0]->wordFIlePath : '';
      
      
      $html = '<!DOCTYPE html>
			<html lang="en" style="margin:0; padding:0;">
				<head>
					<meta charset="UTF-8">
					<meta http-equiv="X-UA-Compatible" content="IE=edge">
					<meta name="viewport" content="width=device-width, initial-scale=1.0">
					<link rel="preconnect" href="https://fonts.googleapis.com">
					<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
					<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
				</head>
				<body style="font-family: "Roboto", sans-serif; margin:0; padding:0;">
				
				<div style="font-size: 17px;">

					<table width="100%" cellpadding="5" cellspacing="0" align="center" style="margin:0 auto; border: 1px solid #ddd;  border-collapse: collapse;">
						
						<tr>
							<td>
                <h1 style="color:##08bdae; text-align:center; text-transform:uppercase">Application Form & '.$heading.'</h1>
								<h4 style="background:#004d80; color:#fff; margin:0; padding:10px;">Personal Details</h4>
								<table width="100%" cellpadding="10" cellspacing="0">
				
									<tr>
										<td>
											<span style="display:block; margin-bottom: 5px;"><strong>Name</strong></span>
											<span>'.$application_personal_details[0]->first_name.'</span>
										</td>
										<td>
											<span style="display:block; margin-bottom: 5px;"><strong>Middle name</strong></span>
											<span>'.$application_personal_details[0]->middle_name.'</span>
										</td>
                    
										<td>
											<span style="display:block; margin-bottom: 5px;"><strong>Last Name</strong></span>
											<span>'.$application_personal_details[0]->last_name.'</span>
										</td>
									</tr>
                  <tr>
                    <td>
											<span style="display:block; margin-bottom: 5px;"><strong>Date Of Birth</strong></span>
											<span>'.date("Y-m-d",strtotime($application_personal_details[0]->email)).'</span>
										</td>
										<td>
											<span style="display:block; margin-bottom: 5px;"><strong>Date Of Birth</strong></span>
											<span>'.date("Y-m-d",strtotime($application_personal_details[0]->dob)).'</span>
										</td>
                    <td>
											<span style="display:block; margin-bottom: 5px;"><strong>Address</strong></span>
											<span>'.$application_personal_details[0]->address.'</span>
										</td>
										
									</tr>

                  <tr>
										<td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Gender</strong></span>
                      <span>'.$application_personal_details[0]->gender.'</span>
                    </td>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Registered as</strong></span>
                      <span>'.$application_personal_details[0]->qualified_as.'</span>
                    </td>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>City</strong></span>
                      <span>'.$application_personal_details[0]->city.'</span>
                    </td>
                  </tr>
                  <tr>
                    <td>
											<span style="display:block; margin-bottom: 5px;"><strong>Country</strong></span>
											<span>'.$application_personal_details[0]->country.'</span>
										</td>
                    <td>
											<span style="display:block; margin-bottom: 5px;"><strong>Region</strong></span>
											<span>'.$application_personal_details[0]->region.'</span>
										</td>
										<td>
											<span style="display:block; margin-bottom: 5px;"><strong>Contact Number</strong></span>
											<span>'.$phone_number.'</span>
										</td>
									</tr>

                  <tr>
										<td>
											<span style="display:block; margin-bottom: 5px;"><strong>Institute/ Hospital name</strong></span>
											<span>'.$application_personal_details[0]->institute.'</span>
										</td>
                    <td>
											<span style="display:block; margin-bottom: 5px;"><strong>Job Title</strong></span>
											<span>'.$application_personal_details[0]->job_title.'</span>
										</td>
										<td>
											<span style="display:block; margin-bottom: 5px;"><strong>Contact Email ID</strong></span>
											<span>'.$application_personal_details[0]->organisation_email.'</span>
										</td>
                   
									</tr>
                  <tr>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Contact Number</strong></span>
                      <span>'.$application_personal_details[0]->organisation_phonecode.'-'.$application_personal_details[0]->organisation_contact.'</span>
                    </td>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>City</strong></span>
                      <span>'.$application_personal_details[0]->city.'</span>
                    </td>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Country</strong></span>
                      <span>'.$application_personal_details[0]->hospital_country.'</span>
                    </td>
                  </tr>

                  <tr>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Reporting Manager Name</strong></span>
                      <span>'.$application_personal_details[0]->relational_manager_name.'</span>
                    </td>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Reporting Manager Designation</strong></span>
                      <span>'.$application_personal_details[0]->relational_manager_designation.'</span>
                    </td>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Reporting Manager Email Id</strong></span>
                      <span>'.$application_personal_details[0]->relational_manager_email.'</span>
                    </td>
										
									</tr>

                  <tr>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Reporting Manager Contact Number</strong></span>
                      <span>'.$application_personal_details[0]->relational_manager_mobile.'</span>
                    </td>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Website link</strong></span>
                      <span>'.$application_personal_details[0]->organisation_website.'</span>
                    </td>
                    
                  </tr>
                  
                  <tr>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Total years of work experience as a Nurse as of September 30, 2023 :</strong></span>
                      <span>'.$application_personal_details[0]->total_exp.'</span>
                    </td>
										<td>
											<span style="display:block; margin-bottom: 5px;"><strong>Years of experience in the current institute/hospital as of September 30, 2023 : </strong></span>
											<span>'.$application_personal_details[0]->current_exp.'</span>
										</td>
									</tr>
								</table>
							</td>
              
						</tr>

            <tr>
							<td>
								<h4 style="background:#004d80; color:#fff; margin:0; padding:10px;">Areas of contribution</h4>
								<table width="100%" cellpadding="5" cellspacing="0">
                  '.$area_html.'
									
								</table>
							</td>
              
						</tr>

            '.$seg_html.'

						<tr>
              <td>
                <h4 style="background:#004d80; color:#fff; margin:0; padding:10px;">References</h4>
                <table width="100%" cellpadding="10" cellspacing="0">
                  <tr>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Reference 1</strong></span>
                      <span>'.$application_personal_details[0]->ref_name_one.'</span>
                    </td>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Referrer email ID</strong></span>
                      <span>'.$application_personal_details[0]->ref_email_one.'</span>
                    </td>
                    
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Referrer country</strong></span>
                      <span>'.$country_ref.'</span>
                    </td>
                  </tr>
                  <tr>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Referrer contact number</strong></span>
                      <span>'.$ref_contact_one.'</span>
                    </td>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Relationship with the reference</strong></span>
                      <span>'.$ref_rel_other_one.'</span>
                    </td>
                    
                  </tr>

                  <tr>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Second Referrer full name</strong></span>
                      <span>'.$application_personal_details[0]->ref_name_two.'</span>
                    </td>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Referrer email ID</strong></span>
                      <span>'.$application_personal_details[0]->ref_email_two.'</span>
                    </td>
                    
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Referrer country</strong></span>
                      <span>'.$country_ref_two.'</span>
                    </td>
                  </tr>
                  <tr>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Referrer contact number</strong></span>
                      <span>'.$ref_contact_two.'</span>
                    </td>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Relationship with the reference</strong></span>
                      <span>'.$ref_rel_other_two.'</span>
                    </td>
                    
                  </tr>
                  
                </table>
              </td>
            </tr>

            <tr>
              <td>
                <h4 style="background:#004d80; color:#fff; margin:0; padding:10px;">Professional Details</h4>
                <table width="100%" cellpadding="5" cellspacing="0">
                  <tr>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Educational Qualification (Highest degree)</strong></span>
                      <span>'.$degree_file_path.'</span>
                    </td>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Medical/Nurse council registration name and number</strong></span>
                      <span>'.$medical_file_path.'</span>
                    </td>
                  </tr>

                  <tr>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Passport copy</strong></span>
                      <span>Agreed</span>
                    </td>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Valid national proof of identity of the country/region you are applying from (Government ID)</strong></span>
                      <span>Agreed</span>
                    </td>
                  </tr>

                  <tr>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Minimum 2 years of employment proof as a registered nurse</strong></span>
                      <span>Agreed</span>
                    </td>
                    
                  </tr>
                  <tr>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>LinkedIn</strong></span>
                      <span>'.$documents[0]->linkedin.'</span>
                    </td>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Twitter</strong></span>
                      <span>'.$documents[0]->twitter.'</span>
                    </td>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Facebook</strong></span>
                      <span>'.$documents[0]->facebook.'</span>
                    </td>
                  </tr>
                  <tr>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Instgram</strong></span>
                      <span>'.$documents[0]->instagram.'</span>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>

            <tr>
              <td>
                <h4 style="background:#004d80; color:#fff; margin:0; padding:10px;">Collaterals</h4>
                <table width="100%" cellpadding="5" cellspacing="0">
                  <tr>
                    <td>
                      <span style="display:block; margin-bottom: 5px;"><strong>Supporting Word documents </strong></span>
                      <span>'.$sup_file_one_path.'</span>
                    </td>
                  </tr>
                  <tr>';
          $html .=  '
                </table>
              </td>
            </tr>
            
            
					</table>

          
				</div>
					
				</body>
			</html> ';
		$dompdf->loadHtml($html);
		//echo $html;exit;
		$dompdf->setPaper('A4', 'landscape');
		$dompdf->render();

		// Send the PDF to the browser
		$dompdf->stream($filename);
		file_put_contents($_SERVER['DOCUMENT_ROOT'].'/assets/pdf/'.$filename.'.pdf', $dompdf->output());
		$filePath = $_SERVER['DOCUMENT_ROOT'].'/assets/pdf/'.$filename.'.pdf';
		//redirect(base_url("web_uploads/exhibitor_form/".$filename));
		// Flush the output buffer
		ob_end_flush();
  }

  public function generatePdfTest($code){
    //define("DOMPDF_ENABLE_REMOTE", false);
		if(empty($code)){
      redirect("entry/list","refresh");
    }
		$application_personal_details = $this->Mdl_applications->retrieve("application_personal_details", array("code" => $code));
		if($application_personal_details == "NA"){
			echo json_encode(array("status"=>"fail"));
		}

    $documents = $this->Mdl_applications->retrieve("application_documents", array("code"=>$code));
		$casestudies = $this->Mdl_applications->retrieve("application_casestudies", array("code"=>$code));
		
    if(isset($application_personal_details[0]->application_number)){
      $application_number = str_replace('/', '-', $application_personal_details[0]->application_number);
      $filename = $application_number.' '.$application_personal_details[0]->first_name;
    } else {
      $filename = $application_personal_details[0]->code;
    }

    if(isset($application_personal_details[0]->application_number)){
      $heading = $application_personal_details[0]->application_number;
    } else {
      $heading = $application_personal_details[0]->code;
    }

		
		ob_start();
		$phone_number = $application_personal_details[0]->contact !== "" ? $application_personal_details[0]->phone_code.'-'.$application_personal_details[0]->contact : "";
		// Generate the PDF using Dompdf
		$options = new Options();
		$dompdf = new Dompdf(array('enable_remote' => true));
		$options->set('isRemoteEnabled', true);
    $options->set('isPhpEnabled', true);
    $segmentList = [
      array(
        "title" => "Patient care",
        "label" => "patient",
        "casestudies" => [
          array(
            "question"=> "2. Describe the initiatives undertaken to facilitate and improve the quality of patient care in your daily work environment?",
            "words" => 250,
            "placeholder"=> "I have suggested and led nurse resource management to match the specific needs of patients in two hospitals"
          ),
          array(
            "question"=> "3. Describe the challenges faced and how you overcame them",
            "words" => 250,
            "placeholder"=> "I found that most establishments don’t like a big change to a well-used process. The best way that I have found to tackle that  is by introducing it a little at a time"
          ),
          array(
            "question"=> "4. Describe the impact on patients? How did they respond to the care and empathy you extend?",
            "words" => 250,
            "placeholder"=> "My colleagues and peers have shown excitement at the new ideas to cater to patient needs better, while many patients have shown their appreciation vocally"
          ),
          array(
            "question"=> "5. Describe your story/unique instance pertaining to the area of contribution selected and what differentiates you from other nurses",
            "words" => 250,
            "placeholder"=> "In one instance, I rearranged the frequency of nurse visits so that the patients can be better monitored with a lessening of the burden on the nurse carers"
          )
        ]
      ),
      array(
        "title" => "Nursing Leadership",
        "label" => "leadership",
        "casestudies" => [
          array(
            "question"=> "2. We believe nursing is about leading from the front. So, why would you consider yourself as a leader and what difference that has made?",
            "words" => 250,
            "placeholder"=> "I believe in a confident leadership model that pushes my team and peers to higher standards of care and compassion – which has shown bigger results in my experience"
          ),
          array(
            "question"=> "3. Help us understand the challenges faced and how you overcame them",
            "words" => 250,
            "placeholder"=> "Each person in all the teams I work with have different strengths that I can channel right. Taking time to understand their individual strengths has proven to be very fruitful"
          ),
          array(
            "question"=> "4. How do patients and peers respond to your leadership?",
            "words" => 250,
            "placeholder"=> "After the long process of care that they go through, I have been appreciated for a job done well. My peers have been supportive of my initiatives and continue to extend their encouragement to me"
          ),
          array(
            "question"=> "5. Describe your story/unique instance pertaining to the area of contribution selected and what differentiates you from other nurses",
            "words" => 250,
            "placeholder"=> "I was tasked with setting up a new team of nurses for a new wing of my hospital dealing with a specialties focus. The challenge was to make sure the nurses have up to date knowledge skills for the to-be-treated conditions"
          )
        ]
      ),
      array(
        "title" => "Nursing Education",
        "label" => "education",
        "casestudies" => [
          array(
            "question"=> "2. Describe your contribution with respect to nursing education. Highlight the key initiatives undertaken for improving the quality of education, teaching methods, improving learning etc.",
            "words" => 250,
            "placeholder"=> ""
          ),
          array(
            "question"=> "3. Describe the challenges faced and how you overcame them",
            "words" => 250,
            "placeholder"=> ""
          ),
          array(
            "question"=> "4. Describe the measurable impact of the initiative on the students, nursing industry and communities",
            "words" => 250,
            "placeholder"=> ""
          ),
          array(
            "question"=> "5. Describe your story/unique instance pertaining to the area of contribution selected and what differentiates you from other nurses",
            "words" => 250,
            "placeholder"=> ""
          )
        ]
      ),
      array(
        "title" => "Social/Community service in Healthcare",
        "label" => "social",
        "casestudies" => [
          array(
            "question"=> "2. Describe your contribution for the betterment of the healthcare/nursing community",
            "words" => 250,
            "placeholder"=> "I have been involved with projects that work with sections of society that lack medical care and can’t afford it – who are building their way up now"
          ),
          array(
            "question"=> "3. Describe the challenges faced and how you overcame them",
            "words" => 250,
            "placeholder"=> "It takes a lot of commitment and dedication to stick with projects. It is difficult to find people who stick with me in the long run. To change that, I started an internship that resulted in more hands to work along"
          ),
          array(
            "question"=> "4. Describe the impact of the initiative on the healthcare/nursing community and what change they witnessed?",
            "words" => 250,
            "placeholder"=> "My last two projects resulted in a community that found it feet, felt safer & secure, and more healthy. Improving the health of a community sparks all round change"
          ),
          array(
            "question"=> "5. Describe your story/unique instance pertaining to the area of contribution selected and what differentiates you from other nurses",
            "words" => 250,
            "placeholder"=> "During my last project, I had the opportunity to work with a backward community from where a number of beneficiaries were inspired to join my line of work and take the mission forward"
          )
        ]
      ),
      array(
        "title" => "Research/Innovation/Entrepreneurship in Healthcare",
        "label" => "research",
        "casestudies" => [
          array(
            "question"=> "2. Describe your contributions to nursing research, policy, practice, or any innovation at the local/regional, state, and /or national level",
            "words" => 250,
            "placeholder"=> "I have led research individually, and as a  part of the team, building better changes in treatment methods that have growing application today across the country"
          ),
          array(
            "question"=> "3. Describe the challenges faced and how you overcame them",
            "words" => 250,
            "placeholder"=> "A project required me to learn a new language with a different community. It has been one of the best learning experiences of my career"
          ),
          array(
            "question"=> "4. Describe the impact of the initiative on the patients, organisation and the healthcare industry",
            "words" => 250,
            "placeholder"=> "Over the course of my career, people have been more receptive of new ideas with time. The success of my past research ideas has helped this"
          ),
          array(
            "question"=> "5. Describe your story/unique instance pertaining to the area of contribution selected and what differentiates you from other nurses",
            "words" => 250,
            "placeholder"=> "I was asked to look into finding ways of treatment that can be used in areas with lower medical resources. I was able to define a treatment model that is effectively used today"
          )
        ]
      )
    ];

    $labelList = ['one', 'two', 'three', 'four']; 

    $questionsList = array(
      "patient" => "1. Years of experience in active Patient Care as on September 30, 2023",
      "leadership" => "1. Years of experience in Nursing Leadership role as on September 30, 2023",
      "education" => "1. Years of experience as a Nursing Educator as on September 30, 2023",
      "social" => "1. Years of experience in Social/Community Nursing as on September 30, 2023",
      "research" => "1. Years of experience in Research/ Innovation as on September 30, 2023"
    ); 
    if(isset($casestudies[0]->selected_segments)){
      $segmentsArr = explode(",", $casestudies[0]->selected_segments); 
    } else {
      $segmentsArr = array(); 
    }
    if(isset($casestudies[0]->selected_segments)){
      $primaryArr = explode(",", $casestudies[0]->primary_segment);
    } else {
      $primaryArr =  array(); 
    }
    if(isset($casestudies[0]->selected_segments)){
      $secondaryArr = $casestudies[0]->secondary_segment !== "" ? explode(",", $casestudies[0]->secondary_segment) : []; 
    } else {
      $secondaryArr =  array(); 
    }
    
    if(in_array("patient",$segmentsArr)) { $patient1  = "checked"; } else { $patient1  = ""; }
    if(in_array("patient", $primaryArr)) { $patient2  =  "checked"; } else { $patient2  =  ""; };
    if(in_array("patient",$segmentsArr)) { $patient3  = ""; } else {$patient3  = "disabled";};
    if(in_array("patient", $secondaryArr)) {$patient4 = "checked";} else {$patient4 = ""; }
    $patient5 = in_array("patient",$segmentsArr) ? "" : "disabled";

    $leadership1 = in_array("leadership",$segmentsArr) ? "checked" : "";
    $leadership2 = in_array("leadership", $primaryArr) ? "checked" : ""; 
    $leadership3 = in_array("leadership",$segmentsArr) ? "" : "disabled"; 
    $leadership4 = in_array("leadership", $secondaryArr) ? "checked" : ""; 
    $leadership5 = in_array("leadership",$segmentsArr) ? "" : "disabled"; 

    $education1 = in_array("education",$segmentsArr) ? "checked" : "";
    $education2 = in_array("education", $primaryArr) ? "checked" : ""; 
    $education3 = in_array("education",$segmentsArr) ? "" : "disabled"; 
    $education4 = in_array("education", $secondaryArr) ? "checked" : ""; 
    $education5 = in_array("education",$segmentsArr) ? "" : "disabled"; 

    $social1 =  in_array("social",$segmentsArr) ? "checked" : ""; 
    $social2 =   in_array("social", $primaryArr) ? "checked" : ""; 
    $social3 =  in_array("social",$segmentsArr) ? "" : "disabled"; 
    $social4 = in_array("social", $secondaryArr) ? "checked" : ""; 
    $social5 = in_array("social",$segmentsArr) ? "" : "disabled"; 

    $research1 = in_array("research",$segmentsArr) ? "checked" : ""; 
    $research2 =  in_array("research", $primaryArr) ? "checked" : "";
    $research3 =  in_array("research",$segmentsArr) ? "" : "disabled";
    $research4 = in_array("research", $secondaryArr) ? "checked" : ""; 
    $research5 = in_array("research",$segmentsArr) ? "" : "disabled"; 
        $area_html = '
        <thead>
          <tr>
            <th>Please tick your preferred area of contribution</th>
            <th>Mark as Primary</th>
            <th>Mark as Secondary</th>
            <th>Areas of contribution</th>
            <th>Definition</th>
          </tr>
        </thead>
        <tbody >

          <tr>
            <td width="10%">
              <input 
                type="checkbox"
                id="patient"
                name="segments[]"
                value="patient"
                class="form-control"
                 '.$patient1.'  />
            </td>

            <td width="10%">
              <input 
                type="checkbox"
                id="patient"
                name="primary[]"
                value="patient"
                class="form-control" 
                '.$patient2.'
                '.$patient3.'
              />
            </td>

            <td width="10%">
              <input 
                type="checkbox"
                id="patient"
                name="secondary[]"
                value="patient"
                class="form-control" 
                '.$patient4.'
                '.$patient5.'
              />
            </td>

            <td width="15%">
              Patient Care <br /> 
              <span class="primary patient">Primary</span>
              <span class="secondary patient">Secondary</span>
            </td>
            <td width="55%" class="text-left">Recognizes exemplary work by a registered nurse who has acted as a caregiver and has helped to address patient needs effectively, prevent illness and treat health conditions which has resulted in overall improvement and wellbeing of their patients. The nurse should have also contributed to the advancement of the nursing practice by demonstrating commitment towards his/her professional and personal development</td>
          </tr>  

          <tr>
            <td width="10%">
              <input 
                type="checkbox"
                id="leadership"
                name="segments[]"
                value="leadership"
                class="form-control"
                '.$leadership1.'
                />
            </td>
            <td width="10%">
              <input 
                type="checkbox"
                id="leadership"
                name="primary[]"
                value="leadership"
                class="form-control" 
               '.$leadership2.'
               '.$leadership3.'
              />
            </td>
            <td width="10%">
              <input 
                type="checkbox"
                id="leadership"
                name="secondary[]"
                value="leadership"
                class="form-control" 
                '.$leadership4.'
                '.$leadership5.'
              />
            </td>
            <td width="15%">
              Nursing Leadership <br /> 
              <span class="primary leadership">Primary</span>
              <span class="secondary leadership">Secondary</span>
            </td>
            <td width="55%" class="text-left">Recognizes exemplary leadership qualities demonstrated by a registered nurse who has the ability to inspire, influence and motivate healthcare professionals to enhance patient safety and improve overall healthcare. Nurses should provide motivational strategies to mentor subordinates, grants autonomy, possess high levels of emotional intelligence, demonstrate leadership skills in his/her daily practice and be a role model for others.</td>
          </tr> 

          <tr>
            <td width="10%">
              <input 
                type="checkbox"
                id="education"
                name="segments[]"
                value="education"
                class="form-control"
                '.$education1.'
            </td>
            <td width="10%">
              <input 
                type="checkbox"
                id="education"
                name="primary[]"
                value="education"
                class="form-control" 
                '.$education2.'
                '.$education3.'
              />
            </td>
            <td width="10%">
              <input 
                type="checkbox"
                id="education"
                name="secondary[]"
                value="education"
                class="form-control" 
                '.$education4.'
                '.$education5.'
              />
            </td>
            <td width="15%">
              Nursing Education <br /> 
              <span class="primary education">Primary</span>
              <span class="secondary education">Secondary</span>
            </td>
            <td width="55%" class="text-left">Recognizes the immense contribution made by a registered nurse who has experience in training and developing his/her team by imparting the necessary skills to improve patient care, health and/or operational efficiencies of the institute</td>
          </tr> 

          <tr>
            <td width="10%">
              <input 
                type="checkbox"
                id="social"
                name="segments[]"
                value="social"
                class="form-control"
                '.$social1.' />
            </td>

            <td width="10%">
              <input 
                type="checkbox"
                id="social"
                name="primary[]"
                value="social"
                class="form-control" 
                '.$social2.'
                '.$social3.'
              />
            </td>
            <td width="10%">
              <input 
                type="checkbox"
                id="social"
                name="secondary[]"
                value="social"
                class="form-control" 
                '.$social4.'
                '.$social5.'
              />
            </td>
            <td width="15%">
              Social/Community service in Healthcare <br /> 
              <span class="primary social">Primary</span>
              <span class="secondary social">Secondary</span>
            </td>
            <td width="55%" class="text-left">Recognizes a registered nurse who has made significant contribution towards social/community health nursing, also called public health nursing or community nursing. The nurse should provide details of initiatives taken towards improving health services, preventive care, intervention, and health education to communities or populations</td>
          </tr>  

        
          <tr>
            <td width="10%">
              <input 
                type="checkbox"
                id="research"
                name="segments[]"
                value="research"
                class="form-control"
                '.$research1.' />
            </td>
            <td width="10%">
              <input 
                type="checkbox"
                id="research"
                name="primary[]"
                value="research"
                class="form-control" 
                '.$research2.'
                '.$research3.'
              />
            </td>
            <td width="10%">
              <input 
                type="checkbox"
                id="research"
                name="secondary[]"
                value="research"
                class="form-control" 
                '.$research4.'
                '.$research5.'
              />
            </td>
            <td width="15%">
            Research/Innovation/Entrepreneurship in Healthcare <br /> 
              <span class="primary research">Primary</span>
              <span class="secondary research">Secondary</span>
            </td>
            <td width="55%" class="text-left">Recognizes a registered nurse who has focused on research, innovation and entrepreneurship to enhance knowledge and understanding of patient care and overall wellbeing in order to respond effectively to actual or potential health problems.This could also include initiatives implemented by the nurse as a healthcare entrepreneur focusing on creating value in health products or services, care delivery innovation, etc.</td>
          </tr> 

        </tbody>
      ';
      $seg_html = '';
      foreach( $segmentList as $segment ){ 
        if( in_array($segment['label'], $segmentsArr) ){ 
          //echo "<pre>";print_r($segmentsArr);exit;
              
          if($segment['label'] == 'Primary'){
            $label = "Primary";
          } 
          if($segment['label'] == 'Secondary'){
            $label = "Secondary";
          }
          $seg_html .= '<tr>
          <td>
            <table width="100%" cellpadding="5" cellspacing="0"><tr>
              <h4 style="background:###08bdae; color:#fff; margin:0; padding:5px;">'.ucfirst($segment['title']).' </h4>
          </tr>
          <tr>
              <td><strong>'.$questionsList[$segment['label']].'</strong></td>
          </tr>
          <tr>
              <td>'.$casestudies[0]->{$segment['label'].'_exp'}.'</td>
          </tr>';
          for($i=0; $i<4; $i++){
            $segmentArr = $casestudies[0]->{$segment['label'].'_'.$labelList[$i]} !== "" ? json_decode($casestudies[0]->{$segment['label'].'_'.$labelList[$i]}, true) : null;
            /// echo "<pre>";print_r($segmentArr);exit;
            $textEn = $segmentArr ? $segmentArr['textEn'] : '';
            $seg_html .= '<tr>
              <td><strong>'.$segment['casestudies'][$i]['question'].'</strong></td>
              </tr>
            <tr><td>'.$textEn.'</td></tr>';
          }
          $seg_html .='</table>
            </td>
            
          </tr>';
          /*for($i=0; $i<4; $i++){
            $segmentArr = $casestudies[0]->{$segment['label'].'_'.$labelList[$i]} !== "" ? json_decode($casestudies[0]->{$segment['label'].'_'.$labelList[$i]}, true) : null;
              $seg_html .= '      
                <div class="row align-items-center">
                  <div class="col-lg-12 field">
                    <label><'.$segment['casestudies'][$i]['question'].'></label>
                </div>
                <div class="col-lg-12">
                  '.$segmentArr ? $segmentArr['textEn'] : ''.'
                </div>
              </div>';
             }
          $seg_html .= '</div>'; */
        }
      }
      //echo $seg_html;exit;
      $country_ref = '';
      $ref_country = Modules::run('api/application/personal/country',$application_personal_details[0]->ref_country_one); 
      $country_ref == "NA" ? "" : $ref_country; 
      $ref_contact_one = $application_personal_details[0]->ref_contact_one !== "" ? $application_personal_details[0]->ref_phone_code_one."-".$application_personal_details[0]->ref_contact_one : "";
      $ref_rel_other_one = $application_personal_details[0]->ref_rel_one == "others" ? $application_personal_details[0]->ref_rel_other_one : ucfirst($application_personal_details[0]->ref_rel_one) ;
      $country_ref_two = '';
      $ref_country_two = Modules::run('api/application/personal/country',$application_personal_details[0]->ref_country_two); 
      $country_ref_two == "NA" ? "" : $ref_country_two; 
      $ref_contact_two = $application_personal_details[0]->ref_contact_two !== "" ? $application_personal_details[0]->ref_phone_code_two."-".$application_personal_details[0]->ref_contact_two : "";
      $ref_rel_other_two = $application_personal_details[0]->ref_rel_two == "others" ? $application_personal_details[0]->ref_rel_other_two : ucfirst($application_personal_details[0]->ref_rel_two);
      // $proof_type = $documents[0]->proof_type == "employment" ? "Proof of employment along with validity of the document/ID card (Nurse ID card, letter from institute, etc.)" : "Self declaration if not associated with any institute/hospital";
      // $proof_file_em_path = $documents[0]->proof_type == "employment" ? base_url().$documents[0]->employment_file_path : base_url().$documents[0]->declaration_file_path;
      $degree_file_path = !empty($documents[0]->degree_file_path) ? base_url().$documents[0]->degree_file_path : '';
      $medical_file_path = !empty($documents[0]->medical_file_path) ? base_url().$documents[0]->medical_file_path : '';
      // $passport_front_file_path = !empty($documents[0]->passport_front_file_path) ? base_url().$documents[0]->passport_front_file_path : '';
      // $passport_back_file_path = !empty($documents[0]->passport_back_file_path) ? base_url().$documents[0]->passport_back_file_path : '';
      // $nursepic_path = !empty($documents[0]->nursepic_path) ? base_url().$documents[0]->nursepic_path : '';
      // $proof_file_path = !empty($documents[0]->proof_file_path) ? base_url().$documents[0]->proof_file_path : '';
      $sup_file_one_path = !empty($documents[0]->wordFIlePath) ? base_url().$documents[0]->wordFIlePath : '';
      
      $linkedin = isset($documents[0]->linkedin) ? $documents[0]->linkedin : '';
      $twitter = isset($documents[0]->twitter) ? $documents[0]->twitter : '';
      $instagram = isset($documents[0]->instagram) ? $documents[0]->instagram : '';
      $facebook = isset($documents[0]->facebook) ? $documents[0]->facebook : '';
      $facebook = isset($documents[0]->facebook) ? $documents[0]->facebook : '';

      $email = isset($application_personal_details[0]->email) ?  $application_personal_details[0]->email : "";
      $html = '<!DOCTYPE html>
			<html lang="en" style="margin:0; padding:0;">
				<head>
					<meta charset="UTF-8">
					<meta http-equiv="X-UA-Compatible" content="IE=edge">
					<meta name="viewport" content="width=device-width, initial-scale=1.0">
					<link rel="preconnect" href="https://fonts.googleapis.com">
					<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
					<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
				</head>
				<body style="font-family: Calibri, sans-serif; margin:0; padding:0;">
				
				<div style="font-size: 15.5px;text-align: center;border: 1px solid #ddd;padding: 0 25px;">

					<table width="100%" cellpadding="5" cellspacing="0" align="center" style="margin:0 auto; border-collapse: collapse;">
						
						<tr>
							<td>
                <h1 style="color:##08bdae; text-align:center; text-transform:uppercase">Application Form & '.$heading.'</h1>
								<h4 style="background:#004d80; color:#fff; margin:0; padding:10px;">Personal Details</h4>
								<table width="100%" cellpadding="10" cellspacing="0">
				
									<tr>
										<td>
											<span width="35%" style="display:block; margin-bottom: 5px;"><strong>Name</strong></span>
										</td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
											<span style="">'.$application_personal_details[0]->first_name.'</span>
										</td>
									</tr>
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Middle name</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$application_personal_details[0]->middle_name.'</span>
                    </td>
                  </tr>
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Last Name</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$application_personal_details[0]->last_name.'</span>
                    </td>
                  </tr>
                  <tr>
                    <td width="35%">
											<span style="display:block; margin-bottom: 5px;"><strong>Email</strong></span>
										</td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
											<span>'.$email.'</span>
										</td>
									</tr>
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Date Of Birth</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.date("Y-m-d",strtotime($application_personal_details[0]->dob)).'</span>
                    </td>
                  </tr>
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Address</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$application_personal_details[0]->address.'</span>
                    </td>
                  </tr>

                  <tr>
										<td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Gender</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$application_personal_details[0]->gender.'</span>
                    </td>
                  </tr>
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Registered as</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$application_personal_details[0]->qualified_as.'</span>
                    </td>
                  </tr>
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>City</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$application_personal_details[0]->city.'</span>
                    </td>
                  </tr>
                  <tr>
                    <td width="35%">
											<span style="display:block; margin-bottom: 5px;"><strong>Country</strong></span>
										</td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
											<span>'.$application_personal_details[0]->country.'</span>
										</td>
									</tr>
                  <tr>
                    <td width="35%">
											<span style="display:block; margin-bottom: 5px;"><strong>Region</strong></span>
										</td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
											<span>'.$application_personal_details[0]->region.'</span>
										</td>
                  </tr>
                  <tr>
										<td width="35%">
											<span style="display:block; margin-bottom: 5px;"><strong>Contact Number</strong></span>
										</td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
											<span>'.$phone_number.'</span>
										</td>
                  </tr>  
                  <tr>
										<td width="35%">
											<span style="display:block; margin-bottom: 5px;"><strong>Institute/ Hospital name</strong></span>
										</td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
											<span>'.$application_personal_details[0]->institute.'</span>
										</td>
                  </tr>
                  <tr>
                    <td width="35%">
											<span style="display:block; margin-bottom: 5px;"><strong>Job Title</strong></span>
										</td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
											<span>'.$application_personal_details[0]->job_title.'</span>
										</td>
                  </tr>
                  <tr>  
										<td width="35%">
											<span style="display:block; margin-bottom: 5px;"><strong>Contact Email ID</strong></span>
										</td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
											<span>'.$application_personal_details[0]->organisation_email.'</span>
										</td>
                  </tr> 
									
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Contact Number</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$application_personal_details[0]->organisation_phonecode.'-'.$application_personal_details[0]->organisation_contact.'</span>
                    </td>
                  </tr>
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>City</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$application_personal_details[0]->city.'</span>
                    </td>
                  </tr> 
                  <tr> 
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Country</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$application_personal_details[0]->hospital_country.'</span>
                    </td>
                  </tr>

                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Reporting Manager Name</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$application_personal_details[0]->relational_manager_name.'</span>
                    </td>
                  </tr> 
                  <tr> 
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Reporting Manager Designation</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$application_personal_details[0]->relational_manager_designation.'</span>
                    </td>
                  </tr>  
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Reporting Manager Email Id</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$application_personal_details[0]->relational_manager_email.'</span>
                    </td>
									</tr>

                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Reporting Manager Contact Number</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$application_personal_details[0]->relational_manager_mobile.'</span>
                    </td>
                  </tr> 
                  <tr> 
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Website link</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$application_personal_details[0]->organisation_website.'</span>
                    </td>
                  </tr>
                  
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Total years of work experience as a Nurse as of September 30, 2023 :</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$application_personal_details[0]->total_exp.'</span>
                    </td>
                  </tr>
                  <tr>  
										<td width="35%">
											<span style="display:block; margin-bottom: 5px;"><strong>Years of experience in the current institute/hospital as of September 30, 2023 : </strong></span>
										</td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
											<span>'.$application_personal_details[0]->current_exp.'</span>
										</td>
									</tr>
								</table>
							</td>
              
						</tr>

            <tr>
							<td>
								<h4 style="background:#004d80; color:#fff; margin:0; padding:10px;">Areas of contribution</h4>
								<table width="100%" cellpadding="3" cellspacing="0" style="height: 100%;">
                  '.$area_html.'
									
								</table>
							</td>
              
						</tr>

            '.$seg_html.'

						<tr>
              <td>
                <h4 style="background:#004d80; color:#fff; margin:0; padding:10px;">References</h4>
                <table width="100%" cellpadding="10" cellspacing="0">
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Reference 1</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$application_personal_details[0]->ref_name_one.'</span>
                    </td>
                  </tr>  
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Referrer email ID</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$application_personal_details[0]->ref_email_one.'</span>
                    </td>
                  </tr>
                  <tr>  
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Referrer country</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$country_ref.'</span>
                    </td>
                  </tr>
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Referrer contact number</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$ref_contact_two.'</span>
                    </td>
                  </tr> 
                  <tr> 
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Relationship with the reference</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$ref_rel_other_one.'</span>
                    </td>
                  </tr>

                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Second Referrer full name</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$application_personal_details[0]->ref_name_two.'</span>
                    </td>
                  </tr>
                  <tr>  
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Referrer email ID</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="65%">
                      <span>'.$application_personal_details[0]->ref_email_two.'</span>
                    </td>
                  </tr>
                  <tr>  
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Referrer country</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$country_ref_two.'</span>
                    </td>
                  </tr>
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Referrer contact number</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="65%">
                      <span>'.$ref_contact_two.'</span>
                    </td>
                  </tr>
                  <tr>  
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Relationship with the reference</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$ref_rel_other_two.'</span>
                    </td>
                  </tr>
                  
                </table>
              </td>
            </tr>

            <tr>
              <td>
                <h4 style="background:#004d80; color:#fff; margin:0; padding:10px;">Professional Details</h4>
                <table width="100%" cellpadding="5" cellspacing="0">
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Educational Qualification (Highest degree)</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$degree_file_path.'</span>
                    </td>
                  </tr>
                  <tr> 
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Medical/Nurse council registration name and number</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$medical_file_path.'</span>
                    </td>
                  </tr>

                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Passport copy</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>Agreed</span>
                    </td>
                  </tr>
                  <tr>  
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Valid national proof of identity of the country/region you are applying from (Government ID)</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>Agreed</span>
                    </td>
                  </tr>

                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Minimum 2 years of employment proof as a registered nurse</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>Agreed</span>
                    </td>
                  </tr>
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>LinkedIn</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$linkedin.'</span>
                    </td>
                  </tr>
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Twitter</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$twitter.'</span>
                    </td>
                  </tr>
                  <tr>  
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Facebook</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$facebook.'</span>
                    </td>
                  </tr>
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Instgram</strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$instagram.'</span>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>

            <tr>
              <td>
                <h4 style="background:#004d80; color:#fff; margin:0; padding:10px;">Collaterals</h4>
                <table width="100%" cellpadding="5" cellspacing="0">
                  <tr>
                    <td width="35%">
                      <span style="display:block; margin-bottom: 5px;"><strong>Supporting Word documents </strong></span>
                    </td>
                    <td width="5%" class="title"><strong>:</strong></td>
                    <td width="60%">
                      <span>'.$sup_file_one_path.'</span>
                    </td>
                  </tr>
                  <tr>';
          $html .=  '
                </table>
              </td>
            </tr>
            
            
					</table>

          
				</div>
					
				</body>
			</html> ';
		$dompdf->loadHtml($html);
		//echo $html;exit;
    //$dompdf->setOptions(['debug' => true]);
		//$dompdf->setPaper('A4', 'portrait');
		$dompdf->setPaper('A4', 'landscape');
		$dompdf->render();

		// Send the PDF to the browser
		$dompdf->stream($filename);
		file_put_contents($_SERVER['DOCUMENT_ROOT'].'/assets/pdf/'.$filename.'.pdf', $dompdf->output());
		$filePath = $_SERVER['DOCUMENT_ROOT'].'/assets/pdf/'.$filename.'.pdf';
		//redirect(base_url("web_uploads/exhibitor_form/".$filename));
		// Flush the output buffer
		ob_end_flush();
  }
  
}