*/ require_once AWP_LIB_DIR . '/Plugin.php'; require_once AWP_INC_DIR . '/apptivo_services/labelDetails.php'; require_once AWP_INC_DIR . '/apptivo_services/noteDetails.php'; require_once AWP_INC_DIR . '/apptivo_services/LeadDetails.php'; require_once AWP_ASSETS_DIR.'/captcha/simple-captcha/simple-captcha.php'; require_once AWP_LIB_DIR.'/Plugin/AWPServices.php'; require_once AWP_APPTIVO_DIR.'ConfigDataUtil.php'; require_once AWP_APPTIVO_DIR.'DataRetrieval.php'; /** * Class AWP_ContactForms */ class AWP_ContactForms extends AWP_Base { var $_plugin_activated = false; /** * PHP5 constructor */ function __construct() { $settings=array(); $this->_plugin_activated=false; $settings=get_option("awp_plugins"); if(get_option("awp_plugins")!=="false"){ if($settings["contactforms"]) $this->_plugin_activated=true; } } /** * Returns plugin instance * * @return AWP_ContactForms */ function &instance() { static $instances = array(); if (!isset($instances[0])) { $class = __CLASS__; $instances[0] = new $class(); } return $instances[0]; } /** * Runs plugin */ function run() { if($this->_plugin_activated){ add_shortcode('apptivocontactform', array(&$this,'showcontactform')); add_action( 'contextual_help', array(&$this,'inlinedocument'), 10, 2 ); } } function inlinedocument( $text, $screen){ $helpcontent = ''; if( $screen == 'apptivo_page_awp_contactforms') { $helpcontent ='

Activating Contact Form:

Creating New Contact Form:
Configuring Contact Form
  1. Contact Form can be configured using the section "Contact Form Configuration". ( This section will be shown automatically after first Contact Form is created )
  2. Select your Contact Form from the "Contact Form" Drop down.
  3. Select type of Template (Plugin or Theme) from the "Template Type" dropdown. Current version of plugin supports only Plugin Template.
  4. Choose one of the available layouts for the form from "Template Layout" dropdown.
  5. Content provided on field "Confirmation Message" will be shown in Site after user submitted this contact form.
  6. Custom CSS provides option to override styles of Layout choosen in Step 4. Refer Custom CSS help section for Style details.
  7. Option "Submit Button Type" provides option to select Button or Image to be placed for Contact Form submission.
  8. If Option "Button" is selected, User can provide text to be displayed in "Submit Button Text" field.
  9. If Option "image" is selected, User can provide the url of buttom image to be displayed in "Button Image URL" field.
  10. Leads collected through Contact Form can be subscribed to Apptivo Target List. Apptivo Target List for this form can be selected using "Apptivo Target List" drop down. ( Target Lists created in Apptivo Target List app will be listed on this dropdown )
  11. On selecting the "Apptivo Target List", Admin can decide whether user should be added to the Target List by default, or end user to choose subscribe using the option "Provide subscribe option to user?"
  12. Totally 13 inbuilt fields and 5 custom fields can be added into your contact form using Contact Form Fields section.
  13. 13 inbuilt fields in Contact Form Fields section has options Show flag, Required flag, Display order (in the form) and Display Text to customize.
  14. Among 13 inbuilt fields Last Name and Email are by default mandatory and it cant excluded from the form.
  15. Custom fields can be of Field Type Check Box, Radio option, Select, Text box and Text area. Field values can be provided on Option Values.
Contact Form Shortcode:
  1. Once Contact Form is created and configured, short code for the particular form will be displayed on "Contact Form Configuration" section.
  2. Shortcode for the selected form can be copied from the field "Form Shortcode"
  3. Paste the short code on the Page or Post.
Custom CSS:
  • Below are the list of CSS Style class names used on Contact Form. Below style class names can be defined in "Custom CSS" field in "Contact Form Configuration" to apply your styles.
Label 		:   absp_contact_label
mandatory : absp_contact_mandatory
input text : absp_contact_input_text
Select : absp_contact_select
textarea : absp_contact_textarea
select : absp_contact_select
input checkbox : absp_contact_input_checkbox
input radio : absp_contact_input_radio
submit : absp_contact_button_submit
'; } if($helpcontent == '') { return $text; }else { return $helpcontent; } } /** * Contact Form shortcode handler */ function showcontactform($atts){ extract(shortcode_atts(array('name'=> ''), $atts)); ob_start(); $formname=trim($name); $content=""; $successmsg=""; if(isset($_POST['awp_contactformname'])){ $submitformname=$_POST['awp_contactformname']; } $value_present = false; if(isset($_POST['awp_contactform_submit']) && $submitformname==$formname ) { if(isset($_POST["simple_captcha"]) ) { if(isset($_POST['awp_simple_captcha_challenge'])){ $captcha_instance = new AWPSimpleCaptcha(); $response = $captcha_instance->check($_POST['awp_simple_captcha_challenge'], $_POST["simple_captcha"]); $captcha_instance->remove( $_POST['awp_simple_captcha_challenge'] ); if($response!="1") { $value_present = true; $captch_error = awp_messagelist("recaptcha_error"); } else { $successmsg=$this->save_contact($submitformname); } }else{ $captcha_instance = new ReallySimpleCaptcha(); $captcha_instance->remove( $_POST['awp_simple_captcha_challenge'] ); $captch_error = awp_messagelist("recaptcha_error"); } } else if(isset($_POST["g-recaptcha-response"])) { $response_field = $_POST["g-recaptcha-response"]; //$challenge_field= $_POST["recaptcha_challenge_field"]; $option=get_option('apptivo_business_recaptcha_settings'); $option=json_decode($option); $private_key = $option->recaptcha_privatekey; $response = captchaValidation($private_key, $response_field); if($response!="1") { $value_present = true; $captch_error = awp_messagelist("v2recaptcha_error"); } else { $successmsg=$this->save_contact($submitformname); } } else{ $successmsg=$this->save_contact($submitformname); } } $contactform=$this->get_contactform_fields($formname); if(strlen(trim($successmsg)) != 0 && $contactform['confmsg_pagemode'] == 'other' ) : $location = get_permalink($contactform['confmsg_pageid']); $verification = check_blockip(); if($verification){ echo awp_messagelist('IP_banned'); return; } wp_safe_redirect($location); endif; if(isset($contactform['fields'])) { foreach($contactform['fields'] as $field){ if(is_array($field)){ if($field['fieldid']=="country") { $countrylist = $this->getAllCountryList(); break; } } } } /* Get Contact From Width Size */ $contact_width_size=$contactform['contact_width_type']; if(!empty($contactform) && !empty($contactform['fields'])){ //Registering Validation Scripts. //$this->loadscripts(); add_action('wp_footer', abwpExternalScripts); include $contactform['templatefile']; }else { echo awp_messagelist('contactform-display-page'); } return ob_get_clean(); } /** * Save contact from submitted */ function save_contact($formname,$ajaxform=false){ $customfieldArr = array(); if($ajaxform) { if(isset($_POST['captcha'])){ if(trim($_POST['captcha']) != $_SESSION['apptivo_business_captcha_code']) { $captch_error = 'Please enter correct Verification code'; return $captch_error; } } } $contactform=$this->get_contactform_fields($formname); if(!empty($contactform)){ $contactformfields=$contactform['fields']; //Process the $_POST here.. $submittedformvalues=array(); $submittedformvalues['name']=$contactform['name']; if(isset($_POST['subscribe'])){ $submittedformvalues['targetlist']=$contactform[targetlist]; } else{ if($contactform['subscribe_option']=='no'){ $submittedformvalues['targetlist']=$contactform['targetlist']; } } $customfields=""; foreach($contactformfields as $field) { $fieldid= isset($field['fieldid']) ? $field['fieldid'] : ''; $pos=strpos($fieldid, "customfield"); if($pos===false){ if($fieldid=='telephonenumber'){ $telephone1=sanitize_text_field($_POST['telephonenumber1']); if(isset($telephone1) && !empty($telephone1)){ $submittedformvalues[$fieldid]= sanitize_text_field($_POST['telephonenumber1']).sanitize_text_field($_POST['telephonenumber2']).sanitize_text_field($_POST['telephonenumber3']); } else if(isset($_POST['telephonenumber_string'])) { $submittedformvalues[$fieldid]= $_POST['telephonenumber_string']; } else{ $submittedformvalues[$fieldid]= sanitize_text_field($_POST[$fieldid]); } } else{ $submittedformvalues[$fieldid]= stripslashes($_POST[$fieldid]); } }else{ if(trim($customfields)!="") { if(is_array($_POST[$fieldid])) { $CustomArr = $_POST[$fieldid]; $customfieldVal= ""; for($i=0; $i: ".stripslashes($customfieldVal)."
"; } } else { if(is_array($_POST[$fieldid])) { $CustomArr = $_POST[$fieldid]; $customfieldVal= ""; for($i=0; $i:".stripslashes($customfieldVal)."
"; } } } } $_SESSION['AddradioMismatchValues'] = ''; $_SESSION['AddselectMismatchValues'] = ''; $_SESSION['AddcheckMismatchValues'] = ''; /* Custom Field mapping with Apptivo Leads Config data */ $apptivoArr = array(); $unmatchFields = array(); $configObj = new configData(); $sections = $configObj->appConfigData(APPTIVO_LEAD_V6_API,APPTIVO_LEAD_OBJECT_ID); foreach($sections as $section){ $sectionName = $section->getSecLabel(); $attributes = $section->getAttributeList(); foreach($attributes as $attribute){ $labelName = $attribute->getAttributeLabel(); $fieldType = $attribute->getAttributeType(); if($fieldType == 'Custom'){ if(array_key_exists($labelName, $customfieldArr)){ $apptivoArr[] = $labelName; $dataRetriObj = new DataRetrieval(); $cust = $dataRetriObj->customAttribute($customAttributes,$sectionName,$labelName,$attribute, $customfieldArr); if(!empty($cust)){ $customAttributes[] = $cust; } } } } } /* Creating note text for unmatched fields */ $customfields = ''; if(isset($customfieldArr) && $customfieldArr != ""){ foreach($customfieldArr as $customLabelName => $customValue){ if(!in_array($customLabelName, $apptivoArr)){ $customfields .= "".$customLabelName.":".stripslashes($customValue)."
"; } } } /*copying selected mismatched values to notes tab*/ if(isset($_SESSION['AddcheckMismatchValues']) && $_SESSION['AddcheckMismatchValues'] != ""){ foreach($_SESSION['AddcheckMismatchValues'] as $checkLablename => $checkval){ foreach($checkval as $values){ $AddcheckMismatchValues .= "".$checkLablename.":".trim($values)."
"; } } } $customfields .= "
Requested IP:".stripslashes(get_RealIpAddr()); $customfields = $_SESSION['AddradioMismatchValues'].'
'.$_SESSION['AddselectMismatchValues'].'
'.$AddcheckMismatchValues.'
'.$customfields; $_SESSION['AddradioMismatchValues'] = ''; $_SESSION['AddselectMismatchValues'] = ''; $_SESSION['AddcheckMismatchValues'] = ''; if(trim($customfields)!="") { $submittedformvalues["notes"]=$customfields; } $firstName="";$jobTitle="";$company="";$address1="";$address2="";$city="";$state="";$zipCode="";$bestWayToContact="";$phoneNumber="";$comments="";$targetname=""; if(isset($submittedformvalues['firstname'])){ $firstName = sanitize_text_field($submittedformvalues['firstname']); } if(isset($submittedformvalues['lastname'])){ $lastName = sanitize_text_field($submittedformvalues['lastname']); } if(isset($submittedformvalues['email'])){ $emailId = sanitize_email($submittedformvalues['email']); } if(isset($submittedformvalues['jobtitle'])){ $jobTitle = sanitize_text_field($submittedformvalues['jobtitle']); } if(isset($submittedformvalues['company'])){ $company = sanitize_text_field($submittedformvalues['company']); } if(isset($submittedformvalues['address1'])){ $address1 = sanitize_text_field($submittedformvalues['address1']); } if(isset($submittedformvalues['address2'])){ $address2 = sanitize_text_field($submittedformvalues['address2']); } if(isset($submittedformvalues['city'])){ $city = sanitize_text_field($submittedformvalues['city']); } if(isset($submittedformvalues['state'])){ $state = sanitize_text_field($submittedformvalues['state']); } if(isset($submittedformvalues['zipcode'])){ $zipCode = sanitize_text_field($submittedformvalues['zipcode']); } if(isset($submittedformvalues['simple_captcha'])){ $simple_captcha=sanitize_text_field($submittedformvalues['simple_captcha']); } if(isset($submittedformvalues['bestway'])){ $bestWayToContact = sanitize_text_field($submittedformvalues['bestway']); } if(isset($submittedformvalues['country'])){ $country = sanitize_text_field($submittedformvalues['country']); } if(isset($submittedformvalues['name'])){ $leadSource = sanitize_text_field($submittedformvalues['name']); } if(isset($submittedformvalues['telephonenumber'])){ $phoneNumber = sanitize_text_field($submittedformvalues['telephonenumber']); } if(isset($submittedformvalues['comments'])){ $comments = sanitize_text_field($submittedformvalues['comments']); } if(isset($submittedformvalues['notes'])){ $noteDetails = $submittedformvalues['notes']; } $targetlistid=""; if(isset($submittedformvalues['targetlist'])){ $targetlistid = sanitize_text_field($submittedformvalues['targetlist']); } /* Get Country Id & Country Name*/ if(isset($_POST['country_id']) && isset($_POST['country_name'])){ $countryId=sanitize_text_field($_POST['country_id']); $countryName=sanitize_text_field($_POST['country_name']); }else{ $countryId="176"; $countryName="United States"; } if(!empty($noteDetails)){ $parent1NoteId=""; $parent1details = nl2br($noteDetails); $awp_services_obj=new AWPAPIServices(); $noteDetails = $awp_services_obj->notes('Custom Fields',$parent1details,$parent1NoteId); $contactformdetails=$this->get_settings($leadSource); $formproperties=$contactformdetails['properties']; if(isset($targetlistid) && $targetlistid!=''){ $getTargetName=$awp_services_obj->getTargetListcategory(); if($getTargetName!="") { foreach($getTargetName as $category){ if($category->id==$formproperties['targetlist']) { $targetname=$category->name; } } } } } $contactAccountName=""; $customerAccountName=""; if(!_isCurl()) { $targetname=$targetlistid; } if(strlen(trim($firstName)) == 0 ) : $firstName = null; endif; if(strlen(trim($lastName))==0 || strlen(trim($emailId))==0 || !filter_var($emailId, FILTER_VALIDATE_EMAIL)){ echo awp_messagelist('no_redirection'); }else{ /* check manually and update the values */ $form_name = $_POST['awp_contactformname']; $contact_formvalues=$this->get_contactform_fields($form_name); if(isset($_POST['status_name']) || isset($_POST['status_id']) || isset($_POST['rank_id']) || isset($_POST['rank_id']) || isset($_POST['type_name']) || isset($_POST['type_id'])){ $contact_status=sanitize_text_field($_POST['status_name']); $contact_status_id=sanitize_text_field($_POST['status_id']); $contact_type=sanitize_text_field($_POST['type_name']); $contact_type_id=sanitize_text_field($_POST['type_id']); $contact_rank=sanitize_text_field($_POST['rank_name']); $contact_rank_id=sanitize_text_field($_POST['rank_id']); } if($contact_status=="" && $contact_status_id==""){ $contact_status=$contact_formvalues['contact_status']; $contact_status_id=$contact_formvalues['contact_status_id']; } if($contact_type=="" && $contact_type_id==""){ $contact_type=$contact_formvalues['contact_type']; $contact_type_id=$contact_formvalues['contact_type_id']; } if($contact_rank=="" && $contact_rank_id==""){ $contact_rank=$contact_formvalues['contact_rank']; $contact_rank_id=$contact_formvalues['contact_rank_id']; } /* Get Lead Source,Type,Status */ $contact_source=$contact_formvalues['contact_source']; $contact_source_id=$contact_formvalues['contact_source_id']; /* Check Wheather leadSource Selected or not */ if($contact_source=="Select One" || $contact_source=="" && $contact_source_id==0){$leadSource=$leadSource;$leadSourceId=strtoupper($leadSource);} else{$leadSource=$contact_source;$leadSourceId=$contact_source_id;} $assigneeName = trim($contact_formvalues["contact_assignee_name"]); $assigneeObjId = ($contact_formvalues["contact_assignee_type"] == 'team') ? APPTIVO_TEAM_OBJECT_ID : APPTIVO_EMPLOYEE_OBJECT_ID; $assigneeObjRefId = $contact_formvalues["contact_assignee_type_id"]; $contactAssociates = trim($contact_formvalues["contact_associates"]); $createAssociates = trim($contact_formvalues["contact_create_associates"]); //echo $assigneeName."-".$assigneeObjId."-".$assigneeObjRefId."-".$contactAssociates."-".$createAssociates;exit; /* Check wheather Team exist or not */ if($assigneeName=='No Team'){ $assigneeName= $assigneeObjId = $assigneeObjRefId = ""; } $associates=""; if($contactAssociates != "No Need") { $associates=$awp_services_obj->awpContactAssociates($emailId, $contactAssociates); } //echo $associates["leadContactId"]."-".$associates["leadContact"]."-".$associates["leadCustomerId"]."-".$associates["leadCustomer"];exit; $customerAccountId = $customerAccountName = ""; if(count($associates) !="") { if(isset($associates["leadCustomerId"])){ $customerAccountId = $associates["leadCustomerId"]; } if(isset($associates["leadCustomer"])){ $customerAccountName= $associates["leadCustomer"]; } } if($customerAccountId == "" && $createAssociates == "customer" && $contactAssociates!="No Need") { $createCustomerResponse=$awp_services_obj->createCustomer($lastName,$assigneeName,$assigneeObjId,$assigneeObjRefId,$phoneNumber,$emailId); $customerAccountId=$createCustomerResponse['leadCustomerId']; $customerAccountName=$createCustomerResponse['leadCustomer']; } $verification = check_blockip(); if($verification){ if($verification == 'E_IP') { echo awp_messagelist('IP_banned'); } return; } $leadSource=strtoupper($leadSource); if(_isCurl()) { $saveLeadresponse = $awp_services_obj->saveLeadDetails($firstName , $lastName, $emailId, $jobTitle, $company, $address1, $address2, $city, $state, $zipCode, $bestWayToContact, $countryId,$countryName, $leadSource, $leadSourceId,$phoneNumber, $comments, $noteDetails,$targetname,$customerAccountId,$customerAccountName,$contact_status,$contact_type,$contact_rank,$contact_status_id,$contact_type_id,$contact_rank_id,$assigneeName,$assigneeObjId,$assigneeObjRefId,$customAttributes); $leadId= $saveLeadresponse->lead->leadId; $leadfullName = $saveLeadresponse->lead->fullName; if($noteDetails!="" && $leadId!="") { $noteText=$noteDetails->noteText; $saveNotesResponse=$awp_services_obj->saveNotes(APPTIVO_LEAD_OBJECT_ID,$leadId,$leadfullName,$noteText); } if($leadId!="") { $response='Success'; if (extension_loaded('soap') && $targetlistid!="") { createTargetList($targetlistid, addslashes($firstName), addslashes($lastName), addslashes($emailId), addslashes($phoneNumber), addslashes($comments),$notesLabel); } } else { $response='E_100'; } } else { $leads = new AWP_LeadDetails(APPTIVO_BUSINESS_API_KEY,$firstName, $lastName, $emailId, $jobTitle, $company, $address1, $address2, $city, $state, $zipCode, $bestWayToContact, $country, $leadSource, $phoneNumber, $comments, $noteDetails,$targetlistid); $params = array ( "arg0" => APPTIVO_BUSINESS_API_KEY, "arg1" => APPTIVO_BUSINESS_ACCESS_KEY, "arg2" => $leads ); $response = getsoapCall(APPTIVO_BUSINESS_SERVICES,'createLeadWithLeadSource',$params); $response= $response->return->statusMessage; } $response_msg = $response; if($response_msg=='Success' && $response != 'E_100'){ if(!empty($contactform['confmsg'])){ $confmsg = $contactform['confmsg']; } else{ $confmsg="Your request has been submitted. Thanks for contacting us."; } }else if($response == 'E_IP') { echo awp_messagelist('IP_banned');} else { echo awp_messagelist('contactlead-display-page'); } } } return $confmsg; } /** * Get contactform and its fields to render in page which is using shortcode */ function get_contactform_fields($formname){ $formExists=""; $contact_forms=array(); $contactform=array(); $contactformdetails=array(); $formname=trim($formname); $contact_forms=get_option('awp_contactforms'); if($formname=="") $formExists=""; else if(!empty($contact_forms)) $formExists = awp_recursive_array_search($contact_forms,$formname,'name' ); if(trim($formExists)!=="" ){ $contactform=$contact_forms[$formExists]; //build contactformdetails array $contactformdetails['name']=$contactform['name']; //add properties $contactformproperties=$contactform['properties']; $contactformdetails['tmpltype']=$contactformproperties['tmpltype']; $contactformdetails['layout']=$contactformproperties['layout']; $contactformdetails['confmsg']= stripslashes($contactformproperties['confmsg']); $contactformdetails['confmsg_pagemode']= $contactformproperties['confirm_msg_page']; $contactformdetails['confmsg_pageid']= $contactformproperties['confirm_msg_pageid']; $contactformdetails['targetlist']=$contactformproperties['targetlist']; $contactformdetails['css']=stripslashes($contactformproperties['css']); $contactformdetails['subscribe_option']=$contactformproperties['subscribe_option']; $contactformdetails['subscribe_to_newsletter_displaytext']=stripslashes($contactformproperties['subscribe_to_newsletter_displaytext']); $contactformdetails['submit_button_type']=$contactformproperties['submit_button_type']; $contactformdetails['submit_button_val']=$contactformproperties['submit_button_val']; $contactformdetails['contact_create_associates']=$contactformproperties['contact_create_associates']; $contactformdetails['contact_assignee_type']=$contactformproperties['contact_assignee_type']; $contactformdetails['contact_assignee_type_id']=$contactformproperties['contact_assignee_type_id']; $contactformdetails['contact_assignee_name']=$contactformproperties['contact_assignee_name']; $contactformdetails['contact_status']=$contactformproperties['contact_status']; $contactformdetails['contact_type']=$contactformproperties['contact_type']; $contactformdetails['contact_source']=$contactformproperties['contact_source']; $contactformdetails['contact_associates']=$contactformproperties['contact_associates']; $contactformdetails['contact_rank']=$contactformproperties['contact_rank']; $contactformdetails['contact_status_id']=$contactformproperties['contact_status_id']; $contactformdetails['contact_type_id']=$contactformproperties['contact_type_id']; $contactformdetails['contact_source_id']=$contactformproperties['contact_source_id']; $contactformdetails['contact_rank_id']=$contactformproperties['contact_rank_id']; $contactformdetails['contact_width_type']=$contactformproperties['contact_width_type']; $check_browser = get_current_browser(); if(isset($chrome)){ if($check_browser=="chrome") { $chrome= ".recaptcha_source{width:40%;}"; } echo ''; } //include template files if($contactformproperties['tmpltype']=="awp_plugin_template") : $templatefile=AWP_CONTACTFORM_TEMPLATEPATH."/".$contactformproperties['layout']; // Plugin templates else : $templatefile=TEMPLATEPATH."/contactforms/".$contactformproperties['layout']; // theme templates endif; $contactformdetails['templatefile']=$templatefile; $possible_letters = '23456789bcdfghjkmnpqrstvwxyz'; $characters_on_image = 6; $code = ''; $i = 0; while ($i < $characters_on_image) { $code .= substr($possible_letters, mt_rand(0, strlen($possible_letters)-1), 1); $i++; } $_SESSION['apptivo_business_captcha_code'] = $code; $contactformdetails['captchaimagepath'] = AWP_PLUGIN_BASEURL.'/assets/captcha/captcha_code_file.php?captcha_code='.$code; //add fields $contactformfields=$contactform['fields']; if(!empty($contactformfields)){ usort($contactformfields, "awp_sort_by_order"); $newcontactformfields=$contactformfields; $contactformdetails['fields']=$newcontactformfields; } } return $contactformdetails; } /** * Get Contact form settings by form name to render in Admin */ function get_settings($formname){ $formExists=""; $contact_forms=array(); $contactform=array(); $formname=trim($formname); $contact_forms=get_option('awp_contactforms'); if($formname=="") $formExists=""; else if(!empty($contact_forms)) $formExists = awp_recursive_array_search($contact_forms,$formname,'name' ); if(trim($formExists)!=="" ){ $contactform=$contact_forms[$formExists]; } return $contactform; } /** * Return master fields lists supported by Apptivo Contact Form */ function get_master_fields() { $fields = array( array('fieldid' => 'firstname','fieldname' => 'First Name','defaulttext' => 'First Name','showorder' => '1','validation' => 'text','fieldtype' => 'text'), array('fieldid' => 'lastname','fieldname' => 'Last Name','defaulttext' => 'Last Name','showorder' => '2','validation' => 'text','fieldtype' => 'text'), array('fieldid' => 'leadStatus','fieldname' => 'Lead Status','defaulttext' => 'Lead Status','showorder' => '3','validation' => 'text','fieldtype' => 'select'), array('fieldid' => 'leadType','fieldname' => 'Lead Type','defaulttext' => 'Lead Type','showorder' => '4','validation' => 'text','fieldtype' => 'select'), array('fieldid' => 'leadSource','fieldname' => 'Lead Source','defaulttext' => 'Lead Source','showorder' => '5','validation' => 'text','fieldtype' => 'select'), array('fieldid' => 'leadRank','fieldname' => 'Lead Rank','defaulttext' => 'Lead Rank','showorder' => '6','validation' => 'text','fieldtype' => 'select'), array('fieldid' => 'email','fieldname' => 'Email','defaulttext' => 'Email','showorder' => '7','validation' => 'email','fieldtype' => 'text'), array('fieldid' => 'jobtitle','fieldname' => 'Job Title','defaulttext' => 'Job Title','showorder' => '8','validation' => 'text','fieldtype' => 'text'), array('fieldid' => 'company','fieldname' => 'Company','defaulttext' => 'Company','showorder' => '9','validation' => 'text','fieldtype' => 'text'), array('fieldid' => 'address1','fieldname' => 'Address1','defaulttext' => 'Address1','showorder' => '10','validation' => 'text','fieldtype' => 'text'), array('fieldid' => 'address2','fieldname' => 'Address2','defaulttext' => 'Address2','showorder' => '11','validation' => 'text','fieldtype' => 'text'), array('fieldid' => 'city','fieldname' => 'City','defaulttext' => 'City','showorder' => '12','validation' => 'text','fieldtype' => 'text'), array('fieldid' => 'state','fieldname' => 'State','defaulttext' => 'State','showorder' => '13','validation' => 'text','fieldtype' => 'text'), array('fieldid' => 'zipcode','fieldname' => 'ZipCode','defaulttext' => 'ZipCode','showorder' => '14','validation' => 'text','fieldtype' => 'text'), array('fieldid' => 'country','fieldname' => 'Country','defaulttext' => 'Country','showorder' => '15','validation' => 'text','fieldtype' => 'select'), array('fieldid' => 'telephonenumber','fieldname' => 'Telephone Number','defaulttext' => 'Telephone Number','showorder' => '16','validation' => '','fieldtype' => 'text'), array('fieldid' => 'comments','fieldname' => 'Comments','defaulttext' => 'Comments','showorder' => '17','validation' => 'textarea','fieldtype' => 'textarea'), array('fieldid' => 'captcha','fieldname' => 'Captcha','defaulttext' => 'Captcha','showorder' => '18','validation' => 'text','fieldtype' => 'captcha'), array('fieldid' => 'customfield1','fieldname' => 'Custom Field 1','defaulttext' => 'Custom Field1','showorder' => '19','validation' => '','fieldtype' => 'select'), array('fieldid' => 'customfield2','fieldname' => 'Custom Field 2','defaulttext' => 'Custom Field2','showorder' => '20','validation' => '','fieldtype' => 'select'), array('fieldid' => 'customfield3','fieldname' => 'Custom Field 3','defaulttext' => 'Custom Field3','showorder' => '21','validation' => '','fieldtype' => 'select'), array('fieldid' => 'customfield4','fieldname' => 'Custom Field 4','defaulttext' => 'Custom Field4','showorder' => '22','validation' => '','fieldtype' => 'radio'), array('fieldid' => 'customfield5','fieldname' => 'Custom Field 5','defaulttext' => 'Custom Field5','showorder' => '23','validation' => '','fieldtype' => 'checkbox') ); //For Additional custom fields. $addtional_custom = get_option('awp_addtional_custom'); if(!empty($addtional_custom)): $fields = array_merge($fields,$addtional_custom); endif; return $fields; } /** * Retrieve list of validations supported by Apptivo Contact Form * */ function get_master_validations(){ $validations = array( array('validationLabel' => 'None','validation' => 'none'), array('validationLabel' => 'Email ID','validation' => 'email'), array('validationLabel' => 'Number','validation' => 'number') ); return $validations; } /** * * * Retrieve list of Field Types supported by Apptivo Contact Form */ function get_master_fieldtypes(){ $fieldtypes = array( array('fieldtypeLabel' => 'Checkbox','fieldtype' => 'checkbox'), array('fieldtypeLabel' => 'Radio Option','fieldtype' => 'radio'), array('fieldtypeLabel' => 'Select','fieldtype' => 'select'), array('fieldtypeLabel' => 'Textbox','fieldtype' => 'text'), array('fieldtypeLabel' => 'Textarea','fieldtype' => 'textarea') ); return $fieldtypes; } /** * return array of plugin templates available with Template name and template file name */ function get_plugin_templates() { $default_headers = array( 'Template Name' => 'Template Name' ); $templates = array(); $dir_contact = AWP_CONTACTFORM_TEMPLATEPATH; // Open a known directory, and proceed to read its contents if (is_dir($dir_contact)) { if ($dh = opendir($dir_contact)) { while (($file = readdir($dh)) !== false) { if ( substr( $file, -4 ) == '.php' ) { $plugin_data = get_file_data( $dir_contact."/".$file, $default_headers, '' ); if(strlen(trim($plugin_data['Template Name'])) != 0 ) { $templates[$plugin_data['Template Name']] = $file; } } } closedir($dh); } } return $templates; } /** * Create field array */ function createformfield_array($fieldid,$showtext,$required,$type,$validation,$options,$displayorder){ $displayorder = (trim($displayorder)=="")?0:trim($displayorder); $options = (is_array($options))?$options:stripslashes(str_replace( array('"'), '', strip_tags($options))); if( trim($type) != 'text' && trim($type) != 'textarea') { $pos = strpos(trim($fieldid), 'customfield'); if( $pos !== false ) { if( !is_array($options) && trim($options) == '') { return ''; } } } $contactformfield= array( 'fieldid'=>$fieldid, 'showtext' => stripslashes(str_replace( array('"'), '', strip_tags($showtext))), 'required' => $required, 'type' => $type, 'validation' => $validation, 'options' => $options, 'order' => $displayorder ); return $contactformfield; } /** * It renders UI in Admin page */ function options(){ $updatemessage=""; if($_POST['delformname']) //Delete Form Name: { if(strlen(trim($_POST['delformname'])) != 0) { $formname = $_POST['delformname']; $contact_forms=get_option('awp_contactforms'); $formExists = awp_recursive_array_search($contact_forms,$formname,'name' ); if(isset($formExists)) { unset($contact_forms[$formExists]); } $contact_sort_form = array(); foreach($contact_forms as $contact_forms_tosort ) { array_push($contact_sort_form,$contact_forms_tosort); } update_option('awp_contactforms', $contact_sort_form); $updatemessage= 'Contact Form "'.$formname.'" Deleted Successfully.'; } } $contact_forms=array(); $contactformdetails=array(); $contact_forms=get_option('awp_contactforms'); /* * Saving New form */ if(isset($_POST['newcontactformname'])) { $newcontactformname = $_POST['newcontactformname']; $leadSources = json_decode($_SESSION['contact_config'])->leadSource; //$newcontactformname = preg_replace('/[^\w]/', '', $newcontactformname); $newcontactformname=trim($newcontactformname); if(_isCurl()) { if($newcontactformname != '_' && $newcontactformname != '' ) { $response= CreateContactFormLeads($newcontactformname,$leadSources); } else{ $updatemessage= "Form Name should be valid data."; } } else { $response = "soap"; } if($newcontactformname!='' ) { $contactform=array(); $contactform=$this->get_settings($newcontactformname); if( count($contactform)==0 && $response!="present") { $newcontactformname_array =array("name"=>$newcontactformname); $newcontactform=array($newcontactformname_array); if( empty($contact_forms) ){ update_option('awp_contactforms',$newcontactform); }else{ array_push($contact_forms, $newcontactformname_array); update_option('awp_contactforms',$contact_forms); } $contact_forms=get_option('awp_contactforms'); $contactform=$this->get_settings($newcontactformname); $selectedcontactform=$newcontactformname; $updatemessage= "Contact Form created. Please configure settings using the below Configuration section."; }else{ $updatemessage= "Form already exists. To change configuration, please select the form from below configuration section."; } }else{ $updatemessage= "Form Name cannot be empty or should valid data."; } } /* * Loading the settings of selected form */ if(isset($_POST['awp_contactform_select_form'])) { $selectedcontactform = trim( $_POST['awp_contactform_select_form']); if($selectedcontactform!='') { $contactform=array(); $contactform=$this->get_settings($selectedcontactform); if( empty($contactform)) { //echo "Selected form configuration doestn exist."; }else{ $contactformdetails=$contactform; } } } /* * Saving selected form settings */ if(isset($_POST['awp_contactform_settings'])){ $templatelayout=""; contactOptions('save'); $contactConfigDetails =array("awp_leadSource_selected"=>$_POST['absp_contact_config_leadSource'],"awp_leadType_selected"=>$_POST['absp_contact_config_leadType'],"awp_leadStatus_selected"=>$_POST['absp_contact_config_leadStatus'],"awp_leadRank_selected"=>$_POST['absp_contact_config_leadRank']); $newformname=$_POST['awp_contactform_name']; if($_POST['awp_contactform_templatetype']=="awp_plugin_template") $templatelayout=$_POST['awp_contactform_plugintemplatelayout']; else $templatelayout=$_POST['awp_contactform_themetemplatelayout']; if($_POST["awp_contact_select_assignee"] == 'team'){ $assignee_type_id = $_POST['awp_contact_select_assignee_team']; } else{ $assignee_type_id = $_POST['awp_contact_select_assignee_employee']; } $contactformproperties=array( 'tmpltype' =>$_POST['awp_contactform_templatetype'], 'layout' =>$templatelayout, 'confmsg' => stripslashes($_POST['awp_contactform_confirmationmsg']), 'confirm_msg_page' => $_POST['awp_contactform_confirm_msg_page'], 'confirm_msg_pageid' => $_POST['awp_contactform_confirmmsg_pageid'], 'targetlist' =>$_POST['awp_contactform_targetlist'], 'css' => stripslashes($_POST['awp_contactform_customcss']), 'subscribe_option' => $_POST['subscribe_option'], 'subscribe_to_newsletter_displaytext' => stripslashes($_POST['awp_subscribe_to_newsletter']), 'submit_button_type' => $_POST['awp_contactform_submit_type'], 'submit_button_val' => $_POST['awp_contactform_submit_value'], 'contact_associates' => $_POST['awp_contact_associates'], 'contact_create_associates' => $_POST['awp_contact_createassociate'], 'contact_assignee_type' => $_POST['awp_contact_select_assignee'], 'contact_assignee_type_id' => $assignee_type_id, 'contact_assignee_name' => trim($_POST['select_assignee_name_val']), 'contact_status' => $_POST['awp_leadStatus'], 'contact_type' => $_POST['awp_leadType'], 'contact_source' => $_POST['awp_leadSource'], 'contact_rank' => $_POST['awp_leadRank'], 'contact_status_id'=>$_POST['absp_contact_config_leadStatus'], 'contact_type_id'=>$_POST['absp_contact_config_leadType'], 'contact_source_id'=>$_POST['absp_contact_config_leadSource'], 'contact_rank_id'=>$_POST['absp_contact_config_leadRank'], 'contact_width_type'=>$_POST['awp_contact_width_type'] ); //New Custom fields $stack = array(); $addtional_custom = array(); $addtional_order = 20; for($i=6;$i<200;$i++) { if(isset($_POST['customfield'.$i.'_newest']) ) { $addtional_custom = array('fieldid' => 'customfield'.$i.'','fieldname' => 'Custom Field '.$i.'', 'defaulttext' => 'Custom Field'.$i.'','showorder' => $addtional_order,'validation' => '', 'fieldtype' => 'select'); $addtional_order++; array_push($stack, $addtional_custom); }else { break; } } if(!empty($stack)) : update_option('awp_addtional_custom',$stack); endif; //General Contact form fields $contactformfields=array(); foreach( $this->get_master_fields() as $fieldsmasterproperties ) { $enabled=0; $contactformfield=array(); $fieldid=$fieldsmasterproperties['fieldid']; if(!empty ($_POST[$fieldid.'_order'])){ $displayorder = $_POST[$fieldid.'_order']; } else{ $displayorder = $fieldsmasterproperties['showorder']; } if(!empty ($_POST[$fieldid.'_text'])){ $displaytext = $_POST[$fieldid.'_text']; } else{ $displaytext = $fieldsmasterproperties['defaulttext']; } if($fieldid=='lastname' || $fieldid=='email') { $enabled = 1; $required = 1; } else if($fieldid=='captcha') { $enabled = $_POST[$fieldid.'_show']; $required = 1; } else { $enabled = $_POST[$fieldid.'_show']; $required = $_POST[$fieldid.'_require']; } if($enabled){ $contactformfield=$this->createformfield_array($fieldid,$displaytext,$required,$_POST[$fieldid.'_type'],$_POST[$fieldid.'_validation'],$_POST[$fieldid.'_options'],$displayorder); array_push($contactformfields, $contactformfield); } } //usort($contactformfields, "awp_sort_by_order"); if(!empty($contactformfields)){ $newcontactformdetails=array('name'=>$newformname,'properties'=>$contactformproperties,'fields'=>$contactformfields,'contact_config'=>$contactConfigDetails); $formExists=""; if(!empty($contact_forms)) $formExists = awp_recursive_array_search($contact_forms,$newformname,'name' ); if(trim($formExists)!=="" ){ unset($contact_forms[$formExists]); array_push($contact_forms, $newcontactformdetails); sort($contact_forms); contactOptions('save'); update_option('awp_contactforms',$contact_forms); $contact_forms=get_option('awp_contactforms'); $updatemessage= "Contact Form '".$newformname."' settings updated. Use Shortcode '[apptivocontactform name=\"".$newformname."\"]' in your page to use this form."; } }else{ $updatemessage="Select atleast one Form field for Contact Form."; } $selectedcontactform=$newformname; } // Now display the settings editing screen echo '
'; // header echo "

" . __( 'Apptivo Contact Forms', 'awp_contactform' ) . "

"; checkCaptchaOption(); echo '
'; //if updatemessage is not empty display the div if(trim($updatemessage)!=""){ ?>

_plugin_activated){ $disabledForm = 'disabled="disabled"'; $disabledOption = TRUE; echo "Contact Forms is currently disabled. Please enable this in Apptivo General Settings."; } //get the count of total contact forms created $contactformscount=0; if(!empty($contact_forms)){ $contactformscount=count($contactformscount); }else{ $contactformscount=0; } if($contactformscount < 10){ ?>

contactform

For Complete instructions,see the Developer's Guide.

*  

type="submit" name="Submit" class="button-primary" value="" />

getNewsletterCategory(); $themetemplates = get_awpTemplates(TEMPLATEPATH.'/contactforms','Plugin'); $plugintemplates=$this->get_plugin_templates(); arsort($plugintemplates); ?>

" . __( 'Contact Form Configuration', 'awp_contactform' ) . ""; ?> get_settings($selectedcontactform); if(count($contactformdetails)>0){ $selectedcontactform=$contactformdetails[name]; $fields=$contactformdetails[fields]; $formproperties=$contactformdetails[properties]; } ?> Save the below settings to get the Shortcode for contact form.'; endif; ?>
     _plugin_activated) { ?>
Delete
leadAssignee)){ foreach ($configDatas->leadAssignee as $assigne_key => $assigne_value){ if($assigne_value->assigneeObjectId == APPTIVO_EMPLOYEE_OBJECT_ID){ $assignee_employee_list[$assigne_value->assigneeName] = $assigne_value->assigneeObjectRefId; } else if($assigne_value->assigneeObjectId == APPTIVO_TEAM_OBJECT_ID){ $assignee_team_list[$assigne_value->assigneeName] = $assigne_value->assigneeObjectRefId; } } $contact_assignee_default_name = $configDatas->leadAssignee[0]->assigneeName; } else{ $contact_assignee_default_name = ''; } if(!isset($assignee_employee_list)){ $assignee_employee_list["No Employee"] = ''; } if(!isset($assignee_team_list)){ $assignee_team_list["No Team"] = ''; } } if(isset($formproperties['contact_assignee_name'])){ $contact_assignee_name = $formproperties['contact_assignee_name']; } else{ $contact_assignee_name = $case_assignee_default_name; } ?>
>

