<?php
include('session.php');
?>
<!doctype html>
<html lang="en">

<head>
<title>LaktusDev | Home</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="description" content="">
<meta name="author" content="LaktusDev, design by: laktusdev.com">

<link rel="icon" href="favicon.ico" type="image/x-icon">
<!-- VENDOR CSS -->
<link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/vendor/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/vendor/animate-css/vivify.min.css">

<link rel="stylesheet" href="assets/vendor/light-gallery/css/lightgallery.css">
<link rel="stylesheet" href="assets/vendor/dropify/css/dropify.min.css">
<link rel="stylesheet" href="assets/vendor/jquery-steps/jquery.steps.css">

<link rel="stylesheet" href="assets/vendor/bootstrap-multiselect/bootstrap-multiselect.css">
<link rel="stylesheet" href="assets/vendor/parsleyjs/css/parsley.css">

<link rel="stylesheet" href="assets/vendor/sweetalert/sweetalert.css"/>

<link rel="stylesheet" href="assets/vendor/jquery-datatable/dataTables.bootstrap4.min.css">
<link rel="stylesheet" href="assets/vendor/jquery-datatable/fixedeader/dataTables.fixedcolumns.bootstrap4.min.css">
<link rel="stylesheet" href="assets/vendor/jquery-datatable/fixedeader/dataTables.fixedheader.bootstrap4.min.css">

<!-- MAIN CSS -->
<link rel="stylesheet" href="assets/css/mooli.min.css">

<script src="assets/vendor/ckeditor/ckeditor.js"></script>

