<?php
  ob_start();
  session_start();
  require_once 'system/db.php';
  require_once 'pages/functions.php';
  require_once 'func.php';
  date_default_timezone_set('Europe/Istanbul');
  $dates = date("Y-m-d H:i:s");
?>
<!DOCTYPE html>
<html lang="<?php echo $getLangCheck['country_code']; ?>">
<head>
  <base href="<?php echo $generalSettingCheck['site_url']?>adminx/">
  <!-- Required meta tags -->
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
	<title>Management Panel</title>
	<!--favicon-->
	<link rel="icon" href="assets/images/favicon-32x32.png" type="image/png" />
	<!--plugins-->
	<link href="assets/plugins/simplebar/css/simplebar.css" rel="stylesheet" />
	<link href="assets/plugins/perfect-scrollbar/css/perfect-scrollbar.css" rel="stylesheet" />
	<link href="assets/plugins/metismenu/css/metisMenu.min.css" rel="stylesheet" />
  <link href="assets/plugins/select2/css/select2.min.css" rel="stylesheet" />
  <link href="assets/plugins/select2/css/select2-bootstrap4.css" rel="stylesheet" />
  <link href="assets/plugins/input-tags/css/tagsinput.css" rel="stylesheet" />
  <link rel="stylesheet" href="assets/css/dropzone.min.css">
  <!-- # fontawesome -->
  <link rel="stylesheet" href="assets/css/fontawesome-free-all.min.css">
  <!--Data Tables -->
  <link href="assets/plugins/datatable/css/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css">
  <link href="assets/plugins/datatable/css/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css">
  <!-- # summernote -->
  <link rel="stylesheet" href="assets/css/summernote-bs4.min.css">
	<!-- loader
	<link href="assets/css/pace.min.css" rel="stylesheet" />
	<script src="assets/js/pace.min.js"></script>-->
	<!-- Bootstrap CSS -->
	<link rel="stylesheet" href="assets/css/bootstrap.min.css" />
	<!-- Icons CSS -->
	<link rel="stylesheet" href="assets/css/icons.css" />
	<!-- App CSS -->
	<link rel="stylesheet" href="assets/css/app.css" />

