<script id="cp_feedback_html<?php print esc_attr($plugin_slug); ?>" type="text/template">
	<div title="QUICK FEEDBACK">
		<div style="padding:10px;">
			<style type="text/css">
				.cp-feedback-reason-block { margin-top:8px; }
			</style>
      		<h3><strong>If you have a moment, please let us know why you are deactivating:</strong></h3>
			<form id="cp_feedback_form{{plugin_slug}}">
				<div class="cp-feedback-reason-block">
					<label>
						<input type="radio" name="answer" value="download-link-issue">
						It is not possible download the purchased songs.<br />
					</label>
					<div id="cp_feedback_download_link_issue" style="margin-left:25px;display:none;padding:10px;border:1px dotted gray;color:#660000">
						<p>Please, check the Instant Payment Notification (IPN) in your PayPal account. If the IPN is not enabled the website won't be notified about the payments. Please, visit the following link: <a href="https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNSetup/#id089EG030E5Z" target="_blank">How to enable the IPN?</a>. PayPal needs the URL to the IPN Script in your website, however, you simply should enter the URL to the home page, because the store will send the correct URL to the IPN Script.</p>
						<p>If the IPN is enabled, you should check the payment status in the <a href="https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNOperations/" target="_blank">IPN history</a>. If the payment's status is different to "Completed", the Music Store does not generate the download link, or send the notification emails, to protect the store against frauds.</p>
						<p style="font-style:italic;">Note that if you are testing the store with a PayPal Sandbox account, you should enabling the IPN in this account too.</p>
					</div>
				</div>
				<div class="cp-feedback-reason-block">
					<label>
						<input type="radio" name="answer" value="notification-email-issue">
						The purchases were registered in the <a href="<?php print esc_attr(admin_url('admin.php?page=music-store-menu-reports')); ?>" target="_blank">sales reports</a>, but the buyers didn't receive the notification emails with the download links.<br />
					</label>
					<div id="cp_feedback_notification_email_issue" style="margin-left:25px;display:none;padding:10px;border:1px dotted gray;color:#660000">
						<p>Enter an email address belonging to your website's domain through the attribute: "Notification "from" email" in the store's settings ( accessible from the menu option: "Music Store/Store Settings"). The email services (like AOL, YAHOO, MSN, etc.) check the email addresses in the "Sender" header of the emails, and if they do not belong to the websites that send the emails, can be classified as spam or even worst, as "Phishing" emails.</p>
						<p>If the email address in the "From" attribute belongs to the store's domain, but the buyer is not receiving the notification email. In this case you should ask the hosting provider the accesses to the SMTP server (all hosting providers include one), and install any of the plugin for SMTP connection distributed for free through the WordPress directory.</p>
					</div>
				</div>
				<div class="cp-feedback-reason-block">
					<label>
						<input type="radio" name="answer" value="temporary-deactivation"> It's a temporary deactivation. I'm just upgrading to the Professional version or debugging an issue.<br />
					</label>
				</div>
				<div class="cp-feedback-reason-block">
					<label>
						<input type="radio" name="answer" value="better-plugin"> I found a better plugin.<br />
					</label>
					<div id="cp_feedback_otherplugin" style="margin-left:25px;display:none;">
						<input type="text" name="otherplugin" placeholder="What's the plugin name?" style="width:100%">
					</div>
				</div>
				<div class="cp-feedback-reason-block">
					<label>
						<input type="radio" name="answer" value="other"> Other.<br />
					</label>
					<div id="cp_feedback_other" style="margin-left:25px;display:none;font-weight:bold;">
						Kindly tell us the reason so we can improve.<br />
						<input type="text" name="otherinfo" style="width:100%">
					</div>
				</div>
				<div id="cp_feedback_anonymous" style="display:none;margin-top:30px;text-align:right">
					<input type="checkbox" name="cp_feedback_anonymous" value="yes"> Anonymous feedback
				</div>
			</form>
		</div>
	</div>
