Add new 'receiving form' for purchase batches
This commit is contained in:
parent
468a84aa90
commit
6c3d221e98
5 changed files with 323 additions and 36 deletions
147
tailbone/templates/purchases/batches/receive_form.mako
Normal file
147
tailbone/templates/purchases/batches/receive_form.mako
Normal file
|
@ -0,0 +1,147 @@
|
|||
## -*- 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(' ');
|
||||
$('#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> </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>
|
|
@ -18,13 +18,20 @@
|
|||
location.href = '${url('purchases.batch.order_form', uuid=batch.uuid)}';
|
||||
});
|
||||
|
||||
$('#receive-form').click(function() {
|
||||
$(this).button('disable').button('option', 'label', "Working, please wait...");
|
||||
location.href = '${url('purchases.batch.receiving_form', uuid=batch.uuid)}';
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
</%def>
|
||||
|
||||
<%def name="leading_buttons()">
|
||||
% if batch.mode == enum.PURCHASE_BATCH_MODE_NEW and not batch.complete and not batch.executed and request.has_perm('purchases.batch.order_form'):
|
||||
<button type="button" id="order-form">View as Order Form</button>
|
||||
<button type="button" id="order-form">Ordering Form</button>
|
||||
% elif batch.mode == enum.PURCHASE_BATCH_MODE_RECEIVING and not batch.complete and not batch.executed and request.has_perm('purchases.batch.receiving_form'):
|
||||
<button type="button" id="receive-form">Receiving Form</button>
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue