"getAllStatesByCountryId", "countryId" =>$countryId, "apiKey" => APPTIVO_API_KEY, "accessKey" => APPTIVO_ACCESS_KEY ); $response = getRestAPICall1( 'POST', $api_url, $params ); return $response->responseObject; } /* * Lead configData */ function getleadConfigData(){ $api_url = APPTIVO_API_URL . 'app/dao/v6/leads'; $params = array ( "a" => "getConfigData", "apiKey" => APPTIVO_API_KEY, "accessKey" =>APPTIVO_ACCESS_KEY ); $response = getRestAPICall1( 'POST', $api_url, $params ); return $response; } function createContact($customerName, $customerId, $fullName, $firstName, $lastName, $email, $phone, $countryText, $countryId, $coutryCode,$assigneeName,$assigneeId){ $countryText = $countryText; $countryId = $countryId; $coutryCode =$coutryCode; // $state = ($state) ? $state : ""; // $stateCode = ($stateCode) ? $stateCode : ""; $firstname = $firstName; $lastname = $lastName; $fullname = $firstName . ' ' . $lastName; $email = $email; $phone = $phone; $address =$address; //$address1 = ($address1) ? $address1 : ""; $city = $city; $accountname =$customerName; $accountId =$customerId; $contactJson = new stdClass (); $contactJson->firstName = $firstname; $contactJson->lastName = $lastname; $contactJson->accountName = $customerName; $contactJson->accountId = $customerId; //$assignee = getAssigneeDetails (); $contactJson->assigneeObjectRefName = $assigneeName; $contactJson->assigneeObjectRefId = $assigneeId; $contactJson->assigneeObjectId = "8"; $contactJson->phoneNumbers = array (); $pNumber = new stdClass (); if ($phone != '') { $pNumber->phoneNumber = $phone; $pNumber->phoneType = "Business"; $pNumber->phoneTypeCode = "PHONE_BUSINESS"; $pNumber->id = "contact_phone_input"; $contactJson->phoneNumbers [] = $pNumber; } $contactJson->emailAddresses = array (); $emailAddr = new stdClass (); if ($email != '') { $emailAddr->emailAddress = $email; $emailAddr->emailTypeCode = "BUSINESS"; $emailAddr->emailType = "Business"; $emailAddr->id = "cont_email_input"; $contactJson->emailAddresses [] = $emailAddr; } $contactJson->addresses = array(); $contaddr = new stdClass(); if($countryText != ''){ $contaddr->addressAttributeId="address_section_attr_id"; $contaddr->countryId=$countryId; $contaddr->addressTypeCode="1"; $contaddr->addressType="Billing Address"; $contaddr->addressLine1=$address; $contaddr->addressLine2=$address1; $contaddr->city=$city; $contaddr->state=$state; $contaddr->stateCode=$stateCode; $contaddr->zipCode=$zipCode; $contaddr->county=""; $contaddr->country=$countryText; $contaddr->countryName=$countryText; $contaddr->countryCode=$coutryCode; $contaddr->deliveryInstructions=null; $contaddr->addressGroupName="Address1"; $contactJson->addresses[] = $contaddr; } $contactJson->customAttributes = $customAttributes; $contactJson = json_encode ( $contactJson ); $api_url = APPTIVO_API_URL . 'app/dao/v6/contacts'; $params = array ( "a" => "save", "contactData" => $contactJson, "apiKey" => APPTIVO_API_KEY, "accessKey" => APPTIVO_ACCESS_KEY ); $response = getRestAPICall1 ( 'POST', $api_url, $params ); return $response; } /* check customer existing */ function checkIsexistingCustomer($fullName){ $api_url = APPTIVO_API_URL . 'app/dao/customer'; $params = array ( "a" => "configurationCustomerDetails", "customerName" => $fullName, "customerNumber" => "Auto generated number", "objectId" => 3, "apiKey" => APPTIVO_API_KEY, "accessKey" => APPTIVO_ACCESS_KEY ); $response = getRestAPICall1 ( 'POST', $api_url, $params ); return $response; } function createCustomer($fullName, $firstname, $lastname, $email, $phone,$company,$countryText, $countryId, $coutryCode,$assigneeName,$assigneeId){ //$countryText = $_POST['countryText']; //$countryId = $_POST['countryId']; //$coutryCode = $_POST['countryCode']; $firstname = $firstName; $lastname = $lastName; $fullname = $fullName; $email = $email; //$phone = $_POST ['phone']; //$address = $_POST['address']; //$city = $_POST['city']; //$description = $_POST['description']; $customerJson = new stdClass (); $customerJson->customerName = $company; //$customerJson->firstname= $firstname; //$customerJson->lastname= $lastname; //$assignee = getAssigneeDetails(); $customerJson->assigneeObjectRefName = $assigneeName; $customerJson->assigneeObjectRefId = $assigneeId; $customerJson->assigneeObjectId = "8"; $customerJson->emailAddresses = array (); $emailAddr = new stdClass (); if ($email != '') { $emailAddr->emailAddress = $email; $emailAddr->emailTypeCode = "BUSINESS"; $emailAddr->emailType = "Business"; $emailAddr->id = "cont_email_input"; $customerJson->emailAddresses [] = $emailAddr; } $customerJson->phoneNumbers = array (); $pNumber = new stdClass (); if ($phone != '') { $pNumber->phoneNumber = $phone; $pNumber->phoneType = "Business"; $pNumber->phoneTypeCode = "PHONE_BUSINESS"; $pNumber->id = "contact_phone_input"; $customerJson->phoneNumbers [] = $pNumber; } $customerJson = json_encode ( $customerJson ); $api_url = APPTIVO_API_URL . 'app/dao/v6/customers'; $params = array ( "a" => "save", "customerData" => $customerJson, "apiKey" => APPTIVO_API_KEY, "accessKey" => APPTIVO_ACCESS_KEY ); $response = getRestAPICall1 ( 'POST', $api_url, $params ); return $response; } //add_action ( 'wp_ajax_createLead', 'createLead' ); //add_action ( 'wp_ajax_nopriv_createLead', 'createLead' ); function createLead(){ $countryText = $_POST['countryText']; $countryId = $_POST['countryId']; $coutryCode = $_POST['coutryCode']; $firstName = $_POST['firstname']; $lastName = $_POST['lastname']; $email = $_POST['email']; $phone = $_POST['phone']; $address1 = $_POST['addr1']; $address2 = $_POST['addr2']; $city = $_POST['city']; $state = $_POST['stateText']; $stateCode = $_POST['stateVal']; $zipCode = $_POST['zipCode']; $description = $_POST['aboutus']; $brokerLicense = $_POST['brokerLicense']; $loanAmt = $_POST['loanAmt']; $propTypeText = $_POST['proptypetxt']; $propTypeVal = $_POST['propTypeVal']; $loanTypeText = $_POST['loanType']; $loanTypeVal = $_POST['loanTypeVal']; $ltv = $_POST['ltv']; $plpurPrice = $_POST['purPrice']; $pldpAmt=$_POST['dpAmt']; $plantiClosedate=$_POST['antiClosedate']; $plExstatFrLoan=$_POST['ExstatFrLoan']; $plCOAmt=$_POST['COAmt']; if(isset($_POST['optionsRadios']) && $_POST['optionsRadios'] != ''){ $plpurchaseoptions=$_POST['optionsRadios']; } $exitstrateRefin=$_POST['exitstrateRefin']; $COAmtRefin=$_POST['COAmtRefin']; if(isset($_POST['optionsRadiosRefin']) && $_POST['optionsRadiosRefin'] != ''){ $refinoptions=$_POST['optionsRadiosRefin']; } $budgetAmt=$_POST['budgetAmt']; $EstAfterRepairVal=$_POST['EstAfterRepairVal']; $ExitStratLoanRehab=$_POST['ExitStratLoanRehab']; $COAmtRehap=$_POST['COAmtRehap']; if(isset($_POST['optionsRadiosRehab']) && $_POST['optionsRadiosRehab'] != ''){ $optionsRadiosRehab=$_POST['optionsRadiosRehab']; } $ExitstratLoanOther=$_POST['ExitstratLoanOther']; $COAmtOther=$_POST['COAmtOther']; if(isset($_POST['optionsRadiosOther']) && $_POST['optionsRadiosOther'] != ''){ $optionsRadiosOther=$_POST['optionsRadiosOther']; } $empname = $_POST['loanOfficerText']; $empid = $_POST['loanOfficerVal']; $leadSource = $_POST['leadSource']; $leadSourceCode = $_POST['leadSourceId']; $leadStatus = "New"; $leadSource = $leadSource; $currencyCode = 'USD'; $customerName = $_POST['customerName']; $customerId= $_POST['customerId']; $contactId= $_POST['contactId']; $contactName= $_POST['contactName']; if( $plpurchaseoptions == 'Yes' || $refinoptions == 'Yes' || $optionsRadiosRehab == 'Yes' || $optionsRadiosOther == 'Yes'){ $loanOfficer = $empname; if($empid == 'team'){ $loanOfficer = "Sales Team"; } } else{ $loanOfficer = "Sales Team"; } $fieldArr = array('Lead Information'=>array("First Name"=>$firstName,"Last Name"=>$lastName,"Lead Status"=>$leadStatus,"Lead Source"=>$leadSource,"Loan Officer"=>$loanOfficer,"Broker License"=>$brokerLicense, "Loan Amount"=>$loanAmt,"Estimated Value or LTV (Loan to Value)"=>$ltv,"Property Type"=>$propTypeText,"Loan Type"=>$loanTypeText), 'Contact Information'=>array('Phone'=>$phone,'Email'=>$email), 'Purchase Loan'=>array("Purchase Price"=>$plpurPrice,'Down Payment Amount'=>$pldpAmt,'Anticipated Closing Date'=>$plantiClosedate,'Exit Strategy From Loan'=>$plExstatFrLoan,'Cash Out Amount'=>$plCOAmt,'Have You Been in Contact With a Rodeo Capital Agent?'=>$plpurchaseoptions), 'Refinance Loan'=>array('Exit Strategy From Loan'=>$exitstrateRefin,'Cash Out Amount'=>$COAmtRefin,'Have You Been in Contact With a Rodeo Capital Agent?'=>$refinoptions), 'Rehab or Construction Completion'=>array('Budget Amount'=>$budgetAmt,'Estimated After Repair Value'=>$EstAfterRepairVal,'Exit Strategy From Loan'=>$ExitStratLoanRehab,'Cash Out Amount'=>$COAmtRehap,'Have You Been in Contact With a Rodeo Capital Agent?'=>$optionsRadiosRehab), 'Other Loan'=>array('Exit Strategy From Loan'=>$ExitstratLoanOther,'Cash Out Amount'=>$COAmtOther,'Have You Been in Contact With a Rodeo Capital Agent?'=>$optionsRadiosOther) ); $leadSources =getLeadSource(); $config = new configData(); $sections = $config->appConfigData(APPTIVO_LEAD_API,LEAD_OBJECT_ID); //$retrivalKey = new DataRetrieval(); //$sections = $retrivalKey->dataRetrieval($sections,$fieldArr); $customAttributes = array(); foreach ( $sections as $section ) { $sectionName = $section->getSecLabel(); $sectionName = str_replace('/'," ",$sectionName); if(array_key_exists($sectionName, $fieldArr)){ $attributes = $section->getAttributeList(); foreach ( $attributes as $attribute ) { $labelName = $attribute->getAttributeLabel(); $fieldType = $attribute->getAttributeType(); if(array_key_exists($labelName, $fieldArr[$sectionName])){ if($fieldType == 'Custom'){ $dataRetriObj = new DataRetrieval(); $cust = $dataRetriObj->customAttribute($customAttributes,$sectionName,$labelName,$attribute, $fieldArr); if(!empty($cust)){ $customAttributes[] = $cust; } } /*if($fieldType == 'Standard'){ $std = $dataRetriObj->standardAttribute($fieldArr[$sectionName][$labelName],$sectionName,$labelName,$attribute,$fieldArr); }*/ } } } } $dataRetriObj->customAttributes = $customAttributes; $leadJson = new stdClass(); $leadJson->firstName = $firstName; $leadJson->lastName = $lastName; //$leadJson->wayToContact = $wayTocontact; //$leadJson->easyWayToContact = $easyWayToContact; $leadJson->leadStatus = 1; $leadJson->leadStatusMeaning = "New"; $leadJson->leadSource = $leadSourceCode; $leadJson->leadSourceMeaning = $leadSource; $leadJson->accountId = $customerId; $leadJson->accountName=$customerName; $leadJson->potentialAmount = $loanAmt; if( $plpurchaseoptions == 'Yes' || $refinoptions == 'Yes' || $optionsRadiosRehab == 'Yes' || $optionsRadiosOther == 'Yes'){ $leadJson->assigneeObjectRefName = $empname; $leadJson->assigneeObjectRefId = $empid; $leadJson->assigneeObjectId = "8"; if($empid == 'team'){ $leadJson->assigneeObjectRefName = "Sales Team"; $leadJson->assigneeObjectRefId = 10852; $leadJson->assigneeObjectId = "91"; } } else{ $leadJson->assigneeObjectRefName = "Sales Team"; $leadJson->assigneeObjectRefId = 10852; $leadJson->assigneeObjectId = "91"; } /* Test Firm // $assignee = getAssigneeDetails(); $empname = $_POST['loanOfficerText']; $empid = $_POST['loanOfficerVal']; if( $plpurchaseoptions == 'Yes' || $refinoptions == 'Yes' || $optionsRadiosRehab == 'Yes' || $optionsRadiosOther == 'Yes'){ $leadJson->assigneeObjectRefName = $empname; $leadJson->assigneeObjectRefId = $empid; $leadJson->assigneeObjectId = "8"; } else{ $leadJson->assigneeObjectRefName = "Loan Officer"; $leadJson->assigneeObjectRefId = 10903; $leadJson->assigneeObjectId = "91"; }*/ /* if($empid == 'team'){ $leadJson->assigneeObjectRefName = "Loan Officer"; $leadJson->assigneeObjectRefId = 10903; $leadJson->assigneeObjectId = "8"; $leadJson->referredById = 10903; $leadJson->referredByName = "Loan Officer"; }else{ $leadJson->assigneeObjectRefName = $empname; $leadJson->assigneeObjectRefId = $empid; $leadJson->assigneeObjectId = "8"; $leadJson->referredById = $empid; $leadJson->referredByName =$empname; } */ $leadJson->description = $description; $phoneNumbers = array(); $pNum = new stdClass(); if($phone != ''){ $pNum->phoneNumber=$phone; $pNum->phoneType="Mobile"; $pNum->phoneTypeCode="PHONE_MOBILE"; $pNum->id="lead_phone_input"; $leadJson->phoneNumbers[] = $pNum; } $leadJson->emailAddresses = array(); $eAddr = new stdClass(); if($email != ''){ $eAddr->emailAddress=$email; $eAddr->emailTypeCode="HOME"; $eAddr->emailType="Home"; $eAddr->id="cont_email_input"; $leadJson->emailAddresses[] = $eAddr; } $leadJson->addresses = array(); $laddr = new stdClass(); if($countryText != ''){ $laddr->addressAttributeId="apptivo_attribute_addressAttributeId_1497532375088_898_1278181497532375088_86"; $laddr->countryId=$countryId; $laddr->addressTypeCode="1"; $laddr->addressType="Property Address"; $laddr->addressLine1=$address1; $laddr->addressLine2=$address2; $laddr->city=$city; $laddr->state=$state; $laddr->stateCode=$stateCode; $laddr->zipCode=$zipCode; $laddr->county=""; $laddr->country=$countryText; $laddr->countryName=$countryText; $laddr->countryCode=$coutryCode; $laddr->deliveryInstructions=null; $laddr->addressGroupName="Address1"; $leadJson->addresses[] = $laddr; } $leadJson->customAttributes = $customAttributes; $leadResponse = createLeadcall(json_encode($leadJson)); $leadId = $leadResponse->lead->leadId; if(isset($_FILES['uploadfile']) && !empty($_FILES['uploadfile']) && $leadId!=''){ foreach($_FILES['uploadfile']['tmp_name'] as $key => $tmp_name) { $file_name = $_FILES['uploadfile']['name'][$key]; $file_size =$_FILES['uploadfile']['size'][$key]; $file_tmp =$_FILES['uploadfile']['tmp_name'][$key]; //$file_type=$_FILES['uploadfile']['type'][$key]; $file_ext = strtolower ( end ( explode ( '.', $file_name ) ) ); $data = file_get_contents ( $file_tmp ); $base64 = base64_encode ( $data ); uploadDocument1($leadId,$file_name,$file_ext,$file_size,$base64); } } print_r(json_encode($leadResponse)); exit; } /** * Generating the json for custom attributes based on that * @param unknown_type $attrId * @param unknown_type $tagName * @param unknown_type $attrtype * @param unknown_type $attrVal * @param unknown_type $attrValId * @param unknown_type $tagId * @param unknown_type $currencyCode */ function customAttrJson($attrId,$tagName,$attrtype,$attrVal,$attrValId,$tagId,$currencyCode){ $customArr = array(); if($attrtype == 'number'){ $customArr['customAttributeId']=$attrId; $customArr['customAttributeValue']=$attrVal; $customArr['customAttributeType']="number"; $customArr['customAttributeTagName']=$tagName; $customArr['customAttributeName']=$tagName; $customArr[$tagName]=$attrVal; $customArr['numberValue'] = $attrVal; return $customArr; } else if($attrtype == 'currency'){ $customArr['customAttributeId']=$attrId; $customArr['customAttributeValue']=$attrVal; $customArr['customAttributeType']="currency"; $customArr['customAttributeTagName']=$tagName; $customArr['customAttributeName']=$tagName; $customArr[$tagName]=$attrVal; $customArr['currencyCode'] = $currencyCode; return $customArr; } else if($attrtype == 'input'){ $customArr['customAttributeId']=$attrId; $customArr['customAttributeValue']=$attrVal; $customArr['customAttributeType']="input"; $customArr['customAttributeTagName']=$tagName; $customArr['customAttributeName']=$tagName; $customArr[$tagName]=$attrVal; return $customArr; } else if($attrtype == 'date'){ $customArr['customAttributeId']=$attrId; $customArr['customAttributeValue']=$attrVal; $customArr['customAttributeType']="date"; $customArr['customAttributeTagName']=$tagName; $customArr['customAttributeName']=$tagName; $customArr[$tagName]=$attrVal; return $customArr; } else if($attrtype == 'select'){ $customArr['customAttributeId']=$attrId; $customArr['customAttributeValue']=$attrVal; $customArr['customAttributeType']=$attrtype; $customArr['customAttributeTagName']=$tagName; $customArr['customAttributeName']=$tagName; $customArr[$tagName]=$attrVal; $customArr['customAttributeValueId'] = $attrValId; return $customArr; } else if($attrtype == 'radio'){ $customArr['customAttributeId']=$attrId; $customArr['customAttributeValue']=$attrVal; $customArr['customAttributeType']="radio"; $customArr['customAttributeTagName']=$tagName; $customArr['customAttributeName']=$tagName; $attrValues = array(); $attributes = new stdClass(); $attributes->attributeId = $tagId; $attributes->attributeValue = $attrVal; $attributes->shape = ""; $attributes->color = ""; $attrValues[] = $attributes; $customArr['attributeValues'] = $attrValues; $customArr['customAttributeValueId'] = $tagId; $customArr[$tagName] = $attrVal; $customArr['color'] = "" ; $customArr['shape'] = "" ; return $customArr; } } function customAttrSearchJson($attrId,$tagName,$attrtype,$attrVal,$attrValId,$tagId,$currencyCode){ $customArr = array(); if($attrtype == 'check'){ $customArr['customAttributeId']=$attrId; $customArr['customAttributeValue']=$attrVal; $customArr['customAttributeType']="check"; $customArr['customAttributeTagName']=$tagName; $customArr['customAttributeName']=$tagName; $attrValues = array(); $attributes = new stdClass(); $attributes->attributeId = $tagId; $attributes->attributeValue = $attrVal; $attrValues[] = $attributes; $customArr['attributeValues'] = $attrValues; return $customArr; } } function getAllProjects($acountId,$customerName){ $api_url = APPTIVO_API_URL . 'app/dao/v6/projects'; $params = array ( "a" => "getAllByAdvancedSearch", "startIndex"=>0, "numRecords"=>50, "searchData"=>'{"customerName": "'.$customerName.'","customerId": '.$acountId.'}', "apiKey" => APPTIVO_API_KEY, "accessKey" =>APPTIVO_ACCESS_KEY ); //print_r($params); $response = getRestAPICall1( 'POST', $api_url, $params ); return $response; } /* * create lead in apptivo */ function createLeadcall($leadJson){ $api_url = APPTIVO_API_URL . 'app/dao/v6/leads'; $params = array ( "a" => "save", "leadData"=>$leadJson, "apiKey" => APPTIVO_API_KEY, "accessKey" =>APPTIVO_ACCESS_KEY ); //print_r($params); $response = getRestAPICall1( 'POST', $api_url, $params ); return $response; } /* * Opportunity ConfigData */ function getOppConfigData() { $api_url = APPTIVO_API_URL . 'app/dao/v6/opportunities'; $params = array ( "a" => "getConfigData", "apiKey" => APPTIVO_API_KEY, "accessKey" => APPTIVO_ACCESS_KEY ); $response = getRestAPICall1 ( 'POST', $api_url, $params ); return $response; } /* * Opportunity ConfigData */ function getPropertyConfigData() { $api_url = APPTIVO_API_URL . 'app/dao/v6/properties'; $params = array ( "a" => "getConfigData", "apiKey" => APPTIVO_API_KEY, "accessKey" => APPTIVO_ACCESS_KEY ); $response = getRestAPICall1 ( 'POST', $api_url, $params ); return $response; } /* * getProjectById */ function getProjectById($projectId) { $api_url = APPTIVO_API_URL . 'app/dao/v6/projects'; $params = array ( "a" => "getById", "projectId" => $projectId, "includeBudget"=>"true", "includeMilestones"=>"true", "includeSubProjects"=>"true", "apiKey" => APPTIVO_API_KEY, "accessKey" => APPTIVO_ACCESS_KEY ); $response = getRestAPICall1( "POST", $api_url, $params ); return $response; } /* * Projects getAllDocumentsByObjectIdObjectRefId */ function getAllProjectDocuments($projectId) { $api_url = APPTIVO_API_URL . 'app/dao/document'; $params = array ( "a" => "getAllDocumentsByObjectIdObjectRefId", "iDisplayStart" => 0, "numRecords" => 50, "objRefId" => $projectId, "objectId" => 88, "apiKey" => APPTIVO_API_KEY, "accessKey" => APPTIVO_ACCESS_KEY ); $response = getRestAPICall1( "POST", $api_url, $params ); return $response; } /* * getAllOpportunityNotes */ function getAllProjectNotes($projectId) { $api_url = APPTIVO_API_URL . 'app/dao/note'; $params = array ( "a" => "getNotes", "isFrom" => "App", "noteData" => '{}', "selectedObjectId" => 88, "selectedObjectRefId" => $projectId, "startIndex" => 0, "numRecords" => 10, "apiKey" => APPTIVO_API_KEY, "accessKey" => APPTIVO_ACCESS_KEY ); $response = getRestAPICall1( 'POST', $api_url, $params ); return $response; } /* * Download URL */ function get_download_url($id) { $api_url = APPTIVO_API_URL . 'app/dao/document'; $params = array ( "a" => "getDocumentDownloadUrl", "id" => $id, "apiKey" => APPTIVO_API_KEY, "accessKey" => APPTIVO_ACCESS_KEY ); $response = getRestAPICall1( 'POST', $api_url, $params ); return $response; } /* * Create Opportunity */ //add_action ( 'wp_ajax_createOpportunity', 'createOpportunity' ); //add_action ( 'wp_ajax_nopriv_createOpportunity', 'createOpportunity' ); function createOpportunity(){ $countryText = $_POST['countryText']; $countryId = $_POST['countryId']; $coutryCode = $_POST['coutryCode']; $firstName = $_POST['firstName']; $lastName = $_POST['lastName']; $email = $_POST['email']; $phone = $_POST['phone']; $address1 = $_POST['addr1']; $address2 = $_POST['addr2']; $city = $_POST['city']; $state = $_POST['statetxt']; $stateCode = $_POST['state']; $zipCode = $_POST['zipCode']; $description = $_POST['aboutus']; $customerId = $_POST['customerId']; $customerName = $_POST['customerName']; $contactId = $_POST['contactId']; $contactName = $_POST['contactName']; $brokerLicense = $_POST['brokerLicense']; $loanAmt = $_POST['loanAmt']; $propTypeText = $_POST['proptypetxt']; $propTypeVal = $_POST['propType']; $loanTypeText = $_POST['loantypetxt']; $loanTypeVal = $_POST['loanType']; $ltv = $_POST['ltv']; $plpurPrice = $_POST['purPrice']; $pldpAmt=$_POST['dpAmt']; $plantiClosedate=$_POST['antiClosedate']; $plExstatFrLoan=$_POST['ExstatFrLoan']; $plCOAmt=$_POST['COAmt']; $plpurchaseoptions=$_POST['optionsRadios']; $exitstrateRefin=$_POST['exitstrateRefin']; $COAmtRefin=$_POST['COAmtRefin']; $refinoptions=$_POST['optionsRadiosRefin']; $budgetAmt=$_POST['budgetAmt']; $EstAfterRepairVal=$_POST['EstAfterRepairVal']; $ExitStratLoanRehab=$_POST['ExitStratLoanRehab']; $COAmtRehap=$_POST['COAmtRehap']; $optionsRadiosRehab=$_POST['optionsRadiosRehab']; $ExitstratLoanOther=$_POST['ExitstratLoanOther']; $COAmtOther=$_POST['COAmtOther']; $optionsRadiosOther=$_POST['optionsRadiosOther']; $empname = $_POST['emptxt']; $empid = $_POST['loanOff_name']; $leadconfigData = getOppConfigData(); $phTypes = $leadconfigData->phoneTypes; foreach($phTypes as $ptype){ if($ptype->code == 'PHONE_HOME'){ $phoneId = $ptype->id; } } $leadWeblayout = json_decode ( $leadconfigData->webLayout ); foreach ( $leadWeblayout->sections as $section ) { foreach ( $section->attributes as $attribute ) { if(isset($attribute->addressList)){ foreach($attribute->addressList as $addrField){ $addressAttributeId = $addrField->addressAttributeId; } } if(($attribute->attributeTag) == 'phone'){ $phoneattributeId = $attribute->attributeId; } if ($attribute->label->modifiedLabel != '') { if ($attribute->label->modifiedLabel == 'First Name') { $fnamecustomAttributeId = $attribute->attributeId; $fnamecustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Last Name') { $lnamecustomAttributeId = $attribute->attributeId; $lnamecustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Broker License') { $brokerLicencecustomAttributeId = $attribute->attributeId; $brokerLicencecustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Loan Amount') { $loanAmtcustomAttributeId = $attribute->attributeId; $loanAmtcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Estimated Value or LTV (Loan to Value)') { $ltvcustomAttributeId = $attribute->attributeId; $ltvcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Property Type') { $propTypecustomAttributeId = $attribute->attributeId; $propTypecustomAttributeTagName = $attribute->right [0]->tagName; $propTypeOpts = $attribute->right [0]->optionValueList; foreach ( $propTypeOpts as $options ) { if (trim(strtoupper($options->optionObject)) == trim(strtoupper($propTypeText))) { $propTypeValue = $options->optionObject; $propTypeValueId = $options->optionId; } } } if ($attribute->label->modifiedLabel == 'Loan Type') { $loanTypecustomAttributeId = $attribute->attributeId; $loanTypecustomAttributeTagName = $attribute->right [0]->tagName; $loanTypeOpts = $attribute->right [0]->optionValueList; foreach ( $loanTypeOpts as $options ) { if (trim(strtoupper($options->optionObject)) == trim(strtoupper($loanTypeText))) { $loanTypeValue = $options->optionObject; $loanTypeValueId = $options->optionId; } } } /*Purchase Loan section */ if($section->label == 'Purchase Loan'){ if ($attribute->label->modifiedLabel == 'Purchase Price') { $plpurchasePricecustomAttributeId = $attribute->attributeId; $plpurchasePricecustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Down Payment Amount') { $pldpAmtcustomAttributeId = $attribute->attributeId; $pldpAmtcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Anticipated Closing Date') { $plantiClosedatecustomAttributeId = $attribute->attributeId; $plantiClosedatecustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Exit Strategy From Loan') { $plexitstartpurchcustomAttributeId = $attribute->attributeId; $plexitstartpurchcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Cash Out Amount') { $plcmAmtcustomAttributeId = $attribute->attributeId; $plcmAmtcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Have You Been in Contact With a Rodeo Capital Agent?') { $plrodCapAgentcustomAttributeId = $attribute->attributeId; $plrodCapAgentcustomAttributeTagName = $attribute->right [0]->tagName; foreach($attribute->right as $rightarr){ if($rightarr->options[0] == $plpurchaseoptions){ $plrodCapAgentcustomAttributeTagId = $rightarr->tagId; } } } } /*Refinance*/ if($section->label == 'Refinance Loan'){ if ($attribute->label->modifiedLabel == 'Exit Strategy From Loan') { $refineexitstartpurchcustomAttributeId = $attribute->attributeId; $refineexitstartpurchcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Cash Out Amount') { $refinecmAmtcustomAttributeId = $attribute->attributeId; $refinecmAmtcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Have You Been in Contact With a Rodeo Capital Agent?') { $refinerodCapAgentcustomAttributeId = $attribute->attributeId; $refinerodCapAgentcustomAttributeTagName = $attribute->right [0]->tagName; foreach($attribute->right as $rightarr){ if($rightarr->options[0] == $refinoptions){ $refinerodCapAgentcustomAttributeTagId = $rightarr->tagId; } } } } /*Rehab */ if($section->label == 'Rehab / Construction Completion'){ if ($attribute->label->modifiedLabel == 'Budget Amount') { $rehabudgetAmtcustomAttributeId = $attribute->attributeId; $rehabudgetAmtcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Estimated After Repair Value') { $rehabeAfterrepairValcustomAttributeId = $attribute->attributeId; $rehabeAfterrepairValcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Exit Strategy From Loan') { $rehabexitstartpurchcustomAttributeId = $attribute->attributeId; $rehabexitstartpurchcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Cash Out Amount') { $rehabcmAmtcustomAttributeId = $attribute->attributeId; $rehabcmAmtcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Have You Been in Contact With a Rodeo Capital Agent?') { $rehabrodCapAgentcustomAttributeId = $attribute->attributeId; $rehabrodCapAgentcustomAttributeTagName = $attribute->right [0]->tagName; foreach($attribute->right as $rightarr){ if($rightarr->options[0] == $optionsRadiosRehab){ $rehabrodCapAgentcustomAttributeTagId = $rightarr->tagId; } } } } /* Other */ if($section->label == 'Other Loan'){ if ($attribute->label->modifiedLabel == 'Exit Strategy From Loan') { $otherexitstartpurchcustomAttributeId = $attribute->attributeId; $othereexitstartpurchcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Cash Out Amount') { $othercmAmtcustomAttributeId = $attribute->attributeId; $othercmAmtcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Have You Been in Contact With a Rodeo Capital Agent?') { $otherrodCapAgentcustomAttributeId = $attribute->attributeId; $otherrodCapAgentcustomAttributeTagName = $attribute->right [0]->tagName; foreach($attribute->right as $rightarr){ if($rightarr->options[0] == $optionsRadiosOther){ $otherrodCapAgentcustomAttributeTagId = $rightarr->tagId; } } } } } } } $opportunityJson = new stdClass (); if($address2 != ''){ $opportunityName = $address1.",".$address2.",".$city.",".$state.",".$zipCode; } else{ $opportunityName = $address1.",".$city.",".$state.",".$zipCode; } $opportunityJson->opportunityName = $opportunityName; $opportunityJson->salesStageName = "Prospecting"; $opportunityJson->salesStageId = 170459; $opportunityJson->salesCycleName = "Default Sales Stages"; $opportunityJson->salesCycleId = 1; $opportunityJson->closeDate = "29/05/2017"; $opportunityJson->description = $description; $opportunityJson->probability = "5.00"; if($empid == 'team'){ $opportunityJson->assigneeObjectRefName = "Loan Officer"; $opportunityJson->assigneeObjectRefId = 10903; $opportunityJson->assigneeObjectId = "8"; }else{ $opportunityJson->assigneeObjectRefName = $empname; $opportunityJson->assigneeObjectRefId = $empid; $opportunityJson->assigneeObjectId = "8"; } if($contactId != '' && $customerId !=''){ $opportunityJson->opportunityContactId = $contactId; $opportunityJson->opportunityContact = $contactName; } if (! empty ( $customerName ) || ! empty ( $customerId )) { $opportunityJson->opportunityCustomer = $customerName; $opportunityJson->opportunityCustomerId = $customerId; } $opportunityJson->amount = $loanAmt; $opportunityJson->addresses = array(); $laddr = new stdClass(); if($countryText != ''){ $laddr->addressAttributeId=$addressAttributeId; $laddr->addressType="Billing Address"; $laddr->addressTypeCode="1"; $laddr->addressLine1=$address1; $laddr->addressLine2=$address2; $laddr->city=$city; $laddr->state=$state; $laddr->stateCode=$stateCode; $laddr->countryId=$countryId; $laddr->country=$countryText; $laddr->countryName=$countryText; $laddr->countryCode=$coutryCode; $laddr->zipCode=$zipCode; $laddr->county=""; $laddr->addressGroupName="Address1"; $opportunityJson->addresses[] = $laddr; } $opportunityJson->phoneNumbers = array(); $phoneObj = new stdClass(); if($phone != ''){ $phoneObj->id = $phoneattributeId; $phoneObj->attributeId = $phoneattributeId; $phoneObj->phoneType = "Home"; $phoneObj->phoneTypeCode = "PHONE_HOME"; $selectedPhoneTypeObj = new stdClass(); $selectedPhoneTypeObj->id = $phoneId; $selectedPhoneTypeObj->code = "PHONE_HOME"; $selectedPhoneTypeObj->name = "Home"; $selectedPhoneTypeObj->description = "Home phone number"; $selectedPhoneTypeObj->isEnabled = "Y"; $selectedPhoneTypeObj->isSmsEnabled = "N"; $phoneObj->selectedPhoneType = $selectedPhoneTypeObj; $phoneObj->phoneNumber = $phone; $opportunityJson->phoneNumbers[] = $phoneObj; } $customAttributes = array(); $brokerlicArr = array(); if($brokerlicArr != ''){ $brokerlicArr['customAttributeId']=$brokerLicencecustomAttributeId; $brokerlicArr['customAttributeValue']=$brokerLicense; $brokerlicArr['customAttributeType']="number"; $brokerlicArr['customAttributeTagName']=$brokerLicencecustomAttributeTagName; $brokerlicArr['customAttributeName']=$brokerLicencecustomAttributeTagName; $brokerlicArr[$brokerLicencecustomAttributeTagName]=$brokerLicense; $brokerlicArr['numberValue'] = $brokerLicense; $customAttributes[] = $brokerlicArr; } $propertyTypeArr = array(); if($propTypeText != '' && $propTypeVal){ $propertyTypeArr['customAttributeId']=$propTypecustomAttributeId; $propertyTypeArr['customAttributeValue']=$propTypeValue; $propertyTypeArr['customAttributeType']="select"; $propertyTypeArr['customAttributeTagName']=$propTypecustomAttributeTagName; $propertyTypeArr['customAttributeName']=$propTypecustomAttributeTagName; $propertyTypeArr[$propTypecustomAttributeTagName]=$propTypeValue; $propertyTypeArr['customAttributeValueId'] = $propTypeValueId; $customAttributes[] = $propertyTypeArr; } $ltvArr = array(); if($ltv != ''){ $ltvArr['customAttributeId']=$ltvcustomAttributeId; $ltvArr['customAttributeValue']=$ltv; $ltvArr['customAttributeType']="currency"; $ltvArr['customAttributeTagName']=$ltvcustomAttributeTagName; $ltvArr['customAttributeName']=$ltvcustomAttributeTagName; $ltvArr[$ltvcustomAttributeTagName]=$ltv; $ltvArr['currencyCode'] = "AUD"; $customAttributes[] = $ltvArr; } $loanTypeArr = array(); if($loanTypeText != '' && $loanTypeVal){ $loanTypeArr['customAttributeId']=$loanTypecustomAttributeId; $loanTypeArr['customAttributeValue']=$loanTypeValue; $loanTypeArr['customAttributeType']="select"; $loanTypeArr['customAttributeTagName']=$loanTypecustomAttributeTagName; $loanTypeArr['customAttributeName']=$loanTypecustomAttributeTagName; $loanTypeArr[$loanTypecustomAttributeTagName]=$loanTypeValue; $loanTypeArr['customAttributeValueId'] = $loanTypeValueId; $customAttributes[] = $loanTypeArr; } /* purchase */ $plpurPriceArr = array(); if($plpurPrice != ''){ $plpurPriceArr['customAttributeId']=$plpurchasePricecustomAttributeId; $plpurPriceArr['customAttributeValue']=$plpurPrice; $plpurPriceArr['customAttributeType']="currency"; $plpurPriceArr['customAttributeTagName']=$plpurchasePricecustomAttributeTagName; $plpurPriceArr['customAttributeName']=$plpurchasePricecustomAttributeTagName; $plpurPriceArr[$plpurchasePricecustomAttributeTagName]=$plpurPrice; $plpurPriceArr['currencyCode'] = "AUD"; $customAttributes[] = $plpurPriceArr; } $pldpAmtArr = array(); if($pldpAmt != ''){ $pldpAmtArr['customAttributeId']=$pldpAmtcustomAttributeId; $pldpAmtArr['customAttributeValue']=$pldpAmt; $pldpAmtArr['customAttributeType']="currency"; $pldpAmtArr['customAttributeTagName']=$pldpAmtcustomAttributeTagName; $pldpAmtArr['customAttributeName']=$pldpAmtcustomAttributeTagName; $pldpAmtArr[$pldpAmtcustomAttributeTagName]=$pldpAmt; $pldpAmtArr['currencyCode'] = "AUD"; $customAttributes[] = $pldpAmtArr; } $plcloseDateArr = array(); if($plantiClosedate != ''){ $plcloseDateArr['customAttributeId']=$plantiClosedatecustomAttributeId; $plcloseDateArr['customAttributeValue']=$plantiClosedate; $plcloseDateArr['customAttributeType']="date"; $plcloseDateArr['customAttributeTagName']=$plantiClosedatecustomAttributeTagName; $plcloseDateArr['customAttributeName']=$plantiClosedatecustomAttributeTagName; $plcloseDateArr[$plantiClosedatecustomAttributeTagName]=$plantiClosedate; $customAttributes[] = $plcloseDateArr; } $fnameArr= array(); if($firstName != ''){ $fnameArr['customAttributeId']=$fnamecustomAttributeId; $fnameArr['customAttributeValue']=$firstName; $fnameArr['customAttributeType']="input"; $fnameArr['customAttributeTagName']=$fnamecustomAttributeTagName; $fnameArr['customAttributeName']=$fnamecustomAttributeTagName; $fnameArr[$fnamecustomAttributeTagName]=$firstName; $customAttributes[] = $fnameArr; } $lnameArr= array(); if($lastName != ''){ $lnameArr['customAttributeId']=$lnamecustomAttributeId; $lnameArr['customAttributeValue']=$lastName; $lnameArr['customAttributeType']="input"; $lnameArr['customAttributeTagName']=$lnamecustomAttributeTagName; $lnameArr['customAttributeName']=$lnamecustomAttributeTagName; $lnameArr[$lnamecustomAttributeTagName]=$lastName; $customAttributes[] = $lnameArr; } $plExstatFrLoanArr = array(); if($plExstatFrLoan != ''){ $plExstatFrLoanArr['customAttributeId']=$plexitstartpurchcustomAttributeId; $plExstatFrLoanArr['customAttributeValue']=$plExstatFrLoan; $plExstatFrLoanArr['customAttributeType']="input"; $plExstatFrLoanArr['customAttributeTagName']=$plexitstartpurchcustomAttributeTagName; $plExstatFrLoanArr['customAttributeName']=$plexitstartpurchcustomAttributeTagName; $plExstatFrLoanArr[$plexitstartpurchcustomAttributeTagName]=$plExstatFrLoan; $customAttributes[] = $plExstatFrLoanArr; } $plCOAmtArr= array(); if($plCOAmt != ''){ $plCOAmtArr['customAttributeId']=$plcmAmtcustomAttributeId; $plCOAmtArr['customAttributeValue']=$plCOAmt; $plCOAmtArr['customAttributeType']="currency"; $plCOAmtArr['customAttributeTagName']=$plcmAmtcustomAttributeTagName; $plCOAmtArr['customAttributeName']=$plcmAmtcustomAttributeTagName; $plCOAmtArr[$plcmAmtcustomAttributeTagName]=$plCOAmt; $plCOAmtArr['currencyCode'] = "AUD"; $customAttributes[] = $plCOAmtArr; } $plpurchaseoptionsArr= array(); if($plpurchaseoptions != ''){ $plpurchaseoptionsArr['customAttributeId']=$plrodCapAgentcustomAttributeId; $plpurchaseoptionsArr['customAttributeValue']=$plpurchaseoptions; $plpurchaseoptionsArr['customAttributeType']="radio"; $plpurchaseoptionsArr['customAttributeTagName']=$plrodCapAgentcustomAttributeTagName; $plpurchaseoptionsArr['customAttributeName']=$plrodCapAgentcustomAttributeTagName; $attrValues = array(); $attributes = new stdClass(); $attributes->attributeId = $plrodCapAgentcustomAttributeTagId; $attributes->attributeValue = $plpurchaseoptions; $attributes->shape = ""; $attributes->color = ""; $attrValues[] = $attributes; $plpurchaseoptionsArr['attributeValues'] = $attrValues; $plpurchaseoptionsArr['customAttributeValueId'] = $plrodCapAgentcustomAttributeTagId; $plpurchaseoptionsArr[$plrodCapAgentcustomAttributeTagName] = $plpurchaseoptions; $plpurchaseoptionsArr['color'] = "" ; $plpurchaseoptionsArr['shape'] = "" ; $customAttributes[] = $plpurchaseoptionsArr; } /*refinance */ $exitstrateRefinArr = array(); if($exitstrateRefin != ''){ $exitstrateRefinArr['customAttributeId']=$refineexitstartpurchcustomAttributeId; $exitstrateRefinArr['customAttributeValue']=$exitstrateRefin; $exitstrateRefinArr['customAttributeType']="input"; $exitstrateRefinArr['customAttributeTagName']=$refineexitstartpurchcustomAttributeTagName; $exitstrateRefinArr['customAttributeName']=$refineexitstartpurchcustomAttributeTagName; $exitstrateRefinArr[$refineexitstartpurchcustomAttributeTagName]=$exitstrateRefin; $customAttributes[] = $exitstrateRefinArr; } $COAmtRefinArr = array(); if($COAmtRefin != ''){ $COAmtRefinArr['customAttributeId']=$refinecmAmtcustomAttributeId; $COAmtRefinArr['customAttributeValue']=$COAmtRefin; $COAmtRefinArr['customAttributeType']="currency"; $COAmtRefinArr['customAttributeTagName']=$refinecmAmtcustomAttributeTagName; $COAmtRefinArr['customAttributeName']=$refinecmAmtcustomAttributeTagName; $COAmtRefinArr[$refinecmAmtcustomAttributeTagName]=$COAmtRefin; $COAmtRefinArr['currencyCode'] = "AUD"; $customAttributes[] = $COAmtRefinArr; } $refinoptionsArr= array(); if($refinoptions != ''){ $refinoptionsArr['customAttributeId']=$refinerodCapAgentcustomAttributeId; $refinoptionsArr['customAttributeValue']=$refinoptions; $refinoptionsArr['customAttributeType']="radio"; $refinoptionsArr['customAttributeTagName']=$refinerodCapAgentcustomAttributeTagName; $refinoptionsArr['customAttributeName']=$refinerodCapAgentcustomAttributeTagName; $refineattrValues = array(); $refattributes = new stdClass(); $refattributes->attributeId = $refinerodCapAgentcustomAttributeTagId; $refattributes->attributeValue = $refinoptions; $refattributes->shape = ""; $refattributes->color = ""; $refineattrValues[] = $refattributes; $refinoptionsArr['attributeValues'] = $refineattrValues; $refinoptionsArr['customAttributeValueId'] = $refinerodCapAgentcustomAttributeTagId; $refinoptionsArr[$refinerodCapAgentcustomAttributeTagName] = $refinoptions; $refinoptionsArr['color'] = "" ; $refinoptionsArr['shape'] = "" ; $customAttributes[] = $refinoptionsArr; } /*rehab*/ $budgetAmtArr = array(); if($budgetAmt != ''){ $budgetAmtArr['customAttributeId']=$rehabudgetAmtcustomAttributeId; $budgetAmtArr['customAttributeValue']=$budgetAmt; $budgetAmtArr['customAttributeType']="currency"; $budgetAmtArr['customAttributeTagName']=$rehabudgetAmtcustomAttributeTagName; $budgetAmtArr['customAttributeName']=$rehabudgetAmtcustomAttributeTagName; $budgetAmtArr[$rehabudgetAmtcustomAttributeTagName]=$budgetAmt; $budgetAmtArr['currencyCode'] = "AUD"; $customAttributes[] = $budgetAmtArr; } $EstAfterRepairValArr = array(); if($EstAfterRepairVal != ''){ $EstAfterRepairValArr['customAttributeId'] = $rehabeAfterrepairValcustomAttributeId; $EstAfterRepairValArr['customAttributeValue']=$EstAfterRepairVal; $EstAfterRepairValArr['customAttributeType']="currency"; $EstAfterRepairValArr['customAttributeTagName']=$rehabeAfterrepairValcustomAttributeTagName; $EstAfterRepairValArr['customAttributeName']=$rehabeAfterrepairValcustomAttributeTagName; $EstAfterRepairValArr[$rehabeAfterrepairValcustomAttributeTagName]=$EstAfterRepairVal; $EstAfterRepairValArr['currencyCode'] = "AUD"; $customAttributes[] = $EstAfterRepairValArr; } $exitStratLoanRehabArr = array(); if($ExitStratLoanRehab != ''){ $exitStratLoanRehabArr['customAttributeId']=$rehabexitstartpurchcustomAttributeId; $exitStratLoanRehabArr['customAttributeValue']=$ExitStratLoanRehab; $exitStratLoanRehabArr['customAttributeType']="input"; $exitStratLoanRehabArr['customAttributeTagName']=$rehabexitstartpurchcustomAttributeTagName; $exitStratLoanRehabArr['customAttributeName']=$rehabexitstartpurchcustomAttributeTagName; $exitStratLoanRehabArr[$rehabexitstartpurchcustomAttributeTagName]=$ExitStratLoanRehab; $customAttributes[] = $exitStratLoanRehabArr; } $COAmtRehabArr = array(); if($COAmtRehap != ''){ $COAmtRehabArr['customAttributeId']=$rehabcmAmtcustomAttributeId; $COAmtRehabArr['customAttributeValue']=$COAmtRehap; $COAmtRehabArr['customAttributeType']="currency"; $COAmtRehabArr['customAttributeTagName']=$rehabcmAmtcustomAttributeTagName; $COAmtRehabArr['customAttributeName']=$rehabcmAmtcustomAttributeTagName; $COAmtRehabArr[$rehabcmAmtcustomAttributeTagName]=$COAmtRehap; $COAmtRehabArr['currencyCode'] = "AUD"; $customAttributes[] = $COAmtRehabArr; } $rehaboptionsArr= array(); if($optionsRadiosRehab != ''){ $rehaboptionsArr['customAttributeId']=$rehabrodCapAgentcustomAttributeId; $rehaboptionsArr['customAttributeValue']=$optionsRadiosRehab; $rehaboptionsArr['customAttributeType']="radio"; $rehaboptionsArr['customAttributeTagName']=$rehabrodCapAgentcustomAttributeTagName; $rehaboptionsArr['customAttributeName']=$rehabrodCapAgentcustomAttributeTagName; $rehabattrValues = array(); $rehabattributes = new stdClass(); $rehabattributes->attributeId = $rehabrodCapAgentcustomAttributeTagId; $rehabattributes->attributeValue = $optionsRadiosRehab; $rehabattributes->shape = ""; $rehabattributes->color = ""; $rehabattrValues[] = $rehabattributes; $rehaboptionsArr['attributeValues'] = $rehabattrValues; $rehaboptionsArr['customAttributeValueId'] = $rehabrodCapAgentcustomAttributeTagId; $rehaboptionsArr[$rehabrodCapAgentcustomAttributeTagName] = $optionsRadiosRehab; $rehaboptionsArr['color'] = "" ; $rehaboptionsArr['shape'] = "" ; $customAttributes[] = $rehaboptionsArr; } /*Other*/ $exitStratLoanOtherArr = array(); if($ExitstratLoanOther != ''){ $exitStratLoanOtherArr['customAttributeId']=$otherexitstartpurchcustomAttributeId; $exitStratLoanOtherArr['customAttributeValue']=$ExitstratLoanOther; $exitStratLoanOtherArr['customAttributeType']="input"; $exitStratLoanOtherArr['customAttributeTagName']=$othereexitstartpurchcustomAttributeTagName; $exitStratLoanOtherArr['customAttributeName']=$othereexitstartpurchcustomAttributeTagName; $exitStratLoanOtherArr[$othereexitstartpurchcustomAttributeTagName]=$ExitstratLoanOther; $customAttributes[] = $exitStratLoanOtherArr; } $COAmtOtherArr = array(); if($COAmtOther != ''){ $COAmtOtherArr['customAttributeId']=$othercmAmtcustomAttributeId; $COAmtOtherArr['customAttributeValue']=$COAmtOther; $COAmtOtherArr['customAttributeType']="currency"; $COAmtOtherArr['customAttributeTagName']=$othercmAmtcustomAttributeTagName; $COAmtOtherArr['customAttributeName']=$othercmAmtcustomAttributeTagName; $COAmtOtherArr[$othercmAmtcustomAttributeTagName]=$COAmtOther; $COAmtOtherArr['currencyCode'] = "AUD"; $customAttributes[] = $COAmtOtherArr; } $otheroptionsArr= array(); if($optionsRadiosOther != ''){ $otheroptionsArr['customAttributeId']=$otherrodCapAgentcustomAttributeId; $otheroptionsArr['customAttributeValue']=$optionsRadiosOther; $otheroptionsArr['customAttributeType']="radio"; $otheroptionsArr['customAttributeTagName']=$otherrodCapAgentcustomAttributeTagName; $otheroptionsArr['customAttributeName']=$otherrodCapAgentcustomAttributeTagName; $otherattrValues = array(); $otherattributes = new stdClass(); $otherattributes->attributeId = $rehabrodCapAgentcustomAttributeTagId; $otherattributes->attributeValue = $optionsRadiosOther; $otherattributes->shape = ""; $otherattributes->color = ""; $otherattrValues[] = $otherattributes; $otheroptionsArr['attributeValues'] = $otherattrValues; $otheroptionsArr['customAttributeValueId'] = $otherrodCapAgentcustomAttributeTagId; $otheroptionsArr[$otherrodCapAgentcustomAttributeTagName] = $optionsRadiosOther; $otheroptionsArr['color'] = "" ; $otheroptionsArr['shape'] = "" ; $customAttributes[] = $otheroptionsArr; } $opportunityJson->customAttributes = $customAttributes; $opportunityJson = json_encode ( $opportunityJson ); $api_url = APPTIVO_API_URL . 'app/dao/v6/opportunities'; $params = array ( "a" => "save", "opportunityData" => $opportunityJson, "apiKey" => APPTIVO_API_KEY, "accessKey" => APPTIVO_ACCESS_KEY ); $response = getRestAPICall1( 'POST', $api_url, $params ); $opportunityId = $response->opportunity->opportunityId; if(isset($_FILES['uploadfile']) && !empty($_FILES['uploadfile'])){ foreach($_FILES['uploadfile']['tmp_name'] as $key => $tmp_name) { $file_name = $_FILES['uploadfile']['name'][$key]; $file_size =$_FILES['uploadfile']['size'][$key]; $file_tmp =$_FILES['uploadfile']['tmp_name'][$key]; //$file_type=$_FILES['uploadfile']['type'][$key]; $file_ext = strtolower ( end ( explode ( '.', $file_name ) ) ); $data = file_get_contents ( $file_tmp ); $base64 = base64_encode ( $data ); uploadDocument1($opportunityId,$file_name,$file_ext,$file_size,$base64); } } print_r(json_encode($response)); exit; } /*get All employees */ function getEnabledEmployees($enabledEmployees){ $api_url = APPTIVO_API_URL . 'app/dao/v6/employees'; $params = array ( "a" => "getAllByAdvancedSearch", "iDisplayLength" => 50, "iDisplayStart" => 0, "numRecords"=> 50, //"selectedLetter"=>'All', "filterAdvData" => '{"departmentIds":[],"jobTitleIds":[],"locationIds":[],"workShiftIds":[],"categoryIds":[],"resourceTypeIds":[]}', "searchData"=>'{"customAttributes":['.$enabledEmployees.'],"assigneeObjectRefId":0,"description":"","labels":[],"maritalStatus":[],"status":[],"tagIds":[],"managerName":null,"managerId":null,"addresses":[{"addressAttributeId":"address_section_attr_id","addressGroupName":"Address1","state":"","stateCode":"","stateId":null,"stateName":""}],"phoneNumbers":[]}', "startIndex"=>0, "apiKey" => APPTIVO_API_KEY, "accessKey" => APPTIVO_ACCESS_KEY ); $response = getRestAPICall1 ( 'POST', $api_url, $params ); return $response; } /* * Upload document to the Opportunity */ function uploadDocument1( $leadId, $file_name, $file_ext, $file_size, $base64) { $api_url = APPTIVO_API_URL . 'app/dao/document'; $params = array ( "a" => "uploadDoc", "objectId" => LEAD_OBJECT_ID, "objectRefId" => $leadId, "docName" => $file_name, "docTitle" => $file_name, "docType" => $file_ext, "docSize" => $file_size, "encodedDocStr" => $base64, "apiKey" => APPTIVO_API_KEY, "accessKey" => APPTIVO_ACCESS_KEY ); $response = getRestAPICall1( 'POST', $api_url, $params ); return $response; } //add_action ( 'wp_ajax_convertLeadtoCustomerContact', 'convertLeadtoCustomerContact' ); //add_action ( 'wp_ajax_nopriv_convertLeadtoCustomerContact', 'convertLeadtoCustomerContact' ); function convertLeadtoCustomerContact(){ $customercontact = new stdClass (); $leadData = $_POST ['leadData']; $leadData = $leadData [0]; if ($leadData ['accountName'] == '') { $customerJson = new stdClass (); if ($leadData ['fullName'] != '') { $customerJson->customerName = $leadData ['fullName']; } if ($leadData ['assigneeObjectRefName'] != '') { $customerJson->assigneeObjectRefName = $leadData ['assigneeObjectRefName']; } if ($leadData ['assigneeObjectRefId'] != '') { $customerJson->assigneeObjectRefId = $leadData ['assigneeObjectRefId']; } $customerJson->assigneeObjectId = "8"; if ($leadData ['description'] != '') { $customerJson->description = $leadData ['description']; } if ($leadData ['faceBookURL'] != '') { $customerJson->faceBookURL = $leadData ['faceBookURL']; } if ($leadData ['twitterURL'] != '') { $customerJson->twitterURL = $leadData ['twitterURL']; } if ($leadData ['linkedInURL'] != '') { $customerJson->linkedInURL = $ledData ['linkedInURL']; } $customerJson->phoneNumbers = array (); $pNumber = new stdClass (); if ($leadData ['phoneNumbers'] [0] ['phoneNumber'] != '') { $pNumber->phoneNumber = $leadData ['phoneNumbers'] [0] ['phoneNumber']; $pNumber->phoneType = $leadData ['phoneNumbers'] [0] ['phoneType']; $pNumber->phoneTypeCode = $leadData ['phoneNumbers'] [0] ['phoneTypeCode']; $pNumber->id = "cust_phone_input"; $pNumber->communicationId = $leadData ['phoneNumbers'] [0] ['communicationId']; $customerJson->phoneNumbers [] = $pNumber; } $customerJson->emailAddresses = array (); $emailAddr = new stdClass (); if ($leadData ['emailAddresses'] [0] ['emailAddress'] != '') { $emailAddr->emailAddress = $leadData ['emailAddresses'] [0] ['emailAddress']; $emailAddr->emailTypeCode = $leadData ['emailAddresses'] [0] ['emailTypeCode']; $emailAddr->emailType = $leadData ['emailAddresses'] [0] ['emailType']; $emailAddr->id = "cont_email_input"; $emailAddr->communicationId = $leadData ['emailAddresses'] [0] ['communicationId']; $customerJson->emailAddresses [] = $emailAddr; } $customerJson->addresses = array (); $address = new stdClass (); if ($leadData ['addresses'] [0] != '') { $address->addressAttributeId = $leadData ['addresses'] [0] ['addressAttributeId']; $address->addressTypeCode = $leadData ['addresses'] [0] ['addressTypeCode']; $address->addressType = $leadData ['addresses'] [0] ['addressType']; $address->addressLine1 = $leadData ['addresses'] [0] ['addressLine1']; $address->addressLine2 = $leadData ['addresses'] [0] ['addressLine2']; $address->city = $leadData ['addresses'] [0] ['city']; $address->stateCode = $leadData ['addresses'] [0] ['stateCode']; $address->addressGroupName = $leadData ['addresses'] [0] ['addressGroupName']; $address->state = $leadData ['addresses'] [0] ['state']; $address->zipCode = $leadData ['addresses'] [0] ['zipCode']; $address->countryId = $leadData ['addresses'] [0] ['countryId']; $address->countryName = $leadData ['addresses'] [0] ['countryName']; $address->countryCode = $leadData ['addresses'] [0] ['countryCode']; // $address->deliveryInstructions=$leadData['addresses'][0]['deliveryInstructions']; $address->county = $leadData ['addresses'] [0] ['county']; $customerJson->addresses [] = $address; } $fromObjectId = $leadData ['objectId']; $fromObjectRefId = $leadData ['leadId']; $customerJson = json_encode ( $customerJson ); $params = array ( "a" => "save", "customerData" => $customerJson, "fromObjectId" => $fromObjectId, "fromObjectRefId" => $fromObjectRefId, "isLeadConvert" => "Y", "apiKey" => APPTIVO_API_KEY, "accessKey" => APPTIVO_ACCESS_KEY ); $custResponse = getRestAPICall1( 'POST', APPTIVO_CUSTOMER_API, $params ); } if ($custResponse != '') { $customercontact->customerName = $custResponse->customerName; $customercontact->customerId = $custResponse->customerId; } else { $customercontact->customerName = $leadData ['accountName']; $customercontact->customerId = $leadData ['accountId']; } $contactJson = new stdClass (); if ($leadData ['firstName'] != '') { $contactJson->firstName = $leadData ['firstName']; } if ($leadData ['lastName'] != '') { $contactJson->lastName = $leadData ['lastName']; } // $contactJson->accountName = $accountname; // $contactJson->accountId = $contactId; if ($leadData ['description'] != '') { $contactJson->description = $leadData ['description']; } if ($leadData ['faceBookURL'] != '') { $contactJson->faceBookURL = $leadData ['faceBookURL']; } if ($leadData ['twitterURL'] != '') { $contactJson->twitterURL = $leadData ['twitterURL']; } if ($leadData ['linkedInURL'] != '') { $contactJson->linkedInURL = $leadData ['linkedInURL']; } $assignee = getAssigneeDetails (); $contactJson->assigneeObjectRefName = $leadData ['assigneeObjectRefName']; $contactJson->assigneeObjectRefId = $leadData ['assigneeObjectRefId']; $contactJson->assigneeObjectId = "8"; if($customercontact != ''){ $contactJson->accountId = $customercontact->customerId; $contactJson->accountName = $customercontact->customerName; } $contactJson->phoneNumbers = array (); $pNumber = new stdClass (); if ($leadData ['phoneNumbers'] [0] ['phoneNumber'] != '') { $pNumber->phoneNumber = $leadData ['phoneNumbers'] [0] ['phoneNumber']; $pNumber->phoneType = $leadData ['phoneNumbers'] [0] ['phoneType']; $pNumber->phoneTypeCode = $leadData ['phoneNumbers'] [0] ['phoneTypeCode']; $pNumber->id = "contact_phone_input"; $contactJson->phoneNumbers [] = $pNumber; } $contactJson->emailAddresses = array (); $emailAddr = new stdClass (); if ($leadData ['emailAddresses'] [0] ['emailAddress'] != '') { $emailAddr->emailAddress = $leadData ['emailAddresses'] [0] ['emailAddress']; $emailAddr->emailTypeCode = $leadData ['emailAddresses'] [0] ['emailTypeCode']; $emailAddr->emailType = $leadData ['emailAddresses'] [0] ['emailType']; $emailAddr->id = "cont_email_input"; $contactJson->emailAddresses [] = $emailAddr; } $contactJson->addresses = array (); $address = new stdClass (); if ($leadData ['addresses'] [0] != '') { $address->addressAttributeId = $leadData ['addresses'] [0] ['addressAttributeId']; $address->addressTypeCode = $leadData ['addresses'] [0] ['addressTypeCode']; $address->addressType = $leadData ['addresses'] [0] ['addressType']; $address->addressLine1 = $leadData ['addresses'] [0] ['addressLine1']; $address->addressLine2 = $leadData ['addresses'] [0] ['addressLine2']; $address->city = $leadData ['addresses'] [0] ['city']; $address->stateCode = $leadData ['addresses'] [0] ['stateCode']; $address->addressGroupName = $leadData ['addresses'] [0] ['addressGroupName']; $address->state = $leadData ['addresses'] [0] ['state']; $address->zipCode = $leadData ['addresses'] [0] ['zipCode']; $address->countryId = $leadData ['addresses'] [0] ['countryId']; $address->countryName = $leadData ['addresses'] [0] ['countryName']; $address->countryCode = $leadData ['addresses'] [0] ['countryCode']; // $address->deliveryInstructions=$leadData['addresses'][0]['deliveryInstructions']; $address->county = $leadData ['addresses'] [0] ['county']; $contactJson->addresses [] = $address; } $contactJson = json_encode ( $contactJson ); $params = array ( "a" => "save", "contactData" => $contactJson, "objectRefId" => $fromObjectRefId, "isLeadConvert" => "Y", "apiKey" => APPTIVO_API_KEY, "accessKey" => APPTIVO_ACCESS_KEY ); $contResponse = getRestAPICall1( 'POST', APPTIVO_CONTACT_API, $params ); if ($contResponse != '') { $customercontact->contactfullName = $contResponse->fullName; $customercontact->contactId = $contResponse->contactId; } print_r ( json_encode ( $customercontact ) ); exit; } //add_action ( 'wp_ajax_convertOpportunity', 'convertOpportunity' ); //add_action ( 'wp_ajax_nopriv_convertOpportunity', 'convertOpportunity' ); function convertOpportunity(){ $countryText = "United States"; $countryId = 176; $coutryCode = "US"; $firstName = $_POST['firstName']; $lastName = $_POST['lastName']; $email = $_POST['email']; $phone = $_POST['phone']; $address1 = $_POST['addr1']; $address2 = $_POST['addr2']; $city = $_POST['city']; $state = $_POST['statetxt']; $stateCode = $_POST['state']; $zipCode = $_POST['zipCode']; $description = $_POST['aboutus']; $customerId = $_POST['customerId']; $customerName = $_POST['customerName']; $contactId = $_POST['contactId']; $contactName = $_POST['contactName']; $brokerLicense = $_POST['brokerLicense']; $loanAmt = $_POST['loanAmt']; $propTypeText = $_POST['proptypetxt']; $propTypeVal = $_POST['propType']; $loanTypeText = $_POST['loantypetxt']; $loanTypeVal = $_POST['loanType']; $ltv = $_POST['ltv']; $plpurPrice = $_POST['purPrice']; $pldpAmt=$_POST['dpAmt']; $plantiClosedate=$_POST['antiClosedate']; $plExstatFrLoan=$_POST['ExstatFrLoan']; $plCOAmt=$_POST['COAmt']; $plpurchaseoptions=$_POST['optionsRadios']; $exitstrateRefin=$_POST['exitstrateRefin']; $COAmtRefin=$_POST['COAmtRefin']; $refinoptions=$_POST['optionsRadiosRefin']; $budgetAmt=$_POST['budgetAmt']; $EstAfterRepairVal=$_POST['EstAfterRepairVal']; $ExitStratLoanRehab=$_POST['ExitStratLoanRehab']; $COAmtRehap=$_POST['COAmtRehap']; $optionsRadiosRehab=$_POST['optionsRadiosRehab']; $ExitstratLoanOther=$_POST['ExitstratLoanOther']; $COAmtOther=$_POST['COAmtOther']; $optionsRadiosOther=$_POST['optionsRadiosOther']; $empname = $_POST['emptxt']; $empid = $_POST['loanOff_name']; $leadapi_url = APPTIVO_API_URL . 'app/dao/v6/leads'; $params = array ( 'a' => 'getAllByAdvancedSearch', 'searchData' => '{"emailAddresses":[{"emailAddress":"' . $email . '","id":"cont_email_input"}]}', 'apiKey' => APPTIVO_API_KEY, 'accessKey' => APPTIVO_ACCESS_KEY ); $lead = getRestAPICall1( 'POST', $leadapi_url, $params ); if (! empty ( $lead->data )) { $leadData = $lead->data [0]; } $leadconfigData = getOppConfigData(); $phTypes = $leadconfigData->phoneTypes; foreach($phTypes as $ptype){ if($ptype->code == 'PHONE_HOME'){ $phoneId = $ptype->id; } } $leadWeblayout = json_decode ( $leadconfigData->webLayout ); foreach ( $leadWeblayout->sections as $section ) { foreach ( $section->attributes as $attribute ) { if(isset($attribute->addressList)){ foreach($attribute->addressList as $addrField){ $addressAttributeId = $addrField->addressAttributeId; } } if(($attribute->attributeTag) == 'phone'){ $phoneattributeId = $attribute->attributeId; } if ($attribute->label->modifiedLabel != '') { if ($attribute->label->modifiedLabel == 'First Name') { $fnamecustomAttributeId = $attribute->attributeId; $fnamecustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Last Name') { $lnamecustomAttributeId = $attribute->attributeId; $lnamecustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Broker License') { $brokerLicencecustomAttributeId = $attribute->attributeId; $brokerLicencecustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Loan Amount') { $loanAmtcustomAttributeId = $attribute->attributeId; $loanAmtcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Estimated Value or LTV (Loan to Value)') { $ltvcustomAttributeId = $attribute->attributeId; $ltvcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Property Type') { $propTypecustomAttributeId = $attribute->attributeId; $propTypecustomAttributeTagName = $attribute->right [0]->tagName; $propTypeOpts = $attribute->right [0]->optionValueList; foreach ( $propTypeOpts as $options ) { if (trim(strtoupper($options->optionObject)) == trim(strtoupper($propTypeText))) { $propTypeValue = $options->optionObject; $propTypeValueId = $options->optionId; } } } if ($attribute->label->modifiedLabel == 'Loan Type') { $loanTypecustomAttributeId = $attribute->attributeId; $loanTypecustomAttributeTagName = $attribute->right [0]->tagName; $loanTypeOpts = $attribute->right [0]->optionValueList; foreach ( $loanTypeOpts as $options ) { if (trim(strtoupper($options->optionObject)) == trim(strtoupper($loanTypeText))) { $loanTypeValue = $options->optionObject; $loanTypeValueId = $options->optionId; } } } /*Purchase Loan section */ if($section->label == 'Purchase Loan'){ if ($attribute->label->modifiedLabel == 'Purchase Price') { $plpurchasePricecustomAttributeId = $attribute->attributeId; $plpurchasePricecustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Down Payment Amount') { $pldpAmtcustomAttributeId = $attribute->attributeId; $pldpAmtcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Anticipated Closing Date') { $plantiClosedatecustomAttributeId = $attribute->attributeId; $plantiClosedatecustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Exit Strategy From Loan') { $plexitstartpurchcustomAttributeId = $attribute->attributeId; $plexitstartpurchcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Cash Out Amount') { $plcmAmtcustomAttributeId = $attribute->attributeId; $plcmAmtcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Have You Been in Contact With a Rodeo Capital Agent?') { $plrodCapAgentcustomAttributeId = $attribute->attributeId; $plrodCapAgentcustomAttributeTagName = $attribute->right [0]->tagName; foreach($attribute->right as $rightarr){ if($rightarr->options[0] == $plpurchaseoptions){ $plrodCapAgentcustomAttributeTagId = $rightarr->tagId; } } } } /*Refinance*/ if($section->label == 'Refinance Loan'){ if ($attribute->label->modifiedLabel == 'Exit Strategy From Loan') { $refineexitstartpurchcustomAttributeId = $attribute->attributeId; $refineexitstartpurchcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Cash Out Amount') { $refinecmAmtcustomAttributeId = $attribute->attributeId; $refinecmAmtcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Have You Been in Contact With a Rodeo Capital Agent?') { $refinerodCapAgentcustomAttributeId = $attribute->attributeId; $refinerodCapAgentcustomAttributeTagName = $attribute->right [0]->tagName; foreach($attribute->right as $rightarr){ if($rightarr->options[0] == $refinoptions){ $refinerodCapAgentcustomAttributeTagId = $rightarr->tagId; } } } } /*Rehab */ if($section->label == 'Rehab / Construction Completion'){ if ($attribute->label->modifiedLabel == 'Budget Amount') { $rehabudgetAmtcustomAttributeId = $attribute->attributeId; $rehabudgetAmtcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Estimated After Repair Value') { $rehabeAfterrepairValcustomAttributeId = $attribute->attributeId; $rehabeAfterrepairValcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Exit Strategy From Loan') { $rehabexitstartpurchcustomAttributeId = $attribute->attributeId; $rehabexitstartpurchcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Cash Out Amount') { $rehabcmAmtcustomAttributeId = $attribute->attributeId; $rehabcmAmtcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Have You Been in Contact With a Rodeo Capital Agent?') { $rehabrodCapAgentcustomAttributeId = $attribute->attributeId; $rehabrodCapAgentcustomAttributeTagName = $attribute->right [0]->tagName; foreach($attribute->right as $rightarr){ if($rightarr->options[0] == $optionsRadiosRehab){ $rehabrodCapAgentcustomAttributeTagId = $rightarr->tagId; } } } } /* Other */ if($section->label == 'Other Loan'){ if ($attribute->label->modifiedLabel == 'Exit Strategy From Loan') { $otherexitstartpurchcustomAttributeId = $attribute->attributeId; $othereexitstartpurchcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Cash Out Amount') { $othercmAmtcustomAttributeId = $attribute->attributeId; $othercmAmtcustomAttributeTagName = $attribute->right [0]->tagName; } if ($attribute->label->modifiedLabel == 'Have You Been in Contact With a Rodeo Capital Agent?') { $otherrodCapAgentcustomAttributeId = $attribute->attributeId; $otherrodCapAgentcustomAttributeTagName = $attribute->right [0]->tagName; foreach($attribute->right as $rightarr){ if($rightarr->options[0] == $optionsRadiosOther){ $otherrodCapAgentcustomAttributeTagId = $rightarr->tagId; } } } } } } } $opportunityJson = new stdClass (); if($address2 != ''){ $opportunityName = $address1.",".$address2.",".$city.",".$state.",".$zipCode; } else{ $opportunityName = $address1.",".$city.",".$state.",".$zipCode; } $opportunityJson->opportunityName = $opportunityName; $opportunityJson->salesStageName = "Prospecting"; $opportunityJson->salesStageId = 170459; $opportunityJson->salesCycleName = "Default Sales Stages"; $opportunityJson->salesCycleId = 1; $opportunityJson->closeDate = "29/05/2017"; $opportunityJson->description = $description; $opportunityJson->assigneeObjectRefName =$leadData->assigneeObjectRefName; $opportunityJson->assigneeObjectRefId =$leadData->assigneeObjectRefId; $opportunityJson->assigneeObjectId = "8"; if($contactId != '' && $customerId !=''){ $opportunityJson->opportunityContactId = $contactId; $opportunityJson->opportunityContact = $contactName; } if (! empty ( $customerName ) || ! empty ( $customerId )) { $opportunityJson->opportunityCustomer = $customerName; $opportunityJson->opportunityCustomerId = $customerId; } $opportunityJson->amount = $loanAmt; $opportunityJson->addresses = array(); $laddr = new stdClass(); if($countryText != ''){ $laddr->addressAttributeId=$addressAttributeId; $laddr->addressType="Billing Address"; $laddr->addressTypeCode="1"; $laddr->addressLine1=$address1; $laddr->addressLine2=$address2; $laddr->city=$city; $laddr->state=$state; $laddr->stateCode=$stateCode; $laddr->countryId=$countryId; $laddr->country=$countryText; $laddr->countryName=$countryText; $laddr->countryCode=$coutryCode; $laddr->zipCode=$zipCode; $laddr->county=""; $laddr->addressGroupName="Address1"; $opportunityJson->addresses[] = $laddr; } $opportunityJson->phoneNumbers = array(); $phoneObj = new stdClass(); if($phone != ''){ $phoneObj->id = $phoneattributeId; $phoneObj->attributeId = $phoneattributeId; $phoneObj->phoneType = "Home"; $phoneObj->phoneTypeCode = "PHONE_HOME"; $selectedPhoneTypeObj = new stdClass(); $selectedPhoneTypeObj->id = $phoneId; $selectedPhoneTypeObj->code = "PHONE_HOME"; $selectedPhoneTypeObj->name = "Home"; $selectedPhoneTypeObj->description = "Home phone number"; $selectedPhoneTypeObj->isEnabled = "Y"; $selectedPhoneTypeObj->isSmsEnabled = "N"; $phoneObj->selectedPhoneType = $selectedPhoneTypeObj; $phoneObj->phoneNumber = $phone; $opportunityJson->phoneNumbers[] = $phoneObj; } $customAttributes = array(); $brokerlicArr = array(); if($brokerlicArr != ''){ $brokerlicArr['customAttributeId']=$brokerLicencecustomAttributeId; $brokerlicArr['customAttributeValue']=$brokerLicense; $brokerlicArr['customAttributeType']="number"; $brokerlicArr['customAttributeTagName']=$brokerLicencecustomAttributeTagName; $brokerlicArr['customAttributeName']=$brokerLicencecustomAttributeTagName; $brokerlicArr[$brokerLicencecustomAttributeTagName]=$brokerLicense; $brokerlicArr['numberValue'] = $brokerLicense; $customAttributes[] = $brokerlicArr; } $propertyTypeArr = array(); if($propTypeText != '' && $propTypeVal){ $propertyTypeArr['customAttributeId']=$propTypecustomAttributeId; $propertyTypeArr['customAttributeValue']=$propTypeValue; $propertyTypeArr['customAttributeType']="select"; $propertyTypeArr['customAttributeTagName']=$propTypecustomAttributeTagName; $propertyTypeArr['customAttributeName']=$propTypecustomAttributeTagName; $propertyTypeArr[$propTypecustomAttributeTagName]=$propTypeValue; $propertyTypeArr['customAttributeValueId'] = $propTypeValueId; $customAttributes[] = $propertyTypeArr; } $ltvArr = array(); if($ltv != ''){ $ltvArr['customAttributeId']=$ltvcustomAttributeId; $ltvArr['customAttributeValue']=$ltv; $ltvArr['customAttributeType']="currency"; $ltvArr['customAttributeTagName']=$ltvcustomAttributeTagName; $ltvArr['customAttributeName']=$ltvcustomAttributeTagName; $ltvArr[$ltvcustomAttributeTagName]=$ltv; $ltvArr['currencyCode'] = "AUD"; $customAttributes[] = $ltvArr; } $loanTypeArr = array(); if($loanTypeText != '' && $loanTypeVal){ $loanTypeArr['customAttributeId']=$loanTypecustomAttributeId; $loanTypeArr['customAttributeValue']=$loanTypeValue; $loanTypeArr['customAttributeType']="select"; $loanTypeArr['customAttributeTagName']=$loanTypecustomAttributeTagName; $loanTypeArr['customAttributeName']=$loanTypecustomAttributeTagName; $loanTypeArr[$loanTypecustomAttributeTagName]=$loanTypeValue; $loanTypeArr['customAttributeValueId'] = $loanTypeValueId; $customAttributes[] = $loanTypeArr; } /* purchase */ $plpurPriceArr = array(); if($plpurPrice != ''){ $plpurPriceArr['customAttributeId']=$plpurchasePricecustomAttributeId; $plpurPriceArr['customAttributeValue']=$plpurPrice; $plpurPriceArr['customAttributeType']="currency"; $plpurPriceArr['customAttributeTagName']=$plpurchasePricecustomAttributeTagName; $plpurPriceArr['customAttributeName']=$plpurchasePricecustomAttributeTagName; $plpurPriceArr[$plpurchasePricecustomAttributeTagName]=$plpurPrice; $plpurPriceArr['currencyCode'] = "AUD"; $customAttributes[] = $plpurPriceArr; } $pldpAmtArr = array(); if($pldpAmt != ''){ $pldpAmtArr['customAttributeId']=$pldpAmtcustomAttributeId; $pldpAmtArr['customAttributeValue']=$pldpAmt; $pldpAmtArr['customAttributeType']="currency"; $pldpAmtArr['customAttributeTagName']=$pldpAmtcustomAttributeTagName; $pldpAmtArr['customAttributeName']=$pldpAmtcustomAttributeTagName; $pldpAmtArr[$pldpAmtcustomAttributeTagName]=$pldpAmt; $pldpAmtArr['currencyCode'] = "AUD"; $customAttributes[] = $pldpAmtArr; } $plcloseDateArr = array(); if($plantiClosedate != ''){ $plcloseDateArr['customAttributeId']=$plantiClosedatecustomAttributeId; $plcloseDateArr['customAttributeValue']=$plantiClosedate; $plcloseDateArr['customAttributeType']="date"; $plcloseDateArr['customAttributeTagName']=$plantiClosedatecustomAttributeTagName; $plcloseDateArr['customAttributeName']=$plantiClosedatecustomAttributeTagName; $plcloseDateArr[$plantiClosedatecustomAttributeTagName]=$plantiClosedate; $customAttributes[] = $plcloseDateArr; } $fnameArr= array(); if($firstName != ''){ $fnameArr['customAttributeId']=$fnamecustomAttributeId; $fnameArr['customAttributeValue']=$firstName; $fnameArr['customAttributeType']="input"; $fnameArr['customAttributeTagName']=$fnamecustomAttributeTagName; $fnameArr['customAttributeName']=$fnamecustomAttributeTagName; $fnameArr[$fnamecustomAttributeTagName]=$firstName; $customAttributes[] = $fnameArr; } $lnameArr= array(); if($lastName != ''){ $lnameArr['customAttributeId']=$lnamecustomAttributeId; $lnameArr['customAttributeValue']=$lastName; $lnameArr['customAttributeType']="input"; $lnameArr['customAttributeTagName']=$lnamecustomAttributeTagName; $lnameArr['customAttributeName']=$lnamecustomAttributeTagName; $lnameArr[$lnamecustomAttributeTagName]=$lastName; $customAttributes[] = $lnameArr; } $plExstatFrLoanArr = array(); if($plExstatFrLoan != ''){ $plExstatFrLoanArr['customAttributeId']=$plexitstartpurchcustomAttributeId; $plExstatFrLoanArr['customAttributeValue']=$plExstatFrLoan; $plExstatFrLoanArr['customAttributeType']="input"; $plExstatFrLoanArr['customAttributeTagName']=$plexitstartpurchcustomAttributeTagName; $plExstatFrLoanArr['customAttributeName']=$plexitstartpurchcustomAttributeTagName; $plExstatFrLoanArr[$plexitstartpurchcustomAttributeTagName]=$plExstatFrLoan; $customAttributes[] = $plExstatFrLoanArr; } $plCOAmtArr= array(); if($plCOAmt != ''){ $plCOAmtArr['customAttributeId']=$plcmAmtcustomAttributeId; $plCOAmtArr['customAttributeValue']=$plCOAmt; $plCOAmtArr['customAttributeType']="currency"; $plCOAmtArr['customAttributeTagName']=$plcmAmtcustomAttributeTagName; $plCOAmtArr['customAttributeName']=$plcmAmtcustomAttributeTagName; $plCOAmtArr[$plcmAmtcustomAttributeTagName]=$plCOAmt; $plCOAmtArr['currencyCode'] = "AUD"; $customAttributes[] = $plCOAmtArr; } $plpurchaseoptionsArr= array(); if($plpurchaseoptions != ''){ $plpurchaseoptionsArr['customAttributeId']=$plrodCapAgentcustomAttributeId; $plpurchaseoptionsArr['customAttributeValue']=$plpurchaseoptions; $plpurchaseoptionsArr['customAttributeType']="radio"; $plpurchaseoptionsArr['customAttributeTagName']=$plrodCapAgentcustomAttributeTagName; $plpurchaseoptionsArr['customAttributeName']=$plrodCapAgentcustomAttributeTagName; $attrValues = array(); $attributes = new stdClass(); $attributes->attributeId = $plrodCapAgentcustomAttributeTagId; $attributes->attributeValue = $plpurchaseoptions; $attributes->shape = ""; $attributes->color = ""; $attrValues[] = $attributes; $plpurchaseoptionsArr['attributeValues'] = $attrValues; $plpurchaseoptionsArr['customAttributeValueId'] = $plrodCapAgentcustomAttributeTagId; $plpurchaseoptionsArr[$plrodCapAgentcustomAttributeTagName] = $plpurchaseoptions; $plpurchaseoptionsArr['color'] = "" ; $plpurchaseoptionsArr['shape'] = "" ; $customAttributes[] = $plpurchaseoptionsArr; } /*refinance */ $exitstrateRefinArr = array(); if($exitstrateRefin != ''){ $exitstrateRefinArr['customAttributeId']=$refineexitstartpurchcustomAttributeId; $exitstrateRefinArr['customAttributeValue']=$exitstrateRefin; $exitstrateRefinArr['customAttributeType']="input"; $exitstrateRefinArr['customAttributeTagName']=$refineexitstartpurchcustomAttributeTagName; $exitstrateRefinArr['customAttributeName']=$refineexitstartpurchcustomAttributeTagName; $exitstrateRefinArr[$refineexitstartpurchcustomAttributeTagName]=$exitstrateRefin; $customAttributes[] = $exitstrateRefinArr; } $COAmtRefinArr = array(); if($COAmtRefin != ''){ $COAmtRefinArr['customAttributeId']=$refinecmAmtcustomAttributeId; $COAmtRefinArr['customAttributeValue']=$COAmtRefin; $COAmtRefinArr['customAttributeType']="currency"; $COAmtRefinArr['customAttributeTagName']=$refinecmAmtcustomAttributeTagName; $COAmtRefinArr['customAttributeName']=$refinecmAmtcustomAttributeTagName; $COAmtRefinArr[$refinecmAmtcustomAttributeTagName]=$COAmtRefin; $COAmtRefinArr['currencyCode'] = "AUD"; $customAttributes[] = $COAmtRefinArr; } $refinoptionsArr= array(); if($refinoptions != ''){ $refinoptionsArr['customAttributeId']=$refinerodCapAgentcustomAttributeId; $refinoptionsArr['customAttributeValue']=$refinoptions; $refinoptionsArr['customAttributeType']="radio"; $refinoptionsArr['customAttributeTagName']=$refinerodCapAgentcustomAttributeTagName; $refinoptionsArr['customAttributeName']=$refinerodCapAgentcustomAttributeTagName; $refineattrValues = array(); $refattributes = new stdClass(); $refattributes->attributeId = $refinerodCapAgentcustomAttributeTagId; $refattributes->attributeValue = $refinoptions; $refattributes->shape = ""; $refattributes->color = ""; $refineattrValues[] = $refattributes; $refinoptionsArr['attributeValues'] = $refineattrValues; $refinoptionsArr['customAttributeValueId'] = $refinerodCapAgentcustomAttributeTagId; $refinoptionsArr[$refinerodCapAgentcustomAttributeTagName] = $refinoptions; $refinoptionsArr['color'] = "" ; $refinoptionsArr['shape'] = "" ; $customAttributes[] = $refinoptionsArr; } /*rehab*/ $budgetAmtArr = array(); if($budgetAmt != ''){ $budgetAmtArr['customAttributeId']=$rehabudgetAmtcustomAttributeId; $budgetAmtArr['customAttributeValue']=$budgetAmt; $budgetAmtArr['customAttributeType']="currency"; $budgetAmtArr['customAttributeTagName']=$rehabudgetAmtcustomAttributeTagName; $budgetAmtArr['customAttributeName']=$rehabudgetAmtcustomAttributeTagName; $budgetAmtArr[$rehabudgetAmtcustomAttributeTagName]=$budgetAmt; $budgetAmtArr['currencyCode'] = "AUD"; $customAttributes[] = $budgetAmtArr; } $EstAfterRepairValArr = array(); if($EstAfterRepairVal != ''){ $EstAfterRepairValArr['customAttributeId'] = $rehabeAfterrepairValcustomAttributeId; $EstAfterRepairValArr['customAttributeValue']=$EstAfterRepairVal; $EstAfterRepairValArr['customAttributeType']="currency"; $EstAfterRepairValArr['customAttributeTagName']=$rehabeAfterrepairValcustomAttributeTagName; $EstAfterRepairValArr['customAttributeName']=$rehabeAfterrepairValcustomAttributeTagName; $EstAfterRepairValArr[$rehabeAfterrepairValcustomAttributeTagName]=$EstAfterRepairVal; $EstAfterRepairValArr['currencyCode'] = "AUD"; $customAttributes[] = $EstAfterRepairValArr; } $exitStratLoanRehabArr = array(); if($ExitStratLoanRehab != ''){ $exitStratLoanRehabArr['customAttributeId']=$rehabexitstartpurchcustomAttributeId; $exitStratLoanRehabArr['customAttributeValue']=$ExitStratLoanRehab; $exitStratLoanRehabArr['customAttributeType']="input"; $exitStratLoanRehabArr['customAttributeTagName']=$rehabexitstartpurchcustomAttributeTagName; $exitStratLoanRehabArr['customAttributeName']=$rehabexitstartpurchcustomAttributeTagName; $exitStratLoanRehabArr[$rehabexitstartpurchcustomAttributeTagName]=$ExitStratLoanRehab; $customAttributes[] = $exitStratLoanRehabArr; } $COAmtRehabArr = array(); if($COAmtRehap != ''){ $COAmtRehabArr['customAttributeId']=$rehabcmAmtcustomAttributeId; $COAmtRehabArr['customAttributeValue']=$COAmtRehap; $COAmtRehabArr['customAttributeType']="currency"; $COAmtRehabArr['customAttributeTagName']=$rehabcmAmtcustomAttributeTagName; $COAmtRehabArr['customAttributeName']=$rehabcmAmtcustomAttributeTagName; $COAmtRehabArr[$rehabcmAmtcustomAttributeTagName]=$COAmtRehap; $COAmtRehabArr['currencyCode'] = "AUD"; $customAttributes[] = $COAmtRehabArr; } $rehaboptionsArr= array(); if($optionsRadiosRehab != ''){ $rehaboptionsArr['customAttributeId']=$rehabrodCapAgentcustomAttributeId; $rehaboptionsArr['customAttributeValue']=$optionsRadiosRehab; $rehaboptionsArr['customAttributeType']="radio"; $rehaboptionsArr['customAttributeTagName']=$rehabrodCapAgentcustomAttributeTagName; $rehaboptionsArr['customAttributeName']=$rehabrodCapAgentcustomAttributeTagName; $rehabattrValues = array(); $rehabattributes = new stdClass(); $rehabattributes->attributeId = $rehabrodCapAgentcustomAttributeTagId; $rehabattributes->attributeValue = $optionsRadiosRehab; $rehabattributes->shape = ""; $rehabattributes->color = ""; $rehabattrValues[] = $rehabattributes; $rehaboptionsArr['attributeValues'] = $rehabattrValues; $rehaboptionsArr['customAttributeValueId'] = $rehabrodCapAgentcustomAttributeTagId; $rehaboptionsArr[$rehabrodCapAgentcustomAttributeTagName] = $optionsRadiosRehab; $rehaboptionsArr['color'] = "" ; $rehaboptionsArr['shape'] = "" ; $customAttributes[] = $rehaboptionsArr; } /*Other*/ $exitStratLoanOtherArr = array(); if($ExitstratLoanOther != ''){ $exitStratLoanOtherArr['customAttributeId']=$otherexitstartpurchcustomAttributeId; $exitStratLoanOtherArr['customAttributeValue']=$ExitstratLoanOther; $exitStratLoanOtherArr['customAttributeType']="input"; $exitStratLoanOtherArr['customAttributeTagName']=$othereexitstartpurchcustomAttributeTagName; $exitStratLoanOtherArr['customAttributeName']=$othereexitstartpurchcustomAttributeTagName; $exitStratLoanOtherArr[$othereexitstartpurchcustomAttributeTagName]=$ExitstratLoanOther; $customAttributes[] = $exitStratLoanOtherArr; } $COAmtOtherArr = array(); if($COAmtOther != ''){ $COAmtOtherArr['customAttributeId']=$othercmAmtcustomAttributeId; $COAmtOtherArr['customAttributeValue']=$COAmtOther; $COAmtOtherArr['customAttributeType']="currency"; $COAmtOtherArr['customAttributeTagName']=$othercmAmtcustomAttributeTagName; $COAmtOtherArr['customAttributeName']=$othercmAmtcustomAttributeTagName; $COAmtOtherArr[$othercmAmtcustomAttributeTagName]=$COAmtOther; $COAmtOtherArr['currencyCode'] = "AUD"; $customAttributes[] = $COAmtOtherArr; } $otheroptionsArr= array(); if($optionsRadiosOther != ''){ $otheroptionsArr['customAttributeId']=$otherrodCapAgentcustomAttributeId; $otheroptionsArr['customAttributeValue']=$optionsRadiosOther; $otheroptionsArr['customAttributeType']="radio"; $otheroptionsArr['customAttributeTagName']=$otherrodCapAgentcustomAttributeTagName; $otheroptionsArr['customAttributeName']=$otherrodCapAgentcustomAttributeTagName; $otherattrValues = array(); $otherattributes = new stdClass(); $otherattributes->attributeId = $rehabrodCapAgentcustomAttributeTagId; $otherattributes->attributeValue = $optionsRadiosOther; $otherattributes->shape = ""; $otherattributes->color = ""; $otherattrValues[] = $otherattributes; $otheroptionsArr['attributeValues'] = $otherattrValues; $otheroptionsArr['customAttributeValueId'] = $otherrodCapAgentcustomAttributeTagId; $otheroptionsArr[$otherrodCapAgentcustomAttributeTagName] = $optionsRadiosOther; $otheroptionsArr['color'] = "" ; $otheroptionsArr['shape'] = "" ; $customAttributes[] = $otheroptionsArr; } $opportunityJson->customAttributes = $customAttributes; $opportunityJson = json_encode ( $opportunityJson ); $fromObjectId = $leadData->objectId; $fromObjectRefId = $leadData->leadId; $api_url = APPTIVO_API_URL . 'app/dao/v6/opportunities'; $params = array ( "a" => "save", "opportunityData" => $opportunityJson, "fromObjectId" => $fromObjectId, "fromObjectRefId" => $fromObjectRefId, "isLeadConvert" => "Y", "apiKey" => APPTIVO_API_KEY, "accessKey" => APPTIVO_ACCESS_KEY ); $response = getRestAPICall1( 'POST', $api_url, $params ); $opportunityId = $response->opportunity->opportunityId; if(isset($_FILES['uploadfile'])){ foreach($_FILES['uploadfile']['tmp_name'] as $key => $tmp_name) { $file_name = $_FILES['uploadfile']['name'][$key]; $file_size =$_FILES['uploadfile']['size'][$key]; $file_tmp =$_FILES['uploadfile']['tmp_name'][$key]; //$file_type=$_FILES['uploadfile']['type'][$key]; $file_ext = strtolower ( end ( explode ( '.', $file_name ) ) ); $data = file_get_contents ( $file_tmp ); $base64 = base64_encode ( $data ); uploadDocument($opportunityId,$file_name,$file_ext,$file_size,$base64); } } print_r(json_encode($response)); exit; } //add_action ( 'wp_ajax_createProperty', 'createProperty' ); //add_action ( 'wp_ajax_nopriv_createProperty', 'createProperty' ); function createProperty(){ $countryText = $_POST['countryText']; $countryId = $_POST['countryId']; $coutryCode = $_POST['coutryCode']; $firstName = $_POST['firstname']; $lastName = $_POST['lastname']; $email = $_POST['email']; $phone = $_POST['phone']; $address1 = $_POST['addr1']; $address2 = $_POST['addr2']; $city = $_POST['city']; $state = $_POST['stateText']; $stateCode = $_POST['stateVal']; $zipCode = $_POST['zipCode']; $description = $_POST['description']; $brokerLicense = $_POST['brokerLicense']; $loanAmt = $_POST['loanAmt']; $propTypeText = $_POST['propTypeText']; $propTypeVal = $_POST['propTypeVal']; $loanTypeText = $_POST['loanTypeText']; $loanTypeVal = $_POST['loanTypeVal']; $ltv = $_POST['ltv']; $plpurPrice = $_POST['plpurPrice']; $pldpAmt=$_POST['pldpAmt']; $plantiClosedate=$_POST['plantiClosedate']; $plExstatFrLoan=$_POST['plExstatFrLoan']; $plCOAmt=$_POST['plCOAmt']; $plpurchaseoptions=$_POST['plpurchaseoptions']; $exitstrateRefin=$_POST['exitstrateRefin']; $COAmtRefin=$_POST['COAmtRefin']; $refinoptions=$_POST['refinoptions']; $budgetAmt=$_POST['budgetAmt']; $EstAfterRepairVal=$_POST['EstAfterRepairVal']; $ExitStratLoanRehab=$_POST['ExitStratLoanRehab']; $COAmtRehap=$_POST['COAmtRehap']; $optionsRadiosRehab=$_POST['optionsRadiosRehab']; $ExitstratLoanOther=$_POST['ExitstratLoanOther']; $COAmtOther=$_POST['COAmtOther']; $optionsRadiosOther=$_POST['optionsRadiosOther']; $customerName = $_POST['customerName']; $customerId= $_POST['customerId']; $contactId= $_POST['contactId']; $contactName= $_POST['contactName']; $empname = $_POST['loanOfficerText']; $empid = $_POST['loanOfficerVal']; $propertyJson = new stdClass(); if($address2 != ''){ $propertyName = $address1.",".$address2.",".$city.",".$state.",".$zipCode; } else{ $propertyName = $address1.",".$city.",".$state.",".$zipCode; } $propTypes = getPropertyConfigData()->propertyTypes; foreach($propTypes as $type){ if(trim(strtoupper($type->name)) == trim(strtoupper($propTypeText))){ $propTypeValId = $type->typeId; $subTypeVal = $type->subTypeData[0]->name; $subTypeValId = $type->subTypeData[0]->subTypeId; } } $propertyJson->propertyNumber = "Auto generated number"; $propertyJson->propertyName = $propertyName; $propertyJson->propertyTypeName = $propTypeText; $propertyJson->propertyTypeId = $propTypeValId; $propertyJson->propertySubtypeName = $subTypeVal; $propertyJson->propertySubtypeId = $subTypeValId; $propertyJson->ownerName = $customerName; $propertyJson->ownerId = $customerId; $propertyJson->contactName = $contactName; $propertyJson->contactId = $contactId; if($plpurchaseoptions == 'Yes' || $refinoptions == 'Yes' || $optionsRadiosRehab == 'Yes' || $optionsRadiosOther == 'Yes'){ $propertyJson->assigneeObjectRefName = "Carlos Yanez"; $propertyJson->assigneeObjectRefId = 44808; $propertyJson->assigneeObjectId = "8"; if($empid == 'team'){ $leadJson->assigneeObjectRefName = "Sales Team"; $leadJson->assigneeObjectRefId = 10852; $leadJson->assigneeObjectId = "91"; } } else{ $propertyJson->assigneeObjectRefName = "Sales Team"; $propertyJson->assigneeObjectRefId = 10852; $propertyJson->assigneeObjectId = "91"; } /* if($empid == 'team'){ $propertyJson->assigneeObjectRefName = "Loan Officer"; $propertyJson->assigneeObjectRefId = 10903; $propertyJson->assigneeObjectId = "8"; }else{ $propertyJson->assigneeObjectRefName = $empname; $propertyJson->assigneeObjectRefId = $empid; $propertyJson->assigneeObjectId = "8"; }*/ $propertyJson->addresses = array(); $laddr = new stdClass(); if($countryText != ''){ $laddr->addressAttributeId="address_section_attr_id"; $laddr->addressType="Communication"; $laddr->addressTypeCode="3"; $laddr->addressLine1=$address1; $laddr->addressLine2=$address2; $laddr->city=$city; $laddr->state=$state; $laddr->stateCode=$stateCode; $laddr->countryId=$countryId; $laddr->country=$countryText; $laddr->countryName=$countryText; $laddr->countryCode=$coutryCode; $laddr->zipCode=$zipCode; $laddr->county=""; $laddr->addressGroupName="Address1"; $propertyJson->addresses[] = $laddr; } $propertyJson = json_encode($propertyJson); $api_url = APPTIVO_API_URL . 'app/dao/v6/properties'; $params = array ( "a" => "save", "propertyData"=>$propertyJson, "apiKey" => APPTIVO_API_KEY, "accessKey" =>APPTIVO_ACCESS_KEY ); //print_r($params); $response = getRestAPICall1( 'POST', $api_url, $params ); } //add_action ( 'wp_ajax_addContact', 'addContact' ); //add_action ( 'wp_ajax_nopriv_addContact', 'addContact' ); function addContact(){ $leadId = $_POST['leadId']; $contactId = $_POST['contactId']; $addContactResponse = addContactsToLead($leadId,$contactId); if(!empty($addContactResponse[0])){ if($addContactResponse[0]->contactId == $contactId){ echo "Contact added successfully"; } } else{ echo "Try again"; } exit; } function addContactsToLead($leadId,$contactId){ $api_url = APPTIVO_API_URL . 'app/dao/v6/leads'; $params = array ( "a" => "addContacts", "contactIds"=>'{"id":['.$contactId.']}', "leadId"=>$leadId, "apiKey" => APPTIVO_API_KEY, "accessKey" =>APPTIVO_ACCESS_KEY ); //print_r($params); $response = getRestAPICall1( 'POST', $api_url, $params ); return $response; } /* * API method - Curl call */ if(!function_exists('getRestAPICall1')){ function getRestAPICall1($method, $url, $data = false) { $proxysettings = array(); //$proxysettings = get_option('awp_proxy_settings'); /* if (!_isCurl()) { echo 'CURL disabled in your server. please enable through php.ini'; exit; } */ $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded;charset=utf-8")); if ($method == "POST") { curl_setopt($ch, CURLOPT_POST, 1); if ($data) { curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); } } else { if ($data) $url = sprintf("%s?%s", $url, http_build_query($data)); } curl_setopt($ch, CURLOPT_URL, $url); if (isset($proxysettings['proxy_enable'])) { if (isset($proxysettings['proxy_hostname_portno'])) { curl_setopt($ch, CURLOPT_PROXY, $proxysettings['proxy_hostname_portno']); } if (isset($proxysettings['proxy_loginuser_pwd'])) { curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxysettings['proxy_loginuser_pwd']); } } if(TLSV2_SUPPORT){ curl_setopt($ch, CURLOPT_SSLVERSION,'CURL_SSLVERSION_TLSv1_2'); } curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); $response = curl_exec($ch); curl_close($ch); $result = json_decode($response); return $result; } } ?>