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

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

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

// active menu bar
$active_main_menu   = 'service' ;
$active_sub_menu    = 'training' ;
$active_menu        = 'training-list-list' ;

// get all branch
$branch_all     = [] ;
$get_branch = $mysqli->query( "SELECT * FROM branch
                               WHERE deleted_at IS NULL " . $user_branch_permission_sql_123 ) ;
if ( $get_branch->num_rows > 0 ){
    while ( $row_branch = $get_branch->fetch_assoc() ){
        $branch_all[$row_branch['branch_id']] = $row_branch['branch_name'] ;
    }
}

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

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

		// check query exsits
		$submit_type = 'new' ;
		$mysqli_page = $mysqli->query("SELECT * FROM training
									   WHERE training_id = '".$training_id."' 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 ){

			// keep value in variable
			$page_title      = escapeString($_POST['title']) ;
			$page_title      = ($page_title != '' ? $page_title : 'No Title') ;
			if ( $training_id == '' ){
				$mysqli->query( "INSERT INTO training 
							    ( created_at ) VALUES 
							    ( '".TODAYDATE."' )" ) ;
				$training_id = $mysqli->insert_id ;	
			}

			// resize image
	        // set image in variable
			$image 		  = $_FILES["image"]["name"] ;
			$image_query  = '' ;
			$remove_photo = $_POST['remove_photo'] ;
			if ($remove_photo == 1){
				$image = '' ;	
				$image_query = "file = ''," ;
			}

			if ( $image != '' ){
				$get_image = pathinfo($image) ;

				$create_image = reCreateImage('Training', $training_id, $training_id, '', $image, $_FILES["image"]["type"], $_FILES['image']['tmp_name']) ;
				// Image uploads when exists
				if ($create_image['result'] && is_array($create_image['crop']) && count($create_image['result']) > 0){
					$resizeObj = new resize($create_image['original']) ; // Initialise load image
					foreach($create_image['crop'] as $value){
						// Resize image (options: exact, portrait, landscape, auto, crop)
						$resizeObj -> resizeImage($value['width'], $value['height'], $value['type']) ;
						$resizeObj -> saveImage($value['source'], 70) ; // Save image	
					}
					$get_image   = pathinfo($create_image['image']) ;
					$image_query = "file = '".$create_image['image']."'," ;
				}
			}

			$array_branch = [] ;
			foreach ( $_POST['branch'] as $k_branch => $v_branch ){
				$array_branch[] = escapeString( $v_branch ) ;
			}

			// update database
			$mysqli->query( "UPDATE training SET
							".$image_query."
							branch                = '/".implode('/', $array_branch)."/',
							training_type   	  = '".escapeString($_POST['training_type'])."',
							date_start   		  = '".escapeString($_POST['date_start'])."',
							date_end    		  = '".escapeString($_POST['date_end'])."',
							status   			  = '".escapeString($_POST['status'])."'
							WHERE training_id     = '".$training_id."'" ) ;

			$title_en = '' ;
			foreach ( $LANGS as $klang => $vlang ){
				$title        = escapeString( $_POST['title_'.$klang] ) ;
				$content      = escapeString( $_POST['content_'.$klang] ) ;

				if ( $klang  == 'en' ){ $title_en = $title ; }

				checkLangUpdate( 'training_translation', 'training_id', $training_id, $klang, [ 
					'title' 	=> [ 'type' => 'input', 'value' => $title   ], 
					'content' 	=> [ 'type' => 'input', 'value' => $content ]
				] ) ;
			}

			if ( $submit_type == 'new' ){
				pushToBranchUser( $array_branch, [], 'training', $training_id, 'New Training', ( $title_en != '' ? $title_en : 'New training has been submitted.' ) ) ;
			}

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

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

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

		<div class="warper container-fluid">   	
		<div class='container' style="background-color: white; border-radius: 10px;">
			<div class="page-header" style="margin: 30px 0px 0px 0px;padding: 0px;">
				<h1>Training <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-training.php?page_mode=edit&training_id=<?= $training_id ?>&type=edit" novalidate="novalidate">

                        <div class="form-group show_branch_action">
                            <div class="col-sm-2 control-label"><?= $lang['branch']?></div>
                            <div class="col-sm-9">
                                <select name="branch[]" class="form-control ui-search-input chosen-select select2-basic-single" multiple required>
                                	<?php
                            		foreach ( $branch_all as $key => $value ) {
                            			echo '<option value="'.$key.'" '. ( strpos( $row_page['branch'], '/'.$key.'/' ) !== false ? 'selected' : '' ) .' >'.$value.'</option>';
                            		}
                                	?>
                                </select>
                            </div>
                        </div>


                        <?php 
                		echo showTabs( 'training_translation', 'training_id', $training_id, [ 
                			'title'   => [
                				'type'    => 'input', 
                				'title'   => $lang['title']
                			], 
                			'content' => [
                				'type'    => 'textarea', 
                				'title'   => $lang['Content']
                			]
                		]) ; 
                    	?>

                        <div class="form-group">
                            <div class="col-sm-2 control-label">Training Type</div>
                            <div class="col-sm-9">
                                <select name="training_type" class="form-control ui-search-input">
                                	<option value="all" <?= ( $row_page['training_type'] == 'all' ? 'selected' : '' ) ?> >All</option>
                                	<option value="date" <?= ( $row_page['training_type'] == 'date' ? 'selected' : '' ) ?> >Date</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-2 control-label">Date Start</div>
                            <div class="col-sm-9">
                                <input type="date" name="date_start" class="form-control ui-search-input" value="<?= dataFilter($row_page['date_start']) ?>" placeholder="Date Start" />
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-2 control-label">Date End</div>
                            <div class="col-sm-9">
                                <input type="date" name="date_end" class="form-control ui-search-input" value="<?= dataFilter($row_page['date_end']) ?>" placeholder="Date End" />
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-2 control-label"><?= $lang['photo']?></div>
                            <div class="col-sm-9">
                                <div class="file_upload">
                                    <div class="file_form">
                                        <input type="hidden" name="hide_image" value="<?= dataFilter($row_page['file']) ?>" />
                                        <input type="hidden" name="remove_photo" value="">
                                        <input type="file" name="image" class="file_button control-label" <?= $input_block ?> />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <?php if ($row_page['file'] != ''){ ?>
	                        <div class="form-group form-group-pdf">
	                            <div class="col-sm-2 control-label"><?= $lang['preview']?></div>
	                            <div class="col-sm-9">
	                            	<label class="remove_photo"><input type="checkbox" name="remove_photo" class="ui-checkbox tick" value="1">&nbsp;<?= $lang['Remove File']?></label>
	                            	<a href="<?= PATH.'uploads/Training/'.dataFilter($row_page['file']) ?>" target="_blank">
	                            		<img src="<?= PATH.'uploads/Training/'.dataFilter($row_page['file']) ?>" style="width:100px;" />
	                            	</a>
		                        </div>
	                        </div>
                        <?php }else{ ?>
                            <input type="hidden" name="remove_photo" value="" />
                        <?php } ?>

                        <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="inactive" <?= ( $row_page['status'] == 'inactive' ? 'selected' : '' ) ?> >Inactive</option>
                                	<option value="active"  <?= ( $row_page['status'] == 'active' ? 'selected' : '' ) ?> >Active</option>
								</select>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-2 control-label"></div>
                            <div class="col-sm-9">
                                <button type="submit" class="btn" style="color:white;background-color: #5e5bd0;float:right; margin-top: 5px;width: 100px;"><?= $lang['submit']?></button>
                                <input type="hidden" name="hide" value="1">
                                <input type="hidden" name="page_status" value="<?= $submit_type ?>">
                            </div>
                        </div>   
                    </form>
                </div>
            </div>
        </div>
		</div>

		<?php
		
	break ;

	// view training
	case 'view' :

		// check query exsits
		$submit_type  = 'new' ;
		$mysqli_page  = $mysqli->query("SELECT a.training_id, b.title, b.content FROM training a
						   			    LEFT JOIN training_translation b ON ( a.training_id = b.training_id )
									    WHERE a.training_id = '".$training_id."' LIMIT 1");
		if ($mysqli_page->num_rows == 0){
			exit ;
		}

		$row_page     = $mysqli_page->fetch_assoc() ;

		// update database
		if ( $_POST['hide'] == 1 ){
			$update_status   = escapeString( $_POST['update_status'] ) ;

			foreach ( $_POST['multiple_status'] as $kk => $vv ){
				$mysqli->query( "UPDATE staff_training SET
								 status 	   = '".$update_status."'
								 WHERE view_id = '".$kk."'" ) ;

				if ( $update_status == 'rejected' ){
					pushToUserCron( 'staff_training', $kk, $vv, 'Training', 'Training has been reject.' ) ;
				}else{
					pushToUserCron( 'staff_training', $kk, $vv, 'Training', 'Training has been update.' ) ;
				}
			}

			header( "Refresh: 0;" ) ;
			exit ;
		}



		//query
		$search_query = '' ;
		$search_name = escapeString($_GET['search_name']) ;
		$search_idno = escapeString($_GET['search_idno']) ;
		$search_rated = escapeString($_GET['search_rated']) ;
		$search_date = ( $_GET['search_date']!= '' ? date('Y-m-d', strtotime($_GET['search_date'])) : '' ) ;
		$search_training = escapeString($_GET['search_training']) ;
		$search_type = $_GET['search_type'] ;
		$export_excel = $_GET['export-excel'];

		$search_query = '';

		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_rated != ''){
			$search_query .= " AND a.rated = '".$search_rated."'" ;
		}
		if ( $search_date != '' ){
		    $search_query .= " AND a.created_at >= '".$search_date."' " ;
		}
		// search query
		if ($search  != ''){
			$search_query .= " AND ( title LIKE '%".$search."%' )" ;
		}
		if( $search_type != ''){
			$search_query .= " AND a.status = '".$search_type."' " ;
		}

		// related staff
		// 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_rated='.$search_rated.'&search_date='.$search_date.'&page_mode='.$page_mode.'&training_id='.$training_id.'&search_idno='.$search_idno;

		// page query
		$mysqli_query = "SELECT a.view_id, a.training_so, a.training_id, a.rated, a.comment, a.status, a.created_at, a.updated_at, b.staff_id, b.staff_idno, b.staff_name, b.staff_image, c.title FROM staff_training a
						 LEFT JOIN staff b ON ( a.staff_id = b.staff_id )
						 LEFT JOIN training_translation c ON ( a.training_id = c.training_id )
						 WHERE a.deleted_at IS NULL AND c.lang = 'en' AND a.training_id = '".$training_id."' " . $search_query ;
		$mysqli_list  = $mysqli->query( $mysqli_query." ORDER BY a.view_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 = 'Training Report-';

		    $array_header_excel =   array( 
		                                'No.', 
		                                'SO Number', 
		                                'ID', 
		                                'Name', 
		                                'Rated', 
		                                'Comment', 
		                                'Training', 
		                                'Status', 
		                                'Created At', 
		                                'Updated At'
		                            ) ;

		    $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['training_so'], 
		                                        $mysqli_export_page['staff_idno'], 
		                                        $mysqli_export_page['staff_name'], 
		                                        $mysqli_export_page['rated'], 
		                                        $mysqli_export_page['comment'], 
		                                        dataFilter($mysqli_export_page['title']), 
		                                        $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';
		?>

		<div class="warper container-fluid">
		<div class='container' style="background-color: white; border-radius: 10px;">
			<div class="page-header" style="margin: 30px 0px 0px 0px;padding: 0px;">
				<div class="row">
			        <div class="pull-left col">
                		<h1>Training <small>View</small></h1>
					</div>
                	<div class="pull-right col">
                		<a class="btn" style="color:white;background-color: #5e5bd0;" href="?search_name=<?= $search_name?>&search_idno=<?= $search_idno?>&search_rated=<?= $search_rated?>&search_date=<?= $search_date?>&search_training=<?= $search_training?>&search_type=<?= $search_type?>&page_mode=view&training_id=<?= $training_id ?>&export-excel=export_eae">Export As Excel</a>
                	</div>
                </div>
            </div>

			<div class="panel panel-default" id="basic-table-title">
		        <div class="panel-heading">search</div>
		        <div class="panel-body">
		            <form method="get" class="form-horizontal">
		                <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">Rated</label>
		                    <div class="col-sm-9">
		                        <input type="number" name="search_rated" value="<?= $search_rated ?>" class="form-control" step="1" min="0" max="5" />
		                    </div>
		                </div>
	                    <div class="form-group">
		                    <label class="col-sm-2 control-label"><?= $lang['date'] ?></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['status'] ?></label>
		                    <div class="col-sm-9">
		                        <select name="search_type" class="form-control">
		                        	<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>
		                        	<option value="cancelled" <?= ($search_type == 'cancelled' ? 'selected' : '') ?>>Cancelled</option>
		                        	<option value="rated" <?= ($search_type == 'rated' ? 'selected' : '') ?>>Rated</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="training_id" value="<?= $training_id ?>" />
		                        <button type="submit" class="btn" style="color:white;background-color: #5e5bd0;float:right; margin-top: 5px;width: 100px;"><?= $lang['submit'] ?></button>
		                    </div>
		                </div>
		            </form>
		        </div>
		    </div>

			<form method="post">
            	
                <div class="panel panel-default">
                    <div class="panel-body">
                        <select name="update_status" class="form-control selectpicker">
                            <option value="pending">Pending</option>
                            <option value="approved">Approved</option>
                            <option value="confirmed">Confirmed</option>
                            <option value="rejected">Rejected</option>
                            <option value="cancelled">Cancelled</option>
                        </select>
                        <input type="hidden" name="hide" value="1" />
                        <input type="hidden" name="hide_status" value="action" />
                        <input type="submit" class="btn" style="color:white; background-color:#5e5bd0; width:100px;" value="<?= $lang['submit'] ?>" />
                    </div>
                </div>

				<div class="panel panel-default">
	                <div class="panel-heading">Join Staff</div>
	                <div class="panel-body">
						<table cellpadding="0" cellspacing="0" border="0" class="listing-table responsive table table-striped table-bordered" id="basic-datatable">
							<thead>
								<tr>
									<th></th>
									<th>So Number</th>
									<th>Profile</th>
									<th>Staff ID</th>
									<th>Name</th>
									<th>Rated</th>
									<th>Comment</th>
									<th>Status</th>
									<th>Created At</th>
									<th>Updated At</th>
								</tr>
							</thead>
							<tbody>
								<?php
								if ( $mysqli_list->num_rows > 0 ){
									while ( $row_list = $mysqli_list->fetch_assoc() ){
										$staff_image  = ( $row_list['staff_image'] != '' ? PATH.'uploads/Staff/'.dataFilter($row_list['staff_image']) : '' ) ;

										echo '
										<tr class="odd gradeX">
											<td>' ;
												if ( $row_list['status'] == 'pending' || $row_list['status'] == 'approved' ){
													echo '
													<div class="checkbox multiple_trash">
														<input type="checkbox" name="multiple_status['.$row_list['view_id'].']" class="trash_button" value="'.$row_list['staff_id'].'" />
														<label for="checkbox1"></label>
													</div>' ;
												}
											echo '
											</td>
											<td>'.dataFilter($row_list['training_so']).'</td>
										 	<td class="text-center">'.( $staff_image != '' ? '<a href="'.$staff_image.'" target="_blank"><img src="'.$staff_image.'" style="width:80px;" /></a>' : '' ).'</td>
											<td>'.dataFilter($row_list['staff_idno']).'</td>
											<td>'.dataFilter($row_list['staff_name']).'</td>
											<td class="text-center">'.dataFilter($row_list['rated']).'</td>
											<td>'.dataFilter($row_list['comment']).'</td>
											<td class="text-center">'.resetStatus($row_list['status']).'</td>
											<td class="text-center">'.resetDateFormat($row_list['created_at']).'</td>
											<td class="text-center">'.resetDateFormat($row_list['updated_at']).'</td>
										</tr>';
									}
								}else{
									echo 
									'<tr class="odd gradeX">
									<td class="border_none">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>
									<td class="border_none"></td>
									<td class="border_none"></td>
									<td class="border_none"></td>
									<td class="border_none"></td>
									</td>';
								}
								?>
							</tbody>
						</table>
						<?= $page_pagination['page_pagination'] ?>
	                </div>
	            </div>

	        </form>
            
            <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-training.php?page_mode=edit&training_id=<?= $training_id ?>&type=edit" novalidate="novalidate">

                        <div class="form-group">
                            <div class="col-sm-2 control-label">Title</div>
                            <div class="col-sm-9">
                                <input type="text" name="title" class="form-control ui-search-input" value="<?= dataFilter($row_page['title']) ?>" placeholder="Title" />
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-2 control-label">Content</div>
                            <div class="col-sm-9">
                            	<textarea name="content" class="content" id="editor1" rows="10" cols="80"><?= dataFilter($row_page['content']) ?></textarea>
		                        <script>
		                        CKEDITOR.replace('editor1') ;
		                        </script>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-2 control-label">Training Type</div>
                            <div class="col-sm-9">
                                <select name="training_type" class="form-control ui-search-input">
                                	<option value="all" <?= ( $row_page['training_type'] == 'all' ? 'selected' : '' ) ?> >All</option>
                                	<option value="date" <?= ( $row_page['training_type'] == 'date' ? 'selected' : '' ) ?> >Date</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-2 control-label">Date Start</div>
                            <div class="col-sm-9">
                                <input type="date" name="date_start" class="form-control ui-search-input" value="<?= dataFilter($row_page['date_start']) ?>" placeholder="Date Start" />
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-2 control-label">Date End</div>
                            <div class="col-sm-9">
                                <input type="date" name="date_end" class="form-control ui-search-input" value="<?= dataFilter($row_page['date_end']) ?>" placeholder="Date End" />
                            </div>
                        </div>

                        <?php if ($row_page['file'] != ''){ ?>
	                        <div class="form-group form-group-pdf">
	                            <div class="col-sm-2 control-label"><?= $lang['preview']?></div>
	                            <div class="col-sm-9">
	                            	<label class="remove_photo"><input type="checkbox" name="remove_photo" class="ui-checkbox tick" value="1">&nbsp;<?= $lang['Remove File']?></label>
	                            	<a href="<?= PATH.'uploads/Training/'.dataFilter($row_page['file']) ?>" target="_blank">
	                            		<img src="<?= PATH.'uploads/Training/'.dataFilter($row_page['file']) ?>" style="width:100px;" />
	                            	</a>
		                        </div>
	                        </div>
                        <?php }else{ ?>
                            <input type="hidden" name="remove_photo" value="" />
                        <?php } ?>

                        <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="inactive" <?= ( $row_page['status'] == 'inactive' ? 'selected' : '' ) ?> >Inactive</option>
                                	<option value="active"  <?= ( $row_page['status'] == 'active' ? 'selected' : '' ) ?> >Active</option>
								</select>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
		</div>

		<?php
		
	break ;



	// view training
	case 'view_all' :
		
		// query type
		$search_query = '' ;
		$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_training = escapeString($_GET['search_training']) ;
		$search_type = $_GET['search_type'] ;
		$export_excel = $_GET['export-excel'];

		$search_query = '';

		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_training != ''){
			$search_query .= " AND c.title LIKE '%".$search_training."%' " ;
		}
		// search query
		if ($search  != ''){
			$search_query .= " AND ( title LIKE '%".$search."%' )" ;
		}
		if( $search_type != ''){
			$search_query .= " AND a.status IN ('".implode("', '",$search_type)."') " ;
		}

		// related staff
		// 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;

		// page query

		// $mysqli_query = "SELECT a.view_id, a.training_so, a.created_at, a.updated_at, a.status, b.staff_idno, b.staff_name, b.staff_image FROM staff_training 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_query = "SELECT a.view_id, a.training_so, a.training_id, a.created_at, a.updated_at, a.status, b.staff_idno, b.staff_name, b.staff_image, c.title FROM staff_training a
						 LEFT JOIN staff b ON ( a.staff_id = b.staff_id )
						 LEFT JOIN training_translation c ON ( a.training_id = c.training_id )
						 WHERE a.deleted_at IS NULL AND c.lang = 'en' " . $search_query.$user_branch_permission_sql_b  ;

		$mysqli_list  = $mysqli->query( $mysqli_query." ORDER BY a.view_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 = 'Training List-';

		    $array_header_excel =   array( 
		                                'No.', 
		                                'SO Number', 
		                                'ID', 
		                                'Name', 
		                                'Training', 
		                                'Status', 
		                                'Created At', 
		                                'Updated At'
		                            ) ;

		    $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['training_so'], 
		                                        $mysqli_export_page['staff_idno'], 
		                                        $mysqli_export_page['staff_name'], 
		                                        dataFilter($mysqli_export_page['title']), 
		                                        $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';
		?>

		<div class="warper container-fluid">   	
		<div class='container' style="background-color: white; border-radius: 10px;">
			<div class="page-header" style="margin: 30px 0px 0px 0px;padding: 0px;">
				<div class="row">
					<div class="pull-left col">
						<h1>Training <small>View</small></h1>
					</div>
					<div class="pull-right col">
						<a class="btn" style="color:white;background-color: #5e5bd0;" 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_training=<?= $search_training?><?php 
			        	if(is_array($search_type)){
			        		foreach ($search_type as $key => $value) {
			        			echo "&search_type[]=".$value;
			        		}
			        	}
		        	?>&page_mode=view_all&export-excel=export_eae">Export As Excel</a>
		        	</div>
				</div>
			</div>

		    <div class="panel panel-default" id="basic-table-title">
		        <div class="panel-heading">search</div>
		        <div class="panel-body">
		            <form method="get" class="form-horizontal">
		                <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">Training</label>
		                    <div class="col-sm-9">
		                        <input type="text" name="search_training" value="<?= $search_training ?>" class="form-control" />
		                    </div>
		                </div>
	                    <div class="form-group">
		                    <label class="col-sm-2 control-label"><?= $lang['status'] ?></label>
		                    <div class="col-sm-9">
		                        <select name="search_type[]" class="form-control ui-search-input chosen-select select2-basic-single" id="" multiple>
		                        	<option value=""><?= $lang['All'] ?></option>
		                        	<option value="pending" <?= (in_array("pending", $search_type) ? 'selected' : '') ?>>Pending</option>
		                        	<option value="confirmed" <?= (in_array("confirmed", $search_type) ? 'selected' : '') ?>>Confirmed</option>
		                        	<option value="approved" <?= (in_array("approved", $search_type) ? 'selected' : '') ?>>Approved</option>\
		                        	<option value="rejected" <?= (in_array("rejected", $search_type) ? 'selected' : '') ?>>Rejected</option>
		                        	<option value="cancelled" <?= (in_array("cancelled", $search_type) ? 'selected' : '') ?>>Cancelled</option>
		                        	<option value="rated" <?= (in_array("rated", $search_type) ? 'selected' : '') ?>>Rated</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" style="color:white;background-color: #5e5bd0;float:right; margin-top: 5px;width: 100px;"><?= $lang['submit'] ?></button>
		                    </div>
		                </div>
		            </form>
		        </div>
		    </div>

			<div class="panel panel-default">
                <div class="panel-heading">Join Staff</div>
                <div class="panel-body">
					<table cellpadding="0" cellspacing="0" border="0" class="listing-table responsive table table-striped table-bordered" id="basic-datatable">
						<thead>
							<tr>
								<th></th>
								<th>So Number</th>
								<th>Profile</th>
								<th>Staff ID</th>
								<th>Name</th>
								<th>Training</th>
								<th>Status</th>
								<th>Created At</th>
								<th>Updated At</th>
							</tr>
						</thead>
						<tbody>
							<?php
							if ( $mysqli_list->num_rows > 0 ){
								while ( $row_list = $mysqli_list->fetch_assoc() ){
									$staff_image  = ( $row_list['staff_image'] != '' ? PATH.'uploads/Staff/'.dataFilter($row_list['staff_image']) : '' ) ;

									echo '
									<tr class="odd gradeX">
										<td>' ;
											if ( $row_list['status'] == 'pending' || $row_list['status'] == 'approved' ){
												echo '
												<div class="checkbox multiple_trash">
													<input type="checkbox" name="multiple_status['.$row_list['view_id'].']" class="trash_button" value="1">
													<label for="checkbox1"></label>
												</div>' ;
											}
										echo '
										</td>
										<td>'.dataFilter($row_list['training_so']).'</td>
									 	<td class="text-center">'.( $staff_image != '' ? '<a href="'.$staff_image.'" target="_blank"><img src="'.$staff_image.'" style="width:80px;" /></a>' : '' ).'</td>
										<td>'.dataFilter($row_list['staff_idno']).'</td>
										<td>'.dataFilter($row_list['staff_name']).'</td>
										<td class="text-center">'.$row_list['title'].'</td>
										<td class="text-center">'.resetStatus($row_list['status']).'</td>
										<td class="text-center">'.resetDateFormat($row_list['created_at']).'</td>
										<td class="text-center">'.resetDateFormat($row_list['updated_at']).'</td>
									</tr>';
								}
							}else{
								echo 
								'<tr class="odd gradeX">
								<td class="border_none">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>
								<td class="border_none"></td>
								<td class="border_none"></td>
								<td class="border_none"></td>
								</td>';
							}
							?>
						</tbody>
					</table>
					<?= $page_pagination['page_pagination'] ?>
                </div>
            </div>
	    </div>
		</div>

		<?php
		
	break ;


	case 'scan' :
		
		// query type
		$search_query = '' ;

		// form submit
		if ( $_POST['hide'] == '1' ){
			$error 	 	   = 'Invalid parameter' ;

			$qrcode   	   = escapeString( $_POST['qrcode'] ) ;
			if ( $qrcode  != '' ){
				$error     = 'Invalid qrcode' ;
				$select    = $mysqli->query( "SELECT training_id, status FROM staff_training
							 				  WHERE deleted_at IS NULL AND training_so = '".$qrcode."' LIMIT 1" ) ;

				if ( $select->num_rows > 0 ){
					$error     = 'Invalid status' ;

					$row       = $select->fetch_assoc() ;

					if ( $row['status'] == 'approved' ){
						$error = 'Success' ;

						$mysqli->query( "UPDATE staff_training SET
										 status            = 'confirmed'
										 WHERE training_id = '".$row['training_id']."'" ) ;
					}
				}
			}

			$_SESSION['system_result'] = $error ;
			header( "Refresh: 0;" ) ;
			exit ;
		}
		
		// 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 ;
		
		// page query
		$mysqli_query = "SELECT a.training_so, a.created_at, a.updated_at, c.staff_idno, c.staff_name FROM staff_training a
						 LEFT JOIN training b ON ( a.training_id = b.training_id )
						 LEFT JOIN staff c ON ( a.staff_id = c.staff_id )
						 WHERE a.deleted_at IS NULL AND a.status = 'confirmed' " . $search_query ;
		$mysqli_page  = $mysqli->query( $mysqli_query." ORDER BY a.view_id DESC LIMIT $start_from, " . LIMIT ) ;

		// load pagination
		$page_pagination = nextPrevious($product_page, LIMIT, $search_url, $mysqli_query) ;
		
		// start header here
		include 'requires/page_header.php' ;
		include 'requires/page_top.php' ;

		?>
		<!-- Header Ends -->
		<div class="warper container-fluid">
		<div class='container' style="background-color: white; border-radius: 10px;">
			<div class="page-header" style="margin: 30px 0px 0px 0px;padding: 0px;">
				<h1>Training <small>Scan</small></h1>
			</div>

            <form method="POST">

            	<?php if ( $_SESSION['system_result'] != '' ){ ?>
            		<div class="<?= $_SESSION['system_result'] == 'Success' ? 'result_success' : 'result_error' ?>"><?= $_SESSION['system_result'] ?></div>
            	<?php unset($_SESSION['system_result']) ; } ?>

            	<div class="panel panel-default">
                    <div class="panel-heading"></div>
                    <div class="panel-body">
                        <div class="form-group">
                            <div class="col-sm-2 control-label">Scan Qrde</div>
                            <div class="col-sm-9">
                                <input type="text" name="qrcode" class="form-control" value="" placeholder="Scan Qrcode" />
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-2 control-label"></div>
                            <div class="col-sm-9">
                                <button type="submit" class="btn" style="color:white;background-color: #5e5bd0;float:right; margin-top: 5px;width: 100px;"><?= $lang['submit'] ?></button>
                                <input type="hidden" name="hide" value="1" />
                            </div>
                        </div>   
                    </div>
                </div>
                
                <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>So Number</th>
									<th>Staff ID</th>
									<th>Staff Name</th>
									<th>Created Date</th>
									<th>Updated Date</th>
								</tr>
							</thead>
							<tbody>
								<?php
								if ( $mysqli_page->num_rows > 0 ){
									while ( $row_page = $mysqli_page->fetch_assoc() ){
										echo '
										 <tr class="odd gradeX">
											<td>'.dataFilter($row_page['training_so']).'</td>
											<td>'.dataFilter($row_page['staff_idno']).'</td>
											<td>'.dataFilter($row_page['staff_name']).'</td>
											<td class="text-center">'.resetDateFormat($row_page['created_at']).'</td>
											<td class="text-center">'.resetDateFormat($row_page['updated_at']).'</td>
										</tr>';
									}
								}else{
									echo 
									'<tr class="odd gradeX">
									<td class="border_none">No data.</td>
									<td class="border_none"></td>
									<td class="border_none"></td>
									<td class="border_none"></td>
									<td class="border_none"></td>
									</td>';
								}

								?>
							</tbody>
						</table>
						<?= $page_pagination['page_pagination'] ?>
                    </div>
                </div>
			</form>
		</div>
		</div>

	<?php
	break ;

	
	// all announcement list
	case 'all' :
	default :
		
		$search_title 		= escapeString($_GET['search_title']) ;
		$search_date 		= ( $_GET['search_date']!= '' ? date('Y-m-d', strtotime($_GET['search_date'])) : '' ) ;
		
		// query type
		$search_query 		= '' ;
		
		// search query
		if( $search_title  != ''){
			$search_query  .= " AND b.title LIKE '%".$search_title."%'" ;
		}
		if ( $search_date  != '' ){
		    $search_query  .= " AND a.created_at like '%".$search_date."%' " ;
		}
		
		// form submit
		if ( $_POST['hide'] == '1' && $_POST['hide_status'] == 'action' ){
			switch($_POST['page_action']){
				case 'trash':
					$mysqli_query 	= "UPDATE training SET deleted_at = '".TODAYDATE."' WHERE training_id = " ;
					$trash_page 	= trashPage('training', $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_title='.$search_title.'&search_date='.$search_date.'&page_mode='.$page_mode ;
		
		// page query
		$mysqli_query 	= "SELECT a.training_id, a.status, a.date_start, a.date_end, a.created_at, b.title FROM training a
						   LEFT JOIN training_translation b ON ( a.training_id = b.training_id )
						   WHERE a.deleted_at IS NULL AND b.lang = 'en' " . $search_query . $user_branch_permission_sql_symbol ;
		$mysqli_page 	= $mysqli->query( $mysqli_query." ORDER BY a.training_id DESC LIMIT $start_from, " . LIMIT ) ;

		// load pagination
		$page_pagination = nextPrevious($product_page, LIMIT, $search_url, $mysqli_query) ;
		
		// start header here
		include 'requires/page_header.php' ;
		include 'requires/page_top.php' ;

		?>
		<!-- Header Ends -->
		<div class="warper container-fluid">   	
		<div class='container' style="background-color: white; border-radius: 10px;">
			<div class="page-header" style="margin: 30px 0px 0px 0px;padding: 0px;">
				<div class="row">
			        <div class="pull-left col">
						<h1>Training <small><?= $lang['list']?></small></h1>
					</div>
                	<div class="pull-right col">
				<?php if ( permissionCheck($row_user, 'training-new') ){ ?>
					<a href="app-training.php?page_mode=new" class="btn" style="color:white;background-color: #5e5bd0;" target="_blank"><?= $lang['add_new']?></a>
				<?php } ?>
				<?php if ( permissionCheck($row_user, 'training-qr') ){ ?>
					<a href="app-training.php?page_mode=scan" class="btn" style="color:white;background-color: #5e5bd0;" target="_blank">Scan Qrcode</a>
				<?php } ?>
				<?php if ( permissionCheck($row_user, 'training-gallery') ){ ?>
					<a href="app-training-gallery.php?page_mode=list" class="btn" style="color:white;background-color: #5e5bd0;" target="_blank">Gallery</a>
				<?php } ?>
					<a href="app-training.php?page_mode=view_all" class="btn" style="color:white;background-color: #5e5bd0;" target="_blank">View all</a>
					</div>
				</div>
			</div>
			
		    <div class="panel panel-default" id="basic-table-title">
		        <div class="panel-heading">search</div>
		        <div class="panel-body">
		            <form method="get" class="form-horizontal">
		                <div class="form-group">
		                    <label class="col-sm-2 control-label"><?= $lang['Subject'] ?></label>
		                    <div class="col-sm-9">
		                        <input type="text" name="search_title" value="<?= $search_title ?>" class="form-control" />
		                    </div>
		                </div>
	                    <div class="form-group">
		                    <label class="col-sm-2 control-label"><?= $lang['date'] ?></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">
		                    <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" style="color:white;background-color: #5e5bd0;float:right; margin-top: 5px;width: 100px;"><?= $lang['submit'] ?></button>
		                    </div>
		                </div>
		            </form>
		        </div>
		    </div>

            <form method="post">
                
                <?php if ( permissionCheck($row_user, 'training-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" style="color:white; background-color:#5e5bd0; width:100px;" 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['Subject']?></th>
									<th><?= $lang['status']?></th>
									<th>Created Date</th>
                                    <th width="50"><?= $lang['trash']?></th>
								</tr>
							</thead>
							<tbody>
								<?php
								if ( $mysqli_page->num_rows > 0 ){
									while ( $row_page = $mysqli_page->fetch_assoc() ){

										$staff_training    = $mysqli->query( "SELECT view_id FROM staff_training
																			  WHERE deleted_at IS NULL AND training_id = '".$row_page['training_id']."' AND status IN ( 'pending' )" ) ;
										$total_training    = $staff_training->num_rows ;		  

										echo '
										 <tr class="odd gradeX">
										 	<td class="align_center">' ;
												if ( permissionCheck($row_user, 'training-edit') ){
													echo '
										 			<a title="Edit Current training" href="app-training.php?page_mode=edit&training_id='.$row_page['training_id'].'"><i class="fa fa-edit"></i></a>' ;
												}else{
													echo '-' ;
												}
												echo '
												<span class="split">|</span>
												<a title="View Current training" href="app-training.php?page_mode=view&training_id='.$row_page['training_id'].'"><i class="fa fa-eye"></i> ( '.$total_training.' )</a>
										 	</td>
											<td>'.dataFilter($row_page['title']).'</td>
											<td class="text-center">'.resetStatus($row_page['status']).'</td>
											<td class="text-center">'.resetDateFormat($row_page['created_at']).'</td>
											<td>
												<div class="checkbox multiple_trash">
													<input type="checkbox" name="multiple_trash['.$row_page['training_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>
		</div>
		<?php
	break ;

}
// footer
include 'requires/page_footer.php' ;
?>