</script>
<script type="text/javascript">
	jQuery(window).on(
		'load',
		function()
		{
			var $ = jQuery,
				plugin_slug = '<?php print esc_js($plugin_slug); ?>',
				support_link = '<?php print esc_js($support_link); ?>',
				full_support_link = '<?php print esc_js($full_support_link); ?>';
			$('[data-slug="'+plugin_slug+'"] .deactivate a').
			on(
				'click',
				function(evt)
				{
					evt.preventDefault()
					evt.stopPropagation();
					// Define events
					$(document).on(
						'change',
						'[id="cp_feedback_form'+plugin_slug+'"] [name="answer"]',
						function()
						{
							var field = $(this),
								value = field.val(),
								form  = field.closest('form');
							$("#cp_feedback_deactivatebtn:visible").val('Submit & Deactivate');
							$("#cp_feedback_deactivatebtn:visible").html('<span class="ui-button-text">Submit &amp; Deactivate</span>');
							form.find("#cp_feedback_anonymous").show();
							form.find("#cp_feedback_other,#cp_feedback_otherplugin,#cp_feedback_download_link_issue,#cp_feedback_notification_email_issue").hide();
							switch(value)
							{
								case 'other':
									form.find("#cp_feedback_other").show();
								break;
								case 'better-plugin':
									form.find("#cp_feedback_otherplugin").show();
								break;
								case 'download-link-issue':
									form.find("#cp_feedback_download_link_issue").show();
								break;
								case 'notification-email-issue':
									form.find("#cp_feedback_notification_email_issue").show();
								break;
							}
						}
					);
					var url_redirect = $('[data-slug="'+plugin_slug+'"] .deactivate a').attr('href'),
						html = $('[id="cp_feedback_html'+plugin_slug+'"]').html();
					html = html.replace(/\{\{plugin_slug\}\}/g, plugin_slug)
							.replace(/\{\{support_link\}\}/g, full_support_link)
							.replace(/\{\{support_link_text\}\}/g, support_link);
					$(html).dialog(
						{
							width:'600',
							dialogClass: 'wp-dialog',
							modal: true,
							close: function(event, ui)
								{
									$(this).dialog("close");
									$(this).remove();
								},
							closeOnEscape: true,
							buttons: [
								{
									id: 'cp_feedback_deactivatebtn',
									text: "Skip & Deactivate",
									click: function()
									{
										var form = $('[id="cp_feedback_form'+plugin_slug+'"]'),
											answer = form.find("input[name='answer']:checked").val(),
											submitFeedback = function(){
												var data = {
													'action': 'cp_feedback',
													'feedback_plugin': plugin_slug
												};
												$.each(form.serializeArray(), function(i,v){data[v['name']] = v['value'];});
												if(ajaxurl) // WordPress global variable with the AJAX URL
												{
													$.post(
														ajaxurl,
														data,
														function(response)
														{
															window.location.href = url_redirect;
														}
													);
												}
											};

										if (answer == undefined || answer == '')
										{
											window.location.href = url_redirect;
										}
										else
										{
											// Promote the Music Store for WooCommerce
											if(answer == 'better-plugin' || answer == 'other')
											{
												promote_html = $('<p>If you have decided to replace the Music Store plugin with other plugin, I recommend you to install our <a href="https://wordpress.org/plugins/music-player-for-woocommerce/" target="_blank" style="font-weight:bold;">Music Player for WooCommerce</a> plugin in order to continue enjoying a <a href="https://wordpress.org/plugins/music-player-for-woocommerce/" target="_blank">Music Player</a> in your new store.</p>');
												$(promote_html).dialog(
													{
														width:'400',
														dialogClass: 'wp-dialog',
														modal: true,
														close: function(event, ui)
															{
																$(this).dialog("close");
																$(this).remove();
																submitFeedback();
															},
														closeOnEscape: true,
														buttons: [
															{
																id: 'cp_feedback_continue',
																text: "Continue",
																click: function()
																{
																	submitFeedback();
																}
															}
														]
													}
												); // End dialog
											}
											else
											{
												submitFeedback();
											}
										}
									}
								},
								{
									text: "We can help: Support Service",
									click: function()
									{
										window.open(support_link);
										$(this).dialog("close");
									}
								},
								{
									text: "Cancel",
									"class": 'button button-primary button-close',
									click: function()
									{
										$(this).dialog("close");
									}
								}
							]
						}
					); // End dialog
				}
			); // End onclick deactivate btn
		}
	); // End onload window
</script>