<?php

    /**
     * @copyright		(C)2013 DM Digital S.r.l
     * @author 			DM Digital <support@dmjoomlaextensions.com>
     * @link				http://www.dmjoomlaextensions.com
     * @license 			GNU/LGPL http://www.gnu.org/copyleft/gpl.html
     **/

    //---
    defined('_JEXEC') or die('Restricted access');
?>

<table width="100%" border="0">
  <tr>
    <td width="25%" style=" padding-right:10px;" valign="top">
    <span class="componentheading">Controle de Usuários</span>
    <div id="dmfum" <?php if (!empty($this->pageclass_sfx)) echo 'class="' . $this->pageclass_sfx . '"'; ?>>
    <?php if ($this->page_title != ''): ?>
    <div class="page-header"><h1><?php echo $this->page_title; ?></h1></div>
    <?php endif; ?>
    <?php if (count($this->users)): ?>
    <div id="dmfum_sidebar">
        <input id="filterSearch" class="filterSearch" type="text" placeholder="Nome, E-mail, Matrícula..." name="filterSearch" value="" />
        <button id="buscaservidor" type="button" class="dm_btn dm_btn-search" onclick="DMFUM.getUsers();">&#128269;</button>
        <select id="filterGroup" class="filterGroup" name="filterGroup" onChange="DMFUM.getUsers();">
            <option value=""><?php echo JText::_('COM_DMFRONTENDUSERMANAGER_FILTERGROUP'); ?></option>
            <?php foreach($this->groups as $groups): ?>
                <option value="<?php echo $groups->id; ?>"><?php echo $groups->title; ?></option>
            <?php endforeach; ?>
        </select>
        <select id="orderBy" class="orderBy" name="orderBy" onChange="DMFUM.getUsers();">
            <option value=""><?php echo JText::_('COM_DMFRONTENDUSERMANAGER_ORDERBY'); ?></option>
            <option value="id ASC"><?php echo JText::_('COM_DMFRONTENDUSERMANAGER_ORDERBY_ID_ASC'); ?></option>
            <option value="id DESC"><?php echo JText::_('COM_DMFRONTENDUSERMANAGER_ORDERBY_ID_DESC'); ?></option>
            <option value="username ASC"><?php echo JText::_('COM_DMFRONTENDUSERMANAGER_ORDERBY_USERNAME_ASC'); ?></option>
            <option value="username DESC"><?php echo JText::_('COM_DMFRONTENDUSERMANAGER_ORDERBY_USERNAME_DESC'); ?></option>
            <option value="email ASC"><?php echo JText::_('COM_DMFRONTENDUSERMANAGER_ORDERBY_EMAIL_ASC'); ?></option>
            <option value="email DESC"><?php echo JText::_('COM_DMFRONTENDUSERMANAGER_ORDERBY_EMAIL_DESC'); ?></option>
        </select>
        <?php if ($this->canAdd): ?>
         <button id="button_new" type="button" class="dm_btn dm_btn-add" onclick="DMFUM.toggleUserInfo('new');" value="New User" ><?php echo JText::_('COM_DMFRONTENDUSERMANAGER_NEWUSER'); ?></button>
         <?php endif; ?>
    </div>
    <div id="dmfum_cont">
        <div class="userinfo" id="userinfo_new"></div>

    </div>
    <?php else: ?>
    <div class="box-warning">
        <ul>
            <li><?php echo JText::_('COM_DMFRONTENDUSERMANAGER_NOUSERS'); ?></li>
        </ul>
    </div>
    <?php endif; ?>
</div>
<span class="componentheading">Usuários Por Departamento</span>
<div style=" float:left; width:100%;">
<?php echo JHtml::_('content.prepare', '{loadposition admuser1}'); ?>
</div>
</td>
    <td valign="top">
	<span class="componentheading">Relatório Geral</span>
    <div style=" float:left; width:100%;">
    <input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for names.." title="Type in a name">
<br>
<input class="customRadioButton" id="all" name="searchRadio" value="" checked="" type="radio">
<label for="all">TODOS</label>
<input class="customRadioButton" id="newyork" name="searchRadio" value="Ativo" type="radio">
<label for="newyork">ATIVO</label>
<input class="customRadioButton" id="sanfrancisco" name="searchRadio" value="Bloqueado" type="radio">
<label for="sanfrancisco">BLOQUEADO</label>

<input id="nunca" name="searchRadio" value="NUNCA" type="radio">
<label for="Developer">NUNCA ACESSOU</label>

	<?php echo JHtml::_('content.prepare', '{loadposition admuser2}'); ?>
    </div>
    </td>
  </tr>
</table>


<script>
	var input = document.getElementById("filterSearch");
input.addEventListener("keyup", function(event) {
    event.preventDefault();
    if (event.keyCode === 13) {
        document.getElementById("buscaservidor").click();
    }
});

function myFunction() {
  var input, filter, table, tr, td, i;
  input = document.getElementById("myInput");
  filter = input.value.toUpperCase();
  table = document.getElementById("dt_359");
  tr = table.getElementsByTagName("tr");
  for (i = 0; i < tr.length; i++) {
    td = tr[i].getElementsByTagName("td")[0];
    if (td) {
      if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
        tr[i].style.display = "";
      } else {
        tr[i].style.display = "none";
      }
    }       
  }
}

</script>