<?php
include_once '../includes/config.php';
include_once '../includes/database.php';
include_once '../includes/check_session.php';
include_once '../includes/check_edit_page.php';
include_once '../includes/auth.php';

$auth = array('customer_admin');
$authRes = checkAuth($auth, $user);
if(!$authRes)
{
    header('Location: ' . DOMAIN . '/auth/login.php');
    exit;
}

class Add extends database
{
   
    
    public function getAllCategory()
    {
        return $this->fetchAll('tb_category');
    }
    
    public function getCurrentPost($id, $userID)
    {
        $where['cl_user_id'] = $userID;
        $where['cl_id'] = $id;
        return $this->fetchRow('tb_menu', $where);
    }
    
}

$obj = new Add();
$categories = $obj->getAllCategory();

$data = $obj->getCurrentPost($id, $user['cl_id']);
if(!$data)
{
    header('Location: list.php');
    exit;
}


 include '../header.php';
 ?>
<div class="content-wrapper">
            <!-- Content -->

            <div class="container-xxl flex-grow-1 container-p-y">
              <h4 class="fw-bold py-3 mb-4">Add Menu Item</h4>
                

              <!-- Basic Layout -->
              <div class="row">
				
                   
                    <div class="col-sm-12">
                    	<div class="order-contact">
                        	<div class="row edit-user-box">
                                <div class="col-sm-12">
                                    <div class="row">
									
                                        <form method="post" class="form" cluster-url="ajax/edit_ajax.php?id=<?php echo $id ?>" cluster-redirect="add.php">
                                            <div class="error-main"></div>
                                            <?php include_once 'template/form.php' ?>
                                        </form>
                                    </div>
                            	</div>
                        	</div>                            
                        </div>
                    </div>
                </div>
                
                
            </div>
        </div>


    <script>
    $(document).ready(function(){
        $('.menu-item').removeClass('active');
        $('#item-menu').addClass('active');
    }); 
</script>
<?php include '../footer.php';?>