<?php 

$lldocroot = defined('SITEROOT') ? SITEROOT : $_SERVER['DOCUMENT_ROOT'];
if(file_exists($lldocroot . "/dap/dap-config.php")) include_once ($lldocroot . "/dap/dap-config.php"); // dap config call
 
  try{
        $customFieldsList = Dap_CustomFields::loadUserFacingCustomFields();  // get dap custom fields.
      }
    catch (PDOException $e) {
     return ERROR_DB_OPERATION;
    } catch (Exception $e) {
     return ERROR_GENERAL;
    } 
   
 ?>

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

    <div class="live-links-outer" id="mycontent_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>  My Profile
      <a href="<?= admin_url('admin.php?page=dap_memberpages'); ?>" title="Back to Member Pages" class="member_backicon">Return to Member Pages</a></h3>
 
    <table width="100%" cellpadding="2" cellspacing="2" class="table-outer">
   
     <tr>
    <td valign="top">
     Show Account Info Section?
    </td>
    <td valign="top" width="50%">
       <select  name="showaccountsec" id="showaccountsec">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>

    <tr>
    <td valign="top">
   Show Additional Info Section?
    </td>
    <td valign="top" width="50%">
       <select  name="showaddsec" id="showaddsec">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>

  <tr>
    <td valign="top">
   Show Billing Info Section?
    </td>
    <td valign="top" width="50%">
       <select  name="showbillingsec" id="showbillingsec">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>
  
   <tr>
    <td valign="top">
   Show First Name?
    </td>
    <td valign="top" width="50%">
       <select  name="showfirstname" id="showfirstname">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>
    
     
    <tr>
    <td valign="top">
   Show Last Name?
    </td>
    <td valign="top" width="50%">
       <select  name="showlastname" id="showlastname">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>

   
    <tr>
    <td valign="top">
   Show User Name?
    </td>
    <td valign="top" width="50%">
       <select  name="showusername" id="showusername">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>
    
     
    <tr>
    <td valign="top">
   Show Email?
    </td>
    <td valign="top" width="50%">
       <select  name="showemail" id="showemail">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br/> 
    </td>
    </tr>
    
     
    <tr>
    <td valign="top">
   Show Password?
    </td>
    <td valign="top" width="50%">
       <select  name="showpassword" id="showpassword">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>
    
     
    <tr>
    <td valign="top">
   Show Address1?
    </td>
    <td valign="top" width="50%">
       <select  name="showaddress1" id="showaddress1">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>
    
     
    <tr>
    <td valign="top">
   Show Address2?
    </td>
    <td valign="top" width="50%">
       <select  name="showaddress2" id="showaddress2">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>
     
    <tr>
    <td valign="top">
   Show City?
    </td>
    <td valign="top" width="50%">
       <select  name="showcity" id="showcity">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br />
    </td>
    </tr>
      
    <tr>
    <td valign="top">
   Show State/Province/Region?
    </td>
    <td valign="top" width="50%">
       <select  name="showstate" id="showstate">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>
     
    <tr>
    <td valign="top">
   Show Zip/Postal Code?
    </td>
    <td valign="top" width="50%">
       <select  name="showzip" id="showzip">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>
     
    <tr>
    <td valign="top">
   Show Country?
    </td>
    <td valign="top" width="50%">
       <select  name="showcountry" id="showcountry">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>
     
    <tr>
    <td valign="top">
   Show Phone?
    </td>
    <td valign="top" width="50%">
       <select  name="showphone" id="showphone">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>
     
    <tr>
    <td valign="top">
   Show Fax?
    </td>
    <td valign="top" width="50%">
       <select  name="showfax" id="showfax">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>
     
    <tr>
    <td valign="top">
   Show Company?
    </td>
    <td valign="top" width="50%">
       <select  name="showcompany" id="showcompany">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>
     
    <tr>
    <td valign="top">
   Show Title?
    </td>
    <td valign="top" width="50%">
       <select  name="showtitle" id="showtitle">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>
     
    <tr>
    <td valign="top">
   Show Paypal Email?
    </td>
    <td valign="top" width="50%">
       <select  name="showpaypalemail" id="showpaypalemail">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>
     
    <tr>
    <td valign="top">
   Show Opted Out?
    </td>
    <td valign="top" width="50%">
       <select  name="showoptedout" id="showoptedout">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>
    
    <tr>
  <td valign="top">
 Form Alignment
  </td>
  <td valign="top" width="50%">
  <select id="formalign" style="" name="formalign">
    <option value="none">Center</option>
    <option value="left">Left</option>
    <option value="right">Right</option>
  </select>
  </td>
  </tr>
    
  <tr>
    <td valign="top">
   Heading Label - Account Info
    </td>
    <td valign="top" width="50%">
    <input type="text" id="account_info_heading" value="Account Info"> 
    </tr>
  
  <tr>
    <td valign="top">
   Heading Label - Billing Info
    </td>
    <td valign="top" width="50%">
    <input type="text" id="billing_info_heading" value="Billing Info"> 
    </tr>
  
  <tr>
    <td valign="top">
   Heading Label - Additional Info
    </td>
    <td valign="top" width="50%">
    <input type="text" id="additional_info_heading" value="Additional Info"> 
    </tr>
  
  
    <tr>
    <td valign="top">
   Show Custom Fields?
    </td>
    <td valign="top" width="50%">
       <select  name="showcustomfields" id="showcustomfields">
          <option value="Y">YES</option>
          <option value="N" selected="selected">NO</option>
       </select><br /> 
    </td>
    </tr>
  
   <tr id="select_custom_fields" style="display:none;">
   <td width="50%"></td>
  <td valign="top">
   Select Custom Fields
    </td>
    </tr>
    <tr id="list_custom_fields" style="display:none;">
    <td width="50%"></td>
    <td valign="top">
    
       <select name="customfields" id="customfields" multiple >
       <option value="all">All</option>
         <?php 
     foreach($customFieldsList as $key){
       echo "<option value='".$key['id']."'>".$key['name']."</option>";
     }
     ?>
       </select><br/> 
  </tr>
  
    
  
    <tr>
    <td valign="top">
   Enter Redirect URL
    </td>
    <td valign="top" width="50%">
  <textarea name="redirect" id="redirect"></textarea>
       <br /><i style="font-size:13px;"> <br />For ex: http://yoursite.com/my-account<br />(Users will be redirected to this page upon profile update.If you leave it empty, the users will remain on the same page.)</i>
       <br /> 
    </tr>

     <tr>
    <td valign="top">
   Allow GDPR?
    </td>
    <td valign="top" width="50%">
       <select  name="allowgdpr" id="allowgdpr">
          <option value="Y" selected="selected">YES</option>
          <option value="N">NO</option>
       </select><br /> 
    </td>
    </tr>


    <tr class="show_gdpr_terms">
    <td valign="top">
    GDPR Label
    </td>
    <td valign="top" width="50%">
         <input type="text"  name="gdpr_label" id="gdpr_label" value="GDPR Consent"> 
    </td>   
    </tr>

     <tr class="show_gdpr_terms">
    <td valign="top">
    GDPR Terms
    </td>
      <td valign="top" width="50%">
        <div id="gdprouter" name="gdprouter" style="display:block;border:1px solid #e0e0e0;padding:8px">
          <div class="gdpr-check editable_textarea"><div>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div></div>
          <label><input type="checkbox" class="gdpr_checkbox required" name="GDPRConsent" id="GDPRConsent" value="" disabled ="disabled"> 
           <span class="editable_textarea">Yes, I agree to the Terms</span> 
          </label>
        </div>
    </td>  
    </tr>

    <tr class="show_gdpr_terms">
    <td valign="top">
     Enter GDPR Confirmation Message
    </td>
    <td valign="top" width="50%">
         <input type="text"  name="gdpr_confirmation" id="gdpr_confirmation" value="Are you sure you do not want to give GDPR consent?"> 
    </td>   
    </tr>
   
    
    </table>   
     <div class="shortcode_container"  style="display:none;">  
		  <h5>Here is the DAP My Profile 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="myprofilegenscbtn">Generate Shortcode</button></div>          
       </div>
       </div>
   
  </div>
  <script>
  jQuery('#showcustomfields').change(function(){
    var val = jQuery(this).val();
    if(val == "Y"){
      jQuery('#select_custom_fields').show();
      jQuery('#list_custom_fields').show();
    }
    else{
      jQuery('#select_custom_fields').hide();
      jQuery('#list_custom_fields').hide();
    }
  
  });
  </script>
 
