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

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

$active_menu == 'setting-website-page-menu';

$hide_status = ($_POST['hide_status']) ;
$permission2 = ($_POST['permission2']) ;
$temp_permission2 = multipleArrayTo($permission2) ;

if($hide_status == 'update'){
	$mysqli->query("UPDATE system_post SET
					post_content = '".$temp_permission2."'
					WHERE post_type = 'website-page-menu'") ;
}

$mysqli_page = $mysqli->query("SELECT * FROM system_post
							   WHERE post_type = 'website-page-menu' LIMIT 1") ;
// check table exsits
if ($mysqli_page->num_rows > 0){
	$row_page = $mysqli_page->fetch_array(MYSQLI_ASSOC) ;	
}

$array_page_remove = [] ;

$array_page_remove['dashboard'] = [
	"dashboard" => 
	[ 
		"dashboard" => "Dashboard"
	]
];
$array_page_remove['hr'] = [
	"staff-application" => [ 
		"application-form" => "Application Form", 
		"application-pending-list" => "Pending", 
		"application-processing-list" => "Processing", 
		"application-processing-manager-approved" => "Processing - Manager Approved", 
		"application-processing-manager-rejected" => "Processing - Manager Rejected", 
		"application-processing-interview-slot" => "Processing - Interview Slot", 
		"application-interview-list" => "Interview", 
		"application-reschedule-list" => "Reschedule", 
		"application-kiv-list" => "Keep In View", 
		"application-offer-list" => "Offer", 
		"application-confirmation-list" => "Confirmation", 
		"application-terminate-list" => "Terminate",
		"application-reject-list" => "Reject"
	],
	"staff" => [ 
		"staff-list" => "List",
		"staff-adjustment" => "Point Adjustment", 
		"staff-point-history" => "Point History", 
		"staff-adjustment-wallet" => "Wallet Adjustment", 
		"staff-resign-list" => "Resign", 
		"staff-run-away-list" => "Run Away", 
		"staff-warning-list" => "Warning"
	],
	"merit-points" => [ 
		"hr-merit-points-movement" => "Movement", 
		"hr-merit-points-adjustment" => "Adjustment", 
		"hr-merit-points-task" => "Task", 
	],
	"attendance" => [ 
		"attendance-list" => "List", 
		"attendance-report" => "Report", 
		"attendance-qrcode" => "Qrcode", 
		"attendance-health" => "Health"
	],
	"leave" => [ 
		"leave" => "Leave"
	],
	"advance" => [ 
		"advance" => "Advance"
	],
	"payment-slip" => [ 
		"payment-slip" => "Payment Slip"
	],
	"salary" => [ 
		"salary-list" => "Salary"
	]
] ;
$array_page_remove['task'] = [
	"task-list" => [ 
		"task-list" => "List",
		"task-report" => "Report"
	]
] ;
$array_page_remove['service'] = [
	"announcement" => [ 
		"announcement" => "Announcement"
	],
	"inbox" => [ 
		"inbox" => "Inbox"
	],
	"our-inbox" => [ 
		"our-suggestion" => "Suggestion",
		"our-request" => "Request",
		"our-main-request" => "Main Category",
		"our-sub-request" => "Sub Category",
		"our-grievance" => "Grievance"
	],
	"form-submission" => [ 
		"form-headcount" => "Headcount Requisition",
		"form-nomination" => "Nomination",
		"form-resignation" => "Resignation Letter",
		"form-submission-category" => "Category"
	],
	"redeem" => [ 
		"redeem-list" => "List",
		"redeem-category" => "Category"
	],
	"association" => [ 
		"association-list" => "List",
		"association-category" => "Category"
	],
	"training" => [ 
		"training" => "Training"
	],
	"form" => [ 
		"form-list" => "List",
		"form-main-category" => "Main Category",
		"form-sub-category" => "Sub Category"
	],
	"handbook" => [ 
		"handbook-list" => "List",
		"handbook-main-category" => "Main Category",
		"handbook-sub-category" => "Sub Category"
	],
	"catalog" => [ 
		"catalog-list" => "List",
		"catalog-main-category" => "Main Category",
		"catalog-sub-category" => "Sub Category"
	]
] ;
$array_page_remove['report'] = [
	"report" => [ 
		"year-end-cut-off"   		=> "Year End Cut Off"
	]
] ;
$array_page_remove['import'] = [
	"import" => [ 
		"import-full-attendance"   		=> "Import Full Attendance",
		"import-outstanding-employee" 	=> "Import Outstanding Employee",
		"import-lateness-board" 		=> "Import Lateness Board",
		"import-point"				 	=> "Import Point"
	]
] ;
$array_page_remove['visitor'] = [
	"visitor-list" => [ 
		"visitor-list" => "List"
	]
] ;
$array_page_remove['setting'] = [
	"user-setting" => [ 
		"user-user" => "User",
		"user-new-user" => "New User"
	],
	"service-annoucment" => [ 
		"user-notification" => "Notification",
		"user-new-notification" => "New Notification",
		"user-letterhead" => "Letterhead"
	],
	"hr-setting" => [ 
		"hr-branch" => "Branch",
		"hr-working-hours" => "Working Hours",
		"hr-leave-setting" => "Leave Setting",
		"hr-sick-setting" => "Sick Setting",
		"hr-holiday-list" => "Holiday List",
		"hr-hostel-list" => "Hostel List",
		"hr-knowledge-list" => "Knowledge List",
		"hr-department-list" => "Department List",
		"hr-section-list" => "Section List",
		"hr-position-list" => "Designation List",
		"hr-advance-setting" => "Advance Setting",
		"hr-chief-list" => "Chief List",
		"employment-schedule-date" => "Schedule Interview Date"
	],
	"app-setting" => [ 
		"app-welcome-screen" => "Welcome Screen",
		"app-pop-up" => "Pop Up",
		"app-service" => "Sevice",
		"app-page" => "Page",
		"app-menu" => "Menu",
		"app-support" => "Support",
		"app-password" => "Password",
		"app-difficulty" => "Difficulty",
		"app-adjustment" => "Adjustment",
		"app-point" => "Point Adjustment",
		"profile-star" => "Star",
		"profile-point" => "Point",
		"profile-achievement" => "Achievement",
		"profile-tier" => "Tier"
	],
	"salary-setting" => [ 
		"setting-salary" => "Salary Setting"
	],
	"rms-setting" => [ 
		"setting-rms" => "RMS Setting"
	]
] ;
// print_r($row_page['post_content']);exit();
$page_menu = '' ;
foreach ( $array_page_remove as $key1 => $value1 ){
	$page_menu .= '
	<div style="margin-bottom:10px;">
		<div class="custom_label" style="text-transform: capitalize; width: 100%; display: block; background: #eaeaea; padding: 5px;" >'.str_replace('-', ' ', $key1).'</div>' ;

		foreach ( $value1 as $key2 => $value2 ){

			$page_menu .= '
			<div>
				<div style="text-transform: capitalize; width: 100%; display: block; background: #fbfbfb; padding: 5px;" >'.str_replace('-', ' ', $key2).'</div>
				<div class="clearfix">' ;

					foreach ( $value2 as $key3 => $value3 ){

						$page_menu .= '
						<label style="text-transform: capitalize; display:block; float:left; width:33.33%; margin:0; padding:6px 0;" >
							<input type="checkbox" name="permission2[]" value="'.$key3.'" '.(strpos($row_page['post_content'], '('.$key3.')') !== false ? 'checked' : '').' class="custom_checkbox permission2_checkbox" /> '.$value3.'
						</label>' ;

					}

				$page_menu .= '
				</div>
			</div>' ;

		}

	$page_menu .= '
	</div>' ;
}


// start header here
include 'requires/page_header.php' ;
include 'requires/page_top.php' ;
?>
<div class="warper container-fluid">
	<div class="row">
		<form method="post">
			<div class="col-md-12">
	            <div class="form-group">
	                <div class="col-sm-2 control-label"><?= $lang['permission']?></div>
	                <div class="col-sm-9">
						<?= $page_menu ?>
	                </div>
	            </div>
                <div class="form-group">
                    <div class="col-sm-2 control-label"></div>
                    <div class="col-sm-9">
                        <input type="hidden" name="hide" value="1" />
                        <input type="hidden" name="hide_status" value="update" />
                        <button type="submit" class="btn" style="color:white;background-color: #5e5bd0;float:right; margin-top: 5px;width: 100px;"><?= $lang['submit']?></button>
                    </div>
                </div>  
			</div>
		</form>
	</div>
</div>
<?php
// footer
include 'requires/page_footer.php' ;
?>