<?php
session_start(); 
		/*User Add Data page */

	include("connect.php");
	if(!isset($_SESSION['linkarisecrm']))
	{
		header('Location: index.php');
		return;
	}
	$ftime=0;
	$ttime=23;
	$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	
	
				date_default_timezone_set("Asia/Kolkata");
				$mdate1= date('Y-m-d H:i:s');
				$mdate= date('d-m-Y');
				
				$par1 = $_SESSION['linkariseumobile'];
				$ipaddress = "";
	
				if (getenv('HTTP_CLIENT_IP'))
					$ipaddress = getenv('HTTP_CLIENT_IP');
				else if(getenv('HTTP_X_FORWARDED_FOR'))
					$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
				else if(getenv('HTTP_X_FORWARDED'))
					$ipaddress = getenv('HTTP_X_FORWARDED');
				else if(getenv('HTTP_FORWARDED_FOR'))
					$ipaddress = getenv('HTTP_FORWARDED_FOR');
				else if(getenv('HTTP_FORWARDED'))
					$ipaddress = getenv('HTTP_FORWARDED');
				else if(getenv('REMOTE_ADDR'))
					$ipaddress = getenv('REMOTE_ADDR');
				else
					$ipaddress = 'UNKNOWN';
				
				$userserver=$_SERVER['HTTP_USER_AGENT'];
				$eve1 = "insert into res_user_log (lid,mobile,lastupdatedtime,pagename,taskname,ipaddress,useragentdetail) values(NULL,'$par1','$mdate1','User','Add User','$ipaddress','$userserver')";
				$re1 = mysqli_query($conn, $eve1);
	
	
?>
<!DOCTYPE html>
<!--
Author: Keenthemes
Product Name: Metronic - Bootstrap 5 HTML, VueJS, React, Angular. Laravel, Asp.Net Core, Ruby on Rails, Spring Boot, Blazor, Django, Express Node.js & Flask Admin Dashboard Theme
Purchase: https://1.envato.market/EA4JP
Website: http://www.keenthemes.com
Contact: support@keenthemes.com
Follow: www.twitter.com/keenthemes
Dribbble: www.dribbble.com/keenthemes
Like: www.facebook.com/keenthemes
License: For each use you must have a valid license purchased only from above link in order to legally use the theme for your project.
-->
<html lang="en">
	<!--begin::Head-->
	<head>
		<title>Module Allocation Add</title>
		<meta charset="utf-8" />
		<meta name="description" content="The most advanced Bootstrap Admin Theme on Themeforest trusted by 100,000 beginners and professionals. Multi-demo, Dark Mode, RTL support and complete React, Angular, Vue, Asp.Net Core, Rails, Spring, Blazor, Django, Flask & Laravel versions. Grab your copy now and get life-time updates for free." />
		<meta name="keywords" content="metronic, bootstrap, bootstrap 5, angular, VueJs, React, Asp.Net Core, Rails, Spring, Blazor, Django, Flask & Laravel starter kits, admin themes, web design, figma, web development, free templates, free admin themes, bootstrap theme, bootstrap template, bootstrap dashboard, bootstrap dak mode, bootstrap button, bootstrap datepicker, bootstrap timepicker, fullcalendar, datatables, flaticon" />
		<meta name="viewport" content="width=device-width, initial-scale=1" />
		<meta property="og:locale" content="en_US" />
		<meta property="og:type" content="article" />
		<meta property="og:title" content="Metronic - Bootstrap 5 HTML, VueJS, React, Angular. Laravel, Asp.Net Core, Ruby on Rails, Spring Boot, Blazor, Django, Express Node.js & Flask Admin Dashboard Theme" />
		<meta property="og:url" content="https://keenthemes.com/metronic" />
		<meta property="og:site_name" content="Keenthemes | Metronic" />
		<link rel="canonical" href="https://preview.keenthemes.com/metronic8" />
		<link rel="shortcut icon" href="assets/media/logos/favicon.ico" />
		<!--begin::Fonts(mandatory for all pages)-->
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Inter:300,400,500,600,700" />
		<!--end::Fonts-->
		<!--begin::Vendor Stylesheets(used for this page only)-->
		<link href="assets/plugins/custom/datatables/datatables.bundle.css" rel="stylesheet" type="text/css" />
		<!--end::Vendor Stylesheets-->
		<!--begin::Global Stylesheets Bundle(mandatory for all pages)-->
		<link href="assets/plugins/global/plugins.bundle.css" rel="stylesheet" type="text/css" />
		<link href="assets/css/style.bundle.css" rel="stylesheet" type="text/css" />
		<!--end::Global Stylesheets Bundle-->
	</head>
	<!--end::Head-->
	<!--begin::Body-->
