Added an page for editing order informations

This commit is contained in:
Jan Böhmer 2019-08-30 14:25:05 +02:00
parent 1776cd9a77
commit 8c6342bffe
14 changed files with 504 additions and 12 deletions

View file

@ -0,0 +1,66 @@
{% form_theme form 'Parts/edit/edit_form_styles.html.twig' %}
<table class="table table-striped" id="orderdetails_table" data-prototype="{{ form_widget(form.orderDetails.vars.prototype)|e('html_attr') }}">
<tbody>
{% for detail in form.orderDetails %}
{{ form_widget(detail) }}
{% endfor %}
</tbody>
</table>
<button type="button" class="btn btn-success" onclick="create_orderdetail_entry(this)">
<i class="fas fa-plus-square fa-fw"></i>
{% trans %}orderdetail.create{% endtrans %}
</button>
<script>
function delete_pricedetail_entry(btn) {
window.bootbox.confirm('{% trans %}pricedetails.edit.delete.confirm{% endtrans %}', function (result) {
if(result) {
$(btn).closest("tr").remove();
}
});
}
function create_pricedetail_entry(btn) {
//Determine the table, so we can determine, how many entries there are already.
$holder = $(btn).siblings("table");
var index = $holder.find(":input").length;
var newForm = $holder.data("prototype");
//Increase the index
newForm = newForm.replace(/__name__/g, index);
$holder.children("tbody").append(newForm);
//Reinit the selectpickers
$(".selectpicker").selectpicker();
}
function delete_orderdetail_entry(btn) {
window.bootbox.confirm('{% trans %}orderdetails.edit.delete.confirm{% endtrans %}', function (result) {
if(result) {
$(btn).parents("tr").remove();
}
});
}
function create_orderdetail_entry(btn) {
//Determine the table, so we can determine, how many entries there are already.
$holder = $("#orderdetails_table");
var index = $holder.find(":input").length;
var newForm = $holder.data("prototype");
//Increase the index
newForm = newForm.replace(/__name__/g, index);
$holder.children("tbody").append(newForm);
//Reinit the selectpickers
$(".selectpicker").selectpicker();
}
</script>

View file

@ -0,0 +1,59 @@
{% block pricedetail_widget %}
<tr>
<td>{{ form_widget(form.minDiscountQuantity) }} {{ form_errors(form.minDiscountQuantity) }}</td>
<td>
<div class="input-group">
{{ form_widget(form.price) }}
<div class="input-group-append">
{{ form_widget(form.currency) }}
</div>
</div>
{{ form_errors(form.price) }}
{{ form_errors(form.currency) }}
</td>
<td>{{ form_widget(form.priceRelatedQuantity) }} {{ form_errors(form.price) }}</td>
<td><button type="button" class="btn btn-danger order_btn_delete" title="{% trans %}orderdetail.delete{% endtrans %}" onclick="delete_pricedetail_entry(this);">
<i class="fas fa-trash-alt fa-fw"></i>
</button>
</td>
</tr>
{% endblock %}
{% block orderdetail_widget %}
<tr>
<td>
{{ form_row(form.supplierpartnr) }}
{{ form_row(form.supplier) }}
{{ form_row(form.supplierProductUrl) }}
{{ form_row(form.obsolete) }}
</td>
<td>
<table class="table table-sm table-bordered" data-prototype="{{ form_widget(form.priceDetails.vars.prototype)|e('html_attr') }}">
<thead>
<tr>
<th>Min Qty.</th>
<th>Price</th>
<th>Price Qty</th>
<th></th>
</tr>
</thead>
<tbody>
{% for price in form.priceDetails %}
{{ form_widget(price) }}
{% endfor %}
</tbody>
</table>
<button type="button" class="btn btn-success" onclick="create_pricedetail_entry(this)">
<i class="fas fa-plus-square fa-fw"></i>
{% trans %}pricedetail.create{% endtrans %}
</button>
</td>
<td>
<button type="button" class="btn btn-danger order_btn_delete" onclick="delete_orderdetail_entry(this);">
<i class="fas fa-trash-alt fa-fw"></i>
{% trans %}orderdetail.delete{% endtrans %}
</button>
</td>
</tr>
{% endblock %}

View file

@ -46,6 +46,12 @@
{% trans %}part.edit.tab.attachments{% endtrans %}
</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" role="tab" href="#orderdetails">
<i class="fas fa-shopping-cart fa-fw"></i>
{% trans %}part.edit.tab.orderdetails{% endtrans %}
</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" role="tab" href="#comment">
<i class="fas fa-sticky-note fa-fw"></i>
@ -72,6 +78,9 @@
<div class="tab-pane fade p-2" id="attachments" role="tabpanel">
{% include "Parts/edit/_attachments.html.twig" %}
</div>
<div class="tab-pane fade p-2" id="orderdetails" role="tabpanel">
{% include "Parts/edit/_orderdetails.html.twig" %}
</div>
<div class="tab-pane fade p-2" id="comment" role="tabpanel">
{{ form_widget(form.comment)}}
</div>