  <div id="myinvoice_shortcode_popup" style="display:block;" class="popup_div_outer">

    <div class="live-links-outer" id="myinvoice_shortcode_popup_inner">
    <div class="container" id="memberpages_shortcode_popup_button">
     <h3 class="mb-4 border-bottom pb-2"><i class="fa fa-users" aria-hidden="true"></i> Member Invoice
      <a href="<?= admin_url('admin.php?page=dap_memberpages'); ?>" title="Back to Member Pages" class="member_backicon">Return to Member Pages</a></h3>
 
 
	  <form method="post" action="" enctype="multipart/form-data">
	  <table width="100%" cellpadding="2" cellspacing="2" class="table-outer">
    
    <tr>
    <td valign="top">
    Select a Page Template
    </td>
    <td valign="top" width="50%">
       <select  name="ptemplate" id="ptemplate">
         <option value="template1">Template1</option>
       </select><br />
    </td>
    </tr>
	<tr><td></td></tr>
	 <tr>
    <td valign="top">
    Select an Invoice Template
    </td>
    <td valign="top" width="50%">
       <select  name="itemplate" id="itemplate">
         <option value="template1">Template1</option>
		 <option value="template2">Template2</option>
       </select><br />
    </td>
    </tr>
	
	<tr>
    <td valign="top">
    Show a "View Invoice" Link
    </td>
    <td valign="top" width="50%">
	<select name="showinvoice" id="showinvoice">
	<option value="Y">Yes</option>
	<option value="N">No</option>
	</select>
    
    </td>
    </tr>
	
	<tr>
    <td valign="top">
    Enter Admin Email
    </td>
    <td valign="top" width="50%">
      <input type="text" name="adminemail" id="adminemail" value="">
    </td>
    </tr>
	 
	 <tr>
    <td valign="top">
    Enter Company Name
    </td>
    <td valign="top" width="50%">
      <input type="text" name="companyname" id="companyname" value="">
    </td>
    </tr>
	
	<tr>
    <td valign="top">
    Enter Company URL
    </td>
    <td valign="top" width="50%">
      <input type="text" name="companyurl" id="companyurl" value="">
    </td>
    </tr>
	
	
	<tr>
    <td valign="top">
    Enter "No Transaction Found" message
    </td>
    <td valign="top" width="50%">
      <textarea name="notranmsg" id="notranmsg" rows="3">Sorry, no transactions found</textarea>
    </td>
    </tr>
	
	<tr>
    <td valign="top">
    Enter full URL of your Logo image
    </td>
    <td valign="top" width="50%">
	 <input type="file" name="logobrowse" id="logobrowse">
	 
	 <div class="col-sm-8">
        <div class="or">
          <span>OR</span>
        </div>
      </div>
      
      
     <label><br>Enter full URL of your logo image<br></label>
     <textarea name="logourl" id="logourl" rows="5"></textarea>
    </td>
    </tr>
	</table>
	 </form>
	 
	 <div class="shortcode_container" style="display:none;"> 
		  <h5>Here is the DAP Invoice Shortcode</h5>
		 <textarea> </textarea>
      </div>  
	      <div align="center" class="btn_outer"><a href="<?= admin_url('admin.php?page=dap_memberpages'); ?>"><button class="button-primary back-btn" id="backbtn">Back</button> </a>
   <button class="button-primary next-btn" id="myinvoicescbtn">Generate Shortcode</button></div>     
	 
	</div>
	
	</div>
 
	<script>
	jQuery(document).ready(function(){
	
	jQuery('#logobrowse').change(function(){
		if(jQuery(this).val()!=""){
			jQuery('#logourl').prop("disabled",true);
		}
		else{
			jQuery('#logourl').prop("disabled",false);
		}
	});	
		
	jQuery('#myinvoicescbtn').click(function(){
		var ptemplate = jQuery('#ptemplate').val();
		var itemplate = jQuery('#itemplate').val();
		var adminemail = jQuery('#adminemail').val();
		var companyname = jQuery('#companyname').val();
		var companyurl = jQuery('#companyurl').val();
		var notranmsg = jQuery('#notranmsg').val();
		var showinvoice = jQuery('#showinvoice').val();
		var logourl = jQuery('#logourl').val();
		var logobrowse = jQuery('#logobrowse').val();
	
	    if(ptemplate == ""){
			alert("Please select a Page template");
			jQuery('#ptemplate').focus();
			return false;
		}
		if(itemplate == ""){
			alert("Please select an Invoice template");
			jQuery('#itemplate').focus();
			return false;
		} 
		if(adminemail == ""){
			alert("Please enter admin email");
			jQuery('#adminemail').focus();
			return false;
			
		}
		if(companyname == "" ){
			alert("Please enter company name");
			jQuery('#companyname').focus();
			return false;
		}
		if(showinvoice == ""){
			alert("Please select Show invoice");
			jQuery('#showinvoice').focus();
			return false;
		}
		if(logourl == "" && logobrowse == ""){
			alert("Please select a logo file or enter logo URL");
			jQuery('#logobrowse').focus();
			return false;
		}

		if(companyurl == ""){
			alert("Please Enter company URL");
			return false;
		}
	    
		if(logobrowse != "")
		{
		   var formData = new FormData();
           formData.append('action', 'live_links_invoice_logo_image_url');
           formData.append('file', jQuery('input[type=file]')[0].files[0]);
           jQuery.ajax({
               type: 'POST',
               url: ajaxurl,
               data: formData,
               cache: false,
               contentType: false,
               processData: false,
               success: function(data) {
                   logourl = data;
				   var shortcode = '[DAPShowTransactions template="'+ptemplate+'" invoicetemplate="'+itemplate+'" adminemail="'+adminemail+'" companyname="'+companyname+'" companyurl="'+companyurl+'" notranmsg="'+notranmsg+'" showinvoice="'+showinvoice+'" logo="'+logourl+'"][/DAPShowTransactions]';
		           jQuery('.shortcode_container').show();
					jQuery('.shortcode_container textarea').html(shortcode); 
               },
               error: function(data) {
               }
           });
		}
		else if(logourl != ""){
			var shortcode = '[DAPShowTransactions template="'+ptemplate+'" invoicetemplate="'+itemplate+'" adminemail="'+adminemail+'" companyname="'+companyname+'" companyurl="'+companyurl+'" notranmsg="'+notranmsg+'" showinvoice="'+showinvoice+'" logo="'+logourl+'"][/DAPShowTransactions]';
			jQuery('.shortcode_container').show();
			jQuery('.shortcode_container textarea').html(shortcode);
		}
	
		
	});  // click
	}); // ready
	
	</script>
 