*Developers Guide - Contact Form Shortcodes.
*Developers Guide - Contact Form Templates.

Selecting Theme template which doesnt support Contact form structure will wont show the contact form in webpage.
checked="checked" /> />


This message will shown in your website page, once contact form submitted.

Style class provided here will override template style. Please refer Apptivo plugin help section for class name to be used.
*Developers Guide - Contact Form CSS.

checked="checked" /> />


Select the Apptivo Target List category to which this Form submitted has to be subscribed.

if select yes means subscribe option display to user else subscribe user automatically.
type="radio" name="subscribe_option" id="subscribe_option_yes" value="yes" /> type="radio" name="subscribe_option" id="subscribe_option_no" value="no" />

type="text" size="52" value="" id="awp_subscribe_to_newsletter" name="awp_subscribe_to_newsletter">
"donot","Create New customer"=>"customer"); ?>
"employee","Team"=>"team"); ?>
"100%","Half Width (50%)"=>"50%"); ?>

" . __( 'Contact Form Fields', 'awp_contactform' ) . "";?>
Select and configure list of fields from below table to show in your contact form. *Developers Guide - Basic Contact Form Config.

get_master_fields() as $fieldsmasterproperties ) { $enabled=0; $fieldExists=array(); $fieldid=$fieldsmasterproperties['fieldid']; $fieldExistFlag=""; if(!empty($fields)) { $fieldExistFlag= awp_recursive_array_search($fields, $fieldid, 'fieldid'); } if(trim($fieldExistFlag)!=="") { $enabled=1; $fieldData=array("fieldid"=>$fieldid, "fieldname"=>$fieldsmasterproperties['fieldname'], "show"=>$enabled, "required"=>$fields[$fieldExistFlag]['required'], "showtext"=>$fields[$fieldExistFlag]['showtext'], "type"=>$fields[$fieldExistFlag]['type'], "validation"=>$fields[$fieldExistFlag]['validation'], "options"=>$fields[$fieldExistFlag]['options'], "order"=>$fields[$fieldExistFlag]['order']); }else{ if($fieldid=='lastname' || $fieldid=='email') { $enabled =1; $required =1; } else if($fieldid=='captcha'){ $required =1; } $fieldData=array("fieldid"=>$fieldid, "fieldname"=>$fieldsmasterproperties['fieldname'], "show"=>$enabled, "required"=>$required, "showtext"=>$fieldsmasterproperties['defaulttext'], "type"=>"", "validation"=>"", "options"=>"", "order"=>""); } $pos=strpos($fieldsmasterproperties['fieldid'], "customfield"); ?>
checked="checked" disabled="disabled" type="checkbox" id="_show" name="_show" size="30" class="custom_fld" rel=""> 18 ) :?> disabled="disabled" checked="checked" type="checkbox" disabled="disabled" id="_require" name="_require" size="30"> disabled="disabled" > disabled="disabled" type="text" id="_text" name="_text" value=""> value="select" value="textarea" value="captcha" value="text" > disabled="disabled" size="6" readonly="readonly" type="text" id="_typehiddentext" name="_typehiddentext" value="Select" value="Textarea" value="Captcha" value="Text box" > value="email" value="none" > disabled="disabled" size="6" readonly="readonly" type="text" id="_validationhidden" name="_validationhidden" value="Email Id" value="None" > $configType; //echo "
";print_r($configTypeName[0]->opportunityTypeName		);echo "
"; $selectedConfig = $selectedConfigdata['awp_'.$configType.'_selected']; //echo "
";print_r($configDatas);echo "
"; echo ''; if($selectedConfigName=="" && $configType!="leadSource"){ $selectedConfigName=$configTypeName[0]->name; } //if($configType=="leadSource"){$selectedConfigName="Select One";} echo ''; } } } else if(($fieldData['type']=="select")||($fieldData['type']=="radio")||($fieldData['type']=="checkbox")){?>