</head>
<body class="bg-theme bg-theme1">
	<div class="wrapper">
    <div class="sidebar-wrapper" data-simplebar="true">
      <div class="sidebar-header">
				<div class="">
					<img src="assets/images/logo-icon.png" class="logo-icon-2" alt="" />
				</div>
				<div>
					<h4 class="logo-text">Nice Panel</h4>
				</div>
				<a href="javascript:;" class="toggle-btn ml-auto"> <i class="bx bx-menu"></i>
				</a>
			</div>
      <?php include('menu.php'); ?>
		</div>
    <header class="top-header">
      <nav class="navbar navbar-expand">
        <div class="left-topbar d-flex align-items-center">
					<a href="javascript:;" class="toggle-btn">	<i class="bx bx-menu"></i>
					</a>
				</div>
        <div class="right-topbar ml-auto">
          <ul class="navbar-nav">
            <li class="nav-item">
							<a target="_blank" class="nav-link position-relative" href="<?php echo $generalSettingCheck['site_url']; ?>">
                <i class="fas fa-eye vertical-align-middle"></i>
							</a>
						</li>
            <li class="nav-item dropdown dropdown-lg">
							<a class="nav-link dropdown-toggle dropdown-toggle-nocaret position-relative" href="javascript:;" data-toggle="dropdown">
                <span class="msg-count"><?php echo $contactRowCount; ?></span>
                <i class="fas fa-envelope vertical-align-middle"></i>
							</a>
							<div class="dropdown-menu dropdown-menu-right">
								<a href="javascript:;">
									<div class="msg-header">
										<p class="msg-header-subtitle"><?php echo $langArray['CONTACTBOX_TITLE']; ?></p>
									</div>
								</a>
								<div class="dashboard-social-list">
                  <?php
                    $allContactAsk->execute(array(
                      'status' => 0
                    ));
                    while ($allContactCheck=$allContactAsk->fetch(PDO::FETCH_ASSOC)){
                   ?>
									<a class="dropdown-item" href="index.php?page=mailBoxRead&log_id=<?php echo $allContactCheck['log_id'] ?>">
										<div class="media align-items-center">
											<div class="user-online">
												<img src="assets/images/favicon-32x32.png" class="msg-avatar" alt="user avatar">
											</div>
											<div class="media-body">
												<h6 class="msg-name">
                          <?php echo $allContactCheck['namesurname']; ?>
                          <span class="msg-time float-right"><?php echo addAgo($allContactCheck['dates']); ?></span>
                        </h6>
												<p class="msg-info"><?php echo $allContactCheck['subject']; ?></p>
											</div>
										</div>
									</a>
                <?php } ?>
								</div>
								<a href="mailBoxs">
									<div class="text-center msg-footer"><?php echo $langArray['LIST_TITLE']; ?></div>
								</a>
							</div>
						</li>
           <!-- <li class="nav-item dropdown dropdown-lg">
							<a class="nav-link dropdown-toggle dropdown-toggle-nocaret position-relative" href="javascript:;" data-toggle="dropdown">
                <span class="msg-count"><?php echo $orderProductCount; ?></span>
                <i class="fas fa-tags vertical-align-middle"></i>
							</a>
							<div class="dropdown-menu dropdown-menu-right">
								<a href="javascript:;">
									<div class="msg-header">
										<p class="msg-header-subtitle"><?php echo $langArray['PRODUCT_ORDER_TITLE']; ?></p>
									</div>
								</a>
								<div class="header-message-list">
                  <?php
                    $orderAsk1->execute(array(
                      'order_type' => 'order_product',
                      'status' => 0
                    ));
                    while ($orderProductCheck=$orderAsk1->fetch(PDO::FETCH_ASSOC)){
                   ?>
									<a class="dropdown-item" href="index.php?page=productOrderList&order_id=<?php echo $orderProductCheck["order_id"]; ?>">
										<div class="media align-items-center">
											<div class="user-online">
                        <img src="assets/images/favicon-32x32.png" class="msg-avatar" alt="user avatar">
											</div>
											<div class="media-body">
												<h6 class="msg-name">
                          <?php echo $orderProductCheck['name_surname']; ?>
                          <span class="msg-time float-right"><?php echo addAgo($orderProductCheck['dates']); ?></span>
                        </h6>
												<p class="msg-info"><?php echo $orderProductCheck['description']; ?></p>
											</div>
										</div>
									</a>
                <?php } ?>
								</div>
								<a href="productOrderList">
									<div class="text-center msg-footer"><?php echo $langArray['LIST_TITLE']; ?></div>
								</a>
							</div>
						</li>-->
						<li class="nav-item dropdown dropdown-lg">
							<a class="nav-link dropdown-toggle dropdown-toggle-nocaret position-relative" href="javascript:;" data-toggle="dropdown">
                <i class="fas fa-box-open vertical-align-middle"></i>
								<span class="msg-count"><?php echo $orderPacketCount; ?></span>
							</a>
							<div class="dropdown-menu dropdown-menu-right">
								<a href="javascript:;">
									<div class="msg-header">
										<p class="msg-header-subtitle"><?php echo $langArray['PACKET_TITLE']; ?></p>
									</div>
								</a>
								<div class="header-notifications-list">
                  <?php
                    $orderAsk1->execute(array(
                      'order_type' => 'order_packet',
                      'status' => 0
                    ));
                    while ($orderPacketCheck=$orderAsk1->fetch(PDO::FETCH_ASSOC)){
                   ?>
  									<a class="dropdown-item" href="index.php?page=packetOrderRead&order_id=<?php echo $orderPacketCheck["order_id"]; ?>">
  										<div class="media align-items-center">
  											<div class="notify bg-light-primary text-primary">
                          <i class="bx bx-group"></i>
  											</div>
  											<div class="media-body">
  												<h6 class="msg-name">
                            <?php echo $orderPacketCheck['name_surname']; ?>
                            <span class="msg-time float-right">
                              <?php echo addAgo($orderPacketCheck['dates']); ?>
                            </span>
                          </h6>
  												<p class="msg-info"><?php echo $orderPacketCheck['description']; ?></p>
  											</div>
  										</div>
  									</a>
                 <?php } ?>
								</div>
								<a href="packetOrderList">
									<div class="text-center msg-footer"><?php echo $langArray['LIST_TITLE']; ?></div>
								</a>
							</div>
						</li>
            <li class="nav-item dropdown dropdown-lg">
							<a class="nav-link dropdown-toggle dropdown-toggle-nocaret position-relative" href="javascript:;" data-toggle="dropdown">
                <i class="fas fa-flag-checkered vertical-align-middle"></i>
								<span class="msg-count"><?php echo $countOffer; ?></span>
							</a>
							<div class="dropdown-menu dropdown-menu-right">
								<a href="javascript:;">
									<div class="msg-header">
										<p class="msg-header-subtitle"><?php echo $langArray['OFFER_TITLE']; ?></p>
									</div>
								</a>
								<div class="header-notifications-list header-notifications-list1">
                  <?php
                    $statusOfferAsk->execute(array(
                      'status' => 0
                    ));
                    while ($offerCheck=$statusOfferAsk->fetch(PDO::FETCH_ASSOC)){
                   ?>
  									<a class="dropdown-item" href="index.php?page=offerEdit&offer_id=<?php echo $offerCheck["offer_id"]; ?>">
  										<div class="media align-items-center">
  											<div class="notify bg-light-primary text-primary">
                          <i class="bx bx-group"></i>
  											</div>
  											<div class="media-body">
  												<h6 class="msg-name">
                            <?php echo $offerCheck['offer_name']; ?>
                          </h6>
  												<p class="msg-info"><?php echo $offerCheck['offer_email']; ?></p>
  											</div>
  										</div>
  									</a>
                 <?php } ?>
								</div>
								<a href="offerList">
									<div class="text-center msg-footer"><?php echo $langArray['LIST_TITLE']; ?></div>
								</a>
							</div>
						</li>
            <li class="nav-item dropdown dropdown-language">
              <a class="nav-link dropdown-toggle dropdown-toggle-nocaret" href="javascript:;" data-toggle="dropdown">
                <div class="lang d-flex">
                  <div>
                    <i class="flag-icon flag-icon-<?php echo $getLangCheck['country_code']; ?>"></i>
                  </div>
                </div>
              </a>
              <div class="dropdown-menu dropdown-menu-right">
                <?php
                  while ($statusLangCheck=$statusLangAsk->fetch(PDO::FETCH_ASSOC)){
                    $langCodeAsk=$db->prepare("SELECT * FROM countries where alpha=:alpha");
                    $langCodeAsk->execute(array(
                      'alpha' => $statusLangCheck['country_code']
                    ));
                    $langCodeCheck=$langCodeAsk->fetch(PDO::FETCH_ASSOC);
                    $url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
                    $str = explode('?',$url);
                ?>
                <a class="dropdown-item" href="<?php echo $str[0]; ?>?lang=<?php echo $statusLangCheck['country_code']; ?>">
                  <i class="flag-icon flag-icon-<?php echo $statusLangCheck['country_code'] ?>"></i><span><?php echo $langCodeCheck['country'] ?></span>
                </a>
              <?php } ?>
              </div>
            </li>
          </ul>
        </div>
      </nav>
    </header>
      <div class="page-wrapper">
        <!--page-content-wrapper-->
        <div class="page-content-wrapper">
          <div class="page-content">
            <?php require('pages/breadcrumb.php'); ?>
