<?php

// dynamic_full_menu.php

session_start();

$userid = isset($_SESSION['userid']) ? $_SESSION['userid'] : '';

if (!$userid) {

	//header("location:login.php?action=need");

    //die("Please login first.");

}



include("config2.php");



if (!$conn) {

    die("Connection failed: " . mysqli_connect_error());

}



// Get permissions for this user

$sql = "SELECT permissions FROM user WHERE userid='$userid'";

$result = mysqli_query($conn, $sql);

if (!$result || mysqli_num_rows($result) == 0) {

    die("No permissions found for this user.");

}



$row = mysqli_fetch_assoc($result);

$permissions = explode(',', $row['permissions']); // array of allowed page names



function can_access($page_name, $permissions) {

    return in_array($page_name, $permissions);

}



mysqli_close($conn);

?>



<ul class="menu" id="menu">

	

    

        <li><a href="index.php" target="_self" class="menulink">Home</a></li>

   



 

<!-- Room Booking -->

<?php if (

    can_access('hotel_new', $permissions) ||

    can_access('hotel_new_confirm', $permissions) ||

    can_access('hotel_new_due_payment', $permissions) ||

    can_access('hotel_bill_list', $permissions) ||

    can_access('customer_profile', $permissions)

) { ?>

    <li><a href="javascript:void(0);" class="menulink">Hotel</a>

        <ul>

            <?php if (can_access('hotel_new', $permissions)) { ?><li><a href="hotel_new.php" class="menulink">Room Booking</a></li><?php } ?>
            	<li><a href="booking.php"  target="_parent" class="menulink">Web Booking</a></li>

            <?php if (can_access('hotel_new_confirm', $permissions)) { ?><li><a href="hotel_new_confirm.php" class="menulink">Room Status</a></li><?php } ?>

            <?php if (can_access('hotel_new_due_payment', $permissions)) { ?><li><a href="hotel_new_due_payment.php" class="menulink">Due Payment</a></li><?php } ?>

            <?php if (can_access('hotel_bill_list', $permissions)) { ?><li><a href="hotel_bill_list.php" class="menulink">All Booking List</a></li><?php } ?>
            <?php if (can_access('hotel_bill_list', $permissions)) { ?><li><a href="hotel_bill_list_room.php"  target="_parent" class="menulink">All Booking room</a></li><?php } ?>
			<?php if (can_access('hotel_bill_list', $permissions)) { ?><li><a href="hotel_due_list.php" class="menulink">All Due List</a></li><?php } ?>

            <?php if (can_access('customer_profile', $permissions)) { ?><li><a href="customer_profile.php" class="menulink">Customer Profile</a></li><?php } ?>

			<?php if (can_access('add_client', $permissions)) { ?><li><a href="add_client.php" class="menulink">Customer</a></li><?php } ?>
			
			<li><a href="hotel_breakfast_list.php"  target="_parent" class="menulink">Breakfast list</a></li>
			
			<li><a href="hotel_breakfast_list2.php"  target="_parent" class="menulink">Breakfast list old</a></li>
			
		
 

        </ul>

    </li>

<?php } ?>