<script>
jQuery(document).ready(function() {
 tinymce_editor();
});
jQuery('#myprofilegenscbtn').on('click',function() {
                         
  var showfirstname = jQuery('select#showfirstname').val();
  var showlastname = jQuery('select#showlastname').val();
  var showusername = jQuery('select#showusername').val();
  var showemail = jQuery('select#showemail').val();
  var showpassword = jQuery('select#showpassword').val();
  var showaddress1 = jQuery('select#showaddress1').val();
  var showaddress2 = jQuery('select#showaddress2').val();
  var showcity = jQuery('select#showcity').val();
  var showstate = jQuery('select#showstate').val();
  var showzip = jQuery('select#showzip').val();
  var showcountry = jQuery('select#showcountry').val();
  var showphone = jQuery('select#showphone').val();
  var showfax = jQuery('select#showfax').val();
  var showcompany = jQuery('select#showcompany').val();
  var showtitle = jQuery('select#showtitle').val();
  var showpaypalemail = jQuery('select#showpaypalemail').val();
  var showoptedout = jQuery('select#showoptedout').val();
  var redirect = jQuery('#redirect').val();
  var showaccountsec = jQuery('#showaccountsec').val();
  var showbillingsec = jQuery('#showbillingsec').val();
  var showaddsec = jQuery('#showaddsec').val();
  
  var account_info_heading = jQuery('#account_info_heading').val();
  var billing_info_heading = jQuery('#billing_info_heading').val();
  var additional_info_heading = jQuery('#additional_info_heading').val();
  
  var formalign = jQuery('#formalign').val();
  var showcustomfields = jQuery('#showcustomfields').val();
  if(showcustomfields == "Y")
  {
    customvalues = jQuery('#customfields').val();
    newvalues = new Array();
    for(var i = 0;i<(customvalues.length);i++){
      if(customvalues[i] == "all"){
        newvalues = [];
        newvalues.push("all");
        break;
      }
      else{
          newvalues.push(customvalues[i]);
      }
    }
    fields = newvalues.toString(); 
  }
  else
  {
    fields = "";
  }

  var allowGDPR = jQuery("#allowgdpr").val();
  var gdpr_label = jQuery("#gdpr_label").val();
  var gdpr_confirmation = jQuery("#gdpr_confirmation").val();
  var add_html = jQuery('#gdprouter').html(); 
 
  var gdprouter = add_html.replace(/'/g, '"');
  
   var shortcode = "[DAPMyProfile showAccountSection='"+showaccountsec+"' showBillingSection='"+showbillingsec+"' showAdditionalSection='"+showaddsec+"' showFirstName='"+showfirstname+"' showLastName='"+showlastname+"' showUserName='"+showusername+"' showEmail='"+showemail+"' showPassword='"+showpassword+"' showAddress1='"+showaddress1+"' showAddress2='"+showaddress2+"' showCity='"+showcity+"' showState='"+showstate+"' showZip='"+showzip+"' showCountry='"+showcountry+"' showPhone='"+showphone+"' showFax='"+showfax+"' showCompany='"+showcompany+"' showTitle='"+showtitle+"' showPaypalEmail='"+showpaypalemail+"' account_info_heading='"+account_info_heading +"' billing_info_heading='"+billing_info_heading +"' additional_info_heading='"+additional_info_heading +"' showOptedOut='"+showoptedout +"' redirect='"+redirect+"' formalign='"+formalign+"' showCustomFields='"+showcustomfields+"'  customFieldValues='"+fields+"' allowGDPR='"+allowGDPR+"'  gdpr_label='"+gdpr_label+"'  gdpr_confirmation='"+gdpr_confirmation+"' gdprouter='"+gdprouter+"' /]";

	jQuery('.shortcode_container').show();
	jQuery('.shortcode_container textarea').html(shortcode);
});



function tinymce_editor() {  

	tinymce.init({
		selector: '.editable_textarea',
		inline: true,
		theme: 'modern',
		force_br_newlines: true,
		force_p_newlines: false,
		resize: "both",
		object_resizing: "img",
		forced_root_block: '',
		fontsize_formats: "8pt 9pt 10pt 11pt 12pt 13pt 14pt 15pt 16pt 17pt 18pt 19pt 20pt 22pt 24pt 26pt 30pt",
		theme_advanced_fonts: "Andale Mono=andale mono,times;" + "Arial=arial,helvetica,sans-serif;" + "Arial Black=arial black,avant garde;" + "Book Antiqua=book antiqua,palatino;" + "Comic Sans MS=comic sans ms,sans-serif;" + "Courier New=courier new,courier;" + "Georgia=georgia,palatino;" + "Helvetica=helvetica;" + "Impact=impact,chicago;" + "Symbol=symbol;" + "Tahoma=tahoma,arial,helvetica,sans-serif;" + "Terminal=terminal,monaco;" + "Times New Roman=times new roman,times;" + "Trebuchet MS=trebuchet ms,geneva;" + "Verdana=verdana,geneva;" + "Webdings=webdings;" + "Wingdings=wingdings,zapf dingbats",
		plugins: ['advlist autolink lists link image charmap print preview hr anchor pagebreak', 'searchreplace wordcount visualblocks visualchars code fullscreen', 'insertdatetime media nonbreaking save table contextmenu directionality', 'emoticons template paste textcolor colorpicker textpattern imagetools'],
		toolbar1: 'insertfile undo redo | styleselect | bold italic |  fontselect | fontsizeselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
		toolbar2: 'print preview media | forecolor backcolor emoticons | codesample',
		image_advtab: true,
		templates: [{
			title: 'Test template 1',
			content: 'Test 1'
		}, {
			title: 'Test template 2',
			content: 'Test 2'
		}]
	});
}


</script>
 
