*/ require_once AWP_LIB_DIR . '/Plugin.php'; class AWP_Cases extends AWP_Base { function &instance() { static $instances = array(); if (!isset($instances[0])) { $class = __CLASS__; $instances[0] = & new $class(); } return $instances[0]; } function __construct() { $this->_plugin_activated = false; $settings=array(); $this->_plugin_activated=false; $settings=get_option("awp_plugins"); if(get_option("awp_plugins")!=="false"){ if($settings["cases"]) $this->_plugin_activated=true; } $this->fields = array( array('fieldid' => 'subject','fieldname' => 'Subject','defaulttext' => 'Subject','must_require'=>1,'must'=>1,'showorder' => '1','validation' => 'text','fieldtype' => 'text'), array('fieldid' => 'description','fieldname' => 'Description','defaulttext' => 'Description','must_require'=>0,'must'=>0,'showorder' => '2','validation' => 'textarea','fieldtype' => 'textarea'), array('fieldid' => 'priority','fieldname' => 'Priority','defaulttext' => 'Priority','must_require'=>1,'must'=>1,'showorder' => '3','validation' => 'text','fieldtype' => 'select'), array('fieldid' => 'firstname','fieldname' => 'First Name','defaulttext' => 'First Name','must_require'=>1,'must'=>1,'showorder' => '4','validation' => 'text','fieldtype' => 'text'), array('fieldid' => 'lastname','fieldname' => 'Last Name','defaulttext' => 'Last Name','must_require'=>1,'must'=>1,'showorder' => '5','validation' => 'text','fieldtype' => 'text'), array('fieldid' => 'email','fieldname' => 'Email','defaulttext' => 'Email','showorder' => '6','must_require'=>1,'must'=>1,'validation' => 'email','fieldtype' => 'text'), array('fieldid' => 'phone','fieldname' => 'Telephone Number','defaulttext' => 'Telephone Number','must_require'=>0,'must'=>0,'showorder' => '7','validation' => 'phonenumber','fieldtype' => 'text'), array('fieldid' => 'type','fieldname' => 'Type','defaulttext' => 'Type','must_require'=>1,'must'=>1,'showorder' => '8','validation' => 'text','fieldtype' => 'select'), array('fieldid' => 'captcha','fieldname' => 'Captcha','defaulttext' => 'Captcha','must_require'=>1,'showorder' => '9','validation' => 'text','fieldtype' => 'captcha'), array('fieldid' => 'customfield1','fieldname' => 'Custom Field 1','defaulttext' => 'Custom Field1','showorder' => '10','validation' => '','fieldtype' => 'select'), array('fieldid' => 'customfield2','fieldname' => 'Custom Field 2','defaulttext' => 'Custom Field2','showorder' => '11','validation' => '','fieldtype' => 'select'), array('fieldid' => 'customfield3','fieldname' => 'Custom Field 3','defaulttext' => 'Custom Field3','showorder' => '12','validation' => '','fieldtype' => 'select'), array('fieldid' => 'customfield4','fieldname' => 'Custom Field 4','defaulttext' => 'Custom Field4','showorder' => '13','validation' => '','fieldtype' => 'radio'), array('fieldid' => 'customfield5','fieldname' => 'Custom Field 5','defaulttext' => 'Custom Field5','showorder' => '14','validation' => '','fieldtype' => 'checkbox') ); $this->validations = array( array('validationLabel' => 'None','validation' => 'none'), array('validationLabel' => 'Email ID','validation' => 'email'), array('validationLabel' => 'Number','validation' => 'number') ); $this->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') ); } /** * Runs plugin */ function run() { if($this->_plugin_activated){ add_shortcode('apptivo_cases','apptivo_business_cases'); } } function settings(){ //Theme Templates $themetemplates = get_awpTemplates(TEMPLATEPATH.'/cases','Plugin'); $plugintemplates=$this->get_plugin_templates(); arsort($plugintemplates); if(isset($_POST['awp_cases_settings'])): //Cases Form Propertieds. //template Type& Template Layout if($_POST['awp_cases_templatetype']=="awp_plugin_template"): $templatelayout=$_POST['awp_cases_plugintemplatelayout']; else: $templatelayout=$_POST['awp_cases_themetemplatelayout']; endif; $casesform_properties=array( 'tmpltype' =>$_POST['awp_cases_templatetype'], 'layout' =>$templatelayout, 'confmsg' => stripslashes($_POST['awp_cases_confirmationmsg']), 'confirm_msg_page' => $_POST['awp_cases_confirm_msg_page'], 'confirm_msg_pageid' => $_POST['awp_cases_confirmmsg_pageid'], 'css' => stripslashes($_POST['awp_cases_customcss']), 'submit_button_type' => $_POST['awp_cases_submit_type'], 'submit_button_val' => $_POST['awp_cases_submit_value'] ); //New Custom fields $stack = array(); $addtional_custom = array(); $addtional_order = 15; for($i=6;$i<20;$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_cases',$stack); endif; //General Cases form fields //For Additional custom fields. $addtional_custom = get_option('awp_addtional_custom_cases'); $master_field = array(); if(!empty($addtional_custom)): $master_field = array_merge($this->fields,$addtional_custom); else: $master_field = $this->fields; endif; $casesformfields=array(); foreach( $master_field 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($fieldsmasterproperties['must']) { $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){ $casefield=$this->createformfield_array($fieldid,$displaytext,$required,$_POST[$fieldid.'_type'],$_POST[$fieldid.'_validation'],$_POST[$fieldid.'_options'],$displayorder); array_push($casesformfields, $casefield); } } $cases_fields_properties = array('properties'=>$casesform_properties,'fields'=>$casesformfields); update_option('absp_cases_form_fields',$cases_fields_properties); endif; $absp_cases_fields_properties = get_option('absp_cases_form_fields'); $fields=$absp_cases_fields_properties['fields']; //Cases Fields $formproperties=$absp_cases_fields_properties['properties'];//Case Properties echo '

Apptivo Cases Form

'; ?> _plugin_activated) { echo "Cases form is currently disabled. Please enable this in Apptivo General Settings."; } echo awp_flow_diagram('cases',1); ?>
>

0 ) : ?>
checked="checked" /> />


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

