php js css php js css

Changes

Changes to Page: membership

218113
Yesterday 10:49pm
Guevarra, Kim
Modified page
220079
Today 2:28am
Guevarra, Kim
Modified page
Event Category:
Id:
/new-site/join-us/membership/
/new-site/join-us/membership/
Title:
Membership
Membership
Content:
<templates:section paddingleft="1rem" paddingright="1rem" paddingTop="6rem" paddingBottom="6rem" bgimage="https://images.unsplash.com/photo-1582274528667-1e8a10ded835?ixid=M3w2ODg1fDB8MXxzZWFyY2h8OXx8YnVzaW5lc3xlbnwwfHx8fDE3NDk2NDA4Njl8MA&" color="#ffffff" bgposition="center" contentsize="sm" style="text-align: center;" bgwashcolor="#000000" bgwashopacity="10" bgcolor="#f9f1e1">
<h1 style="text-align: center;">Become a Member</h1>
</templates:section>
<templates:section paddingTop="4rem" paddingBottom="6rem" paddingleft="1rem" paddingright="1rem" bgimage="" bgcolor="" bgwashcolor="#ffffff" bgwashopacity="80">
<templates:row>
<templates:column width="6">
<h2>Join the community now</h2>
</templates:column>
<templates:column width="6">
<p>
To become a member, all you have to do is sign up and pay a small fee. Your membership begins as soon as you enroll and is good for twelve
months. All membership fees are tax deductible.
</p>
</templates:column>
</templates:row>
<p><br /></p>
<forms:form id="membership_form" recordsubmissions="true" onsubmitredirect="/membership/success/?sale_id=[? $sale_id ?]" onsubmitserver="onFormSubmit($membership_form.getValuesForComponent())" onsubmitemail="info@oncord.com" onsubmitemailsubject="New Membership" contactmode="store">
<ajax:event id="payment_ajaxevent" updateregions="total_paymentmethod_ajaxregion" />
<div class="fieldset">
<h4>Membership</h4>
<forms:row type="one_column" label="">
<forms:radiobuttongroup name="product_id" validations="mandatory">
<data:repeater class="template-productFlexContainer" datasource="\Components\Commerce\Products::getAllForCategoryAndBrand(5, null)" as="product" dataorder="[? [['product_price_base', 'asc']] ?]" datafilter="[? [['product_is_offline', '=', 0]] ?]">
<div class="template-productFlex">
<forms:radiobutton datacolumn="product_id" valuechecked="[? $product['product_id'] ?]" label="" value="" validations="mandatory" onchangeajax="payment_ajaxevent" savestate="true">
<p class="product-price" style="">
[? ' $' + round(\Components\Commerce\Products::getColumn($product['product_id'],'product_price'), 2) ?]
</p>
<small>[? $product['product_title'] ?]</small>
</forms:radiobutton>
</div>
</data:repeater>
</forms:radiobuttongroup>
</forms:row>
</div>
<div class="fieldset">
<h4>Personal Information</h4>
<templates:row>
<templates:column width="6">
<forms:row label="First Name" type="one_column">
<forms:editbox id="contact_first_name" datacolumn="contact_first_name" validations="mandatory" />
</forms:row>
</templates:column>
<templates:column width="6">
<forms:row label="Last Name" type="one_column">
<forms:editbox id="contact_last_name" datacolumn="contact_last_name" validations="mandatory" />
</forms:row>
</templates:column>
</templates:row>
<templates:row>
<templates:column width="6">
<forms:row label="Email Address" type="one_column">
<forms:editbox id="contact_email" datacolumn="contact_email" validations="mandatory,email" transformations="tolower" />
</forms:row>
</templates:column>
<templates:column width="6">
<forms:row label="Password" type="one_column">
<forms:password datacolumn="contact_password" id="contact_password" validations="mandatory" />
</forms:row>
</templates:column>
</templates:row>
<templates:row>
<templates:column width="12">
<forms:row label="Phone" type="one_column">
<forms:editbox id="contact_phone" datacolumn="contact_phone" validations="numeric" />
</forms:row>
</templates:column>
</templates:row>
<forms:address id="contact_address" validations="mandatory" rowtype="one_column" />
</div>
<ajax:region id="total_paymentmethod_ajaxregion">
<!-- If family is selected -->
<logic:if test="$membership_form.getValueForFormItem('product_id') == 308">
<div class="fieldset">
<h4>Family Member(s) Information</h4>
<ajax:event id="counterContactDetails_ajaxevent" updateregions="counterContactDetails_ajaxregion" />
<ajax:region id="counterContactDetails_ajaxregion">
<div style="position: relative;">
<forms:row label="Additional Contacts QTY" class="counter">
<forms:spinbox id="counterContactDetails" valuemin="1" valuemax="5" value="1" onchangeajax="counterContactDetails_ajaxevent" />
</forms:row>
<logic:if test="$counterContactDetails.value > 0">
<data:repeater datasource="createCounter($counterContactDetails.value)" as="item">
<logic:if test="$counterContactDetails.value < 2">
<style> .spinBoxDown {background-color: #efefef !important; pointer-events: none; } </style>
</logic:if>
<logic:if test="$counterContactDetails.value >= 5">
<style> .spinBoxUp {background-color: #efefef !important; pointer-events: none; } </style>
</logic:if>
<forms:form id="additional_contact_partner" datacolumn="additional_contact_partner">
<h5><strong>Family Member #[? $item ?]</strong></h5>
<templates:row>
<templates:column width="6">
<forms:row type="one_column" label="First Name">
<forms:editbox id="ac_first_name_[? $item ?]" datacolumn="contact_first_name" validations="mandatory" />
</forms:row>
</templates:column>
<templates:column width="6">
<forms:row type="one_column" label="Last Name">
<forms:editbox id="ac_last_name_[? $item ?]" datacolumn="contact_last_name" validations="mandatory" />
</forms:row>
</templates:column>
</templates:row>
<forms:row type="one_column" label="E-mail Address">
<forms:editbox id="ac_email_[? $item ?]" datacolumn="contact_email" transformations="tolower" validations="mandatory,email" />
</forms:row>
</forms:form>
</data:repeater>
</logic:if>
</div>
</ajax:region>
</div>
</logic:if>

<logic:if test="$membership_form.getValueForFormItem('product_id')">
<div class="fieldset">
<h4>Payment</h4>
<logic:variable as="product" value="[? \Components\Commerce\Products::get($membership_form.getValueForFormItem('product_id')) ?]" />
<forms:paymentmethod productid="[? $product['product_id'] ?]" completecart="true" recurring="true" recurringamount="[? $product['recurring_sale_amount'] ?]" recurringinterval="[? $product['recurring_sale_schedule_interval'] ?]" recurringintervalnumber="[? $product['recurring_sale_schedule_interval_number'] ?]" showpaymentformonzerovalue="true" />
</div>
</logic:if>
</ajax:region>
</forms:form>
</templates:section>
<templates:section paddingleft="1rem" paddingright="1rem" paddingTop="6rem" paddingBottom="6rem" bgimage="https://images.unsplash.com/photo-1582274528667-1e8a10ded835?ixid=M3w2ODg1fDB8MXxzZWFyY2h8OXx8YnVzaW5lc3xlbnwwfHx8fDE3NDk2NDA4Njl8MA&" color="#ffffff" bgposition="center" contentsize="sm" style="text-align: center;" bgwashcolor="#000000" bgwashopacity="10" bgcolor="#f9f1e1">
<h1 style="text-align: center;">Become a Member</h1>
</templates:section>
<templates:section paddingTop="4rem" paddingBottom="6rem" paddingleft="1rem" paddingright="1rem" bgimage="" bgcolor="" bgwashcolor="#ffffff" bgwashopacity="80">
<templates:row>
<templates:column width="6">
<h2>Join the community now</h2>
</templates:column>
<templates:column width="6">
<p>
To become a member, all you have to do is sign up and pay a small fee. Your membership begins as soon as you enroll and is good for twelve
months. All membership fees are tax deductible.
</p>
</templates:column>
</templates:row>
<p><br /></p>
<forms:form id="membership_form" recordsubmissions="true" onsubmitredirect="/membership/success/?sale_id=[? $sale_id ?]" onsubmitserver="onFormSubmit($membership_form.getValuesForComponent())" onsubmitemail="info@oncord.com" onsubmitemailsubject="New Membership" contactmode="store">
<ajax:event id="payment_ajaxevent" updateregions="total_paymentmethod_ajaxregion" />
<div class="fieldset">
<h4>Membership</h4>
<forms:row type="one_column" label="">
<forms:radiobuttongroup name="product_id" validations="mandatory">
<data:repeater class="template-productFlexContainer" datasource="\Components\Commerce\Products::getAllForCategoryAndBrand(5, null)" as="product" dataorder="[? [['product_price_base', 'asc']] ?]" datafilter="[? [['product_is_offline', '=', 0]] ?]">
<div class="template-productFlex">
<forms:radiobutton datacolumn="product_id" valuechecked="[? $product['product_id'] ?]" label="" value="" validations="mandatory" onchangeajax="payment_ajaxevent" savestate="true">
<p class="product-price" style="">
[? ' $' + round(\Components\Commerce\Products::getColumn($product['product_id'],'product_price'), 2) ?]
</p>
<small>[? $product['product_title'] ?]</small>
</forms:radiobutton>
</div>
</data:repeater>
</forms:radiobuttongroup>
</forms:row>
</div>
<div class="fieldset">
<h4>Personal Information</h4>
<templates:row>
<templates:column width="6">
<forms:row label="First Name" type="one_column">
<forms:editbox id="contact_first_name" datacolumn="contact_first_name" validations="mandatory" />
</forms:row>
</templates:column>
<templates:column width="6">
<forms:row label="Last Name" type="one_column">
<forms:editbox id="contact_last_name" datacolumn="contact_last_name" validations="mandatory" />
</forms:row>
</templates:column>
</templates:row>
<templates:row>
<templates:column width="6">
<forms:row label="Email Address" type="one_column">
<forms:editbox id="contact_email" datacolumn="contact_email" validations="mandatory,email" transformations="tolower" />
</forms:row>
</templates:column>
<templates:column width="6">
<forms:row label="Password" type="one_column">
<forms:password datacolumn="contact_password" id="contact_password" validations="mandatory" />
</forms:row>
</templates:column>
</templates:row>
<templates:row>
<templates:column width="12">
<forms:row label="Phone" type="one_column">
<forms:editbox id="contact_phone" datacolumn="contact_phone" validations="numeric" />
</forms:row>
</templates:column>
</templates:row>
<forms:address id="contact_address" validations="mandatory" rowtype="one_column" />
</div>
<ajax:region id="total_paymentmethod_ajaxregion">
<!-- If family is selected -->
<logic:if test="$membership_form.getValueForFormItem('product_id') == 308">
<div class="fieldset">
<h4>Family Member(s) Information</h4>
<ajax:event id="counterContactDetails_ajaxevent" updateregions="counterContactDetails_ajaxregion" />
<ajax:region id="counterContactDetails_ajaxregion">
<div style="position: relative;">
<forms:row label="Additional Contacts QTY" class="counter">
<forms:spinbox id="counterContactDetails" valuemin="1" valuemax="5" value="1" onchangeajax="counterContactDetails_ajaxevent" />
</forms:row>
<logic:if test="$counterContactDetails.value > 0">
<data:repeater datasource="createCounter($counterContactDetails.value)" as="item">
<logic:if test="$counterContactDetails.value < 2">
<style> .spinBoxDown {background-color: #efefef !important; pointer-events: none; } </style>
</logic:if>
<logic:if test="$counterContactDetails.value >= 5">
<style> .spinBoxUp {background-color: #efefef !important; pointer-events: none; } </style>
</logic:if>
<forms:form id="additional_contact_partner" datacolumn="additional_contact_partner">
<h5><strong>Family Member #[? $item ?]</strong></h5>
<templates:row>
<templates:column width="6">
<forms:row type="one_column" label="First Name">
<forms:editbox id="ac_first_name_[? $item ?]" datacolumn="contact_first_name" validations="mandatory" />
</forms:row>
</templates:column>
<templates:column width="6">
<forms:row type="one_column" label="Last Name">
<forms:editbox id="ac_last_name_[? $item ?]" datacolumn="contact_last_name" validations="mandatory" />
</forms:row>
</templates:column>
</templates:row>
<forms:row type="one_column" label="E-mail Address">
<forms:editbox id="ac_email_[? $item ?]" datacolumn="contact_email" transformations="tolower" validations="mandatory,email" />
</forms:row>
</forms:form>
</data:repeater>
</logic:if>
</div>
</ajax:region>
</div>
</logic:if>

<logic:if test="$membership_form.getValueForFormItem('product_id')">
<div class="fieldset">
<h4>Payment</h4>
<logic:variable as="product" value="[? \Components\Commerce\Products::get($membership_form.getValueForFormItem('product_id')) ?]" />
<forms:paymentmethod productid="[? $product['product_id'] ?]" completecart="true" recurring="true" recurringamount="[? $product['recurring_sale_amount'] ?]" recurringinterval="[? $product['recurring_sale_schedule_interval'] ?]" recurringintervalnumber="[? $product['recurring_sale_schedule_interval_number'] ?]" showpaymentformonzerovalue="true" />
</div>
</logic:if>
</ajax:region>
</forms:form>
</templates:section>
Content Additional:
{"togglable_footerCTA":"on","togglable_memberCTA":null,"togglable_testCTA":null,"togglable_newslettercta":null}
{"togglable_footerCTA":"on","togglable_memberCTA":null,"togglable_testCTA":null,"togglable_newslettercta":null}
Css:
/* --- General Elements --- */
span.template-selectedProduct {}

select {
width: 100% !important;
}

.product-price {
font-size: 1.432rem;
}

/* --- Grid Container --- */
.template-productFlexContainer {
display: grid !important;
align-items: center;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
grid-gap: 1.5rem;
padding: 0;
margin: 0;
}

/* --- Radio Button Group --- */
.s8-radiobuttongroup {
display: block !important;
}

/* --- Product Flex Card --- */
.template-productFlex {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: #333333;
color: #fff;
text-align: center;
min-height: 230px;
padding: 25px;
position: relative;
}

.template-productFlex .s8-radiobutton-container {
opacity: 1 !important;
min-height: unset !important;
min-width: unset !important;
}

.template-productFlex .s8-radiobutton-container,
.template-productFlex input {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 0;
opacity: 0;
}

/* --- Radio Button Appearance --- */
.template-productFlex label.s8-radiobutton-container input ~ .s8-radiobutton {
border: none;
}

label.s8-radiobutton-container input:checked ~ .s8-radiobutton:before {
opacity: 0;
}

.template-productFlex.selected {
background: #d90e30;
}

/* --- Quantity Counter --- */
.counter {
position: absolute;
right: 0;
bottom: -67px;
}

.counter .formRowCol1 {
display: none;
min-width: 100px;
width: auto;
}

.counter .formRowLabel {
color: #989898;
font-size: 2rem;
letter-spacing: 2px;
padding-top: 0.8rem;
text-transform: uppercase;
}

.counter .spinBox > input {
display: none !important;
}

.counter .spinBoxUp,
.counter .spinBoxDown {
background: #720c1c;
color: #fff;
display: inline-block;
width: 2rem;
height: 2rem;
line-height: 2rem;
text-align: center;
position: static;
top: 0;
bottom: 0;
right: 0;
opacity: 1;
}

.counter .spinBoxUp:before,
.counter .spinBoxDown:before {
content: '+';
font-size: 1.2rem;
position: static;
width: 100%;
height: 100%;
left: 0;
top: 0;
border: none;
transform: none;
}

.counter .spinBoxDown:before {
content: '-' !important;
}
/* --- General Elements --- */
span.template-selectedProduct {}

select {
width: 100% !important;
}

.product-price {
font-size: 1.432rem;
}

/* --- Grid Container --- */
.template-productFlexContainer {
display: grid !important;
align-items: center;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
grid-gap: 1.5rem;
padding: 0;
margin: 0;
}

/* --- Radio Button Group --- */
.s8-radiobuttongroup {
display: block !important;
}

/* --- Product Flex Card --- */
.template-productFlex {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: #333333;
color: #fff;
text-align: center;
min-height: 230px;
padding: 25px;
position: relative;
}

.template-productFlex .s8-radiobutton-container {
opacity: 1 !important;
min-height: unset !important;
min-width: unset !important;
}

.template-productFlex .s8-radiobutton-container,
.template-productFlex input {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 0;
opacity: 0;
}

/* --- Radio Button Appearance --- */
.template-productFlex label.s8-radiobutton-container input ~ .s8-radiobutton {
border: none;
}

label.s8-radiobutton-container input:checked ~ .s8-radiobutton:before {
opacity: 0;
}

.template-productFlex.selected {
background: #d90e30;
}

/* --- Quantity Counter --- */
.counter {
position: absolute;
right: 0;
bottom: -67px;
}

.counter .formRowCol1 {
display: none;
min-width: 100px;
width: auto;
}

.counter .formRowLabel {
color: #989898;
font-size: 2rem;
letter-spacing: 2px;
padding-top: 0.8rem;
text-transform: uppercase;
}

.counter .spinBox > input {
display: none !important;
}

.counter .spinBoxUp,
.counter .spinBoxDown {
background: #720c1c;
color: #fff;
display: inline-block;
width: 2rem;
height: 2rem;
line-height: 2rem;
text-align: center;
position: static;
top: 0;
bottom: 0;
right: 0;
opacity: 1;
}

.counter .spinBoxUp:before,
.counter .spinBoxDown:before {
content: '+';
font-size: 1.2rem;
position: static;
width: 100%;
height: 100%;
left: 0;
top: 0;
border: none;
transform: none;
}

.counter .spinBoxDown:before {
content: '-' !important;
}
Js:
document.addEventListener('DOMContentLoaded', function () {
// Select all radio inputs inside .template-productFlex
const productFlexBoxes = document.querySelectorAll('.template-productFlex');

productFlexBoxes.forEach(function (box) {
const radio = box.querySelector('input[type="radio"]');

if (radio) {
// Initial state on load
if (radio.checked) {
box.classList.add('selected');
}

// Listen for changes
radio.addEventListener('change', function () {
// Remove 'selected' from all .template-productFlex elements sharing the same name
const allRadios = document.querySelectorAll(`input[name="${radio.name}"]`);
allRadios.forEach(function (r) {
const parent = r.closest('.template-productFlex');
if (parent) {
parent.classList.remove('selected');
}
});

// Add 'selected' class to the current one
if (radio.checked) {
box.classList.add('selected');
}
});
}
});
});
document.addEventListener('DOMContentLoaded', function () {
// Select all radio inputs inside .template-productFlex
const productFlexBoxes = document.querySelectorAll('.template-productFlex');

productFlexBoxes.forEach(function (box) {
const radio = box.querySelector('input[type="radio"]');

if (radio) {
// Initial state on load
if (radio.checked) {
box.classList.add('selected');
}

// Listen for changes
radio.addEventListener('change', function () {
// Remove 'selected' from all .template-productFlex elements sharing the same name
const allRadios = document.querySelectorAll(`input[name="${radio.name}"]`);
allRadios.forEach(function (r) {
const parent = r.closest('.template-productFlex');
if (parent) {
parent.classList.remove('selected');
}
});

// Add 'selected' class to the current one
if (radio.checked) {
box.classList.add('selected');
}
});
}
});
});
Php Source:
<?php

function onFormSubmit($arrValues)
{
$arrContact['contact_first_name'] = $arrValues['contact_first_name'];
$arrContact['contact_last_name'] = $arrValues['contact_last_name'];
$arrContact['contact_email'] = $arrValues['contact_email'];
$arrContact['contact_password'] = $arrValues['contact_password'];

// save first contact
$iContactId = \Components\Customers\Contacts::save($arrContact);
\Components\Customers\Contacts::currentLoginViaContactId($iContactId);

if ($arrValues['product_id'] == 308)
{
$i = 1;
$strFormName = 'additional_contact_family_' . $i;
while (isset($arrValues[$strFormName]))
{
$arrFamilyContact = $arrValues[$strFormName];
$strRelationship = $arrFamilyContact['relationship_type_id'];
varDump($arrFamilyContact);
unset($arrFamilyContact['relationship_type_id']);
$iFamilyContactId = \Components\Customers\Contacts::save($arrFamilyContact);

if ($iFamilyContactId)
{
\Components\Customers\Contacts\Relationships::create($iContactId, $iFamilyContactId, $strRelationship);
}
$i++;
$strFormName = 'additional_contact_family_' . $i;
}
}
}

function createCounter($last)
{
return range(1, $last);
}

function updatePreferencesOnSubmit($arrValues, $iContactId = NULL)
{
if(!$iContactId)
{
$iContactId = \Components\Customers\Contacts::currentContactId(true);
}
}

function getRelationshipCategory($strType1, $strType2)
{
if($strType1 == 'Individual' && $strType2 == 'Individual')
{
return 'I2I';
}

if($strType1 == 'Individual' && $strType2 == 'Company')
{
return 'I2C';
}

if($strType1 == 'Company' && in_array($strType2, ['Individual', '']))
{
return 'I2C';
}

if($strType1 == 'Company' && $strType2 == 'Company')
{
return 'C2C';
}

return 'I2I';
}

function getContactType($arrContact)
{
if(!is_array($arrContact))
{
$arrContact = \Components\Customers\Contacts::get($arrContact);
}

if(isset($arrContact['contact_type']))
{
return $arrContact['contact_type'];
}

return null;
}

function renderRelationship($arrContact1, $arrContact2, $strRelationshipType)
{
if(!is_array($arrContact1))
{
$arrContact1 = \Components\Customers\Contacts::get($arrContact1);
}

if(!is_array($arrContact2))
{
$arrContact2 = \Components\Customers\Contacts::get($arrContact2);
}

$strContact1Name = \Components\Customers\Contacts::renderName($arrContact1);
$strContact2Name = \Components\Customers\Contacts::renderName($arrContact2);

$strRelationshipTitle = \Components\Customers\Contacts\Relationships\Types::getColumn($strRelationshipType, 'relationship_type_title');

if(strpos($strRelationshipType, "I2C") === 0 && $arrContact1['contact_type'] == 'Company')
{
return $strContact2Name . ' is ' . $strRelationshipTitle . ' of &nbsp;' . $strContact1Name;
}

return $strContact1Name . ' is ' . $strRelationshipTitle . ' of &nbsp;' . $strContact2Name;
}

function getRelationshipTypes($iContactId1, $arrContact2)
{
$strRelationshipCategory = getRelationshipCategory(getContactType($iContactId1), getContactType($arrContact2));

$arrRelationshipTypes = \Components\Customers\Contacts\Relationships\Types::getAllForRelationshipCategory($strRelationshipCategory);

foreach ($arrRelationshipTypes as &$arrRelationshipType)
{
$arrRelationshipType['relationship_type_title'] = renderRelationship($arrContact2, $iContactId1, $arrRelationshipType['relationship_type_id']);
}

//varDump($arrRelationshipTypes);
return $arrRelationshipTypes;
}

function createRelationship($arrValues)
{
foreach($arrValues as $strField => $strValue)
{
if(str_starts_with($strField, 'contact_'))
{
$arrContact[$strField] = $arrValues[$strField];
}
}

// Try to auto merge the contact with an existing one
\Components\Customers\Contacts::autoMerge($arrContact);

$iContactId1 = $arrContact['contact_id'];
$iContactId2 = \Components\Customers\Contacts::currentContactId(true);


$arrRelationship = [];
$arrRelationship['relationship_type_id'] = 'I2I_Partner';
$arrRelationship['contact_id_1'] = $iContactId1;
$arrRelationship['contact_id_2'] = $iContactId2;
$arrRelationship['contact1_can_edit_contact2'] = 1;
$arrRelationship['contact2_can_edit_contact1'] = 0;

\Components\Customers\Contacts\Relationships::save($arrRelationship);
}

?>
<?php

function onFormSubmit($arrValues)
{
$arrContact['contact_first_name'] = $arrValues['contact_first_name'];
$arrContact['contact_last_name'] = $arrValues['contact_last_name'];
$arrContact['contact_email'] = $arrValues['contact_email'];
$arrContact['contact_password'] = $arrValues['contact_password'];

// save first contact
$iContactId = \Components\Customers\Contacts::save($arrContact);
\Components\Customers\Contacts::currentLoginViaContactId($iContactId);

if ($arrValues['product_id'] == 308)
{
$i = 1;
$strFormName = 'additional_contact_family_' . $i;
while (isset($arrValues[$strFormName]))
{
$arrFamilyContact = $arrValues[$strFormName];
$strRelationship = $arrFamilyContact['relationship_type_id'];
varDump($arrFamilyContact);
unset($arrFamilyContact['relationship_type_id']);
$iFamilyContactId = \Components\Customers\Contacts::save($arrFamilyContact);

if ($iFamilyContactId)
{
\Components\Customers\Contacts\Relationships::create($iContactId, $iFamilyContactId, $strRelationship);
}
$i++;
$strFormName = 'additional_contact_family_' . $i;
}
}
}

function createCounter($last)
{
return range(1, $last);
}

function updatePreferencesOnSubmit($arrValues, $iContactId = NULL)
{
if(!$iContactId)
{
$iContactId = \Components\Customers\Contacts::currentContactId(true);
}
}

function getRelationshipCategory($strType1, $strType2)
{
if($strType1 == 'Individual' && $strType2 == 'Individual')
{
return 'I2I';
}

if($strType1 == 'Individual' && $strType2 == 'Company')
{
return 'I2C';
}

if($strType1 == 'Company' && in_array($strType2, ['Individual', '']))
{
return 'I2C';
}

if($strType1 == 'Company' && $strType2 == 'Company')
{
return 'C2C';
}

return 'I2I';
}

function getContactType($arrContact)
{
if(!is_array($arrContact))
{
$arrContact = \Components\Customers\Contacts::get($arrContact);
}

if(isset($arrContact['contact_type']))
{
return $arrContact['contact_type'];
}

return null;
}

function renderRelationship($arrContact1, $arrContact2, $strRelationshipType)
{
if(!is_array($arrContact1))
{
$arrContact1 = \Components\Customers\Contacts::get($arrContact1);
}

if(!is_array($arrContact2))
{
$arrContact2 = \Components\Customers\Contacts::get($arrContact2);
}

$strContact1Name = \Components\Customers\Contacts::renderName($arrContact1);
$strContact2Name = \Components\Customers\Contacts::renderName($arrContact2);

$strRelationshipTitle = \Components\Customers\Contacts\Relationships\Types::getColumn($strRelationshipType, 'relationship_type_title');

if(strpos($strRelationshipType, "I2C") === 0 && $arrContact1['contact_type'] == 'Company')
{
return $strContact2Name . ' is ' . $strRelationshipTitle . ' of &nbsp;' . $strContact1Name;
}

return $strContact1Name . ' is ' . $strRelationshipTitle . ' of &nbsp;' . $strContact2Name;
}

function getRelationshipTypes($iContactId1, $arrContact2)
{
$strRelationshipCategory = getRelationshipCategory(getContactType($iContactId1), getContactType($arrContact2));

$arrRelationshipTypes = \Components\Customers\Contacts\Relationships\Types::getAllForRelationshipCategory($strRelationshipCategory);

foreach ($arrRelationshipTypes as &$arrRelationshipType)
{
$arrRelationshipType['relationship_type_title'] = renderRelationship($arrContact2, $iContactId1, $arrRelationshipType['relationship_type_id']);
}

//varDump($arrRelationshipTypes);
return $arrRelationshipTypes;
}

function createRelationship($arrValues)
{
foreach($arrValues as $strField => $strValue)
{
if(str_starts_with($strField, 'contact_'))
{
$arrContact[$strField] = $arrValues[$strField];
}
}

// Try to auto merge the contact with an existing one
\Components\Customers\Contacts::autoMerge($arrContact);

$iContactId1 = $arrContact['contact_id'];
$iContactId2 = \Components\Customers\Contacts::currentContactId(true);


$arrRelationship = [];
$arrRelationship['relationship_type_id'] = 'I2I_Partner';
$arrRelationship['contact_id_1'] = $iContactId1;
$arrRelationship['contact_id_2'] = $iContactId2;
$arrRelationship['contact1_can_edit_contact2'] = 1;
$arrRelationship['contact2_can_edit_contact1'] = 0;

\Components\Customers\Contacts\Relationships::save($arrRelationship);
}

?>
Accept Child 404:
0
0
Search Title:

															

														
Search Title Prefix:

															

														
Search Description:

															

														
Search Keywords:

															

														
Search Noindex:
0
0
Search Nofollow:
0
0
Search Change Frequency:

															

														
Search Priority:
0.5
0.5
Search Canonical Override:

															

														
Is Offline:
0
0
Is Hidden In Navigation:
0
0
Is Hidden In Sitemap:
0
0
Security New:
0
0
Security Contact Mode:

															

														
Security Contact Squeeze Viewlimit:

															

														
Security Contact Require Login:

															

														
Security Contact Groups:

															

														
Security Condition Id:

															

														
Security Heading:

															

														
Security Description:

															

														
Other Fields:

															

														
Order:
0
0
Parent Id:
/new-site/join-us/
/new-site/join-us/
Contact Id:
0
0
Design Id:
16
16
Header Functions:

															

														
Header Category:

															

														
Is Domain:
0
0
Post Category Id: