function HTMLformAdvancedSearch($array)
{
    global $CFG;
    $rows .= ' <fieldset>
    <legend>' . ucfirst(LABEL_BusquedaAvanzada) . '</legend>
   <form class="formdiv" name="advancedsearch" action="index.php#xstring" method="get" onsubmit="return checkrequired(this)">';
    $LABEL_Termino = ucfirst(LABEL_Termino);
    $LABEL_esNoPreferido = ucfirst(LABEL_esNoPreferido);
    $LABEL_CODE = ucfirst(LABEL_CODE);
    $rows .= '<div><label for="ws" accesskey="f">' . ucfirst(LABEL_QueBuscar) . '</label>';
    $rows .= '<select id="ws" name="ws">';
    $arrayWS = $CFG["_USE_CODE"] == '1' ? array("t#{$LABEL_Termino}", "uf#{$LABEL_esNoPreferido}", "c#{$LABEL_CODE}") : array("t#{$LABEL_Termino}", "uf#{$LABEL_esNoPreferido}");
    $rows .= doSelectForm($arrayWS, "{$_GET['ws']}");
    $rows .= '</select>';
    //	$rows.='<input name="isUF" type="checkbox" id="isUF" value="1" '.do_check('1',$_GET[isUF],"checked").'/>';
    $rows .= '</div>';
    $rows .= '<div><label for="xstring" accesskey="s">' . ucfirst(LABEL_BuscaTermino) . '</label>';
    $rows .= '<input name="xstring" type="text" id="xstring" size="25" maxlength="50" value="' . $_GET[xstring] . '"/>';
    $rows .= '</div>';
    $rows .= '<div><label for="isExactMatch" accesskey="f">' . ucfirst(LABEL_esFraseExacta) . '</label>';
    $rows .= '<input name="isExactMatch" type="checkbox" id="isExactMatch" value="1" ' . do_check('1', $_GET[isExactMatch], "checked") . '/>';
    $rows .= '</div>';
    //Evaluar si hay top terms
    $sqlTopTerm = SQLverTopTerm();
    if ($sqlTopTerm[cant]) {
        while ($arrayTopTerms = mysqli_fetch_array($sqlTopTerm[datos])) {
            $formSelectTopTerms[] = $arrayTopTerms[tema_id] . '#' . $arrayTopTerms[tema];
        }
        $rows .= '<div><label for="hasTopTerm" accesskey="t">' . ucfirst(LABEL_TopTerm) . '</label>';
        $rows .= '<select id="hasTopTerm" name="hasTopTerm">';
        $rows .= '<option value="">' . ucfirst(LABEL_Todos) . '</option>';
        $rows .= doSelectForm($formSelectTopTerms, "{$_GET['hasTopTerm']}");
        $rows .= '</select>';
        $rows .= '</div>';
    }
    //Evaluar si hay notas
    $resumen = ARRAYresumen($_SESSION[id_tesa], "G", "");
    if (is_array($resumen["cant_notas"])) {
        $arrayTiposNotas = array('NA' => LABEL_NA, 'NH' => LABEL_NH, 'NC' => LABEL_NC, 'NB' => LABEL_NB, 'NP' => LABEL_NP);
        foreach ($resumen["cant_notas"] as $knotas => $vnotas) {
            $formSelectTipoNota[] = $knotas . '#' . $arrayTiposNotas[$knotas] . ' (' . $vnotas . ')';
        }
        $rows .= '<div><label for="hasNote" accesskey="n">' . ucfirst(LABEL_tipoNota) . '</label>';
        $rows .= '<select id="hasNote" name="hasNote">';
        $rows .= '<option value="">' . ucfirst(LABEL_Todos) . '</option>';
        $rows .= doSelectForm($formSelectTipoNota, "{$_GET['hasNote']}");
        $rows .= '</select>';
        $rows .= '</div>';
    }
    //Evaluar si hay terminos
    $sqlTermsByDates = SQLtermsByDate();
    if ($sqlTermsByDates[cant]) {
        global $MONTHS;
        while ($arrayTermsByDates = mysqli_fetch_array($sqlTermsByDates[datos])) {
            //normalizacion de fechas
            $arrayTermsByDates[months] = strlen($arrayTermsByDates[months]) == 1 ? '0' . $arrayTermsByDates[months] : $arrayTermsByDates[months];
            $formSelectByDate[] = $arrayTermsByDates[years] . '-' . $arrayTermsByDates[months] . '#' . $MONTHS["{$arrayTermsByDates['months']}"] . '/' . $arrayTermsByDates[years] . ' (' . $arrayTermsByDates[cant] . ')';
        }
        $rows .= '<div><label for="fromDate" accesskey="d">' . ucfirst(LABEL_DesdeFecha) . '</label>';
        $rows .= '<select id="fromDate" name="fromDate">';
        $rows .= '<option value="">' . ucfirst(LABEL_Todos) . '</option>';
        $rows .= doSelectForm($formSelectByDate, "{$_GET['fromDate']}");
        $rows .= '</select>' . ucfirst(LABEL_mes) . '/' . ucfirst(LABEL_ano);
        $rows .= '</div>';
    }
    //Evaluar si hay candidatos
    $sqlTermsByDeep = SQLTermDeep();
    if ($sqlTermsByDeep[cant] > 1) {
        while ($arrayTermsByDeep = mysqli_fetch_array($sqlTermsByDeep[datos])) {
            $formSelectByDeep[] = $arrayTermsByDeep[tdeep] . '#' . $arrayTermsByDeep[tdeep] . ' (' . $arrayTermsByDeep[cant] . ')';
        }
        $rows .= '<div><label for="termDeep" accesskey="e">' . ucfirst(LABEL_ProfundidadTermino) . '</label>';
        $rows .= '<select id="termDeep" name="termDeep">';
        $rows .= '<option value="">' . ucfirst(LABEL_Todos) . '</option>';
        $rows .= doSelectForm($formSelectByDeep, "{$_GET['termDeep']}");
        $rows .= '</select>';
        $rows .= '</div>';
    }
    $rows .= '<div class="submit_form" align="center">';
    $rows .= '<input type="submit"  id="boton" name="boton" value="' . LABEL_Enviar . '"/>';
    $rows .= '<input type="hidden"  name="xsearch" id="xsearch" value="1"/>';
    $rows .= '<input type="button"  name="cancelar" type="button" onClick="location.href=\'index.php\'" value="' . ucfirst(LABEL_Cancelar) . '"/>';
    $rows .= '</div>';
    $rows .= '</form>';
    $rows .= '  </fieldset>';
    if ($_GET[boton] == LABEL_Enviar) {
        $rows .= HTMLadvancedSearchResult($_GET);
    }
    return $rows;
}
function HTMLformAdvancedSearch($array)
{
    global $CFG;
    $array = XSSpreventArray($array);
    $rows .= '<div class="row">';
    $rows .= '	<div class="col-md-6 col-md-offset-3">';
    $rows .= ' <h3>' . ucfirst(LABEL_BusquedaAvanzada) . '</h3>';
    $rows .= '<form  class="col-xs-8 form-horizontal" role="form" name="advancedsearch" action="index.php#xstring" method="get">';
    $rows .= '<fieldset>';
    $LABEL_Termino = ucfirst(LABEL_Termino);
    $LABEL_esNoPreferido = ucfirst(LABEL_esNoPreferido);
    $LABEL_CODE = ucfirst(LABEL_CODE);
    $LABEL_NOTE = ucfirst(LABEL_nota);
    $LABEL_META_TERM = ucfirst(LABEL_meta_term);
    $LABEL_TARGET_TERM = ucfirst(LABEL_TargetTerm);
    $arrayWS = array("t#{$LABEL_Termino}", "mt#{$LABEL_META_TERM}");
    $arrayVocabStats = ARRAYresumen($_SESSION[id_tesa], "G", "");
    if ($arrayVocabStats["cant_up"] > 0) {
        array_push($arrayWS, "uf#{$LABEL_esNoPreferido}");
    }
    if ($arrayVocabStats["cant_notas"] > 0) {
        array_push($arrayWS, "n#{$LABEL_NOTE}");
    }
    if ($CFG["_SHOW_CODE"] == '1') {
        array_push($arrayWS, "c#{$LABEL_CODE}");
    }
    if ($arrayVocabStats["cant_term2tterm"]) {
        array_push($arrayWS, "tgt#{$LABEL_TARGET_TERM}");
    }
    /*
    solo si hay m�s de un opci�n
    */
    if (count($arrayWS) > 1) {
        $rows .= '<div class="form-group"><label class="label_ttl control-label" for="ws" accesskey="f">' . ucfirst(LABEL_QueBuscar) . '</label>';
        $rows .= '<select class="select_ttl form-control" id="ws" name="ws">';
        $rows .= doSelectForm($arrayWS, "{$_GET['ws']}");
        $rows .= '</select>';
        $rows .= '</div>';
    }
    $rows .= '<div class="form-group"><label class="label_ln control-label" for="xstring" accesskey="s">' . ucfirst(LABEL_BuscaTermino) . '</label>';
    $rows .= '<input name="xstring" class="input_ln form-control" required type="search" id="xstring" size="25" maxlength="50" value="' . $array["xstring"] . '"/>';
    $rows .= '	<div class="checkbox-inline" ><label class="btn btn-default" for="isExactMatch" accesskey="f">';
    $rows .= '	<input name="isExactMatch" type="checkbox" id="isExactMatch" value="1" ' . do_check('1', $_GET["isExactMatch"], "checked") . '/>' . ucfirst(LABEL_esFraseExacta) . '</label>';
    $rows .= ' 	</div>';
    $rows .= '</div>';
    $rows .= '<div class="collapse" id="masOpcionesBusqueda">';
    //Evaluar si hay top terms
    $sqlTopTerm = SQLverTopTerm();
    if (SQLcount($sqlTopTerm) > 0) {
        while ($arrayTopTerms = $sqlTopTerm->FetchRow()) {
            $formSelectTopTerms[] = $arrayTopTerms["tema_id"] . '#' . $arrayTopTerms[tema];
        }
        $rows .= '<div class="form-group"><label class="label_ttl control-label" for="hasTopTerm" accesskey="t">' . ucfirst(LABEL_TopTerm) . '</label>';
        $rows .= '<select class="select_ttl form-control" id="hasTopTerm" name="hasTopTerm">';
        $rows .= '<option value="">' . ucfirst(LABEL_Todos) . '</option>';
        $rows .= doSelectForm($formSelectTopTerms, "{$_GET['hasTopTerm']}");
        $rows .= '</select>';
        $rows .= '</div>';
    }
    //Evaluar si hay notas
    if (is_array($arrayVocabStats["cant_notas"])) {
        $LabelNB = 'NB#' . LABEL_NB;
        $LabelNH = 'NH#' . LABEL_NH;
        $LabelNA = 'NA#' . LABEL_NA;
        $LabelNP = 'NP#' . LABEL_NP;
        $LabelNC = 'NC#' . LABEL_NC;
        $sqlNoteType = SQLcantNotas();
        $arrayNoteType = array();
        while ($arrayNotes = $sqlNoteType->FetchRow()) {
            if ($arrayNotes[cant] > 0) {
                //nota privada no
                if ($_SESSION[$_SESSION["CFGURL"]][ssuser_nivel] || $arrayNotes["value_id"] !== '11') {
                    $varNoteType = in_array($arrayNotes["value_id"], array(8, 9, 10, 11, 15)) ? arrayReplace(array(8, 9, 10, 11, 15), array($LabelNA, $LabelNH, $LabelNB, $LabelNP, $LabelNC), $arrayNotes["value_id"]) : $arrayNotes["value_code"] . '#' . $arrayNotes["value"];
                    $varNoteType .= ' (' . $arrayNotes[cant] . ')';
                    array_push($arrayNoteType, $varNoteType);
                }
            }
        }
        /*
        Si hay m�s de un tipo de nota
        */
        if (count($arrayVocabStats["cant_notas"]) > 0) {
            $rows .= '<div class="form-group"><label class="label_ttl control-label" for="hasNote" accesskey="n">' . ucfirst(LABEL_tipoNota) . '</label>';
            $rows .= '<select class="select_ttl form-control" id="hasNote" name="hasNote">';
            $rows .= '<option value="">' . ucfirst(LABEL_Todos) . '</option>';
            $rows .= doSelectForm($arrayNoteType, "{$_GET['hasNote']}");
            $rows .= '</select>';
            $rows .= '</div>';
        }
    }
    //Evaluar si hay terminos
    $sqlTermsByDates = SQLtermsByDate();
    if (SQLcount($sqlTermsByDates) > 0) {
        global $MONTHS;
        while ($arrayTermsByDates = $sqlTermsByDates->FetchRow()) {
            //normalizacion de fechas
            $arrayTermsByDates[months] = strlen($arrayTermsByDates[months]) == 1 ? '0' . $arrayTermsByDates[months] : $arrayTermsByDates[months];
            $formSelectByDate[] = $arrayTermsByDates[years] . '-' . $arrayTermsByDates[months] . '#' . $MONTHS["{$arrayTermsByDates['months']}"] . '/' . $arrayTermsByDates[years] . ' (' . $arrayTermsByDates[cant] . ')';
        }
        $rows .= '<div class="form-group"><label class="label_ttl control-label" for="fromDate" accesskey="d">' . ucfirst(LABEL_DesdeFecha) . '</label>';
        $rows .= '<select class="select_ttl form-control" id="fromDate" name="fromDate">';
        $rows .= '<option value="">' . ucfirst(LABEL_Todos) . '</option>';
        $rows .= doSelectForm($formSelectByDate, "{$_GET['fromDate']}");
        $rows .= '</select>';
        $rows .= '</div>';
    }
    //terms by deep
    $sqlTermsByDeep = SQLTermDeep();
    if (SQLcount($sqlTermsByDeep) > 1) {
        while ($arrayTermsByDeep = $sqlTermsByDeep->FetchRow()) {
            $formSelectByDeep[] = $arrayTermsByDeep[tdeep] . '#' . $arrayTermsByDeep[tdeep] . ' (' . $arrayTermsByDeep[cant] . ')';
        }
        $rows .= '<div class="form-group"><label class="label_ttl control-label" for="termDeep" accesskey="e">' . ucfirst(LABEL_ProfundidadTermino) . '</label>';
        $rows .= '<select class="select_ttl form-control" id="termDeep" name="termDeep">';
        $rows .= '<option value="">' . ucfirst(LABEL_Todos) . '</option>';
        $rows .= doSelectForm($formSelectByDeep, "{$_GET['termDeep']}");
        $rows .= '</select>';
        $rows .= '</div>';
    }
    $rows .= '</div>';
    //hide div
    $rows .= '<div class="btn-group">';
    $rows .= '<input type="submit"  id="boton" name="boton" class="btn btn-primary" value="' . LABEL_Enviar . '"/>';
    $rows .= ' <button class="btn btn-default" type="button" data-toggle="collapse" data-target="#masOpcionesBusqueda" aria-expanded="false" aria-controls="masOpcionesBusqueda">' . ucfirst(LABEL_Opciones) . '</button>';
    //$rows.='<input type="button" class="btn btn-default" name="cancelar" type="button" onClick="location.href=\'index.php\'" value="'.ucfirst(LABEL_Cancelar).'"/>';
    $rows .= '</div>';
    $rows .= '<input type="hidden"  name="xsearch" id="xsearch" value="1"/>';
    $rows .= '  </fieldset>';
    $rows .= '</form>';
    $rows .= '</div>';
    //div row
    $rows .= '</div>';
    //div col
    $rows .= '<div class="push"></div>';
    if ($_GET[boton] == LABEL_Enviar) {
        $rows .= HTMLadvancedSearchResult($array);
    }
    return $rows;
}