tailbone/tailbone/templates/purchases/batches/receive_form.mako
2016-12-09 12:09:18 -06:00

148 lines
4.5 KiB
Mako

## -*- coding: utf-8 -*-
<%inherit file="/base.mako" />
<%def name="title()">Receiving Form (${batch.vendor})</%def>
<%def name="head_tags()">
${parent.head_tags()}
${h.javascript_link(request.static_url('tailbone:static/js/numeric.js'))}
<script type="text/javascript">
function invalid_product(msg) {
$('#product-info p').text(msg);
$('#product-info img').hide();
$('#product-info .rogue-item-warning').hide();
$('#product-textbox').focus().select();
}
$(function() {
$('#product-textbox').keydown(function(event) {
if (key_allowed(event)) {
return true;
}
if (key_modifies(event)) {
$('#product').val('');
$('#product-info p').html('&nbsp;');
$('#product-info img').hide();
$('#product-info .rogue-item-warning').hide();
return true;
}
if (event.which == 13) {
var input = $(this);
var data = {upc: input.val()};
$.get('${url('purchases.batch.receiving_lookup', uuid=batch.uuid)}', data, function(data) {
if (data.error) {
alert(data.error);
if (data.redirect) {
$('#receiving-form').mask("Redirecting...");
location.href = data.redirect;
}
} else if (data.product) {
input.val(data.product.upc_pretty);
if (data.product.cost_found) {
$('#product').val(data.product.uuid);
$('#product-info p').text(data.product.full_description);
$('#product-info img').attr('src', data.product.image_url).show();
$('#product-info .rogue-item-warning').hide();
$('#cases').focus().select();
if (! data.product.found_in_batch) {
$('#product-info .rogue-item-warning').show();
}
} else {
invalid_product('cost not found for ' + data.product.full_description);
}
} else {
invalid_product('product not found');
}
});
}
return false;
});
$('#product-textbox').focus();
$('#received').click(function() {
$(this).button('disable').button('option', 'label', "Working...");
$('#mode').val('received');
$('#receiving-form').submit();
});
$('#receiving-form').submit(function() {
$(this).mask("Working...");
});
});
</script>
<style type="text/css">
#product-info {
margin-top: 0.5em;
text-align: center;
}
#product-info p {
margin-left: 0.5em;
}
#product-info .img-wrapper {
height: 150px;
margin: 0.5em 0;
}
#product-info .rogue-item-warning {
background: #f66;
display: none;
}
</style>
</%def>
<%def name="context_menu_items()">
<li>${h.link_to("Back to Purchase Batch", url('purchases.batch.view', uuid=batch.uuid))}</li>
</%def>
<ul id="context-menu">
${self.context_menu_items()}
</ul>
<div class="form-wrapper">
${form.begin(id='receiving-form')}
${h.hidden('mode')}
<div class="field-wrapper">
<label for="product-textbox">Product</label>
<div class="field">
${h.hidden('product')}
<div>${h.text('product-textbox', autocomplete='off')}</div>
<div id="product-info">
<p>&nbsp;</p>
<div class="img-wrapper"><img /></div>
<div class="rogue-item-warning">warning: product not found on current purchase</div>
</div>
</div>
</div>
<div class="field-wrapper">
<label for="cases">Cases</label>
<div class="field">${h.text('cases')}</div>
</div>
<div class="field-wrapper">
<label for="units">Units</label>
<div class="field">${h.text('units')}</div>
</div>
<div class="buttons">
<button type="button" id="received">Received</button>
<button type="button" id="damaged" disabled="disabled">Damaged</button>
<button type="button" id="expired" disabled="disabled">Expired</button>
<button type="button" id="mispick" disabled="disabled">Mispick</button>
</div>
${form.end()}
</div>