<?php use_helper('UrlFunctions'); ?>
<script>
findControl = function(){
  
  concatValueStr();
  
}

executeFind = function(str){ 
  //str = str + '&block=001';
  url = "<?=buildUrl('user/grid', "block=".$block)?>";
	var myAjax  = new Ajax.Updater(
                                	"resultGrtid",
                                	url,
                                	{
                                		asynchronous:	true,
                                		method			: 'get',
                                		parameters	: str,
                                		evalScripts	: true,
                                		onLoading   : cargandoImagenSerch(),
                                		onComplete	: function(){
                                			//objMainTab.showMenu();
                                		}
                                	});
}

concatValueStr = function(){
  strFormSerialize = returnQueryStringForm();
  if(arguments[0]){
    strFormSerialize += '&'+arguments[0];
  }
  executeFind(strFormSerialize);
}

function returnQueryStringForm(){
  cadenaFormulario = $('form1').serialize();
             var posicion = new Array();
             var a_pars = new Array();
             var miArray = new Array();
             posicion=[];
             a_pars=[];
             miArray=[];
             miArray = cadenaFormulario.split('&');
             x=0;
             for (i = 0; i < miArray.length; i++){
            	   posicion[i] = miArray[i].indexOf('=');
            	   if(typeof(miArray[i-1])!='undefined'){
            				if(miArray[i].substring(posicion[i],0)== miArray[i-1].substring(posicion[i-1],0) ){
           					 porcion = miArray[i].substring((1+posicion[i]));
           					 a_pars[x-1]+='@'+porcion;
           				}else{
          					 a_pars[x]= miArray[i];
         					 x++;
          				}
          		}else{
          			 a_pars[x]= miArray[i];
          			  x++;
          		}
           }
  cadenaFormulario = a_pars.join('&');
  cadenaFormulario += '&id_form=frmFindFedu';
  return(cadenaFormulario);
}

function cargandoImagenSerch(){
	//disabledWin.setPathImage('/images/common/progress.gif');
	disabledWin.show(true,true,'resultGrtid');
}

</script>
<script>
findControl = function(){
  
  var pars = $('form1').serialize();
  
	disabledWin.setPathImage('/images/common/progress.gif');
	disabledWin.show(true,true,'resultGrtid');
  
	url = "<?=buildUrl('doc/grid', "block=".$block)?>&dfff=ddd";
	var myAjax  = new Ajax.Updater(
	"resultGrtid",
	url,
	{
		asynchronous:	true,
		method			: 'get',
		parameters	: pars,
		evalScripts	: true,
		onLoading		: function(){
			//$('contentMenu').innerHTML = $('messageLoadMenu').innerHTML;
		},
		onComplete	: function(){
			//objMainTab.showMenu();
		}
	});
  
}

deleteRegistro = function(id,codigo){
  //buildUrl('doc/delete/id/'block=001'
  if(confirm("żEsta seguro de eliminar la ficha del usuario : "+codigo+ " ?")){
      //objMainTab.reqBody('<? //=buildUrl('doc/add')?>','block=001&delete=1&id='+id);   
      parent.objMainTab.reqBody('<?=buildUrl('user/delete')?>','block=001&delete=1&cod=jj&id='+id);
  }
  
}

acutalizarEspecialidad = function(destino,elm){
  $(destino).options.length = 1;
  var url = '<?=buildUrl('ajax/request')?>';
  var pars = 'type=getEspecialidad&nombreElm='+destino+'&value='+elm.value;
  
	var myAjax = new Ajax.Request(
                            		url, 
                            		{
                            			method: 'get', 
                            			parameters: pars, 
                            			onComplete: actualizaJSON
                            		});
}

</script>
<?php
$o_UserSystemClass = new UserSystemClass(new RolBean());
$a_Rol = $o_UserSystemClass->getRol();

  //echo "<pre>";
  //print_r($a_Rol);
  //echo "</pre>";

?>

