<?php
$this->session = \Config\Services::session();$query_reader = new \App\Models\_query_reader();
$jquery = "<script src='".base_url()."/assets/js/jquery-2.1.1.min.js' type='text/javascript'></script>";
$javascript = "<script type='text/javascript' src='".base_url()."/assets/js/tmis.js'></script>".get_AJAX_constructor(true);

$tableHTML = "<link rel='stylesheet' href='".base_url()."/assets/css/tmis.css' type='text/css' media='screen' />
<link rel='stylesheet' href='".base_url()."/assets/css/tmis.list.css' type='text/css' media='screen' />";

if (!empty($area) && $area == "show_bigger_image") {
    $tableHTML .= "<table width='530' height='398' border='0' cellspacing='0' cellpadding='0'><tr><td><img src='".$url."' border='0' /></td></tr></table>";
} elseif (!empty($area) && $area == "basic_msg" && !empty($msg)) {
    $tableHTML .= format_notice($this, $msg);
} elseif (!empty($area) && $area == "address_field_form") {
    $tableHTML .= "<table border='0' cellspacing='0' cellpadding='5' id='".$field_id."__form' class='simpleform'>";

    $tableHTML .= !empty($physical_only)? "":"<tr><td>
  			<div class='nextdiv'><input type='radio' name='".$field_id."__addresstype' id='".$field_id."__addresstype_physical' value='physical' ".((!$this->session->get($field_id.'__addresstype') || ($this->session->get($field_id.'__addresstype') && $this->session->get($field_id.'__addresstype')=='physical'))? 'checked': '')."><label for='".$field_id."__addresstype_physical'>Physical</label></div>
  			<div class='nextdiv'><input type='radio' name='".$field_id."__addresstype' id='".$field_id."__addresstype_postal' value='postal' ".(($this->session->get($field_id.'__addresstype') && $this->session->get($field_id.'__addresstype')=='postal')? 'checked': '')."><label for='".$field_id."__addresstype_postal'>Postal</label></div>
		</td></tr>";

    $tableHTML .= "<tr><td><input type='text' id='".$field_id."__addressline' name='".$field_id."__addressline' class='textfield' placeholder='Address (e.g. Plot 23 Kira Rd)' value='".($this->session->get($field_id.'__addressline')? $this->session->get($field_id.'__addressline'): '')."' maxlength='200'/></td></tr>
	
  <tr><td><input type='text' id='".$field_id."__county' name='".$field_id."__county' class='textfield selectfield searchable editable optional' placeholder='County (Optional)' data-val='-district-".$field_id."' value='".($this->session->get($field_id.'__county')? $this->session->get($field_id.'__county'): '')."' maxlength='200'/>
  <input type='hidden' id='-district-".$field_id."' name='-district-".$field_id."' value='".$field_id."__district' /></td></tr>
  
  <tr><td><input type='text' id='".$field_id."__district' name='".$field_id."__district' class='textfield selectfield editable' placeholder='District or State' value='".($this->session->get($field_id.'__district')? $this->session->get($field_id.'__district'): '')."' maxlength='200'/>".
        ($this->session->get($field_id.'__district__hidden')? "<input type='hidden' id='".$field_id."__district__hidden' name='".$field_id."__district__hidden' value='".$this->session->get($field_id.'__district__hidden')."' /><div id='".$field_id."__district__div' class='selectfielddiv'></div>": "")
        ."</td></tr>
  
  <tr><td><input type='text' id='".$field_id."__country' name='".$field_id."__country' class='textfield selectfield' placeholder='Country' value='".($this->session->get($field_id.'__country')? $this->session->get($field_id.'__country'): '')."' maxlength='200'/>".
        ($this->session->get($field_id.'__country__hidden')? "<input type='hidden' id='".$field_id."__country__hidden' name='".$field_id."__country__hidden' value='".$this->session->get($field_id.'__country__hidden')."' /><div id='".$field_id."__country__div' class='selectfielddiv'></div>": "")
        ."</td></tr>
  
  <tr><td style='text-align:right'><button type='button' id='".$field_id."__btn' name='".$field_id."__btn' ".($this->session->get($field_id.'__addressline')? "class='submitbtn btn' onclick=\"postFormFromLayer('".$field_id."__form')\"": "class='submitbtn greybtn'").">SAVE</button><div id='".$field_id."__resultsdiv' style='display:none;'></div><input type='hidden' id='".$field_id."__response_fields' name='".$field_id."__response_fields' value='".$field_id."__addressline' /><input type='hidden' id='".$field_id."__type' name='".$field_id."__type' value='address' /></td></tr>
  </table>";
} elseif (!empty($area) && $area == "dropdown_list") {
    $tableHTML .= !empty($list)? $list: "";
} elseif (!empty($area) && $area == "education_form") {
    $tableHTML .= "<table border='0' cellspacing='0' cellpadding='10' class='microform'>
  <tr>
    <td class='label' style='width:150px;'>Institution:</td>
    <td><div class='nextdiv'><input type='text' id='institutionname' name='institutionname' title='Institution Name' class='textfield' value='".(!empty($details['institutionname'])? $details['institutionname']: '')."'/></div>
      <div class='nextdiv'><input type='text' id='institution__institutiontype' name='institution__institutiontype' class='textfield selectfield' value='".(!empty($details['institution__institutiontype'])? $details['institution__institutiontype']: '')."' placeholder='Institution Type' /></div></td>
  </tr>
  <tr>
    <td class='label'>Period:</td>
    <td><div class='nextdiv'>
    <table border='0' cellspacing='0' cellpadding='0'>
    <tr><td class='value' style='padding-right:9px;'>From</td>
    <td><input type='text' id='from__month' name='from__month' placeholder='Month' class='textfield selectfield' style='width:100px;' value=''/></td>
    <td><input type='text' id='from__pastyear' name='from__pastyear' placeholder='Year' class='textfield selectfield' style='width:55px;' value=''/></td>
    </tr>
    </table>
    </div>
    <div class='nextdiv'>
    <table border='0' cellspacing='0' cellpadding='0'>
    <tr><td class='value' style='padding-right:30px;'>To</td>
    <td><input type='text' id='to__month' name='to__month' placeholder='Month' class='textfield selectfield' style='width:100px;' value=''/></td>
    <td><input type='text' id='to__pastyear' name='to__pastyear' placeholder='Year' class='textfield selectfield' style='width:55px;' value=''/></td>
    </tr>
    </table>
    </div></td>
  </tr>
  <tr>
    <td class='label'>Certificate Obtained:</td>
    <td><div class='nextdiv'><input type='text' id='certificatename' name='certificatename' placeholder='e.g., MSc. Mathematics' title='Certificate Name' class='textfield' value='".(!empty($details['certificatename'])? $details['certificatename']: '')."'/></div>
      <div class='nextdiv'><input type='checkbox' id='highestcertificate' name='highestcertificate' value='Y' ".(!empty($details['highestcertificate'])? 'checked': '')."/>
      <label for='highestcertificate'>This is my highest certificate.</label></div></td>
  </tr>
  <tr>
    <td class='label'>Certificate Number:</td>
    <td><input type='text' id='certificatenumber' name='certificatenumber' title='Certificate Number' class='textfield optional' value='".(!empty($details['certificatenumber'])? $details['certificatenumber']: '')."'/></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><button type='button' name='saveeducation' data-val='".(!empty($details['item_id']) && !empty($type)? $type."_id": "")."' id='saveeducation' class='greybtn submitmicrobtn'>ADD</button><input type='hidden' id='action' name='action' value='".base_url().(($this->session->get('is_admin_adding_teacher') || $this->session->get('is_teacher_updating'))? "/teacher": "/Register/step_three/action")."/add_education' /><input type='hidden' id='resultsdiv' name='resultsdiv' value='institution_list' />".(!empty($details['item_id']) && !empty($type)? "<input type='hidden' name='".$type."_id' id='".$type."_id' value='".$details['item_id']."' />": "")."</td>
  </tr>
        </table>";
} elseif (!empty($area) && $area == "education_list") {
    $tableHTML .= !empty($response['msg'])? format_notice($this, $response['msg']): "";

    if ($this->session->get('education_list')) {
        $tableHTML .= "<table border='0' cellspacing='0' cellpadding='0' class='resultslisttable".(!empty($mode) && $mode=='preview'? " preview":" editable")."'>
			<tr><td colspan='3'>Education List</td></tr>";

        foreach ($this->session->get('education_list') as $row) {
            $tableHTML .= "<tr id='".$row['education_id']."'><td class='edit'>&nbsp;</td>
			<td><div class='nextdiv'><span class='label'>".$row['institution__institutiontype'].": ".$row['institutionname']."</span><br>".$row['certificatename']."</div>
				<div class='nextdiv'>(".$row['from__month']." ".$row['from__pastyear']." - ".$row['to__month']." ".$row['to__pastyear'].")<br>Certificate # ".$row['certificatenumber']."</div>
				<div class='nextdiv'>".(!empty($row['highestcertificate']) && $row['highestcertificate'] == 'Y'? "-- highest --": "&nbsp;")."</div></td>
			<td class='delete'>&nbsp;</td>
			</tr>";
        }
        $tableHTML .= "</table>";
    }
} elseif ((!empty($area) && $area == "subject_form") && (isset($_SESSION['teacherQualCat']) && $_SESSION['teacherQualCat'] != 'Primary')) {
    $tableHTML .= "<table border='0' cellspacing='0' cellpadding='10' class='microform'>
  <tr>
    <td class='label' style='width:150px;'>Subject Name:</td>
    <td><div class='nextdiv'><input type='text' id='subjectname' name='subjectname' title='Subject Name' class='textfield selectfield searchable editable' value='".(!empty($details['subjectname'])? $details['subjectname']: '')."'/></div>
      <div class='nextdiv'><input type='text' id='subject__subjecttype' name='subject__subjecttype' class='textfield selectfield' value='".(!empty($details['subject__subjecttype'])? $details['subject__subjecttype']: '')."' placeholder='Subject Type' /></div></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><button type='button' name='savesubject' id='savesubject' data-val='".(!empty($details['item_id']) && !empty($type)? $type."_id": "")."' class='greybtn submitmicrobtn'>ADD</button><input type='hidden' id='action' name='action' value='".base_url().(($this->session->get('is_admin_adding_teacher') || $this->session->get('is_teacher_updating'))? "/teacher": "/Register/step_three/action")."/add_subject' /><input type='hidden' id='resultsdiv' name='resultsdiv' value='subject_list' />".(!empty($details['item_id']) && !empty($type)? "<input type='hidden' name='".$type."_id' id='".$type."_id' value='".$details['item_id']."' />": "")."</td>
  </tr>
  </table>";
} elseif ((!empty($area) && $area == "subject_list") && (isset($_SESSION['teacherQualCat']) && $_SESSION['teacherQualCat'] != 'Primary')) {
    $tableHTML .= !empty($response['msg'])? format_notice($this, $response['msg']): "";

    if ($this->session->get('subject_list')) {
        $tableHTML .= "<table border='0' cellspacing='0' cellpadding='0' class='resultslisttable".(!empty($mode) && $mode=='preview'? " preview":" editable")."'>
			<tr><td colspan='3'>Subject List</td></tr>";

        foreach ($this->session->get('subject_list') as $row) {
            $tableHTML .= "<tr id='".$row['subject_id']."'><td class='edit'>&nbsp;</td>
			<td><div class='nextdiv'>".$row['subjectname']."</div>
				<div class='nextdiv'>".(!empty($row['subject__subjecttype']) && $row['subject__subjecttype'] != 'Other'? "-- ".strtolower($row['subject__subjecttype'])." --": "&nbsp;")."</div></td>
			<td class='delete'>&nbsp;</td>
			</tr>";
        }
        $tableHTML .= "</table>";
    }
} elseif (!empty($area) && $area == "document_form") {
    $isEditing = (!empty($details['documentname']) && $this->session->get('edit_step_3_document'))? true: false;
    $tableHTML .= "<table border='0' cellspacing='0' cellpadding='10' class='microform'>
  <tr>
    <td class='label top' style='width:150px;'>Document:</td>
    <td style='vertical-align:top;'><div class='nextdiv' style='vertical-align:top;'><input type='text' id='documentname' name='documentname' title='Document Name' placeholder='Name' class='textfield' value='".(!empty($details['documentname'])? $details['documentname']: '')."'/></div>
      <div class='nextdiv hideonedit' ".($isEditing? "style='display:none;'": "")."><input type='text' id='documenturl' name='documenturl' title='Document URL' data-size='500' data-val='pdf' class='textfield filefield".($isEditing? " optional": "")."' placeholder='Document File' value=''/>
    <div class='smalltext'>Allowed Format: PDF  &nbsp;&nbsp; Max Size: 2000kB</div></div></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><button type='button' name='savedocument' data-val='".(!empty($details['item_id']) && !empty($type)? $type."_id": "")."' id='savedocument' class='greybtn submitmicrobtn'>ADD</button><input type='hidden' id='action' name='action' value='".base_url()."/".(($this->session->get('is_admin_adding_teacher') || $this->session->get('is_teacher_updating'))? "/teacher": "/Register/step_three/action")."/add_document' /><input type='hidden' id='resultsdiv' name='resultsdiv' value='document_list' />".(!empty($details['item_id']) && !empty($type)? "<input type='hidden' name='".$type."_id' id='".$type."_id' value='".$details['item_id']."' />": "")."</td>
  </tr>
  </table>";
}






