<?PHP
ob_start();
session_start();
include 'connect.php';
if(isset($_SESSION['adminemail']))
{
$user=$_SESSION['adminemail'];

$gtp=mysqli_query($conn,"select * from admin where username='$user'");
$gtp1=mysqli_fetch_assoc($gtp);

include 'top.php';
?>


<div id="page-wrapper" >
          <div id="page-inner">
<div class="main-content">
				<div class="main-content-inner">
					<div class="breadcrumbs ace-save-state" id="breadcrumbs">
						<ul class="breadcrumb">
							<li>
								<i class="ace-icon fa fa-home home-icon"></i>
								<a href="#">Home</a>
							</li>
							<li class="active">Menu Control</li>
						</ul><!-- /.breadcrumb -->
					</div>

					<div class="page-content">
			

						<div class="page-header">
							<h1>
								Menu Control
							</h1>
						</div><!-- /.page-header -->
<br />

						<div class="row">
							<div class="col-xs-12">
                            
								<!-- PAGE CONTENT BEGINS -->
                                
<script src="assets/js/jquery.js"></script>
<script>
	
jQuery(function($){
		   
	// simple jQuery validation script
	$('#work').submit(function(){
		
		var valid = true;
		var errormsg = 'This field is required!';
		var errorcn = 'error';
		
		$('.' + errorcn, this).remove();			
		
		$('#required', this).each(function(){
			var parent = $(this).parent();
			if( $(this).val() == '' ){
				var msg = $(this).attr('title');
				msg = (msg != '') ? msg : errormsg;
				$('<span style="font-size:13px;color:#FF0000; padding-left:3px;" class="'+ errorcn +'">'+ msg +'</span>')
					.appendTo(parent)
					.fadeIn('fast')
					.click(function(){ $(this).remove(); });
				valid = false;
			};
		});
		
		return valid;
	});
	
});	

</script>
								

                               
<?php



if(isset($_POST['submit']))

{

$check=$_POST['check'];

$type=$_POST['type'];

$user=$_POST['user'];



$kk=mysqli_query($conn,"delete from menu where username='$user'");


foreach($check as $chk)
{

$in=mysqli_query($conn,"insert into menu(menu,username) values('$chk','$user')");

}

if($kk || $in)
{

header("location:menu_control.php?s=1&user=".$user."");

}

else
{

header("location:menu_control.php?s=2&user=".$user."");

}


}	

elseif($_GET['user'])
{


$user=$_GET['user'];



if (isset($_GET['s']))

	{

	

	 $status=$_GET['s'];

	 

		 if($status=='1')

		 {

           echo'<div class="alert alert-success alert-dismissable">

                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>

                <span style="text-align:left;">Values Insreted Successfully.</span>

                </div>';

		 }

		 

		 elseif($status=='2')

		 {

           echo'<div class="alert alert-error alert-dismissable">

                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>

                <span style="text-align:left;">Values Not Insreted. Please try again.</span>

                </div>';

		 }

		

	}


$sela=mysqli_query($conn,"select * from employee where ID='$user'");
$sela1=mysqli_fetch_assoc($sela);


echo"<center>


<table style='line-height:23px; font-weight:bold;'>


<tr><td>User</td><td style='padding:0 5px 0 5px;'>:</td><td>".$sela1['username']."</td></tr>


</table>


</center><br />";


$c1=mysqli_query($conn,"select * from menu where menu='customer' and username='$user'");
$d1=mysqli_num_rows($c1);


$c2=mysqli_query($conn,"select * from menu where menu='supplier' and username='$user'");
$d2=mysqli_num_rows($c2);


$c3=mysqli_query($conn,"select * from menu where menu='productcategory' and username='$user'");
$d3=mysqli_num_rows($c3);


$c4=mysqli_query($conn,"select * from menu where menu='product' and username='$user'");
$d4=mysqli_num_rows($c4);


$c5=mysqli_query($conn,"select * from menu where menu='factory' and username='$user'");
$d5=mysqli_num_rows($c5);


$c6=mysqli_query($conn,"select * from menu where menu='bank' and username='$user'");
$d6=mysqli_num_rows($c6);


$c7=mysqli_query($conn,"select * from menu where menu='department' and username='$user'");
$d7=mysqli_num_rows($c7);


$c8=mysqli_query($conn,"select * from menu where menu='designation' and username='$user'");
$d8=mysqli_num_rows($c8);


$c9=mysqli_query($conn,"select * from menu where menu='settings' and username='$user'");
$d9=mysqli_num_rows($c9);


$c10=mysqli_query($conn,"select * from menu where menu='purchaseorder' and username='$user'");
$d10=mysqli_num_rows($c10);


$c11=mysqli_query($conn,"select * from menu where menu='purchase' and username='$user'");
$d11=mysqli_num_rows($c11);


$c12=mysqli_query($conn,"select * from menu where menu='production' and username='$user'");
$d12=mysqli_num_rows($c12);


$c13=mysqli_query($conn,"select * from menu where menu='salesorder' and username='$user'");
$d13=mysqli_num_rows($c13);


$c14=mysqli_query($conn,"select * from menu where menu='sales' and username='$user'");
$d14=mysqli_num_rows($c14);


$c15=mysqli_query($conn,"select * from menu where menu='stock' and username='$user'");
$d15=mysqli_num_rows($c15);


$c16=mysqli_query($conn,"select * from menu where menu='payment' and username='$user'");
$d16=mysqli_num_rows($c16);


$c17=mysqli_query($conn,"select * from menu where menu='receipt' and username='$user'");
$d17=mysqli_num_rows($c17);


$c18=mysqli_query($conn,"select * from menu where menu='daybook' and username='$user'");
$d18=mysqli_num_rows($c18);


$c19=mysqli_query($conn,"select * from menu where menu='customerledger' and username='$user'");
$d19=mysqli_num_rows($c19);


$c20=mysqli_query($conn,"select * from menu where menu='supplierledger' and username='$user'");
$d20=mysqli_num_rows($c20);


$c21=mysqli_query($conn,"select * from menu where menu='cashledger' and username='$user'");
$d21=mysqli_num_rows($c21);


$c22=mysqli_query($conn,"select * from menu where menu='bankledger' and username='$user'");
$d22=mysqli_num_rows($c22);


$c23=mysqli_query($conn,"select * from menu where menu='outstandings' and username='$user'");
$d23=mysqli_num_rows($c23);


$c24=mysqli_query($conn,"select * from menu where menu='expensecategory' and username='$user'");
$d24=mysqli_num_rows($c24);


$c25=mysqli_query($conn,"select * from menu where menu='expense' and username='$user'");
$d25=mysqli_num_rows($c25);


$c26=mysqli_query($conn,"select * from menu where menu='imprest' and username='$user'");
$d26=mysqli_num_rows($c26);


$c27=mysqli_query($conn,"select * from menu where menu='employees' and username='$user'");
$d27=mysqli_num_rows($c27);


$c28=mysqli_query($conn,"select * from menu where menu='attendance' and username='$user'");
$d28=mysqli_num_rows($c28);


$c29=mysqli_query($conn,"select * from menu where menu='advance' and username='$user'");
$d29=mysqli_num_rows($c29);


$c30=mysqli_query($conn,"select * from menu where menu='generatepayslip' and username='$user'");
$d30=mysqli_num_rows($c30);


$c31=mysqli_query($conn,"select * from menu where menu='kpi' and username='$user'");
$d31=mysqli_num_rows($c31);


$c32=mysqli_query($conn,"select * from menu where menu='kpireport' and username='$user'");
$d32=mysqli_num_rows($c32);


$c33=mysqli_query($conn,"select * from menu where menu='salarysheet' and username='$user'");
$d33=mysqli_num_rows($c33);


$c34=mysqli_query($conn,"select * from menu where menu='transport' and username='$user'");
$d34=mysqli_num_rows($c34);


$c35=mysqli_query($conn,"select * from menu where menu='delivery' and username='$user'");
$d35=mysqli_num_rows($c35);


$c36=mysqli_query($conn,"select * from menu where menu='fuel' and username='$user'");
$d36=mysqli_num_rows($c36);


$c37=mysqli_query($conn,"select * from menu where menu='fuelreport' and username='$user'");
$d37=mysqli_num_rows($c37);


$c38=mysqli_query($conn,"select * from menu where menu='crmcustomer' and username='$user'");
$d38=mysqli_num_rows($c38);


$c39=mysqli_query($conn,"select * from menu where menu='crmteamallocate' and username='$user'");
$d39=mysqli_num_rows($c39);


$c40=mysqli_query($conn,"select * from menu where menu='followup' and username='$user'");
$d40=mysqli_num_rows($c40);


$c41=mysqli_query($conn,"select * from menu where menu='followupreport' and username='$user'");
$d41=mysqli_num_rows($c41);


$c42=mysqli_query($conn,"select * from menu where menu='executivesreport' and username='$user'");
$d42=mysqli_num_rows($c42);


$c43=mysqli_query($conn,"select * from menu where menu='otattendance' and username='$user'");
$d43=mysqli_num_rows($c43);


$c44=mysqli_query($conn,"select * from menu where menu='todaysfollowup' and username='$user'");
$d44=mysqli_num_rows($c44);


$c45=mysqli_query($conn,"select * from menu where menu='teamwisereport' and username='$user'");
$d45=mysqli_num_rows($c45);


$c46=mysqli_query($conn,"select * from menu where menu='newproject' and username='$user'");
$d46=mysqli_num_rows($c46);


$c47=mysqli_query($conn,"select * from menu where menu='coconutproject' and username='$user'");
$d47=mysqli_num_rows($c47);


$c48=mysqli_query($conn,"select * from menu where menu='premiumcustomers' and username='$user'");
$d48=mysqli_num_rows($c48);


?>


<form action="menu_control.php" method="post">


<input type="hidden" name="user" value="<?php echo $user; ?>" />


<table style="width:95%; margin:auto;">

<tr>

<td style="width:20%; padding-top:35px;" valign="top">

<b>Masters</b>

<table style="margin-top:7px; line-height:23px;">

<tr><td><input type="checkbox" value="customer" name="check[1]" style="margin-top:-3px;" <?php if($d1>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Customer</td></tr>

<tr><td><input type="checkbox" value="supplier" name="check[2]" style="margin-top:-3px;" <?php if($d2>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Supplier</td></tr>

<tr><td><input type="checkbox" value="productcategory" name="check[3]" style="margin-top:-3px;" <?php if($d3>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Product Category</td></tr>

<tr><td><input type="checkbox" value="product" name="check[4]" style="margin-top:-3px;" <?php if($d4>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Product</td></tr>

<tr><td><input type="checkbox" value="factory" name="check[5]" style="margin-top:-3px;" <?php if($d5>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Factory</td></tr>

<tr><td><input type="checkbox" value="bank" name="check[6]" style="margin-top:-3px;" <?php if($d6>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Bank</td></tr>

<tr><td><input type="checkbox" value="department" name="check[7]" style="margin-top:-3px;" <?php if($d7>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Department</td></tr>

<tr><td><input type="checkbox" value="designation" name="check[8]" style="margin-top:-3px;" <?php if($d8>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Designation</td></tr>

<tr><td><input type="checkbox" value="settings" name="check[9]" style="margin-top:-3px;" <?php if($d9>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Settings</td></tr>

</table>

</td>

<td style="width:20%; padding-top:35px;" valign="top">

<b>Purchase</b>

<table style="margin-top:7px; line-height:23px;">

<tr><td><input type="checkbox" value="purchaseorder" name="check[10]" style="margin-top:-3px;" <?php if($d10>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Purchase Order</td></tr>

<tr><td><input type="checkbox" value="purchase" name="check[11]" style="margin-top:-3px;" <?php if($d11>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Purchase</td></tr>

</table>

</td>


<td style="width:20%; padding-top:35px;" valign="top">

<b>Production</b>

<table style="margin-top:7px; line-height:23px;">

<tr><td><input type="checkbox" value="production" name="check[12]" style="margin-top:-3px;" <?php if($d12>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Production</td></tr>

</table>

</td>


<td style="width:20%; padding-top:35px;" valign="top">

<b>Sales</b>

<table style="margin-top:7px; line-height:23px;">

<tr><td><input type="checkbox" value="salesorder" name="check[13]" style="margin-top:-3px;" <?php if($d13>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Sales Order</td></tr>

<tr><td><input type="checkbox" value="sales" name="check[14]" style="margin-top:-3px;" <?php if($d14>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Sales</td></tr>

</table>

</td>

</tr>


<tr>

<td style="width:20%; padding-top:35px;" valign="top">

<b>Vouchers</b>

<table style="margin-top:7px; line-height:23px;">

<tr><td><input type="checkbox" value="payment" name="check[16]" style="margin-top:-3px;" <?php if($d16>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Payment</td></tr>

<tr><td><input type="checkbox" value="Receipt" name="check[17]" style="margin-top:-3px;" <?php if($d17>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Receipt</td></tr>

</table>

</td>


<td style="width:20%; padding-top:35px;" valign="top">

<b>Accounts</b>

<table style="margin-top:7px; line-height:23px;">


<tr><td><input type="checkbox" value="daybook" name="check[18]" style="margin-top:-3px;" <?php if($d18>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Daybook</td></tr>

<tr><td><input type="checkbox" value="customerledger" name="check[19]" style="margin-top:-3px;" <?php if($d19>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Customer Ledger</td></tr>

<tr><td><input type="checkbox" value="supplierledger" name="check[20]" style="margin-top:-3px;" <?php if($d20>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Supplier Ledger</td></tr>

<tr><td><input type="checkbox" value="cashledger" name="check[21]" style="margin-top:-3px;" <?php if($d21>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Cash Ledger</td></tr>

<tr><td><input type="checkbox" value="bankledger" name="check[22]" style="margin-top:-3px;" <?php if($d22>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Bank Ledger</td></tr>

<tr><td><input type="checkbox" value="outstandings" name="check[23]" style="margin-top:-3px;" <?php if($d23>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Outstandings</td></tr>

</table>

</td>


<td style="width:20%; padding-top:35px;" valign="top">

<b>Expense</b>

<table style="margin-top:7px; line-height:23px;">

<tr><td><input type="checkbox" value="expensecategory" name="check[24]" style="margin-top:-3px;" <?php if($d24>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Expense Category</td></tr>

<tr><td><input type="checkbox" value="expense" name="check[25]" style="margin-top:-3px;" <?php if($d25>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Expense</td></tr>

</table>

</td>


<td style="width:20%; padding-top:35px;" valign="top">

<b>Imprest</b>

<table style="margin-top:7px; line-height:23px;">

<tr><td><input type="checkbox" value="imprest" name="check[26]" style="margin-top:-3px;" <?php if($d26>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Imprest</td></tr>

</table>

</td>

</tr>


<tr>

<td style="width:20%; padding-top:35px;" valign="top">

<b>Employee</b>

<table style="margin-top:7px; line-height:23px;">

<tr><td><input type="checkbox" value="employees" name="check[27]" style="margin-top:-3px;" <?php if($d27>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Employees</td></tr>

<tr><td><input type="checkbox" value="attendance" name="check[28]" style="margin-top:-3px;" <?php if($d28>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Attendance</td></tr>

<tr><td><input type="checkbox" value="otattendance" name="check[43]" style="margin-top:-3px;" <?php if($d43>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">OT Attendance</td></tr>

<tr><td><input type="checkbox" value="advance" name="check[29]" style="margin-top:-3px;" <?php if($d29>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Advance</td></tr>

<tr><td><input type="checkbox" value="generatepayslip" name="check[30]" style="margin-top:-3px;" <?php if($d30>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Generate Payslip</td></tr>

</table>

</td>


<td style="width:20%; padding-top:35px;" valign="top">

<b>KPI</b>

<table style="margin-top:7px; line-height:23px;">

<tr><td><input type="checkbox" value="kpi" name="check[31]" style="margin-top:-3px;" <?php if($d31>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">KPI</td></tr>

<tr><td><input type="checkbox" value="kpireport" name="check[32]" style="margin-top:-3px;" <?php if($d32>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">KPI Report</td></tr>

<tr><td><input type="checkbox" value="salarysheet" name="check[33]" style="margin-top:-3px;" <?php if($d33>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Salary Sheet</td></tr>

</table>

</td>


<td style="width:20%; padding-top:35px;" valign="top">

<b>Transport</b>

<table style="margin-top:7px; line-height:23px;">

<tr><td><input type="checkbox" value="transport" name="check[34]" style="margin-top:-3px;" <?php if($d34>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Transport</td></tr>

<tr><td><input type="checkbox" value="delivery" name="check[35]" style="margin-top:-3px;" <?php if($d35>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Delivery</td></tr>

<tr><td><input type="checkbox" value="fuel" name="check[36]" style="margin-top:-3px;" <?php if($d36>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Fuel</td></tr>

<tr><td><input type="checkbox" value="fuelreport" name="check[37]" style="margin-top:-3px;" <?php if($d37>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Fuel Report</td></tr>

</table>

</td>

<td style="width:20%; padding-top:35px;" valign="top">

<b>CRM</b>

<table style="margin-top:7px; line-height:23px;">

<tr><td><input type="checkbox" value="crmcustomer" name="check[38]" style="margin-top:-3px;" <?php if($d38>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Farmer Data</td></tr>

<tr><td><input type="checkbox" value="crmteamallocate" name="check[39]" style="margin-top:-3px;" <?php if($d39>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">CRM Team Allocate</td></tr>

<tr><td><input type="checkbox" value="premiumcustomers" name="check[48]" style="margin-top:-3px;" <?php if($d48>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Premium Customers</td></tr>

<tr><td><input type="checkbox" value="followup" name="check[40]" style="margin-top:-3px;" <?php if($d40>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Follow Up</td></tr>

<tr><td><input type="checkbox" value="todaysfollowup" name="check[44]" style="margin-top:-3px;" <?php if($d44>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Today's Follow Up</td></tr>

<tr><td><input type="checkbox" value="followupreport" name="check[41]" style="margin-top:-3px;" <?php if($d41>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Follow Up Report</td></tr>

<tr><td><input type="checkbox" value="executivesreport" name="check[42]" style="margin-top:-3px;" <?php if($d42>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Executives Report</td></tr>

<tr><td><input type="checkbox" value="teamwisereport" name="check[45]" style="margin-top:-3px;" <?php if($d45>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Teamwise Report</td></tr>

</table>

</td>

</tr>


<tr>

<td style="width:20%; padding-top:35px;" valign="top">

<b>Stock</b>

<table style="margin-top:7px; line-height:23px;">

<tr><td><input type="checkbox" value="stock" name="check[15]" style="margin-top:-3px;" <?php if($d15>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Stock</td></tr>

</table>

</td>


<td style="width:20%; padding-top:35px;" valign="top">

<b>New Project</b>

<table style="margin-top:7px; line-height:23px;">

<tr><td><input type="checkbox" value="newproject" name="check[46]" style="margin-top:-3px;" <?php if($d46>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">New Project</td></tr>

</table>

</td>


<td style="width:20%; padding-top:35px;" valign="top">

<b>Coconut Project</b>

<table style="margin-top:7px; line-height:23px;">

<tr><td><input type="checkbox" value="coconutproject" name="check[47]" style="margin-top:-3px;" <?php if($d47>0){ echo'checked="checked"'; } ?> /> </td><td style="padding-left:5px;">Coconut Project</td></tr>

</table>

</td>

<td style="width:20%; padding-top:35px;" valign="top">

</td>

</tr>

</table><br /><br />



<center><button type="submit" name="submit" value="submit" class="btn btn btn-primary">Submit</button></center>



</form>



<br />



<center><a href="viewemployee.php">Back</a></center>



<?php



}



?>

                               
							<br>
<br>
	

								<!-- PAGE CONTENT ENDS -->
							</div><!-- /.col -->
						</div><!-- /.row -->
					

</div><!-- /.page-content -->
				</div>
			</div><!-- /.main-content -->
			</div><!-- /.main-content -->
			</div><!-- /.main-content -->


<?php
include 'bottom.php';
}
else
{

 header("location:login.php");
}
ob_flush();
?>