<?php
	
	/**
	 * Template für die Kundengruppenübersicht im Backend
	 */

?>
<div class="wrap wpsg_mod_kundenverwaltung_customergroup_index">
	
	<div class="icon32 icon32-posts-post" id="icon-edit"><br /></div>
	
	<h2>
		<?php echo __('Kundengruppenverwaltung', 'wpsg'); ?>		
		<a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Customergroup&action=add" class="add-new-h2"><?php echo __("Hinzufügen", "wpsg"); ?></a>		
	</h2>
	
	<?php echo $this->writeBackendMessage(); ?>
	
	<form method="POST" id="filter_form">
		
		<?php if (sizeof($this->view['data']) > 0) { ?>
		<p class="search-box">
			<label for="post-search-input" class="screen-reader-text"><?php echo __('Kundengruppen suchen', 'wpsg'); ?>:</label>
			<input type="text" value="<?php echo wpsg_hspc($_REQUEST['s']); ?>" name="filter[s]" id="post-search-input">
			<input type="submit" value="<?php echo __('Kundengruppen suchen', 'wpsg'); ?>" class="button" id="search-submit" name="">
		</p>
		<?php } ?>
		
		<div class="tablenav top">
		
			<?php if (sizeof($this->view['data']) > 0) { ?>
			<div class="tablenav-pages"><span class="displaying-num"><?php echo wpsg_translate(__('#1# Elemente', 'wpsg'), $this->view['count']); ?></span>
				<div class="tablenav-pages">	
					<span class="pagination-links">
						<a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Customergroup&seite=1&s=<?php echo $_REQUEST['s'].'&'.http_build_query((array)$_REQUEST['filter']); ?>" title="<?php echo __('Zur ersten Seite gehen', 'wpsg'); ?>" class="first-page <?php echo (($this->view['seite'] == '1')?'disabled':''); ?>">«</a>
						<a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Customergroup&seite=<?php echo ($this->view['seite'] - 1).'&'.http_build_query((array)$_REQUEST['filter']); ?>" title="<?php echo __('Zur vorherigen Seite gehen', 'wpsg'); ?>" class="prev-page <?php echo (($this->view['seite'] <= 1)?'disabled':''); ?>">‹</a>
						<span class="paging-input"><input type="text" size="1" value="<?php echo $this->view['seite']; ?>" id="seite" name="seite" title="<?php echo __('Aktuelle Seite', 'wpsg'); ?>" class="current-page"> <?php echo __('von', 'wpsg'); ?> <span class="total-pages"><?php echo $this->view['pages']; ?></span></span>
						<a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Customergroup&seite=<?php echo ($this->view['seite'] + 1).'&'.http_build_query((array)$_REQUEST['filter']); ?>" title="<?php echo __('Zur nächsten Seite gehen', 'wpsg'); ?>" class="next-page <?php echo (($this->view['seite'] >= $this->view['pages'])?'disabled':''); ?>">›</a>
						<a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Customergroup&seite=<?php echo $this->view['pages'].'&'.http_build_query((array)$_REQUEST['filter']); ?>" title="<?php echo __('Zur letzten Seite gehen', 'wpsg'); ?>" class="last-page <?php echo (($this->view['seite'] == $this->view['pages'])?'disabled':''); ?>">»</a>
					</span>
				</div>
				
				<script type="text/javascript">

					jQuery('.tablenav-pages .disabled').bind('click', function() { return false; } );
				
				</script>
				
				<br class="clear" />
			</div>
			<?php } ?>
		
		</div>
		
		<input id="wpsg_order" type="hidden" name="filter[order]" value="<?php echo $this->view['filter']['order']; ?>" />
		<input id="wpsg_ascdesc" type="hidden" name="filter[ascdesc]" value="<?php echo $this->view['filter']['ascdesc']; ?>" />
		
		<input style="display:none;" type="submit" name="suchen" value="" />
		
	</form>
	
	<?php if (is_array($this->view['data']) && sizeof($this->view['data']) > 0) { ?>
	<table class="widefat post fixed">
		<thead>
			<tr>
				<th class="manage-column col-id <?php echo ((wpsg_isSizedString($this->view['filter']['order'], 'id'))?'sorted':'sortable'); ?> <?php echo ((wpsg_isSizedString($this->view['filter']['ascdesc'], 'asc'))?'asc':'desc'); ?>">
					<a href="#" onclick="return wpsg_setOrder('id');">
						<span><?php echo __("Id", 'wpsg'); ?></span>
						<span class="sorting-indicator"></span>
					</a>
				</th>
				<th class="manage-column col-name <?php echo ((wpsg_isSizedString($this->view['filter']['order'], 'name'))?'sorted':'sortable'); ?> <?php echo ((wpsg_isSizedString($this->view['filter']['ascdesc'], 'asc'))?'asc':'desc'); ?>">
					<a href="#" onclick="return wpsg_setOrder('name');">
						<span><?php echo __("Name", 'wpsg'); ?></span>
						<span class="sorting-indicator"></span>
					</a>
				</th>
				<th class="manage-column col-calculation <?php echo ((wpsg_isSizedString($this->view['filter']['order'], 'calculation'))?'sorted':'sortable'); ?> <?php echo ((wpsg_isSizedString($this->view['filter']['ascdesc'], 'asc'))?'asc':'desc'); ?>">
					<a href="#" onclick="return wpsg_setOrder('name');">
						<span><?php echo __("Preisanzeige", 'wpsg'); ?></span>
						<span class="sorting-indicator"></span>
					</a>
				</th>
				<th class="manage-column col-customercount <?php echo ((wpsg_isSizedString($this->view['filter']['order'], 'customercount'))?'sorted':'sortable'); ?> <?php echo ((wpsg_isSizedString($this->view['filter']['ascdesc'], 'asc'))?'asc':'desc'); ?>">
					<a href="#" onclick="return wpsg_setOrder('customercount');">
						<span><?php echo __("Kunden", 'wpsg'); ?></span>
						<span class="sorting-indicator"></span>
					</a>
				</th>
			</tr>
		</thead>
		<tbody>
			<?php $i = 0; foreach ($this->view['data'] as $oCustomerGroup) { ?>
			<tr class="<?php echo (($i % 2 == 0)?'odd':'even'); ?>">
				<td class="col-id">
					<?php echo wpsg_hspc($oCustomerGroup->id); ?>
				</td>
				<td class="col-name">
					<?php echo wpsg_hspc($oCustomerGroup->name); ?>
					<div class="row-actions">
						<span class="edit"><a title="<?php echo __("Diesen Kunden bearbeiten", "wpsg"); ?>" href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Customergroup&action=edit&edit_id=<?php echo $oCustomerGroup->id; ?>"><?php echo __("Bearbeiten", "wpsg"); ?></a></span>
						|
						<span class="edit"><a title="<?php echo __("Kunden dieser Kundengruppe anzeigen", "wpsg"); ?>" href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Customer&customergroup=<?php echo $oCustomerGroup->id; ?>"><?php echo __("Kunden anzeigen", "wpsg"); ?></a></span>
						|
						<span class="del"><a onclick="if (!confirm('<?php echo __("Sind Sie sicher, dass Sie diese Kundengruppe löschen wollen?", "wpsg"); ?>')) return false;" title="<?php echo __("Diesen Kunden löschen", "wpsg"); ?>" href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Customergroup&action=del&edit_id=<?php echo $oCustomerGroup->id; ?>&noheader=1"><?php echo __("Löschen", "wpsg"); ?></a></span>											
					</div>
				</td>
				<td class="col-calculation">
					<?php if ($oCustomerGroup->calculation == WPSG_BRUTTO) { ?>
					<?php echo __('Brutto Preise', 'wpsg'); ?>
					<?php } else if ($oCustomerGroup->calculation == WPSG_NETTO) { ?>
					<?php echo __('Netto Preise', 'wpsg'); ?>
					<?php } else { ?>
					<?php echo __('Standard', 'wpsg'); ?>
					<?php } ?>
				</td>
				<td class="col-customercount">
					<?php echo wpsg_hspc($oCustomerGroup->customercount); ?>
				</td>
			</tr>
			<?php $i ++; } ?>
		</tbody>
		<tfoot>
			<tr>
				<th class="manage-column col-id <?php echo ((wpsg_isSizedString($this->view['filter']['order'], 'id'))?'sorted':'sortable'); ?> <?php echo ((wpsg_isSizedString($this->view['filter']['ascdesc'], 'asc'))?'asc':'desc'); ?>">
					<a href="#" onclick="return wpsg_setOrder('id');">
						<span><?php echo __("Id", 'wpsg'); ?></span>
						<span class="sorting-indicator"></span>
					</a>
				</th>
				<th class="manage-column col-name <?php echo ((wpsg_isSizedString($this->view['filter']['order'], 'name'))?'sorted':'sortable'); ?> <?php echo ((wpsg_isSizedString($this->view['filter']['ascdesc'], 'asc'))?'asc':'desc'); ?>">
					<a href="#" onclick="return wpsg_setOrder('name');">
						<span><?php echo __("Name", 'wpsg'); ?></span>
						<span class="sorting-indicator"></span>
					</a>
				</th>
				<th class="manage-column col-calculation <?php echo ((wpsg_isSizedString($this->view['filter']['order'], 'calculation'))?'sorted':'sortable'); ?> <?php echo ((wpsg_isSizedString($this->view['filter']['ascdesc'], 'asc'))?'asc':'desc'); ?>">
					<a href="#" onclick="return wpsg_setOrder('name');">
						<span><?php echo __("Preisanzeige", 'wpsg'); ?></span>
						<span class="sorting-indicator"></span>
					</a>
				</th>
				<th class="manage-column col-customercount <?php echo ((wpsg_isSizedString($this->view['filter']['order'], 'customercount'))?'sorted':'sortable'); ?> <?php echo ((wpsg_isSizedString($this->view['filter']['ascdesc'], 'asc'))?'asc':'desc'); ?>">
					<a href="#" onclick="return wpsg_setOrder('customercount');">
						<span><?php echo __("Kunden", 'wpsg'); ?></span>
						<span class="sorting-indicator"></span>
					</a>
				</th>
			</tr>
		</tfoot>
	</table>
	<?php } ?>
		
	<div class="tablenav">
	
		<?php if (is_array($this->view['data']) && sizeof($this->view['data']) > 0) { ?>
	
		<div class="tablenav-pages"><span class="displaying-num"><?php echo wpsg_translate(__('#1# Elemente', 'wpsg'), $this->view['count']); ?></span>
			<div class="tablenav-pages">	
				<span class="pagination-links">
					<form method="POST">
						<a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Customergroup&seite=1&s=<?php echo $_REQUEST['s'].'&'.http_build_query((array)$_REQUEST['filter']); ?>" title="<?php echo __('Zur ersten Seite gehen', 'wpsg'); ?>" class="first-page <?php echo (($this->view['seite'] == '1')?'disabled':''); ?>">«</a>
						<a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Customergroup&seite=<?php echo ($this->view['seite'] - 1).'&'.http_build_query((array)$_REQUEST['filter']); ?>" title="<?php echo __('Zur vorherigen Seite gehen', 'wpsg'); ?>" class="prev-page <?php echo (($this->view['seite'] <= 1)?'disabled':''); ?>">‹</a>
						<span class="paging-input"><input type="text" size="1" value="<?php echo $this->view['seite']; ?>" name="seite" title="<?php echo __('Aktuelle Seite', 'wpsg'); ?>" class="current-page"> <?php echo __('von', 'wpsg'); ?> <span class="total-pages"><?php echo $this->view['pages']; ?></span></span>
						<a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Customergroup&seite=<?php echo ($this->view['seite'] + 1).'&'.http_build_query((array)$_REQUEST['filter']); ?>" title="<?php echo __('Zur nächsten Seite gehen', 'wpsg'); ?>" class="next-page <?php echo (($this->view['seite'] >= $this->view['pages'])?'disabled':''); ?>">›</a>
						<a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Customergroup&seite=<?php echo $this->view['pages'].'&'.http_build_query((array)$_REQUEST['filter']); ?>" title="<?php echo __('Zur letzten Seite gehen', 'wpsg'); ?>" class="last-page <?php echo (($this->view['seite'] == $this->view['pages'])?'disabled':''); ?>">»</a>
					</form>
				</span>
			</div>
			
			<script type="text/javascript">
	
				jQuery('.tablenav-pages .disabled').bind('click', function() { return false; } );
			
			</script>
			
			<br class="clear">
		</div>
		
		<?php } ?>
		
	</div>
	
	<script type="text/javascript">/* <![CDATA[ */

		var wpsg_order = '<?php echo $this->view['filter']['order']; ?>';
		var wpsg_ascdesc = '<?php echo $this->view['filter']['ascdesc']; ?>';
	
		function wpsg_setOrder(order)
		{
		
			if (order == wpsg_order)
			{
		
				// Nur Richtung ändern
				if (wpsg_ascdesc == 'asc') jQuery('#wpsg_ascdesc').val('desc');
				else jQuery('#wpsg_ascdesc').val('asc');
				
			}
			else
			{
		
				jQuery('#wpsg_order').val(order);
				jQuery('#wpsg_ascdesc').val('asc');
				
			}
		
			jQuery('#seite').val(1);
			jQuery('#filter_form').submit();
			
			return false;
			
		} // function wpsg_setOrder(order)
    
	/* ]]> */</script>
	
</div>