<?php
include 'connect/cms-config.php' ;
include 'requires/function.php' ;
include 'requires/session.php' ;

// include the class
include 'requires/class_resize.php' ;


//check password
if ($_POST['password_inserted']!='') {
	$password_inserted = escapeString($_POST['password_inserted']) ;
	$_SESSION['nomination_password'] = $password_inserted;
}

$mysqli_ck_password = $mysqli->query("SELECT a.password_id, a.content FROM app_password a LEFT JOIN app_password_translation b ON ( a.password_id = b.password_id ) WHERE a.deleted_at IS NULL AND a.password_type = 'nomination' AND b.lang = 'en'");
if ($mysqli_ck_password->num_rows > 0) {
	$row_ck_password = $mysqli_ck_password->fetch_array();
}
if ($_SESSION['nomination_password'] == '' ){
	echo '<script>
			alert("You need password to access this page.");
			window.open("check_password.php?type=nomination&pu='.base64_encode($_SERVER['REQUEST_URI']).'","_self");
		</script>';
}
if($_SESSION['nomination_password'] != $row_ck_password['content']) {
	unset($_SESSION['nomination_password']);
	echo '<script>
			alert("Sorry, password inserted is wrong!");
			var boolean_confirm = confirm("Do you want to retry?");
			if(boolean_confirm == true){
				window.open("check_password.php?type=nomination&pu='.base64_encode($_SERVER['REQUEST_URI']).'","_self");
			}else{
				window.open("index.php","_self");
			}
		</script>';
}

// keep parameter in value
$page 				= escapeString($_GET['page']) ;
$page_mode 			= escapeString($_GET['page_mode']) ;
$type 				= escapeString($_GET['type']) ;
$search 			= escapeString($_GET['search']) ;

// active menu bar
$active_main_menu 	= 'service' ;
$active_sub_menu 	= 'form-submission' ;
$active_menu 		= 'form-nomination-list' ;

// check permission
if ( !permissionCheck($row_user, 'form-nomination-view') ){
	header('Location: index.php') ;
	exit ;
}

