Giancarlo Voci 7 years ago
parent
commit
e9181071b4

+ 9 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
 	"name": "omlink",
 	"name": "omlink",
-	"version": "1.9.34",
+	"version": "1.9.36",
 	"codename": "Barricade",
 	"codename": "Barricade",
 	"private": true,
 	"private": true,
 	"description": "OM-Link Engine",
 	"description": "OM-Link Engine",
@@ -14,6 +14,14 @@
 	},
 	},
 	"dependencies": {
 	"dependencies": {
 		"bootstrap": "^4.3.1",
 		"bootstrap": "^4.3.1",
+		"datatables.net": "^1.10.19",
+		"datatables.net-bs4": "^1.10.19",
+		"datatables.net-buttons": "^1.5.6",
+		"datatables.net-buttons-bs4": "^1.5.6",
+		"datatables.net-responsive": "^2.2.3",
+		"datatables.net-responsive-bs4": "^2.2.3",
+		"datatables.net-select": "^1.3.0",
+		"datatables.net-select-bs4": "^1.3.0",
 		"jquery": "^3.4.1",
 		"jquery": "^3.4.1",
 		"popper.js": "^1.15.0"
 		"popper.js": "^1.15.0"
 	},
 	},

+ 67 - 97
src/Modules/Blank/Pages.php

@@ -22,103 +22,6 @@ class Pages extends Controller
 	 */
 	 */
 	public function HelloWorld($f3)
 	public function HelloWorld($f3)
 	{
 	{
-		$labels = [
-			'0113067F',
-			'011306C5',
-			'01130713',
-			'01130747',
-			'011307A4',
-			'011307B4',
-			'01130D98',
-			'01130D9A',
-			'01130DA5',
-			'01130E03',
-			'01130E27',
-			'01130F13',
-			'01131170',
-			'01131749',
-			'0113174B',
-			'01131777',
-			'01131797',
-			'01131798',
-			'0113C2FB',
-			'0113C2FE',
-			'0113C330',
-			'0113C333',
-			'0113C337',
-			'0113C371',
-			'0113C374',
-			'0113C377',
-			'011306C5',
-			'01130713',
-			'01130747',
-			'011307A4',
-			'011307B4',
-			'01130D98',
-			'01130D9A',
-			'01130DA5',
-			'01130E03',
-			'01130E27',
-			'01130F13',
-			'01131170',
-			'01131749',
-			'0113174B',
-			'01131777',
-			'01131797',
-			'01131798',
-			'0113C2FB',
-			'0113C2FE',
-			'0113C330',
-			'0113C333',
-			'0113C337',
-			'0113C371',
-			'0113C374',
-			'0113C377',
-			'011306C5',
-			'01130713',
-			'01130747',
-			'011307A4',
-			'011307B4',
-			'01130D98',
-			'01130D9A',
-			'01130DA5',
-			'01130E03',
-			'01130E27',
-			'01130F13',
-			'01131170',
-			'01131749',
-			'0113174B',
-			'01131777',
-			'01131797',
-			'01131798',
-			'0113C2FB',
-			'0113C2FE',
-			'0113C330',
-			'0113C333',
-			'0113C337',
-			'0113C371',
-			'0113C374',
-			'0113C377'
-		];
-
-		$this->BlinkON($labels);
-
-		$qc = new QueueCommand();
-		$qc->getJobs();
-		$qs = new QueueSystem();
-		$resp = $qs->send($qc, true);
-		echo $resp->jobCount . "<BR/>";
-
-		$qc->clearQueue();
-		$resp = $qs->send($qc, true);
-		echo $resp->jobClear . "<BR/>";
-
-		$qc->getJobs();
-		$resp = $qs->send($qc, true);
-		echo $resp->jobCount . "<BR/>";
-
-		die;
-
 		$f3->set('MESSAGE', 'Hello World');
 		$f3->set('MESSAGE', 'Hello World');
 		$f3->set('CONTENT', 'message.tpl');
 		$f3->set('CONTENT', 'message.tpl');
 		echo Template::instance()->render('masterpage.tpl');
 		echo Template::instance()->render('masterpage.tpl');
@@ -147,4 +50,71 @@ class Pages extends Controller
 		$cmd->setLeds(2, 1, 1000, 300, 0);
 		$cmd->setLeds(2, 1, 1000, 300, 0);
 		$qs->send($cmd);
 		$qs->send($cmd);
 	}
 	}
