customer_shownctextform.phtml 12.5 KB
<!--
	/** 
	 * Anc_Text_CustomerController::shownctextformAction() template
	 * @var $this anc_text/galleriesmanager (Anc_Text_Block_Galleriesmanager)
	 * 
	 * @package	anc_text 
	 * @anc_text_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* 
	 */ /home/dev/git/Magento/AncText/app/design/frontend/template/customer_shownctextform.phtml
-->
<script type="text/javascript">

	
//	function ajax_gettextinfo(ncinput_id) {
//		var ajax_edittext_data = {
//			url: "<?php echo Mage::getUrl('anctext/customer/getcustomertextdata'); ?>",
//			method: 'Post',
//			data: {entity_id: ncinput_id},
//			success: function(data, textStatus, jqXhr) {
//				console.log(data);
//				var parseddata = jQuery.parseJSON(data);
//				console.log(parseddata);
//				jQuery("#<?php echo $input_id; ?>").attr('value', parseddata.entity_id);
//				jQuery("#anc_text_id").attr('value', parseddata.entity_id);
//				jQuery("#anc_customer_id").attr('value', parseddata.customer_id);
//				jQuery("#anc_admin_id").attr('value', parseddata.admin_user_id);
//				jQuery("#ncalbum_id").attr('value', parseddata.ncalbum_id);
//				jQuery("#used_byitem_id").attr('value', parseddata.used_byitem_id);
//				jQuery("#ordered").attr('value', parseddata.ordered);
////				tinyMCE.activeEditor.setContent(parseddata.content);
//				loadNcTextIntoForm('<?php echo $this->getUrl('anctext/customer/shownctextform', array()) ?>id/'+parseddata.entity_id+'/');
//			}
//		};
//		console.log('data');
//		jQuery.ajax(ajax_edittext_data);
//	}
		function ajax_gettextinfo(ncinput_id) {
			var ajax_edittext_data = {
			url: "<?php echo Mage::getUrl('anctext/customer/getcustomertextdata'); ?>",
			method: 'Post',
			data: {entity_id: ncinput_id},
			success: function(data, textStatus, jqXhr) {
				console.log('succes');
				var parseddata = jQuery.parseJSON(data);
				console.log(parseddata);
				jQuery("#<?php // echo $input_id; ?>").attr('value', parseddata.entity_id);
				jQuery("#anc_text_id").attr('value', parseddata.entity_id);
				jQuery("#anc_customer_id").attr('value', parseddata.customer_id);
				jQuery("#anc_admin_id").attr('value', parseddata.admin_user_id);
				jQuery("#ncalbum_id").attr('value', parseddata.ncalbum_id);
				jQuery("#used_byitem_id").attr('value', parseddata.used_byitem_id);
				jQuery("#ordered").attr('value', parseddata.ordered);
//				tinymce.execCommand('mceRemoveControl',true,'anctext-texteditorarea-id');
//				tinymce.EditorManager.execCommand('mceRemoveEditor', true, "#anctext-texteditorarea-id");
//				tinymce.EditorManager.execCommand('mceAddEditor', true, "#anctext-texteditorarea-id");
//				tinymce.execCommand('mceAddControl',true,'anctext-texteditorarea-id');
				if (typeof parseddata.content === "undefined"||parseddata.content === null) { 
						parseddata.content=' ';
				}else{
					tinyMCE.activeEditor.setContent(parseddata.content);
				}		
				
//				loadNcTextIntoForm('<?php // echo $this->getUrl('anctext/customer/shownctextform', array()) ?>id/'+parseddata.entity_id+'/');
			}
		};
//		console.log('ncinput_id');
//		console.log('ncinput_id'+ncinput_id);
		jQuery.ajax(ajax_edittext_data);
	}
</script>



<?php 
	$nctext = $this->getCallNcText();
//	$path = Mage::helper('anc_text/nctext')->getNcTextPath($nctext->getId(), 'relative', 'original'); 
//	$nctext_data = mcImagick::getData(Mage::getBaseDir().$path);
//	$nctext_data = mcImagick::getData(Mage::helper('anc_lib/ncfilepath')->getThisMagentoInstallationPath().$path);
	$dropzone_id = 'anctext-dropzone-id';
	$ancnote_id = '#ancnote';