<script language="javascript" type="text/javascript">
function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
	function getaddsubmenu(catid) {		
		
		var strURL="addsubmenu_sr.php?menu_subcat_cat="+catid;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('submenu').innerHTML=req.responseText;	
						document.getElementById('subsubmenu').innerHTML='<div class="form-group c_form_group"><label>Pod meni</label><select name="content_subsub" class="custom-select" id="inputGroupSelect01" required>'+
						'<option>Izaberi</option>'+
				        '</select></div>';
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
	
	function getaddsubsubmenu(subcat_id) {		
		var strURL="addsubsubmenu_sr.php?menu_subcat_subcat="+subcat_id;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('subsubmenu').innerHTML=req.responseText;						
					} else {
						alert("Problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
</script>

</head>
<body>
    
<div id="body" class="theme-green">

<?php require 'includes/page-loader.php'; ?>

<?php require 'includes/themesetting.php'; ?>

    <!-- Overlay For Sidebars -->
    <div class="overlay"></div>

    <div id="wrapper">

<?php require 'includes/topbar.php'; ?>
<?php require 'includes/leftbar_sr.php'; ?> 
        <!-- Main body part  -->
        <div id="main-content">

            <div class="container-fluid">
                <!-- Page header section  -->
                <div class="block-header">
                    <div class="row clearfix">
                        <div class="col-xl-6 col-md-5 col-sm-12">
                            <h1><img src="assets/images/flag/rs.png" width="20" alt="Srpski" > Menu content</h1>
                            <span> </span><br />
							<span> </span>
                        </div>
                        <div class="col-xl-6 col-md-7 col-sm-12 text-md-right">
                            <div class="d-flex align-items-center justify-content-between flex-wrap vivify pullUp delay-550">                        
                                <div class="ml-auto mb-3 mb-xl-0">
                                    <p class="text-muted mb-1"><?php echo date('l'); ?></p>
                                    <h5 class="mb-0"><?php echo date('d').'. '.date('m').'. '.date('Y'); ?></h5>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row clearfix">
                    <div class="col-12">
                        <nav class="navbar navbar-expand-lg navbar-light bg-light page_menu">
                            
                            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
                                <i class="fa fa-bars text-muted"></i>
                            </button>
                            <div class="collapse navbar-collapse" id="navbarNavDropdown">
                                <ul class="navbar-nav mr-auto">
									<li class="nav-item vivify swoopInTop delay-250 active">Menu content</li>
                                    
                                </ul>
                                <div class="ml-auto">
                                    <a href="add_content_sr.php" class="btn btn-success"><i class="fa fa-plus-square"></i> Add content</a>
                                </div>
                            </div>
                        </nav>
                    </div>


					<div class="col-12">

                        <div class="d-lg-flex justify-content-between">
                            <ul class="nav nav-tabs4 page-header-tab">
								<li class="nav-item"><a class="nav-link active show" data-toggle="tab" href="#content">Menu content</a></li>
                                <!--<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#godina">Godina</a></li>-->
                            </ul>
                        </div>
                        <div class="tab-content">
                            <div class="tab-pane active show" id="content">

								<div class="card">
									<div class="card-header">
                                        <span class="badge badge-success"></span>
                                    </div>
									<div class="card-body">
										
<?php

$status_content = "";
if(isset($_POST['new_content']) && $_POST['new_content']==1)
{ 
$cat =$_REQUEST['content_cat'];
$sub =$_REQUEST['content_sub'];
$subsub =$_REQUEST['content_subsub'];
$content =$_REQUEST['content'];
$price =$_REQUEST['content_price'];
$active =$_REQUEST['content_active'];
$ins_query_mc="insert into le_menu_content_sr (`content_cat`,`content_sub`,`content_subsub`,`content`,`content_price`,`content_active`) values ('$cat','$sub','$subsub','$content','$price','$active')";
mysqli_query($leld,$ins_query_mc) or die ( mysqli_error());
$status_content = "
<div class='sweet-overlay' tabindex='-1' style='opacity: 1.02; display: block;'></div>
<div class='sweet-alert showSweetAlert visible' data-custom-class='' data-has-cancel-button='false' data-has-confirm-button='true' data-allow-outside-click='false' data-has-done-function='false' data-animation='pop' data-timer='null' style='display: block; margin-top: -165px;'><div class='sa-icon sa-error' style='display: none;'>
      <span class='sa-x-mark'>
        <span class='sa-line sa-left'></span>
        <span class='sa-line sa-right'></span>
      </span>
    </div><div class='sa-icon sa-warning' style='display: none;'>
      <span class='sa-body'></span>
      <span class='sa-dot'></span>
    </div><div class='sa-icon sa-info' style='display: none;'></div><div class='sa-icon sa-success animate' style='display: block;'>
      <span class='sa-line sa-tip animateSuccessTip'></span>
      <span class='sa-line sa-long animateSuccessLong'></span>

      <div class='sa-placeholder'></div>
      <div class='sa-fix'></div>
    </div><div class='sa-icon sa-custom' style='display: none; background-image: url(&quot;assets/images/sm/avatar1.jpg&quot;); width: 80px; height: 80px;'></div><h4>Sadržaj menija dodat!</h4>
    <p style='display: block;'></p>
    <fieldset>
      <input type='text' tabindex='3' placeholder=''>
      <div class='sa-input-error'></div>
    </fieldset><div class='sa-error-container'>
      <div class='icon'>!</div>
      <p>Not valid!</p>
    </div><div class='sa-button-container'>
      <button class='cancel' tabindex='2' style='display: none; box-shadow: none;'>Cancel</button>
      <div class='sa-confirm-button-container'>
        <script>setTimeout(\"location.href = 'add_content.php';\",2000);</script>
		<div class='la-ball-fall'>
          <div></div>
          <div></div>
          <div></div>
        </div>
      </div>
    </div></div>
";
echo ''.$status_content.'';
}
?>
										<form action="" method="post" id="advanced-form" data-parsley-validate novalidate>
											<div class="form-group c_form_group">
												<label>Menu</label>
												<select name="content_cat" onChange="getaddsubmenu(this.value)" class="custom-select" id="inputGroupSelect01" required>
													<option selected disabled>--Izaberi--</option>
<?php
$query_menu_category = "SELECT * FROM le_menu_category_sr WHERE menu_cat_active = 'y'";
$menu_category = mysqli_query($leld,$query_menu_category);
$totalRows_menu_category = mysqli_num_rows($menu_category);
?>
<?php while($row_menu_category = mysqli_fetch_assoc($menu_category)) { ?>
													<option value="<?php echo $row_menu_category['menu_cat_id']?>"><?php echo $row_menu_category['menu_cat_name']?></option>
<?php } ?>
												</select>
											</div>
											<div id="submenu">
										
											</div>
											<div id="subsubmenu">
										
											</div>
											<div class="form-group c_form_group">
												<label>Sadržaj menija</label>
												<div class="input-group">
													<input type="text" name="content" class="form-control" required data-parsley-maxlength="255">
												</div>
											</div>
											<div class="form-group c_form_group">
												<label>Cena</label>
												<div class="input-group">
													<input type="numeric" name="content_price" class="form-control" data-parsley-maxlength="11">
												</div>
											</div>
											<button type="submit" class="btn btn-success">Dodaj</button>
											<input type="hidden" name="new_content" value="1" />
											<input name="content_active" type="hidden" value="y" />
										</form>
										
<nav>									
<ul class="pagination pagination-split">

</ul>
</nav>
										
									</div>
								</div>
							</div>
                            
                        </div>
                    </div>

                </div>
            </div>
        </div>
        
    </div>

</div>


<!-- Javascript -->
<script src="assets/bundles/libscripts.bundle.js"></script>    
<script src="assets/bundles/vendorscripts.bundle.js"></script>

<!-- Vedor js file and create bundle with grunt  --> 

<!-- Project core js file minify with grunt --> 
<script src="assets/bundles/mainscripts.bundle.js"></script>

<!-- Vedor js file and create bundle with grunt  --> 

<script src="assets/vendor/light-gallery/js/lightgallery-all.min.js"></script><!-- Light Gallery Plugin Js --> 
<script src="assets/vendor/light-gallery/js/mousewheel.min.js"></script><!-- Light Gallery Plugin Js -->
<script src="assets/vendor/bootstrap-multiselect/bootstrap-multiselect.js"></script>
<script src="assets/vendor/parsleyjs/js/parsley.min.js"></script>
<script src="assets/vendor/sweetalert/sweetalert.min.js"></script><!-- SweetAlert Plugin Js -->
<script src="assets/vendor/dropify/js/dropify.js"></script>
<script src="assets/vendor/jquery-steps/jquery.steps.js"></script>
<script src="assets/bundles/datatablescripts.bundle.js"></script>
<script src="assets/vendor/jquery-datatable/buttons/dataTables.buttons.min.js"></script>
<script src="assets/vendor/jquery-datatable/buttons/buttons.bootstrap4.min.js"></script>
<script src="assets/vendor/jquery-datatable/buttons/buttons.colVis.min.js"></script>
<script src="assets/vendor/jquery-datatable/buttons/buttons.html5.min.js"></script>
<script src="assets/vendor/jquery-datatable/buttons/buttons.print.min.js"></script>

<!-- Project core js file minify with grunt --> 
<script src="assets/bundles/mainscripts.bundle.js"></script>
<script src="../js/pages/medias/image-gallery.js"></script>
<script src="../js/pages/forms/dropify.js"></script>
<script src="../js/pages/forms/form-wizard.js"></script>
<script src="../js/pages/ui/dialogs.js"></script>
<script src="../js/pages/tables/jquery-datatable.js"></script>
<script src="../js/pages/forms/editors.js"></script>

<script>
    $(function() {
        // validation needs name of the element
        $('#food').multiselect();

        // initialize after multiselect
        $('#advanced-form').parsley();
    });
</script>
</body>
</html>