<?php if (

    can_access('restaurant_chalan_entry', $permissions) ||

    can_access('restaurant_add_product', $permissions) ||

    can_access('restaurant_bill_list', $permissions) ||

    can_access('restaurant_due_payment', $permissions) ||
	
	can_access('restaurant_cash_book', $permissions) ||
	can_access('restaurant_add_cost', $permissions) ||
	can_access('restaurant_cost_summary', $permissions) ||
	can_access('restaurant_cost_view', $permissions) ||
	can_access('restaurant_due_payment', $permissions) ||

    can_access('restaurant_cost_type', $permissions)

) { ?>
<li><a href="javascript:void(0);" class="menulink">Restaurant</a>
	<ul>
		<?php if (can_access('restaurant_chalan_entry', $permissions)) { ?><li><a href="restaurant_chalan_entry.php" target="_parent" class="menulink">Create invoice</a></li>
		<?php } if (can_access('restaurant_add_product', $permissions)) { ?><li><a href="restaurant_add_product.php" target="_parent" class="menulink">product entry</a></li>
		<?php } if (can_access('restaurant_invoice_list-custom', $permissions)) { ?><li><a href="restaurant_invoice_list-custom.php"  target="_parent" class="menulink">Total Sale [item wise]</a></li>
		<?php } if (can_access('restaurant_bill_list', $permissions)) { ?><li><a href="restaurant_bill_list.php"  target="_parent" class="menulink">Bill list</a></li>
       
		<?php } if (can_access('restaurant_due_list', $permissions)) { ?><li><a href="restaurant_due_list.php"  target="_parent" class="menulink">Due list</a></li> 
		<?php } if (can_access('restaurant_due_payment', $permissions)) { ?><li><a href="restaurant_due_payment.php"  target="_parent" class="menulink">Due Payment</a></li>
		<?php } if (can_access('restaurant_cash_book', $permissions)) { ?><li><a href="restaurant_cash_book.php"  target="_parent" class="menulink">Resturent Cash Book</a></li> 
		<?php } if (can_access('restaurant_add_cost', $permissions)) { ?><li><a href="restaurant_add_cost.php" class="menulink">Add Cost</a></li>
		<?php } if (can_access('restaurant_cost_summary', $permissions)) { ?><li><a href="restaurant_cost_summary.php" class="menulink">Cost Summary</a></li>
		<?php } if (can_access('restaurant_cost_view', $permissions)) { ?><li><a href="restaurant_cost_view.php" class="menulink">Cost View</a></li>
		<?php } if (can_access('restaurant_cost_type', $permissions)) { ?><li><a href="restaurant_cost_type.php" class="menulink">Cost Type</a></li>
		<?php } if (can_access('add_cost', $permissions)) { ?><li><a href="restaurant_add_transfar.php" class="menulink">R Transfar Money </a></li>
		<?php } if (can_access('add_cost', $permissions)) { ?><li><a href="restaurant_add_withdraw.php" class="menulink">R Withdraw Money </a></li> 
		<?php } if (can_access('add_cost', $permissions)) { ?><li><a href="add_token.php" class="menulink">Token</a></li><?php } ?>

    </li>


			 
		
	 </ul>
    </li><?php } ?>

<li><a href="javascript:void(0);" class="menulink">Kitchen</a>
	<ul>
		<li><a href="restaurant_current_stock.php" class="menulink">Current Available Food</a></li>
        <li><a href="restaurant_meterial_in.php" class="menulink">Material Stock In</a></li>
		<li><a href="restaurant_meterial_weast.php" class="menulink">Material damaged / waste</a></li>
         <li><a href="restaurant_meterial.php" target="_parent" class="menulink">product Material </a></li>
         <li><a href="restaurant_add_product.php" target="_parent" class="menulink">product entry</a></li>
         
        

    </li>


			 
		
	 </ul>
    </li>
	

<!-- invest --> 

<?php if (

    can_access('add_invest', $permissions)

) { ?>

    <li><a href="javascript:void(0);" class="menulink">Invest</a>

        <ul>

            <?php if (can_access('add_invest', $permissions)) { ?><li><a href="add_invest.php" class="menulink">Add Invest</a></li><?php } ?>

			<?php if (can_access('invest_view', $permissions)) { ?><li><a href="invest_view.php" class="menulink">Invest View</a></li><?php } ?>
			
			



        </ul>

    </li>

<?php } ?>



<!-- Payable & Receivable -->

