{% extends "base.html" %}
{% block titulo %}
  .::Nuevo - Cliente
{% endblock titulo %}
{% block content1 %} 
      <script type="text/javascript">
        $("#navClien").attr('class','dropdown active');
        $("#navCrearClien").attr('class','active');
      </script>
      <form action="/CrearCliente/" method="POST" data-toggle="validator" role="form"> {% csrf_token %}
        <!--<div class="row"><br><br><br><br></div>-->
        <div class="row">
          <div class="col-md-12 col-sm-12" >
              <div class="panel panel-primary">
                <div class="panel-heading" align="center"> <h4>NUEVO CLIENTE</h4></div>
                <div class="panel-body">
                  <div class="row" id="Result">
                    {% ifnotequal resultado '' %}
                    {% ifequal resultado 'exito' %}
                    <div class="alert alert-success" role="alert" align="center">
                      <h4>OPERACION EXITOSA!!</h4>
                    </div>
                    {% else %}
                    <div class="alert alert-danger" role="alert" align="center">
                      <h4>FALLO OPERACION :( {{resultado}}</h4>
                    </div>
                    {% endifequal %}
                    {% endifnotequal %}
                  </div>
                  <div class="row">
                    <div class="col-md-10 col-md-offset-1">
                      <div class="panel panel-default">
                        <div class="panel-body">
                          <div class="row">
                            <div class="col-md-12">
                              <p class="bg-success" align="center">
                                <!--&nbsp;-->
                                Datos del Cliente
                              </p>
                            </div>
                          </div>
                           <div class="row">
                            <div class="col-md-5 col-md-offset-1">
                                <div class="form-group">
                                  <label class="radio-inline">
                                  <input type="radio" name="TipoPersona" id="rbNatural" value="Natural"required> Persona Natural
                                </label>
                                <label class="radio-inline">
                                  <input type="radio" name="TipoPersona" id="rbJuridica" value="Juridica" required> Persona Juridica
                                </label>
                                  <div class="form-control-feedback" ></div>
                                  <div class="help-block with-errors"></div>
                                </div>
                                <p></p>
                            </div>
                            <div class="col-md-1">
                              <h5 id="dniRUC"> DNI:</h5>
                            </div>
                            <div class="col-md-3">
                              <div class="form-group">
                                <input type="text" class="form-control" id="txtDniC" placeholder="DNI" name="DniCli" maxlength="11" data-minlength="8">
                                <div class="form-control-feedback" style="text-align:left;" ></div>
                                 <div class="help-block with-errors"></div>
                              </div>
                              <p></p>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-md-2 col-md-offset-1">
                              <h5 id = "nombreRazon">Nombres:</h5>
                            </div>
                            <div class="col-md-5">
                              <div class="form-group">
                                <input type="text" class="form-control" id="txtNombreC" placeholder="Nombres" name="NombreCli" required>
                                <div class="form-control-feedback" style="text-align:left;" ></div>
                                <div class="help-block with-errors"></div>
                              </div>
                              <p></p>
                            </div>
                          </div>
                          <div class="row" id="campoAp">
                            <div class="col-md-2 col-md-offset-1">
                              <h5>Apellido P.</h5>
                            </div>
                            <div class="col-md-3">
                              <div class="form-group">
                                 <input type="text" class="form-control" id="txtApCli" placeholder="Apellido Paterno" name="PaternoCli" required>
                                 <div class="form-control-feedback" style="text-align:left;" ></div>
                                 <div class="help-block with-errors"></div>
                              </div>                             
                              <p></p>
                            </div>
                            <div class="col-md-2">
                              <h5>Apellido M.</h5>
                            </div>
                            <div class="col-md-3">
                              <div class="form-group">
                                 <input type="text" class="form-control" id="txtAmCli" placeholder="Apellido Materno" name="MaternoCli" required>
                                 <div class="form-control-feedback" style="text-align:left;" ></div>
                                 <div class="help-block with-errors"></div>
                              </div>                             
                              <p></p>
                            </div>
                          </div> 
                         
                                    
                          <div class="row">
                            <div class="col-md-2 col-md-offset-1">
                              <h5>Teléfono:</h5>
                            </div>
                            <div class="col-md-3">
                              <div class="form-group">
                                 <input type="text" class="form-control" id="txtTelefonoC" placeholder="Telefono" name="TelefonoCli" data-minlength="6">
                                 <div class="form-control-feedback" style="text-align:left;" ></div>
                                 <div class="help-block with-errors"></div>
                              </div>
                              <p></p>
                            </div>
                          </div>  
                          <script type="text/javascript">
                            $(document).ready(function(){
                              $('#txtDniC').numeric();
                              $('#txtTelefonoC').numeric();
                              $('input').on('keypress', function(e){
                                if(e.keyCode == 13)
                                {
                                  var inputs = $(this).parents("form").eq(0).find(":input.form-control");
                                  var idx = inputs.index($(this));
                                  if (idx == inputs.length - 1) {
                                    inputs[0].select()
                                  } 
                                  else {
                                    inputs[idx + 1].focus(); //  handles submit buttons
                                    inputs[idx + 1].select();
                                  }
                                  return false;
                                }
                              });
                                  //$('#decimal').numeric(","); 
                            });
                          </script>
                          <div class="row">
                            <div class="col-md-2 col-md-offset-1">
                              <h5>Direccion:</h5>
                            </div>
                            <div class="col-md-6 ">
                              <div class="form-group">
                                <input type="text" class="form-control" id="txtDir" placeholder="Direccion" name="DircCli" required>
                                <div class="form-control-feedback" style="text-align:left;" ></div>
                                <div class="help-block with-errors"></div>
                              </div>                              
                              <p></p>
                            </div>                            
                          </div>  
                          <div class="row">
                            <div class="col-md-2 col-md-offset-1">
                              <h5>Fecha de Naci</h5>
                            </div>
                            <div class="col-md-4">
                              <div form-group>
                                <input type='text' class="form-control" id='datetimepicker1' name="fechaNaCli" required>
                                <div class="form-control-feedback" style="text-align:left;" ></div>
                                <div class="help-block with-errors"></div>
                              </div>                              
                              <p></p>
                            </div>
                            <script type="text/javascript">

                              $(document).ready(function (){
                                $('#datetimepicker1').datetimepicker({
                                      locale: 'es',
                                      format: 'YYYY-MM-DD'
                                  });

                                $("input[name=TipoPersona]").click(function(){
                                    if($(this).val()=="Natural"){
                                        $("#dniRUC").text("DNI");
                                        $("#nombreRazon").text("Nombres");
                                        $("#campoAp").show();
                                    }
                                    else{
                                        $("#dniRUC").text("RUC");
                                        $("#nombreRazon").text("Razon Social");
                                        $("#campoAp").hide();
                                    }
                                });

                              });
                            </script>
                          </div>
                          <div class="row">
                            <div class="col-md-2 col-md-offset-1">
                              <h5>Email:</h5>
                            </div>
                            <div class="col-md-5">
                              <div class="form-group">
                                <input type="email" class="form-control" id="txtEmail" placeholder="Email" name="EmailCli">
                                <div class="form-control-feedback" style="text-align:left;" ></div>
                                <div class="help-block with-errors"></div>
                              </div>                              
                              <p></p>
                            </div>                            
                          </div>  
                          <div class="row">
                            <div class="col-md-2 col-md-offset-1">
                              <h5>DREM</h5>
                            </div>
                            <div class="col-md-8">
                              <div class="form-group">
                                <input type="text" class="form-control" id="txtDrem" placeholder="DREM" name="DremCli" data-minlength="2">
                                <div class="form-control-feedback" style="text-align:left;" ></div>
                                <div class="help-block with-errors"></div>
                              </div>                              
                              <p></p>
                            </div>                            
                          </div>
                        </div>
                      </div>  
                    </div>
                  </div>
                  <div class="row">
                    <div class="col-md-3 col-md-offset-3 col-xs-4 col-xs-offset-2">
                      <input class="btn btn-primary btn-block" type="submit" value="Guardar">
                    </div>
                    <div class="col-md-3 col-xs-4">
                      <input class="btn btn-default btn-block" type="button" value="Cancelar" id="cancelarTrans">
                    </div>
                  </div>
                </div>
              </div>
          </div>
        </div>
      </form>
{% endblock content1 %}
