<?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');
?>

<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" name="filterSearch" value="" />
        <button 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>


<script>
    DMFUM.root = '<?php echo JURI::base(); ?>';

    jDM(document).ready(function(){
        DMFUM.getUsers();
    });
    jDM('#filterSearch').keypress(function(key){
        if (key.which == 13)
        DMFUM.getUsers();
    });

</script>
