Browse Source

* Add Web Service to manage background operations
* Added queue message system
* Added Mysql Memory table

Giancarlo Voci 8 years ago
parent
commit
062c0fbb3c

+ 7 - 4
cfg/config - dimatec.ini

@@ -2,13 +2,16 @@
 AUTOLOAD="src/"
 CACHE = TRUE
 UI=ui/
-DEBUG=3
+DEBUG=2
 ENCODING="UTF-8"
 HIGHLIGHT=false
 JAR.expire={{time()+31536000}}
 DSN="mysql:host=localhost;port=3306;dbname=omlink"
 dbuser=root
 dbpass=giancarlo
+;dbpass=OMG988of8$
+PHP_PATH=C:/nginx/php7/php.exe
+MAX_BLINK_TIME_SEC=60
 
 ; Path
 BASEURL=/omlink
@@ -22,9 +25,9 @@ CUSTOMERNAME=dimatec
 [CORE.fb]
 host=192.168.1.140
 port=50443
-key=C0000000000011532366136
-pass=RvM5WNOo2XaDL6AspUaO7OIMuXqg9IFS
+key=C0000000000011474023057
+pass=ZrgzkvJrOKnNSCnPnGz3u{A6eHSNXVvs
 
 [VERTICALSTORAGE]
 ; Magazzino verticale ICAM
-MV_ADDRESS=192.168.253.130
+;MV_ADDRESS=192.168.253.130

+ 5 - 3
cfg/config - lamborghini.ini

@@ -2,13 +2,15 @@
 AUTOLOAD="src/"
 CACHE = TRUE
 UI=ui/
-DEBUG=3
+DEBUG=1
 ENCODING="UTF-8"
 HIGHLIGHT=false
 JAR.expire={{time()+31536000}}
 DSN="mysql:host=localhost;port=3306;dbname=omlink"
 dbuser=root
 dbpass=giancarlo
+PHP_PATH=C:/nginx/php7/php.exe
+MAX_BLINK_TIME_SEC=60
 
 ; Path
 BASEURL=/omlink
@@ -22,5 +24,5 @@ CUSTOMERNAME=lamborghini
 [CORE.fb]
 host=192.168.0.140
 port=50443
-key=C0000000000011532366136
-pass=RvM5WNOo2XaDL6AspUaO7OIMuXqg9IFS
+key=C0000000000011474023057
+pass=ZrgzkvJrOKnNSCnPnGz3u{A6eHSNXVvs

+ 1 - 1
cfg/config.bin

@@ -1 +1 @@
-eJx1kV1vmzAUhu8t+T+gXG2axkdIWLvI0ii4hAnwxEdXqaoiQ1yCajAF062t8t9n0na7miVLtvS+5zznPTc1FyXl4y0EbpGTiLg+WoxDZSwg8FxvizWk5WmBIShCNDUGBD6+KAJkQ4ATj/hhEqBFkV9+PlOGbRhsI3VzdKdKMgi+u6nOfvfNwNDLi2xa9uHjJ9ta245pmsejqpUlaNE+jQ/860GMEnFRUT6/Nr0YJLJt09nsy462DImWN929arIvp5ENaBBCzp+ejiOqG9pVdOACAgg22g8qDxBcuBku0ggZr1YIsjDHiRtj5DctlayCICIB2XlFlpMYpwrx25vneDTUrEpVs9F4U0eiFnrf1RCEHkl2s7XI/+fhSjzJV/lMlDHOKqn9OjTVQaumUYqWDVrFFbzGOlpyFdY7xwlx/44IwY1HUqzflWpFp5Cs86VuOWe6pVsrE4JTUmtztVIruWdPyDP/HUtlvbQdx7IdJZyTSh/j9c+EiOU19SPHHfuCki8kjKfrh/o8vMxODa9wmoeeGyme1A3w7TxBTGv6/Nx0Qntkg2zUnpimNDEE8dXO9f0UZ9lftOXa1i1bwf0BLRu0Lw==
+eJx1kWtvmzAUhr9b8n9A0T5smsYl5NZGluaAB7RcIi5RtapChDgEBTADkrWJ8t9n0nT7NEu2fHnPOc97/JwVbJ0U7QsEOAo928M6GrRNKg0g0LBmEgEJoR8RCCILHXIJAp0sIgMNISCu5umWa6BBFP74NuMBpmWYNp8h2vKUFIIH7Iv0tc4bis7nLi/p5y9fVWWsTmRZvlx4rsBFg/Kt/VXc71jboYKlSdHv5jVrOqSq8mS+WVdJSREri7za8yKb9aGlDWoY6/pDnbQtyvKkSpOmYBDMb1eeY9zNZmw7+wTB0lzGSxyaSLuXqiyvXqV6V0/7hdNxTAc/xQvbch/j0HJIHBANTWQIeDJhmXQ7CBY4IJFvI+mdAoLAComLHYL0vEw6mkJge4YXa1EQeg7xudvvt5jLReJt46qMttJNbbOMiXWVQWBpnhv3oVH4v5iCiw/du7wnCmhB0074vcvTnZAe2o6VtBHSgpsWaJWsC27og+OKuPlAhOBZ83wibtf8t6/9Vu6GojKZiYqojLjha9PH8mikQrCnb0iT/w1FGU1H8lCVx1Mu7Dv8s8lO++ND4z1WbqBVy8o4qYcznlAzcJ9Wx/ZacEX80NKwzXl8bJCX3oGTZMnplFdMONKmy/mXU4FrHP7mrGKs6z4Jgr9sw7EqKiqn+wPcGMvS

+ 0 - 0
labels.ini → cfg/labels.ini


BIN
favicon.ico


+ 1 - 1
index.php

@@ -16,7 +16,7 @@ $f3 = \Base::instance();
 $f3->set('GLOBALMENU', array());
 
 // Load Utility Class
-require_once "src\OpenMind\System\OMUtils.php";
+require_once "src/OpenMind/System/OMUtils.php";
 
 // Initialize Util library
 $frameworkUtils = new \OpenMind\System\OMUtils();

+ 1 - 1
package.json

@@ -5,7 +5,7 @@
   "main": "",
   "scripts": {
     "build": "node build.js dimatec",
-    "deploy": "zip -9 -r deploy.zip favicon.ico config.bin labels.ini *.php bundle.* src ui"
+    "deploy": "zip -9 -r deploy.zip dbschema.sql lib cfg/config.bin cfg/labels.ini *.php bundle.* src ui tmp cache"
   },
   "author": "Open Mind",
   "license": "ISC",

+ 4 - 1
src/Modules/Dimatec/Dimatec.php

@@ -8,6 +8,9 @@
 
 namespace Modules\Dimatec;
 
+use DB\SQL\Mapper;
+use OpenMind\FindBox\FindBoxCoreSystem;
+use OpenMind\FindBox\SmartESL;
 use OpenMind\System\PluginStrategy;
 
 class Dimatec extends PluginStrategy
@@ -17,7 +20,7 @@ class Dimatec extends PluginStrategy
     if (\F3::get('CUSTOMERNAME') != 'dimatec')
       return;
 
-    \F3::config('labels.ini', true);
+    \F3::config('cfg/labels.ini', true);
 
     // Definisco il namespace del gestore delle pagine
     define('KITTING_SYSTEM', 'Modules\KittingDynamic');

+ 4 - 2
src/Modules/Dimatec/Distinta.php

@@ -173,7 +173,9 @@ SOAP;
 
 
     $mvHost = \F3::get('VERTICALSTORAGE.MV_ADDRESS');
-    $icam = new Soap("http://{$mvHost}/servizi_xchange.asmx");
-    $icam->ImportLists($xml, 'http://servizi_xchange.org/ImportLists');
+    if (!empty($mvHost)) {
+      $icam = new Soap("http://{$mvHost}/servizi_xchange.asmx");
+      $icam->ImportLists($xml, 'http://servizi_xchange.org/ImportLists');
+    }
   }
 }

+ 30 - 8
src/Modules/Dimatec/Pages.php

@@ -8,7 +8,9 @@
 namespace Modules\Dimatec;
 
 use OpenMind\FindBox\FindBoxCoreSystem;
+use OpenMind\FindBox\LedAlive;
 use OpenMind\FindBox\SmartESL;
+use OpenMind\System\QueueSystem;
 use OpenMind\Web\Controller;
 
 class Pages extends Controller
@@ -57,23 +59,43 @@ class Pages extends Controller
           if (!$ok) {
             $f3->set('INFOTEXT', "Codice cesta non corretto");
           } else {
-            $distinta->DeleteCommessa($stepValues['commessa']);
+            $labelid = $distinta->GetLabelIdFromBarcode($stepValues['commessa']);
+            if ($labelid != null) {
+              // Send BlinkOFF
+              $obj = new LedAlive($labelid);
+              $obj->setToBlinkOff();
+
+              // Send command to queue
+              $qm = new QueueSystem('FindBoxService');
+              $qm->send($obj);
+              //$f3->get('DB')->exec('UPDATE label_bindings SET isBlinking=0 WHERE label_id=?', $labelid);
+
+              $distinta->DeleteCommessa($stepValues['commessa']);
+            }
           }
         }
         $commesse = $distinta->getCommesseFromProduct($f3->get('SESSION.barcode_mv'));
         if (count($commesse) == 0) {
           $f3->set('INFOTEXT', "Ventilazione terminata");
-          $f3->set('RESTART_VENTILAZIONE', true);
+          $f3->set('RESTART_VENTILAZIONE', TRUE);
         }
         foreach($commesse as $commessa) {
           $labelid = $distinta->GetLabelIdFromBarcode($commessa['commessa']);
-          $label = new SmartESL($this->findBoxCore, [$labelid]);
-          $eslData = array(
+          if ($labelid == null) {
+            $f3->set('INFOTEXT', "Alcune etichette non accenderano il led in quanto non associate.");
+            continue;
+          }
+
+          $obj = new LedAlive($labelid);
+          $obj->setToBlink();
+          $obj->SetLeds($commessa['descrizione'], 2, 1, 1000, 1);
+          $obj->setDataFields([
             'Q.ta' => $commessa['qta_prelevare'],
             'Commessa' => $commessa['commessa']
-          );
-          $label->BlinkSpecial(0, 1, 1000, 8, 0);
-          $err = $this->findBoxCore->SaveProducts($labelid, $commessa['descrizione'], $eslData);
+          ]);
+
+          $qm = new QueueSystem('FindBoxService');
+          $qm->send($obj);
         }
         $f3->set('COMMESSE', $commesse);
         break;
@@ -90,7 +112,7 @@ class Pages extends Controller
 
     if (count($params)) {
       $bindData = array_map('strtoupper', $this->getSanitizedPostRequest());
-      $err = $this->findBoxCore->Bind($bindData['labelid'], $bindData['labelid']);
+      //$err = $this->findBoxCore->Bind($bindData['labelid'], $bindData['labelid']);
       $label = new SmartESL($this->findBoxCore, [$bindData['labelid']]);
 
       $labelTemplateId = \F3::get("LABELS.TEMPLATES.DT31");

+ 1 - 1
src/Modules/Lamborghini/Lamborghini.php

@@ -20,7 +20,7 @@ class Lamborghini extends PluginStrategy
     // Definisco il namespace del gestore delle pagine
     define('KITTING_SYSTEM', 'Modules\KittingDynamic');
 
-    \F3::config('labels.ini', true);
+    \F3::config('cfg/labels.ini', true);
 
     $this->AddRoute('GET|POST /pick2light/@step', KITTING_SYSTEM . '\Pages->Pick2Light');
     $this->AddRoute("GET|POST /bind/@step", KITTING_SYSTEM . '\Pages->Bind');

+ 56 - 0
src/OpenMind/FindBox/FindBox.php

@@ -0,0 +1,56 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Giancarlo
+ * Date: 09/08/2018
+ * Time: 09:57
+ */
+
+namespace OpenMind\FindBox;
+
+use OpenMind\System\PluginStrategy;
+
+class FindBox extends PluginStrategy
+{
+  public function __construct()
+  {
+    // CLI scripts
+    $this->AddRoute('GET /api.fb.service', __NAMESPACE__ . '\FindBoxService->Main');
+  }
+
+  /**
+   * Spawn and detach a new php process to call a webservice of OM-Link. With DEBUG>0 enable XDEBUG to stop to breakpoints
+   * This method make use of F3 Cache to pass object
+   *
+   * @param $data object to serialize
+   * @throws \Exception in case of no operative system is detected
+   */
+  private function SpawnServiceProcess($data)
+  {
+    global $f3;
+
+    $objCacheId = 'obj' . rand(10, 200);
+    $this->cache->set($objCacheId, $data);
+
+    $cacheSeed = $f3->get('SEED');
+    if ($f3->get('DEBUG') > 0)
+      putenv('XDEBUG_CONFIG="remote_enable=1 remote_mode=req remote_port=9000 remote_host=127.0.0.1 remote_connect_back=0"');
+
+    $apiCall = "index.php /api.fb.service";
+    switch (strtolower(PHP_OS_FAMILY)) {
+      case 'linux':
+        $command = "nohup {$f3->get('PHP_PATH')} {$apiCall} &";
+        break;
+      case 'windows':
+        $command = "start {$f3->get('PHP_PATH')} {$apiCall}";
+        break;
+      default:
+        throw new \Exception('Operative system not detected');
+        break;
+    }
+    pclose(popen($command, 'r'));
+  }
+}
+
+/** @var \OpenMind\FindBox\FindBox $FindBox */
+Global $FindBox;

+ 0 - 0
src/OpenMind/Findbox/FindBoxCoreSystem.php → src/OpenMind/FindBox/FindBoxCoreSystem.php


+ 108 - 0
src/OpenMind/FindBox/FindBoxService.php

@@ -0,0 +1,108 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Giancarlo
+ * Date: 09/08/2018
+ * Time: 11:18
+ */
+
+namespace OpenMind\FindBox;
+
+use DB\SQL\Mapper;
+use http\QueryString;
+use OpenMind\System\QueueSystem;
+
+class FindBoxService
+{
+  private $dbHandle;
+  private $findBoxCore;
+  private $labels;
+
+  public function __construct()
+  {
+    global $f3;
+    $this->dbHandle = $f3->get('DB');
+    $this->findBoxCore = new FindBoxCoreSystem(...array_values($f3->get('CORE.fb')));
+
+    $this->labels = [];
+  }
+
+  private function getCurrentQueue()
+  {
+    $table = new QueueSystem('FindBoxService');
+    while (!$table->check()) {
+
+      /** @var LedAlive $apiParameters */
+      $apiParameters = $table->getCommandObject();
+      $this->labels[] = $apiParameters;
+      $table->erase();
+      $table->next();
+    }
+  }
+
+  public function saveProduct($label)
+  {
+    if ($label->dataFields != null)
+      $this->findBoxCore->SaveProducts($label->id, $label->description, $label->dataFields);
+  }
+
+  /**
+   * Called from php spawn process. This script end after MAX_BLINK_TIME
+   *
+   * @param $f3
+   * @param $args
+   * @throws \Exception
+   */
+  public function Main($f3)
+  {
+    while (true) {
+
+      $this->getCurrentQueue();
+
+      //$this->parseQueue();
+
+      /** @var LedAlive $label */
+      foreach($this->labels as $key => $label) {
+
+        $this->saveProduct($label);
+
+        // Priority 1
+        // ----------
+        // Force exit and blink off if run time script > MAX_BLINK_TIME_SEC
+        $now = time() - $label->tsFirstBlink;
+        if ($now > $f3->get('MAX_BLINK_TIME_SEC')) {
+          $esl = new SmartESL($this->findBoxCore, [$label->id]);
+          $esl->BlinkOff();
+          unset($this->labels[$key]);
+          continue;
+        }
+
+        // Priority 2
+        // ----------
+        // Stop blink if isBlinking = 0
+        if ($label->operation == BLINK_OFF) {
+          $esl = new SmartESL($this->findBoxCore, [$label->id]);
+          $esl->BlinkOff();
+          unset($this->labels[$key]);
+          continue;
+        }
+
+        // Priority 3
+        // ----------
+        // Restart blink if blink is ended
+        $blinkEndTime = time() - $label->tsLastLongBlink;
+        if ($blinkEndTime > $label->getBlinkDuration()) {
+          $esl = new SmartESL($this->findBoxCore, [$label->id]);
+          $esl->BlinkSpecial($label->pattern, $label->repeat, $label->iter_time, $label->iterations, 0);
+          $esl->tsLastLongBlink = time();
+        }
+      }
+
+
+      sleep(1);
+    }
+
+    return;
+  }
+
+}

+ 63 - 0
src/OpenMind/FindBox/LedAlive.php

@@ -0,0 +1,63 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Giancarlo
+ * Date: 09/08/2018
+ * Time: 14:42
+ */
+
+namespace OpenMind\FindBox;
+
+define('BLINK_ON', 1);
+define('BLINK_OFF', 2);
+
+class LedAlive
+{
+  public $id;
+  public $description;
+  public $pattern;
+  public $repeat;
+  public $iter_time;
+  public $iterations;
+  public $dataFields;
+  public $operation;
+  public $tsFirstBlink;
+  public $tsLastLongBlink;
+
+  public function __construct(string $labelID)
+  {
+    $this->id = $labelID;
+    $this->dataFields = null;
+    $this->tsLastLongBlink = $this->tsFirstBlink = time();
+  }
+
+  public function SetLeds(string $description, int $pattern, int $repeat, int $iter_time, int $iterations)
+  {
+    list($this->description, $this->pattern, $this->repeat, $this->iter_time, $this->iterations) = func_get_args();
+  }
+
+  public function setDataFields(array $dataFields)
+  {
+    $this->dataFields = $dataFields;
+  }
+
+  public function setToBlink()
+  {
+    $this->operation = BLINK_ON;
+  }
+
+  public function setToBlinkOff()
+  {
+    $this->operation = BLINK_OFF;
+  }
+
+  /**
+   * Calculate blink duration in seconds for patterns_type=2
+   *
+   * @return int
+   */
+  public function getBlinkDuration(): int
+  {
+    return ($this->iter_time / 1000) * $this->iterations;
+  }
+}

+ 26 - 9
src/OpenMind/Findbox/SmartESL.php → src/OpenMind/FindBox/SmartESL.php

@@ -16,7 +16,7 @@ class SmartESL
   public function __construct(FindBoxCoreSystem $coreL, array $LabelID)
   {
     $this->core = $coreL;
-    $this->labels = $LabelID;
+    $this->labels = array_map('strtoupper', $LabelID);
     // TODO utilizzare la $Cache di F3 per velocizzare le operazioni
     $this->labelProperties = $this->GetStatus();
   }
@@ -31,7 +31,9 @@ class SmartESL
     $URI = "/1.0.0/index.php/smartesl.getstatus/3.1.0/";
     $ret = $this->core->CallAPI($URI, $labels);
     if ($ret['err'] == 0 && $ret['value']['code'] == 0) {
-      return $ret['value']['value'];
+      // Update current properties
+      $this->labelProperties = $ret['value']['value'];
+      return $this->labelProperties;
     }
     return null;
   }