<?php if (

    can_access('payable', $permissions) ||

    can_access('receivable', $permissions) ||

    can_access('payable_summary', $permissions) ||

    can_access('payable_view', $permissions) ||

    can_access('payable_type', $permissions)

) { ?>

    <li><a href="javascript:void(0);" class="menulink">Pay & Rec.</a>
      <ul>
<?php if (can_access('payable_summary', $permissions)) { ?><li><a href="recentpr.php" class="menulink">Pending P&R </a></li><?php } ?>
            <?php if (can_access('payable', $permissions)) { ?><li><a href="payable.php" class="menulink">Add Payable</a></li><?php } ?>

            <?php if (can_access('receivable', $permissions)) { ?><li><a href="receivable.php" class="menulink">Add Receivable</a></li><?php } ?>

            <?php if (can_access('payable_summary', $permissions)) { ?><li><a href="payable_summary.php" class="menulink">P&R Summary</a></li><?php } ?>

            <?php if (can_access('payable_view', $permissions)) { ?><li><a href="payable_view.php" class="menulink">P&R Details</a></li><?php } ?>

            <?php if (can_access('payable_type', $permissions)) { ?><li><a href="payable_type.php" class="menulink">P&R Type</a></li><?php } ?>

      </ul>

  </li>

<?php } ?>


<!-- Accounts -->

<?php if (

    can_access('cash_book', $permissions) ||

    can_access('profit_loss', $permissions)

) { ?>

    <li><a href="javascript:void(0);" class="menulink">Accounts</a>

        <ul>

            <?php if (can_access('cash_book', $permissions)) { ?><li><a href="cash_book.php" class="menulink">Hotel Cash Book</a></li><?php } ?>


	<?php  if (can_access('restaurant_cash_book', $permissions)) { ?><li><a href="restaurant_cash_book.php"  target="_parent" class="menulink">Resturent Cash Book</a></li> <?php } ?>


            <?php if (can_access('profit_loss', $permissions)) { ?><li><a href="profit_loss.php" class="menulink">Hotel Profit and Loss</a></li><?php } ?>
			<?php if (can_access('add_cost', $permissions)) { ?><li><a href="add_transfar.php" class="menulink">Hotel Transfar Money </a></li><?php } ?>
			<?php if (can_access('add_cost', $permissions)) { ?><li><a href="add_withdraw.php" class="menulink">Hotel Withdraw Money </a></li><?php } ?>


<!-- Income -->

<?php if (

    can_access('add_income', $permissions) ||

    can_access('income_summary', $permissions) ||

    can_access('income_view', $permissions)

) { ?>

    <li><a href="javascript:void(0);" class="menulink">H Income</a>

        <ul>

            <?php if (can_access('add_income', $permissions)) { ?><li><a href="add_income.php" class="menulink">Add Income</a></li><?php } ?>

            <?php if (can_access('income_summary', $permissions)) { ?><li><a href="income_summary.php" class="menulink">Income Summary</a></li><?php } ?>

            <?php if (can_access('income_view', $permissions)) { ?><li><a href="income_view.php" class="menulink">Income View Details</a>


</li><?php } ?>

        </ul>

    </li>

<?php } ?>
<!-- Cost -->

<?php if (

    can_access('add_cost', $permissions) ||

    can_access('cost_summary', $permissions) ||

    can_access('cost_view', $permissions)

) { ?>

    <li><a href="javascript:void(0);" class="menulink">H Cost</a>

        <ul>

            <?php if (can_access('add_cost', $permissions)) { ?><li><a href="add_cost.php" class="menulink">Add Cost</a></li><?php } ?>

            <?php if (can_access('cost_summary', $permissions)) { ?><li><a href="cost_summary.php" class="menulink">Cost Summary</a></li><?php } ?>

            <?php if (can_access('cost_view', $permissions)) { ?><li><a href="cost_view.php" class="menulink">Cost View Details</a></li><?php } ?>

        </ul>

    </li>

<?php } ?>


        </ul>

    </li>

<?php } ?>



<!-- Entry -->

