{% extends "@crud\\crud\\index_inner.html.twig" %}
{% block button_new_no_elements_href %}
{% if idParent is defined %}
href="{{ path('crud_plain_new', { 'rol': rol, 'routeClassName': routeClassName, 'idParent': idParent} ) }}"
{% else %}
{{ parent() }}
{% endif %}
{% endblock button_new_no_elements_href %}
{% block button_new_no_elements_onclick %}
{% set texto = routeClassName~'.singular' %}
onclick='javascript:creaNuevo("{{ routeClassName }}", "{{ texto | trans({}, 'crud') }}", {{ widthModalForm }}, {{ heightModalForm }}); return false;'
{% endblock button_new_no_elements_onclick %}
{% block button_new_elements %}
{% set texto = routeClassName~'.singular' %}
{% set onClick = "javascript:creaNuevo('"~routeClassName~"', '"~ texto | trans({}, 'crud') ~"',"~ widthModalForm ~","~ heightModalForm ~"); return false;" %}
{% if idParent is defined %}
.append("<span id='{{routeClassName}}_botonNuevoDiv' class='forChanges'><a id='{{routeClassName}}_botonNuevoBoton' onclick='{{ onClick }}' href='{{ path('crud_plain_new', { 'rol': rol, 'routeClassName': routeClassName, 'idParent': idParent} ) }}'><button class='btn btn-white btn-inverse btn-bold btn-round' title='{% trans from 'crud' %}botones.nuevo{% endtrans %}'><i class='fas fa-plus green'></i><span class='hidden-xs'>{% trans from 'crud' %}botones.nuevo{% endtrans %}</span></button></a></span>")
{% else %}
.append("<span id='{{routeClassName}}_botonNuevoDiv' class='forChanges'><a id='{{routeClassName}}_botonNuevoBoton' onclick='{{ onClick }}' href='{{ path('crud_plain_new', { 'rol': rol, 'routeClassName': routeClassName} ) }}'><button class='btn btn-white btn-inverse btn-bold btn-round' title='{% trans from 'crud' %}botones.nuevo{% endtrans %}'><i class='fas fa-plus green'></i><span class='hidden-xs'>{% trans from 'crud' %}botones.nuevo{% endtrans %}</span></button></a></span>")
{% endif %}
{% endblock button_new_elements %}
{% block results %}
{{ parent() }}
<div id='dialog_{{ routeClassName }}'></div>
<div id='dialog_show_{{ routeClassName }}'></div>
{% set filter = [] %}
{% if filterData is defined %}
{% set filter = filterData %}
{% endif %}
{% set parent = '' %}
{% if idParent is defined %}
{% set parent = idParent %}
{% endif %}
{% autoescape %}
{% set urlReload = path('crud_index', {'rol': rol, 'routeClassName': routeClassName, 'filterData': filter, 'idParent' : parent, 'view': index_view} ) %}
<input type='hidden' id='urlReload' value='{{ urlReload }}'>
{% endautoescape %}
{% endblock %}
{% block show_action %}
{% set href = path('crud_plain_show', { 'rol': rol, 'id': entity.id, 'routeClassName': routeClassName }) %}
{% set texto=routeClassName~'.singular' %}
<a href="" itemid="{{ entity.id }}" onclick="javascript:showModal('{{ routeClassName }}','{{ href }}', '{{ texto | trans({}, 'crud') }}'); return false;">
<i class="{{ buttons['view'] }}" title="{% trans from 'crud' %}index.acciones.show_alt{% endtrans %}"></i>
</a>
{% endblock show_action %}
{% block edit_action %}
{% if idParent is defined %}
{% set href=path('crud_plain_edit', { 'rol': rol, 'id': entity.id, 'routeClassName': routeClassName, 'idParent': idParent }) %}
{% else %}
{% set href=path('crud_plain_edit', { 'rol': rol, 'id': entity.id, 'routeClassName': routeClassName }) %}
{% endif %}
{% set texto=routeClassName~'.singular' %}
<a href="" itemid="{{ entity.id }}" onclick="javascript:editModal('{{ routeClassName }}','{{ href }}', '{{ texto | trans({}, 'crud') }}', {{ widthModalForm }}, {{ heightModalForm }}); return false;">
<i class="{{ buttons['edit'] }}" title="{% trans from 'crud' %}index.acciones.edit_alt{% endtrans %}"></i>
</a>
{% endblock edit_action %}
{% block delete_action %}
{% if idParent is defined %}
{% set href=path('crud_plain_delete', { 'rol': rol, 'id': entity.id, 'routeClassName': routeClassName, 'idParent': idParent }) %}
{% else %}
{% set href=path('crud_plain_delete', { 'rol': rol, 'id': entity.id, 'routeClassName': routeClassName }) %}
{% endif %}
<a class="del_modal_{{ routeClassName }}" href="{{ href }}" itemid="{{ entity.id }}">
<i class="{{ buttons['delete'] }}" title="{% trans from 'crud' %}index.acciones.delete_alt{% endtrans %}"></i>
</a>
{% endblock delete_action %}
{% block table_index_jquery %}
{{ parent() }}
{% if heightModalForm is not defined %}
{% set heightModalForm = 770 %}
{% endif %}
{% if widthModalForm is not defined %}
{% set widthModalForm = 1000 %}
{% endif %}
$("#dialog_{{ routeClassName }}").dialog({
autoOpen: false,
width: {{ widthModalForm }},
height: {{ heightModalForm }},
modal: true,
resizable: false,
title_html: true,
title: "<div id='texto' class='widget-header widget-header-small'><h4 class='smaller red'><i class='fas fa-shopping-cart'></i> </h4></div>",
{% block dialog_events %}{% endblock dialog_events %}
buttons: {
{% block dialog_buttons %}
{% block dialog_buttons_save %}
"{{ 'botones.grabar' | trans({}, 'crud') | upper }}": function() {
if (validaDatos{{ routeClassName }}())
{
// var form = $('#crud_form_{{ routeClassName }}');
var form = $('#dialog_{{ routeClassName }}').children('form');
if ($(form).find('.wrong_email').length>0)
{
alert('Correo electrónico incorrecto');
return false;
}
$( "#dialog_{{ routeClassName }}" ).parent().mask(" Actualizando...");
$(form).ajaxSubmit({
type: form.attr('method'),
url: form.attr('action'),
dataType: 'json',
data: { _xml_http_request: true },
success: function(data) {
if (data.ok)
{
$( "#dialog_{{ routeClassName }}" ).dialog( "close" );
$( "#dialog_{{ routeClassName }}" ).parent().unmask();
{% set filter = [] %}
{% if filterData is defined %}
{% set filter = filterData %}
{% endif %}
{% set parent = '' %}
{% if idParent is defined %}
{% set parent = idParent %}
{% endif %}
var url="{% autoescape %}{{ path('crud_index', {'rol': rol, 'routeClassName': routeClassName, 'filterData': filter, 'idParent' : parent, 'view': index_view} ) }}{% endautoescape %}";
reloadContenedor('{{ routeClassName }}',url);
}
else
{
showError(bootbox,data.error);
$( "#dialog_{{ routeClassName }}" ).parent().unmask();
}
}
})
}
},
"{{ 'botones.grabar_y_crear' | trans({}, 'crud') | upper }}": function() {
if (validaDatos{{ routeClassName }}())
{
var form = $('#crud_form_{{ routeClassName }}');
if ($(form).find('.wrong_email').length>0)
{
alert('Correo electrónico incorrecto');
return false;
}
$( "#dialog_{{ routeClassName }}" ).parent().mask(" Actualizando...");
$(form).ajaxSubmit({
type: form.attr('method'),
url: form.attr('action'),
dataType: 'json',
data: { _xml_http_request: true },
success: function(data) {
if (data.ok)
{
{% set filter = [] %}
{% if filterData is defined %}
{% set filter = filterData %}
{% endif %}
{% set parent = '' %}
{% if idParent is defined %}
{% set parent = idParent %}
{% endif %}
var url="{% autoescape %}{{ path('crud_index', {'rol': rol, 'routeClassName': routeClassName, 'filterData': filter, 'idParent' : parent, 'view': index_view} ) }}{% endautoescape %}";
reloadContenedor('{{ routeClassName }}',url);
var urlForm=$("#{{ routeClassName }}_botonNuevoBoton").attr("href");
$('#dialog_{{ routeClassName }}').load(urlForm, function(){
$('#dialog_{{ routeClassName }}').parent().unmask();
});
}
else
{
showError(bootbox,data.error);
$( "#dialog_{{ routeClassName }}" ).parent().unmask();
}
}
})
}
},
{% endblock dialog_buttons_save %}
{% block dialog_buttons_cancel %}
"{{ 'botones.cancelar' | trans({}, 'crud') | upper }}": function() {
$( "#dialog_{{ routeClassName }}" ).dialog( "close" );
}
{% endblock dialog_buttons_cancel %}
{% endblock dialog_buttons %}
}
});
{% if heightModalShow is not defined %}
{% set heightModalShow = heightModalForm %}
{% endif %}
{% if widthModalShow is not defined %}
{% set widthModalShow = widthModalForm %}
{% endif %}
$("#dialog_show_{{ routeClassName }}").dialog({
autoOpen: false,
height: {{ heightModalShow }},
width: {{ widthModalShow }},
modal: true,
resizable: false,
title_html: true,
title: "<div id='texto' class='widget-header widget-header-small'><h4 class='smaller red'><i class='fas fa-shopping-cart'></i> </h4></div>",
buttons: {
"{{ 'botones.cerrar' | trans({}, 'crud') | upper }}": function() {
$( "#dialog_show_{{ routeClassName }}" ).dialog( "close" );
}
}
});
$(".del_modal_{{ routeClassName }}").click(function(e){
e.preventDefault();
if (confirm("{{ 'delete.confirm' | trans({}, 'crud') }}"))
{
$('#contenedor_{{ routeClassName }}').mask(" Actualizando...");
$.ajax({
type: "GET",
url: $(this).attr("href"),
dataType: 'json',
data: { _xml_http_request: true },
success: function(html){
if (html.ok)
{
{% if filterData is defined %}
var url="{{ path('crud_index', {'rol': rol, 'routeClassName': routeClassName, 'filterData': filterData, 'view': index_view} ) }}";
{% else %}
var url="{{ path('crud_index', {'rol': rol, 'routeClassName': routeClassName, 'view': index_view} ) }}";
{% endif %}
reloadContenedor('{{ routeClassName }}',url);
}
else
{
$('#contenedor_{{ routeClassName }}').unmask();
showError(bootbox, html.error);
}
}
});
}
});
{% endblock table_index_jquery %}
{% block table_index_functions %}
{{ parent() }}
function validaDatos{{ routeClassName }}()
{
{% block valida_datos %}
return true;
{% endblock valida_datos %}
}
{% endblock table_index_functions %}
{% block principal_heading %}
{% endblock %}