Style class provided here will override template style. Please refer Apptivo plugin help section for class name to be used.

checked="checked" /> />

fields,$addtional_custom); else: $master_field = $this->fields; endif; ?>

Cases Form Fields

Select and configure list of fields from below table to show in your cases form.
$fieldid, "fieldname"=>$fieldsmasterproperties['fieldname'], "show"=>$enabled, "required"=>$fields[$fieldExistFlag]['required'], "showtext"=>$fields[$fieldExistFlag]['showtext'], "type"=>$fields[$fieldExistFlag]['type'], "must_require"=> $fieldsmasterproperties['must_require'], "validation"=>$fields[$fieldExistFlag]['validation'], "options"=>$fields[$fieldExistFlag]['options'], "order"=>$fields[$fieldExistFlag]['order']); }else{ $fieldData=array("fieldid"=>$fieldid, "fieldname"=>$fieldsmasterproperties['fieldname'], "show"=>$enabled, "required"=>$required, "showtext"=>$fieldsmasterproperties['defaulttext'], "type"=> $fieldsmasterproperties['fieldtype'], "must_require"=> $fieldsmasterproperties['must_require'], "validation"=>"", "options"=>"", "order"=>""); } $pos=strpos($fieldsmasterproperties['fieldid'], "customfield"); ?>
13 ) : ?> checked="checked" disabled="disabled" type="checkbox" id="_show" name="_show" size="30" onclick="casesform_enablefield('')"> checked="checked" disabled="disabled" type="checkbox" id="_require" name="_require" size="30"> disabled="disabled" > disabled="disabled" type="text" id="_text" name="_text" value=""> disabled="disabled" size="6" readonly="readonly" type="text" id="_typehiddentext" name="_typehiddentext" value="" > value="email" value="phonenumber" value="none" > disabled="disabled" size="6" readonly="readonly" type="text" id="_validationhidden" name="_validationhidden" value="Email Id" value="Phone Number" value="None" >

+Add Another Custom Field

_plugin_activated): echo 'disabled="disabled"'; endif; ?> type="submit" name="awp_cases_settings" id="awp_cases_settings" class="button-primary" value="" />

'Template Name' ); $templates = array(); $dir_contact = AWP_CASES_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; } }