Seccion estanterías acabada

This commit is contained in:
Juan Ferrer Toribio 2015-10-24 01:23:19 +02:00
parent 96a894e4b9
commit bbecb5fce9
11 changed files with 198 additions and 105 deletions

View File

@ -5,27 +5,38 @@ Vn.Shelves = new Class
,activate: function () ,activate: function ()
{ {
this.$('report-title').value = 'Anthuriums';
this.$('warehouse').value = 44; this.$('warehouse').value = 44;
this.$('date').value = new Date (); this.$('date').value = new Date ();
this.$('shelf').value = 1; this.$('shelf').value = 4;
this.$('reign').value = 1; this.$('reign').value = 1;
this.$('family').value = 2; this.$('family').value = 2;
this.$('filter').value = 'Ant %'; this.$('filter').value = 'Ant ';
this.$('max-amount').value = 50; 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 () ,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}); var report = new Vn.ShelvesReport ({conn: this.conn});
report.setParams ( report.setParams (
this.$('report-title').value, this.$('report-title').value,
this.$('warehouse').value,
this.$('date').value,
this.$('family').value,
this.$('filter').value,
this.$('max-amount').value, this.$('max-amount').value,
this.$('shelf').value this.$('show-packing').value,
this.$('stack').value,
batch
); );
report.open (); report.open ();
} }
@ -38,18 +49,13 @@ Vn.ShelvesReport = new Class
,nItem: -1 ,nItem: -1
,nColors: 4 ,nColors: 4
,setParams: function (title, warehouse, date, type, filter, maxAmount, shelf) ,setParams: function (title, maxAmount, showPacking, stack, batch)
{ {
this.title = title; this.title = title;
this.maxAmount = maxAmount; 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.batch = batch;
this.showPacking = showPacking;
this.stack = stack;
} }
,open: function () ,open: function ()
@ -58,7 +64,7 @@ Vn.ShelvesReport = new Class
'SELECT id, name, width, height, max_height, tray_height, '+ 'SELECT id, name, width, height, max_height, tray_height, '+
'first_tray_elevation, tray_density, vspacing, hspacing '+ 'first_tray_elevation, tray_density, vspacing, hspacing '+
'FROM vn2008.shelf WHERE id = #shelf; '+ '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); this.conn.execQuery (query, this.onQueryExec.bind (this), this.batch);
} }
@ -85,24 +91,36 @@ Vn.ShelvesReport = new Class
}; };
var items = []; var items = [];
var remainings = [];
var res = resultSet.fetchResult (); var res = resultSet.fetchResult ();
while (res.next ()) while (res.next ())
if (res.get ('etiquetas') <= this.maxAmount)
{
items.push ({ items.push ({
name: res.get ('Article') +' x'+ res.get ('Medida') name: res.get ('Article')
,packing: res.get ('packing')
,boxHeight: res.get ('z') * 10 * scale ,boxHeight: res.get ('z') * 10 * scale
,boxWidth: res.get ('x') * 10 * scale ,boxWidth: res.get ('x') * 10 * scale
,amount: res.get ('etiquetas') ,amount: res.get ('etiquetas')
}); });
}
else
{
remainings.push ({
name: res.get ('Article')
,packing: res.get ('packing')
,amount: res.get ('etiquetas')
});
}
// Intializes the allocator // Intializes the allocator
alloc = new Vn.Allocator (); alloc = new Vn.Allocator ();
alloc.items = items; alloc.items = items;
alloc.maxAmount = this.maxAmount;
alloc.shelfFunc = this.drawShelf.bind (this); alloc.shelfFunc = this.drawShelf.bind (this);
alloc.boxFunc = this.drawBox.bind (this); alloc.boxFunc = this.drawBox.bind (this);
alloc.stack = this.stack;
alloc.nTrays = Math.ceil ( alloc.nTrays = Math.ceil (
(shelf.height - shelf.firstTrayElevation) / (shelf.height - shelf.firstTrayElevation) /
(shelf.trayHeight + shelf.trayDensity) (shelf.trayHeight + shelf.trayDensity)
@ -115,6 +133,45 @@ Vn.ShelvesReport = new Class
// Opens the report // Opens the report
this.createWindow ('shelves'); 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 (); alloc.run ();
} }
@ -124,8 +181,7 @@ Vn.ShelvesReport = new Class
var sheet = this.doc.createElement ('div'); var sheet = this.doc.createElement ('div');
sheet.className = 'sheet'; sheet.className = 'sheet';
/* sheet.style.top = (allocator.currentShelf * 297) +'mm'; this.doc.body.appendChild (sheet);
*/ this.doc.body.appendChild (sheet);
// Draws the title // Draws the title
@ -208,11 +264,18 @@ Vn.ShelvesReport = new Class
if (amount == 0 || allocator.firstShelfBox) if (amount == 0 || allocator.firstShelfBox)
{ {
var boxLabel = this.doc.createElement ('span'); if (this.showPacking)
box.appendChild (boxLabel); {
var packing = this.doc.createElement ('span');
packing.className = 'packing';
packing.appendChild (this.doc.createTextNode (item.packing));
box.appendChild (packing);
}
var text = this.doc.createTextNode (item.name); var boxLabel = this.doc.createElement ('span');
boxLabel.appendChild (text); boxLabel.className = 'box-label';
boxLabel.appendChild (this.doc.createTextNode (item.name));
box.appendChild (boxLabel);
} }
} }
}); });
@ -262,7 +325,8 @@ Vn.Allocator = new Class
trayHeight = this.topTrayHeight; trayHeight = this.topTrayHeight;
if (this.trayY + item.boxHeight > trayHeight if (this.trayY + item.boxHeight > trayHeight
|| item.boxWidth > this.lastBoxWidth) || item.boxWidth > this.lastBoxWidth
|| (!this.stack && amount == 0))
this.addColumn (item.boxWidth); this.addColumn (item.boxWidth);
if (this.boxFunc) if (this.boxFunc)
@ -283,6 +347,7 @@ Vn.Allocator = new Class
this.lastBoxWidth = 0; this.lastBoxWidth = 0;
this.trayX = 0; this.trayX = 0;
this.trayY = 0; this.trayY = 0;
this.remaining = false;
for (var i = 0; i < this.items.length; i++) 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++) for (var amount = 0; amount < item.amount; amount++)
{ {
if (amount == 0
&& this.maxAmount > 0
&& item.amount > this.maxAmount)
break;
this.addBox (item, amount); this.addBox (item, amount);
this.firstShelfBox = false; this.firstShelfBox = false;
} }

