';
// header
//if updatemessage is not empty display the div
if(trim($updatemessage)!=""){
?>
get_case_settings($selectedcasesform);
if( empty($caseform))
{
//echo "Selected form configuration doestn exist.";
}else{
$caseformdetails=$caseform;
}
}
}
if($_POST['delformname']) //Delete Form Name:
{
if(strlen(trim($_POST['delformname'])) != 0)
{
$formname = $_POST['delformname'];
$cases_forms=get_option('awp_casesforms');
$formExists = awp_recursive_array_search($cases_forms,$formname,'name' );
if(isset($formExists))
{
unset($cases_forms[$formExists]);
}
$case_sort_form = array();
foreach($cases_forms as $cases_forms_tosort )
{
array_push($case_sort_form,$cases_forms_tosort);
}
update_option('awp_casesforms', $case_sort_form);
$updatemessage= 'Case Form "'.$formname.'" Deleted Successfully.';
}
}
?>
" . __( 'Cases Form Configuration', 'awp_casesforms' ) . "";
?>
get_case_settings($selectedcasesform);
if(count($caseformdetails)>0){
$selectedcasesform=$caseformdetails[name];
$fields=$caseformdetails[fields];
$formproperties=$caseformdetails[properties];
}
?>
caseAssignee)){
foreach ($configDatas->caseAssignee 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;
}
if(isset($formproperties['case_assignee_name'])){
if($assigne_value->assigneeName == $formproperties['case_assignee_name']){
$case_assignee_name = $assigne_value->assigneeName;
}
}
}
$case_assignee_default_name = $configDatas->caseAssignee[0]->assigneeName;
}
else{
$case_assignee_default_name = '';
}
if(!isset($assignee_employee_list)){
$assignee_employee_list["No Employee"] = '';
}
if(!isset($assignee_team_list)){
$assignee_team_list["No Team"] = '';
}
}
if($case_assignee_name == ""){
$case_assignee_name = $case_assignee_default_name;
}
?>
'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;
}
}
/*
* Save Case Status, Case Type and Case Priority
*
*/
function caseOptions($save)
{
if(_isCurl())
{
$case_status=array();
$case_priority=array();
$case_type=array();
//$casesConfigData = getAllCasesConfigData();
$casesConfigData = getCasesConfigData();
if($casesConfigData == ''){
echo '';
}
if(isset($casesConfigData->statuses)){
foreach ($casesConfigData->statuses as $caseStatus){
if($caseStatus->disabled !='Y'){
$caseStatus->lookupId = $caseStatus->statusId;
$caseStatus->meaning = $caseStatus->statusName;
array_push($case_status, $caseStatus);
}
}
}
if(isset($casesConfigData->priorities)){
foreach ($casesConfigData->priorities as $casePriority){
if($casePriority->disabled !='Y'){
$casePriority->lookupId = $casePriority->id;
$casePriority->meaning = $casePriority->name;
array_push($case_priority, $casePriority);
}
}
}
if(isset($casesConfigData->types)){
foreach ($casesConfigData->types as $caseType){
if($caseType->disabled !='Y'){
$caseType->lookupId = $caseType->typeId;
$caseType->meaning = $caseType->typeName;
array_push($case_type, $caseType);
}
}
}
//$case_assignee = $casesConfigData->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;
$case_assignee[] = $assigneeObj;
}
foreach($teamAssignees as $team){
$assigneeObj = new stdClass();
$assigneeObj->assigneeName = $team->name;
$assigneeObj->assigneeObjectId = APPTIVO_TEAM_OBJECT_ID;
$assigneeObj->assigneeObjectRefId = $team->teamId;
$case_assignee[] = $assigneeObj;
}
//error_log(json_encode($case_assignee));
$case_config = array("caseStatus"=>$case_status,"casePriority"=>$case_priority,"caseType"=>$case_type,'caseAssignee'=>$case_assignee);
$case_configDatas = json_encode($case_config);
}
if($save=='save'){
check_option('awp_cases_configdata',$case_configDatas);
}
return $case_configDatas;
}
/* Get Cases Config Data with default */
function getCasesConfig(){
if(_isCurl()){
$getCasesConfig=getCaseConfigureData();
$autoGenerateCheck=$getCasesConfig->autoGenerate;
$configAssigneeName=$getCasesConfig->assigneeName;
$configAssigneeId=$getCasesConfig->assigneeId;
}
}
function getFirstConfigData($type,$priotity,$status,$caseForm)
{
$firstConfig = get_option("awp_cases_configdata");
$firstConfig = json_decode($firstConfig);
$getConfig=get_option('awp_casesforms');
for($i=0;$i
caseType as $casetype)
{
if($formConfig["awp_caseType_selected"]==$casetype->lookupId)
{
echo '';
echo '';
break;
}
}
}
elseif($priotity=="0")
{
foreach ($firstConfig->casePriority as $casePriority)
{
if($formConfig["awp_casePriority_selected"]==$casePriority->lookupId)
{
echo '';
echo '';
break;
}
}
}
elseif($status=="0")
{
foreach ($firstConfig->caseStatus as $caseStatus)
{
if($formConfig["awp_caseStatus_selected"]==$caseStatus->lookupId)
{
echo '';
echo '';
break;
}
}
}
}
add_action("admin_footer", "apptivo_business_cases_assignee_validation");
function apptivo_business_cases_assignee_validation() {
?>