Example #1
0
function post_to_third_party($entry, $form)
{
    $first_id = null;
    $last_id = null;
    $email_id = null;
    $phone_id = null;
    $comment_id = null;
    $firm_id = null;
    $address_id = null;
    $city_id = null;
    $state_id = null;
    $zip_id = null;
    $builders_id = array();
    $price_range_id = null;
    $sqft_id = null;
    // Get Field IDs
    foreach ($form['fields'] as $form_items) {
        if ($form_items['label'] === 'First Name' || strpos($form_items['defaultValue'], 'First Name') !== FALSE) {
            $first_id = $form_items['id'];
        } else {
            if ($form_items['label'] === 'Last Name' || strpos($form_items['defaultValue'], 'Last Name') !== FALSE) {
                $last_id = $form_items['id'];
            } else {
                if ($form_items['label'] === 'Email' || strpos($form_items['defaultValue'], 'Email') !== FALSE) {
                    $email_id = $form_items['id'];
                } else {
                    if ($form_items['label'] === 'Phone' || strpos($form_items['defaultValue'], 'Phone') !== FALSE) {
                        $phone_id = $form_items['id'];
                    } else {
                        if ($form_items['label'] === 'Comment' || strpos($form_items['defaultValue'], 'Comment') !== FALSE) {
                            $comment_id = $form_items['id'];
                        } else {
                            if ($form_items['label'] === 'Brokerage Firm' || strpos($form_items['defaultValue'], 'Brokerage Firm') !== FALSE) {
                                $firm_id = $form_items['id'];
                            } else {
                                if ($form_items['label'] === 'Address' || strpos($form_items['defaultValue'], 'Address') !== FALSE) {
                                    foreach ($form_items['inputs'] as $form_item) {
                                        if ($form_item['label'] === 'Street Address' || strpos($form_items['defaultValue'], 'Street Address') !== FALSE) {
                                            $address_id = $form_item['id'];
                                        } else {
                                            if ($form_item['label'] === 'State / Province' || strpos($form_items['defaultValue'], 'State / Province') !== FALSE) {
                                                $state_id = $form_item['id'];
                                            } else {
                                                if ($form_item['label'] === 'City' || strpos($form_items['defaultValue'], 'City') !== FALSE) {
                                                    $city_id = $form_item['id'];
                                                } else {
                                                    if ($form_item['label'] === 'ZIP / Postal Code' || strpos($form_items['defaultValue'], 'ZIP / Postal Code') !== FALSE) {
                                                        $zip_id = $form_item['id'];
                                                    }
                                                }
                                            }
                                        }
                                    }
                                } else {
                                    if (is_array($form_items['inputs'])) {
                                        foreach ($form_items['inputs'] as $form_item) {
                                            $builders_id[] = $form_item['id'];
                                        }
                                    } else {
                                        if ($form_items['label'] === 'Builder' || strpos($form_items['defaultValue'], 'Builder') !== FALSE) {
                                            $builders_id = $form_items['id'];
                                        } else {
                                            if ($form_items['label'] === 'Desired Price Range' || strpos($form_items['defaultValue'], 'Desired Price Range') !== FALSE) {
                                                $price_range_id = $form_items['id'];
                                            } else {
                                                if ($form_items['label'] === 'Desired Square Footage' || strpos($form_items['defaultValue'], 'Desired Square Footage') !== FALSE) {
                                                    $sqft_id = $form_items['id'];
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $first = $first_id ? $entry[$first_id] : null;
    $last = $last_id ? $entry[$last_id] : null;
    $email = $email_id ? $entry[$email_id] : null;
    $phone = $phone_id ? $entry[$phone_id] : null;
    $comment = $comment_id ? $entry[$comment_id] : null;
    $firm = $firm_id ? $entry[$firm_id] : null;
    $address = isset($entry[strval($address_id)]) ? $entry[strval($address_id)] : null;
    $city = isset($entry[strval($city_id)]) ? $entry[strval($city_id)] : null;
    $state = isset($entry[strval($state_id)]) ? $entry[strval($state_id)] : null;
    $zip = isset($entry[strval($zip_id)]) ? $entry[strval($zip_id)] : null;
    $builder = isset($entry[strval($builders_id)]) ? $entry[strval($builders_id)] : null;
    $price_range = isset($entry[strval($price_range_id)]) ? $entry[strval($price_range_id)] : null;
    $sqft = isset($entry[strval($sqft_id)]) ? $entry[strval($sqft_id)] : null;
    if ($builder === 'all') {
        $builders = array('beazer homes', 'kb home', 'pardee homes', 'toll brothers');
    } else {
        $builders = array();
        foreach ($builders_id as $builder) {
            $curBuilder = str_replace('  ', ' ', strtolower($entry[$builder]));
            if ($curBuilder !== '') {
                if (strpos($curBuilder, 'beazer') !== false) {
                    $curBuilder = 'beazer homes';
                } else {
                    if (strpos($curBuilder, 'kb') !== false) {
                        $curBuilder = 'kb home';
                    } else {
                        if (strpos($curBuilder, 'pardee') !== false) {
                            $curBuilder = 'pardee homes';
                        } else {
                            if (strpos($curBuilder, 'toll') !== false) {
                                $curBuilder = 'toll brothers';
                            }
                        }
                    }
                }
                $builders[] = $curBuilder;
            }
        }
    }
    save_to_admin($first, $last, $email, $phone, $comment, $firm, $address, $city, $state, $zip, json_encode($builders), $price_range, $sqft);
    return;
}
Example #2
0
function post_to_third_party($entry, $form)
{
    $first_id = null;
    $last_id = null;
    $email_id = null;
    $phone_id = null;
    $comment_id = null;
    $firm_id = null;
    $address_id = null;
    $city_id = null;
    $state_id = null;
    $zip_id = null;
    $builders_id = array();
    // Get Field IDs
    foreach ($form['fields'] as $form_items) {
        if ($form_items['label'] === 'First Name') {
            $first_id = $form_items['id'];
        } else {
            if ($form_items['label'] === 'Last Name') {
                $last_id = $form_items['id'];
            } else {
                if ($form_items['label'] === 'Email') {
                    $email_id = $form_items['id'];
                } else {
                    if ($form_items['label'] === 'Phone') {
                        $phone_id = $form_items['id'];
                    } else {
                        if ($form_items['label'] === 'Comment') {
                            $comment_id = $form_items['id'];
                        } else {
                            if ($form_items['label'] === 'Brokerage Firm') {
                                $firm_id = $form_items['id'];
                            } else {
                                if ($form_items['label'] === 'Address') {
                                    foreach ($form_items['inputs'] as $form_item) {
                                        print_r($form_item);
                                        if ($form_item['label'] === 'Street Address') {
                                            $address_id = $form_item['id'];
                                        } else {
                                            if ($form_item['label'] === 'State / Province') {
                                                $state_id = $form_item['id'];
                                            } else {
                                                if ($form_item['label'] === 'City') {
                                                    $city_id = $form_item['id'];
                                                } else {
                                                    if ($form_item['label'] === 'ZIP / Postal Code') {
                                                        $zip_id = $form_item['id'];
                                                    }
                                                }
                                            }
                                        }
                                    }
                                } else {
                                    if (is_array($form_items['inputs'])) {
                                        foreach ($form_items['inputs'] as $form_item) {
                                            $builders_id[] = $form_item['id'];
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $first = $first_id ? $entry[$first_id] : null;
    $last = $last_id ? $entry[$last_id] : null;
    $email = $email_id ? $entry[$email_id] : null;
    $phone = $phone_id ? $entry[$phone_id] : null;
    $comment = $comment_id ? $entry[$comment_id] : null;
    $firm = $firm_id ? $entry[$firm_id] : null;
    $address = isset($entry[strval($address_id)]) ? $entry[strval($address_id)] : null;
    $city = isset($entry[strval($city_id)]) ? $entry[strval($city_id)] : null;
    $state = isset($entry[strval($state_id)]) ? $entry[strval($state_id)] : null;
    $zip = isset($entry[strval($zip_id)]) ? $entry[strval($zip_id)] : null;
    $builders = array();
    print_r($state_id);
    foreach ($builders_id as $builder) {
        $curBuilder = str_replace('  ', ' ', strtolower($entry[$builder]));
        if ($curBuilder !== '') {
            $builders[] = $curBuilder;
        }
    }
    save_to_admin($first, $last, $email, $phone, $comment, $firm, $address, $city, $state, $zip, json_encode($builders));
    return;
}