Browse Source

RC3:
* ADD: trash button in picking list
* ADD: isServerAlive() for check availability of Soap Server
* FIX: query in picking list view
* optimized notification class

Giancarlo Voci 8 years ago
parent
commit
0311a460f9

+ 2 - 1
cfg/config - dimatec.ini

@@ -23,7 +23,8 @@ ICON_LOGOUT={{@BASEURL}}/ui/images/logout.png
 CUSTOMERNAME=dimatec
 
 [CORE.fb]
-host=192.168.1.140
+host=192.168.0.73
+;host=192.168.1.140
 port=50443
 key=C0000000000011474023057
 pass=ZrgzkvJrOKnNSCnPnGz3u{A6eHSNXVvs

+ 0 - 121
dbschema.sql

@@ -1,121 +0,0 @@
--- Adminer 4.6.3 MySQL dump
-
-SET NAMES utf8;
-SET time_zone = '+00:00';
-SET foreign_key_checks = 0;
-SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
-
-SET NAMES utf8mb4;
-
-DROP DATABASE IF EXISTS `omlink`;
-CREATE DATABASE `omlink` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
-USE `omlink`;
-
-DROP TABLE IF EXISTS `articles`;
-CREATE TABLE `articles` (
-  `stazione` varchar(255) NOT NULL,
-  `divisione` varchar(10) NOT NULL,
-  `magazzino` varchar(10) NOT NULL,
-  `tipo_magazzino` varchar(10) NOT NULL,
-  `area_magazzino` varchar(10) NOT NULL,
-  `ubicazione` varchar(255) NOT NULL,
-  `materiale` varchar(255) NOT NULL,
-  `descrizione` varchar(255) NOT NULL,
-  `incc_intr` varchar(10) NOT NULL,
-  `cont_std` varchar(10) NOT NULL,
-  `tipo_contenitore` varchar(10) NOT NULL,
-  `qta_contenitore` varchar(10) NOT NULL,
-  `qta_riordino` varchar(10) NOT NULL,
-  `sequenza` varchar(10) NOT NULL,
-  `dummy01` varchar(10) DEFAULT NULL,
-  PRIMARY KEY (`materiale`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-
-
-DROP TABLE IF EXISTS `distinte`;
-CREATE TABLE `distinte` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `idUtente` int(11) NOT NULL DEFAULT -1,
-  `commessa` varchar(255) NOT NULL DEFAULT '',
-  `barcode` varchar(255) NOT NULL DEFAULT '',
-  `descrizione` varchar(255) NOT NULL DEFAULT '',
-  `data_creazione` date NOT NULL DEFAULT current_timestamp(),
-  `time_creazione` time NOT NULL DEFAULT current_timestamp(),
-  `qta_prelevare` int(11) NOT NULL DEFAULT 0,
-  `qta_mancante` int(11) NOT NULL DEFAULT 0,
-  `deleted` tinyint(4) NOT NULL DEFAULT 0,
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-
-INSERT INTO `distinte` (`id`, `idUtente`, `commessa`, `barcode`, `descrizione`, `data_creazione`, `time_creazione`, `qta_prelevare`, `qta_mancante`, `deleted`) VALUES
-(1,	1,	'180300428900200     ',	'FAA C245-DX    ',	'COMPASSO L245/230 DX.MANIGLIA GRIG.',	'2018-09-17',	'18:18:56',	1,	0,	0),
-(2,	1,	'180300428900300     ',	'FAA C245-SX    ',	'COMPASSO L245/230 SX-MANIGLIA GRIG.',	'2018-09-17',	'18:18:56',	1,	0,	0),
-(3,	1,	'180300428900100     ',	'F23 1450X650S  ',	'FINESTRA COMPASSO C/SERIGRAFIA GRIG',	'2018-09-17',	'18:18:56',	1,	0,	0),
-(4,	1,	'180300428900500     ',	'F23 1450X650S  ',	'FINESTRA COMPASSO C/SERIGRAFIA GRIG',	'2018-09-17',	'18:18:56',	1,	0,	0),
-(5,	1,	'180800430200200     ',	'030 M16TSI     ',	'PLAFON.MODUL.16W/12V ARGENTO INTERR',	'2018-09-17',	'18:18:56',	1,	0,	0),
-(6,	1,	'180300430200100     ',	'030 PL13S      ',	'LAMPADA COMP.NEON12V/13W ARG.      ',	'2018-09-17',	'18:18:56',	1,	0,	0),
-(7,	1,	'180907376100500     ',	'015 G10-Z8     ',	'RACCORDO DIRITTO 10MM/TUBO 8MM X VK',	'2018-09-17',	'18:18:56',	5,	0,	0),
-(8,	1,	'180907376100100     ',	'018 2006.998   ',	'AERATORE 22X1 F PER RUBINETTI      ',	'2018-09-17',	'18:18:56',	10,	0,	0),
-(9,	1,	'180907376100200     ',	'018 2006.999   ',	'AERATORE 24X1 M PER MONOLEVA CROMO ',	'2018-09-17',	'18:18:56',	10,	0,	0),
-(10,	1,	'180907376100100     ',	'030 HA10X10Y   ',	'LAMPADINA ALOG.12V/10W G4 BLIS.10PZ',	'2018-09-17',	'18:18:56',	1,	0,	0),
-(11,	1,	'180907376100400     ',	'015 50410.14Y  ',	'TUBO GAS AP 450 CON SECURITY IT-BL.',	'2018-09-17',	'18:18:56',	3,	0,	0),
-(12,	1,	'180907382700500     ',	'F48 MAN-P      ',	'MANIGLIA POLYFIX X FIN.F20/23/24/26',	'2018-09-17',	'18:18:56',	1,	0,	0);
-
-DROP TABLE IF EXISTS `label_bindings`;
-CREATE TABLE `label_bindings` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `label_id` varchar(255) NOT NULL,
-  `barcode` varchar(255) NOT NULL,
-  `descrizione` varchar(255) NOT NULL,
-  `template_id` varchar(255) NOT NULL DEFAULT '0',
-  `esl_datafields` varchar(5000) NOT NULL COMMENT 'FindBox Articles datafields in JSON format',
-  `qr_code` varchar(255) DEFAULT NULL,
-  `qta_prelevare` int(11) NOT NULL DEFAULT 0,
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-
-INSERT INTO `label_bindings` (`id`, `label_id`, `barcode`, `descrizione`, `template_id`, `esl_datafields`, `qr_code`, `qta_prelevare`) VALUES
-(1,	'0105E104',	'180300428900100',	'180300428900100',	'dimatec2_2',	'{\"Q.ta\":0,\"Commessa\":\"180300428900100\"}',	NULL,	0),
-(2,	'011133B5',	'180300428900200',	'180300428900200',	'dimatec2_2',	'{\"Q.ta\":0,\"Commessa\":\"180300428900200\"}',	NULL,	0),
-(3,	'0105A8DE',	'180300428900300',	'180300428900300',	'dimatec2_2',	'{\"Q.ta\":0,\"Commessa\":\"180300428900300\"}',	NULL,	0),
-(5,	'010423C5',	'180300428900500',	'180300428900500',	'dimatec2_2',	'{\"Q.ta\":0,\"Commessa\":\"180300428900500\"}',	NULL,	0),
-(6,	'011282AF',	'180300430200100',	'180300430200100',	'dimatec2_2',	'{\"Q.ta\":0,\"Commessa\":\"180300430200100\"}',	NULL,	0);
-
-DROP TABLE IF EXISTS `notifications`;
-CREATE TABLE `notifications` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `code` int(11) NOT NULL DEFAULT 0,
-  `caption` varchar(255) NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `link` varchar(255) NOT NULL DEFAULT '#',
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-
-INSERT INTO `notifications` (`id`, `code`, `caption`, `timestamp`, `link`) VALUES
-(1,	12,	'Battery labels low',	'2018-09-12 10:09:09',	'/bind'),
-(2,	12,	'Battery labels low',	'2018-09-12 10:09:09',	'/bind'),
-(3,	11,	'FindBox server doesn\'t respond',	'2018-09-12 10:09:27',	'/');
-
-DROP TABLE IF EXISTS `queuesystem`;
-CREATE TABLE `queuesystem` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `servicename` varchar(255) NOT NULL,
-  `timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
-  `command` varchar(5000) NOT NULL,
-  PRIMARY KEY (`id`)
-) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4;
-
-
-DROP TABLE IF EXISTS `users`;
-CREATE TABLE `users` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `username` varchar(255) NOT NULL,
-  `saltedpassword` varchar(255) NOT NULL,
-  `roles` varchar(4096) NOT NULL DEFAULT '{}',
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-
-INSERT INTO `users` (`id`, `username`, `saltedpassword`, `roles`) VALUES
-(1,	'operatore1',	'$2y$10$Vd0Uv.h848Xj8HtuqMBO.OvSLp8ycQpSgveHb.bH4tl72iTCgpvay',	'a:1:{i:0;s:10:\"importdata\";}');
-
--- 2018-09-18 13:19:15

+ 9 - 1
src/Modules/Dimatec/Distinta.php

@@ -25,6 +25,14 @@ class Distinta
     $this->userId = $f3->get('USER')->id;
   }
 
+  /**
+   * Delete from table all commesse present
+   */
+  public function TrashCommesse()
+  {
+    $this->dbHandle->exec("DELETE FROM `distinte` WHERE deleted=0");
+  }
+
   /**
    * Virtual delete and article of a commessa by set deleted=1 in database field
    *
@@ -60,7 +68,7 @@ class Distinta
   public function UnbindAll()
   {
     global $f3;
-    
+
     $labels = $this->dbHandle->exec('SELECT label_id FROM label_bindings');
     foreach($labels as $label) {
       $msgDisplay = new QueueCommand($label['label_id']);

+ 7 - 1
src/Modules/Dimatec/MigrationData.php

@@ -55,9 +55,14 @@ class MigrationData
   /**
    * Create the connection client to a SOAP server
    * @param string $serverAddress IP Address
+   * @throws \Exception
    */
   public function SoapConnector(string $serverAddress)
   {
+    global $frameworkUtils;
+    if($frameworkUtils->isServerAlive($serverAddress, 80, 2)>0)
+      throw new \Exception('Magazzino Verticale non raggiungibile');
+
     $this->soapClient = new \SoapClient("http://$serverAddress/servizi_xchange.asmx?wsdl", array(
       'trace' => true,
       'exceptions' => true,
@@ -80,7 +85,7 @@ class MigrationData
    * Set mission status on AS400
    * @param $listaId
    */
-  public function InitializeMissions($listaId)
+  public function InitializeMissionsToPending($listaId)
   {
     $ids = join(", ", $this->db2RowsId);
     $this->query("UPDATE SMEDAT_DIM.INTMAV0F SET MXSTAT=" . MigrationData::STATUS_PENDING . ", MXNOLS='$listaId' WHERE MXIDDM IN ($ids)");
@@ -256,6 +261,7 @@ EOF;
     return <<<EOF
 SELECT `uds`, `barcode`, `descrizione`, SUM(`qta_prelevare`) AS `qta`
 FROM `distinte`
+WHERE deleted=0
 GROUP BY `barcode`
 ORDER BY `uds`
 EOF;

+ 7 - 1
src/Modules/Dimatec/Pages.php

@@ -132,6 +132,12 @@ class Pages extends Controller
                 }*/
         $f3->set('COMMESSE', $commesse);
         break;
+      case 3: // empty list
+        $distinteDaCancellare = new Distinta();
+        $distinteDaCancellare->TrashCommesse();
+        $f3->reroute("/pick2light/1");
+        return;
+        break;
     }
 
     $migData = new MigrationData();
@@ -274,7 +280,7 @@ class Pages extends Controller
         $f3->set('IMPORT_RESULT', "Liste inviate correttamente al Magazzino Verticale<br/><br/>Righe con massimizzazione importate: $count");
 
         $migData->selectAvailableMissions('SCARICO');
-        $migData->InitializeMissions($idList);
+        $migData->InitializeMissionsToPending($idList);
       }
     }
 

+ 10 - 9
src/OpenMind/System/Notifications.php

@@ -14,12 +14,9 @@ class Notifications extends Mapper
 {
   const FB_NOTALIVE = 11;
 
-  private $f3;
-
   public function __construct()
   {
     global $f3;
-    $this->f3 = $f3;
 
     parent::__construct($f3->get('DB'), 'notifications');
   }
@@ -44,15 +41,19 @@ class Notifications extends Mapper
    */
   public function emptyAll()
   {
-    $this->f3->get('DB')->exec('TRUNCATE TABLE notifications');
+    global $f3;
+
+    $f3->get('DB')->exec('TRUNCATE TABLE notifications');
   }
 
   public function notify(int $code, string $caption, $link = '#')
   {
-    $this->reset();
-    $this->code = $code;
-    $this->caption = $caption;
-    $this->link = $link;
-    $this->save();
+    if (true/*$this->check($code)*/) {
+      $this->reset();
+      $this->code = $code;
+      $this->caption = $caption;
+      $this->link = $link;
+      $this->save();
+    }
   }
 }

+ 3 - 3
src/OpenMind/System/OMUtils.php

@@ -110,17 +110,17 @@ class OMUtils
   }
 
   /**
-   * Check if a port server is opened, return error code of fsockopen function
+   * Check if a port server is opened, return $errno code of fsockopen function
    *
    * @param string $ip
    * @param int $port
    * @param int $mstimeout timeout of check in milliseconds
    * @return int
    */
-  function isServerAlive(string $ip, int $port, int $mstimeout = 1000): int
+  function isServerAlive(string $ip, int $port, int $timeout_sec = 5): int
   {
     try {
-      @fclose($sck = @fsockopen($ip, $port, $errno, $errstr, $mstimeout));
+      @fclose($sck = @fsockopen($ip, $port, $errno, $errstr, $timeout_sec));
     } catch (\Exception $e) {
       die($e->getMessage());
     }

+ 6 - 4
src/OpenMind/System/System.php

@@ -70,10 +70,12 @@ class System extends PluginStrategy
     $qs = new QueueSystem('FindBoxService_isAlive');
     if (!$qs->check()) {
       $lastUpdate = time() - $qs->command;
-      if ($lastUpdate > $f3->get('FINDBOXSERVICE.SLEEPTIME') + 5) {
+      if ($lastUpdate > $f3->get('FINDBOXSERVICE.SLEEPTIME') + 2) { // 2 secondi come piccolo delay
         $omlNotifications = new Notifications();
-        if ($omlNotifications->check(Notifications::FB_NOTALIVE))
-          $omlNotifications->notify(Notifications::FB_NOTALIVE, 'Errore: Servizio di FindBox non disponibile');
+        $omlNotifications->notify(Notifications::FB_NOTALIVE, 'Errore: Servizio di FindBox non disponibile');
+      } else {
+        $omlNotifications = new Notifications();
+        $omlNotifications->Remove(Notifications::FB_NOTALIVE);
       }
     }
 
@@ -98,5 +100,5 @@ class System extends PluginStrategy
   }
 }
 
-/** @var System $System **/
+/** @var System $System * */
 Global $System;

+ 1 - 1
ui/header.tpl

@@ -2,7 +2,7 @@
 	<a href="{{@BASEURL}}/"><img class="img-fluid om-shadow navbar-brand customerlogo" src="{{@LOGO_CUSTOMER}}"/></a>
 	<div class="ml-auto dropdown dropleft navbar-brand">
 		<a id="notification_area_button" class="disabled" href="javascript:void(0)" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="mr-3" style="position: relative">
-			<span>&#x1f514;</span>
+			<img src="{{@BASEURL}}/ui/images/bell.png"/>
 			<span id="sysmsgnum" class="blink badge badge-light"></span>
 		</a>
 		<div id="notification_area" class="dropdown-menu" aria-labelledby="dropdownMenuButton"></div>

+ 9 - 11
ui/homemenu.tpl

@@ -1,11 +1,9 @@
-<div class="d-flex flex-wrap justify-content-around align-items-center flex-fill">
-	<repeat group="{{@GLOBALMENU}}" value="{{@menuitem}}">
-		<div class="text-center m-2">
-			<check if="{{ !empty(@menuitem.url) }}">
-				<a href="{{@BASEURL . '/' . @menuitem.url}}">
-					<img class="img-fluid {{@menuitem.imgClass}} imgbuttonmenu" src="{{@menuitem.image}}"/>
-				</a>
-			</check>
-		</div>
-	</repeat>
-</div>
+<repeat group="{{@GLOBALMENU}}" value="{{@menuitem}}">
+	<div class="text-center m-2">
+		<check if="{{ !empty(@menuitem.url) }}">
+			<a href="{{@BASEURL . '/' . @menuitem.url}}">
+				<img class="img-fluid {{@menuitem.imgClass}} imgbuttonmenu" src="{{@menuitem.image}}"/>
+			</a>
+		</check>
+	</div>
+</repeat>

+ 9 - 0
ui/js/omlink.js

@@ -56,7 +56,16 @@ function NotificationDelete(link, code) {
     });
 }
 
+function SetupConfirmationDialog() {
+  $('.requestconfirm').on('click', function (ev) {
+    if (!confirm('Sicuro di voler cancellare la lista?'))
+      ev.preventDefault();
+  });
+}
+
 $(function () {
+  SetupConfirmationDialog();
+
   refreshNotificationArea();
 
   $('form').on('submit', function () {

+ 1 - 1
ui/masterpage.tpl

@@ -15,7 +15,7 @@
 
 <include href="header.tpl"/>
 
-<div class="d-flex px-0 justify-content-around" style="height: calc(100% - 150px); overflow: auto">
+<div class="d-flex flex-row justify-content-around align-items-center" style="overflow-y: auto; height: calc(100% - 150px)">
 	<include if="{{isset(@CONTENT)}}" href="{{@CONTENT}}"/>
 </div>
 

+ 5 - 3
ui/pick2light.tpl

@@ -1,5 +1,5 @@
 <div class="row h-100 justify-content-center w-100">
-	<div class="col-xs-3 col-md-3 col-lg-2 align-self-center">
+	<div class="col-md-4 align-self-center">
 		<form class="form" method="post" action="{{@BASEURL}}/pick2light/{{@NEXTSTEP}}">
 			<check if="{{ isset(@INFOTEXT) }}">
 				<div class="alert alert-danger" role="alert">
@@ -41,12 +41,14 @@
 
 		</form>
 	</div>
-	<div class="col-xs-9 col-md-9 col-lg-10 align-self-center">
+	<div class="col-md-8">
 		<div class="table-responsive">
 			<table class="table table-striped table-secondary" style="font-size: 10pt;">
 				<thead>
 				<tr style="font-size: 12pt" class="bg-warning">
-					<th class="text-center text-uppercase" colspan="6" scope="col">Articoli da ventilare</th>
+					<th class="text-center text-uppercase" colspan="6" scope="col">Articoli da ventilare
+						<a class="requestconfirm" href="{{@BASEURL}}/pick2light/3"><img class="float-right" src="{{@BASEURL}}/ui/images/delete.png"/></a>
+					</th>
 				</tr>
 				<tr style="font-size: 12pt" class="bg-warning">
 					<th scope="col">UDS</th>