customer_showncimageform.phtml 4.54 KB
<!--
	/** 
	 * Anc_Image_CustomerController::showncimageformAction() template
	 * @var $this anc_image/galleriesmanager (Anc_Image_Block_Galleriesmanager)
	 * 
	 * @package	anc_image 
	 * @anc_image_eingabetyp -- Formular bzw ansicht im Frontend im Warenkorb beim Produkt konfigurieren
	 * @copy Grundlage: Magento18/app/design/frontend/base/default/template/catalog/product/view/options/type/text.phtml 
	 * @since	20140416 
	 * @author	netz.coop eG* 
	 */ 
-->

<?php 
	$ncimage = $this->getCallNcImage();
	$path = Mage::helper('anc_image/ncimage')->getNcImagePath($ncimage->getId(), 'relative', 'original'); 
//	$ncimage_data = mcImagick::getData(Mage::getBaseDir().$path);
	$ncimage_data = mcImagick::getData(Mage::helper('anc_lib/ncfilepath')->getThisMagentoInstallationPath().$path);
	$dropzone_id = 'ancimage-dropzone-id';
	$ancnote_id = '#ancnote';
?>
<form action="<?php echo $this->getUrl('ancimage/customer/showNcImageForm', array('id'=>$ncimage->getId())); ?>" id="ancimage-customer_showNcImageForm">
	<div class="anctable showncimageform">
		<div id="ancnote"></div>

		<div class="ancimage" >
			<div id="<?php echo $dropzone_id; ?>"  class="dropzone ancimage-dropzone">
				<div class="preview-database-image">
					<?php if($path):?>
						<img src="<?php echo DS.$path; ?>"  />
					<?php endif; ?>
				</div>
			</div>
		</div>	
		<div class="fileinfos anctablerow">
			<div class="label">Dateiinfos:</div>
			<div class="value">Breite: <?php echo $ncimage_data['width']?> px - Höhe: <?php echo $ncimage_data['height']; ?> px - Dateigröße: <?php echo mcFile::binary_multiples($ncimage_data['size']); ?> </div>
		</div>

		<div class="name anctablerow">
			<div class="label">Name:</div>
			<div class="value"><input name="name" type="text" size="30" maxlength="30" value="<?php echo $ncimage->getName(); ?>" /></div>
		</div>
		<div class="comment anctablerow">
			<div class="label">Kommentar:</div>
			<div class="value"><textarea name="comment" cols="50" rows="5" ><?php echo $ncimage->getComment(); ?></textarea></div>
		</div>
		<div class="anctablerow buttons">
			<div class="label"></div>
			<div class="value">
				<?php $buttonTitle = 'lösche Datei'; ?>
				<input class="button delete"  title="<?php echo $this->__($buttonTitle) ?>" type="submit" value="<?php echo $this->__($buttonTitle) ?>" /> 
				<?php $buttonTitle = 'speichern'; ?>
				<input class="button save"  title="<?php echo $this->__($buttonTitle) ?>" type="submit" value="<?php echo $this->__($buttonTitle) ?>" /> 		
			</div>
		</div>
		<script type="text/javascript">
			jQuery('.buttons > .delete').unbind("click").click(function(e){
				e.preventDefault(); 			
				jQuery.ajax({ // create an AJAX call...
					url: '<?php echo $this->getUrl('ancimage/customer/deleteNcImage', array('id'=>$ncimage->getId())); ?>', // the file to call
					success: function(rep) { // on success..
						var reponse = jQuery.parseJSON( rep );
						jQuery('#ancnote').append(reponse.message);
						jQuery('#ancnote').addClass('anc-error');
						jQuery('#ancimage-customer_showNcImageForm').hide();
						var gallery_ajaxData = {
							url: "<?php echo $this->getUrl('ancimage/customer/gallerysimple', array()) ?>  ul.gallery",
							context: jQuery(".ancimage-customer_galleriesown > .ancimage-gallerie-content > .ancimage-gallerie-content-view"),
							success: function(data) { 
								jQuery(this).html(data);
								// damit die gallerie auch klickbar ist
									loadNcImageIntoFormThumbnailButton();	
								Anc_Image_Type.customerGallerysimplePrettyPhoto();
							},
						};	
						jQuery.ajax(gallery_ajaxData);
					}
				});
			});				

		</script>
	</div>
</form>	
<script type="text/javascript">
	jQuery(document).ready(function($) {
		var dropzone_params = {
			url: "<?php echo $this->getUrl('ancimage/customer/uploadImage', array('id'=> $ncimage->getId())) ?>",
			dictDefaultMessage: '',
			success: function(file, rep) {	
				var reponse = jQuery.parseJSON( rep );
				this.removeAllFiles();	
				jQuery('#<?php echo $dropzone_id; ?> > .preview-database-image').append('<img src="'+reponse.path+'"  />');
			}
		};
		var gallery_ajaxData = {
			url: "<?php echo $this->getUrl('ancimage/customer/gallerysimple', array()) ?>  ul.gallery",
			context: jQuery(".ancimage-customer_galleriesown > .ancimage-gallerie-content > .ancimage-gallerie-content-view"),
			success: function() { 
				loadNcImageIntoFormThumbnailButton();	
			},
		};			
		Anc_Image_Type.droppableFile(
			jQuery(" #<?php echo $dropzone_id; ?>"), 
			dropzone_params,
			null, 
			jQuery(" <?php echo $ancnote_id; ?>"), 
			gallery_ajaxData,
			false
		);			
	}); 
</script>