<body id="kt_body" data-kt-app-layout="dark-sidebar" data-kt-app-header-fixed="true" data-kt-app-sidebar-enabled="true"  data-kt-app-sidebar-hoverable="true" data-kt-app-sidebar-push-header="true" data-kt-app-sidebar-push-toolbar="true" data-kt-app-sidebar-push-footer="true" data-kt-app-toolbar-enabled="true"  class="app-default">
		<!--begin::Theme mode setup on page load-->
		<script>var defaultThemeMode = "light"; var themeMode; if ( document.documentElement ) { if ( document.documentElement.hasAttribute("data-theme-mode")) { themeMode = document.documentElement.getAttribute("data-theme-mode"); } else { if ( localStorage.getItem("data-theme") !== null ) { themeMode = localStorage.getItem("data-theme"); } else { themeMode = defaultThemeMode; } } if (themeMode === "system") { themeMode = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; } document.documentElement.setAttribute("data-theme", themeMode); }</script>
		<!--end::Theme mode setup on page load-->
		<!--begin::Main-->
		<!--begin::Root-->
		<div class="d-flex flex-column flex-root">
			<!--begin::Page-->
			<div class="page d-flex flex-row flex-column-fluid">
				<!--begin::Aside-->
				<?php include('sidebar.php'); ?>
				<!--end::Aside-->
				<!--begin::Wrapper-->
				<div class="wrapper d-flex flex-column flex-row-fluid" id="kt_wrapper">
					<!--begin::Header-->
					<div id="kt_header" style="" class="header align-items-stretch">
						<!--begin::Container-->
						<div class="container-fluid d-flex align-items-stretch justify-content-between">
							<!--begin::Aside mobile toggle-->
							<div class="d-flex align-items-center d-lg-none ms-n3 me-1" title="Show aside menu">
								<div class="btn btn-icon btn-active-color-primary w-40px h-40px" id="kt_aside_toggle">
									<!--begin::Svg Icon | path: icons/duotune/abstract/abs015.svg-->
									<span class="svg-icon svg-icon-1">
										<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
											<path d="M21 7H3C2.4 7 2 6.6 2 6V4C2 3.4 2.4 3 3 3H21C21.6 3 22 3.4 22 4V6C22 6.6 21.6 7 21 7Z" fill="currentColor" />
											<path opacity="0.3" d="M21 14H3C2.4 14 2 13.6 2 13V11C2 10.4 2.4 10 3 10H21C21.6 10 22 10.4 22 11V13C22 13.6 21.6 14 21 14ZM22 20V18C22 17.4 21.6 17 21 17H3C2.4 17 2 17.4 2 18V20C2 20.6 2.4 21 3 21H21C21.6 21 22 20.6 22 20Z" fill="currentColor" />
										</svg>
									</span>
									<!--end::Svg Icon-->
								</div>
							</div>
							<!--end::Aside mobile toggle-->
							<!--begin::Mobile logo-->
							<div class="d-flex align-items-center flex-grow-1 flex-lg-grow-0">
								<a href="../../demo4/dist/index.html" class="d-lg-none">
									<img alt="Logo" src="assets/media/logos/demo4-mobile.svg" class="h-25px" />
								</a>
							</div>
							<!--end::Mobile logo-->
							<div class="d-flex align-items-center" id="kt_header_wrapper">
								<!--begin::Page title-->
								<div class="page-title d-flex flex-column align-items-start justify-content-center flex-wrap me-lg-20 pb-5 pb-lg-0" data-kt-swapper="true" data-kt-swapper-mode="prepend" data-kt-swapper-parent="{default: '#kt_content_container', lg: '#kt_header_wrapper'}">
									<!--begin::Heading-->
									<h1 class="text-dark fw-bold my-1 fs-3 lh-1">Add moduleallocation</h1>
									<!--end::Heading-->
									<!--begin::Breadcrumb-->
									<ul class="breadcrumb fw-semibold fs-8 my-1">
										<li class="breadcrumb-item text-muted">
											<a href="dashboard.php" class="text-muted">Home</a>
										</li>
										<li class="breadcrumb-item text-muted">Master</li>
										<li class="breadcrumb-item text-muted">moduleallocation</li>
									</ul>
									<!--end::Breadcrumb-->
								</div>
								<!--end::Page title=-->
							</div>
							<!--begin::Wrapper-->
							<?php include('header.php'); ?>
							<!--end::Wrapper-->
						</div>
						<!--end::Container-->
					</div>
					<!--end::Header-->
					<!--begin::Content-->
					<div class="content d-flex flex-column flex-column-fluid" id="kt_content">
						<!--begin::Container-->
						<div class="container-xxl" id="kt_content_container">
							<!--begin::Contacts App- Add New Contact-->
							<div class="row g-7">
							<div class="col-xl-2">
							</div>
								<!--begin::Content-->
								<div class="col-xl-8">
									<!--begin::Contacts-->
									<div class="card card-flush h-lg-100" id="kt_contacts_main">
										<!--begin::Card header-->
										<div class="card-header pt-7" id="kt_chat_contacts_header">
											<!--begin::Card title-->
											<div class="card-title">
												<!--begin::Svg Icon | path: icons/duotune/communication/com005.svg-->
												
												<!--end::Svg Icon-->
												<h2><span class="menu-icon">
													<span class="fas fa-dice-six"></span>
												</span> Add moduleallocation</h2>
											</div>
											<!--end::Card title-->
										</div>
										<!--end::Card header-->
										<!--begin::Card body-->
										<div class="card-body pt-5">
											<!--begin::Form-->
											<form id="kt_ecommerce_settings_general_form" class="form" action="moduleallocationedit2.php" method="POST">
											<!--begin::Input group-->
												<div class="fv-row mb-7">
													<!--begin::Label-->
													<label class="fs-6 fw-semibold form-label mt-3">
														<span class="required">Role</span>
														<i class="fas fa-exclamation-circle ms-1 fs-7" data-bs-toggle="tooltip" title="Select Role."></i>
													</label>
													<!--end::Label-->
													<!--begin::Input-->
													<select class="form-select form-select-solid" data-control="select2"   name="rolemid" id="rolemid" >
														<option value="0">Select</option>
													<?php 
													$rolemid=(int)mysqli_real_escape_string($conn,$_GET['id']);
																			$eve = "select * from res_role_master";

																			$re = mysqli_query($conn, $eve);
																			
																			while($rt = mysqli_fetch_assoc($re))

																			{											
																				
																				
																				$rolename=$rt['rolename'];
																				$rolemid1=$rt['rolemid'];
																				if($rolemid == $rolemid1)
																				{
																				echo "<option value='$rolemid1' selected>$rolename</option>";
																				}else{
																					echo "<option value='$rolemid1'>$rolename</option>";
																				}
																				 
																			}
																			
																	?>
													</select>
													<!--end::Input-->
												</div>
												<!--end::Input group-->
												<!--begin::Permissions-->
															<div class="fv-row">
																<!--begin::Label-->
																<label class="fs-5 fw-bold form-label mb-2">Role Permissions</label>
																<!--end::Label-->
																<!--begin::Table wrapper-->
																<div class="table-responsive">
																	<!--begin::Table-->
																	<table class="table align-middle table-row-dashed fs-6 gy-5">
																		<!--begin::Table body-->
																		<tbody class="text-gray-600 fw-semibold">
																			<!--begin::Table row-->
																			<tr>
																				<td class="text-gray-800">Administrator Access
																				<i class="fas fa-exclamation-circle ms-1 fs-7" data-bs-toggle="tooltip" title="Allows a full access to the system"></i></td>
																				<td>
																					<!--begin::Checkbox-->
																					<label class="form-check form-check-sm form-check-custom form-check-solid me-9">
																						<input class="form-check-input" type="checkbox" value="" id="kt_roles_select_all" />
																						<span class="form-check-label" for="kt_roles_select_all">Select all</span>
																					</label>
																					<!--end::Checkbox-->
																				</td>
																			</tr>
																			<!--end::Table row-->
																			<!--begin::Table row-->
																			<?php 
																			$rolemid=(int)mysqli_real_escape_string($conn,$_GET['id']);
																			 $eve1 = "select * from res_submodule_master,res_mainmodule_master where res_submodule_master.smstatus=1 and res_mainmodule_master.mmodulemid = res_submodule_master.mmodulemid and res_mainmodule_master.mmstatus=1";
																			$re1 = mysqli_query($conn, $eve1);
																			if(mysqli_num_rows($re1) > 0)
																			{
																			while($rt1 = mysqli_fetch_assoc($re1))

																			{
																				$mainmodulename = $rt1['mainmodulename'];
																				$smodulemid  = $rt1['smodulemid'];
																				$smodulename  = $rt1['smodulename'];
																				$malistview=0;
						$maview=0;
						$maadd=0;
						$maedit=0;
						$madelete=0;
																				$eve2 = "select * from res_moduleallocation_detail where smodulemid=$smodulemid and rolemid=$rolemid";
																			$re2 = mysqli_query($conn, $eve2);
																			if(mysqli_num_rows($re2) > 0)
																			{
																				
																			while($rt2 = mysqli_fetch_assoc($re2))

																			{
																				$malistview = $rt2['malistview'];
																				$maview = $rt2['maview'];
																				$maadd = $rt2['maadd'];
																				$maedit = $rt2['maedit'];
																				$madelete = $rt2['madelete'];
																			}
																			}
																				
																				
																				
																			?>
																			<tr>
																				<!--begin::Label-->
																				<td class="text-gray-800"><?php echo $mainmodulename; ?></td>
																				<td class="text-gray-800"><?php echo $smodulename; ?></td>
																				<input type="hidden" name="smodulemid[]" value="<?php echo $smodulemid; ?>">
																				<!--end::Label-->
																				<!--begin::Input group-->
																				<td>
																					<!--begin::Wrapper-->
																					<div class="d-flex">
																						<!--begin::Checkbox-->
																						<label class="form-check form-check-sm form-check-custom form-check-solid me-5 me-lg-15">
																							<input class="form-check-input" type="checkbox" value="1" name="malistview<?php echo $smodulemid ?>" <?php if($malistview == 1){ echo 'checked'; }?>/>
																							<span class="form-check-label">View List</span>
																						</label>
																						<!--end::Checkbox-->
																						<!--begin::Checkbox-->
																						<label class="form-check form-check-sm form-check-custom form-check-solid me-5 me-lg-15">
																							<input class="form-check-input" type="checkbox" value="1" name="maview<?php echo $smodulemid ?>" <?php if($maview == 1){ echo 'checked'; }?>/>
																							<span class="form-check-label">Read</span>
																						</label>
																						<!--end::Checkbox-->
																						<!--begin::Checkbox-->
																						<label class="form-check form-check-custom form-check-solid me-5 me-lg-15">
																							<input class="form-check-input" type="checkbox" value="1" name="maadd<?php echo $smodulemid ?>" <?php if($maadd == 1){ echo 'checked'; }?> />
																							<span class="form-check-label">Add</span>
																						</label>
																						<!--end::Checkbox-->
																						<!--begin::Checkbox-->
																						<label class="form-check form-check-custom form-check-solid  me-5 me-lg-15">
																							<input class="form-check-input" type="checkbox" value="1" name="maedit<?php echo $smodulemid ?>" <?php if($maedit == 1){ echo 'checked'; }?>/>
																							<span class="form-check-label">Edit</span>
																						</label>
																						<!--end::Checkbox-->
																					<!--begin::Checkbox-->
																						<label class="form-check form-check-custom form-check-solid  me-5 me-lg-15">
																							<input class="form-check-input" type="checkbox" value="1" name="madelete<?php echo $smodulemid ?>" <?php if($madelete == 1){ echo 'checked'; }?>/>
																							<span class="form-check-label">Delete</span>
																						</label>
																						<!--end::Checkbox-->
																					</div>
																					<!--end::Wrapper-->
																				</td>
																				<!--end::Input group-->
																			</tr>
																			<!--end::Table row-->
																			<?php
																			}
																			}
																			?>
																			</tbody>
																		<!--end::Table body-->
																	</table>
																	<!--end::Table-->
																</div>
																<!--end::Table wrapper-->
															</div>
															<!--end::Permissions-->
														
												
												
												<!--begin::Separator-->
												<div class="separator mb-6"></div>
												<!--end::Separator-->
												<!--begin::Action buttons-->
												<div class="d-flex justify-content-end">
													<!--begin::Button-->
													<a type="reset" href="moduleallocation.php"  class="btn btn-light me-3">Cancel</a>
													<!--end::Button-->
													<!--begin::Button-->
													<button type="submit"  class="btn btn-primary">
														<span class="indicator-label">Save</span>
														<span class="indicator-progress">Please wait...
														<span class="spinner-border spinner-border-sm align-middle ms-2"></span></span>
													</button>
													<!--end::Button-->
												</div>
												<!--end::Action buttons-->
											</form>
											<!--end::Form-->
										</div>
										<!--end::Card body-->
									</div>
									<!--end::Contacts-->
								</div>
								<!--end::Content-->
							</div>
							<!--end::Contacts App- Add New Contact-->
						</div>
						<!--end::Container-->
					</div>
					<!--end::Content-->
					</div>
				<!--end::Wrapper-->
			</div>
			<!--end::Page-->
		</div>
		<!--end::Root-->
		
		<!--end::Main-->
		
		<!--begin::Engage modals-->
		<!--end::Engage modals-->
		<!--begin::Engage toolbar-->
		<!--end::Engage toolbar-->
		<!--begin::Scrolltop-->
		<div id="kt_scrolltop" class="scrolltop" data-kt-scrolltop="true">
			<!--begin::Svg Icon | path: icons/duotune/arrows/arr066.svg-->
			<span class="svg-icon">
				<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
					<rect opacity="0.5" x="13" y="6" width="13" height="2" rx="1" transform="rotate(90 13 6)" fill="currentColor" />
					<path d="M12.5657 8.56569L16.75 12.75C17.1642 13.1642 17.8358 13.1642 18.25 12.75C18.6642 12.3358 18.6642 11.6642 18.25 11.25L12.7071 5.70711C12.3166 5.31658 11.6834 5.31658 11.2929 5.70711L5.75 11.25C5.33579 11.6642 5.33579 12.3358 5.75 12.75C6.16421 13.1642 6.83579 13.1642 7.25 12.75L11.4343 8.56569C11.7467 8.25327 12.2533 8.25327 12.5657 8.56569Z" fill="currentColor" />
				</svg>
			</span>
			<!--end::Svg Icon-->
		</div>
		<!--end::Scrolltop-->
		
		<!--begin::Javascript-->
		<script>var hostUrl = "assets/";</script>
		<!--begin::Global Javascript Bundle(mandatory for all pages)-->
		<script src="assets/plugins/global/plugins.bundle.js"></script>
		<script src="assets/js/scripts.bundle.js"></script>
		<!--end::Global Javascript Bundle-->
		<!--begin::Vendors Javascript(used for this page only)-->
		<script src="assets/plugins/custom/datatables/datatables.bundle.js"></script>
		<!--end::Vendors Javascript-->
		<!--begin::Custom Javascript(used for this page only)-->
		<script src="assets/js/custom/apps/contacts/edit-contact.js"></script>
		<script src="assets/js/widgets.bundle.js"></script>
		<script src="assets/js/custom/widgets.js"></script>
		<script src="assets/js/custom/apps/chat/chat.js"></script>
		<script src="assets/js/custom/utilities/modals/upgrade-plan.js"></script>
		<script src="assets/js/custom/utilities/modals/users-search.js"></script>
		<!--end::Custom Javascript-->
		<script type="text/javascript">
	
		$('#kt_ecommerce_settings_general_form').submit(function(e)
		{
			if($('#countrymid').val() == '0')
			{
				alert('Select Country');
				e.preventDefault();
			}

		});
	
	</script>
	<script type="text/javascript">
	

 
	   
	  $(document).ready(function() {
    $('#kt_roles_select_all').click(function() {
		var checked = $(this).is(':checked'); // Checkbox state
		if(checked){
        $(':checkbox').each(function() {
            this.checked = true;
        });
		}else{
		$(':checkbox').each(function() {
            this.checked = false;
        });	
		}
    })
});
	
	</script>
		<!--end::Javascript-->
	</body>
	<!--end::Body-->
</html>