<?php

	/**
	 * Template für die Verwaltung der Berechtigungen
	 */

?>
<div class="wpsg_admin_submenu">
	
	<div class="list-group">
		<span class="list-group-head list-group-item"><?php echo __('Konfiguration'); ?></span>		
		<?php foreach ($this->view['arSubAction'] as $k => $v) { ?>		 
		<a class="list-group-item <?php echo (($k == $this->view['subAction'])?'active':''); ?>" href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&amp;subaction=<?php echo $k; ?>"><?php echo $v['Menutext']; ?></a>		
		<?php } ?>
	</div> 
	
</div>
		
<div class="wpsg_admin_content form-horizontal">
	<form name="form1" method="post" enctype="multipart/form-data" action="<?php echo wpsg_hspc(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&subaction='.$_REQUEST['subaction'].'&noheader=1'); ?>">
		
		<?php \wp_nonce_field('wpsg-admin-access'); ?>
		
		<?php global $wpdb; $arRoles = get_option($wpdb->prefix."user_roles"); ?>
		
		<div class="panel panel-default">
  			<div class="panel-heading clearfix">
          		<h3 class="panel-title"><?php echo __('Berechtigungen', 'wpsg'); ?></h3>
        	</div>
  			<div class="panel-body">

				<table class="wpsg_access_table table" cellpadding="0" cellspacing="0">
					<thead>
						<tr>
							<th class="wpsg_col_capname"></th>
							<?php foreach ($arRoles as $role_key => $r) { ?>
							<th class="wpsg_col_cap"><?php echo $r['name']; ?></th>
							<?php } ?>
							<th></th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td class="wpsg_col_capname"><?php echo __('Menüpunkt sichtbar', 'wpsg'); ?></td>
							<?php foreach ($arRoles as $role_key => $r) { ?>
							<td class="wpsg_col_cap">
								<input type="hidden" name="wpsg_cap[<?php echo $role_key; ?>][wpsg_menu]" value="0" />
								<input type="checkbox" <?php echo ((isset($r['capabilities']['wpsg_menu']) && $r['capabilities']['wpsg_menu'] == "1")?'checked="checked"':''); ?> name="wpsg_cap[<?php echo $role_key; ?>][wpsg_menu]" value="1" /> 
							</td>
							<?php } ?>
							<td></td>
						</tr>
						<tr>
							<td class="wpsg_col_capname"><?php echo __('Konfiguration', 'wpsg'); ?></td>
							<?php foreach ($arRoles as $role_key => $r) { ?>
							<td class="wpsg_col_cap">
								<input type="hidden" name="wpsg_cap[<?php echo $role_key; ?>][wpsg_conf]" value="0" />
								<input type="checkbox" <?php echo ((isset($r['capabilities']['wpsg_conf']) && $r['capabilities']['wpsg_conf'] == "1")?'checked="checked"':''); ?> name="wpsg_cap[<?php echo $role_key; ?>][wpsg_conf]" value="1" /> 
							</td>
							<?php } ?>
							<td></td>
						</tr>
						<?php $wpsg_update_data = wpsg_get_update_data(); if (wpsg_isSizedInt($wpsg_update_data['returnCode'])) { ?>
						<tr>
							<td class="wpsg_col_capname"><?php echo __('Lizenzverwaltung', 'wpsg'); ?></td>
							<?php foreach ($arRoles as $role_key => $r) { ?>
							<td class="wpsg_col_cap">
								<input type="hidden" name="wpsg_cap[<?php echo $role_key; ?>][wpsg_lizence]" value="0" />
								<input type="checkbox" <?php echo ((isset($r['capabilities']['wpsg_lizence']) && $r['capabilities']['wpsg_lizence'] == "1")?'checked="checked"':''); ?> name="wpsg_cap[<?php echo $role_key; ?>][wpsg_lizence]" value="1" /> 
							</td>
							<?php } ?>
							<td></td>
						</tr>	
						<?php } ?>
						<tr>
							<td class="wpsg_col_capname"><?php echo __('Bestellverwaltung', 'wpsg'); ?></td>
							<?php foreach ($arRoles as $role_key => $r) { ?>
							<td class="wpsg_col_cap">
								<input type="hidden" name="wpsg_cap[<?php echo $role_key; ?>][wpsg_order]" value="0" />
								<input type="checkbox" <?php echo ((isset($r['capabilities']['wpsg_order']) && $r['capabilities']['wpsg_order'] == "1")?'checked="checked"':''); ?> name="wpsg_cap[<?php echo $role_key; ?>][wpsg_order]" value="1" /> 
							</td>
							<?php } ?>
							<td></td>
						</tr>		
						<tr>
							<td class="wpsg_col_capname"><?php echo __('Produktverwaltung', 'wpsg'); ?></td>
							<?php foreach ($arRoles as $role_key => $r) { ?>
							<td class="wpsg_col_cap">
								<input type="hidden" name="wpsg_cap[<?php echo $role_key; ?>][wpsg_produkt]" value="0" />
								<input type="checkbox" <?php echo ((isset($r['capabilities']['wpsg_produkt']) && $r['capabilities']['wpsg_produkt'] == "1")?'checked="checked"':''); ?> name="wpsg_cap[<?php echo $role_key; ?>][wpsg_produkt]" value="1" /> 
							</td>
							<?php } ?>
							<td></td>
						</tr>			
						<?php $this->callMods('admin_setcapabilities'); ?>
					</tbody>
				</table>
			
			</div>
		</div>
		
		<p class="submit"><input type="submit" value="<?php echo __('Berechtigungen Speichern', 'wpsg'); ?>" name="submit" id="submit" class="button-primary" /></p>		
  
  	</form>
</div>