<?php
  include 'cookie.php';

  $linkHome = "'../dashboard'";

  /* Terméklista */
  $linkProductCatalog = "'products'";
  $linkItemCreator = "'itemcreator'";
  $linkMontlyStat = "'monthlystat'";

  /* Gyártás */
  $linkProduction = "'production'";
  $linkBoxing = "'boxing'";
  $linkProductionStat = "'productionstat'";

  /* Rendeléskezelés */
  $linkWarehouseOrders = "'wh_orders'";
  $linkWarehouseReturnGoods = "'return_goods'";
  $linkPricing = "'pricing'";

  /* Raktárak */
  $linkWarehouse = "'warehouse'";
  $linkWarehouseAdd = "'wh_add'";
  $linkWarehouseRemove = "'wh_remove'";


  /* Fiók kezelés */
  $linkProfile = "'profile'";
  $linkUserEditor = "'usereditor'";
  $linkPermEditor = "'permlist'";
  $linkLogOut = "'../managers/logout.php'";

  /* Indikátor */
  function MenuIndicator($name) {
    $current_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
    $parsed_url = parse_url($current_url);
    $path = $parsed_url['path'];
    $file_name = "'" . basename($path) . "'";

    if ($name == $file_name) {
      return '<div class="active"></div>';
    }
    return '';
  }

  /* Van e aktív fejlesztés */
  $ServerLocalIP = trim(shell_exec('hostname -I | cut -d" " -f1'));
  $sql = mysqli_query($conn,"SELECT param_value FROM system_params WHERE param_key = 'is_active_development'");
  if (mysqli_fetch_array($sql)[0] == '1') {
    $TextActiveDevelopment = '<p style="color: #FF4D00; display: inline-block;"><b>Aktív fejlesztés!</b> Hibák és esetleges leállások jelentkezhetnek!</p>';
  } else if ($ServerLocalIP != '192.168.15.10') {
    $TextActiveDevelopment = '<p style="color: green; display: inline-block;"><b>Teszt környezet</b> A jelenegi rendszer a teszt környezetben üzemel!</p>';
  } else {
    $TextActiveDevelopment = '';
  }

  $menuhtml = '<div class="top">
    <div style="position: absolute; left: 220px;">'.$TextActiveDevelopment.'</div>
    <span style="position: absolute; right: 10px; top: 25px; color: var(--panelcolor); opacity: 0.4;" id="TimeBeforeLogOutSpan"></span>
    <div class="title">
      <a href="#menu"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAABmJLR0QA/wD/AP+gvaeTAAAAhElEQVR4nO3awQnAMAwEQSv996y0EIPF4TDzNwjv99YCAAAAAAAA4K9q90F398Qhf1FVW3/6TB3CNwKECRAmQJgAYQKECQAAAAAAADDMLugwu6DLCBAmQJgAYQKECRAmAAAAAAAAwDC7oMPsgi4jQJgAYQKECRAmQJgAAAAAAAAAADDkBY73DC4/UsNcAAAAAElFTkSuQmCC"></a>
      <p>Kezelőfelület</p>
    </div>
    <div class="profile" onclick="window.location='.$linkProfile.';">
      <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAD/klEQVR4nO2Yb2gTZxzHb3u5F3bCXdUXTjuLvau6DhR14By+0Pln2kISROsrNy9VVEQRxW4+VyesL3y5DZQpDAfDf/hCU+9pNGtyTVuaf64ts7ZgQ6y2Kkn/LWnSNv2N59rcIv2bXLyLkB984Xjuud/z+eSeu4NQVK5ylatcJZdkZkoch/Lv2Hm6x8HTUYeZgRnST2VbSUfoa7MAvxU7z7ipbKnG40s3ec4tb50vvJwKpsHNL/lIb3aqns+vcFTkx1OCT4RnPNLhvIW6wdvNdHVa4MlbyczU6ALvOER/ZTcz42oFHGYGJJ4xaS/AM5YEQNtPLESl3TDSUAqvb22G9kurofn0J+A8uhicxxaDt7IAui6vhUG8DcaayyAqfQOPz69Iugu0VXsBM9NHFnedWQZxtwHAZ0wpo42l0Hh8SWIbBXUQoP8li7+6+WXK8IkErq2ffJjpIT0EntUfWRRP59dPJObcDVJFPhHo1EOgofVi0Ui68Il4KwtGHTzj0FzAzjNXu66si6sV6Pz58zjppYMAfeLVjc2q4MFnlN9apJem8OA1FQfvbukexF+rFgg/2gmkF3j2ctoJPDadJO/8kaYy1QJjzWUQc+4B0lM7Aa9hh1rwKfGYtmsn0FS+AHzGJxkUeEJ6aiagiGRIgNKrwGeIqBcwRHQUMDZmQKBBRwHDAdUCXsM+/QQAfQg+oyV9eOM90kM3AVmiZf9C8BncaQi4wFf6MZUNBW5THviMNSnAW3R5bc5WANQHPffXw5h75q8zOUfmkLlUNlbn3a3Q/kch9Fo2Qrh+uwxMQo57LRug/XohkDlUNlURerCcQ7XnWCQ+DHZ7oePWF/DP7wXThpwjc1gBW8k13I/3l+kGzlY92MUKop1D4jgnYCAJDQzBUN8L8Fu/mwJPxsg5Micxn0Pi+ESP2p2aga9ENZ9xCNsUiKR0vAxCOByWE/LXwTOLQQ45Tox3vAhOuY6TZbCt6IJ1zTuFLxbEclbA4WkBBAy3XX4FtKk7AofrovCtLQZSYFgZv+3qml5AIBGHOSQefCfwnCBWzrzwRMp/a1JAr7ZFYcOdETm//h1VxsmcufqwSDybUfjiqlpT8l6fLb2hQRk0EIooAs9DEXmsJzgw5/Xc5LNRhMT9GYH/tNqaxwpi37wWFjD8Ynsqwz7yDysCNv/EFiLn5tuHQ2J/CfpL/ZeaReL5eS86mdehAbjc8v8WutIShTd9g7AqxT4cwt9nQAC3pSpgvu6CU/UxReC0MwbH/vSkBi/ID3WragEO4WjqC2MQ7G8UAXKcTg9OEIfVC6S18ER+kPrlqOlBqS1WwM/VAKgJi3BA/R2owjv0kGARDhQjUbu/WnKVK+r9rP8Agj27s/V2DZ4AAAAASUVORK5CYII=">
      <div class="userNameDiv" id="userNameDiv"><p id="userNameP">'.$userName.'</p></div>
    </div>
  </div>
  <div class="menu scrollable">
    <div class="menubtn" onclick="window.location='.$linkHome.';">
      '.MenuIndicator("'dashboard'").'
      <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAACD0lEQVR4nO2YO0/CUBTH+zVcnDSmoMIgXKKDq8bEODkZVwejnwF8JzopuukGU0siOgjloZRJjRMaHHRQVyXRAQSTYw4+Ath7C1hp1ftP/gkBWs7vvHqDIHBxcXFxcb3LLZdG3HLxjshFsKSl4i0JlYYFmspfMDtIWRfihg5gdnByfeYApCIbqfgEXB/1Q1iZgem9JHjkZ2tXoC+QA4f/HOzLaRB9MXhJt1X5NDEG47tZ3fvsRBYgr7Z/uR6N729HFo0FcEsFcKxnQPRGQfRGPq0VQE7tgqk9lQnwpHZoXvvhR7XTOAAMvmf1uCpwFsAHBKsSmOE8qwIHS8YB9G5kNINnAaDPkqM/MhNCIwDY87VtUy8AGgfbVACH/5wafD0AYWXWXAA7bptvAFwdDmgG4dzMguhTtO/rU8CxlTUGwDYXYwKc7A8yAZLxSWjmvra5uFEAceYPNRsEZlhkVMC5edmaFmLZvpI2vP9Jw0O8wR5ilp3+C/MBXIEc2BhrlNo+3ii4gjnzAUi5CvQHGc24fllBtGwLEbRUgG7KUULLPWsnQHSewC3bQqQCAueB1U742Vvm9Y8PLdtCpHYmgnicvihvGMwiGl/jwP5UzxMjAaxggQPIvALAW0hLtKw8pETdYzPNTR8E5xPGDfF9yva7AYjFLPxdAOm3/7kbKg1bGkIq3njk0hAVgIuLi4vr3+kV2KuTy9D28uEAAAAASUVORK5CYII=">
      <p>Áttekintés</p>
    </div>';

    /* Terméklista */

    $isProduct = false;
    if (UserHasPerm('pr_parameters_read') || UserHasPerm('pr_parameters_edit') || UserHasPerm("edit_item_introduction_basic_data")) {
      $isProduct = true;
      $menuhtml .= '
      <p class="category">Terméklista</p>
      <div class="menubtn" onclick="window.location='.$linkProductCatalog.';">
        '.MenuIndicator($linkProductCatalog).'
        <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAACeUlEQVR4nO2ZTU8TQRjHe5JXRZTW4ks8+wVYz3AAPgd60+/gga+iB+ma4A2LQCkUiiCWlmINHqTefAMbjCwyfzM7O7PD7jZhmymG+DzJLyE9/X4P02m2TSRoaGiazpB9tGzZDtrBvSczLvprw1P7mHyWxUplF49zv2FlnLr14ng80eq0S75ZgGU7GJnaR61Ww8cvDfFaxtm7UAGW7bgBjYYXYDugAIv+Aw4doZaG3sQ23UKga9SiDzLn330S48NtnJka5xbwXnIT2PGocgaBbY9KWgWgfEOw5VFKnVNAUHhHFx4MCbuU00pYBZRSgnecJLCZbFMAl40SrgaF02Fhud0tT7aU8gM2hTTeDgg2BgwG6MKfHwK/isDJT+DkADgsAvUHQH1C/P3nQHC4CnyaUMfB33BSbZijAja49HVg3cdcgL7huBMQ1jfMhVXAm2s+a5x+gwH6+Y07AWG1YU9WBaz1A0UBW73qYi5AvyHiTkBYblcKywDGpVc4fWAFgbkA/YaIO1K4GN4wF1YBhT6w5SuCJYG5AP38xhwlG7FhLqsCli6D5TUWew0G6Oc3bkBA2N+wEFUBi72CHKcHbKHHYIB+Q3x/CVTHgfW7Lmx7DPg27cIqo2DFO4LyKPB1OiQstytRAQtCms13C+a6DQZE3BDh4xC94VPCudMb5qiAOS7dBfbaY7bLXECz86u/4ZoL+7LBDXNhFTDLpTvBspIOgwFRwvkzCM+Hhf0Nd7qogFcdPjOXXOh7ITn0UG/TQz3ood6ih3qHvl5PtDp0jdp0jeLCXaMjJn/kG8oc5c8zYPj5D0w+zaJQ2cUj8TPr3n37eKzlABqa/2D+AmoXqZXlipnIAAAAAElFTkSuQmCC" alt="moleskine">
        <p>Termékkatalógus</p>
      </div>';
    }

    if (UserHasPerm('edit_item_introduction_basic_data') || UserHasPerm('edit_item_introduction_tools_send') || UserHasPerm('edit_item_introduction_testing') || UserHasPerm('edit_item_introduction_final') || UserHasPerm('read_item_introduction')) {
      if (!$isProduct) { $isProduct = true; $menuhtml .= '<p class="category">Terméklista</p>'; }
      $menuhtml .= '
      <div class="menubtn" onclick="window.location='.$linkItemCreator.';">
      '.MenuIndicator($linkItemCreator).'
        <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMA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zdj+aUmLOtpwtKLjVja3QBRD4HL1yV8BLz+I/3XWoSJOyJ88pUmKviSC/VYct6M/HNm5J81YfHndR0Ci2Xe9AJm7UhD48Ic6Yu7Xng1B7yZAl8WBF7PBseiz4xYdMaI3K7atggC4u/0SO0y+YsYV76RYUUvf/DFNHheVy3yTtcg9xSB3E69bhoBr6/TPVYxnvQVQnLNTMEvo+LSiKUXG/zw+efNeD7lxrMpt9/1vDNscAI5Jw3IOq7/XdBLLAgV8Bo7/dWvIlz8WjoteP45ExafrQMzFHhXDXJPExR8TqcBOSerkX1Cj6zjVcg8XkWEEcAzLhFdD3wCBB6jNVSnb7mqDTrQfD94IOfM5NKuB4PrkXWsCplHdcg8ou0OETAbR8r+BGBeUtK6Gk/7VkFyqYbVLKYg8EW048ywwbODwbHwsAYZh9RjIQI8/YrxeI6U+wlAWn3wpLUQE7c+wHvnTdSBssGfT7kRbZ5OvqTBtVh4SIOMg2qk7Ve6QyPkkCs89rLxeOPCuO4F920BJm6+j3fP1XEcr8WzqZe8BDDgGQdUSN+vROpe5d+CRE/eGeMjbiXmUFExIPtENRUVZjKP6IIc94GrkLZPibS9lUhtV7gSL6CrtidQiYYgcG/Gs47q/AK44OkMeIcCqe0VELaVX0i4gOxTRA3T5dlB4FWU45mHtX4BGQfUYcAVELZVQLinHMJWuSHhAgSdm+dnn9Q/Zro8i2kWVlS8effudOApu8uQ0ir/TWAJ85AlYjKP6fShlaih4NPpA03bV+mHF/rigpQ9ZRR8cqscSTul2jcC7xdxWNPhBV8YC/guOZJbZUjaId0jeONjsczLOKhuD4CHHChS6Lj4wXdK8dZ2aVvEz+lEj3CvSpfaUfk4GvjbO6SPF2wrebOxmXY6P5wvbK8gkneXdyfvlruSd8ndya0yd9IOqStpe2l30vZSg/dvwv3vf1t9PzQz/v8bAAAAAElFTkSuQmCC" alt="add-ticket">
        <p>Új Termék</p>
      </div>';
    }

    if (UserHasPerm('statistics_menu')) {
      if (!$isProduct) { $isProduct = true; $menuhtml .= '<p class="category">Terméklista</p>'; }
      $menuhtml .= '
      <div class="menubtn" onclick="window.location='.$linkMontlyStat.';">
      '.MenuIndicator($linkMontlyStat).'
        <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAACg0lEQVR4nO2ZPU/bQBjH8wWQmErCQDKUfoV0A6ntUIbede/Uj9AXXipQGSt2RKVK7ZB26oxCi7r1A4QRQtQQ+W6lYogDhfyr56iRe7Extu9iI/mRniGyL7nf4+d+d3JKpSKKKKKIXMZTgUdcos0lkGUyge4TBw9jA3CJo6wnzz0IiYMkAMgRgFsAcMs51+pjpiFQbQjMt1w7AGvHwMaJnZz9LFD50FNJENpvD4wA2Jr8xglQ+9QzDCAwDAMIa4Ok15kzxNT6T0xtHqL28Qjze+7tAqhvdzHx/CtmFpt493sYNDa/AIyqv7ijAJ796AY/IYnT3ALU/1X/zqvL6hsDYAIXtgGYr/r3ty+rnxkAeXz2i1CpezxsfN1XfYIZG0CUx+82nEhtUrtUl5r/9X4ogMCZdQC/x6e3Olhz3Gvvp0lP+MxjA+A8icfLm4eYfLGLyso3LBwMAser+183r3o/8vttA/g9TpWvvPmuPpeXdvB43x0Zr/c+zxIgyOML7UEghNf7fvPwm0hC4I81gDCPB0H4e1+vPjcNQIPSelyHWO31UVsOrj7PAoAmQZOhBRnmcVrItKAnX+6ivNVRC50WvF59Pk4Ar5e9auoe13NdDjD9vnOlWTpxXnc/H13E58YBvF6mzUj3eFDS5uYB0KZnHYAJnIUB6L0f2QIS6nhBx4x7dNQYPe8jQqNmAeJ6PO11ZhIgkcfTA1wYA0jk8UwAJE71L/KbJ5bH8wAw1+qrE6fy+NuYHs8DQLUhbuzxtMlHN7KhUYAoj6fJ1WNDAPQqQ/d41Xv1F+JxaykMAGSa4rYDSCAJQDtHT+BXbADm4AH9vZP15JnEPs0lNkARRRRRRGkc8RfqdxZO+/ApvQAAAABJRU5ErkJggg==" alt="graph">
        <p>Statisztika</p>
      </div>';
    }

    /* Gyártás */

    $isProduction = false;
    if (UserHasPerm('production_classic') || UserHasPerm('production_injmold') || UserHasPerm("production_sporty")) {
      $isProduction = true;
      $menuhtml .= '
      <p class="category">Gyártás</p>
      <div class="menubtn" onclick="window.location='.$linkProduction.';">
      '.MenuIndicator($linkProduction).'
        <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAFDElEQVR4nO2Ya0xbZRzGj5q4zBhvCX41MWRRNt2WnlNR5qZzujF2A90XE43JHLs5GeMyLoW29AqMgnNgDyYmJvpBjR+ck10Y7fuWrQM2MEZjjJ/McCYaHe/bcr895m0LK4yVFlxXTJ/k+dKc9/T3O/9zayUpmWSSkZxO5yVVVRFqu7TUot6ED1T6vwoohFsVyvsVyi1SIgucyXkcbW+ngOxJAd2bApqbAk9uCjJcf0GhHAphWNfOHpWWmsCG1mtBAcqh8fS9IS25U4iyb6YEZMI+juU70PP6TnyfQ9Cd04/u7P6J7mw3urN3/CcCTqdzKBoBmXL7tADlvdHuf6Inxz7Zk43JbtFdwV7diQnRKzusixZQVfVNVVUH5p8Af2dKQFTr8aXNt2/07NopYIPAOwQwJq5sx0TXNox3ZWG8cyvGOjO3LVqiubl5pdPp7FJV9dTtttG6eXq4gMbD8+fb7/iV7SQInIXxrq0Y78zEWMcWjHVsxtjl1zB6+VWMeDe5pHhktbvvkXABmfCz860Z68z0zwD2bsKo9xWMXtqIkUsvY+TiSxhu3+CT4hWFsD9uXgdsKN2L5ZG2H/Fu8gvgEQF8cQp4PYbbX8SwZx2GPBkYJC/wuAnIlLvCp6BQtjmiwMX17gCwJwRMMzBEn8cgScegW4tBl4IBl6YtbgIK5Y0zTiPKP4+0/TDJ2D5EBPBzAeABl4yBNg0GLqxF/4U16G99Frx1VVb8BNzs8MwJBGqItGagba0lCLsa/vPPwH9+Ffzn0uA7+zT4mRVmKZ5R2v0rFcJGZ0vIhOdFWsfPrtzGzzzl8rWs8POWVB8/ndrGTz8ZvyMfHplw0y1TIGxSS317pKWQtJ9wv0LZj7dMgbLxhHpHihQNZVoBPMckJhTKW7WE7RaiUiJHIax2jgs6/Lq4oVCuKu6+NVIiJt2L5TJlv0aSCJtMh0xYrrbj74ekRIpCfetDp838EsGp/CNTXigB90qJEvEwi1bg5kT4V6ktWCYlQmTKPo1ZIPgU/yIhJiETfmEhAkqwjYlwN/plEQJQCC+4uwKU+xcnwCZlN3/rrsBrWm88vADo326ZGmEjWtq3Me4Cstu/KuaLl/Bz6V72mHg2zPqcx/2hp7jZlgUIfCbWprn/fFC8dsyaxPW1bTeeiJuAeANdwDnvmFqf2oJlCmVfz7y9sp/FhOIiIBOmj/3+z0rD97H7S9ynUPbJLMkOzdXrD9x5AcqbYxWY83cDcI9MWd3MbdkpIXdHBRTKvlvANXDbvxQVyg2zZL+9owIy4T/EPAE3T4+4T8oOKZQHXhBlwmP/z8juaMyyNzT9bm/4CNHWVt8UqNXRBIujEZa6RpjrTsJ8/CRMxz9EVa3oCRhrTsBQ/UGgensDKkVt9agQtTqgszpQbqkLtMxch1LTcdHeYmNtZtQCtvqm3ikY6zwwxpoQTHVDEMjWEIKpD8DoLI5pmDJzAAYlplqUVNXimLEGxaKGahSJ6u0o1NtRUClqw9EKG/IrrMjXWZGns1yLWsBQ3dA7++jcDqZ0CiYMKAhTHYApDIM5GoI5orPgSLkFeeVm5JWZ8X6ZCYdLTThcUoX3Sqpw6JioEQeLjThQbMCBIgP2FemjFxDjOmas6Q0/OoXTR8eGgjCY/GkYSwjGHIQpNQVggkBBmIMhmP1Feuwv1GNfYSX2FVQit6ACe4+K6vBu/hw9oru2J798S9QCySSTTDJSvPIv7UjuaOvpQHkAAAAASUVORK5CYII=" alt="construction-worker">
        <p>Termékgyártás</p>
      </div>';
    }

    if (UserHasPerm('production_boxing')) {
      if (!$isProduction) { $isProduction = true; $menuhtml .= '<p class="category">Gyártás</p>'; }
      $menuhtml .= '
      <div class="menubtn" onclick="window.location='.$linkBoxing.';">
      '.MenuIndicator($linkBoxing).'
        <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAEZklEQVR4nO2YX0wcRRzHR4ymYnzQ2IcmPpgYk4amcu3OHtRSEJE/QkGgRawasVJj1ERNjDHRRF8aTXzR1AcTX/re4IO1QfoHduaOu9v7w0FbKGljUo0W00SXmT3+3MHtfs0dAgcc3BEuzZLwSebldmbz/ezOzP7mCNlhB+cCrWsXxlseIduNhF5Xmgw1DSQjzUl7qBUYOnYTw8dfI9uBxGCVK+GvMef1Bliho7AiL8EeagOix1LtA+J04p6KgcTgc5jzv4BksAFWuBn2osRw+wwiJx4nTgXnleJpVpaMe44g4avGXKAWyeCLyxLRdiDacZw4FXFh/6PT/Qpm2SHEvSmJ5zEfqEMy2Agr3IL0eoi2vUGczNSlZ36bHqCY5c8i7q3EXEpCr0cy1AQr0gJEW0qIk5EXS7qmrpRiRlMxyw8jMViFOX9NWsIKNvWQ7UCsr+Tj2BVXfEZzY9aTkkgv6h6M1D5Mtgtmr2v3zOUDnbNa2cmE9/A+4lQoE6rKRS9l0lS5nFS5+MntMZ09zxehTLaoXMRVLrGqxVRNUOJkjvCpPZSLZJbw6UaZ/IsARcSpqEz2rxd+SYLLj4gToUy+lSv8/wJ/KhE8sDgO429/i7FuGzdOAmNdwOjrgPAD8YmFdrUdGGkFhpuB4SZY0Xq94OHLtMknKZMyH4GFqSTeWxK40a2vCH/9VUD4lgUywtvRBthDdUBEWXoAWwcookzwfMOnGxMTSuRO8YLAm/qK8Nc7gWsda578Yng7UlNYAcrlJ5sKv7ygz7i9Rml87FRwM+HtSHXhBFJ7O+ViNve8F0mFCZbtWjn7135lcByf65dxNnQWPaEzmBo5sW54O1xZGIGSUTxImfwjzzn/WblfPKbm2b/JexuxaEfW8HaoojACKhODec53X8c53J8aU8bk0yoX4/mMGw2/nzW8HTy0dQFFM/eqTNh5BIkp/eKpFYOB+yibPKAy8TJl8sOvAucnvgz8ind9Oho9v6PKcxdf+C4gOdSQNbwdLNu6QP4L1zyV61642qZvtGDtVeFtXS2IwOnc4cXP+dwLw636ZsLbgYOFEBCdOcIjNd/zEoge1TcT3va7ti6wsAOJmzkW7zf5CTSdtobqDStSa1jhGsMKVxtWqNKwQhWGFSw3rKDbsHRqWIGDhuV3GZZv/yVSCMo0s4J6xPwGAnOOPwOo3tg+lQljg/3/dmrXIU6XoEzcXU9CGRDvEKejaOZeysXf2QTcLPYDcTxAEeXCk3UaeeWPxOmoTHy67mL2iO+Ik6ELZUFig29CL3EqVRp2qVxcy1FK3yJORWXy+zWBPbJP5eZkhsB85hnYMbi5qFtdkVIm+9JvhcmezN/zLSvuGS6PuXv13k+ZvJgKn7ru5mb3im8Bk43ESah85fEwM3wKhU/tyXw7jvsviGacgykX3nI/HlrTRxO3MiQLU4AVCsrk16lijTLJlQiKs/bh8tyypPkLcRzYuEhza/88kd5imbijaGbFvQu2ww47/AeJmFhkVItJWQAAAABJRU5ErkJggg==" alt="manual-handling">
        <p>Termékdobozolás</p>
      </div>';
    }

    if (UserHasPerm('production_statistics')) {
      if (!$isProduction) { $isProduction = true; $menuhtml .= '<p class="category">Gyártás</p>'; }
      $menuhtml .= '
      <div class="menubtn" onclick="window.location='.$linkProductionStat.';">
      '.MenuIndicator($linkProductionStat).'
        <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAADTUlEQVR4nO2ZXWvTUBiAQ1JhQ+cPcLALvRYcE+d+hGtRvBG03R8w0V042C46ryZ+MARhooJ40esWJlutboNNknZDtHNJmg/X7WZsbWoi7NYjpx8zXZMmJzl1rfSF9/b0eXLevHnPKUF0oxvd+P8jwKQvkwy7STFciWS4e638Le5a+Co3Gt5Nj4azmetj530veOouNwTBKYYDMAP3N0BvNJ8kWhBcKDyUDkZK6WAEwIQiG6E7F7DC980UwNmnv0Dv9C5Wie3t7RFxIZVMh8bK8EcSwciOp51ogB+H8Adl+DOPCmUZiuFmcMDLsjyiqqqhqioQFz+ucKGx33USqDsBa56iWb0GD7NnSirDwx2owlfLaWfeL7yiKIaiKKCWwkJq5fhOpIORb64XJWn2uxneLGGG/1tO+fe44JVqiqnlz3USo+G864UpmtOsBJruCM1GUeFlWTZkWQZ2aZIwYHdyvThslU4CVjvitpwKS8TQ3trgVyknapIkgWa5Nb+YRII/kqDZB24kULsThC9+IkraEgH2Vy+qOVHQcrkcsEpRFHVJktDhUSRQupMZvpb7NhK+4d1K2Hen+o+dFbxmkhAFXhNFEYIDQRAMnuf9w6NIWHenSjk1g9dMEgK/pfE8jxferYTdjtx88vCdtkQYzeC1au6tXvrC89kR7PBeJCD8YPQtUBf7HMG1ShrFZQL/k/cq0ZbwbiXaGt5JoiPg7SQ6Cv64BAp8/sPpcnci2iVuPJ5+jgJ/Zfp1S092SOHmI2UF36qTXcvhbcaPGaJT4O1H8XyyY+C9juLtBz/euosC3/Cwz996NvUCxyh+IvC1j5TfUfxE4f2O4hSOcvIL70UigKuccMGjSlA4yumwuNtfXO3XcQ9m8P7IEX68sTsh34obhnFbP9gE2toA9qnSSaLHojvByzYkAV3X3+i6DhwkPI/EbiQCNXiGA/D/CVSBH2UBewnf8zzlopwqT5/V4YWz64Xj8fjw+vp6Bd5aAtthhHR6sSE8zQ4jLRqLxV5NTk6CTCbTIFFcGyjhPkmRdhJe4GHMzc3JExMTwCShwncCvtiHhZ1zOOFtJbzCw5idnf0JJWKx2MtEIvHPzq1k5Va8RNJcFqnmu9GNbhAdG38AQsYOuBigmlUAAAAASUVORK5CYII=" alt="design">
        <p>Gyártástervező</p>
      </div>';
    }

    /* Rendeléskezelés */
    $isOrders = false;
    if (UserHasPerm('removal_from_warehouse') || UserHasPerm('warehouse_reservation') || UserHasPerm('warehouse_reservation_order')) {
      if (!$isOrders) { $isOrders = true; $menuhtml .= '<p class="category">Rendeléskezelés</p>'; }
      $menuhtml .= '
      <div class="menubtn" onclick="window.location='.$linkWarehouseOrders.';">
      '.MenuIndicator($linkWarehouseOrders).'
        <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF+ElEQVR4nO2YeWwUZRjGp4hIidcfRmJijEajQi+0IG25CqVAW662bGm7yx60LEqiiFztbgMiqCCIRzQiRoNHiCliuwtGIqQF2pntMdvu7sw3W1uVUBHFA4gEUrX7PWZmdnvtlpLYIa3pk7x/zPwxeX7P977ffDMMM6IRjej/q/JycczBKn5qxWlvWkV1893McNHh0941FTVilYOVrjo5CUqx5JrDJeUwQ13lXHu0kyOdsmkHS6iTk0QHJ50IQlwu57+/ixnqcrIkzcmSpU6+5Z7ue9JxFUoqYIajnKxUogBw5F1mOMrBtUwLAgjMcFS5KI6Rh1qZix6tNazk5EiVsgq1ZAkzHOVgyTZ1WyV7BvvZ4LPvA78oCWCiGK1UyZG56hxIDf/1WfDoHoI31wRv9ofwLGlF8yKgOQtwZ1gYreTk+XFOVvrLwUn/VNb677hhs0AULlTMx69fHcDF021o23Qe3lzAmw14lgAe2fxC0KZMBNwLyjUDUCA44pJX4Qjrn9+/Yd0tIMYYtNk34JLrHK5+F0DHeXTVT/sBbw7gWQp4Fivm0ZwJ2rQAAfe8n7UFYKVdwRfaji7Dom4MWqzT4bfaIBV/DWL5E8QMSBbg2tlu46H6/Zvu9JvV1qFNGaBN80Hd6UB92qOaAThYaWHwfHRKMQ8mCi2rRfhXA/5VgFQEEAtATIC4ArhUA1w7A1w8CZzbB7RuBHy6XunTJjV96p4H6p4L8HOKNQOQz0LyWcnBkY7q6jNjFQi/9WKXeWkllPSJERANACkGhALAlwf4lkVonSw1fbeaPuXTEOBTP2a0lIOTPPIqVLJkpgIgrXLCXxxuXtQHzS9XU+85uGGtM09Jn/JzEGhM/UFTACcrva20kYvYFQB/8UY1/R6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LpdNEGo6U2knm90fKJ3GbMUJfJZBqrN1lKDEZLs8Fo/kVvMnN6s3nlsDA/ohGNiBkS+hfJJlDyRMsDFAAAAABJRU5ErkJggg==" alt="handcart">
        <p>Rendelések</p>
      </div>';
    }

    if (UserHasPerm('return_goods')) {
      if (!$isOrders) { $isOrders = true; $menuhtml .= '<p class="category">Rendeléskezelés</p>'; }
      $menuhtml .= '
      <div class="menubtn" onclick="window.location='.$linkWarehouseReturnGoods.';">
      '.MenuIndicator($linkWarehouseReturnGoods).'
        <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAFCUlEQVR4nO2YfUwTdxjHzxYL4khmgjNbpjGLCVYY4GS6mbpyN0JiNhezyLI5wkuyLYuJ21yySGk3Z3xjGsUFh7q4THqMJWRTqUqWMYeVXmXMgn25H4WWogIKfYFiNo3tdc9yd6Uw6ZK2V3kxfJNPcrk/nt/zuefJ74/DsLnMZS6PNNCJLWfsIgtjn2eBXmw5NpsCPdgyxirqCXSLgIXpFt2ELuy5uB6y5OSN15accPSnVjn6FlXaN8arLliwZQwS9wSsYuARQaBLBIw1zhJPHe/tS61ywJOVdlh+tBs0FO3QUOirc7rOFEHN0+KeAC2GAJpAJw9jFcdPIrXK0cc2n3LQBkuPWEGjRzwUrWtu7k2KpXm/WdzDmBOAw8IToFnEPEgMDIqTxKJK+8aUg7a+5P3WW8l7rRs1evSCRo/srMR5HXo/2nr+6wndjHE+cJgSxnlIiEfchT2KnKPQ2/wUUFPUAtfEBNMhKQhxfT5wcFKsjLhgDL9ZjD8SgZ+16OngGnkBYJ6QWkz7fGA6xsGmKm/UDTOb6kYgr3bURqi9OlztPU+QXjVOjlYQ5OjHuHq4iFAPb8qrGZbhpz3peXWuZ8IKXJMAYwjSLpk6ga317kGCvAs8o2HwhmHkPqEeuY2rR2hCPaLbcPxGo79NAv4/g1yTgPxU7+a8H4ZleN3/S8cl750Z1EYvwEmE2FBtB/8fieO0JcKGahsQtcNBPECQnns46b5FkO4OnPQ0EbXuOrzWVYWTri9x0r0dJ53v4KQ7/9U65+r8Hz1Ld+0CUUQC284O7Y2LwNUk8F9N5GkNI1AbDncYXDykqz4iga3VnWty93VD/mF7YO2BXsO6Qzep9Uf7tbJvBptlJ4e08lMuSv69x0CcHrHiau8ATnr/DitAJfHoeYQK4LXO5giXCOatVdGBbAWCrBA0TzlP5kNklaP72V+godW7rfacfTZTtrK13deyAHwtSeDX8bxUaW7PrXGbctUeO066h6IWIJ3HIhTAsPz9yBmNAMvzHBYO6Sct4NMu4LnCI93RAhlKC2QozZDOorLcy9yNBrL2dlnXVHQbXjzsoNZ9fUP7cnXfZdm3A9pXvrtDyU8PGogapxUnnQNEzeCHEQtsPkTrBAs0J4PvMssCjkkCyv+yagzVGCYOaZA0pTk3YoEtR+gKwQKXksH3+zhCBVYo2hdHLIDvMa8XLNC0EHy/BbkkUEBpcmHRZNUui2SNkv5HiMCDXxeO07RQ4ASMkd5AE6eAPLEKrNpBgefCYnjwyxMc7guLQfopJWSFjkUtIN9tuRirQMZOA2xS1cBH+/dwvK6qgfQyQ8wCKz83botaYLXCsj1WAU5CYYKMMiOkK4yQXm4KNh+rgEketUDmTotMiEBIJNR47AIrormBxpL2WWdKVhkdmG6BlUrTUNTNh6agQLbpFpDGcgNNEKiffgHTsdgFypBiugVWxnIDjSVbgeTTLZBWbsqJWaC+xbLsgxPofo5q6gWkKtNfUpXxACYkDXr6J/YvRYMeXWxsNT6LzbZo9PRdVmBWNv9YCDRQ9BluhSjUeLbNvBSbbTmn60xroJAn9ON3immgUItgCXZ9NHpU30DRo1MuoEdXsHjl3eLSisLiUpgI+26m1p2UwuKS22zxN7e8xcEdVFR6B5uhdSelsKhkYNJBxaX92AytG9GoC4tKDszUupNSUFAg4Q5jv1hRyQD7zL7DZmjduczlcc+/aqqxdF1QA2IAAAAASUVORK5CYII=" alt="return-purchase">
        <p>Visszáru</p>
      </div>';
    }

    if (UserHasPerm('manage_pricing')) {
      if (!$isOrders) { $isOrders = true; $menuhtml .= '<p class="category">Rendeléskezelés</p>'; }
      $menuhtml .= '
      <div class="menubtn" onclick="window.location='.$linkPricing.';">
      '.MenuIndicator($linkPricing).'
        <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAD0UlEQVR4nO2W609TdxyHT9vTm3FLeKHxFpWLF6D8A3vnS/+AvTARpEK5tFZoy4tlyeKrxSzqMNFp3KwxXpAWyq2czoFYrgICe7HCqq5xBKX3V0Zjlsg+5pzfOb2gxlZaTpv0kzyv+zwn39MciiqssMIK+2CApIoJ6zRMZLGSibzTMFFUDkZQ6SRUDLCEUd5PONzH0xt6e9ARnDrUHThCibYzkGpckd+qXFGw4mnI41AP4aAjuCZOREbkQ2wADnQHpvJDvieIkpvPccDuT5APoszmh7ra9lp93DamOn7vmxyVD6GobQTq2m5sbXSitGOFk+foCkJdYydUd77LXsQGzqasYwWq2h6oah1Q1zqw++JfMfkyewDqmq5YhKrGNpN7N+8I4uuWIai0PdhS34/iW8sxeS7gRDfUJ7oINfb/cvKFLbOvYs8VL0rurCTJl9oC3GmRCBKSOXlAomGiVzLzbxNMOhtBnkU4LSEkr+RLOwPcaSW+I3klX9Lph0rby0NC8kq+5J4fqpN9CRG9yCv54g42oJ9E8CF5JV/c4Yeyjg0Q6IPI3zbpye+78xLKugEeEpE3T37/3VXsvuaDst4JZZ0zFpKevEhPfv/dVY6iH6ahrB/kISEp+1e5oiYx5bef80DZwECpYxIiBtMIYCJLosmf90DR8DsUDS4odC4SoWOgqHf+m3KAhom+Ek2+8Q8+gI+Ih7SnHjAYmdx8+UUoGodIQON9ghCic3kovXtrygHlTPhopTO8tnnyS5A3DUPRNARFExsgwEV4KK1rG5XuKgZC2oqB8FrW5S8sQd78APLmYS5CzkXwIQ33v0w+MaK8L/R/1uR//hty/UM+gI/gQ+imIe8WvXsHtdEV337xffbk3SRAP0LgQ+jmYQ9l3MCTX79d13zXMyrf7gVtGAVtcIM2sAECI6D1DzIrL2znVZ81Y/KnRuMY3LEQunnES2XibD61HVd91o3JPwFtHAdtHAN9aiwpRKZ/mF35WMQv/1i/RH5b+xPITk+ANk7wEfEQmWF0c+TjET5rWvIXn0J2epJnIilEZhzfXPnEiJTlW6biJIWMiyMvbPsln/Wz8q3TkLU+gqzl0bqQCXHlYxGXn974uPwzSE0zkLayTK8LmfRS+lnx5YUV/eQ9u/PXZey9/QK7rMv46sdFSC2zkJpYZpJDWqa9VFsOycdmWdBKzY/XpJY5SM2PE0gIaZ3JUXlhlgWtxDxHItaHmHJdXphloVpinn8jscyTCBbT7BRl/DPznwdZW9t8KdU2/53EPNdOmeeOUd/aZdn7scIKK4zK570HcWf1vtE6suoAAAAASUVORK5CYII=" alt="tags">
        <p>Árazás</p>
      </div>';
    }

    /* Raktárak */

    $isWarehouse = false;
    if (UserHasPerm('warehouse_editor') || UserHasPerm('warehouse_statistic')) {
      $isWarehouse = true;
      $menuhtml .= '
      <p class="category">Raktározás</p>
      <div class="menubtn" onclick="window.location='.$linkWarehouse.';">
      '.MenuIndicator($linkWarehouse).'
        <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAEbElEQVR4nO2US2gcZRzAx+zO7COa0hYKHhQEI2raZLOb3W8mqbbSSxUFpc2peCgU0UOpBQ8efNRLsFLx0UMrSg4eBAsWCiKNs2myuzOz70cmu3nuZrM7eWzT0hw8KDnkL7P2C2Mys5kvXbMr5A8/WJaZ//f7wX5LUXuzN803Mycp2zjb8r7c2xKVuZaI+ln9jmr2AYp6TOYs/RnOUhjrtYCWDGcpy1zLO0BRLVQzTgZZUYqzCGnOCjVhLfEUaz1GNcukENOe5Kw3Ehy9nuRoMEuCo/l0H93RMPGolzoYY+lvYhy9Fudo2EziJSdMD7xXRf2s90yMo9fUHequX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P9WgfiAH9IVIZDEqig3pd1qVcAMtiPzx8OieUdBIRe5YOC4g+KwB09rsvEIP3IAUMDtOF+9Wx/UCzzQekkccDe7M3eUP+L+RtcE7PsW6laOgAAAABJRU5ErkJggg==" alt="warehouse-1">
        <p>Raktár</p>
      </div>';
    }

    if (UserHasPerm('warehouse_add')) {
      if (!$isWarehouse) { $isWarehouse = true; $menuhtml .= '<p class="category">Raktározás</p>'; }
      $menuhtml .= '
      <div class="menubtn" onclick="window.location='.$linkWarehouseAdd.';">
      '.MenuIndicator($linkWarehouseAdd).'
        <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAACKUlEQVR4nO2UTWsTURSGzyoggpiWNtOY1i+SzEwSu5XiX/AP6R8QW0QQDBm/QMGFZJLMZBTcWtxEEKsEbWucpJVm7p3aCm5aN0cm0FJukskUxiQ33Afe7Xvuw+FcAIFAIJg4lAq9LZfpgVwmmC4RTBfJQVJ3bgEvyBVK5ArFY4ESwVTRIcALcoXsdwu094EXZKOXgMOpQFkIDJ+J2IDiCZy8A+4FdCEw5A0YkyRQFgLhk7F+LWUtepixXOyk6qLqxfRC0dvAUbxNpCsEp5fXUMo3UCrYOKc1O5EKzcNZzb4OwyZn/Y5mq269r8BJCR+BOc2uLzxsRWEUXHvbns1Uab1bgNlCHwFJszfmH7fiMEqyhhNTLfrVE8icQkAq2JuJ/NYFGAdyb3YTquk2+t6BJ1ByjgViBbsVy9uXYJxQzb0Fter+6CeQLO50BGL5xlZMa16GcUSx9i6qJm32+ok6AnfXfs4UNq7COCO/pinVdHdYgSsv7L9Td74owAMZa1dRTEqOvtJUqf0nfu/TTeCJdNnJqQZZVwzyLalvL476PQLBIKieeE/1eeQixcRql0D7VRx5CrBsv5SQpwBL8/kM8hRg+f5sGv2y+TS65HdDjSfRG4M6wuwClvVH59EvfgODdoTZBSz1/Dn0S5ChgzrC7AKWzw/Ool+CDB3UEWYXsHy8fwb9EmTooI4wu4ClthxZ/bASwV6prUTeBRnq1xFmVy1gh0AgEMB/5x8+sW8rsiFSWQAAAABJRU5ErkJggg==" alt="load-cargo">
        <p>Raktári bevét</p>
      </div>';
    }

    if (UserHasPerm('removal_from_warehouse')) {
      if (!$isWarehouse) { $isWarehouse = true; $menuhtml .= '<p class="category">Raktározás</p>'; }
      $menuhtml .= '
      <div class="menubtn" onclick="window.location='.$linkWarehouseRemove.';">
      '.MenuIndicator($linkWarehouseRemove).'
        <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAADnElEQVR4nO3ZWVNScRjHcSaX3GYar2qc6Q00LZYCB1TAjcSlsjRbNW3zXfRW6qqZXkATB5E2kfUgolC3OlNzEBsvm9Ln1xwwlUHk/P8c0Auemef+84Wz/Ad0uspUpjKVOZGD7y8HkZhdx7dZIPESSLwAEs+B+DMg/hSIzwDxaWBV2SfA6hTw+4e6XR4HlseA6B0gehuIjgJLt3b3JrB0A4iMAJFhQBpah+RwsAeowj/Zx69OMgSoxEeGgMggdiTHGnsAK37lsfoABjxJDpA0AI5vgBG/8oghgA1P0nWeAEb8ykOGgNED8JsF8RTmCsiHnzocH3sAxO4DsXtAbAJYVvbuETesejyF7RwBJwhP4X6egOPG2/fwFO7jCSgV/gYznkK9PAEH8ZMq8He58CTl4v8E+pHy2LD12YbtQA8o1MMRwIuPFoensD2N9400Q5o9j023BdsBG0/A/0umnPj+9MpzVnwx1uGTsR6hmRakXB08AVriR1TjKdwH2WXZC/horEdwpgUeq66aLUAVflxzPIV6Ibu6sgI8xga4DQ1vmSK0wG9Lw/j1aQAbHjs2PP1Izivbh+R8L5LzPUi6u5F023bXiuScBcm5Lvx0duQEzLNGaPHJK/jERDOWzVWImquwZKpGxFSNsKkaIVMNgqYaBIRa+IVaLAqn4RVOY0Gow1eh7vAAYyNEfeObVzrdKRUBxV42w+lPPGY+pWmAy9AIp76pcER+/JgqfCagryQBoqEJTn3DVIGA4vDKDSu7SxfwwdAwWSCgOLzytClhwGsVlxAPfijrUbn5sRdxrW9iQ2NhfDog51yTB591KMt+zv8N2bHp6YY8Z0u/XZUXVGa7ILs6IYsdkEUzZNEEWRQgO42QnQb8eK/P+xh9N66rKojPBBSHz35JZV5QmVUOZ92goA0UtIKCFlCwCxToBAU6QAEzZGduABM+E6A1vkcVnvxKQHv2UWL6HJjw6QDV+EFN8eQ3QXa27R/mps8iJbZyHObS8PLjyS8g5WqHf/gMIrPnsClexba3jTegXHjTHp78RvxZ0CMlXsOWO4OnxWs8AVrgu5nx5DOAfHqQrx3ky+Bp8SpHQMEfnMqHJ76Ak4JvBXl5buKS44XD8Yu5ePJe4Qg4Ch8+Cm/LxgeKx5P3Mk/AYb/ZHA+evJd4Ak4OnhYucgRIg+va440q8Fdy8DsLFzj+4JAcjh1pYE0d3lpSPLwXBpgDKlOZylRGV475B8IqZ4P6TFjOAAAAAElFTkSuQmCC" alt="move-stock">
        <p>Raktári kivét</p>
      </div>';
    }

    /* Fiók kezelés */

    $menuhtml .= '
    <p class="category">Fiókműveletek</p>
    <div class="menubtn" onclick="window.location='.$linkProfile.';">
    '.MenuIndicator($linkProfile).'
      <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAADj0lEQVR4nO2Y709TVxjH7z9xTRZpFoyTFBgCRe8WTLYXSxT2Zhh9IW5xAzXLtjdL9mLJtkzmCxV1WaJTNLEqOITmnhZpe3u9tPf2F1DaMuZIcIsLZkx9o0ZoIMOL8WvOEaqYTX6UhrPsfpNP8uTp7T3nc885TXoFwYoVKyueSPKGLZr+TY6kRjLh1EgmkrrujievFwn/hUSSwzY9MXxfTwwjS/8wQv2/3jcS1woE3qP1Dsk98V/QE/vZF+wbWqskrhVo8SFFiw1Biw26BN4TCKczgUgaipHIPm01krQp4RT8RnJC4D2+UAKU5wU8atLmDfbDG+yDwHu6rsbBUKMKUYwCjxqxeQKxgEeNwaNG8y+wmcy8u5mYtyRiYjkQJQziD0P2G/PxUfRl3VOiyOZfknumZkEBduFyByEmOruD6OzuQeeVZ3QwNEYu95Zkc2xhgVwGICbOug20uwP4aQ4yh4LTJJSbADEX3oK5DrBTvoNTLg2tLi/jIqXTix9dGnbIt/kXkPKMYAkQE2+SaXx96BBC+15BeK+IcKMI4yMR+h4Rvob1fK/Atkuj6Ph8C4y9IiL7n0IljAYR+oci/LttqHWO8Ctw+stdbLJG4xrEPhYR3b8mi1YvQqkT8f0n9fwKqA2vQvt0Pca9RZjs2YipkINB6/HuIlzZVwJ3XSG/At2NGzDQXMYm/Xe0Gg/jbzFoTXuJow64tm/gV8D52VaMOkvZhM2+d/BooIZBa9obu1yJlj1b//X7xQd12A9cXRTFB/WVFzjz1S7cc5exp04n/njwPQataW/CX46TX9TzKzB4Yh0ygYpZgdrnBGpZbzJYifQP+fspFXIV8LXXYTK4EdPRLbNbqJZBa9qjh5lew62AREyMBaoxpVexCT+Mv82g9ZTuwJ+B6pd+d9W3kERMfNvVjoxqx2SwnIlQaD2h2vGNp4N/AYmY+K6rFQ986zChvMagdVNXW962jrSSApsuj6Pi7Ch+byvEzY6n0Jr26GfcClS13sXrzYnsEqcuFGPkYiEjfb4k2y9tHoCj7e6St1DxP2yZFRMob7kB+wFt3oAfNB9D+FwVjHOb8P6R4y9MSENFyx98CFQ6by364L2Iw5n7vzApV4HSw73LFig50rv6Avam+VtnSTRpHKzA0WcHd6nQA73qAhJHCJYA4X0F5NxeLeYVeTGvFt0zNVxKyObYG2Rm24ICVqxYsWLlf5UnC1iPM8geNSsAAAAASUVORK5CYII=" alt="badge--v1">
      <p>Fiókom</p>
    </div>';

    if (UserHasPerm('user_read_perm') || UserHasPerm('user_edit_perm')) {
      $menuhtml .= '
      <div class="menubtn" onclick="window.location='.$linkUserEditor.';">
      '.MenuIndicator($linkUserEditor).'
        <img src="data:image/png;base64,iVB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MGBaEBfZDCdM/Atzmm5XwnIKRH11uRJFTE5v+4iOdg8C3b4H+ViOg9q3wMHc2YX2y6BfrudFluE7wxObbwn62Pc3kG4d9toVKehLGNrjDxEe+nrlpVjxb7IbbcT3D2wMLzr+3CoKeDfjjg7BQCd97LDD8bj7gNcU9TbxYJ7MQGNE4FDZ846bs/qOUQxgbbMlNuAaY+B1lF65RDsFf+Na5LqwxyfXlxd2EEUUuyiliaApB/su9QDn8U2w9UDUjwKGG6oQ9+XW9Ma3MECOECYnXMxLjqdcPJjQVZ1GtE97c/wScbCqA/qZCqN9fA/fVupLuLazHd1zMMIAYJTJNn6r5TFjwxlcZn0JGAQzNYcWapya57tAP8xdg9d7PFA+weu/n8xdAX3tM8QD62mOZBTAisWe2IqWbpyY56wBI7CcywVwFIOYLagDHP38C0f/0Fcqz+1uVDpFn938ybwFUqFChQgUxiT8BIKhhoCtS0CsAAAAASUVORK5CYII=">
        <p>Felhasználók</p>
      </div>';
    }

    if (UserHasPerm('perm_read')) {
      $menuhtml .= '
      <div class="menubtn" onclick="window.location='.$linkPermEditor.';">
      '.MenuIndicator($linkPermEditor).'
        <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAADEklEQVR4nO2YT0gUURzHXwlZJAXm+23FSqlL1DZz6pCBvd+WBB4ygvBi2jkDK5mJbtkhLTp3qFMQIjn7nlKBK3Xpjx2y3Dq4EwlGpRVRh1IqFsyJN7ribjvpbrYzC/uFH+xh5/H5/ub35+0SUlBBBf13GdX+NZxBWDCYEginSd7BI70rECw7GEyQvIVHsCL15V0kX+AFo/cWwj9orHgW09UZU1ONkbZgKckn+IdHK6M2vK5ac/HOPKMgyVN4O2K6Mm1qyjmroaGIeL5sUuCTQlMio62BdXmTeYcYGjkRLHHNgD3nk+ArnmYAb82V1G3XyokjTCbg7zdufZIpvDkfSrsrBuSG5QjvBw6Wd2cPr9qN/VLbGSJuytTVrmwNmLMmJlzdE2Nnd603NfXtP5roJm5KLil7zv+DiYFD/h5Zlq5dAGVDZgs/2Fz1IjEUOMI3VwyM1gWKoy3bX2cK/6i56vnCkSwQenIObyAt4Qwifft8VrRlx9Iz31QVXQgvb7NySeYUXuwt2yQQ5kGkieHji7+JxymZdwXeqNkYFIy+SQaBfllOsiecGnuwOTDsOnwvgz2c0c8p8MOynBLfkUsqpinjnoPnIXpEMPozCYTBuMBSf7o9EdPVazb8MQ/UPGdwSiD8SpocDL72MVD/9lyk3n/TVXijgRRxhCspI88SSOPhENQu9jyfXVLuwF/HLas5gpEKzxFmwghNSzlDILTJW6w8J6fwvbWbNwgGg39m3s6+TrwsXgOVHOFVOniO9CrxssIh326O9FNaeEbvyJ4gXhVHOMyRfnfI/NCNA761xKsSSFsFg2mHmh+7tR98xIuyCFkhkJ5PD26XzZfemrJtxIvqrwsUy2usE7xA+kMgVBOviiNccoRnMC17gnhZgsFHZwNlJ4nXJZwMMLhM8kGCwcU0BnraCVmZ6VkxXe00NTWe8W9jTY2bmtKRlQEjGFwlTXCEDzLkZ9nY2Zxl6upU1n+vaOokcUOCQae8lTpPsUyDxjnSjlwamFo+eEjcdHP3NmS2lvsNCKQXcmagoIIKIjnRb11UiFNqLpkFAAAAAElFTkSuQmCC" alt="law">
        <p>Jog lista</p>
      </div>';
    }

  $menuhtml .= '</div>';

