273 lines
11 KiB
PHP
273 lines
11 KiB
PHP
<?php
|
|
//ini_set("display_errors",1);
|
|
session_start(); get_header('thank');
|
|
|
|
if($_SESSION['error_counter']<= 5){
|
|
}
|
|
|
|
call_the_style();//richiama la funzione per settare gli stili. vedi functions.php ?>
|
|
|
|
<?php
|
|
function fix_dash($num){
|
|
$number = $num;
|
|
$number = str_replace("-","",$number); //se ci sono dash li rimuovo
|
|
$number = str_split($number); //trasformo in array
|
|
$number1 = array_slice($number, 0, 3);
|
|
array_push($number1, '-');
|
|
$number2 = array_slice($number, 3, 3);
|
|
array_push($number2, '-');
|
|
$number3 = array_slice($number, 6, 4);
|
|
$number = array_merge($number1, $number2, $number3);
|
|
$number = implode('', $number);
|
|
return $number;
|
|
}
|
|
|
|
//profile data
|
|
$Name_shipping = $_POST['firstName_shipping'].'%'.$_POST['lastName_shipping'];
|
|
$FirstName= $_POST['firstName_shipping'];
|
|
$LastName= $_POST['lastName_shipping'];
|
|
$birth_date = $_POST['profile_month'].'/'.$_POST['profile_day'].'/'.$_POST['profile_year'];
|
|
$country_shipping = $_POST['country_shipping'];
|
|
$address1_shipping = $_POST['address1_shipping'];
|
|
$address2_shipping = $_POST['address2_shipping'];
|
|
$cross_street = $_POST['cross_street'];
|
|
$city_shipping = $_POST['city_shipping'];
|
|
$state_shipping = $_POST['state_shipping'];
|
|
$zip_shipping = $_POST['zip_shipping'];
|
|
$email_shipping = $_POST['email_shipping'];
|
|
$phone_shipping = $_POST['phone_shipping'];
|
|
|
|
|
|
|
|
//Will Anyone Else Use This System*
|
|
$FirstName2= $_POST['anotherperson_firstname'];
|
|
$LastName2= $_POST['anotherperson_lastname'];
|
|
$name_two = $_POST['anotherperson_firstname'].'%'.$_POST['anotherperson_lastname'];
|
|
$another_person_date_of_birth = $_POST['another_person_month'].'/'.$_POST['another_person_day'].'/'.$_POST['another_person_year'];
|
|
$state_another_person_phone = $_POST['another_person_phone'];
|
|
|
|
//first_emergency_contact
|
|
$name_first_emergency_contact = $_POST['fname_emergency_contact'].'%'.$_POST['sname_emergency_contact'];
|
|
$f_n_ec1=$_POST['fname_emergency_contact'];
|
|
$l_n_ec1=$_POST['sname_emergency_contact'];
|
|
$first_emergencycontact_relationship = $_POST['1_emergencycontact_relationship'];
|
|
$phone_first_emergency_contact = $_POST['phone_first_emergency_contact'];
|
|
/*$s_phone_first_emergency_contact = $_POST['s_phone_first_emergency_contact'];*/
|
|
|
|
//sec_emergency_contact
|
|
$name_second_emergency_contact = $_POST['fname_second_emergency_contact'].'%'.$_POST['sname_second_emergency_contact'];
|
|
$f_n_ec2=$_POST['fname_second_emergency_contact'];
|
|
$l_n_ec2=$_POST['sname_second_emergency_contact'];
|
|
//$name_second_emergency_contact = ($_POST['fname_second_emergency_contact']) ? $_POST['fname_second_emergency_contact']($_POST['sname_second_emergency_contact']) ? ' '.$_POST['sname_second_emergency_contact'] :'' : '';
|
|
$second_emergencycontact_relationship = $_POST['2_emergencycontact_relationship'];
|
|
$phone_second_emergency_contact = $_POST['phone_second_emergency_contact'];
|
|
|
|
//third_emergency_contact
|
|
$fname_third_emergency_contact = $_POST['fname_third_emergency_contact'].'%'.$_POST['sname_third_emergency_contact'];
|
|
$f_n_ec3=$_POST['fname_third_emergency_contact'];
|
|
$l_n_ec3=$_POST['sname_third_emergency_contact'];
|
|
//$fname_third_emergency_contact = ($_POST['fname_third_emergency_contact']) ? $_POST['fname_third_emergency_contact']($_POST['sname_third_emergency_contact']) ? ' '.$_POST['sname_third_emergency_contact'] :'' : '';
|
|
$third_emergencycontact_relationship = $_POST['3_emergencycontact_relationship'];
|
|
$phone_third_emergency_contact = $_POST['phone_third_emergency_contact'];
|
|
|
|
$phone_shipping = fix_dash($phone_shipping);
|
|
if($state_another_person_phone && isset($state_another_person_phone)){
|
|
$state_another_person_phone = fix_dash($state_another_person_phone);}
|
|
if($phone_first_emergency_contact && isset($phone_first_emergency_contact)){
|
|
$phone_first_emergency_contact = fix_dash($phone_first_emergency_contact);}
|
|
if($phone_second_emergency_contact && isset($phone_second_emergency_contact)){
|
|
$phone_second_emergency_contact = fix_dash($phone_second_emergency_contact);}
|
|
if($phone_third_emergency_contact && isset($phone_third_emergency_contact)){
|
|
$phone_third_emergency_contact = fix_dash($phone_third_emergency_contact);}
|
|
|
|
|
|
|
|
|
|
//EmergencyContact
|
|
function createEmergencyContact($FirstName, $LastName, $Phone, $Priority, $Relationship){
|
|
$emergency_contact= array(
|
|
"FirstName"=>$FirstName,
|
|
"LastName"=>$LastName,
|
|
"Phone"=>$Phone,
|
|
"Priority"=>$Priority,
|
|
"Relationship"=>$Relationship);
|
|
|
|
return $emergency_contact;
|
|
}
|
|
|
|
$Emergency_contact[0] = createEmergencyContact($f_n_ec1, $l_n_ec1, $phone_first_emergency_contact, 1, $first_emergencycontact_relationship);
|
|
|
|
if(isset($name_second_emergency_contact) && rtrim($name_second_emergency_contact) != '' && rtrim($name_second_emergency_contact) != '%' && isset($phone_second_emergency_contact) && $phone_second_emergency_contact != ''){
|
|
$Emergency_contact[1] = createEmergencyContact($f_n_ec2, $l_n_ec2, $phone_second_emergency_contact, 2, $second_emergencycontact_relationship);}else{unset($Emergency_contact[1]);}
|
|
|
|
|
|
if(isset($fname_third_emergency_contact) && rtrim($fname_third_emergency_contact) != '' && rtrim($fname_third_emergency_contact) != '%' && isset($phone_third_emergency_contact) && $phone_third_emergency_contact!=''){
|
|
$Emergency_contact[2] = createEmergencyContact($f_n_ec3, $l_n_ec3, $phone_third_emergency_contact, 3, $third_emergencycontact_relationship);}else{unset($Emergency_contact[2]);}
|
|
|
|
/*echo 'name_second_emergency:'; print_r($name_second_emergency_contact);
|
|
echo 'emergency_contact_array:'; print_r($Emergency_contact);*/
|
|
|
|
|
|
//Address
|
|
function createAddress($FirstName, $LastName, $Phone, $Street1, $Street2, $City, $State, $PostalCode, $Country ){
|
|
$address= array(
|
|
"FirstName"=>$FirstName,
|
|
"LastName"=>$LastName,
|
|
"Phone"=>$Phone,
|
|
"Street1"=>$Street1,
|
|
"Street2"=>$Street2,
|
|
"City"=>$City,
|
|
"State"=>$State,
|
|
"PostalCode"=>$PostalCode,
|
|
"Country"=>$Country);
|
|
|
|
return $address;
|
|
}
|
|
$Address = createAddress($FirstName, $LastName, $phone_shipping, $address1_shipping, $address2_shipping, $city_shipping, $state_shipping, $zip_shipping, $country_shipping);
|
|
|
|
//ProductServiceTo
|
|
function createProductServiceTo($Email, $CrossStreet, $DateOfBirth, $Address, $FirstName2, $LastName2){
|
|
|
|
/*if(rtrim($Name2)=='%'){
|
|
$ProductServiceTo= array(
|
|
"Email"=>$Email,
|
|
"CrossStreet"=>$CrossStreet,
|
|
"DateOfBirth"=>$DateOfBirth,
|
|
"Address"=>$Address
|
|
);} else{}*/
|
|
|
|
|
|
$ProductServiceTo= array(
|
|
"Email"=>$Email,
|
|
"CrossStreet"=>$CrossStreet,
|
|
"DateOfBirth"=>$DateOfBirth,
|
|
"Address"=>$Address,
|
|
"FirstName2"=> $FirstName2,
|
|
"LastName2"=> $LastName2
|
|
);
|
|
|
|
return $ProductServiceTo;
|
|
}
|
|
$Product_service = createProductServiceTo($email_shipping, $cross_street, $birth_date, $Address, $FirstName2, $LastName2/*, $another_person_date_of_birth*/);
|
|
|
|
//Profile
|
|
function createProfile($ServiceTo, $EmergencyContact){
|
|
$Profile= array(
|
|
"ServiceTo"=>$ServiceTo,
|
|
"EmergencyContacts"=>$EmergencyContact);
|
|
return $Profile;}
|
|
|
|
$profile = createProfile($Product_service, $Emergency_contact);
|
|
|
|
//RequestHeader
|
|
function createRequestHeader(){
|
|
|
|
$RequestHeader = array(
|
|
|
|
"RequestID" =>"Request_".time()
|
|
|
|
);
|
|
return $RequestHeader;
|
|
|
|
}
|
|
$RequestHeader = createRequestHeader();
|
|
|
|
//ProfileRequest
|
|
function createProfileRequest($RequestedHeader, $RequestBody, $OpportunityID){
|
|
$ProfileRequest = array(
|
|
"RequestHeader"=>$RequestedHeader,
|
|
"RequestBody"=>$RequestBody,
|
|
"OpportunityID"=>$OpportunityID
|
|
|
|
);
|
|
|
|
return $ProfileRequest;
|
|
}
|
|
/*if(!empty($_SESSION['Opportunity_ID_Profile_Page'])){
|
|
$opportunity_id = $_SESSION['Opportunity_ID_Profile_Page'];
|
|
}*/
|
|
$opportunity_id = $_SESSION['Opportunity_ID_Profile_Page'];
|
|
|
|
if($_SESSION['error_counter']<= 5){
|
|
$ProfileRequest= createProfileRequest($RequestHeader, $profile, $opportunity_id);
|
|
$sf=new IperSalseforceSync(IperSalseforceSync::kACTION_PROFILE_CREATE,$ProfileRequest, "POST");
|
|
|
|
$res=json_decode(json_decode($sf->sendRequest()));
|
|
if(isset($res->ResponseBody) && $res->ResponseBody !=''){
|
|
$res_text = 'Success';
|
|
}
|
|
if(!isset($res->ResponseBody) || $res->ResponseBody ==''){
|
|
$res_text = 'Failed';
|
|
}
|
|
/*if(!isset($res->ResponseBody) || $res->ResponseBody =''){
|
|
$res=json_decode(json_decode($sf->sendRequest()));
|
|
}*/}
|
|
|
|
if($_SERVER["REMOTE_ADDR"]=='79.3.196.80'):
|
|
?>
|
|
<?php endif; ?>
|
|
|
|
<?php if($_SESSION['error_counter']<= 5){?>
|
|
|
|
<?php if(is_user_logged_in()) { ?>
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
|
|
<span class="_result"><?php echo $res_text; ?></span>
|
|
<button class="tmp_btn" data-target="#responses2" data-toggle="collapse" data-responses = "<?php echo $res_text; ?>">See the Response</button>
|
|
<div id="responses2" class="collapse">
|
|
<div class="req">
|
|
<h2>Request</h2>
|
|
<?php echo json_encode($ProfileRequest); ?>
|
|
</div>
|
|
<div class="res">
|
|
<h2>Response</h2>
|
|
<?php echo json_encode($res); ?>
|
|
</div>
|
|
</div>
|
|
</div></div></div>
|
|
<?php } ?>
|
|
|
|
|
|
<div class="container">
|
|
<div class="total-page" style="background-image:none !important;/*margin-bottom: 50px;*/ margin-top: 40px;text-shadow: 0 0 5px #000000;">
|
|
<div class="row">
|
|
<div class="col-sm-12">
|
|
<div class="super-title box-border-thumb-bg">
|
|
<!-- <span class="thank-span">Thank you</span> for completing your profile. We are processing your information. -->
|
|
<?php if(is_user_logged_in()){ echo '<span class="response_"></br>Opportunity ID: '.$opportunity_id.'</span>'; }?>
|
|
<?php //echo do_shortcode('[ref]') ?>
|
|
<div class="">
|
|
<h1 class="cblue fs70 text-center" style="margin:0px;"><strong>Thank You</strong></h1>
|
|
<h3 class="cblue fs50 text-center" style="margin:0px;">for completing your profile.</h3>
|
|
<h4 class="cred fs30 text-center">We are processing your request.</h4>
|
|
<br><br><br><br>
|
|
</div>
|
|
</div>
|
|
|
|
</div></div>
|
|
|
|
</div>
|
|
</div>
|
|
<?php } else {?>
|
|
<div class="total-page" style="margin-bottom: 200px; margin-top: 40px;text-shadow: 0 0 4px #000000;">
|
|
<div class="row">
|
|
<div class="col-sm-12">
|
|
<div class="super-title">
|
|
Your <span class="thank-span">order</span> could not be completed at this time. Please contact us at <span><?php echo get_option('assistance_phone'); ?></span> for assistance
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php } ?>
|
|
|
|
<?php
|
|
session_destroy();
|
|
|
|
?>
|
|
|
|
<?php include($ABS_path . "/footer.php");
|
|
get_footer(); ?>
|