Browse Source

* Added unbind

Giancarlo Voci 8 years ago
parent
commit
833c558f76
11 changed files with 232 additions and 226 deletions
  1. 1 0
      TODO.txt
  2. 1 0
      index.php
  3. 2 41
      src/Distinta.php
  4. 33 15
      src/FindBoxCoreSystem.php
  5. 16 19
      src/Modules/Pages.php
  6. 8 9
      src/SmartESL.php
  7. 21 21
      ui/homemenu.tpl
  8. 27 27
      ui/pick2light.tpl
  9. 87 85
      ui/pick2light_picks.tpl
  10. 9 9
      ui/pick2light_savingproducts.tpl
  11. 27 0
      ui/unbind.tpl

+ 1 - 0
TODO.txt

@@ -7,3 +7,4 @@
 [ ] TODO aggiungere alla fine della picking list, sulla 7" l'elenco delle quantità prelevate e delle quantità mancanti (Anomalie) e trimmare la descrizione che in alcuni casi è molto lunga
 [ ] TODO Parametrizzare nel file LABEL.INI i parametri del BlinkSpecial
 [ ] TODO creare la classe wrapper Parameters o Configuration, serve per leggere più velocemente i parametri dai file INI e nel caso manchino uno o l'intero file INI, a creare dei defaults
+[ ] TODO dashboard OMLink: aggiungere "display_refresh" con tempo in minuti; aggiungere l'import dei template da omlink di template prima esportati da Findbox

+ 1 - 0
index.php

@@ -28,6 +28,7 @@ $f3->route('GET /', "Modules\Pages->Login", $f3->get('CACHE_TTL'));
 $f3->route('GET /homemenu', "Modules\Pages->HomeMenu", $f3->get('CACHE_TTL'));
 $f3->route('GET|POST /pick2light/@step', "Modules\Pages->Pick2Light", $f3->get('CACHE_TTL'));
 $f3->route("GET|POST /bind/@step", 'Modules\Pages->Bind', $f3->get('CACHE_TTL'));
+$f3->route("GET|POST /unbind/@step", 'Modules\Pages->UnBind', $f3->get('CACHE_TTL'));
 $f3->route('GET /elencodistinta', "Modules\Pages->ElencoDistinta", $f3->get('CACHE_TTL'));
 
 // Services

+ 2 - 41
src/Distinta.php

@@ -196,48 +196,14 @@ EOF;
     }
 
     $xmlField .= '</distinta>';
-    $xmlField = addslashes($xmlField);
 
     $dataFields['xml'] = $xmlField;
-    /*    $dataFields['xslt'] = <<<EOF
-    <?xml version="1.0" encoding="UTF-8"?>
-    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-      <xsl:template match="/">
-        <svg xmlns="http://www.w3.org/2000/svg" width="640" height="384" viewBox="0 0 640 384">
-          <xsl:for-each select="distinta/materiale">
-            <xsl:if test="@anomalia='1'">
-              <xsl:variable name="posDeltaY" select="((position()-1)*15)+4"/>
-              <rect width="640" height="15px" y="{\$posDeltaY}px" style="fill:rgb(0,0,0)"/>
-            </xsl:if>
-          </xsl:for-each>
-          <text style="font-family: Tahoma; font-size: 8pt; font-weight: bold">
-            <xsl:for-each select="distinta/materiale">
-              <xsl:variable name="textcolor">
-                <xsl:choose>
-                  <xsl:when test="@anomalia='1'">
-                    <xsl:value-of select="'white'"/>
-                  </xsl:when>
-                  <xsl:otherwise>
-                    <xsl:value-of select="'black'"/>
-                  </xsl:otherwise>
-                </xsl:choose>
-              </xsl:variable>
-              <tspan fill="{\$textcolor}" dy="15px" x="0"><xsl:value-of select="barcode"/></tspan>
-              <tspan fill="{\$textcolor}" x="90"><xsl:value-of select="substring(description, 1, 28)" /></tspan>
-              <tspan fill="{\$textcolor}" x="300"><xsl:value-of select="qta_prelevata" /></tspan>
-              <tspan fill="{\$textcolor}" x="330"><xsl:value-of select="qta_prelevare" /></tspan>
-            </xsl:for-each>
-          </text>
-        </svg>
-      </xsl:template>
-    </xsl:stylesheet>
-    EOF;*/
-
+    $dataFields['xslt'] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><xsl:template match=\"/\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"640\" height=\"384\" viewBox=\"0 0 640 384\"><xsl:for-each select=\"distinta/materiale\"><xsl:if test=\"@anomalia='1'\"><xsl:variable name=\"posDeltaY\" select=\"((position()-1)*15)+4\"/><rect width=\"640\" height=\"15px\" y=\"{\$posDeltaY}px\" style=\"fill:rgb(0,0,0)\"/></xsl:if></xsl:for-each><text style=\"font-family: Tahoma; font-size: 8pt; font-weight: bold\"><xsl:for-each select=\"distinta/materiale\"><xsl:variable name=\"textcolor\"><xsl:choose><xsl:when test=\"@anomalia='1'\"><xsl:value-of select=\"'white'\"/></xsl:when><xsl:otherwise><xsl:value-of select=\"'black'\"/></xsl:otherwise></xsl:choose></xsl:variable><tspan fill=\"{\$textcolor}\" dy=\"15px\" x=\"0\"><xsl:value-of select=\"barcode\"/></tspan><tspan fill=\"{\$textcolor}\" x=\"90\"><xsl:value-of select=\"substring(description, 1, 28)\" /></tspan><tspan fill=\"{\$textcolor}\" x=\"300\"><xsl:value-of select=\"qta_prelevata\" /></tspan><tspan fill=\"{\$textcolor}\" x=\"330\"><xsl:value-of select=\"qta_prelevare\" /></tspan></xsl:for-each></text></svg></xsl:template></xsl:stylesheet>";
 
     $dataFields['end_operations'] = $consegna;
 
     $label = new \SmartESL($findBoxCore, [$labelId]);
-    $ret = $findBoxCore->SaveProducts($barcode, $consegna, $dataFields);
+    $findBoxCore->SaveProducts($barcode, $consegna, $dataFields);
     $label->BlinkSpecial(0, 1, 1000, 8, 0);
   }
 
@@ -262,11 +228,6 @@ EOF;
 
       // TODO #NODISPLAY da testare, rimuovere se è ok
       $findBoxCore->SaveProducts($row['barcode'], $row['descrizione'], $dataFields);
-
-//      $label = new \SmartESL($findBoxCore, [$row['label_id']]);
-//      $devType = 31;
-//      $labelTemplateId = \F3::get("LABELS.TEMPLATES.DT{$devType}");
-//      $label->Display($labelTemplateId[0], $row['barcode']);
     }
   }
 

+ 33 - 15
src/FindBoxCoreSystem.php

@@ -37,7 +37,7 @@ class FindBoxCoreSystem
     $this->Pass = $Password;
 
     $URI = '/1.0.0/index.php/getstatus/1.0.0/';
-    $ret = $this->CallAPI("GET", $URI, "");
+    $ret = $this->CallAPI($URI, "");
 
     if ($ret['err'] == 0 && $ret['value']['code'] == 0) {
       $details = $ret['value']['value'];
@@ -54,26 +54,26 @@ class FindBoxCoreSystem
    */
   private function returnCode(int $errorCode, string $value): array
   {
+    $val = json_decode($value, true) ?? $value;
     return array(
       "err" => $errorCode,
-      "value" => json_decode($value, true));
+      "value" => $val);
   }
 
   public function BlinkUnassigned()
   {
     $URI = "/1.0.0/index.php/smartesl.blink_unassigned/2.0.0/";
-    $this->CallAPI("GET", $URI, "", true);
+    $this->CallAPI($URI, "", true);
   }
 
   /**
    * CallGetAPI make HTTP GET requests
-   * @param string $method GET | POST
    * @param string $URI full path of api url, for example "/1.0.0/index.php/smartesl.blink_special/1.0.0/"
    * @param string $Parameters
    * @param bool $skipResponse for faster communications, if response not need, you can skip this step
    * @return array converted from JSON response of request if present
    */
-  public function CallAPI(string $method, string $URI, string $Parameters, bool $skipResponse = false): array
+  public function CallAPI(string $URI, string $Parameters, bool $skipResponse = false): array
   {
     $bodyJSON = "{}";
     $auth = "Authorization: Basic " . base64_encode("{$this->Key}:{$this->Pass}") . "\r\n";
@@ -83,7 +83,11 @@ class FindBoxCoreSystem
       fclose($streamfbOS);
       return $this->returnCode($errno, $errstr);
     } else {
-      fwrite($streamfbOS, "{$method} {$URI}{$Parameters} HTTP/1.0\r\nHost: {$this->Host}\r\n{$auth}Accept: */*\r\nConnection: close\r\n\r\n");
+      //$requestText = "{$method} {$URI}{$Parameters} HTTP/1.0\r\nHost: {$this->Host}\r\n{$auth}Accept: */*\r\nConnection: close\r\n\r\n";
+      $requestBodyLength = strlen($Parameters);
+      $requestText = "POST {$URI} HTTP/1.0\r\nHost: {$this->Host}\r\n{$auth}Accept: */*\r\nContent-Type: application/json\r\nContent-Length: {$requestBodyLength}\r\n\r\n{$Parameters}\r\n";
+      //file_put_contents("request.txt", $requestText);
+      fwrite($streamfbOS, $requestText);
       if (!$skipResponse) {
         $r = stream_get_contents($streamfbOS);
         list(, $bodyJSON) = explode("\r\n\r\n", $r, 2);
@@ -102,16 +106,15 @@ class FindBoxCoreSystem
    */
   public function SaveProducts(string $barcode, string $name, array $dataFields): array
   {
-    $encodeStringsForFindBoxsystem = array_map('rawurlencode', $dataFields);
     $product = json_encode([[[
       "barcode" => $barcode,
-      "name1" => rawurlencode($name),
-      "datafields" => $encodeStringsForFindBoxsystem
+      "name1" => urlencode($name),
+      "datafields" => $dataFields
     ]]]);
 
     $URI = "/1.0.0/index.php/saveproducts/1.2.0/";
 
-    return $this->CallAPI("GET", $URI, $product);
+    return $this->CallAPI($URI, $product);
   }
 
   /**
@@ -125,20 +128,35 @@ class FindBoxCoreSystem
   {
     $URI = "/1.0.0/index.php/smartesl.bind/1.1.0/";
 
-    return $this->CallAPI("GET", $URI, "[\"{$labelId}\",\"{$barcode}\"]");
+    return $this->CallAPI($URI, "[\"{$labelId}\",\"{$barcode}\"]");
   }
 
   /**
    * Remove label from findbox system
    *
    * @param string $labelId
-   * @return array
+   * @return bool true if successfull else no barcode exist in findbox articles
    */
   public function UnBind(string $labelId): array
   {
-    $URI = "/1.0.0/index.php/smartesl.unbind/1.0.0/";
-
-    return $this->CallAPI("GET", $URI, "[\"{$labelId}\"]");
+    // Retrieve barcode associated to the label
+    $labelDetails = $this->CallAPI("/1.0.0/index.php/smartesl.getstatus/3.1.0/", "[[\"{$labelId}\"]]");
+    // If RSSI exist, label it is binded to system
+    if (isset($labelDetails['value']['value'][$labelId]['rssi'])) {
+      $barcode = $labelDetails['value']['value'][$labelId]['data']['barcode'];
+
+      $ret = $this->CallAPI("/1.0.0/index.php/smartesl.unbind/1.0.0/", "[\"{$labelId}\"]");
+      if ($ret['err'] != 0)
+        return $this->returnCode(1, 'Error on unbind');
+
+      $ret = $this->CallAPI("/1.0.0/index.php/deleteproducts/1.0.0/", "[\"{$barcode}\"]");
+      if ($ret['err'] != 0)
+        return $this->returnCode(1, 'Error on deleteproducts');
+
+      // All ok
+      return $this->returnCode(0, '');
+    } else
+      return $this->returnCode(1, 'No label exist on Findbox');
   }
 
 }

+ 16 - 19
src/Modules/Pages.php

@@ -17,7 +17,6 @@ class Pages extends BaseController
     parent::__construct($f3);
     $this->CORE_SETTINGS = $f3->get('CORE.fb');
     $this->findBoxCore = new \FindBoxCoreSystem(...array_values($this->CORE_SETTINGS));
-
   }
 
   public function Login($f3)
@@ -56,14 +55,9 @@ class Pages extends BaseController
         $distinta->CleanDistintaTable();
         $distinta->CopyDistinta($stepValues['consegna']);
 
-//        $CORE_SETTINGS = \F3::get('CORE.fb');
-//        $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
         $label = new \SmartESL($this->findBoxCore, [$stepValues['labelid']]);
         $label->BlinkSpecial(0, 1, 1000, 8, 0);
 
-        // TODO #RIMUOVERE_ASSOLUTAMENTE
-        $distinta->SaveLabelCarrello($stepValues['labelid'], $stepValues['labelid'], $stepValues['consegna']);
-
         $distinta->SaveProductsToFindBox('3', true, 50); // prende soltanto i primi 3 dalla tabella copia delle distinte
 
         $f3->set('COOKIE.p2l', json_encode($stepValues));
@@ -100,11 +94,7 @@ class Pages extends BaseController
             $codeFromLabelId = $distinta->GetBarcodeFromLabelId($pickedBarcode);
             $pickedBarcode = $codeFromLabelId ?? $pickedBarcode;
             if ($distinta->RemoveQuantity($pickedBarcode)) {
-              // BlinkOFF solo se non è lo stesso barcode precedente
-              // if ($distinta->GetArticleCount($pickedBarcode) == 0) {
               // SPEGNE LED ETICHETTA DOPO PICKING
-//              $CORE_SETTINGS = \F3::get('CORE.fb');
-//              $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
               $label = new \SmartESL($this->findBoxCore, [$distinta->GetLabelIdFromBarcode($pickedBarcode)]);
               $label->BlinkOff();
             } else {
@@ -122,8 +112,6 @@ class Pages extends BaseController
           $anomalie = $distinta->getAnomalieFromConsegne($datiCommessa['consegna']);
           $f3->set('LISTANOMALIE', $anomalie);
 
-//          $CORE_SETTINGS = $f3->get('CORE.fb');
-//          $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
           $label = new \SmartESL($this->findBoxCore, [$datiCommessa['labelid']]);
           $label->BlinkSpecial(0, 1, 5000, 8, 0);
           $distinta->SaveLabelCarrello($datiCommessa['labelid'], $datiCommessa['labelid'], $datiCommessa['consegna']);
@@ -135,9 +123,7 @@ class Pages extends BaseController
           }
         } else {
           // Seleziona le prossime tre etichette
-          foreach ($rowsDistinta as $rowDist) {
-//            $CORE_SETTINGS = $f3->get('CORE.fb');
-//            $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
+          foreach($rowsDistinta as $rowDist) {
             $labelId = $distinta->GetLabelIdFromBarcode($rowDist['barcode']);
             if ($labelId != null) {
               $label = new \SmartESL($this->findBoxCore, [$labelId]);
@@ -161,7 +147,7 @@ class Pages extends BaseController
     echo \Template::instance()->render('masterpage.tpl');
   }
 
-  public function Bind($f3, $args)
+  public function Bind($f3, array $args)
   {
     $stepValues = [];
     if ($args['step'] == 1)
@@ -175,8 +161,6 @@ class Pages extends BaseController
     $f3->set('COOKIE.bind', json_encode($stepValues));
 
     if ($args['step'] == 3) {
-//      $CORE_SETTINGS = $f3->get('CORE.fb');
-//      $findBoxCore = new \FindBoxCoreSystem(...array_values($CORE_SETTINGS));
       $this->findBoxCore->Bind($stepValues['labelid'], $stepValues['barcode']);
       $label = new \SmartESL($this->findBoxCore, [$stepValues['labelid']]);
 
@@ -218,11 +202,24 @@ class Pages extends BaseController
     echo \Template::instance()->render('masterpage.tpl');
   }
 
+  public function UnBind($f3, array $args)
+  {
+    $stepValues = array_map('strtoupper', $f3->get('POST'));
+    if ($args['step'] == 2) {
+      $success = $this->findBoxCore->UnBind($stepValues['labelid']);
+      if ($success['err'] <> 0) {
+        $f3->set('INFOTEXT', $success['value']);
+      }
+    }
+    $f3->set('STEP', $args['step']);
+    $f3->set('CONTENT', 'unbind.tpl');
+    echo \Template::instance()->render('masterpage.tpl');
+  }
+
   public function ElencoDistinta($f3)
   {
     $distinta = new \Distinta($f3);
     $f3->set('PRODUCTS', $distinta->getDistinte());
-
     $f3->set('CONTENT', 'distinta.tpl');
     echo \Template::instance()->render('masterpage.tpl');
   }

+ 8 - 9
src/SmartESL.php

@@ -64,15 +64,14 @@ class SmartESL
     );
 
     // TODO #NODISPLAY da sistemare
-    // $ver = $this->GetVersion();
-    $strFWVer = $firmwareStringVersion[4/*$ver[0]*/];
+    $strFWVer = $firmwareStringVersion[4];
 
     $uriParams = json_encode(array_merge(
       array($this->labels),
-      $params[4/*$ver[0]*/]));
+      $params[4]));
 
     $URI = "/1.0.0/index.php/smartesl.blink_special/{$strFWVer}/";
-    $this->core->CallAPI("GET", $URI, $uriParams, true);
+    $this->core->CallAPI($URI, $uriParams, true);
   }
 
   /**
@@ -81,9 +80,9 @@ class SmartESL
   public function BlinkOff()
   {
     $URI = "/1.0.0/index.php/smartesl.blink_special/1.1.0/";
-    $this->core->CallAPI("GET", $URI, "[[\"{$this->labels[0]}\"],3,1,500,1,1]", true);
+    $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("GET", $URI, "[[\"{$this->labels[0]}\"],0,1,1,500,1,1]", true);
+//    $this->core->CallAPI($URI, "[[\"{$this->labels[0]}\"],0,1,1,500,1,1]", true);
   }
 
   /**
@@ -94,7 +93,7 @@ class SmartESL
   {
     $labels = json_encode(array($this->labels));
     $URI = "/1.0.0/index.php/smartesl.getstatus/3.1.0/";
-    $ret = $this->core->CallAPI("GET", $URI, $labels);
+    $ret = $this->core->CallAPI($URI, $labels);
     if ($ret['err'] == 0 && $ret['value']['code'] == 0) {
       return $ret['value']['value'];
     }
@@ -111,13 +110,13 @@ class SmartESL
       $templateId,
       1, 1));
 
-    return $this->core->CallAPI("POST", $URI, $params);
+    return $this->core->CallAPI($URI, $params);
 
   }
 
   public function GetLabelMatch()
   {
     $URI = "/1.0.0/index.php/smartesl.getlabelmatch/1.2.0/";
-    return $this->core->CallAPI("GET", $URI, json_encode(array($this->labels)));
+    return $this->core->CallAPI($URI, json_encode(array($this->labels)));
   }
 }

+ 21 - 21
ui/homemenu.tpl

@@ -1,27 +1,27 @@
 <include href="bars.tpl"/>
 
 <div class="row h-100">
-    <div class="col-md-12 align-self-center">
-        <div class="content">
-            <div class="row justify-content-center">
-                <div class="col-md-2 m-3">
-                    <img class="img-fluid disablebutton" src="ui/images/utente.png"/>
-                </div>
-                <div class="col-md-2 m-2">
-                    <a href="{{@BASEURL}}/elencodistinta"><img class="img-fluid" src="ui/images/elenco_distinta.png"/></a>
-                </div>
-                <div class="col-md-2 m-3">
-                    <a href="{{@BASEURL}}/pick2light/1"><img class="img-fluid" src="ui/images/pick2light.png"/></a>
-                </div>
-            </div>
-            <div class="row justify-content-center">
-                <div class="col-md-2 m-3">
-                    <a href="{{@BASEURL}}/bind/1"><img class="img-fluid" src="ui/images/bind.png"/></a>
-                </div>
-                <div class="col-md-2 m-3">
-                    <img class="img-fluid disablebutton" src="ui/images/bindcarrello.png"/>
-                </div>
-            </div>
+  <div class="col-md-12 align-self-center">
+    <div class="content">
+      <div class="row justify-content-center">
+        <div class="col-md-2 m-3">
+          <img class="img-fluid disablebutton" src="ui/images/utente.png"/>
         </div>
+        <div class="col-md-2 m-2">
+          <a href="{{@BASEURL}}/elencodistinta"><img class="img-fluid" src="ui/images/elenco_distinta.png"/></a>
+        </div>
+        <div class="col-md-2 m-3">
+          <a href="{{@BASEURL}}/pick2light/1"><img class="img-fluid" src="ui/images/pick2light.png"/></a>
+        </div>
+      </div>
+      <div class="row justify-content-center">
+        <div class="col-md-2 m-3">
+          <a href="{{@BASEURL}}/bind/1"><img class="img-fluid" src="ui/images/bind.png"/></a>
+        </div>
+        <div class="col-md-2 m-3">
+          <a href="{{@BASEURL}}/unbind/1"><img class="img-fluid" src="ui/images/bindcarrello.png"/></a>
+        </div>
+      </div>
     </div>
+  </div>
 </div>

+ 27 - 27
ui/pick2light.tpl

@@ -1,31 +1,31 @@
 <include href="bars.tpl"/>
 
 <div class="row h-100 justify-content-center">
-    <check if="{{ @STEP < 4 }}">
-        <div class="col-md-5 align-self-center">
-            <form class="form" method="post" action="{{@BASEURL}}/pick2light/{{@STEP+1}}">
-                <input type="submit" hidden id="submitform"/>
-                <select name="consegna" class="form-control form-control-lg bg-secondary mb-3" onchange="javascript:$('#submitform').click()">
-                    <option {{isset(@PAGEVALUES.consegna) ? '' : 'selected'}} >Seleziona una distinta</option>
-                    <repeat group="{{ @DISTINTE }}" value="{{ @DISTINTA }}">
-                        <option {{@PAGEVALUES.consegna == @@DISTINTA.consegna ? 'selected' : ''}} value="{{@@DISTINTA.consegna}}">{{@@DISTINTA.consegna}} - {{@@DISTINTA.data_creazione}} - {{@@DISTINTA.time_creazione}} - {{@@DISTINTA.destinazione_merci}}</option>
-                    </repeat>
-                </select>
-                <check if="{{ @STEP > 1}}">
-                    <input type="text" name="labelid" {{ @STEP==2 ? 'autofocus' : ''}} value="{{@PAGEVALUES.labelid}}" class="form-control form-control-lg mb-3" placeholder="Codice etichetta" required autocomplete="false"/>
-                </check>
-                <check if="{{ isset(@INFOTEXT) }}">
-                    <div class="alert alert-info mt-3" role="alert">
-                        {{@INFOTEXT}}
-                    </div>
-                </check>
-            </form>
-        </div>
-    </check>
-    <check if="{{ @STEP == 4 }}">
-        <include href="pick2light_savingproducts.tpl"/>
-    </check>
-    <check if="{{ @STEP == 5 }}">
-        <include href="pick2light_picks.tpl"/>
-    </check>
+  <check if="{{ @STEP < 4 }}">
+    <div class="col-md-5 align-self-center">
+      <form class="form" method="post" action="{{@BASEURL}}/pick2light/{{@STEP+1}}">
+        <input type="submit" hidden id="submitform"/>
+        <select name="consegna" class="form-control form-control-lg bg-secondary mb-3" onchange="javascript:$('#submitform').click()">
+          <option {{isset(@PAGEVALUES.consegna) ? '' : 'selected'}} >Seleziona una distinta</option>
+          <repeat group="{{ @DISTINTE }}" value="{{ @DISTINTA }}">
+            <option {{@PAGEVALUES.consegna == @@DISTINTA.consegna ? 'selected' : ''}} value="{{@@DISTINTA.consegna}}">{{@@DISTINTA.consegna}} - {{@@DISTINTA.data_creazione}} - {{@@DISTINTA.time_creazione}} - {{@@DISTINTA.destinazione_merci}}</option>
+          </repeat>
+        </select>
+        <check if="{{ @STEP > 1}}">
+          <input type="text" name="labelid" {{ @STEP==2 ? 'autofocus' : ''}} value="{{@PAGEVALUES.labelid}}" class="form-control form-control-lg mb-3" placeholder="Codice etichetta" required autocomplete="false"/>
+        </check>
+        <check if="{{ isset(@INFOTEXT) }}">
+          <div class="alert alert-info mt-3" role="alert">
+            {{@INFOTEXT}}
+          </div>
+        </check>
+      </form>
+    </div>
+  </check>
+  <check if="{{ @STEP == 4 }}">
+    <include href="pick2light_savingproducts.tpl"/>
+  </check>
+  <check if="{{ @STEP == 5 }}">
+    <include href="pick2light_picks.tpl"/>
+  </check>
 </div>

+ 87 - 85
ui/pick2light_picks.tpl

@@ -1,98 +1,100 @@
 <div class="col-md-8 align-self-center">
 
+  <check if="{{ !isset(@LISTANOMALIE) }}">
     <div class="alert alert-warning mt-3 text-center" role="alert">
-        PICKING ATTIVO!!
+      PICKING ATTIVO!!
     </div>
 
     <form class="form" method="post" action="{{@BASEURL}}/pick2light/{{@STEP}}">
-        <input type="submit" hidden id="submitform"/>
-        <check if="{{ isset(@ANOMALIA) }}">
-            <input type="hidden" hidden name="anomalia" value="1"/>
-        </check>
-        <input type="text" name="pickedlabelid" autofocus class="form-control form-control-lg mb-3" placeholder="Prodotto" required autocomplete="false"/>
+      <input type="submit" hidden id="submitform"/>
+      <check if="{{ isset(@ANOMALIA) }}">
+        <input type="hidden" hidden name="anomalia" value="1"/>
+      </check>
+      <input type="text" name="pickedlabelid" autofocus class="form-control form-control-lg mb-3" placeholder="Prodotto" required autocomplete="false"/>
     </form>
+  </check>
 
-    <check if="{{ isset(@ANOMALIA) }}">
-        <div class="alert alert-light mt-3 text-center" role="alert">
-            {{@ANOMALIA}}
-        </div>
-    </check>
+  <check if="{{ isset(@ANOMALIA) }}">
+    <div class="alert alert-light mt-3 text-center" role="alert">
+      {{@ANOMALIA}}
+    </div>
+  </check>
 
-    <check if="{{ isset(@INFOTEXT) }}">
-        <div class="alert alert-danger mt-3 text-center" role="alert">
-            {{@INFOTEXT}}
-        </div>
-    </check>
+  <check if="{{ isset(@INFOTEXT) }}">
+    <div class="alert alert-danger mt-3 text-center" role="alert">
+      {{@INFOTEXT}}
+    </div>
+  </check>
 
-    <check if="{{ count(@PRODUCTS) }}">
-        <true>
-            <div class="table-responsive" style="max-height: 400px; overflow-y: auto">
-                <table class="table table-striped table-dark">
-                    <thead>
-                    <tr>
-                        <th class="text-center text-uppercase" colspan="6" scope="col">Articoli da prelevare</th>
-                    </tr>
-                    </thead>
-                    <thead>
-                    <tr>
-                        <th scope="col">Barcode</th>
-                        <th scope="col">Descrizione</th>
-                        <th scope="col">Origine</th>
-                        <th scope="col">Ubicazione</th>
-                        <th scope="col">Quantità</th>
-                        <th scope="col">Sequenza</th>
-                    </tr>
-                    </thead>
-                    <tbody>
-                    <repeat group="{{ @PRODUCTS }}" value="{{ @PRODUCT }}">
-                        <tr>
-                            <th scope="row">{{@PRODUCT.barcode}}</th>
-                            <td>{{@PRODUCT.descrizione}}</td>
-                            <td>{{@PRODUCT.origine}}</td>
-                            <td>{{@PRODUCT.ubicazione}}</td>
-                            <td>{{@PRODUCT.qta_prelevare}}</td>
-                            <td>{{@PRODUCT.sequenza}}</td>
-                        </tr>
-                    </repeat>
-                    </tbody>
-                </table>
-            </div>
-        </true>
+  <check if="{{ count(@PRODUCTS) }}">
+    <true>
+      <div class="table-responsive" style="max-height: 400px; overflow-y: auto">
+        <table class="table table-striped table-dark">
+          <thead>
+          <tr>
+            <th class="text-center text-uppercase" colspan="6" scope="col">Articoli da prelevare</th>
+          </tr>
+          </thead>
+          <thead>
+          <tr>
+            <th scope="col">Barcode</th>
+            <th scope="col">Descrizione</th>
+            <th scope="col">Origine</th>
+            <th scope="col">Ubicazione</th>
+            <th scope="col">Quantità</th>
+            <th scope="col">Sequenza</th>
+          </tr>
+          </thead>
+          <tbody>
+          <repeat group="{{ @PRODUCTS }}" value="{{ @PRODUCT }}">
+            <tr>
+              <th scope="row">{{@PRODUCT.barcode}}</th>
+              <td>{{@PRODUCT.descrizione}}</td>
+              <td>{{@PRODUCT.origine}}</td>
+              <td>{{@PRODUCT.ubicazione}}</td>
+              <td>{{@PRODUCT.qta_prelevare}}</td>
+              <td>{{@PRODUCT.sequenza}}</td>
+            </tr>
+          </repeat>
+          </tbody>
+        </table>
+      </div>
+    </true>
+    <false>
+      <check if="{{ isset(@LISTANOMALIE) }}">
         <false>
-            <check if="{{ isset(@LISTANOMALIE) }}">
-                <false>
-                    <div class="alert alert-success mt-3 text-center" role="alert">
-                        Picking list terminata.
-                    </div>
-                </false>
-                <true>
-                    <div class="table-responsive" style="max-height: 400px; overflow-y: auto">
-                        <table class="table table-striped table-dark">
-                            <thead>
-                            <tr>
-                                <th style="color: red" class="text-center text-uppercase" colspan="6" scope="col">Anomalie presenti</th>
-                            </tr>
-                            </thead>
-                            <thead>
-                            <tr>
-                                <th scope="col">Barcode</th>
-                                <th scope="col">Descrizione</th>
-                                <th scope="col">Quantità</th>
-                            </tr>
-                            </thead>
-                            <tbody>
-                            <repeat group="{{ @LISTANOMALIE }}" value="{{ @PRODUCT }}">
-                                <tr>
-                                    <th scope="row">{{@PRODUCT.barcode}}</th>
-                                    <td>{{@PRODUCT.descrizione}}</td>
-                                    <td>{{@PRODUCT.qta_prelevare}}</td>
-                                </tr>
-                            </repeat>
-                            </tbody>
-                        </table>
-                    </div>
-                </true>
-            </check>
+          <div class="alert alert-success mt-3 text-center" role="alert">
+            Picking list terminata.
+          </div>
         </false>
-    </check>
+        <true>
+          <div class="table-responsive" style="max-height: 400px; overflow-y: auto">
+            <table class="table table-striped table-dark">
+              <thead>
+              <tr>
+                <th style="color: red" class="text-center text-uppercase" colspan="6" scope="col">Anomalie presenti</th>
+              </tr>
+              </thead>
+              <thead>
+              <tr>
+                <th scope="col">Barcode</th>
+                <th scope="col">Descrizione</th>
+                <th scope="col">Quantità</th>
+              </tr>
+              </thead>
+              <tbody>
+              <repeat group="{{ @LISTANOMALIE }}" value="{{ @PRODUCT }}">
+                <tr>
+                  <th scope="row">{{@PRODUCT.barcode}}</th>
+                  <td>{{@PRODUCT.descrizione}}</td>
+                  <td>{{@PRODUCT.qta_prelevare}}</td>
+                </tr>
+              </repeat>
+              </tbody>
+            </table>
+          </div>
+        </true>
+      </check>
+    </false>
+  </check>
 </div>

+ 9 - 9
ui/pick2light_savingproducts.tpl

@@ -1,13 +1,13 @@
 <div class="col-md-5 align-self-center">
-    <div class="progress" style="height: 50px">
-        <div class="progress-bar progress-bar-striped progress-bar-animated bg-warning" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%; color: black; font-size: 15pt">
-            Salvataggio prodotti, attendere prego
-        </div>
+  <div class="progress" style="height: 50px">
+    <div class="progress-bar progress-bar-striped progress-bar-animated bg-warning" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%; color: black; font-size: 15pt">
+      Salvataggio prodotti, attendere prego
     </div>
-    <script>
-        setTimeout(function() {
-            window.location.href = "{{@BASEURL}}/pick2light/5"
-        }, 2000)
-    </script>
+  </div>
+  <script>
+    setTimeout(function () {
+      window.location.href = "{{@BASEURL}}/pick2light/5"
+    }, 2000)
+  </script>
 
 </div>

+ 27 - 0
ui/unbind.tpl

@@ -0,0 +1,27 @@
+<include href="bars.tpl"/>
+
+<div class="row h-100 justify-content-center">
+  <div class="col-md-5 align-self-center">
+    <form class="form" method="post" action="{{@BASEURL}}/unbind/{{@STEP+1}}">
+      <input type="submit" hidden id="submitform"/>
+      <input autofocus type="text" name="labelid" class="form-control form-control-lg" placeholder="Label ID" required autocomplete="false" value=""/>
+    </form>
+    <check if="{{ @STEP == 2 }}">
+      <div class="alert alert-info mt-5" role="alert">
+        Invio unbind
+      </div>
+      <check if="{{ isset(@INFOTEXT) }}">
+        <true>
+          <div class="alert alert-danger mt-3 text-center" role="alert">
+            {{@INFOTEXT}}
+          </div>
+        </true>
+        <false>
+          <script>
+            window.location.href = "{{@BASEURL}}/unbind/1";
+          </script>
+        </false>
+      </check>
+    </check>
+  </div>
+</div>