?>
<div id="ancnote"></div>
<form action="<?php echo $this->getUrl('anctext/customer/showNcTextForm', array('id' => $nctext->getId())); ?>" id="anctext-customer_showNcTextForm">
	<div class="anctext" >
		
		<div id="<?php // echo $dropzone_id; ?>"  class="dropzone anctext-dropzone">
			<div class="preview-database-text">
					<input type="hidden" onchange="opConfig.reloadPrice()" id="anc_text_id" data-info="toll" class="data-anc_text_id" name="data-anc_text_id_options" value="<?php echo ''; ?>" />
						<input type="hidden" onchange="opConfig.reloadPrice()" id="anc_customer_id" class="data-anc_customer_id" name="data-anc_customer_id_options" value="<?php echo ''; ?>" />
						<input type="hidden" onchange="opConfig.reloadPrice()" id="anc_admin_id" class="data-anc_admin_id" name="data-anc_admin_id_options" value="<?php echo ''; ?>" />
						<input type="hidden" onchange="opConfig.reloadPrice()" id="ncalbum_id" class="data-ncalbum_id" name="data-anc_admin_id_options" value="<?php echo ''; ?>" />
						<input type="hidden" onchange="opConfig.reloadPrice()" id="used_byitem_id" class="data-used_byitem_id" name="data-used_byitem_id_options" value="<?php echo ''; ?>" />
						<input type="hidden" onchange="opConfig.reloadPrice()" id="ordered" class="data-ordered" name="data-ordered_options" value="<?php echo ''; ?>" />

						<textarea  class="<?php echo 'textareatinymce'; ?>" id="anctext-texteditorarea-id" rows='10' cols="40"></textarea>
					
				<?php if($path):?>
					<img src="<?php // echo DS.$path; ?>"  />
				<?php endif; ?>
			</div>
		</div>
	</div>	
	<div class="fileinfos tablerow">
		<!--<div class="label">Dateiinfos:</div>-->
<!--		<div class="value">Breite: <?php // echo $nctext_data['width']?> px - Höhe: <?php // echo $nctext_data['height']; ?> px - Dateigröße: <?php // echo mcFile::binary_multiples($nctext_data['size']); ?> </div>-->
	</div>

	<div class="name tablerow">
		<div class="label">Name:</div>
		<div class="value"><input name="name" id='text_name' type="text" size="30" maxlength="30" value="<?php echo $nctext->getName(); ?>" /></div>
	</div>
	<div class="comment tablerow">
		<div class="label">Kommentar:</div>
		<div class="value"><textarea name="comment" id='text_comment' cols="50" rows="5" ><?php echo $nctext->getComment(); ?></textarea></div>
	</div>
	<div class="tablerow buttons">
		<?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) ?>" />--> 	
		<?php $backurl= $this->getUrl('*/*/galleriesmanager')?>
		<button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="redirectAfterSubmitAfterSaveText(this,null,'<?php echo $backurl?>')"><span><span><?php echo $buttonTitle ?></span></span></button>	

	</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('anctext/customer/deleteNcText', array('id'=>$nctext->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('#anctext-customer_showNcTextForm').hide();
					var gallery_ajaxData = {
						url: "<?php echo $this->getUrl('anctext/customer/gallerysimple', array()) ?>  ul.gallery",
						context: jQuery(".anctext-customer_galleriesown > .anctext-gallerie-content > .anctext-gallerie-content-view"),
						success: function(data) { 
							jQuery(this).html(data);
							// damit die gallerie auch klickbar ist
								loadNcTextIntoFormThumbnailButton();	
							Anc_Text_Type.customerGallerysimplePrettyPhoto();
						},
					};	
					jQuery.ajax(gallery_ajaxData);
				}
			});
		});			


		function redirectAfterSubmitAfterSaveText(data, url, backurl) {

			var option_id = ''
			var ncalbum_id = jQuery('#ncalbum_id').attr('value');
			var ncinput_id = jQuery('#anc_text_id').attr('value');
			var nccustomerid = jQuery('#anc_customer_id').attr('value');
			var ncadmin_id = jQuery('#anc_admin_id').attr('value');
//		//used_byitem_id
			var used_byitem_id = jQuery('#used_byitem_id').attr('value');
			var ordered = jQuery('#ordered').attr('value');
			var varcontent = tinymce.get('anctext-texteditorarea-id').getContent();
//			var name = jQuery('#text_name').attr('value');
			var name = jQuery('#text_name').val();
			var comment = jQuery('#text_comment').val();
			////		var nctext_id = jQuery("#<?php // echo $AncTextInputId;  ?>").attr('value');
			console.log(jQuery(this));
			console.log('ncalbum_id: ' + ncalbum_id);
			console.log('ncinput_id: ' + ncinput_id);
			console.log('nccustomerid:' + nccustomerid);
			console.log('ncadmin_id: ' + ncadmin_id);
			console.log('used_byitem_id: ' + used_byitem_id);
			console.log('ordered: ' + ordered);
			console.log('option_id: ' + option_id);
			console.log('name: ' + name);
			console.log('comment: ' + comment);
			console.log('tiymce' + varcontent);

			ajax_edittexts(ncinput_id, option_id, ncalbum_id, nccustomerid, ncadmin_id, used_byitem_id, ordered, varcontent,name,comment ,true, data, url, backurl);



		}



		function ajax_edittexts(ncinput_id, option_id, ncalbum_id, nccustomerid, ncadmin_id, used_byitem_id, ordered, varcontent,name,comment, ifredirectAfterSubmit, data, url, backurl) {
			var ajax_edittext_data = {
				url: "<?php echo Mage::getUrl('anctext/customer/savecustomertext'); ?>",
				method: 'Post',
				//			dataType:"json",
				data: {ncinput_id: ncinput_id, option_id: option_id, ncalbum_id: ncalbum_id, nccustomerid: nccustomerid, ncadmin_id: ncadmin_id, used_byitem_id: used_byitem_id, ordered: ordered, varcontent: varcontent,name:name,comment:comment,special:'custemerbe'},
				success: function(data, textStatus, jqXhr) {
					console.log(data);
					var parseddata = jQuery.parseJSON(data);
					console.log(parseddata);
					jQuery("#<?php echo $input_id; ?>").attr('value', parseddata.id);
					if (ifredirectAfterSubmit) {
//						ajax_gettextinfo(parseddata.id)
//						
											redirectAfterSubmit(data, url, backurl);

					}
					
				}
			};
			jQuery.ajax(ajax_edittext_data);

		}

				function redirectAfterSubmit(data, url, backurl){
				jQuery(location).attr('href',backurl);
//					this.submit(data, url);
						//            jquery.ajax(backurl);
				}


	</script>

