{% block formulario_jquery %}
<script type="text/javascript">
function mostrarTextoGeometria(geometria)
{
cadenaRetorno = '';
if (geometria.length)
{
cadena = geometria.replace('POINT(','');
cadena = cadena.replace(')','');
punto = cadena.split(' ');
cadenaRetorno = 'Lat:'+ parseFloat(punto[1]).toFixed(2) + ' Lon:'+ parseFloat(punto[0]).toFixed(2);
}
return cadenaRetorno;
}
{% block formulario_customs_functions %}
{% endblock formulario_customs_functions %}
$(function(){
$('.just_numbers').keypress(function(e){
if (e.which<48 || e.which>57 )
e.preventDefault();
});
$('.just_floats').keypress(function(e){
if (e.which === 46) //el punto
{
//buscar si ya hay un punto
var val = $(this).val();
if (val.indexOf('.')>=0)
{
e.preventDefault();
}
}
else
if (e.which<48 || e.which>57 )
e.preventDefault();
});
$("#crud_form_{{ routeClassName }}").find(".form-control").each(function () {
var idK=$(this).attr('id');
if (idK)
{
var idW = idK.replace('form','');
idW = 'form_{{ routeClassName}}'+ idW;
$(this).attr('id',idW);
$(this).removeClass('form-control');
}
});
{% for key,widget in form %}
{% if key != '_token' %}
{% if widget.vars.attr.readonly is defined %}
$('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').addClass('hide');
{% endif %}
{% if widget.vars.attr.dependiente_parent is defined %}
$('#form_{{ widget.vars.attr.dependiente_parent }}').change(function(){
var selected = $(this).val();
if (selected=="") selected="-1";
// var baseSite = document.getElementById('baseSite').value;
var url = '{{ path('crudDependiente', {'rol': 'all', 'className': widget.vars.attr.dependiente_class, 'fieldName': widget.vars.attr.dependiente_field, 'value': '__VALUE__'}) }}';
url = url.replace('__VALUE__',selected);
// var url = baseSite+"dependientes/{{ widget.vars.attr.dependiente_class }}/{{ widget.vars.attr.dependiente_field }}/"+selected;
$('#{{ key }}').mask(' ');
$('#form_{{ routeClassName }}_{{ key }}').load(url, function(){
$('#{{ key }}').unmask();
});
});
{% endif %}
{% if widget.vars.attr.class is defined %}
{% if isSubString(widget.vars.attr.class,'spinbox-input') %}
{% set min = "" %}
{% if widget.vars.attr.min is defined %}
{% set min = "min: "~widget.vars.attr.min~", " %}
{% endif %}
{% set max = "" %}
{% if widget.vars.attr.max is defined %}
{% set max = "max: "~widget.vars.attr.max~", " %}
{% endif %}
$('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').attr('type','text');
$('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').ace_spinner({ {{ min }}{{ max }} step: 1, on_sides: true, icon_up: 'fas fa-plus', icon_down: 'fas fa-minus ', btn_up_class: 'btn-grey', btn_down_class: 'btn-grey', full_width: true});
{% else %}
{% if isSubString(widget.vars.attr.class,'campo_fecha') %}
$('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').wrap('<div class="input-group" id="campo_fecha_{{ routeClassName }}_{{ key}}" />');
$('#campo_fecha_{{ routeClassName }}_{{ key}}').append('<span class="input-group-addon"><i class="fas fa-calendar bigger-110"></i></span>');
$('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').attr('type','text');
$('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').datepicker({
autoclose: true,
todayHighlight: true,
{% if widget.vars.attr.startDate is defined %}
startDate: '{{ widget.vars.attr.startDate }}',
{% endif %}
{% if widget.vars.attr.endDate is defined %}
endDate: '{{ widget.vars.attr.endDate }}',
{% endif %}
language: '{{ app.request.locale }}'
})
.next().on(ace.click_event, function(){
$(this).prev().focus();
});
{% else %}
{% if isSubString(widget.vars.attr.class,'campo_hora_fecha') %}
$('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').wrap('<div class="input-group" id="campo_fecha_{{ routeClassName }}_{{ key}}" />');
$('#campo_fecha_{{ routeClassName }}_{{ key}}').append('<span class="input-group-addon"><i class="fas fa-calendar bigger-110"></i></span>');
$('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').datetimepicker()
.next().on(ace.click_event, function(){
$(this).prev().focus();
});
{% else %}
{% if isSubString(widget.vars.attr.class,'geometria_punto') %}
$('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').change(function(){
geometria = $(this).val();
valor = mostrarTextoGeometria(geometria);
$('#textoGeometriaPunto').html(valor);
});
$('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').trigger('change');
{% else %}
{% if isSubString(widget.vars.attr.class,'geometria_poligono') %}
$('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').change(function(){
$('#textoGeometriaPoligono').html('Pol�gono definido');
});
if($('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').val())
$('#textoGeometriaPoligono').html('Pol�gono definido');
{% else %}
{% if isSubString(widget.vars.attr.class,'dolar') %}
$('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').wrap('<div class="input-group"/>');
$('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').parent().prepend("<span class='input-group-addon'>$</span>");
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% block formulario_customs_jquery %}
{% endblock formulario_customs_jquery %}
});
</script>
{% endblock %}
{% block formulario_content %}
{% block secondary_heading %}
{% endblock %}
{% if not btnSave is defined %}
{% set btnSave='btn_do_and_list' %}
{% endif %}
{% block pre_form %}
{% endblock %}
{% block form_action %}
{% endblock %}
{% block form %}
{% set rowopen=false %}
{% set maxcol=formColumns %}
{% set col=0 %}
{% block form_pre_rows %}
{% endblock form_pre_rows %}
{% for param, value in paramsRequest %}
{% if value is iterable %}
{% for val in value %}
<input name="{{ param }}" type='hidden' value='{{ val }}'>
{% endfor %}
{% else %}
<input id="{{ param }}" name="{{ param }}" type='hidden' value='{{ value }}'>
{% endif %}
{% endfor %}
<input id='form_accion_{{ routeClassName }}' type='hidden' value='{{ accion }}'>
{#% for key,widget in form %}
{% for k,el in widget.vars if k != 'is_selected'%}
{% if k=='attr' or k=='form' or k=='block_prefixes' or k=='errors' or k=='label_attr' or k=='preferred_choices' or k=='choices' %}
{% for k1,el1 in widget.vars.attr %}
{{ k }}=>{{ k1 }}=>{{ el1 }}<br>
{% endfor %}
{% else %}
{{ k }}=>{{ el }}<br>
{% endif %}
{% endfor %}
{% endfor %#}
{% for key,widget in form %}
{% if notShow[key] is not defined %}
{% if widget.vars.attr['containerclass'] is defined %}
{% if isSubString(widget.vars.attr['containerclass'],'full-row') %}
{% if rowopen %}
</div>
<div class="row">
{% endif %}
{% set col=maxcol-1 %}
{% endif %}
{% endif %}
{% if not rowopen %}
{% block rowopen %}
<div class="row">
{% endblock rowopen %}
{% set rowopen=true %}
{% endif %}
{#% for k,el in widget.vars if k != 'is_selected'%}
{% if k=='attr' or k=='form' or k=='block_prefixes' or k=='errors' or k=='label_attr' or k=='preferred_choices' or k=='choices' %}
{% for k1,el1 in widget.vars.attr %}
{{ k }}=>{{ k1 }}=>{{ el1 }}<br>
{% endfor %}
{% else %}
{{ k }}=>{{ el }}<br>
{% endif %}
{% endfor %#}
{% block draw_widget %}
{% set col_class='col-xs-12' %}
{% if widget.vars.attr['containerclass'] is not defined or not isSubString(widget.vars.attr['containerclass'],'full-row') %}
{% if maxcol>1 %}
{% set col_class=col_class~' col-sm-6' %}
{% endif %}
{% set col_class=col_class~' col-md-'~12/maxcol %}
{% endif %}
{% if widget.vars.attr['containerclass'] is defined %}
{% set col_class=col_class~' '~widget.vars.attr['containerclass'] %}
{% endif %}
<div id="{{key}}" class="{{ col_class }}">
<table class="table table-striped table-bordered table-hover">
<tr>
<th style="width: {{ widthLabel }}; vertical-align: middle">
{% set required = '' %}
{% if widget.vars.required %}
{% set required = 'required' %}
{% endif %}
<label class="crud_label {{required}}" id="label_form_{{ routeClassName }}_{{ key }}" {% if widget.vars.attr.tip is defined %}data-rel="tooltip" data-trigger="hover" data-placement="top" data-content="More details." title="{{ widget.vars.attr.tip }}" style="cursor: help"{% endif %}>
{{widget.vars.label}}
</label>
{% if widget.vars.attr.relation is defined %}
<label onclick="javascript:creaNuevoRelacion('{{ routeClassName }}','form_{{ routeClassName }}_{{ key }}'); return false;" class="relacion" data-rel="tooltip" data-trigger="hover" data-placement="top" data-content="More details." title="Si no encuentra en la lista la información que necesita, pinche aquí para adicionarla" style="cursor: pointer" itemid="form_{{ routeClassName }}_{{ key }}">
<i class="icon fas fa-plus-square green" itemid="{{ widget.vars.id }}"></i>
</label>
{% endif %}
</th>
<td style="vertical-align: middle" class="crud_td">
{% if widget.vars.type is defined and widget.vars.type=='file' and entity.getFieldValue(widget.vars.name)%}
<div id="hidefile_{{ routeClassName }}_{{ widget.vars.id }}">
{% if widget.vars.attr.accept is defined and isSubString(widget.vars.attr.accept,'image') %}
<img src="{{ absolute_url(entity.getFieldValue(widget.vars.name).getUrl()) }}" width='80px'>
{% else %}
<a target="_blank" href="{{ absolute_url(entity.getFieldValue(widget.vars.name).getUrl()) }}">{{entity.getFieldValue(widget.vars.name).getFileName() }}</a>
{% endif %}
{% if widget.vars.attr.readonly is not defined %}
<span class="action-buttons">
<a class="hide_item_{{ routeClassName }}" id="hide_form_{{ routeClassName }}_{{ key }}" item_id="form_{{ key }}" href=""><i class="fas fa-trash red bigger-130" title="{% trans from 'crud' %}botones.eliminar_adjunto{% endtrans %}"></i></a>
</span>
{% endif %}
<input type="hidden" id="oldfile_form_{{ routeClassName }}_{{ key }}" value="clear" name="oldfile[{{ widget.vars.name }}]">
</div>
{% if widget.vars.attr.readonly is not defined %}
<div id="file_{{ routeClassName }}_form_{{ key }}" class="hide {% if widget.vars.required is defined and widget.vars.required %}required{% endif %}">
{{ form_widget(widget) }}
</div>
{% endif %}
{% else %}
{% if widget.vars.attr.class is defined and isSubString(widget.vars.attr.class,'geometria_punto') %}
<a class="botonmapaPunto noti btn-minier" title="Definir Ubicación en Mapa" itemid="form_{{ routeClassName }}_{{ key }}" geom="punto" href="#">
<i class="ace-icon fa fa-globe bigger-220 blue"></i>
</a>
<span id="textoGeometriaPunto"></span>
{{ form_widget(widget) }}
{% else %}
{% if widget.vars.attr.class is defined and isSubString(widget.vars.attr.class,'geometria_poligono') %}
<a class="botonmapa noti btn-minier" title="Definir Ubicación en Mapa" itemid="form_{{ routeClassName }}_{{ key }}" geom="poligono" href="#">
<i class="fas fa-globe bigger-220 blue"></i>
</a>
<span id="textoGeometriaPoligono"></span>
{{ form_widget(widget) }}
{% else %}
{% if widget.vars.attr.class is defined and isSubString(widget.vars.attr.class,'ace-switch') %}
<div style="text-align: center">
<label class="block" style='margin-bottom: 0! important'>
{{ form_widget(widget) }}
<span class="lbl" data-lbl="{{ 'choice_value.yes' | trans({}, 'crud') | upper}} {{ 'choice_value.no' | trans({}, 'crud') | upper}}"></span>
</label>
</div>
{% else %}
{% if widget.vars.attr.readonly is defined %}
<span id="span_{{ routeClassName }}_{{ key }}">{{ entity.getFieldValue(widget.vars.name, true) }}</span>
{% else %}
{{ form_widget(widget) }}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
</td>
</tr>
</table>
</div>
{% endblock draw_widget %}
{% set col = col + 1 %}
{% if col == maxcol %}
{% block rowclose %}
</div>
{% endblock rowclose %}
{% set rowopen=false %}
{% set col=0 %}
{% endif %}
{%endif%}
{% endfor %}
{% if rowopen %}
</div>
{% endif %}
{% block form_post_rows %}
{% endblock form_post_rows %}
<div class="row hide">
<table>{{ form_rest(form) }}</table>
</div>
{% endblock %}
{% block post_form %}
<input type="hidden" id="relaciontarget-{{ routeClassName }}">
<input type="hidden" id="relacionnombre-{{ routeClassName }}">
<div id="dialog-mapa-{{ routeClassName }}" title="Definir Ubicación en Mapa"></div>
<div id="dialog-relacion-{{ routeClassName }}" title="Definir elemento"></div>
{% endblock %}
{% block botones_form %}
<div class="row">
<div class="col-xs-12">
<div class="hr hr-8 hr-dotted"></div>
</div>
</div>
{% endblock %}
{% block end_form %}
{{ form_end(form) }}
{% endblock %}
{% endblock formulario_content %}