@@ -57,8 +59,13 @@ class SmartESL
     return array_values(array_filter_keys($softVersion, ['soft_major', 'soft_minor', 'soft_patch']));
   }
 
+  public function getData()
+  {
+    return $this->labelProperties[$this->labels[0]]['data'];
+  }
+
   /**
-   * Blink the label. If old version found, skip automatically useless parameter
+   * Blink the label with parameters. BlinkSpecial make use of getData() and check how many leds has to auto select the firmware version.
    *
    * @param int $pattern
    * @param int $repeat
@@ -68,6 +75,18 @@ class SmartESL
    */
   public function BlinkSpecial(int $pattern, int $repeat, int $iter_time, int $iterations, int $ledColor = null)
   {
+    $numLeds = $this->getData()['led'];
+    switch ($numLeds) {
+      case 2:
+        $version = 4;
+        break;
+      case 4:
+        $version = 6;
+        break;
+      default:
+        $version = 3;
+        break;
+    }
     $firmwareStringVersion = array(
       '3' => '1.0.0',
       '4' => '1.1.0',
@@ -82,11 +101,11 @@ class SmartESL
     );
 
     // TODO #NODISPLAY da sistemare
-    $strFWVer = $firmwareStringVersion[4];
+    $strFWVer = $firmwareStringVersion[$version];
 
     $uriParams = json_encode(array_merge(
       array($this->labels),
-      $params[4]));
+      $params[$version]));
 
     $URI = "/1.0.0/index.php/smartesl.blink_special/{$strFWVer}/";
     $this->core->CallAPI($URI, $uriParams, true);
