<?php

	/**
	 * Template für die Liste der Versandzonen
	 */

?>
<?php if (!is_array($this->view['data']) || sizeof($this->view['data']) <= 0) { ?>
<?php echo __('Bisher keine Versandzonen hinterlegt.', 'wpsg'); ?>
<?php } else { ?>
<table class="wpsg_admin_vz_list wpsg_admin_table">
	<tr>
		<th class="col_name"><?php echo __('Bezeichnung', 'wpsg'); ?></th>
		<th class="col_innereu"><?php echo __('Inner- gemeinschaftlich', 'wpsg'); ?></th>
		<th class="col_aktion"></th>
	</tr>
	<?php foreach ($this->view['data'] as $vz) { ?>
	<tr>
		<td class="wpsg_editable col_name">
			<span  id="vz_<?php echo $vz['id']; ?>_name" ><?php echo wpsg_hspc($vz['name']); ?></span> 
			<br />
			<?php if (!empty($vz['param'])) { $arPLZ = unserialize($vz['param']); } ?>
			<div id="vz_<?php echo $vz['id']; ?>_plz" style="display:none">
				<textarea style="float:left; width:100%;"><?php echo wpsg_hspc($vz['param']); ?></textarea>
				<input style="width:75px;" class="" type="submit" name="wpsg_mod_vz_submitsave" value="<?php echo __('Speichern', 'wpsg'); ?>" onclick="return wpsg_savePLZ(<?php echo $vz['id']; ?>);" />
			</div>
		</td>
		<td class="col_innereu">		 
			<input class="wpsg_innereu" <?php echo (($vz['innereu'] == '1')?'checked="checked"':''); ?> type="checkbox" value="1" name="innereu_<?php echo $vz['id']; ?>" id="innereu_<?php echo $vz['id']; ?>" />								
		</td>
		<td class="col_aktion">
			
			<a class="wpsg_icon wpsg_icon_remove" href="#" title="<?php echo __('Versandzone löschen', 'wpsg'); ?>" onclick="return wpsg_removeVZ(<?php echo $vz['id']; ?>);"></a>			
			<span><a class="wpsg_icon wpsg_icon_right wpsg_icon_plzedit" href="#" title="<?php echo __('Versandzonen PLZ bearbeiten', 'wpsg'); ?>" onclick="return wpsg_editPLZ(<?php echo $vz['id']; ?>);"></a></span>
			
			<script type="text/javascript">/* <![CDATA[ */

				jQuery('#vz_<?php echo $vz['id']; ?>_name').editable('<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=vz&do=inlinedit&noheader=1', {
					submitdata: { 
			    		field: 'name',
			    		vz_id: '<?php echo $vz['id']; ?>'
					}, 					
					submit  : '<?php echo __('Speichern', 'wpsg'); ?>',
					placeholder: '<?php echo __('Zum Bearbeiten anklicken ...', 'wpsg'); ?>',
					indicator: '<?php echo __('Speicher ...', 'wpsg'); ?>',
			    	tooltip: '<?php echo __('Zum Bearbeiten anklicken ...', 'wpsg'); ?>'
				});
			
				jQuery('#vz_<?php echo $vz['id']; ?>_value').editable('<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=vz&do=inlinedit&noheader=1', {
					submitdata: { 
			    		field: 'value',
			    		vz_id: '<?php echo $vz['id']; ?>'
					}, 					
					submit  : '<?php echo __('Speichern', 'wpsg'); ?>',
					placeholder: '<?php echo __('Zum Bearbeiten anklicken ...', 'wpsg'); ?>',
					indicator: '<?php echo __('Speicher ...', 'wpsg'); ?>',
			    	tooltip: '<?php echo __('Zum Bearbeiten anklicken ...', 'wpsg'); ?>'
				});

				/* ]]> */</script>		
		</td>
	</tr>
	<?php } ?>
</table>

<script type="text/javascript">/* <![CDATA[ */

	jQuery(document).ready(function() {

		jQuery('.wpsg_innereu').bind('click', function() {

			var checked = "0"; if (jQuery(this).prop("checked")) checked = "1";

			jQuery.ajax( {
				url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Admin&subaction=vz&do=inlinedit&noheader=1',
				data: {
					field: 'innereu',
					vz_id: jQuery(this).attr("id").substr(8),
					value: checked					
				}
			} ); 
			
		} );
		
	} );

/* ]]> */</script>

<?php } ?>