{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #}
{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #}
{% set parentEntity = entity.fqcn %}
{% set tab = 'onderdelen' %}
{# if ea.request.get('partialFields') is empty #}
{# set partialFields = [] #}
{# else #}
{% set partialFields = ea.getRequest.get('partialFields') %}
{# endif #}
{% set maxTextLength = 25 %}
{% set opslaglocatieBesteldId = 2 %}
{% if parentEntity == 'App\\Entity\\Order' %}
{% set tab = 'onderdelen' %}
{# als alle onderdelen besteld zijn, dan geen batchactions tonen #}
{% set hasBatchActions = 1 %}
{#
{% set hasBatchActions = 0 %}
{% for value in field.value %}
{% if value.opslaglocatie %}
{% if not value.bestelling and value.opslaglocatie.id == opslaglocatieId %}
{% set hasBatchActions = 1 %}
{% endif %}
{% endif %}
{% endfor %}
#}
{% set showOrdernr = 0 %}
{% set showBestelnr = 1 %}
{% set hasAlwaysEditAction = 0 %}
{% endif %}
{% if parentEntity == 'App\\Entity\\Bestelling' %}
{# set hasBatchActions = 0 #}
{% set showOrdernr = 1 %}
{% set hasAlwaysEditAction = 1 %}
{% set showBestelnr = 0 %}
{% endif %}
{% set urlBatchBestellen = ea_url()
.setController('App\\Controller\\Admin\\Orderonderdeel\\Sub\\OrderonderdeelSubController')
.setAction('actionBatchBestellen')
.unset('entityId')
.set('parentControllerFqcn', ea.getCrud().controllerFqcn)
.set('parentEntity', ea.getCrud().entityFqcn)
.set('parentId', entity.instance.id)
.set('tab', tab)
.removeReferrer()
%}
{% set urlPost = ea_url()
.setController('App\\Controller\\Admin\\Orderonderdeel\\Sub\\OrderonderdeelSubController')
.unset('entityId')
.removeReferrer()
%}
{% if ea.crud.currentAction == 'detail' %}
<table class="table datagrid"> <tr>
{% if hasBatchActions %}
<th>
<div class="form-check">
<span><input type="checkbox" class="form-check-input form-batch-checkbox-all" id="form-batch-checkbox-all"></span>
</div>
</th>
{% endif %}
<th>Aantal</th>
<th>Onderdeel</th>
<th>Materiaal</th>
<th>Bewerking</th>
<th>Lengte</th>
<th>Breedte</th>
<th>Dikte</th>
<th>Opmerkingen</th>
<th>Opslaglocatie</th>
{% if showBestelnr %}
<th>Bestelnr</th>
{% endif %}
{% if showOrdernr %}
<th>Ordernr</th>
{% endif %}
<th>Geleverd</th>
<th></th>
</tr>
{#</tr>#}
{% for value in field.value %}
{% set urlBestelling = '#' %}
{%if value.bestelling %}
{% set urlBestelling = ea_url()
.setController('App\\Controller\\Admin\\Bestelling\\BestellingCrudController')
.setAction('detail')
.set('entityId', value.bestelling.id)
.set('tab', tab)
%}
{% endif %}
{% set urlOrder = '#' %}
{%if value.orderid %}
{% set urlOrder = ea_url()
.setController('App\\Controller\\Admin\\OrderCrudController')
.setAction('detail')
.set('entityId', value.orderid.id)
.set('tab', tab)
%}
{% endif %}
<tr data_id="{{ value.id}}">
{% if hasBatchActions %}
<td
class="batch-actions-selector">
{# filter op niet besteld #}
{% if value.opslaglocatie %}
{% if (not (value.bestelling or value.opslaglocatie.id == opslaglocatieBesteldId)) %}
<div class="form-check">
<input type="checkbox" class="form-check-input form-batch-checkbox" id="form-batch-checkbox-0" value="{{ value.id }}" data-row-index="0">
</div>
{% endif %}
{% endif %}
</td>
{% endif %}
{% set lengte = value.lengte / 10 %}
{% set breedte = value.breedte / 10 %}
{% set dikte = value.dikte / 10 %}
<td>{{ value.aantal }}</td>
<td>{{ value.naam }}</td>
<td>{{ value.materiaal }}</td>
<td>{{ value.bewerking }}</td>
<td>{{ lengte|number_format(1, ',', '.') }}</td>
<td>{{ breedte|number_format(1, ',', '.') }}</td>
<td>{{ dikte|number_format(1, ',', '.') }}</td>
<td>{{ value.opmerkingen|length > maxTextLength ? value.opmerkingen|slice(0,maxTextLength) ~ '...' : value.opmerkingen }}</td>
<td>{{ value.opslaglocatie }}</td>
{% if showBestelnr %}
<td>
<a href="{{ urlBestelling }}">{{ value.bestelling|length > maxTextLength ? value.bestelling|slice(0,maxTextLength) ~'...' : value.bestelling }}</a>
</td>
{% endif %}
{% if showOrdernr and value.orderid %}
<td>
<a href="{{ urlOrder }}">{{ value.orderid|length > maxTextLength ? value.orderid|slice(0,maxTextLength) ~'...': value.orderid }}</a>
</td>
{% endif %}
{% if showOrdernr and not value.orderid %}
<td>{{ 'nvt' }}</td>
{% endif %}
<td>{{ value.aantalGeleverd }}</td>
<td class="actions actions-as-dropdown">
<div class="dropdown dropdown-actions">
<a class="dropdown" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<svg xmlns="http://www.w3.org/2000/svg" height="21" width="21" fill="none" viewbox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h.01M12 12h.01M19 12h.01M6 12a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0z"></path>
</svg>
</a>
<div class="dropdown-menu dropdown-menu-right">
{% set urldetail = ea_url()
.setController('App\\Controller\\Admin\\Orderonderdeel\\Sub\\OrderonderdeelSubController')
.setAction('detail')
.set('entityId' , value.id )
.set('parentControllerFqcn', ea.getCrud().controllerFqcn)
.set('parentEntity', ea.getCrud().entityFqcn)
.set('parentId', entity.instance.id)
.set('tab', tab)
%}
<a class="dropdown-item action-detail" href="{{ urldetail }}" data-action-name="detail">
<span class="action-label">Bekijk</span>
</a>
{% set urledit = ea_url()
.setController('App\\Controller\\Admin\\Orderonderdeel\\Sub\\OrderonderdeelSubController')
.setAction('edit')
.set('entityId' , value.id )
.set('parentControllerFqcn', ea.getCrud().controllerFqcn)
.set('parentEntity', ea.getCrud().entityFqcn)
.set('parentId', entity.instance.id)
.set('tab', tab)
.removeReferrer()
%}
{% if not value.bestelling or hasAlwaysEditAction %}
<a class="dropdown-item action-edit" href="{{ urledit }}" data-action-name="edit">
<span class="action-label">Bewerken</span>
</a>
{% endif %}
</div>
</div>
</td>
</tr>
{# <tr><td colspan="13" ></td></tr> #}
{% endfor %}
</table>
{% set url = ea_url()
.setController('App\\Controller\\Admin\\Orderonderdeel\\Sub\\OrderonderdeelSubController')
.setAction('new')
.unset('entityId')
.set('parentControllerFqcn', ea.getCrud().controllerFqcn)
.set('parentEntity', ea.getCrud().entityFqcn)
.set('parentId', entity.instance.id)
.set('tab', tab)
.removeReferrer()
.generateUrl()
%}
{% set urlBestellen = ea_url()
.setController('App\\Controller\\Admin\\Orderonderdeel\\Sub\\OrderonderdeelSubController')
.setAction('bestellenOnderdelen')
.unset('entityId')
.set('parentControllerFqcn', ea.getCrud().controllerFqcn)
.set('parentEntity', ea.getCrud().entityFqcn)
.set('parentId', entity.instance.id)
.set('tab', tab)
.removeReferrer()
.generateUrl()
%}
{% set urlMateriaalWijzigen = ea_url()
.setController('App\\Controller\\Admin\\Orderonderdeel\\Sub\\OrderonderdeelSubController')
.setAction('materiaalWijzigen')
.unset('entityId')
.set('parentControllerFqcn', ea.getCrud().controllerFqcn)
.set('parentEntity', ea.getCrud().entityFqcn)
.set('parentId', entity.instance.id)
.set('tab', tab)
.removeReferrer()
.generateUrl()
%}
{% set urlBewerkingWijzigen = ea_url()
.setController('App\\Controller\\Admin\\Orderonderdeel\\Sub\\OrderonderdeelSubController')
.setAction('bewerkingWijzigen')
.unset('entityId')
.set('parentControllerFqcn', ea.getCrud().controllerFqcn)
.set('parentEntity', ea.getCrud().entityFqcn)
.set('parentId', entity.instance.id)
.set('tab', tab)
.removeReferrer()
.generateUrl()
%}
{% set urlStdModel = ea_url()
.setController('App\\Controller\\Admin\\Order\\Partial\\OrderPartialControllerModel')
.setAction('edit')
.set('parentControllerFqcn', ea.getCrud().controllerFqcn)
.set('parentEntity', ea.getCrud().entityFqcn)
.set('parentId', entity.instance.id)
.set('tab', tab)
.removeReferrer()
.generateUrl()
%}
<br>
<div class="container p-0">
<div class="d-flex flex-row-reverse justify-content-between">
<div>
<a class="action-new btn btn-primary d-inline-block me-1" href="{{ urlStdModel }}&menuIndex=2&submenuIndex=0">
<span class="action-label ">Kopieer standaard model</span>
</a>
<a class="action-new btn btn-primary d-inline-block " href="{{ url }}&menuIndex=2&submenuIndex=0">
<span class="action-label">Maak nieuw onderdeel</span>
</a>
</div>
<div class="batch-actions d-none">
<div class="dropdown dropdown-actions me-2">
<a class="action-Kies actie btn btn-secundary dropdown-toggle show" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<i class="action-icon fa fa-check"></i>
<span class="action-label">Kies actie</span>
</a>
<div class="dropdown-menu dropdown-menu-right" style="position: absolute; inset: 0px auto auto 0px; margin: 0px; transform: translate(0px, 61px);" data-popper-placement="bottom-start">
{% if (field.value|length) %}
{% if (field.value[0].orderid.recordtype != 'Offerte') %}
<div>
<a id="bestellen" onclick="setModalMelding('bestellen')" class="action-bestellenOnderdelen dropdown-item" href="#" data-action-name="bestellenOnderdelen" data-bs-toggle="modal" data-bs-target="#modal-batch-action" data-action-csrf-token="en een token" data-action-batch="true" data-entity-fqcn="App\Entity\Onderdeel" data-action-url=" {{ urlBestellen }} " disabled="disabled">
Bestel met nieuwe bestelling
</a>
</div>
{% endif %}
{% endif %}
<div>
<a id="materiaal" onclick="setModalMelding('materiaal')" class="action-materiaalWijzigen dropdown-item" href="#" data-action-name="materiaalWijzigen" data-bs-toggle="modal" data-bs-target="#modal-batch-action" data-action-csrf-token="en een token" data-action-batch="true" data-entity-fqcn="App\Entity\Onderdeel" data-action-url=" {{ urlMateriaalWijzigen }} " disabled="disabled">
Materiaal wijzigen
</a>
</div>
<div>
<a id="bewerking" onclick="setModalMelding('bewerking')" class="action-bewerkingWijzigen dropdown-item" href="#" data-action-name="bewerkingWijzigen" data-bs-toggle="modal" data-bs-target="#modal-batch-action" data-action-csrf-token="en een token" data-action-batch="true" data-entity-fqcn="App\Entity\Onderdeel" data-action-url=" {{ urlBewerkingWijzigen }} " disabled="disabled">
Bewerking wijzigen
</a>
</div>
</div>
</div>
</div>
</div>
{% if hasBatchActions %}
<div class="text-muted ms-2 mt-4">
<i class="action-icon fa fa-arrow-up"></i>
<i> Selecteer onderdelen voor actie</i>
</div>
{% endif %}
{% if hasBatchActions %}
<div id="modal-batch-action" class="modal fade" tabindex="-1" style="display: none;" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div id="confirmation-title" class="modal-body">
<h4 id="batch-action-confirmation-title">Onbekende actie!!</h4>
</div>
<div class="modal-footer">
<button type="button" data-bs-dismiss="modal" class="btn btn-secondary">
<span class="btn-label">Annuleren</span>
</button>
<button type="button" id="modal-batch-action-button" data-bs-dismiss="modal" class="btn btn-danger">
<i class="fa fa-fw fa-check"></i>
<span class="btn-label">Verdergaan</span>
</button>
</div>
</div>
</div>
</div>
</div>
{# <form method="POST" action="http://localhost/admin?crudAction=approveOnderdelen&crudControllerFqcn=App\Controller\Admin\OrderonderdeelCrudController"> #}
<script>
function setModalMelding(actie) {
var element = document.getElementById("confirmation-title");
switch (actie) {
case 'materiaal': element.innerHTML = '<h4 id="batch-action-confirmation-title">Wilt u het materiaal wijzigen van de geselecteerde onderdelen?</h4>';
break;
case 'bestellen': element.innerHTML = '<h4 id="batch-action-confirmation-title">Wilt u een nieuwe bestelling maken met de geselecteerde onderdelen?</h4>';
break;
case 'bewerking': element.innerHTML = '<h4 id="batch-action-confirmation-title">Wilt u de bewerking wijzigen van de geselecteerde onderdelen?</h4>';
break;
default: element.innerHTML = '<h4 id="batch-action-confirmation-title">Onbekende actie!!</h4>';
}
}
</script>
{% endif %}
{% else %}
<span class="badge badge-secondary">{{ field.formattedValue }}</span>
{% endif %}