+Add Another Custom Field

type="submit" name="awp_contactform_settings" id="awp_contactform_settings" class="button-primary" value="" />

loadscripts(); //$this->loadstyles(); add_action('wp_footer', abwpExternalScripts); } return $posts; } /** * Load the CSS files */ function loadstyles() { } /** * Load the JS files */ function loadscripts() { // add_action('wp_footer', abwpExternalScripts); } function getAllCountryList(){ $awp_services_obj=new AWPAPIServices(); $countrylist = $awp_services_obj->getAllCountries(); return $countrylist; } function getNewsletterCategory(){ $awp_services_obj=new AWPAPIServices(); $category = $awp_services_obj->getTargetListcategory(); return $category; } } /* * Save Contact Status, Contact Type and Contact Priority * */ function contactOptions($save) { if(_isCurl()) { $lead_status=array(); $lead_type=array(); $lead_source=array(); $lead_rank=array(); //$contactConfigData = getAllContactConfigData(); $contactConfigData = getContactConfigData(); if($contactConfigData == ''){ echo ''; } if(isset($contactConfigData->leadStatuses)){ foreach ($contactConfigData->leadStatuses as $leadStatus){ if($leadStatus->disabled !='Y'){ array_push($lead_status, $leadStatus); } } } if(isset($contactConfigData->leadTypes)){ foreach ($contactConfigData->leadTypes as $leadType){ if($leadType->disabled !='Y'){ array_push($lead_type, $leadType); } } } if(isset($contactConfigData->leadSources)){ foreach ($contactConfigData->leadSources as $leadSource){ if($leadSource->disabled !='Y'){ array_push($lead_source, $leadSource); } } } if(isset($contactConfigData->leadRanks)){ foreach ($contactConfigData->leadRanks as $leadRank){ if($leadRank->disabled !='Y'){ array_push($lead_rank, $leadRank); } } } //$lead_assignee = $contactConfigData->assigneesList; $assignees = getAllEmployeesAndTeams(); $empAssignees = $assignees->employeeData; $teamAssignees = $assignees->teamData; foreach($empAssignees as $emp){ $assigneeObj = new stdClass(); $assigneeObj->assigneeName = $emp->fullName; $assigneeObj->assigneeObjectId = APPTIVO_EMPLOYEE_OBJECT_ID; $assigneeObj->assigneeObjectRefId = $emp->employeeId; $lead_assignee[] = $assigneeObj; } foreach($teamAssignees as $team){ $assigneeObj = new stdClass(); $assigneeObj->assigneeName = $team->name; $assigneeObj->assigneeObjectId = APPTIVO_TEAM_OBJECT_ID; $assigneeObj->assigneeObjectRefId = $team->teamId; $lead_assignee[] = $assigneeObj; } $contact_config = array("leadStatus"=>$lead_status,"leadType"=>$lead_type,"leadSource"=>$lead_source,'leadAssignee'=>$lead_assignee,'leadRank'=>$lead_rank); $contact_configDatas = json_encode($contact_config); $_SESSION['contact_config'] = $contact_configDatas; } if($save=='save'){ check_option('awp_contact_configdata',$contact_configDatas); } return $contact_configDatas; } function getContactFirstConfigData($leadType,$leadSource,$leadStatus,$checkleadRank,$contactForm) { $firstConfig = get_option("awp_contact_configdata"); $firstConfig = json_decode($firstConfig); $getConfig=get_option('awp_contactforms'); for($i=0;$ileadType as $leadType) { if($formConfig["awp_leadType_selected"]==$leadType->opportunityTypeId) { echo ''; echo ''; break; } } } elseif($leadSource=="0") { foreach ($firstConfig->leadSource as $leadSource) { if($formConfig["awp_leadSource_selected"]==$leadSource->lookupCode) { echo ''; echo ''; break; } } } elseif($leadStatus=="0") { foreach ($firstConfig->$leadStatus as $leadStatus) { if($formConfig["awp_leadStatus_selected"]==$leadStatus->lookupCode) { echo ''; echo ''; break; } } } elseif($leadRank=="0") { foreach ($firstConfig->$leadRank as $leadRank) { if($formConfig["awp_leadRank_selected"]==$leadRank->lookupCode) { echo ''; echo ''; break; } } } } add_action("admin_footer", "apptivo_business_contact_assignee_validation"); function apptivo_business_contact_assignee_validation() { ?>