<?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');
    jimport('joomla.html.html.select');
?>
<form action="<?php echo JRoute::_('index.php?option=com_dmfrontendusermanager'); ?>" method="post" name="adminForm" id="adminForm">
	
	<fieldset class="adminform" style="background:#fff;">
		<legend><?php echo JText::_('COM_DMFRONTENDUSERMANAGER_PERMISSIONEDIT_LABEL_DETAILS'); ?></legend>
		<table style="width:auto;" class="adminlist">
		    <tr>
		    	<td class="key">
		    		<?php echo JText::_('COM_DMFRONTENDUSERMANAGER_PERMISSIONEDIT_LABEL_NAME'); ?>
		    	</td>
		    	<td class="value">
                <!-- New group case -->
                <?php if (($this->gid < 0) && !empty($this->groupsUndefined)):  ?>
                <?php echo JHTML::_('select.genericlist', $this->groupsUndefined, 'gid', '', 'id', 'title'); ?>
                <!-- Edit group case -->
                <?php elseif (!empty($this->groupTitle)): ?>
                    <b><?php echo $this->groupTitle; ?></b>
                    <input type="hidden" name="gid" value="<?php echo $this->gid; ?>" />
                <?php endif; ?>
		    	</td>
        </table>
        <table class="adminlist table">
            <thead>
            <tr>
                <th class="groupkey">Group</th>
                <th style="text-align:center;">View</th>
                <th style="text-align:center;">Add</th>
                <th style="text-align:center;">Edit</th>
                <th style="text-align:center;">Delete</th>
                <th style="text-align:center;"><a href="#" onClick="DMFumAdmin.selectAll();return false;">Toggle All</a></th>
            </tr>
            </thead>
            <tbody>
            <?php if (!empty($this->groupsList)): foreach($this->groupsList as $group): ?>
                <tr id="row_group_<?php echo $group->id; ?>">
                    <td class="key">
                        <?php echo $group->title; ?>
                    </td>
                    <td class="value">
                        <input type="checkbox" name="view_<?php echo $group->id; ?>" value="1" <?php if (@$this->permissions[$group->id]['action_view'] == 1) echo 'checked="checked"'; ?> />
                    </td>
                    <td class="value">
                        <input type="checkbox" name="add_<?php echo $group->id; ?>" value="1" <?php if (@$this->permissions[$group->id]['action_add'] == 1) echo 'checked="checked"'; ?> />
                    </td>
                    <td class="value">
                        <input type="checkbox" name="edit_<?php echo $group->id; ?>" value="1" <?php if (@$this->permissions[$group->id]['action_edit'] == 1) echo 'checked="checked"'; ?> />
                    </td>
                    <td class="value">
                        <input type="checkbox" name="del_<?php echo $group->id; ?>" value="1" <?php if (@$this->permissions[$group->id]['action_del'] == 1) echo 'checked="checked"'; ?> />
                    </td>
                    <td class="value">
                        <a href="#" onClick="DMFumAdmin.selectAllRow(<?php echo $group->id; ?>);return false;">Toggle Row</a>
                    </td>
                </tr>
            <?php endforeach; endif; ?>
            </tbody>
		</table>
	</fieldset>

	<input type="hidden" name="option" value="com_dmfrontendusermanager" />
	<input type="hidden" name="view" value="permission" />
	<input type="hidden" name="task" value="" />
	
</form>