{% include 'a_header.twig' %}


            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                {% if mode != 'edit' %}
                    <h2>Añadir nuevo servidor</h2>
                {% else %}
                    <h2>Editar servidor {{server.Name}}</h2>
                {% endif %}
                    <ul class="nav navbar-right panel_toolbox">
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                    <br />
                    <form id="demo-form2" method="POST" action="?page={% if mode == 'edit' %}saveeditserver{% else %}savenewserver{% endif %}&id_serv={{server.ID_SERV}}" data-parsley-validate class="form-horizontal form-label-left">

                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Nombre del servidor <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" id="name" name="name" required="required" class="form-control col-md-7 col-xs-12" value="{{server.Name}}"/>
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="IP">IP del servidor <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" id="IP" name="IP" required="required" class="form-control col-md-7 col-xs-12" value="{{server.IP}}"/>
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="description">Descripción <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" id="description" name="description" required="required" class="form-control col-md-7 col-xs-12" value="{{server.Description}}"/>
                        </div>
                      </div>
                      {% if mode != 'edit' %}
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">Sistema operativo</label>
                        <div class="col-md-9 col-sm-9 col-xs-12">
                          <div id="so" class="btn-group" data-toggle="buttons">
                            <label class="btn btn-default  {%if server.SO == 'WINDOWS' %} active {%endif%}" data-toggle-class="btn-primary" data-toggle-passive-class="btn-default" data-toggle="tooltip" data-placement="top" title="Trabaja con WMI para recoger datos. Soporte bueno desde Windows 2003/XP">
                              <input type="radio" name="so" value="WINDOWS" {%if server.SO == 'WINDOWS' %} checked="checked" {%endif%}> Windows
                            </label>
                            {#<label class="btn btn-default {%if server.SO == 'LINUX_SYSTEMD' %} active {%endif%}" data-toggle-class="btn-primary" data-toggle-passive-class="btn-default" data-toggle="tooltip" data-placement="top" title="Sistemas Linux que usen Systemd como Ubuntu 14.04+, Debian 8+...">
                              <input type="radio" name="so" value="LINUX_SYSTEMD" {%if server.SO == 'LINUX_SYSTEMD' %} checked="checked" {%endif%}> Linux (Systemd)
                            </label>
                            <label class="btn btn-default {%if server.SO == 'LINUX_SERVICE' %} active {%endif%}" data-toggle-class="btn-primary" data-toggle-passive-class="btn-default" data-toggle="tooltip" data-placement="top" title="Sistemas Linux que usen el comando service. Puede ser Centos o Ubuntu anterior a 14.04">
                              <input type="radio" name="so" value="LINUX_SERVICE" {%if server.SO == 'LINUX_SERVICE' %} checked="checked" {%endif%}> Linux (Service)
                            </label>#}
                            <label class="btn btn-default {%if server.SO == 'LINUX' %} active {%endif%}" data-toggle-class="btn-primary" data-toggle-passive-class="btn-default" data-toggle="tooltip" data-placement="top" title="Sistemas Linux. Soporta Systemd y service, y como fallback por procesos">
                              <input type="radio" name="so" value="LINUX" {%if server.SO == 'LINUX' %} checked="checked" {%endif%}> Linux
                            </label>
                            <label class="btn btn-default {%if server.SO == 'BSD' %} active {%endif%}" data-toggle-class="btn-primary" data-toggle-passive-class="btn-default" data-toggle="tooltip" data-placement="top" title="Sistemas BSD. Soporta FreeBSD, FreeNAS,..., Usa procesos para saber el estado de un servicio">
                              <input type="radio" name="so" value="BSD" {%if server.SO == 'BSD' %} checked="checked" {%endif%}> BSD
                            </label>
                          </div>
                        </div>
                      </div>
                      {% endif %}
                     {% if mode == 'edit' %}
                     <p>Cambio de usuario y password si se escribe una</p>
                     {% else %}
                      <p>Usuario y contraseña son necesarias para monitorizar sus datos y servicios, no así para el ping</p>
                     {% endif %}
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="userserv">Usuario (Opcional)<br/><small>Dominio\Usuario</small>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" id="userserv" name="userserv" class="form-control col-md-7 col-xs-12" autocomplete="off" value="{{server.User}}"/>
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="passw">Contraseña (Opcional)
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="password" id="passw" name="passw" class="form-control col-md-7 col-xs-12" autocomplete="off" value="{{server.Password}}"/>
                        </div>
                      </div>
                      <script>
                      document.getElementById('userserv').value='';
                      document.getElementById('passw').value='';
                      </script>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="ssh">Puerto SSH (Linux)<br/><small>Solo si no es el 22</small>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" id="ssh" name="ssh"  class="form-control col-md-7 col-xs-12" value="{{server.ssh}}"/>
                        </div>
                      </div>
                      <div class="ln_solid"></div>
                      <div class="form-group">
                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                          <button class="btn btn-warning" onClick="history.back();" type="button">Cancelar</button>
						              <!--<button class="btn btn-primary" type="reset">Poner en blanco</button>-->
                          <button type="submit" class="btn btn-success">{% if mode == 'edit' %}Guardar{% else %}Añadir{% endif %}</button>
                          {% if mode == 'edit' %}
                          <button onClick="return false;" class="btn btn-danger" data-toggle="modal" data-target=".bs-modal-deletesrv">Borrar servidor</button>
                        
                          {% endif %}
                        </div>
                      </div>

                    </form>
                    {# Modal de borrado de servidor #}
                    {% if mode == 'edit' %}
                    <div class="modal fade bs-modal-deletesrv" tabindex="-1" role="dialog" aria-hidden="true" style="display: none;">
                      <div class="modal-dialog modal-lg">
                        <form method="POST" action="?page=deleteserver&id_serv={{server.ID_SERV}}" data-parsley-validate class="form-horizontal form-label-left">
                          <div class="modal-content">
                            <div class="modal-header">
                              <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span>
                              </button>
                              <h4 class="modal-title" id="myModalLabel">Borrar servidor</h4>
                            </div>
                            <div class="modal-body">      
                              <p>Se procederá a borrar el servidor {{server.Name}}, es irreversible</p>
                            </div>
                            <div class="modal-footer">
                              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                              <button type="submit" class="btn btn-error">Borrar</button>
                            </div>
                          </div>
                        </form>
                      </div>
                    </div>
                    {% endif %}
                  </div>
                </div>
              </div>
            </div>

          </div>
        <!-- /page content -->


{% include 'a_footer.twig' %}