HEX
Server: Apache
System: Linux server1.panigaletech.com 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/captainschairit.com/wp-content/themes/captainschare/template-parts/collect-data-msp.php
<?php
/**
 * Template Name: Collect Data MSP
 */
session_start();
if(!isset($_SESSION['pricing_msp'])) {
  if(isset($_GET['val'])){
    $_SESSION['pricing_msp'] = $_GET['val'];
  } else {
    $url = get_site_url().'/pricing-msp';
    wp_redirect( $url );
    exit;
  }
}
if(isset($_POST) && isset($_POST['company_url']) && isset($_POST['first_name']) && isset($_POST['last_name']) && isset($_POST['email'])) {
  session_start();
  $_SESSION['company_info'] = array();
  $_SESSION['company_info']['company_url'] = $_POST['company_url'];
  $_SESSION['company_info']['first_name'] = $_POST['first_name'];
  $_SESSION['company_info']['last_name'] = $_POST['last_name'];
  $_SESSION['company_info']['email'] = $_POST['email'];
  $_SESSION['company_info']['phone_no'] = $_POST['phone_no'];
  $_SESSION['company_info']['web_url'] = $_POST['web_url'];
  $_SESSION['company_info']['lead_source'] = $_POST['lead_source'];
  $_SESSION['company_info']['termCondition'] = $_POST['termCondition'];
  // Billing Info
  $_SESSION['billing_info']['company_name'] = $_POST['company_name'];
  $_SESSION['billing_info']['bill_address'] = $_POST['bill_address'];
  $_SESSION['billing_info']['bill_city'] = $_POST['bill_city'];
  $_SESSION['billing_info']['bill_country'] = $_POST['bill_country'];
  $_SESSION['billing_info']['bill_state'] = $_POST['bill_state'];
  $_SESSION['billing_info']['bill_zip'] = $_POST['bill_zip'];
  // echo '<pre>'; print_r($_SESSION); exit;
  if(isset($_POST['company_url']) && isset($_POST['first_name']) && isset($_POST['last_name']) && isset($_POST['email'])) {
    $url = get_site_url().'/choose-connectors';
    wp_redirect( $url );
    exit;
  } else {
    $err = 'One or more then one field is empty';
  }
}
$base_url = get_option( 'api_base' );
$api = '/api/cc/list-country';
$request_body = '';
$args_country_list = array(
  'timeout' => 120,
  'redirection' => 5,
  'httpversion' => '1.0',
  'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url(),
  // 'blocking'    => true,
  'headers' => array('Accept' => 'application/json', 'Content-Type' => 'application/json'),
  // 'cookies'     => array(),
  'body' => json_encode($request_body),
);
$reasult_country = wp_remote_post($base_url . $api, $args_country_list);
// $parsed_ststes = json_decode(wp_remote_retrieve_body($states), true);
$response_body_country = json_decode(wp_remote_retrieve_body($reasult_country), true);
// echo $api.'<pre>'; print_r($reasult_country); 
// echo '<pre>'; print_r($response_body_city); exit;
// If country ID exists Hole the value for state
if($_SESSION['billing_info']['bill_country']) {
		$api = '/api/cc/list-state?country_id='.$_SESSION['billing_info']['bill_country'];
		$request_body = '';
	$args_get_country_by_state = array(
		'timeout' => 5,
		'redirection' => 5,
		'httpversion' => '1.0',
		'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url(),
		// 'blocking'    => true,
		'headers' => array('Accept' => 'application/json', 'Content-Type' => 'application/json'),
		// 'cookies'     => array(),
		'body' => json_encode($request_body),
	);
  $reasult_state = wp_remote_post($base_url . $api, $args_get_country_by_state);
  $response_body_state = json_decode(wp_remote_retrieve_body($reasult_state), true);
  // echo '<pre>'; print_r($response_body_state); exit;
}
get_header();
$page_heading = get_field('page_heading');
$captains_charis_url_instructions = get_field('captains_charis_url_instructions');
$content_big_font = get_field('content_big_font');
$content_small_font = get_field('content_small_font');
$image = get_field('image');
?>
 
   <!-- Services -->
  <section class="page-section msp-menu-top msp-page-section" id="CompanyInfo">
    <div class="container">
      <div class="row">
        <div class="col-lg-12 text-center">
          <h2 class="heading01 mb-5"><?php echo $page_heading; ?></h2>
        </div>
        <div class="col-sm-12">
          <div class="msp-tab">
            <?php require_once( trailingslashit( get_template_directory() ). 'template-parts/order-tabs.php' ); ?>
            <div class="msp-tab-body">


            
            <!-- <p><?php //echo $captains_charis_url_instructions; ?></p> -->
              <form action="" method="POST" id="contact_info">
                
                <div class="row">
                  <!-- <div class="col-md-6 col-sm-12">
                    <div class="msp-head">
                      <?php //echo $content_big_font; ?>
                    </div>
                    <p class="mb-4"><?php //echo $content_small_font; ?></p>
                    <figure class="border-radius-25 max-height-300 overflow-hiden">
                      <img src="<?php //echo $image; ?>">
                    </figure>
                  </div> -->
                    <div class="col-lg-8 col-md-10 offset-md-1 offset-lg-2">
                      <div class="setup-data-row setup-block">
                        <h3 class="setup-heading setup-heading-block">Contact Information</h3>
                        <div class="row mb-4 setup-form-block">
                          <div class="col-md-6 col-lg-4">
                            <div class="form-group form-placeholder">
                              <input type="text" class="form-control" id="first_name" name="first_name" value="<?php echo (isset($_SESSION['company_info']['first_name']))?$_SESSION['company_info']['first_name']:''; ?>" placeholder="First Name">
                              <label class="placeholder-label">First Name <span>*</span></label>
                            </div>
                          </div>
                          <div class="col-md-6 col-lg-4">
                            <div class="form-group form-placeholder">
                              <input type="text" class="form-control" id="last_name" name="last_name" value="<?php echo (isset($_SESSION['company_info']['last_name']))?$_SESSION['company_info']['last_name']:''; ?>" placeholder="First Name">
                              <label class="placeholder-label">Last Name <span>*</span></label>
                            </div>
                          </div>

                          <div class="col-md-6 col-lg-4">
                            <div class="form-group form-placeholder ">
                              <input type="email" class="form-control" id="email" name="email" value="<?php echo (isset($_SESSION['company_info']['email']))?$_SESSION['company_info']['email']:''; ?>" placeholder="First Name">
                              <span id="email_validate" class="error-custom"></span>
                              <span id="email_validate_success" class="success-custom"></span>
                              <label class="placeholder-label">Email <span>*</span></label>
                            <!-- <a class="check-availability" id="email_check_btn">Check Availability</a> -->
                            </div>
                          </div>
                          <div class="col-md-6 col-lg-4">
                            <div class="form-group form-placeholder">
                              <input type="text" class="form-control" id="phone_no" name="phone_no" value="<?php echo (isset($_SESSION['company_info']['phone_no']))?$_SESSION['company_info']['phone_no']:''; ?>" placeholder="First Name" maxlength="10">
                              <label class="placeholder-label">Phone </label>
                            </div>
                          </div>

                          <div class="col-md-6 col-lg-4">
                            <div class="form-group form-placeholder">
                              <input type="url" class="form-control" id="web_url" name="web_url" value="<?php echo (isset($_SESSION['company_info']['web_url']))?$_SESSION['company_info']['web_url']:''; ?>" placeholder="First Name">
                              <label class="placeholder-label">Website </label>
                            </div>
                          </div>
						  <div class="col-md-6 col-lg-4">
                            <div class="form-group form-placeholder">
                              <select class="form-control" name="lead_source" id="lead_source">
                                <option value=""></option>
                                  <option value="ConnectWise Marketplace" <?php selected( $_SESSION['company_info']['lead_source'], 'ConnectWise Marketplace' ); ?>>ConnectWise Marketplace</option>
                                  <option value="Kaseya Marketplace" <?php selected( $_SESSION['company_info']['lead_source'], 'Kaseya Marketplace' ); ?>>Kaseya Marketplace</option>
                                  <option value="Email" <?php selected( $_SESSION['company_info']['lead_source'], 'Email' ); ?>>Email</option>
                                  <option value="TechTribe" <?php selected( $_SESSION['company_info']['lead_source'], 'TechTribe' ); ?>>TechTribe</option>
                                  <option value="TradeShow" <?php selected( $_SESSION['company_info']['lead_source'], 'TradeShow' ); ?>>TradeShow</option>
                                  <option value="Other" <?php selected( $_SESSION['company_info']['lead_source'], 'Other' ); ?>>Other</option>
                              </select>
                              <label class="placeholder-label leads">How did you hear about us?</label>
                            </div>
                          </div>
                        </div>
                      </div>

                      <div class="setup-data-row setup-block">
                      <h3 class="setup-heading setup-heading-block">Company Information</h3>
                      <div class="row mb-4 setup-form-block">
                        <!-- Fields From Payment details page -->
                        <div class="col-md-12 col-lg-4">
                          <div class="form-group form-placeholder">
                            <input type="text" class="form-control " placeholder="Company Name" name="company_name" value="<?php echo (isset($_SESSION['billing_info']['company_name']))?$_SESSION['billing_info']['company_name']:''; ?>" id="company_name">
                            <label class="placeholder-label">Company Name <span>*</span></label>
                          </div>
                        </div>

                        <div class="col-md-12 col-lg-8">
                          <div class="form-group form-placeholder">
                            <input type="text" class="form-control " placeholder="Address" name="bill_address" value="<?php echo (isset($_SESSION['billing_info']['bill_address']))?$_SESSION['billing_info']['bill_address']:''; ?>" id="bill_address" maxlength="60">
                            <label class="placeholder-label">Address <span>*</span></label>
                          </div>
                        </div>

                        <div class="col-md-6 col-lg-3">
                          <div class="form-group form-placeholder">
                            <select class="form-control" name="bill_country" id="bill_country">
                              <option value=""></option>
                              <?php foreach($response_body_country['data'] as $country) { ?>
                                <option value="<?php echo $country['i_id']; ?>" <?php selected( $_SESSION['billing_info']['bill_country'], $country['i_id'] ); ?>><?php echo $country['s_name']; ?></option>
                              <?php
                              } ?>
                            </select>
                            <label class="placeholder-label">Country <span>*</span></label>
                          </div>
                        </div>
                        <div class="col-md-6 col-lg-3">
                          <div class="form-group form-placeholder">
                            <!-- <input type="text" class="form-control" placeholder="City" name="bill_state" value="<?php //echo (isset($_SESSION['billing_info']['bill_state']))?$_SESSION['billing_info']['bill_state']:''; ?>" id="bill_state"> -->
                            <select class="form-control" name="bill_state" id="bill_state">
                              <option value=""></option>
                              <?php foreach($response_body_state['data'] as $state) { ?>
                                <option value="<?php echo $state['s_Code']; ?>" <?php selected( $_SESSION['billing_info']['bill_state'], $state['s_Code'] ); ?>><?php echo $state['s_name']; ?></option>
                              <?php
                              } ?>
                            </select>
                            <label class="placeholder-label">State <span>*</span></label>
                          </div>
                        </div>

                        <div class="col-md-6 col-lg-3">
                          <div class="form-group form-placeholder">
                            <input type="text" class="form-control" placeholder="City" name="bill_city" value="<?php echo (isset($_SESSION['billing_info']['bill_city']))?$_SESSION['billing_info']['bill_city']:''; ?>" id="bill_city">
                            <label class="placeholder-label">City <span>*</span></label>
                          </div>
                        </div>
                        <div class="col-md-6 col-lg-3">
                          <div class="form-group form-placeholder">
                            <input type="text" class="form-control " placeholder="Country" name="bill_zip" value="<?php echo (isset($_SESSION['billing_info']['bill_zip']))?$_SESSION['billing_info']['bill_zip']:''; ?>" id="bill_zip">
                            <label class="placeholder-label">ZIP Code <span>*</span></label>
                          </div>
                        </div>
                      </div>
                      </div>
                    </div>
                        
                </div>
                <div class="row">
                  <div class="col-lg-8 col-md-12 offset-lg-2">
                   <div class="setup-data-row setup-block"> 
                   <h3 class="setup-heading setup-heading-block">Create Captain’s Chair Site URL</h3>
                      <div class="msp-gray-bg msp-bg-none mb-4 clearfix">
                        <div class="one-two one-two-block">
                          <div class="form-group form-placeholder mb-0 check-availability-form-msp">
                            <input type="text" class="form-control" id="company_url" name="company_url" value="<?php echo (isset($_SESSION['company_info']['company_url']))?$_SESSION['company_info']['company_url']:''; ?>" placeholder="Company URL">
                            <span id="company_url_validate" class="error-custom msp-error"></span>
                            <span id="company_url_success" class="success-custom msp-error"></span>
                            <label class="placeholder-label">Captain's Chair URL <span>*</span></label>
                          </div>
                        </div>
                        <div class=" one-two-top">
                      <span>.captainschair.app</span>
                        <button type="button" class="checkavailability" id="cc_url_check_btn">Check Availability</button>
                      </div>

                   </div>

                    </div>
                  </div>
                </div>
                <div class="text-center">
                  <div class="mb-4">
                    <input type="checkbox" name="termCondition" value="1" id="term-condition" class="mr-2" <?php echo ($_SESSION['company_info']['termCondition'] == 1)?'checked':'' ?>>
                    <label for="term-condition">I accept this <a href="<?php echo get_site_url(); ?>/saas-agreement.pdf" target="_blank" rel="noopener noreferrer">agreement</a>.</label>
                    <span id="termCondition-error" class="termCondition-hide">Please select the terms and conditions.</span>
                  </div>
                  <a href="<?php echo get_site_url(); ?>/pricing/" class="btn btn-gray btn-rounded hvr-shutter-out-horizontal text-transform">Back</a>
                  <button type="submit" id="contact_info_sbt" class="btn btn-primary btn-rounded hvr-shutter-out-horizontal text-transform">Submit</button>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
  