+	
+	public function PickinglistController($f3)
+	{
+		header('Content-Type: application/json');
+
+		$postData = $this->getSanitizedPostRequest();
+
+		switch ($postData['action']) {
+			case 'getData':
+				echo $this->getTableData();
+				return;
+				break;
+
+			case 'saveall':
+				$ret = $this->SaveProduct();
+				if ($ret) {
+					echo $ret;
+					return;
+				}
+				break;
+
+			case 'edit':
+				$label = new Mapper($f3->get('DB'), 'label_bindings');
+				$label->load(['label_id=?', $postData['label_id']]);
+				$label->takt = $postData['takt'];
+				$label->save();
+
+				$kanban = new Mapper($f3->get('DB'), 'anagraficakanbanlist');
+				$kanban->load(['id=?', $postData['id']]);
+				$kanban->MATNR = $postData['codArticolo'];
+				$kanban->MAKTX = $postData['descrizione'];
+				$kanban->LGPLA = $postData['ubicazione'];
+				$kanban->save();
+				$ret = $this->SaveProduct($postData['codArticolo']);
+				if ($ret) {
+					echo $ret;
+					return;
+				}
+				break;
+
+			case 'delete':
+				$kanban = new Mapper($f3->get('DB'), 'anagraficakanbanlist');
+				$kanban->load(['id=?', $postData['id']]);
+				$kanban->erase();
+				break;
+
+		}
+		echo json_encode([
+			'code' => 0,
+			'err' => 'Success'
+		]);
+
+	}
+
+	private function getTableData(): string
+	{
+		global $f3;
+
+		$data = $f3->get('DB')->exec("SELECT * FROM pickinglist");
+
+		$data2 = array_map(function ($v) {
+			return array_values($v);
+		}, $data);
+
+		return json_encode($data2);
+	}
+
 }
 }

+ 6 - 0
ui/frontend/css/omlink.scss