</form>	

<script type="text/javascript">
	jQuery(document).ready(function($) {
//		console.log(jQuery(this).data());
//		
//		
//		
//		


tinymce.init({
		selector: "textarea.textareatinymce",
		toolbar: "undo redo | bold italic | fontselect fontsizeselect forecolor | selectall removeformat | code | spellchecker ", //backcolor
		menu: {// this is the complete default configuration
			platzhalter: {title: 'Platzhalter', items: 'vorname nachname strasse plz ort land anrede titel firma ansprache adresse absender variable1 variable2 variable3 variable4 variable5 variable6'}
		},
		plugins: "code,textcolor,platzhalter,spellchecker,paste",
		paste_as_text: true,
		formats: {
		},
		fontsize_formats: "8 9 10 11 12 13 14 15 20 30 40 50 75",
		font_formats: "Arial=arial;Comic Sans MS=comic sans ms;Courier New=courier new,courier;Georgia=georgia;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times;Verdana=verdana,geneva;",
		setup: function(editor) {
			editor.addButton('platzhalter', {
				text: 'Platzhalter',
				icon: false,
				onclick: function() {
					editor.execCommand('mceTableInsertRowAfter', false, editor);
				}
			});
		}
	});
var url = jQuery("#anctext-customer_showNcTextForm").attr('action')
url = url.replace(/\/$/, '');
var id = url.substring(url.lastIndexOf('/') +1);

//alert(url +'  ---  '+id);
		ajax_gettextinfo(id);
//		

//		var dropzone_params = {
//			url: "<?php // echo $this->getUrl('anctext/customer/uploadText', array('id'=> $nctext->getId())) ?>",
//			dictDefaultMessage: 'Bitte ziehen Sie aus Ihrem Dateiexplorer einfach ein Bild in diesen Bereich!',
//			success: function(file, rep) {	
//				var reponse = jQuery.parseJSON( rep );
//				this.removeAllFiles();	
//				jQuery('#<?php // echo $dropzone_id; ?> > .preview-database-text').append('<img src="'+reponse.path+'"  />');
//			}
//		};
//		var gallery_ajaxData = {
//			url: "<?php // echo $this->getUrl('anctext/customer/gallerysimple', array()) ?>  ul.gallery",
//			context: jQuery(".anctext-customer_galleriesown > .anctext-gallerie-content > .anctext-gallerie-content-view"),
//			success: function() { 
//				loadNcTextIntoFormThumbnailButton();	
//			},
//		};			
		Anc_Text_Type.droppableFile(
			jQuery(" #<?php // echo $dropzone_id; ?>"), 
			dropzone_params,
			null, 
			jQuery(" <?php // echo $ancnote_id; ?>"), 
			gallery_ajaxData,
			false
		);			
	}); 
</script>