#else if(!empty($area) && $area == "document_list")
#{
 #   $tableHTML .= !empty($response['msg'])? format_notice($this, $response['msg']): "";

  #  if($this->session->get('document_list'))
   # {
    #    $tableHTML .= "<table border='0' cellspacing='0' cellpadding='0' class='resultslisttable".(!empty($mode) && $mode=='preview'? " preview":" editable")."'>
#			<tr><td colspan='3'>Document List</td></tr>";
#
 #       foreach($this->session->get('document_list') AS $row)
  #      {
   #         $isRemovable = (empty($row['is_removable']) || (!empty($row['is_removable']) && $row['is_removable']=='Y'))? true: false;

    #        $tableHTML .= "<tr id='".$row['document_id']."'><td ".($isRemovable? " class='edit'" :"").">&nbsp;</td>
#			<td><a href='".base_url()."/Page/download/folder/documents/file/".$row['documenturl']."'>".$row['documentname']."</a></td>
#			<td ".($isRemovable? " class='delete'" :"").">&nbsp;</td>
#			</tr>";
 #       }
  #      $tableHTML .= "</table>";
   # }
#}


elseif (!empty($area) && $area == "document_list") {
    $tableHTML .= !empty($response['msg'])? format_notice($this, $response['msg']): "";

    if ($this->session->get('document_list')) {
        $tableHTML .= "<table border='0' cellspacing='0' cellpadding='0' class='resultslisttable".(!empty($mode) && $mode=='preview'? " preview":" editable")."'>
			<tr><td colspan='3'>Document List</td></tr>";

        foreach ($this->session->get('document_list') as $row) {
            $isRemovable = (empty($row['is_removable'])||(!empty($row['TeacherStatus']) && $row['TeacherStatus']=='rejected')  || (!empty($row['is_removable']) && $row['is_removable']=='Y'))? true: false;

            $tableHTML .= "<tr id='".$row['document_id']."'><td ".($isRemovable? " class='edit'" :"").">&nbsp;</td>
			<td><div class='nextdiv'>
            <a href='".base_url()."/Page/download/folder/documents/file/".$row['documenturl']."'>".$row['documentname']."</a>
            </div></td>
			<td ".($isRemovable? " class='delete'" :"").">&nbsp;</td>
			</tr>";
        }
        $tableHTML .= "</table>";
    }
} elseif (!empty($area) && $area == "certs_list") {
    $tableHTML .= !empty($response['msg'])? format_notice($this, $response['msg']): "";

    if ($this->session->get('certs_list')) {
        $tableHTML .= "<table border='0' cellspacing='0' cellpadding='0' class='resultslisttable'>
            <tr><td colspan='3'>Issued Document List</td></tr>";

        foreach ($this->session->get('certs_list') as $row) {
            // $isRemovable = (empty($row['is_removable']) || (!empty($row['is_removable']) && $row['is_removable']=='Y'))? true: false;

            $tableHTML .= "<tr id='".$row['document_id']."'>
            
			<td><a href='".base_url()."/Page/download/folder/documents/file/".$row['documenturl']."'>".$row['documentname']."</a></td>
			
			</tr>";
        }
        $tableHTML .= "</table>";
    }
} elseif (!empty($area) && $area == "tiet_list") {
    $tableHTML .= !empty($response['msg'])? format_notice($this, $response['msg']): "";

    if ($this->session->get('tiet_list')) {
        
        $tableHTML .= "<table border='0' cellspacing='0' cellpadding='0' class='resultslisttable'>";

        foreach ($this->session->get('tiet_list') as $row) {
            echo $row['certificate'];
        }
        $tableHTML .= "</table>";
    }
} elseif (!empty($area) && in_array($area, array("verify_vacancy", "verify_user", "verify_permission", "verify_school", "verify_census"))) {
    $item = str_replace('verify_', '', $area);
    $additional = in_array($area, array("verify_user", "verify_permission", "verify_school"))? "WARNING: The ".$item." will be completely removed from the system. ": "";

    $tableHTML .= "<table border='0' cellspacing='0' cellpadding='5' width='100%' />
	<tr><td width='99%'><textarea id='reason_".$action."_".$id."' name='reason_".$action."_".$id."' class='yellowfield' style='width:100%' placeholder='".$additional."Enter the reason you want to ".$list_type." this ".$item.". (Optional)'></textarea></td>
	<td width='1%'><input id='confirm_".$action."_".$id."' name='confirm_".$action."_".$id."' type='button' class='greybtn confirmlistbtn' style='width:125px;' value='CONFIRM' /><div style='padding-top:5px;'><input id='cancel_".$action."_".$id."' name='cancel_".$action."_".$id."' type='button' class='greybtn cancellistbtn' style='width:125px;' value='CANCEL' /><input type='hidden' id='hidden_".$action."_".$id."' name='hidden_".$action."_".$id."' value='".$item."' /></div></td></tr>
	</table>";
} elseif (!empty($area) && in_array($area, array("verify_interview"))) {
    $item = str_replace('verify_', '', $area);

    $tableHTML .= "<table border='0' cellspacing='0' cellpadding='5' width='100%' />
	<tr><td width='99%'><textarea id='reason_".$action."_".$id."' name='reason_".$action."_".$id."' class='yellowfield' style='width:100%' placeholder='WARNING: The ".$item." will be completely removed from the system. Enter the reason you want to cancel this ".$item.". (Optional)'></textarea></td>
	<td width='1%'><input id='confirm_".$action."_".$id."' name='confirm_".$action."_".$id."' type='button' class='greybtn confirmlistbtn' style='width:125px;' value='CONFIRM' /><div style='padding-top:5px;'><input id='cancel_".$action."_".$id."' name='cancel_".$action."_".$id."' type='button' class='greybtn cancellistbtn' style='width:125px;' value='CANCEL' /><input type='hidden' id='hidden_".$action."_".$id."' name='hidden_".$action."_".$id."' value='".$item."' /></div></td></tr>
	</table>";
} elseif (!empty($area) && $area == 'verify_teacher') {
    $item = str_replace('verify_', '', $area);

    $tableHTML .= "<table border='0' cellspacing='0' cellpadding='5' width='100%' />
	<tr><td width='99%'>";

    if ($action == 'confirm_document') {
        $tableHTML .= "<table border='0' cellspacing='0' cellpadding='0' width='100%' />
		<tr>
		<th>Category: </hd>
		<td  colspan='3'><input type='text' id='_".$action."_".$id."category__categories' name='_".$action."_".$id."category__categories' placeholder='Select Grade Category' class='textfield selectfield yellowfield otherfield  ' style='width:100%' onclick='setDatePicker()'/></td>
		</tr>
		<tr><td class='label'>Grade:</td><td><input type='text' id='_".$action."_".$id."grade__grades' name='_".$action."_".$id."grade__grades' placeholder='Select Grade' class='textfield selectfield yellowfield otherfield grade' style='width:97%' onclick='setDatePicker()'/></td>
			<td class='label'>Effective Date:</td><td><input type='text' id='effectivedate_".$action."_".$id."' name='effectivedate_".$action."_".$id."' title='Effective Date' class='textfield datefield clickactivated yellowfield otherfield' value='' style='width:97%'/></td>
		</tr>
		<tr>
			<td class='label top'>Comment:</td><td colspan='3'><textarea id='reason_".$action."_".$id."' name='reason_".$action."_".$id."' class='yellowfield' style='width:100%' maxlength='200' placeholder='This comment will be sent to all those parties involved in the approval of this teacher. (Optional)'></textarea></td>
		</tr>
		</table>";
    } elseif ($action == 'approve_toconfirmed') {
        $tableHTML .= "<table border='0' cellspacing='0' cellpadding='0' width='100%' />
		<tr>
		<th>Category: </hd>
		<td  colspan='3'><input type='text' id='_".$action."_".$id."category__categories' name='_".$action."_".$id."category__categories' placeholder='Select Grade Category' class='textfield selectfield yellowfield otherfield grade__category' style='width:100%' onclick='setDatePicker()'/></td>
		</tr>
		<tr><td class='label'>Grade:</td>
        <td id='grades'>
         <input type='text' id='_".$action."_".$id."grade__grades' name='_".$action."_".$id."grade__grades' placeholder='Select Grade' class='textfield selectfield yellowfield otherfield grade grade__grades' style='width:97%' onclick='setDatePicker()'/>
        </td>
        <td id='multiple_grades' style='display:none;'><div class='yellowfield' style='max-height:200px; overflow-y: auto; width:390px;'>
        <table border='0' cellspacing='0' cellpadding='0' class='listtable'>";
        if($_SESSION['__selected_permission'] == 'verify_pre_primary_teacher_application_at_instructor_level') $grades = $query_reader->get_list('get_teacher_grades', array('searchstring'=>' WHERE g.grade_category LIKE 4'));
        else $grades = $query_reader->get_list('get_teacher_grades', array('searchstring'=>' WHERE g.grade_category IS NOT NULL AND g.grade_category NOT LIKE 4'));
        foreach($grades as $grade){        
        $tableHTML .= "<tr class='listrow'><td>
            <input type='checkbox' name='multiple_grades[]' id='grades_".$grade['value']."_".$id."' class='optional' value='".$grade['value']."' />
            <label for='grades_".$grade['value']."_".$id."' style='white-space: nowrap;'>".$grade['display']."</label>
            </td></tr>";
        }
        $tableHTML .= "</table></div></td>
        <td class='label'>Effective Date:</td><td><input type='text' id='effectivedate_".$action."_".$id."' name='effectivedate_".$action."_".$id."' title='Effective Date' class='textfield datefield clickactivated yellowfield otherfield' value='' style='width:97%'/></td>
		</tr>
		<tr>
			<td class='label top'>Comment:</td><td colspan='3'><textarea id='reason_".$action."_".$id."' name='reason_".$action."_".$id."' class='yellowfield' style='width:100%' maxlength='200' placeholder='This comment will be sent to all those parties involved in the approval of this teacher. (Optional)'></textarea></td>
		</tr>
		</table>";
    } elseif ($action == 'approve_toactive') {
        $tableHTML .= "<table border='0' cellspacing='0' cellpadding='0' width='100%' />
		<tr>
		<th>Category: </hd>
		<td  colspan='3'><input type='text' id='_".$action."_".$id."category__categories' name='_".$action."_".$id."category__categories' placeholder='Select Grade Category' class='textfield selectfield yellowfield otherfield  ' style='width:100%' onclick='setDatePicker()'/></td>
		</tr>
		<tr><td class='label'>Grade:</td><td><input type='text' id='_".$action."_".$id."grade__grades' name='_".$action."_".$id."grade__grades' placeholder='Select Grade' class='textfield selectfield yellowfield otherfield grade' style='width:97%' onclick='setDatePicker()'/></td>
			<td class='label'>Effective Date:</td><td><input type='text' id='effectivedate_".$action."_".$id."' name='effectivedate_".$action."_".$id."' title='Effective Date' class='textfield datefield clickactivated yellowfield otherfield' value='' style='width:97%'/></td>
		</tr>
		<tr>
			<td class='label top'>Comment:</td><td colspan='3'><textarea id='reason_".$action."_".$id."' name='reason_".$action."_".$id."' class='yellowfield' style='width:100%' maxlength='200' placeholder='This comment will be sent to all those parties involved in the approval of this teacher. (Optional)'></textarea></td>
		</tr>
		</table>";
    } else {
        $tableHTML .= ($list_type == "reject")? "<textarea id='reason_".$action."_".$id."' name='reason_".$action."_".$id."' class='textfield' style='width:100%' placeholder='Enter the reason you want to ".$list_type." this ".$item.".'></textarea>":"<textarea id='reason_".$action."_".$id."' name='reason_".$action."_".$id."' class='yellowfield' style='width:100%' placeholder='Enter the reason you want to ".$list_type." this ".$item.".(Optional)'></textarea>";
    }

    $tableHTML .= "</td>
	<td width='1%' style='vertical-align:top; padding-top:10px;'><input id='confirm_".$action."_".$id."' name='confirm_".$action."_".$id."' type='button' class='greybtn confirmlistbtn' style='width:125px;' value='CONFIRM' /><div style='padding-top:5px;'><input id='cancel_".$action."_".$id."' name='cancel_".$action."_".$id."' type='button' class='greybtn cancellistbtn' style='width:125px;' value='CANCEL' /><input type='hidden' id='hidden_".$action."_".$id."' name='hidden_".$action."_".$id."' value='".$item."' /></div></td></tr>
	</table>";
} elseif (!empty($area) && $area == 'permission_list') {
    $tableHTML .= "<link rel='stylesheet' href='".base_url()."/assets/css/tmis.list.css' type='text/css' media='screen' />
	<table border='0' cellspacing='0' cellpadding='5' width='100%' class='listtable' />
	<tr class='header'><td>Category</td><td>Permission</td></tr>";
    foreach ($list as $row) {
        $tableHTML .= "<tr class='listrow'><td>".ucwords(str_replace('_', ' ', $row['category']))."</td><td>".$row['display']."</td></tr>";
    }
    $tableHTML .= "</table>";
} elseif (!empty($area) && $area == 'message_sending_results') {
    if ($result['boolean']) {
        $msg = !empty($result['msg'])? $result['msg']: 'The message has been sent';
        $this->session->set('msg', $msg);
        $tableHTML = "<script>document.location.href='".base_url()."/Message/inbox';</script>";
    } else {
        $tableHTML = !empty($result['msg'])? $result['msg']: 'error';
    }
} elseif (!empty($area) && $area == 'message_details') {
    if (!empty($message)) {
        $tableHTML .= "<table border='0' cellspacing='0' cellpadding='5' width='100%' class='listtable' />
			<tr><td colspan='2' class='h2' style='font-weight:bold;'>".$message['subject']."</td></tr>
			<tr><td class='label'>Date:</td><td class='value'>".date('d-M-Y h:ia T', strtotime($message['date_sent']))."</td></tr>
			<tr><td class='label'>From:</td><td class='value'>".$message['sender_name']."</td></tr>
			<tr><td class='label'>To:</td><td class='value'>".$message['recipient_name']."</td></tr>
			<tr><td class='label top'>Details:</td><td>".html_entity_decode($message['details'], ENT_QUOTES)."</td></tr>".
            (!empty($message['attachment'])? "<tr><td class='label'>Attachment:</td><td class='value'><a href='".base_url()."/Page/download/folder/documents/file/".$message['attachment']."'>".$message['attachment']."</a></td></tr>": '')."</table>";
    } else {
        $tableHTML .= format_notice($this, $msg);
    }
} elseif (!empty($area) && $area == "census_sub_lists") {
    if (!empty($list)) {
        $tableHTML .= "<table border='0' cellspacing='0' cellpadding='0' class='listtable'>
			<tr class='header'><td>Code</td><td>Name</td>".($type=='training'? "<td>Type</td>": '')."</tr>";

        foreach ($list as $row) {
            $tableHTML .= "<tr class='listrow'>
			<td>".$row['code']."</td>
			<td>".$row[$type]."</td>".
                ($type=='training'? "<td>".$row['type']."</td>": '')
                ."</tr>";
        }
        $tableHTML .= "</table>";
    } elseif (empty($msg)) {
        $tableHTML .= format_notice($this, 'WARNING: There is no '.$type.' for this census.');
    } else {
        $tableHTML .= format_notice($this, $msg);
    }
} elseif (!empty($area) && $area == "choose_job_option") {
    $tableHTML .= "<table border='0' cellspacing='0' cellpadding='5' width='100%'>
	<tr><td colspan='2' class='h1'>Are you registered yet?</td></tr>
	<tr><td style='text-align:left;'><button type='button' name='proceed' id='proceed' data-rel='".base_url()."/Account/login' class='greybtn frompop'>Yes. Login and Apply</button></td><td style='text-align:right;'><button type='button' name='register' id='register' data-rel='".base_url()."/Register/step_one' class='btn frompop'>No. Register and Apply</button></td></tr>
	</table>";
}












echo $tableHTML;
