src/templates/ReclutaProceso/redistribuyeUnidad.html.twig line 1

Open in your IDE?
  1. {% extends "@crud\\crud.html.twig" %}
  2. {% block jquery %}
  3.     {{ parent() }}
  4.     <script type="text/javascript">
  5.         $(function()
  6.         {
  7.             var sexo='';
  8.             $('.chosen-select').chosen({allow_single_deselect:true}); 
  9.             $("#buscar").click(function(e){
  10.                 e.preventDefault();
  11.                 if ($('#centroInstruccion').val() && $('#unidadOrigen').val()  && $('#unidadDestino').val() && sexo)
  12.                 {
  13.                     if ($('#unidadOrigen').val() != $('#unidadDestino').val())
  14.                     {
  15.                         var url='{{ path('ajax_get_info_for_redistribution', {'unidadOrigen': '__UO__', 'unidadDestino': '__UD__', 'sexo': '__SEXO__'}) }}';
  16.                         url=url.replace('__UO__',$('#unidadOrigen').val());
  17.                         url=url.replace('__UD__',$('#unidadDestino').val());
  18.                         url=url.replace('__SEXO__',sexo);
  19.                         $('#contenedor_cambio').mask('&nbsp;&nbsp;&nbsp;&nbsp;Buscando...');
  20.                         $.getJSON(url , function(result){
  21.                             $('#contenedor_cambio').unmask();
  22.                             if (result.ok)
  23.                             {
  24.                                 $('#transfer').removeClass('hide');
  25.                                 $('#transferOptions').removeClass('hide');
  26.                                 $('#selcant').val(result.capacidad);
  27.                                 $('#selcant').attr('capacidad',result.capacidad);
  28.                                 $('#maxtransf').html(result.capacidad);
  29.                                 $('#reclutas').html(result.reclutas);
  30.                                 $("#reclutas").trigger('chosen:updated');
  31.                             }
  32.                             else
  33.                             {
  34.                                 showError(bootbox, result.error);
  35.                             }
  36.                         });
  37.                     }
  38.                     else
  39.                         alert('La unidad de orígen debe ser diferente a la de destino');
  40.                 }
  41.                 else
  42.                     alert('Debe completar toda la información para poder realizar la búsqueda');
  43.             });        
  44.             $("#sexoF").click(function(e){
  45.                 $('#transfer').addClass('hide');
  46.                 $('#transferOptions').addClass('hide');
  47.                 $('#searchOptions').addClass('hide');
  48.                 sexo='F';
  49.                 if ($("#centroInstruccion").val())
  50.                     getUnidades(sexo);
  51.             });
  52.             $("#sexoM").click(function(e){
  53.                 $('#transfer').addClass('hide');
  54.                 $('#transferOptions').addClass('hide');
  55.                 $('#searchOptions').addClass('hide');
  56.                 sexo='M';
  57.                 if ($("#centroInstruccion").val())
  58.                     getUnidades(sexo);
  59.             });
  60.             $("#centroInstruccion").change(function(e){
  61.                 $('#transfer').addClass('hide');
  62.                 $('#transferOptions').addClass('hide');
  63.                 $('#searchOptions').addClass('hide');
  64.                 if ($(this).val() && sexo)
  65.                 {
  66.                     getUnidades(sexo);
  67.                 }
  68.             }); 
  69.             $('#unidadOrigen').change(function(e){
  70.                 $('#transferOptions').addClass('hide');
  71.                 $('#transfer').addClass('hide');
  72.             });
  73.             $('#unidadDestino').change(function(e){
  74.                 $('#transferOption').addClass('hide');
  75.                 $('#transfer').addClass('hide');
  76.             });
  77.             $('#transferByQ').click(function(e){
  78.                 $('#spanCant').removeClass('hide');
  79.                 $('#contenedor_reclutas').addClass('hide');
  80.                 $('#reclutas').val('');
  81.                 $("#reclutas").trigger('chosen:updated');
  82.             });
  83.             $('#transferByS').click(function(e){
  84.                 $('#spanCant').addClass('hide');
  85.                 $('#selcant').val($('#selcant').attr('capacidad'));
  86.                 $('#contenedor_reclutas').removeClass('hide');
  87.             });
  88.             $('.just_numbers').keypress(function(e){
  89.                 if (e.which<48 || e.which>57 )
  90.                     e.preventDefault();
  91.             });
  92.             $('#transferir').click(function(e){
  93.                 e.preventDefault();
  94.                 if ($('#selcant').val()*1>$('#selcant').attr('capacidad')*1 || $('.search-choice').length>$('#selcant').attr('capacidad')*1)
  95.                 {
  96.                     alert("La cantidad de reclutas a transferir no puede exceder el cupo disponible ("+$('#selcant').attr('capacidad')+") en la unidad de destino");
  97.                 }
  98.                 else
  99.                 {
  100.                     $('#contenedor_cambio').mask('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Redistribuyendo reclutas...');
  101.                     $('#reclutasinput').val($('#reclutas').val());
  102.                     $('#redistform').ajaxSubmit({
  103.                         type: $('#redistform').attr('method'),
  104.                         url: $('#redistform').attr('action'),
  105.                         dataType: 'json',
  106.                         data: { _xml_http_request: true },
  107.                         success: function(data) {
  108.                             if (data.ok)
  109.                             {  
  110.                                 jAlert(data.message,'Información', function(r){
  111.                                     document.location.href='';
  112.                                 });
  113.                             }
  114.                             else
  115.                             {
  116.                                 jAlert(data.message,'Información');
  117.                                 $('#contenedor_cambio').unmask();
  118.                             }
  119.                         }
  120.                     });
  121.                 }
  122.             });
  123.         
  124.         });
  125.         
  126.     </script>    
  127.     
  128.     
  129. {% endblock %}
  130. {% block jquery_functions %}
  131.     {{ parent() }}
  132.     function getUnidades(sexo){
  133.         var c=0;
  134.         $('#searchOptions').removeClass('hide');
  135.         $('#contenedor_cambio').mask('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cargando unidades...');
  136.         var urlO = '{{ path('ajax_procesounidades_por_centro_instruccion_registrados', {'centro': '__CENTRO__', 'sexo': '__SEXO__'}) }}';
  137.         urlO = urlO.replace('__CENTRO__', $('#centroInstruccion').val());
  138.         urlO = urlO.replace('__SEXO__', sexo);
  139.         $('#unidadOrigen').load(urlO, function(){
  140.             c++;
  141.             $("#unidadOrigen").trigger('chosen:updated');
  142.             if (c==2)
  143.                 $('#contenedor_cambio').unmask();
  144.         });  
  145.         var urlD = '{{ path('ajax_procesounidades_por_centro_instruccion_cupo', {'centro': '__CENTRO__', 'sexo': '__SEXO__'}) }}';
  146.         urlD = urlD.replace('__CENTRO__', $('#centroInstruccion').val());
  147.         urlD = urlD.replace('__SEXO__', sexo);
  148.         $('#unidadDestino').load(urlD, function(){
  149.             c++;
  150.             $("#unidadDestino").trigger('chosen:updated');
  151.             if (c==2)
  152.                 $('#contenedor_cambio').unmask();
  153.         });  
  154.     }
  155.     
  156. {% endblock jquery_functions %}
  157. {% block content %}
  158.     <div class="widget-box transparent">
  159.         <div class="widget-header widget-header-flat">
  160.             <h4 class="widget-title lighter">
  161.                 <i class="fas fa-pencil-alt orange"></i>
  162.                 Redistribuir conscriptos entre unidades
  163.             </h4>
  164.         </div>
  165.         <div id='contenedor_cambio' class="widget-body" style="display: block;">
  166.             {% if proceso is defined %}
  167.                 <div class="widget-main no-padding">
  168.                     <br>
  169.                     <form id="redistform" action="{{ path('ajax_redistribute') }}" method="POST">
  170.                         <div class="row">
  171.                             <div class="col-xs-12 col-sm-6" style="margin-top: 20px;">
  172.                                 <table class="table table-striped table-bordered table-hover">
  173.                                     <tr>
  174.                                         <th style="width: 200px;">
  175.                                             <label>
  176.                                                 Centro de instrucción:
  177.                                             </label>
  178.                                         </th>
  179.                                         <td style="vertical-align: middle">
  180.                                             <select id="centroInstruccion" class='chosen-select' {% if centroUsuario is defined %}readonly='true' disabled='true'{% endif %}>
  181.                                                 <option value="">-- Seleccione --</option>
  182.                                                 {% for centro in centros %}
  183.                                                     {% if centroUsuario is defined and centroUsuario==centro.id %}
  184.                                                         <option value='{{ centro.id}}' selected="selected">{{ centro }}</option>
  185.                                                     {% else %}
  186.                                                         <option value='{{ centro.id}}'>{{ centro }}</option>
  187.                                                     {% endif %}
  188.                                                 {% endfor %}
  189.                                             </select>   
  190.                                         </td>    
  191.                                     </tr>    
  192.                                 </table> 
  193.                             </div>
  194.                             <div class="col-xs-12 col-sm-6" style="margin-top: 20px;">
  195.                                 <table class="table table-striped table-bordered table-hover">
  196.                                     <tr>
  197.                                         <th style="width: 200px;">
  198.                                             <label>
  199.                                                 Sexo:
  200.                                             </label>
  201.                                         </th>
  202.                                         <td style="vertical-align: middle">
  203.                                             <input type="radio" name="distribucion[sexo]" id="sexoF" value='F'> Femenino&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  204.                                             <input type="radio" name="distribucion[sexo]" id="sexoM" value='M'> Masculino
  205.                                         </td>    
  206.                                     </tr>    
  207.                                 </table> 
  208.                             </div>
  209.                         </div>
  210.                         <div id="searchOptions" class="row hide">
  211.                             <div class="col-xs-12 col-sm-6" style="margin-top: 20px;">
  212.                                 <table class="table table-striped table-bordered table-hover">
  213.                                     <tr>
  214.                                         <th style="width: 200px;">
  215.                                             <label>
  216.                                                 Unidad militar de origen:
  217.                                             </label>
  218.                                         </th>
  219.                                         <td style="vertical-align: middle">
  220.                                             <select name="distribucion[unidadOrigen]" id="unidadOrigen" class='chosen-select'>
  221.                                                 <option value="">-- Seleccione --</option>
  222.                                                 {% for unidad in unidades %}
  223.                                                     <option value='{{ unidad.id}}'>{{ unidad }}</option>
  224.                                                 {% endfor %}
  225.                                             </select>
  226.                                         </td>    
  227.                                     </tr>    
  228.                                 </table> 
  229.                             </div>
  230.                             <div class="col-xs-12 col-sm-6" style="margin-top: 20px;">
  231.                                 <table class="table table-striped table-bordered table-hover">
  232.                                     <tr>
  233.                                         <th style="width: 200px;">
  234.                                             <label>
  235.                                                 Unidad militar de destino:
  236.                                             </label>
  237.                                         </th>
  238.                                         <td style="vertical-align: middle">
  239.                                             <select name="distribucion[unidadDestino]" id="unidadDestino" class='chosen-select'>
  240.                                                 <option value="">-- Seleccione --</option>
  241.                                                 {% for unidad in unidades %}
  242.                                                     <option value='{{ unidad.id}}'>{{ unidad }}</option>
  243.                                                 {% endfor %}
  244.                                             </select>   
  245.                                         </td>    
  246.                                     </tr>    
  247.                                 </table> 
  248.                             </div>
  249.                             <div class="col-xs-12" style="margin-top: 20px;">
  250.                                 <button id="buscar">Buscar</button>   
  251.                             </div>
  252.                         </div>
  253.                         <div id="transferOptions" class="row hide">
  254.                             <div class="col-xs-12 col-sm-6" style="margin-top: 20px;">
  255.                                 <table class="table table-striped table-bordered table-hover">
  256.                                     <tr>
  257.                                         <th style="width: 200px;">
  258.                                             <label>
  259.                                                 Transferir por:<br>
  260.                                             </label>
  261.                                         </th>
  262.                                         <td style="vertical-align: middle">
  263.                                             <input type="radio" name="distribucion[transferBy]" id="transferByS" value='S' checked='true'> Selección&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  264.                                             <input type="radio" name="distribucion[transferBy]" id="transferByQ" value='Q'> Cantidad&nbsp;&nbsp;&nbsp;<span id="spanCant" class="hide"><input type="text" id="selcant" name="distribucion[cantidad]" class="just_numbers" placeholder="Indique cuántos"></span>
  265.                                         </td>    
  266.                                     </tr>    
  267.                                 </table> 
  268.                             </div>
  269.                             <div class="col-xs-12 col-sm-6" style="margin-top: 20px;">
  270.                                 <table class="table table-striped table-bordered table-hover">
  271.                                     <tr>
  272.                                         <th style="width: 200px;">
  273.                                             <label style="float: none;">
  274.                                                 Puede transferir hasta <span id='maxtransf'>10</span> reclutas.
  275.                                             </label>
  276.                                         </th>
  277.                                     </tr>    
  278.                                 </table> 
  279.                             </div>
  280.                         </div>
  281.                         <div id="transfer" class="row hide">
  282.                             <div id="contenedor_reclutas" class="col-xs-12" style="margin-top: 20px;">
  283.                                 <table class="table table-striped table-bordered table-hover">
  284.                                     <tr>
  285.                                         <th style="width: 200px;">
  286.                                             <label>
  287.                                                 Seleccione reclutas a transferir:
  288.                                             </label>
  289.                                         </th>
  290.                                         <td style="vertical-align: middle">
  291.                                             <select id="reclutas" class='chosen-select' multiple='true' placeholder="-- Seleccione --">
  292.                                             </select>
  293.                                             <input type='hidden' id='reclutasinput' name="distribucion[reclutas]">
  294.                                         </td>    
  295.                                     </tr>    
  296.                                 </table> 
  297.                             </div>
  298.                             <div class="col-xs-12" style="margin-top: 20px;">
  299.                                 <button id="transferir">Transferir</button>   
  300.                             </div>
  301.                         </div>
  302.                     </form>
  303.                 </div>                   
  304.             {% else %}
  305.                 NO HAY PROCESO ACTIVO
  306.             {% endif %}
  307.         </div>                   
  308.     </div>
  309. {% endblock %}