From bbecb5fce9de053e87299024885330629d496396 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Sat, 24 Oct 2015 01:23:19 +0200 Subject: [PATCH] =?UTF-8?q?Seccion=20estanter=C3=ADas=20acabada?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/forms/admin/shelves/shelves.js | 122 ++++++++++++++++++------- web/forms/admin/shelves/style.css | 2 +- web/forms/admin/shelves/ui.xml | 58 +++++++----- web/js/hedera/style.css | 3 +- web/js/htk/field/date-chooser.js | 1 + web/js/htk/field/select.js | 19 +++- web/js/htk/style.css | 13 +-- web/locale/ca/forms/admin/shelves.json | 12 +-- web/locale/es/forms/admin/shelves.json | 13 ++- web/locale/fr/forms/admin/shelves.json | 12 +-- web/reports/shelves/style.css | 48 ++++++++-- 11 files changed, 198 insertions(+), 105 deletions(-) diff --git a/web/forms/admin/shelves/shelves.js b/web/forms/admin/shelves/shelves.js index 3d3a877a..47c6d84c 100755 --- a/web/forms/admin/shelves/shelves.js +++ b/web/forms/admin/shelves/shelves.js @@ -5,27 +5,38 @@ Vn.Shelves = new Class ,activate: function () { - this.$('report-title').value = 'Anthuriums'; this.$('warehouse').value = 44; this.$('date').value = new Date (); - this.$('shelf').value = 1; + this.$('shelf').value = 4; this.$('reign').value = 1; this.$('family').value = 2; - this.$('filter').value = 'Ant %'; + this.$('filter').value = 'Ant '; this.$('max-amount').value = 50; + this.$('show-packing').value = true; + this.$('stack').value = true; + } + + ,onFamilyChange: function () + { + this.$('report-title').value = this.$('family').get ('Tipo'); } ,onPreviewClick: function () { + var batch = new Sql.Batch (); + batch.addParam ('shelf', this.$('shelf')); + batch.addParam ('wh', this.$('warehouse')); + batch.addParam ('date', this.$('date')); + batch.addParam ('family', this.$('family')); + batch.addValue ('filter', this.$('filter').value); + var report = new Vn.ShelvesReport ({conn: this.conn}); report.setParams ( this.$('report-title').value, - this.$('warehouse').value, - this.$('date').value, - this.$('family').value, - this.$('filter').value, this.$('max-amount').value, - this.$('shelf').value + this.$('show-packing').value, + this.$('stack').value, + batch ); report.open (); } @@ -38,18 +49,13 @@ Vn.ShelvesReport = new Class ,nItem: -1 ,nColors: 4 - ,setParams: function (title, warehouse, date, type, filter, maxAmount, shelf) + ,setParams: function (title, maxAmount, showPacking, stack, batch) { this.title = title; this.maxAmount = maxAmount; - - var batch = new Sql.Batch (); - batch.addValue ('shelf', shelf); - batch.addValue ('wh', warehouse); - batch.addValue ('date', date); - batch.addValue ('type', type); - batch.addValue ('filter', filter); this.batch = batch; + this.showPacking = showPacking; + this.stack = stack; } ,open: function () @@ -58,7 +64,7 @@ Vn.ShelvesReport = new Class 'SELECT id, name, width, height, max_height, tray_height, '+ 'first_tray_elevation, tray_density, vspacing, hspacing '+ 'FROM vn2008.shelf WHERE id = #shelf; '+ - 'CALL item_organizer (#wh, #date, #type, #filter)'; + 'CALL item_organizer (#wh, #date, #family, #filter)'; this.conn.execQuery (query, this.onQueryExec.bind (this), this.batch); } @@ -85,24 +91,36 @@ Vn.ShelvesReport = new Class }; var items = []; + var remainings = []; var res = resultSet.fetchResult (); while (res.next ()) + if (res.get ('etiquetas') <= this.maxAmount) + { items.push ({ - name: res.get ('Article') +' x'+ res.get ('Medida') + name: res.get ('Article') + ,packing: res.get ('packing') ,boxHeight: res.get ('z') * 10 * scale ,boxWidth: res.get ('x') * 10 * scale ,amount: res.get ('etiquetas') }); + } + else + { + remainings.push ({ + name: res.get ('Article') + ,packing: res.get ('packing') + ,amount: res.get ('etiquetas') + }); + } // Intializes the allocator alloc = new Vn.Allocator (); alloc.items = items; - alloc.maxAmount = this.maxAmount; alloc.shelfFunc = this.drawShelf.bind (this); alloc.boxFunc = this.drawBox.bind (this); - + alloc.stack = this.stack; alloc.nTrays = Math.ceil ( (shelf.height - shelf.firstTrayElevation) / (shelf.trayHeight + shelf.trayDensity) @@ -115,6 +133,45 @@ Vn.ShelvesReport = new Class // Opens the report this.createWindow ('shelves'); + + // Remaining amount + + if (remainings.length > 0) + { + var sheet = this.doc.createElement ('div'); + sheet.className = 'sheet'; + this.doc.body.appendChild (sheet); + + var title = this.doc.createElement ('h1'); + title.appendChild (this.doc.createTextNode (this.title +' - ')); + title.appendChild (this.doc.createTextNode (_('Pallets'))); + sheet.appendChild (title); + + var ul = this.doc.createElement ('ul'); + sheet.appendChild (ul); + + for (var i = 0; i < remainings.length; i++) + { + var li = this.doc.createElement ('li'); + ul.appendChild (li); + + var span = this.doc.createElement ('span'); + span.className = 'item'; + span.appendChild (this.doc.createTextNode (remainings[i].name)); + li.appendChild (span); + + if (this.showPacking) + span.appendChild (this.doc.createTextNode (' '+ remainings[i].packing)); + + var span = this.doc.createElement ('span'); + span.className = 'amount'; + span.appendChild (this.doc.createTextNode (remainings[i].amount)); + li.appendChild (span); + } + } + + // Draws the shelves + alloc.run (); } @@ -124,8 +181,7 @@ Vn.ShelvesReport = new Class var sheet = this.doc.createElement ('div'); sheet.className = 'sheet'; -/* sheet.style.top = (allocator.currentShelf * 297) +'mm'; -*/ this.doc.body.appendChild (sheet); + this.doc.body.appendChild (sheet); // Draws the title @@ -208,11 +264,18 @@ Vn.ShelvesReport = new Class if (amount == 0 || allocator.firstShelfBox) { + if (this.showPacking) + { + var packing = this.doc.createElement ('span'); + packing.className = 'packing'; + packing.appendChild (this.doc.createTextNode (item.packing)); + box.appendChild (packing); + } + var boxLabel = this.doc.createElement ('span'); + boxLabel.className = 'box-label'; + boxLabel.appendChild (this.doc.createTextNode (item.name)); box.appendChild (boxLabel); - - var text = this.doc.createTextNode (item.name); - boxLabel.appendChild (text); } } }); @@ -262,7 +325,8 @@ Vn.Allocator = new Class trayHeight = this.topTrayHeight; if (this.trayY + item.boxHeight > trayHeight - || item.boxWidth > this.lastBoxWidth) + || item.boxWidth > this.lastBoxWidth + || (!this.stack && amount == 0)) this.addColumn (item.boxWidth); if (this.boxFunc) @@ -283,6 +347,7 @@ Vn.Allocator = new Class this.lastBoxWidth = 0; this.trayX = 0; this.trayY = 0; + this.remaining = false; for (var i = 0; i < this.items.length; i++) { @@ -290,11 +355,6 @@ Vn.Allocator = new Class for (var amount = 0; amount < item.amount; amount++) { - if (amount == 0 - && this.maxAmount > 0 - && item.amount > this.maxAmount) - break; - this.addBox (item, amount); this.firstShelfBox = false; } diff --git a/web/forms/admin/shelves/style.css b/web/forms/admin/shelves/style.css index 635d0571..b2f20fec 100755 --- a/web/forms/admin/shelves/style.css +++ b/web/forms/admin/shelves/style.css @@ -23,7 +23,7 @@ display: block; margin-bottom: 0.5em; } -.shelves input, +.shelves input[type=text], .shelves select { margin: 0; diff --git a/web/forms/admin/shelves/ui.xml b/web/forms/admin/shelves/ui.xml index b3b1879d..64418240 100755 --- a/web/forms/admin/shelves/ui.xml +++ b/web/forms/admin/shelves/ui.xml @@ -6,8 +6,25 @@
- - + + + + SELECT id, reino FROM vn2008.reinos + WHERE display != FALSE ORDER BY reino + + +
+
+ + + + SELECT tipo_id, Tipo FROM vn2008.Tipos + WHERE reino_id = #reign ORDER BY Tipo + + + + +
@@ -31,34 +48,25 @@
- - - - SELECT id, reino FROM vn2008.reinos - WHERE display != FALSE ORDER BY reino - - -
-
- - - - SELECT tipo_id, Tipo FROM vn2008.Tipos - WHERE reino_id = #reign ORDER BY Tipo - - - - - -
-
- +
- +
+
+ + +
+
+ + +
+
+ + +