<?php if (

    can_access('add_room', $permissions) ||

    can_access('add_service', $permissions) ||

    can_access('add_income_type', $permissions) ||

    can_access('add_cost_type', $permissions) ||

    can_access('add_client', $permissions) ||

    can_access('add_bank', $permissions)

) { ?>

    <li><a href="javascript:void(0);" class="menulink">Entry</a>

        <ul>

            <?php if (can_access('add_room', $permissions)) { ?><li><a href="add_room.php" class="menulink">Room</a></li><?php } ?>

            <?php if (can_access('add_service', $permissions)) { ?><li><a href="add_service.php" class="menulink">Additional Service</a></li><?php } ?>

            <?php if (can_access('add_income_type', $permissions)) { ?><li><a href="add_income_type.php" class="menulink">Income Type</a></li><?php } ?>

            <?php if (can_access('add_cost_type', $permissions)) { ?><li><a href="add_cost_type.php" class="menulink">Cost Type</a></li><?php } ?>

            <?php if (can_access('add_client', $permissions)) { ?><li><a href="add_client.php" class="menulink">Customer</a></li><?php } ?>

            <?php if (can_access('add_bank', $permissions)) { ?><li><a href="add_bank.php" class="menulink">Add Pay methode</a></li><?php } ?>

        </ul>

    </li>

<?php } ?>



<!-- HR -->

<?php if (

    can_access('hr_employee', $permissions) ||

    can_access('hr_salary', $permissions) ||

    can_access('hr_salary_edit', $permissions)

) { ?>

    <li><a href="javascript:void(0);" class="menulink">HR</a>

        <ul>

            <?php if (can_access('hr_employee', $permissions)) { ?><li><a href="hr_employee.php" class="menulink">Add Employee</a></li><?php } ?>

            <?php if (can_access('hr_salary', $permissions)) { ?><li><a href="hr_salary.php" class="menulink">Add Salary</a></li><?php } ?>

			<?php if (can_access('hr_salary_paid', $permissions)) { ?><li><a href="hr_salary_paid.php" class="menulink">Salary Paid</a></li><?php } ?>
            <?php if (can_access('hr_salary_paid', $permissions)) { ?><li><a href="hr_leave.php" class="menulink">Leave Entry </a></li><?php } ?>

            <?php if (can_access('hr_salary_register', $permissions)) { ?>

            <li><a href="hr_salary_register.php" class="menulink">Salary Register</a></li><?php } ?>

        </ul>

    </li>

<?php } ?>



<?php if (

    can_access('stock_in', $permissions) ||

    can_access('current_stock', $permissions)

) { ?>

    <li><a href="javascript:void(0);" class="menulink">Stock</a>
     <ul>
         
			<!-- Inventory -->

<?php if (

    can_access('inventory_stock_in', $permissions) ||

    can_access('inventory_stock_out', $permissions) ||

    can_access('inventory_bac_stock_category', $permissions) ||

    can_access('inventory_current_stock', $permissions)

) { ?>

    <li><a href="javascript:void(0);" class="menulink">Inventory</a>

        <ul>

            <?php if (can_access('inventory_stock_in', $permissions)) { ?><li><a href="inventory_stock_in.php" class="menulink">Stock In</a></li><?php } ?>

            <?php if (can_access('inventory_stock_out', $permissions)) { ?><li><a href="inventory_stock_out.php" class="menulink">Stock Out</a></li><?php } ?>

            <?php if (can_access('inventory_bac_stock_category', $permissions)) { ?><li><a href="inventory_bac_stock_category.php" class="menulink">Inventory Category</a></li><?php } ?>

            <?php if (can_access('inventory_current_stock', $permissions)) { ?><li><a href="inventory_current_stock.php" class="menulink">Current Stock</a></li><?php } ?><br />
        </ul>

    </li>

<?php } ?>
         
<?php if (

    can_access('stock_in', $permissions) ||

    can_access('stock_out', $permissions) ||

    can_access('bac_stock_category', $permissions) ||

    can_access('current_stock', $permissions)

) { ?>

    <li><a href="javascript:void(0);" class="menulink">H Stock</a>

        <ul>

            <?php if (can_access('stock_in', $permissions)) { ?><li><a href="stock_in.php" class="menulink">Stock In</a></li><?php } ?>

            <?php if (can_access('stock_out', $permissions)) { ?><li><a href="stock_out.php" class="menulink">Stock Out</a></li><?php } ?>

            <?php if (can_access('bac_stock_category', $permissions)) { ?><li><a href="bac_stock_category.php" class="menulink">Stock Category</a></li><?php } ?>

            <?php if (can_access('current_stock', $permissions)) { ?><li><a href="current_stock.php" class="menulink">Current Stock</a></li><?php } ?><br />
        </ul>

    </li>

<?php } ?>
<?php if (

    can_access('kitchen_stock_in', $permissions) ||

    can_access('kitchen_stock_out', $permissions) ||

    can_access('bac_kitchen_stock_category', $permissions) ||

    can_access('current_kitchen_stock', $permissions)

) { ?>

    <li><a href="javascript:void(0);" class="menulink">Kitchen</a>

        <ul>

            <?php if (can_access('kitchen_stock_in', $permissions)) { ?><li><a href="kitchen_stock_in.php" class="menulink">Kitchen Stock In</a></li>
            <?php } ?>

            <?php if (can_access('kitchen_stock_out', $permissions)) { ?><li><a href="kitchen_stock_out.php" class="menulink">Kitchen Stock Out</a></li><?php } ?>

            <?php if (can_access('bac_kitchen_stock_category', $permissions)) { ?><li><a href="bac_kitchen_stock_category.php" class="menulink">Kitchen Category</a></li><?php } ?>

            <?php if (can_access('current_kitchen_stock', $permissions)) { ?><li><a href="current_kitchen_stock.php" class="menulink">Current Kitchen Stock</a></li><?php } ?>
        </ul>

    </li>

<?php } ?>

<!-- Laundry -->

<?php if (

    can_access('laundry_in', $permissions) ||

    can_access('laundry_out', $permissions) ||

    can_access('bac_laundry_category', $permissions) ||

    can_access('current_laundry_stock', $permissions)

) { ?>

    <li><a href="javascript:void(0);" class="menulink">Laundry</a>

        <ul>

            <?php if (can_access('laundry_in', $permissions)) { ?><li><a href="laundry_in.php" class="menulink">To Laundry</a></li>
            <?php } ?>

            <?php if (can_access('laundry_out', $permissions)) { ?><li><a href="laundry_out.php" class="menulink">From Laundry</a></li>
            <?php } ?>

            <?php if (can_access('bac_laundry_category', $permissions)) { ?>
            <li><a href="bac_laundry_category.php" class="menulink">Product Category</a></li>
            <?php } ?>

            <?php if (can_access('current_laundry_stock', $permissions)) { ?><li><a href="current_laundry_stock.php" class="menulink">Stock in Laundry</a></li>
            <?php } ?><br />
        </ul>

    </li>

<?php } ?>
      </ul>

    </li>

<?php } ?>




<!-- Stock -->








<!-- User -->

<?php if (can_access('admin_user', $permissions)) { ?>

    <li><a href="javascript:void(0);" class="menulink">User</a>

        <ul>

            <li><a href="admin_user.php" class="menulink">Add User</a></li>

        </ul>

    </li>

<?php } ?>



<?php if (can_access('bill_verify', $permissions)) { $bill_verify="1"; }else{$bill_verify="0"; } ?>
<?php if (can_access('hr_salary_edit', $permissions)) { $hr_salary_edit="1"; }else{$hr_salary_edit="0"; } ?>
	

<li><a href="logout.php" class="menulink">Logout</a></li>

</ul>