@@ -97,10 +116,8 @@ class SmartESL
    */
   public function BlinkOff()
   {
-    $URI = "/1.0.0/index.php/smartesl.blink_special/1.1.0/";
-    $this->core->CallAPI($URI, "[[\"{$this->labels[0]}\"],3,1,500,1,1]", true);
-//    $URI = "/1.0.0/index.php/smartesl.blink_special/2.0.0/";
-//    $this->core->CallAPI($URI, "[[\"{$this->labels[0]}\"],0,1,1,500,1,1]", true);
+    $URI = "/1.0.0/index.php/smartesl.blink_special/2.0.0/";
+    $this->core->CallAPI($URI, "[[\"{$this->labels[0]}\"],0,0,0,0,0,1]", true);
   }
 
   public function Display(string $templateId, string $barcode)

+ 9 - 1
src/OpenMind/System/ErrorHandlers.php

@@ -11,6 +11,7 @@ namespace OpenMind\System;
 class ErrorHandlers
 {
   private $f3;
+
   public function __construct()
   {
     $this->f3 = \Base::instance();
@@ -21,6 +22,8 @@ class ErrorHandlers
    */
   public function Handler()
   {
+    $arrayError = array($this->f3->get('ERROR')['code'], $this->f3->get('ERROR')['status'], $this->f3->get('ERROR')['text']);
+
     while (ob_get_level()) // Prevent to output all previous templates
       ob_end_clean();
 
@@ -28,13 +31,18 @@ class ErrorHandlers
 
     $this->WriteLog(join(' - ', array($err['code'], $err['status'], $err['text'])));
 
+    if ($this->f3->get('CLI')) {
+      print_r($arrayError);
+      die(1);
+    }
+
     if (!$this->f3->get('AJAX')) {
       echo \Template::instance()->render('errors.tpl');
       return;
     }
 
     http_response_code(400);
-    echo join(' - ', array($this->f3->get('ERROR')['code'], $this->f3->get('ERROR')['status'], $this->f3->get('ERROR')['text']));
+    echo join(' - ', $arrayError);
   }
 
   /**

+ 77 - 0
src/OpenMind/System/QueueSystem.php

@@ -0,0 +1,77 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Giancarlo
+ * Date: 09/08/2018
+ * Time: 11:27
+ */
+
+namespace OpenMind\System;
+
+use DB\SQL\Mapper;
+
+class QueueSystem extends Mapper
+{
+  /** @var \Base $f3 */
+  private $f3;
+  private $serviceName;
+
+  // Used internally
+  private $initLoad;
+
+  public function __construct(string $serviceName)
+  {
+    global $f3;
+    $this->f3 = $f3;
+
+    parent::__construct($f3->get('DB'), 'queuesystem');
+
+    $this->serviceName = $serviceName;
+  }
+
+  /**
+   * Send object to <$serviceName>.
+   * send() $obj will be serialized before send to queue
+   *
+   * @param $obj
+   */
+  public function send($obj)
+  {
+    $serializedObject = serialize($obj);
+    $this->reset();
+    $this->servicename = $this->serviceName;
+    $this->command = base64_encode($serializedObject);
+    $this->save();
+  }
+
+  public function getCommandObject() {
+    $decodedObj = base64_decode($this->command);
+    $obj = unserialize($decodedObj);
+    return $obj;
+  }
+
+  /**
+   * Retrieve messages
+   *
+   * @return array|FALSE
+   */
+  public function check()
+  {
+    if (!$this->initLoad) {
+      $this->initLoad = true;
+      $this->load(['servicename=?', $this->serviceName]);
+    }
+    return $this->dry();
+  }
+
+  /**
+   * Delete all messages of <$serviceName>
+   */
+  public function deleteAll()
+  {
+    $this->reset();
+    $this->erase(['servicename=?', $this->serviceName]);
+  }
+
+
+}

+ 3 - 2
ui/masterpage.tpl

@@ -5,9 +5,10 @@
 	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
 	<title>{{@SITENAME}}</title>
 	<link type="text/css" rel="stylesheet" href="{{@BASEURL}}/bundle.css"/>
+	<link rel="shortcut icon" type="image/x-icon" href="ui/favicon_{{@CUSTOMERNAME}}.ico">
 
 	<script type="text/javascript">
-    var BASEURL = '{{@BASEURL}}';
+		const BASEURL = '{{@BASEURL}}';
 	</script>
 </head>
 <body>
@@ -15,7 +16,7 @@
 <include href="header.tpl"/>
 
 <div class="d-flex px-0 justify-content-around" style="height: calc(100% - 150px); overflow: auto">
-	<include if="{{ isset(@CONTENT) }}" href="{{@CONTENT}}"/>
+	<include if="{{isset(@CONTENT)}}" href="{{@CONTENT}}"/>
 </div>
 
 <include href="footer.tpl"/>