/* Globális funkciók */

function StopAndDie($reason = "Jogosultság megtagadva! Önnek nincsen joga a kért tartalom megtekintéséhez!") {
  global $currentUrl;
  $_SESSION['error_message'] = $reason;
  header('X-Frame-Options: DENY');
  header("Location: ".$currentUrl."/dashboard");
  die();
}

function getItemsSlice(array $items, int $page, int $limit = 25): array {
    $offset = ($page - 1) * $limit;
    return array_slice($items, $offset, $limit);
}

function idToHexColor(string $id): string {
    $hash = md5($id);
    $color = substr($hash, 0, 6);
    return '#' . $color;
}

function escapeForJson($string) {
  $escaped = str_replace('"', "'", $string);
  $escaped = str_replace("\\", "\\\\", $escaped);
  $escaped = str_replace("/", "\\/", $escaped);
  $escaped = str_replace("\n", "\\n", $escaped);
  $escaped = str_replace("\r", "\\r", $escaped);
  $escaped = str_replace("\t", "\\t", $escaped);
  return $escaped;
}

function splitSetitem_id($item_id) {
  if (strpos($item_id, '+') === false) {
    return null;
  }

  $parts = explode('+', $item_id, 2);
  $first = trim($parts[0]);
  $second = trim($parts[1]);

  // Prefix
  $prefix = '';
  $first_numeric = $first;
  if (preg_match('/^([^0-9]{1,2})(.*)$/', $first, $matches)) {
    $prefix = $matches[1];
    $first_numeric = $matches[2];
  } else {
    $first_numeric = (string)intval($first);
  }

  $item1 = $prefix . $first_numeric;

  $second_numeric = $second;
  if ($prefix === '') {
    $second_numeric = (string)intval($second);
  }
  $item2 = $prefix . $second_numeric;

  return ['item1' => $item1, 'item2' => $item2];
}

/* scriptek */
$SystemVersion = file_get_contents($currentUrl.'/version.php?v=1');
$menuhtml .= "<div class='VersionData'><a href='".$currentUrl."/version.php' target='_blank'>" . $SystemVersion . "</a></div>";

$menuhtml .= '<script src="../js/szatuna.js?v='.date('Ymd').'"></script>';
$menuhtml .= '<script src="../js/bug_report.js?v='.date('Ymd').'"></script>';


?>
