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 ()
{
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)
{
var boxLabel = this.doc.createElement ('span');
box.appendChild (boxLabel);
if (this.showPacking)
{
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);
boxLabel.appendChild (text);
var boxLabel = this.doc.createElement ('span');
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;
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;
}

View File

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

View File

@ -6,8 +6,25 @@
<div class="box">
<div class="body">
<div class="form-group">
<label><t>Title</t></label>
<htk-entry id="report-title"/>
<label><t>Reign</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" 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 class="form-group">
<label><t>Store</t></label>
@ -31,34 +48,25 @@
</htk-combo>
</div>
<div class="form-group">
<label><t>Reign</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>
<label><t>Name prefix</t></label>
<input type="text" id="filter"/>
</div>
<div class="form-group">
<label><t>Max amount</t></label>
<label><t>Limit amount per item</t></label>
<htk-entry id="max-amount"/>
</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 class="footer">
<button class="thin" on-click="onPreviewClick">

View File

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

View File

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

View File

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

View File

@ -222,16 +222,11 @@
.htk-date-chooser > button
{
margin: 0.2em;
padding: 0.3em;
background-color: white;
color: black;
margin: 0;
text-align: left;
min-width: 9em;
min-height: 2.3em;
border: 1px solid #CCD;
border-radius: 0.1em;
box-shadow: 0 0.1em 0.1em #CCC;
width: 100%;
padding: .4em .2em;
border-radius: 0;
}
/* 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"
,"Date": "Fecha"
,"Shelf": "Estantería"
,"Reign": "Reino"
,"Family": "Familia"
,"Name filter": "Filtro por nombre"
,"Max amount": "Cantidad máxima"
,"Name prefix": "Prefijo del nombre"
,"Limit amount per item": "Límite de cantidad por artículo"
,"Title": "Título"
,"Show packing": "Mostrar unidades por caja"
,"Stack different items": "Apilar artículos distintos"
,"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
{
font-weight: normal;
@ -31,16 +33,21 @@ h1.page-number
{
position: absolute;
border: 1px solid black;
text-align: center;
padding: .8mm;
box-sizing: padding-box;
}
.box > span
.box .box-label
{
font-size: 60%;
text-align: center;
margin: 5%;
display: inline-block;
line-height: 100%;
vertical-align: middle;
text-align: left;
font-size: 55%;
word-wrap: break-word;
}
.box .packing
{
margin: 3%;
display: block;
float: right;
font-size: 80%;
}
.color0
{
@ -58,3 +65,28 @@ h1.page-number
{
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;
}