<?php

	/**
	 * Template für die Liste der Produkte innerhalb der Bestellansicht, wird per Ajax neu geladen
	 */

?>
<?php if (wpsg_isSizedArray($this->view['messages'])) { ?>
<?php foreach ($this->view['messages'] as $m) { ?>
<div class="updated"><p><?php echo wpsg_hspc($m); ?></p></div>
<?php } ?>
<?php } ?>
<?php if (wpsg_isSizedArray($this->view['errors'])) { ?>
<?php foreach ($this->view['errors'] as $e) { ?>
<div class="error"><p><?php echo wpsg_hspc($e); ?></p></div>
<?php } ?>
<?php } ?>
<table class="wpsg_mod_downloadplus_order_view_filelist">
	<tr>
		<th class="col_file"><?php echo __('Datei', 'wpsg'); ?></th>
		<th class="col_status"><?php echo __('Status', 'wpsg'); ?></th>
		<th class="col_counter">#</th>
		<th class="col_action"></th>				
	</tr>
	<?php foreach ($this->view['arFiles'] as $f) { ?>
	<tr class="<?php echo (($f[3] !== false && $f[3]['raid'] === true)?'row_raid':''); ?>">
		<td class="col_file">
		 
			<?php if ($f[3] !== false && wpsg_isSizedArray($f[3]) && strtotime($f[3]['done']) > 0) { ?>
			<a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Order&action=ajax&mod=wpsg_mod_downloadplus&cmd=download_indivfile&edit_id=<?php echo $f[3]['o_id']; ?>&product_id=<?php echo $f[0]; ?>&file=<?php echo rawurlencode($f[3]['out_file']); ?>&noheader=1">
			<?php } ?>
						
			<?php if ($f[3] === false) { ?>
			<?php echo $f[1]; ?>
			<?php } else { ?>
			<?php echo $f[3]['out_file']; ?>
			<?php } ?>
			
			<?php if ($f[3] !== false && wpsg_isSizedArray($f[3]) && strtotime($f[3]['done']) > 0) { ?>
			</a>
			<?php } ?>
		</td>
		<td class="col_status">
			<?php if ($f[3] === false) { ?>			
			<?php echo __('Noch nicht geplant.', 'wpsg'); ?>
			<?php } else if (strtotime($f[3]['scheduled']) > 0 && strtotime($f[3]['done']) <= 0) { ?>
			<?php echo wpsg_translate(__('Geplant am #1#', 'wpsg'), wpsg_fromDate($f[3]['scheduled'])); ?>
			<?php } else if (strtotime($f[3]['done']) > 0) { ?>
			<?php echo wpsg_translate(__('Durchgeführt am #1#', 'wpsg'), wpsg_fromDate($f[3]['done'])); ?>			
			<?php } ?>
		</td>
		<td class="col_counter"><?php echo (($f[3] !== false)?$f[3]['counter']:'0'); ?></td>
		<td class="col_action">		
			<?php if ($f[3] === false) { ?>
			<a href="#" onclick="return wpsg_mod_downloadplus_schedule('<?php echo $f[0]; ?>', '<?php echo rawurldecode($f[1]); ?>', '<?php echo $f[2]; ?>');"><?php echo __('Planen', 'wpsg'); ?></a>
			<?php } else if (strtotime($f[2]['scheduled']) > 0 && strtotime($f[3]['done']) <= 0) { ?>
			<a href="#" onclick="return wpsg_mod_downloadplus_cangelschedule('<?php echo $f[0]; ?>', '<?php echo rawurldecode($f[1]); ?>');"><?php echo __('Abbrechen', 'wpsg'); ?></a>
			<?php } ?>
		</td>
	</tr>
	<?php } ?>
</table>
<br />
<input type="button" onclick="return wpsg_mod_downloadplus_send();" value="<?php echo __('Fertige Downloads an Kunden senden', 'wpsg'); ?>" /><br />
<input type="button" onclick="return wpsg_mod_downloadplus_reindiv();" value="<?php echo __('Alle Dokumente neu planen', 'wpsg'); ?>" />
<input type="button" onclick="return wpsg_mod_downloadplus_reset();" value="<?php echo __('Zähler zurücksetzen', 'wpsg'); ?>" />