@@ -36,10 +36,16 @@ html, body {
 
 
 body {
 body {
 	background-color: $mainColor !important;
 	background-color: $mainColor !important;
+	background: linear-gradient(to right, darken($mainColor, 10%), $mainColor);
 	color: $textColor !important;
 	color: $textColor !important;
 	font-family: 'Roboto';
 	font-family: 'Roboto';
 }
 }
 
 
+.navbar-dark {
+	background: black;
+	background: linear-gradient(to right, #6b6767, #000000);
+}
+
 /* latin */
 /* latin */
 @font-face {
 @font-face {
 	font-family: 'Roboto';
 	font-family: 'Roboto';

+ 2 - 0
ui/frontend/js/common.js

@@ -5,3 +5,5 @@ import 'popper.js';
 // CSS
 // CSS
 import 'bootstrap/dist/css/bootstrap.min.css';
 import 'bootstrap/dist/css/bootstrap.min.css';
 import '../css/omlink.scss';
 import '../css/omlink.scss';
+import '../css/edittable.scss';
+

+ 33 - 15
ui/admin/assets/js/edittable.js → ui/frontend/js/edittable.js

@@ -1,12 +1,14 @@
 import {AjaxReq, fetchHeaders} from "./OMGUtils";
 import {AjaxReq, fetchHeaders} from "./OMGUtils";
 
 
 let CSS_EDITOR_ACTIVE = 'shadow rounded-lg bg-dark text-light';
 let CSS_EDITOR_ACTIVE = 'shadow rounded-lg bg-dark text-light';
+let CSS_EDITOR_ROW_ACTIVE = 'bg-info';
 
 
-let tableSelector = null;
+let _tableSelector = null;
+let _controllerURL = '';
 
 
 function GetTableFieldNames() {
 function GetTableFieldNames() {
 	let columnNames = [];
 	let columnNames = [];
-	$(`${tableSelector} thead th`).each(function (i, e) {
+	$(`${_tableSelector} thead th`).each(function (i, e) {
 		columnNames.push(e.innerText);
 		columnNames.push(e.innerText);
 	});
 	});
 
 
@@ -14,47 +16,63 @@ function GetTableFieldNames() {
 }
 }
 
 
 function GetColumnDef(colIndex, name) {
 function GetColumnDef(colIndex, name) {
-	return $(`${tableSelector} thead th:eq(${colIndex})`).attr(name);
+	return $(`${_tableSelector} thead th:eq(${colIndex})`).attr(name);
 }
 }
 
 
 function cancelEdit(el) {
 function cancelEdit(el) {
 	el.innerText = $(el).data('oldvalue');
 	el.innerText = $(el).data('oldvalue');
-	$(el).parent('tr').removeClass('dt-editing-cell bg-warning');
+	$(el).parent('tr').removeClass(`dt-editing-cell ${CSS_EDITOR_ROW_ACTIVE}`);
 	$(el).removeClass(CSS_EDITOR_ACTIVE);
 	$(el).removeClass(CSS_EDITOR_ACTIVE);
 	$('body').focus();
 	$('body').focus();
 	el.contentEditable = false;
 	el.contentEditable = false;
 }
 }
 
 
-function EditTableInit(tableRef) {
+function EditTableInit(tableRef, controllerURL) {
 
 
-	tableSelector = tableRef;
-	let tableBodyRef = $(`${tableSelector} tbody`);
+	_tableSelector = tableRef;
+	_controllerURL = controllerURL;
+
+	let tableBodyRef = $(`${_tableSelector} tbody`);
 
 
 	$(tableRef).DataTable({
 	$(tableRef).DataTable({
 		"ajax": {
 		"ajax": {
-			"url": `${BASEURL}/masterdataset`,
+			"url": _controllerURL,
 			"type": 'POST',
 			"type": 'POST',
 			"data": {
 			"data": {
 				'action': 'getData'
 				'action': 'getData'
 			},
 			},
 			'dataSrc': function (data) {
 			'dataSrc': function (data) {
-				$(tableSelector).parent('.dataTables_wrapper').parent().removeClass('d-none');
+				$(_tableSelector).parent('.dataTables_wrapper').parent().removeClass('d-none');
 				return data;
 				return data;
 			}
 			}
 		},
 		},
 		'lengthChange': false,
 		'lengthChange': false,
-		dom: 'Bfrtip', // for buttons
+		dom: 'frtBip', // for buttons
 		order: [[0, "asc"]],
 		order: [[0, "asc"]],
 		buttons: [
 		buttons: [
 			{
 			{
-				text: 'Save all',
+				text: 'Completa lista',
+				action: function (e, dt, node, config) {
+					let postHeadersContentType = fetchHeaders;
+					postHeadersContentType['Content-Type'] = 'application/x-www-form-urlencoded';
+					AjaxReq(_controllerURL, {
+						headers: postHeadersContentType,
+						method: 'POST',
+						body: 'action=closelist'
+					}).fetchPromise()
+						.then(json => alert(`${json.code} - ${json.err}`))
+						.catch(err => alert(err.url, `${err.status} (${err.statusText})`));
+				}
+			},
+			{
+				text: 'Annulla lista',
 				action: function (e, dt, node, config) {
 				action: function (e, dt, node, config) {
 					let postHeadersContentType = fetchHeaders;
 					let postHeadersContentType = fetchHeaders;
 					postHeadersContentType['Content-Type'] = 'application/x-www-form-urlencoded';
 					postHeadersContentType['Content-Type'] = 'application/x-www-form-urlencoded';
-					AjaxReq(`${BASEURL}/masterdataset`, {
+					AjaxReq(_controllerURL, {
 						headers: postHeadersContentType,
 						headers: postHeadersContentType,
 						method: 'POST',
 						method: 'POST',
-						body: 'action=saveall'
+						body: 'action=cancellist'
 					}).fetchPromise()
 					}).fetchPromise()
 						.then(json => alert(`${json.code} - ${json.err}`))
 						.then(json => alert(`${json.code} - ${json.err}`))
 						.catch(err => alert(err.url, `${err.status} (${err.statusText})`));
 						.catch(err => alert(err.url, `${err.status} (${err.statusText})`));
@@ -72,7 +90,7 @@ function EditTableInit(tableRef) {
 
 
 		this.contentEditable = true;	// enable html edit
 		this.contentEditable = true;	// enable html edit
 		$this.data('oldvalue', this.innerText);  // backup actual value
 		$this.data('oldvalue', this.innerText);  // backup actual value
-		$this.parent('tr').addClass('dt-editing-cell bg-warning');  // mark the row of current cell
+		$this.parent('tr').addClass(`dt-editing-cell ${CSS_EDITOR_ROW_ACTIVE}`);  // mark the row of current cell
 		$this.addClass(CSS_EDITOR_ACTIVE);
 		$this.addClass(CSS_EDITOR_ACTIVE);
 		$this.focus();
 		$this.focus();
 	});
 	});
@@ -103,7 +121,7 @@ function EditTableInit(tableRef) {
 			let postHeadersContentType = fetchHeaders;
 			let postHeadersContentType = fetchHeaders;
 			delete postHeadersContentType['Content-Type'];
 			delete postHeadersContentType['Content-Type'];
 
 
-			AjaxReq(`${BASEURL}/masterdataset`, {
+			AjaxReq(_controllerURL, {
 				headers: postHeadersContentType,
 				headers: postHeadersContentType,
 				method: 'POST',
 				method: 'POST',
 				body: ajaxData
 				body: ajaxData

+ 3 - 0
ui/frontend/js/frontend.js

@@ -8,6 +8,7 @@
 
 
 import './common';
 import './common';
 import {AjaxReq, fetchHeaders} from "./OMGUtils";
 import {AjaxReq, fetchHeaders} from "./OMGUtils";
+import EditTableInit from "./edittable";
 
 
 let CUSTOM_NOTIFY = 0x4000;
 let CUSTOM_NOTIFY = 0x4000;
 let REFRESH_FILTERS = CUSTOM_NOTIFY + 1;
 let REFRESH_FILTERS = CUSTOM_NOTIFY + 1;
@@ -112,5 +113,7 @@ document.addEventListener('DOMContentLoaded', function () {
 		refreshNotificationArea();
 		refreshNotificationArea();
 	}, 3000);
 	}, 3000);
 
 
+	//EditTableInit('.datatables', `${BASEURL}/pickinglistcontroller`);
+
 	window.NotificationDelete = NotificationDelete;
 	window.NotificationDelete = NotificationDelete;
 });
 });

+ 15 - 0
ui/frontend/pickinglist.tpl

@@ -0,0 +1,15 @@
+<div class="d-flex flex-wrap justify-content-around align-items-center flex-fill">
+	<div class="d-none">
+		<table class="datatables table table-sm table-responsive-sm table-bordered rounded shadow-lg">
+			<thead>
+			<tr>
+				<th aria-editable="false">id</th>
+				<th>article</th>
+				<th>quantity</th>
+			</tr>
+			</thead>
+			<tbody>
+			</tbody>
+		</table>
+	</div>
+</div>