<script>
findControl = function(){
  
  var pars = $('form1').serialize();
  
	disabledWin.setPathImage('/images/common/progress.gif');
	disabledWin.show(true,true,'resultGrtid');
  
	url = "<?=buildUrl('user/grid', "block=".$block)?>";
	var myAjax  = new Ajax.Updater(
	"resultGrtid",
	url,
	{
		asynchronous:	true,
		method			: 'get',
		parameters	: pars,
		evalScripts	: true,
		onLoading		: function(){
			//$('contentMenu').innerHTML = $('messageLoadMenu').innerHTML;

		},
		onComplete	: function(){
			//objMainTab.showMenu();
		}
	});
  
}
</script>
<img src="/images/common/spacer.gif" width="10">
<table class="cuerpo" style="background:#FFFFFF" width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top">
      <form name="form1" id="form1" method="POST">
      <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
          <td class="titleBody"><li>&nbsp;&nbsp;Busqueda de Usuario </li></td>
          <td align="right" valign="baseline">
            <!--<input type="image" src="/images/common/buttons/btnAdd.gif" alt="Nuevo" onclick="" />-->
            <img name="add" src="/images/common/buttons/btnAdd.gif" onClick="parent.objMainTab.reqBody('<?=buildUrl('user/add')?>','001')" style="cursor:pointer">
            <!--<input name="btnNew2" type="image" src="/images/common/buttons/btnExcel.gif" alt="Excel" />-->
            <!--<input name="btnNew3" type="image" src="/images/common/buttons/btnPdf.gif" alt="Pdf" />-->
            <!--<input name="btnNew4" type="image" src="/images/common/buttons/btnClose.gif" alt="Cerrar" />-->
          </td>
        </tr>
      </table>
      <table class="marco" width="100%">
        <tr>
          <td align="center" valign="top">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="50%" valign="top">
                  <table class="SubCabecera" width="100%" border="0" cellpadding="0" cellspacing="2">
                    <tr>
                      <td width="63" height="26" nowrap="nowrap"><label class="label" for="txtNombre">Nombre : </label></td>
                      <td width="406" nowrap="nowrap"><input name="txtNombre" id="txtNombre" type="text" class="text"/></tr>
                    <tr>
                      <td height="26" nowrap="nowrap"><label class="label" for="txtCod">Rol :</label></td>
                      <td nowrap="nowrap">
                        <select class="combo" name="cboRol">
                          <option value="">--Seleccionar--</option>
                          <?php foreach ($a_Rol as $iKey => $o_RolBean){  ?>
                          <option value="<?=$o_RolBean->getRolId()?>"><?=$o_RolBean->getDescripcion()?></option>
                          <?php } ?>
                        </select>
                      </td>
                    </tr>
                  </table>
                </td>
                <td width="50%" valign="top">
                  <table class="SubCabecera" width="100%" border="0" cellpadding="0" cellspacing="2">
                    <tr>
                      <td width="63" height="26" nowrap="nowrap"><label class="label" for="txtFecIni">Desde : </label></td>
                      <td width="406" nowrap="nowrap">
                        <input name="txtFecIni" id="txtFecIni" value="" size="8" type="text" class="text"><button type="button" onclick="return false" id="btnFecIni">...</button>
                        <script type="text/javascript">
                            document.getElementById("btnFecIni").disabled = false;
                            Calendar.setup({
                              inputField : "txtFecIni",
                              ifFormat : "%Y-%m-%d",
                              daFormat : "%Y-%m-%d",
                              button   : "btnFecIni"
                            });
                        </script>
                    </tr>
                    <tr>
                      <td height="26" nowrap="nowrap"><label class="label" for="txtCod">Hasta :</label></td>
                      <td nowrap="nowrap">
                        <input name="txtFecFin" id="txtFecFin" value="" size="8" type="text" class="text"><button type="button" onclick="return false" id="btnFecFin">...</button>
                        <script type="text/javascript">
                            document.getElementById("btnFecFin").disabled = false;
                            Calendar.setup({
                              inputField : "txtFecFin",
                              ifFormat : "%Y-%m-%d",
                              daFormat : "%Y-%m-%d",
                              button   : "btnFecFin"
                            });
                        </script>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
            <div align="center">
              <input class="button" type="button" value="Buscar" onclick="findControl();"/>
            </div>
          </td>
        </tr>
      </table>
      </form>
      <div id="resultGrtid">
      </div>
    </td>
  </tr>
</table>