<?php
get_footer();
?>
<script>
  $(document).ready(function () {
    var form_contact = $("#contact_info");
    var submitbutton_contact = $("#contact_info_sbt");
    jQuery.validator.setDefaults({
      debug: true,
      success: "valid"
    });
    jQuery.validator.methods.email = function( value, element ) {
      return this.optional( element ) || /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test( value );
    }
    jQuery.validator.methods.url = function( value, element ) {
      return this.optional( element ) || /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/.test( value );
    }
    jQuery.validator.methods.alphanumeric = function( value, element ) {
      return this.optional( element ) || /^[a-zA-Z0-9]+$/i.test(value);
    }
    var validator = $( "#contact_info" ).validate({
      rules: {
        company_url: {
          required: true,
          alphanumeric: true
        },
        first_name: {
          required: true
        },
        last_name: {
          required: true
        },
        phone_no: {
          // required: true,
          digits: true,
          minlength: 10,
          maxlength: 10
        },
        email: {
          required: true,
          email: true
        },
        web_url: {
          // required: true,
          url: true
        },
        company_name: {
          required: true
        },
        bill_address: {
          required: true
        },
        bill_country: {
          required: true
        },
        bill_state: {
          required: true
        },
        bill_city: {
          required: true
        },
        bill_zip: {
          required: true,
		      alphanumeric: true
        }
      },
      messages: {
        company_url: {
          alphanumeric: "Only alphanumeric input is allowed."
        },
		  bill_zip: {
          alphanumeric: "Number and characters only."
        }
      },
      onfocusout: function(element) {
          // "eager" validation
          this.element(element);  
      },
      onkeyup: function(element) {
        $('#company_url_validate').html('')
        $('#email_validate').html('')
        $('#company_url_success').html('')
        $('#email_validate_success').html('')
        $('#termCondition-error').removeClass('termCondition-show');
        $('#termCondition-error').addClass('termCondition-hide');
      },
      errorElement : 'span',
      errorLabelContainer: '.errorTxt',
      submitHandler: function (form) {
      
      // Company URL
      var form_contact = $("#contact_info");
      var company_url = $('#company_url').val()
      var email_valid = false
      var comp_valid = false
      $("#loader").removeClass('hidden');
      $("#loader").addClass('show');
      $('#company_url_validate').html('')
      $('#email_validate').html('')
      $('#company_url_success').html('')
      // jQuery.ajax({
      //   url: "<?php //echo admin_url('admin-ajax.php'); ?>",
      //     type: "post",
      //     dataType: 'json',
      //     data: {
      //       action : 'validate_cc_url', company_url: company_url
      //     },
      //     success: function(data) {
      //         // console.log(data)
      //         if(data.status == 'success') {
      //           comp_valid = true; 
      //         } else if (data.status == 'error') {
      //           // console.log(data.msg)
      //           if(data.err_flag == 'domain') {
      //             $('#company_url_validate').html('This domain name is not available. Please choose another.')
      //             comp_valid = false; // prevent normal form posting
      //           }
      //         }
      //         $("#loader").removeClass('show');
      //         $("#loader").addClass('hidden');
      //     }
      // }) 
      //  Email Exists
      var email = $('#email').val()
      jQuery.ajax({
        url: "<?php echo admin_url('admin-ajax.php'); ?>",
          type: "post",
          dataType: 'json',
          data: {
            action : 'before_submit_check', company_url_sbt: company_url, email_sbt: email
          },
          success: function(data) {
              // console.log(data)
              // console.log(data['url'])
              // console.log(data['email'])
              if(data['url']['status'] == 'success' && data['email']['status'] == 'success') {
                $("#loader").removeClass('show');
                $("#loader").addClass('hidden');
                $('#termCondition-error').removeClass('termCondition-show');
                $('#termCondition-error').addClass('termCondition-hide');
                email_valid = true
                if($('input[name=termCondition]').is(':checked')) {
                  
                  if ($(form).valid()) {
                    form.submit();
                  }
                } else {
                  $('#termCondition-error').removeClass('termCondition-hide');
                  $('#termCondition-error').addClass('termCondition-show');
                }
                
              } else if (data['url']['status'] == 'error' || data['email']['status'] == 'error') {
                // console.log(data.msg)
                if(data['email']['err_flag'] == 'email' && data['email']['status'] != 'success') {
                  $('#email_validate').html(data['email']['msg'])
                  email_valid = false; // prevent normal form posting
                  $("#loader").removeClass('show');
                  $("#loader").addClass('hidden');
                }
                if(data['url']['err_flag'] == 'domain'  && data['url']['status'] != 'success') {
                  $('#company_url_validate').html('This domain name is not available. Please choose another.')
                  comp_valid = false; // prevent normal form posting
                  $("#loader").removeClass('show');
                  $("#loader").addClass('hidden');
                }
                if(!email_valid || !comp_valid) {
                  return false 
                }
              }
          }
      }) 
      // if(comp_valid && email_valid) {
      //   if ($(form).valid()) {
      //       form.submit();
      //     }
      //   } else {
      //     return false
      //   }
      }
    });
    $("#company_url").focusout(function(){
      var company_url = $('#company_url').val()
      if(company_url == '') {
        $('#company_url_validate').html('')
      }
    });
    $("#email").focusout(function(){
      var email_validate = $('#email').val()
      if(email_validate == '') {
        $('email_validate').html('')
      }
    });
    // Check CC URL
    $("#cc_url_check_btn").on('click', function(){
      var company_url = $('#company_url').val()
      var regex = /^[a-zA-Z0-9]+$/i;
      var comp_valid = false
      if(company_url != '') {
        $("#loader").removeClass('hidden');
        $("#loader").addClass('show');
      }
      // $("#loader").show()
      $('#email_validate').html('')
      $('#company_url_validate').html('')
      $('#company_url_success').html('')
      if(regex.test(company_url)) {
        jQuery.ajax({
          url: "<?php echo admin_url('admin-ajax.php'); ?>",
            type: "post",
            dataType: 'json',
            data: {
              action : 'validate_cc_url', company_url: company_url
            },
            success: function(data) {
                if(data.status == 'success') {
                  $("#loader").removeClass('show');
                  $("#loader").addClass('hidden');
                  $('#company_url_success').html(data.msg)
                  // comp_valid = true; 
                } else if (data.status == 'error') {
                  if(data.err_flag == 'domain') {
                    $('#company_url_validate').html('This domain name is not available. Please choose another.')
                    $("#loader").removeClass('show');
                    $("#loader").addClass('hidden');
                    comp_valid = false; // prevent normal form posting
                  }
                }
            }
        })
      } else {
        $("#loader").removeClass('show');
        $("#loader").addClass('hidden');
      }
    });
    // Check Email Availability
    $("#email_check_btn").on('click', function(){
      var company_url = $('#company_url').val()
      var regex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
      var email = $('#email').val()
      $('#company_url_validate').html('')
      $('#email_validate').html('')
      $('#email_validate_success').html('')
      if(email != '') {
        $("#loader").removeClass('hidden');
        $("#loader").addClass('show');
      }
      if(regex.test(email)) {
        jQuery.ajax({
          url: "<?php echo admin_url('admin-ajax.php'); ?>",
            type: "post",
            dataType: 'json',
            data: {
              action : 'validate_cc_email', company_url: company_url, email: email
            },
            success: function(data) {
                // console.log(data)
                if(data.status == 'success') {
                  $('#email_validate_success').html(data.msg)
                  $("#loader").removeClass('show');
                  $("#loader").addClass('hidden');
                  // email_valid = true
                } else if (data.status == 'error') {
                  // console.log(data.msg)
                  if(data.err_flag == 'email') {
                    $('#email_validate').html(data.msg)
                    $("#loader").removeClass('show');
                    $("#loader").addClass('hidden');
                  }
                  if(data.err_flag == 'domain') {
                    $('#company_url_validate').html('This domain name is not available. Please choose another.')
                    $("#loader").removeClass('show');
                    $("#loader").addClass('hidden');
                    comp_valid = false; // prevent normal form posting
                  }
                }
            }
        }) 
      } else {
        $("#loader").removeClass('show');
        $("#loader").addClass('hidden');
      }
      
    });
    // Get State from country
    $("#bill_country").on('change', function(){
      var options = [];
      $("#loader").removeClass('hidden');
      $("#loader").addClass('show');
      var country_id = $('#bill_country').val();
      jQuery.ajax({
        url: "<?php echo admin_url('admin-ajax.php'); ?>",
          type: "post",
          dataType: 'json',
          data: {
            action : 'get_state_by_country', country_id: country_id
          },
          success: function(data) {
              console.log(data);
              if(data.status == 'success') {
                // for(i=month; i<=12;i++){
                //   options += '<option value="'+month2digits(i)+'">'+GetMonthName_abbvr(i)+'</option>';
                // }
                options += '<option value=""></option>';
                $.each(data.data, function(index, value) {
                  // console.log(value.s_Code);
                  // console.log(value.s_name);
                  options += '<option value="'+value.i_id+'">'+value.s_name+'</option>';
                  // Will stop running after "three"
                  // return (value !== 'three');
                });
                // console.log($.format.date("2018-05-10T01:10:20+02:00","dd/MM/yyyy"));
                // console.log(current_year);

                $('#bill_state').html(options);
                
              }
              $("#loader").removeClass('show');
              $("#loader").addClass('hidden');
          }
      })
    });
  });
</script>