View File

@ -23,7 +23,7 @@
display: block; display: block;
margin-bottom: 0.5em; margin-bottom: 0.5em;
} }
.shelves input, .shelves input[type=text],
.shelves select .shelves select
{ {
margin: 0; margin: 0;

View File

@ -6,8 +6,25 @@
<div class="box"> <div class="box">
<div class="body"> <div class="body">
<div class="form-group"> <div class="form-group">
<label><t>Title</t></label> <label><t>Reign</t></label>
<htk-entry id="report-title"/> <htk-combo id="reign">
<db-model property="model" id="reigns">
SELECT id, reino FROM vn2008.reinos
WHERE display != FALSE ORDER BY reino
</db-model>
</htk-combo>
</div>
<div class="form-group">
<label><t>Family</t></label>
<htk-combo id="family" on-changed="onFamilyChange" on-ready="onFamilyChange">
<db-model property="model">
SELECT tipo_id, Tipo FROM vn2008.Tipos
WHERE reino_id = #reign ORDER BY Tipo
<sql-batch property="batch">
<item name="reign" param="reign"/>
</sql-batch>
</db-model>
</htk-combo>
</div> </div>
<div class="form-group"> <div class="form-group">
<label><t>Store</t></label> <label><t>Store</t></label>
@ -31,34 +48,25 @@
</htk-combo> </htk-combo>
</div> </div>
<div class="form-group"> <div class="form-group">
<label><t>Reign</t></label> <label><t>Name prefix</t></label>
<htk-combo id="reign">
<db-model property="model" id="reigns">
SELECT id, reino FROM vn2008.reinos
WHERE display != FALSE ORDER BY reino
</db-model>
</htk-combo>
</div>
<div class="form-group">
<label><t>Family</t></label>
<htk-combo id="family">
<db-model property="model">
SELECT tipo_id, Tipo FROM vn2008.Tipos
WHERE reino_id = #reign ORDER BY Tipo
<sql-batch property="batch">
<item name="reign" param="reign"/>
</sql-batch>
</db-model>
</htk-combo>
</div>
<div class="form-group">
<label><t>Name filter</t></label>
<input type="text" id="filter"/> <input type="text" id="filter"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label><t>Max amount</t></label> <label><t>Limit amount per item</t></label>
<htk-entry id="max-amount"/> <htk-entry id="max-amount"/>
</div> </div>
<div class="form-group">
<label><t>Title</t></label>
<htk-entry id="report-title"/>
</div>
<div class="form-group">
<label><t>Show packing</t></label>
<htk-check id="show-packing"/>
</div>
<div class="form-group">
<label><t>Stack different items</t></label>
<htk-check id="stack"/>
</div>
</div> </div>
<div class="footer"> <div class="footer">
<button class="thin" on-click="onPreviewClick"> <button class="thin" on-click="onPreviewClick">

View File

@ -91,7 +91,8 @@ input[type=password],
input[type=file], input[type=file],
input[type=number], input[type=number],
textarea, textarea,
select select,
.input
{ {
border: none; border: none;
border-bottom: 1px solid #999; border-bottom: 1px solid #999;

View File

@ -39,6 +39,7 @@ Htk.DateChooser = new Class
Vn.Node.remove (this.label); Vn.Node.remove (this.label);
this.button = document.createElement ('button'); this.button = document.createElement ('button');
this.button.className = 'input';
this.button.title = _('ChangeDate'); this.button.title = _('ChangeDate');
this.button.addEventListener ('click', this.showCalendar.bind (this)); this.button.addEventListener ('click', this.showCalendar.bind (this));
this.button.appendChild (this.label); this.button.appendChild (this.label);

View File

@ -120,9 +120,11 @@ Htk.Select = new Class
,setRow: function (row) ,setRow: function (row)
{ {
if (row != -1) if (row != -1)
this.node.selectedIndex = row + 1; this.node.selectedIndex = row + this.getIndexIncrement ();
else else if (this._placeholder)
this.node.selectedIndex = 0; this.node.selectedIndex = 0;
else
this.node.selectedIndex = -1;
this._row = row; this._row = row;
this.iterChanged (); this.iterChanged ();
@ -131,7 +133,7 @@ Htk.Select = new Class
,_onChange: function (event) ,_onChange: function (event)
{ {
var value; var value;
var row = this.node.selectedIndex - 1; var row = this.node.selectedIndex - this.getIndexIncrement ();
if (row >= 0) if (row >= 0)
value = this._model.getByIndex (row, this.valueColumnIndex); value = this._model.getByIndex (row, this.valueColumnIndex);
@ -142,6 +144,16 @@ Htk.Select = new Class
this.valueChanged (value); this.valueChanged (value);
} }
,getIndexIncrement: function ()
{
var inc = 0;
if (this._placeholder)
inc++;
return inc;
}
,addOption: function (value, text) ,addOption: function (value, text)
{ {
var option = document.createElement ('option'); var option = document.createElement ('option');
@ -197,6 +209,7 @@ Htk.Select = new Class
this.selectOption (); this.selectOption ();
this._onTimeout (); this._onTimeout ();
this.signalEmit ('ready');
} }
else else
this.setRow (-1); this.setRow (-1);

View File

@ -222,16 +222,11 @@
.htk-date-chooser > button .htk-date-chooser > button
{ {
margin: 0.2em; margin: 0;
padding: 0.3em;
background-color: white;
color: black;
text-align: left; text-align: left;
min-width: 9em; width: 100%;
min-height: 2.3em; padding: .4em .2em;
border: 1px solid #CCD; border-radius: 0;
border-radius: 0.1em;
box-shadow: 0 0.1em 0.1em #CCC;
} }
/* Full image */ /* Full image */

View File

@ -1,11 +1 @@
{ {}
"Title": "Título"
,"Store": "Almacén"
,"Date": "Fecha"
,"Shelf": "Estantería"
,"Reign": "Reino"
,"Family": "Familia"
,"Name filter": "Filtro por nombre"
,"Max amount": "Cantidad máxima"
,"Preview": "Mostrar"
}

View File

@ -1,11 +1,14 @@
{ {
"Title": "Título" "Reign": "Reino"
,"Family": "Familia"
,"Store": "Almacén" ,"Store": "Almacén"
,"Date": "Fecha" ,"Date": "Fecha"
,"Shelf": "Estantería" ,"Shelf": "Estantería"
,"Reign": "Reino" ,"Name prefix": "Prefijo del nombre"
,"Family": "Familia" ,"Limit amount per item": "Límite de cantidad por artículo"
,"Name filter": "Filtro por nombre" ,"Title": "Título"
,"Max amount": "Cantidad máxima" ,"Show packing": "Mostrar unidades por caja"
,"Stack different items": "Apilar artículos distintos"
,"Preview": "Mostrar" ,"Preview": "Mostrar"
} }

View File

@ -1,11 +1 @@
{ {}
"Title": "Título"
,"Store": "Almacén"
,"Date": "Fecha"
,"Shelf": "Estantería"
,"Reign": "Reino"
,"Family": "Familia"
,"Name filter": "Filtro por nombre"
,"Max amount": "Cantidad máxima"
,"Preview": "Mostrar"
}

View File

@ -1,4 +1,6 @@
/* Shelves */
h1 h1
{ {
font-weight: normal; font-weight: normal;
@ -31,16 +33,21 @@ h1.page-number
{ {
position: absolute; position: absolute;
border: 1px solid black; border: 1px solid black;
text-align: center; padding: .8mm;
box-sizing: padding-box;
} }
.box > span .box .box-label
{ {
font-size: 60%; text-align: left;
text-align: center; font-size: 55%;
margin: 5%; word-wrap: break-word;
display: inline-block; }
line-height: 100%; .box .packing
vertical-align: middle; {
margin: 3%;
display: block;
float: right;
font-size: 80%;
} }
.color0 .color0
{ {
@ -58,3 +65,28 @@ h1.page-number
{ {
background-color: #ECE !important; background-color: #ECE !important;
} }
/* Remaining amounts*/
ul
{
list-style-type: none;
}
li *
{
font-size: 6mm;
line-height: 12mm;
}
.item
{
display: inline-block;
width: 100mm;
}
.amount
{
color: #666;
width: 10mm;
text-align: right;
padding-right: 1mm;
}