<?php

	/**
	 * Template für die Integration des Uploadformulars im rechten Bereich
	 * sollte nicht verändert werden
	 */

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

    function wpsg_pdfdownload_removePDF(file)
	{

    	if (!confirm('<?php echo __('Sind sie sich sicher, dass sie die Datei löschen möchten?', 'wpsg'); ?>')) return false;

    	jQuery('#wpsg_mod_downloadplus_files').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
    	
		jQuery.ajax( {
			url: '<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Produkt&action=ajax&mod=wpsg_mod_downloadplus&edit_id=<?php echo $this->view['data']['id']; ?>&noheader=1&cmd=delete_file&file=' + file,
			success: function(response) {

				if (response == '1')
				{
					jQuery("#wpsg_mod_downloadplus_files").load("<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Produkt&action=ajax&mod=wpsg_mod_downloadplus&cmd=pdffiles_list&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1");
				}
				else
				{
					
					alert(response);
					jQuery("#wpsg_mod_downloadplus_files").load("<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Produkt&action=ajax&mod=wpsg_mod_downloadplus&cmd=pdffiles_list&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1");
					
				}
				
			}			
		} );
    	
		return false;
    	
	} // function wpsg_pdfdownload_removePDF($pdf)
             
	jQuery(document).ready(function() {	

		<?php if ($this->get_option('wpsg_classicupload') != '1') { ?>
		new AjaxUpload(
			"wpsg_mod_downloadplus_upload", {
				name: "wpsg_mod_downloadplus_file",
				action: "<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Produkt&action=ajax&mod=wpsg_mod_downloadplus&edit_id=<?php echo $this->view['data']['id'] ?>&noheader=1&cmd=upload_file",
				onSubmit: function(file, extension) {
	
					jQuery('#wpsg_mod_downloadplus_files').html('<img src="<?php echo WPSG_URL; ?>views/gfx/ajax-loader.gif" alt="<?php echo __('Bitte warten ...', 'wpsg'); ?>" />');
					
				},
				onComplete: function(file, response) {

					if (response == '1')
					{
						jQuery("#wpsg_mod_downloadplus_files").load("<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Produkt&action=ajax&mod=wpsg_mod_downloadplus&cmd=pdffiles_list&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1");
					}
					else
					{
						
						alert(response);
						jQuery("#wpsg_mod_downloadplus_files").load("<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Produkt&action=ajax&mod=wpsg_mod_downloadplus&cmd=pdffiles_list&edit_id=<?php echo $_REQUEST['edit_id']; ?>&noheader=1");
						
					}
				}										
			}
		);
		<?php } ?>			
				   
	}); 
	
/* ]]> */
</script>

<div id="wpsg_pdfdownload" class="postbox">	
	<h3 class="wpsg_handlediv">
		<span title="<?php echo __('Zum Ein/Ausklappen hier klicken', 'wpsg'); ?>" class="handlediv"><br /></span>
		<span><?php echo __('DownloadPlus Produkt', 'wpsg'); ?> </span>
	</h3>
	<div class="inside">
		<div id="wpsg_mod_downloadplus_files"><?php echo $this->view['filesList']; ?></div>
		
		<?php if ($this->get_option('wpsg_classicupload') == '1') { ?>
		<input type="file" name="wpsg_mod_downloadplus_file" />
		<?php } else { ?>	
		<input value="<?php echo __("Upload", "wpsg"); ?>" type="text" style="text-align:center;" size="10" id="wpsg_mod_downloadplus_upload" />
		<?php } ?>
		
		<div class="wpsg_clear"></div><br />
		<div class="wpsg_form_field">
			<div class="wpsg_form_left" style="width:75px;">
				<label for="feinheit"><?php echo __('FTP Pfad', 'wpsg'); ?>:</label>
			</div>
			<div class="wpsg_form_right">
				<p>
					<a href="#" onclick="alert('<?php echo addslashes($this->callMod('wpsg_mod_downloadplus', 'getPDFPath', array($this->view['data']['id'], true))); ?>'); return false;"><?php echo __('Anzeigen', 'wpsg'); ?></a>
				</p>
			</div>
			<div class="wpsg_clear"></div>
		</div>		
	</div>
	<div class="clear"></div>
</div>