// mode type | all list | new | edit
switch($page_mode){
	
	// edit formnomination
	case 'new' :
	case 'edit' :

		// check query exsits
		$submit_type = 'new' ;
		$mysqli_page = $mysqli->query("SELECT * FROM formnomination
									   WHERE formnomination_id = '".$page."' LIMIT 1");
		if ($mysqli_page->num_rows > 0){
			// keep query value in array
			$row_page    = $mysqli_page->fetch_array(MYSQLI_ASSOC) ;
			$submit_type = 'edit' ;
		}

		// update database
		if ( isset($type) && ( $type == 'new' || $type == 'edit' ) && $_POST['hide'] == 1 ){

			// update database
			$mysqli->query( "UPDATE formnomination SET
							 comment 	    	  = '".escapeString($_POST['comment'])."',
							 status 	    	  = '".escapeString($_POST['status'])."'
							 WHERE formnomination_id  = '".$page."'" ) ;

			if ( $row_page['status'] != $_POST['status'] ){
				pushToUserCron( 'formnomination', $page, $row_page['staff_id'], 'Nomination', 'Nomination has been update.' ) ;
			}

			// refresh page
			header("Location:app-form-nomination.php?page_mode=edit&page=".$page."&success=1") ;
			$_SESSION['system_result'] = 'success-updated' ;
			exit ;
		}

		if ( ( $page_mode == 'new' && !permissionCheck($row_user, 'form-nomination-new') ) ||
			 ( $page_mode == 'edit' && !permissionCheck($row_user, 'form-nomination-edit') ) ){
			header('Location: app-form-nomination.php') ;
			exit ;
		}

		// get all media
		$media_list   = [] ;
		$mysqli_media = $mysqli->query( "SELECT file, filetype FROM formnomination_media
										 WHERE deleted_at IS NULL AND formnomination_id = '".$page."'" ) ;
		if ( $mysqli_media->num_rows > 0 ){
			while ( $row_media = $mysqli_media->fetch_assoc() ){
				$media_list[]  = $row_media ;
			}
		}

		// get all staff
		$staff_list   = [] ;
		$mysqli_staff = $mysqli->query( "SELECT staff_id, staff_name, staff_idno FROM staff
										WHERE deleted_at IS NULL ".$user_branch_permission_sql) ;
		if ( $mysqli_staff->num_rows > 0 ){
			while ( $row_staff = $mysqli_staff->fetch_assoc() ){
				$staff_list[$row_staff['staff_id']] = dataFilter($row_staff['staff_name']) . ' ( ' . dataFilter($row_staff['staff_idno']) . ' )' ;
			}
		}

		// start header here
		include 'requires/page_header.php';
		include 'requires/page_top.php';
		?>

		<div class="warper container-fluid">   	
			<div class="page-header"><h1>Nomination <small><?= $lang[$page_mode] ?></small></h1></div>
			<?php
            if ($_SESSION['system_result'] != ''){
                switch($_SESSION['system_result']){
                    case 'success-updated' :
                        echo '<div class="result_success">'.$lang['Thank you details has been updated'].'</div>' ;	
                    break ;
                }
                unset($_SESSION['system_result']) ;
            }
            ?>
            <div class="panel panel-default">
                <div class="panel-heading"></div>
                <div class="panel-body">
                    <form method="post" class="form-horizontal" id="quotationForm" enctype="multipart/form-data" action="app-form-nomination.php?page_mode=edit&page=<?= $page ?>&type=edit" novalidate="novalidate">

                    	<?php
							$mysql_ck_position_1 = $mysqli->query("SELECT a.job_position_id, b.job_position_desc FROM setting_job_position a LEFT JOIN setting_job_position_translation b ON ( a.job_position_id = b.job_position_id ) LEFT JOIN staff c ON ( a.job_position_id = c.job_position_id ) WHERE a.deleted_at IS NULL AND b.lang = 'en' AND c.staff_id = '".$row_page['staff_id']."' LIMIT 1");

							if ($mysql_ck_position_1->num_rows > 0 ) {
								$row_ck_position_1 = $mysql_ck_position_1->fetch_assoc();
							}

							$mysqli_ck_department_1 = $mysqli->query("SELECT a.department_id, b.department_desc FROM setting_department a LEFT JOIN setting_department_translation b ON ( a.department_id = b.department_id ) LEFT JOIN staff_department c ON ( a.department_id = c.department_id ) WHERE c.staff_id = '".$row_page['staff_id']."' AND a.deleted_at IS NULL AND b.lang = 'en' LIMIT 1");
							if ($mysqli_ck_department_1->num_rows > 0 ) {
								$row_ck_department_1 = $mysqli_ck_department_1->fetch_assoc();
							}
                    	?>

                    	<div class="form-group">
                        	<div class="col-sm-1 control-label" style="text-align:left">Nominator</div>
                      	</div>
						<div class="form-group">
                            <div class="col-sm-2 control-label">Staff</div>
                            <div class="col-sm-9">
                                <select name="nominator_staff_id" id="nominator_staff_id" class="chosen-select form-control tab_index ui-dropdown-select ui-search-input select2-basic-single">
                                	<option value="">Select</option>
									<?php
									if ( count($staff_list) > 0 ){
										foreach ( $staff_list as $k => $v ){
											echo '<option value="'.$k.'" '.( $k == $row_page['staff_id'] ? 'selected' : '').'>'.$v.'</option>' ;
										}
									}

									?>
								</select>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-2 control-label">Department</div>
                            <div class="col-sm-9">
                                <input type="text" class="form-control ui-search-input" readonly value="<?= dataFilter($row_ck_department_1['department_desc']) ?>" />
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-2 control-label">Position</div>
                            <div class="col-sm-9">
                                <input type="text" class="form-control ui-search-input" readonly value="<?= dataFilter($row_ck_department_1['job_position_desc']) ?>" />
                            </div>
                        </div>

                        <hr />


                        <?php
							$mysql_ck_position_2 = $mysqli->query("SELECT a.job_position_id, b.job_position_desc FROM setting_job_position a LEFT JOIN setting_job_position_translation b ON ( a.job_position_id = b.job_position_id ) LEFT JOIN staff c ON ( a.job_position_id = c.job_position_id ) WHERE a.deleted_at IS NULL AND b.lang = 'en' AND c.staff_id = '".$row_page['nominee_staff_id']."' LIMIT 1");

							if ($mysql_ck_position_2->num_rows > 0 ) {
								$row_ck_position_2 = $mysql_ck_position_2->fetch_assoc();
							}

							$mysqli_ck_department_2 = $mysqli->query("SELECT a.department_id, b.department_desc FROM setting_department a LEFT JOIN setting_department_translation b ON ( a.department_id = b.department_id ) LEFT JOIN staff_department c ON ( a.department_id = c.department_id ) WHERE c.staff_id = '".$row_page['nominee_staff_id']."' AND a.deleted_at IS NULL AND b.lang = 'en' LIMIT 1");
							if ($mysqli_ck_department_2->num_rows > 0 ) {
								$row_ck_department_2 = $mysqli_ck_department_2->fetch_assoc();
							}
                    	?>

                        <div class="form-group">
                        	<div class="col-sm-1 control-label" style="text-align:left">Nominee</div>
                      	</div>
                        <div class="form-group">
                            <div class="col-sm-2 control-label">Staff</div>
                            <div class="col-sm-9">
                                <select name="nominee_staff_id" id="nominee_staff_id" class="chosen-select form-control tab_index ui-dropdown-select ui-search-input select2-basic-single">
                                	<option value="">Select</option>
									<?php
									if ( count($staff_list) > 0 ){
										foreach ( $staff_list as $k => $v ){
											echo '<option value="'.$k.'" '.( $k == $row_page['nominee_staff_id'] ? 'selected' : '').'>'.$v.'</option>' ;
										}
									}
									?>
								</select>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-2 control-label">Department</div>
                            <div class="col-sm-9">
                                <input type="text" class="form-control ui-search-input" readonly value="<?= dataFilter($row_ck_department_2['department_desc']) ?>" />
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-2 control-label">Position</div>
                            <div class="col-sm-9">
                                <input type="text" class="form-control ui-search-input" readonly value="<?= dataFilter($row_ck_department_2['job_position_desc']) ?>" />
                            </div>
                        </div>

                        <hr />

                        <?php
                        $question_list   = [] ;
                        $form_list       = [] ;
                        $answer_list     = [] ;

                        // get all question & form
                        $mysqli_question = $mysqli->query( "SELECT a.question_id, a.question_type, a.sortable, b.title, b.content FROM formnomination_question a 
                        								    LEFT JOIN formnomination_question_translation b ON ( a.question_id = b.question_id ) 
                        								    WHERE a.deleted_at IS NULL AND b.lang = 'en' AND a.branch like '%/".$_SESSION['url_get_branch_admin']."/%' ORDER BY a.sortable ASC" ) ;
                        if ( $mysqli_question->num_rows > 0 ){
                        	while ( $row_question    = $mysqli_question->fetch_assoc() ){
                        		if ( $row_question['question_type'] == 'question' ){
                        			$question_list[] = $row_question ;
                        		}
                        		if ( $row_question['question_type'] == 'form' ){
                        			$form_list[]     = $row_question ;
                        		}
                        	}
                        }

                        // get all answer
                        $mysqli_answer     = $mysqli->query( "SELECT question_id, checkbox, remark FROM formnomination_answer
                        									  WHERE formnomination_id = '".$page."'" ) ;
                        if ( $mysqli_answer->num_rows > 0 ){
                        	while ( $row_answer = $mysqli_answer->fetch_assoc() ){
                        		$answer_list[$row_answer['question_id']]  = $row_answer ;
                        	}
                        }

                        // render question & form
                        if ( count($question_list) > 0 ){
                        	echo '
                        	<div class="form-group">
	                       		<div class="col-sm-1 control-label" style="text-align:left">Question</div>
                        	</div>' ;

                        	foreach ( $question_list as $k => $v ){
                        		$get_answer = $answer_list[$v['question_id']] ;

                        		echo '
                        		<div class="form-group">
		                            <div class="col-sm-2 control-label">'.$v['title'].'</div>
		                            <div class="col-sm-9">
		                            	'.$v['content'].'
		                            </div>
		                        </div>
		                        <div class="form-group">
		                            <div class="col-sm-2 control-label">Answer</div>
		                            <div class="col-sm-9">
		                            	<input type="radio" name="question-'.$v['sortable'].'" value="yes" '.( $get_answer['checkbox'] == 'yes' ? 'checked' : '' ).' />
										<label>Yes</label>
										<span>&emsp;</span>
										<input type="radio" name="question-'.$v['sortable'].'" value="no" '.( $get_answer['checkbox'] == 'no' ? 'checked' : '' ).' />
										<label>No</label>

		                                <textarea class="form-control ui-search-input" readonly rows="10" cols="50">'.$get_answer['remark'].'</textarea>
		                            </div>
		                        </div>
		                        <br>' ;
                        	}
                        }

                        if ( count($form_list) > 0 ){
                        	echo '
                        	<div class="form-group">
	                       		<div class="col-sm-1 control-label" style="text-align:left">Form</div>
                        	</div>' ;

                        	foreach ( $form_list as $k => $v ){
                        		$get_answer = $answer_list[$v['question_id']] ;

                        		echo '
                        		<div class="form-group">
		                            <div class="col-sm-2 control-label">'.$v['title'].'</div>
		                            <div class="col-sm-9">
		                            	'.$v['content'].'
		                            </div>
		                        </div>
		                        <div class="form-group">
		                            <div class="col-sm-2 control-label">Answer</div>
		                            <div class="col-sm-9">
		                                <textarea class="form-control ui-search-input" readonly rows="10" cols="50">'.$get_answer['remark'].'</textarea>
		                            </div>
		                        </div>
		                        <br>' ;
                        	}
                        }
                        ?>

                        <div class="form-group">
                            <div class="col-sm-2 control-label">Status</div>
                            <div class="col-sm-9">
                                <select name="status" id="status" class="form-control ui-search-input">
                                	<option value="pending"   <?= ( $row_page['status'] == 'pending' ? 'selected' : '' ) ?> >Pending</option>
                                	<option value="confirmed" <?= ( $row_page['status'] == 'confirmed' ? 'selected' : '' ) ?> >Confirmed</option>
                                	<option value="approved"   <?= ( $row_page['status'] == 'approved' ? 'selected' : '' ) ?> >Approved</option>
                                	<option value="rejected"  <?= ( $row_page['status'] == 'rejected' ? 'selected' : '' ) ?> >Rejected</option>
								</select>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-2 control-label">Comment</div>
                            <div class="col-sm-9">
                            	<textarea name="comment" class="content" id="editor2" rows="10" cols="80" <?=$row_user['user_permission'] != 'admin' ? 'readonly' : '' ?>> <?= dataFilter($row_page['comment']) ?>  </textarea>
		                        <script>
		                        CKEDITOR.replace('editor2') ;
		                        </script>
                            </div>
                        </div>

                        <?php if ( $row_page['status'] != 'confirmed' && $row_page['status'] != 'rejected' ){ ?>
	                        <div class="form-group">
	                            <div class="col-sm-2 control-label"></div>
	                            <div class="col-sm-9">
	                                <button type="submit" class="btn btn-purple" style="float:right"><?= $lang['submit']?></button>
	                                <input type="hidden" name="hide" value="1">
	                                <input type="hidden" name="page_status" value="<?= $submit_type ?>">
	                            </div>
	                        </div>   
	                    <?php } ?>

                    </form>
                </div>
            </div>
		</div>

		<?php
		
	break ;
	
	// all announcement list
	case 'all' :
	default :
		
		$search_name = escapeString($_GET['search_name']) ;
		$search_idno = escapeString($_GET['search_idno']) ;
		$search_mobile = escapeString($_GET['search_mobile']) ;
		$search_mail = escapeString($_GET['search_mail']) ;
		$search_date = ( $_GET['search_date']!= '' ? date('Y-m-d', strtotime($_GET['search_date'])) : '' ) ;
		$search_update_date = ( $_GET['search_update_date']!= '' ? date('Y-m-d', strtotime($_GET['search_update_date'])) : '' ) ;
		$search_type = escapeString($_GET['search_type']) ;

		$export_excel = escapeString($_GET['export-excel']) ;

		// query type
		$search_query = '' ;
		
		// search query
		if ($search != ''){
			$search_query  .= " AND ( title LIKE '%".$search."%' )" ;
		}
		if( $search_name   != ''){
			$search_query  .= " AND b.staff_name LIKE '%".$search_name."%'" ;
		}
		if( $search_idno   != ''){
			$search_query  .= " AND b.staff_idno LIKE '%".$search_idno."%'" ;
		}
		if( $search_mobile != ''){
			$search_query  .= " AND b.staff_mobileno LIKE '%".$search_mobile."%'" ;
		}
		if( $search_mail   != ''){
			$search_query  .= " AND b.staff_email LIKE '%".$search_mail."%'" ;
		}
		if ( $search_date  != '' ){
		    $search_query  .= " AND a.created_at like '%".$search_date."%' " ;
		}
		if ( $search_update_date != '' ){
		    $search_query  .= " AND a.updated_at like '%".$search_update_date."%' " ;
		}
		if( $search_type   != ''){
			$search_query  .= " AND a.status = '".$search_type."'" ;
		}

		$get_user_tier      = userTierQuery( $row_user ) ;
		$search_query 	   .= ( $get_user_tier['check'] ? " AND b.staff_tier IN ( ".implode(', ', $get_user_tier['tiers'])." )" : '' ) ;
		
		// form submit
		if ( $_POST['hide'] == '1' && $_POST['hide_status'] == 'action' ){
			switch($_POST['page_action']){
				case 'trash':
					$mysqli_query = "UPDATE formnomination SET
									deleted_at = '".TODAYDATE."'
									WHERE formnomination_id = " ;
					$trash_page = trashPage('formnomination', $mysqli, $mysqli_query, $_POST['multiple_trash']) ;
				break;
			}
		}
		
		// pagination
		if (isset($page) && !empty($page)) { $product_page = $page ; } else { $product_page = 1 ; } // next and prev page (5 thing need to change)
		$start_from = ($product_page - 1) * LIMIT ; //end next and prev page
		
		// set search url
		$search_url = 'search='.$search.'&search_name='.$search_name.'&search_date='.$search_date.'&search_update_date='.$search_update_date.'&page_mode='.$page_mode.'&search_idno='.$search_idno.'&search_mobile='.$search_mobile.'&search_mail='.$search_mail.'&search_type='.$search_type ;
		
		// page query
		$mysqli_query = "SELECT a.*, b.staff_idno, b.staff_name FROM formnomination a
						 LEFT JOIN staff b ON ( a.staff_id = b.staff_id )
						 WHERE a.deleted_at IS NULL " . $search_query.$user_branch_permission_sql_b ;
		$mysqli_page = $mysqli->query( $mysqli_query." ORDER BY a.formnomination_id DESC LIMIT $start_from, " . LIMIT ) ;

		// load pagination
		$page_pagination = nextPrevious($product_page, LIMIT, $search_url, $mysqli_query) ;


		if ( $export_excel == 'export_eae' ){

		    $page_export_file_name = 'Nomination Report-';

		    $array_header_excel =   array( 
		                                'No.',
		                                'ID', 
		                                'Name',
		                                'Status',
		                                'Created Date',
		                                'Updated Date'
		                            ) ;

		    $mysqli_export = $mysqli->query( $mysqli_query ) ;

		    if ( $mysqli_export->num_rows > 0 ){
		    	$count_mysqli_export_page = 0;
		        while ( $mysqli_export_page = $mysqli_export->fetch_assoc() ){
		        	$count_mysqli_export_page ++;
		            $array_body_excel[] = array( 
		                                        $count_mysqli_export_page,
		                                        $mysqli_export_page['staff_idno'], 
		                                        $mysqli_export_page['staff_name'],
		                                        $mysqli_export_page['status'], 
		                                        date('Y-m-d', strtotime($mysqli_export_page['created_at'])),
		                                        date('Y-m-d', strtotime($mysqli_export_page['updated_at']))
		                                    ) ;
		        }
		        $count_mysqli_export_page = 0;
		    }

		    include 'export_excel_default.php';

		}
		
		// start header here
		include 'requires/page_header.php' ;
		include 'requires/page_top.php' ;

		?>
		<!-- Header Ends -->
		<div class="warper container-fluid">   	
			
			<div class="page-header">
				<h1>Nomination <small><?= $lang['list']?></small></h1>
				<?php if ( permissionCheck($row_user, 'form-nomination-question') ){ ?>
					<a href="app-form-nomination-question.php?page_mode=all" class="btn btn-purple" target="_blank">Question List</a>
				<?php } ?>
			</div>
			
		    <div class="panel panel-default" id="basic-table-title">
		        <div class="panel-heading" style="text-align:right">
		        	<a href="?search_name=<?= $search_name ?>&search_idno=<?= $search_idno ?>&search_mobile=<?= $search_mobile ?>&search_mail=<?= $search_mail ?>&search_date=<?= $search_date ?>&search_update_date=<?= $search_update_date ?>&search_type=<?= $search_type ?>&page_mode=list&search=<?= $search ?>&export-excel=export_eae">Export As Excel</a>
		        </div>
		        <div class="panel-body">
		            <form method="get" class="form-horizontal" style="max-width:600px;">
		                <div class="form-group">
		                    <label class="col-sm-2 control-label"><?= $lang['Name'] ?></label>
		                    <div class="col-sm-9">
		                        <input type="text" name="search_name" value="<?= $search_name ?>" class="form-control" />
		                    </div>
		                </div>
		                <div class="form-group">
		                    <label class="col-sm-2 control-label"><?= $lang['ID No'] ?></label>
		                    <div class="col-sm-9">
		                        <input type="text" name="search_idno" value="<?= $search_idno ?>" class="form-control" />
		                    </div>
		                </div>
		                <div class="form-group">
		                    <label class="col-sm-2 control-label"><?= $lang['Mobile'] ?></label>
		                    <div class="col-sm-9">
		                        <input type="text" name="search_mobile" value="<?= $search_mobile ?>" class="form-control" />
		                    </div>
		                </div>
		                <div class="form-group">
		                    <label class="col-sm-2 control-label"><?= $lang['email'] ?></label>
		                    <div class="col-sm-9">
		                        <input type="text" name="search_mail" value="<?= $search_mail ?>" class="form-control" />
		                    </div>
		                </div>
	                    <div class="form-group">
		                    <label class="col-sm-2 control-label"><?= $lang['Created At'] ?></label>
		                    <div class="col-sm-9">
		                        <input class="form-control" name="search_date" type="date" value="<?= $search_date ?>" placeholder="Date Resigned">
		                    </div>
		                </div>
		                <div class="form-group">
		                    <label class="col-sm-2 control-label"><?= $lang['Updated At'] ?></label>
		                    <div class="col-sm-9">
		                        <input class="form-control" name="search_update_date" type="date" value="<?= $search_update_date ?>" placeholder="Date Updated">
		                    </div>
		                </div>
	                    <div class="form-group">
		                    <label class="col-sm-2 control-label"><?= $lang['status'] ?></label>
		                    <div class="col-sm-9">
		                        <select class="form-control" name="search_type">
		                        	<option value=""><?= $lang['All'] ?></option>
		                        	<option value="pending" <?= ($search_type == 'pending' ? 'selected' : '') ?>>Pending</option>
		                        	<option value="confirmed" <?= ($search_type == 'confirmed' ? 'selected' : '') ?>>Confirmed</option>
		                        	<option value="approved" <?= ($search_type == 'approved' ? 'selected' : '') ?>>Approved</option>
		                        	<option value="rejected" <?= ($search_type == 'rejected' ? 'selected' : '') ?>>Rejected</option>
		                        </select>
		                    </div>
		                </div>
		                <div class="form-group">
		                    <div class="col-sm-11">
		                        <input type="hidden" name="page_mode" value="<?= $page_mode ?>" />
		                        <input type="hidden" name="search" value="<?= $search ?>" />
		                        <button type="submit" class="btn btn-purple" style="float:right"><?= $lang['submit'] ?></button>
		                    </div>
		                </div>
		            </form>
		        </div>
		    </div>


            <form method="post">
                
                <?php if ( permissionCheck($row_user, 'form-nomination-trash') ){ ?>
                <div class="panel panel-default">
                    <div class="panel-body">
                        <select name="page_action" class="form-control selectpicker">
                            <option value=""><?= $lang['select']?></option>
                            <option value="trash"><?= $lang['move_to_trash']?></option>
                        </select>
                        <input type="hidden" name="hide" value="1" />
                        <input type="hidden" name="hide_status" value="action" />
                        <input type="submit" class="btn btn-purple" value="<?= $lang['submit']?>" />
                    </div>
                </div>
                <?php } ?>

                <div class="panel panel-default">
                    <div class="panel-heading"></div>
                    <div class="panel-body">
						<table cellpadding="0" cellspacing="0" border="0" class="responsive table table-striped table-bordered" id="basic-datatable">
							<thead>
								<tr>
									<th><?= $lang['Action']?></th>
									<th><?= $lang['Staff']?></th>
									<th><?= $lang['status']?></th>
									<th><?= $lang['Created At']?></th>
									<th><?= $lang['Updated At']?></th>
                                    <th width="50"><?= $lang['trash']?></th>
								</tr>
							</thead>
							<tbody>
								<?php
								if ($mysqli_page->num_rows > 0){
									while ( $row_page = $mysqli_page->fetch_array(MYSQLI_ASSOC) ){

										// default variable
										$id = $row_page['formnomination_id'] ;
		
										echo '
										 <tr class="odd gradeX">
										 	<td class="align_center">' ;
												if ( permissionCheck($row_user, 'form-nomination-edit') ){
													echo '
										 			<a title="Edit Current Nomination" href="app-form-nomination.php?page_mode=edit&page='.$id.'"><i class="fa fa-edit"></i></a>' ;
												}else{
													echo '-' ;
												}
											echo '
										 	</td>
											<td class="text-center">'.dataFilter($row_page['staff_name']).' ( '.dataFilter($row_page['staff_idno']).' )</td>
											<td class="text-center">'.resetStatus($row_page['status']).'</td>
											<td class="text-center">'.resetDateFormat($row_page['created_at']).'</td>
											<td class="text-center">'.resetDateFormat($row_page['updated_at']).'</td>
											<td>
												<div class="checkbox multiple_trash">
													<input type="checkbox" name="multiple_trash['.$id.']" class="trash_button" value="1">
													<label for="checkbox1"></label>
												</div>
											</td>
										</tr>';
									}
								}else{
									echo '
									<tr class="odd gradeX">
										<td class="border_none">'.$lang['no_data'].'</td>
										<td class="border_none"></td>
										<td class="border_none"></td>
										<td class="border_none"></td>
										<td class="border_none"></td>
										<td class="border_none"></td>
									</tr>' ;
								}
								?>
							</tbody>
						</table>
						<?= $page_pagination['page_pagination'] ?>
                    </div>
                </div>
			</form>
		</div>
		<?php
	break ;
}
// footer
include 'requires/page_footer.php' ;
?>