mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-06 07:18:48 +00:00
Add a form to select export format
This commit is contained in:
parent
d391c5059b
commit
64cf916c50
@ -39,6 +39,9 @@ src="{% static 'img/blank_image.png' %}"
|
|||||||
<button type='button' class='btn btn-default' id='print-order-report' title='{% trans "Print" %}'>
|
<button type='button' class='btn btn-default' id='print-order-report' title='{% trans "Print" %}'>
|
||||||
<span class='fas fa-print'></span>
|
<span class='fas fa-print'></span>
|
||||||
</button>
|
</button>
|
||||||
|
<button type='button' class='btn btn-default' id='export-order' title='{% trans "Export order to file" %}'>
|
||||||
|
<span class='fas fa-file-download'></span>
|
||||||
|
</button>
|
||||||
{% if roles.purchase_order.change %}
|
{% if roles.purchase_order.change %}
|
||||||
<button type='button' class='btn btn-default' id='edit-order' title='{% trans "Edit order information" %}'>
|
<button type='button' class='btn btn-default' id='edit-order' title='{% trans "Edit order information" %}'>
|
||||||
<span class='fas fa-edit icon-green'></span>
|
<span class='fas fa-edit icon-green'></span>
|
||||||
@ -61,9 +64,6 @@ src="{% static 'img/blank_image.png' %}"
|
|||||||
</button>
|
</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<button type='button' class='btn btn-default' id='export-order' title='{% trans "Export order to file" %}'>
|
|
||||||
<span class='fas fa-file-download'></span>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@ -224,7 +224,7 @@ $("#cancel-order").click(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#export-order").click(function() {
|
$("#export-order").click(function() {
|
||||||
location.href = '{% url "po-export" order.id %}';
|
exportOrder('{% url "po-export" order.id %}');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ $('#print-order-report').click(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#export-order').click(function() {
|
$('#export-order').click(function() {
|
||||||
location.href = '{% url "so-export" order.id %}';
|
exportOrder('{% url "so-export" order.id %}');
|
||||||
});
|
});
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -10,6 +10,7 @@
|
|||||||
/* exported
|
/* exported
|
||||||
attachClipboard,
|
attachClipboard,
|
||||||
enableDragAndDrop,
|
enableDragAndDrop,
|
||||||
|
exportFormatOptions,
|
||||||
inventreeDocReady,
|
inventreeDocReady,
|
||||||
inventreeLoad,
|
inventreeLoad,
|
||||||
inventreeSave,
|
inventreeSave,
|
||||||
@ -46,6 +47,31 @@ function attachClipboard(selector, containerselector, textElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a standard list of export format options *
|
||||||
|
*/
|
||||||
|
function exportFormatOptions() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
value: 'csv',
|
||||||
|
display_name: 'CSV',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'tsv',
|
||||||
|
display_name: 'TSV',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'xls',
|
||||||
|
display_name: 'XLS',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'xlsx',
|
||||||
|
display_name: 'XLSX',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function inventreeDocReady() {
|
function inventreeDocReady() {
|
||||||
/* Run this function when the HTML document is loaded.
|
/* Run this function when the HTML document is loaded.
|
||||||
* This will be called for every page that extends "base.html"
|
* This will be called for every page that extends "base.html"
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
/* exported
|
/* exported
|
||||||
createSalesOrder,
|
createSalesOrder,
|
||||||
editPurchaseOrderLineItem,
|
editPurchaseOrderLineItem,
|
||||||
|
exportOrder,
|
||||||
loadPurchaseOrderLineItemTable,
|
loadPurchaseOrderLineItemTable,
|
||||||
loadPurchaseOrderTable,
|
loadPurchaseOrderTable,
|
||||||
loadSalesOrderAllocationTable,
|
loadSalesOrderAllocationTable,
|
||||||
@ -187,6 +188,49 @@ function newSupplierPartFromOrderWizard(e) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Export an order (PurchaseOrder or SalesOrder)
|
||||||
|
*
|
||||||
|
* - Display a simple form which presents the user with export options
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function exportOrder(redirect_url, options={}) {
|
||||||
|
|
||||||
|
var format = options.format;
|
||||||
|
|
||||||
|
// If default format is not provided, lookup
|
||||||
|
if (!format) {
|
||||||
|
format = inventreeLoad('order-export-format', 'csv');
|
||||||
|
}
|
||||||
|
|
||||||
|
constructFormBody({}, {
|
||||||
|
title: '{% trans "Export Order" %}',
|
||||||
|
fields: {
|
||||||
|
format: {
|
||||||
|
label: '{% trans "Format" %}',
|
||||||
|
help_text: '{% trans "Select file format" %}',
|
||||||
|
required: true,
|
||||||
|
type: 'choice',
|
||||||
|
value: format,
|
||||||
|
choices: exportFormatOptions(),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onSubmit: function(fields, opts) {
|
||||||
|
|
||||||
|
var format = getFormFieldValue('format', fields['format'], opts);
|
||||||
|
|
||||||
|
// Save the format for next time
|
||||||
|
inventreeSave('order-export-format', format);
|
||||||
|
|
||||||
|
// Hide the modal
|
||||||
|
$(opts.modal).modal('hide');
|
||||||
|
|
||||||
|
// Download the file!
|
||||||
|
location.href = `${redirect_url}?format=${format}`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function newPurchaseOrderFromOrderWizard(e) {
|
function newPurchaseOrderFromOrderWizard(e) {
|
||||||
/* Create a new purchase order directly from an order form.
|
/* Create a new purchase order directly from an order form.
|
||||||
* Launches a secondary modal and (if successful),
|
* Launches a secondary modal and (if successful),
|
||||||
|
@ -98,24 +98,7 @@ function exportStock(params={}) {
|
|||||||
required: true,
|
required: true,
|
||||||
type: 'choice',
|
type: 'choice',
|
||||||
value: 'csv',
|
value: 'csv',
|
||||||
choices: [
|
choices: exportFormatOptions(),
|
||||||
{
|
|
||||||
value: 'csv',
|
|
||||||
display_name: 'CSV',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'tsv',
|
|
||||||
display_name: 'TSV',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'xls',
|
|
||||||
display_name: 'XLS',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'xlsx',
|
|
||||||
display_name: 'XLSX',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
sublocations: {
|
sublocations: {
|
||||||
label: '{% trans "Include Sublocations" %}',
|
label: '{% trans "Include Sublocations" %}',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user