"; $output .= " "; $output .= addOptionsFromTable("metatype", "mt_sort", "mt_value", "mt_sort", "mt_type = 'service' AND mt_objtype = '' AND mt_objid = '0'" . $metatypeInstallationPhrase, $f_service , ""); $output .= ""; // Display questions of the service acceptance protocol $outputQuestions = ""; $outputText = ""; if ($f_service != "" && $objType != "" && $objId != "") : // Set special database fieldname regarding the generic data container structure $specialDbFieldNameQuestions = "service_acceptance_protocol_questions"; $specialDbFieldNameMailState = "service_acceptance_protocol_mail_state_question"; $specialDbFieldNameText = "service_acceptance_protocol_text"; // Save questions if ($f_act == "saveCustomerServicesAcceptanceProtocol") : // **** Questions **** // Load current questions of the customer $gdcContentQuestions = getFieldValueFromClause("genericdatacontainer", "gdc_content", "gdc_obj_type = '" . $objType . "' AND gdc_obj_id = '" . $objId . "' AND gdc_gen_fieldname = '" . $specialDbFieldNameQuestions . "'"); $currArray = getKeyValueArrayFromString($gdcContentQuestions); // Convert key-value-string to array $currArray[$f_service] = implode(",", $f_question_array); // Implode new questions of the selected service and store to current structure // Get new string of ALL services to store into the database $newContentArray = array(); for ($i = 0; $i < $numOfAllServices; $i++) : if ($currArray[$i] != "") : $newContentArray[] = $i . "=" . $currArray[$i]; endif; endfor; $gdcContentQuestions = implode("|", $newContentArray); // Update or insert questions if (existsEntry("genericdatacontainer",array("gdc_obj_type",$objType,"gdc_obj_id",$objId,"gdc_gen_fieldname",$specialDbFieldNameQuestions))) : updateStmt("genericdatacontainer","gdc_obj_type",$objType,array("gdc_content", $gdcContentQuestions),"gdc_obj_id = '" . $objId . "' AND gdc_gen_fieldname = '" . $specialDbFieldNameQuestions . "'"); else : insertStmt("genericdatacontainer", array("gdc_obj_type", $objType, "gdc_obj_id", $objId, "gdc_gen_fieldname", $specialDbFieldNameQuestions, "gdc_content", $gdcContentQuestions)); endif; // **** Mail state for questions **** // Load current mail states of the customer $gdcContentMails = getFieldValueFromClause("genericdatacontainer", "gdc_content", "gdc_obj_type = '" . $objType . "' AND gdc_obj_id = '" . $objId . "' AND gdc_gen_fieldname = '" . $specialDbFieldNameMailState . "'"); $currArray = getKeyValueArrayFromString($gdcContentMails); // Convert key-value-string to array $currArray[$f_service] = implode(",", $f_mail_array); // Implode new questions of the selected service and store to current structure // Get new string of ALL services to store into the database $newContentArray = array(); for ($i = 0; $i < $numOfAllServices; $i++) : if ($currArray[$i] != "") : $newContentArray[] = $i . "=" . $currArray[$i]; endif; endfor; $gdcContentQuestions = implode("|", $newContentArray); // Update or insert questions if (existsEntry("genericdatacontainer",array("gdc_obj_type",$objType,"gdc_obj_id",$objId,"gdc_gen_fieldname",$specialDbFieldNameMailState))) : updateStmt("genericdatacontainer","gdc_obj_type",$objType,array("gdc_content", $gdcContentQuestions),"gdc_obj_id = '" . $objId . "' AND gdc_gen_fieldname = '" . $specialDbFieldNameMailState . "'"); else : insertStmt("genericdatacontainer", array("gdc_obj_type", $objType, "gdc_obj_id", $objId, "gdc_gen_fieldname", $specialDbFieldNameMailState, "gdc_content", $gdcContentQuestions)); endif; // **** Text **** $gdcContentTexts = getFieldValueFromClause("genericdatacontainer", "gdc_content", "gdc_obj_type = '" . $objType . "' AND gdc_obj_id = '" . $objId . "' AND gdc_gen_fieldname = '" . $specialDbFieldNameText . "'"); $currArray = getKeyValueArrayFromString($gdcContentTexts); // Convert key-value-string to array $currArray[$f_service] = $f_text; // Implode new text of the selected service and store to current structure // Get new string of ALL services to store into the database $newContentArray = array(); for ($i = 0; $i < $numOfAllServices; $i++) : if ($currArray[$i] != "") : $newContentArray[] = $i . "=" . $currArray[$i]; endif; endfor; $gdcContentTexts = implode("|", $newContentArray); // Update or insert text if (existsEntry("genericdatacontainer",array("gdc_obj_type",$objType,"gdc_obj_id",$objId,"gdc_gen_fieldname",$specialDbFieldNameText))) : updateStmt("genericdatacontainer","gdc_obj_type",$objType,array("gdc_content", $gdcContentTexts),"gdc_obj_id = '" . $objId . "' AND gdc_gen_fieldname = '" . $specialDbFieldNameText . "'"); else : insertStmt("genericdatacontainer", array("gdc_obj_type", $objType, "gdc_obj_id", $objId, "gdc_gen_fieldname", $specialDbFieldNameText, "gdc_content", $gdcContentTexts)); endif; endif; // **** Prepare output questions **** // (Re-)Load current questions and mail states of the customer $gdcContentQuestions = getFieldValueFromClause("genericdatacontainer", "gdc_content", "gdc_obj_type = '" . $objType . "' AND gdc_obj_id = '" . $objId . "' AND gdc_gen_fieldname = '" . $specialDbFieldNameQuestions . "'"); $gdcContentMails = getFieldValueFromClause("genericdatacontainer", "gdc_content", "gdc_obj_type = '" . $objType . "' AND gdc_obj_id = '" . $objId . "' AND gdc_gen_fieldname = '" . $specialDbFieldNameMailState . "'"); $i = ""; // Init $outputQuestions .= "\n"; if ($gdcContentQuestions != "") : // Split content to get the questions of the current selected service // E.g.: "0=Q1,Q2,Q3|1=Q1,Q2,Q3,Q4,Q5|2=Q1..." => x(0) = Q1,Q2,Q3, x(1) = Q1,Q2,Q3,Q4,Q5, ... // [=> 0=Q1,Q2,Q3 => Service "0" (= Lieferung) is mapped to the questions] $f_question_array = getKeyValueArrayFromString($gdcContentQuestions); $f_question_string = $f_question_array[$f_service]; // Take the questions (array) of the current service $f_mail_array = getKeyValueArrayFromString($gdcContentMails); $f_mail_string = $f_mail_array[$f_service]; // Take the mail states (array) of the questions of the current service if ($f_question_string != "") : $f_question_array = spliti(",", $f_question_string); $f_question_array_len = count($f_question_array); $f_mail_array = spliti(",", $f_mail_string); $f_f_mail_array_len = count($f_mail_array); if ($f_question_array_len > 0) : for ($i = 0; $i < $f_question_array_len; $i++) : $outputQuestions .= "\n"; $outputQuestions .= ""; $outputQuestions .= ""; $outputQuestions .= ""; $outputQuestions .= "\n"; endfor; endif; endif; endif; if ($i == "") : $i = 1; else : $i++; endif; $outputQuestions .= "\n"; $outputQuestions .= "\n"; $outputQuestions .= "\n"; $outputQuestions .= "\n"; $outputQuestions .= "
" . ($i + 1) . ". "; $outputQuestions .= ""; $outputQuestions .= ""; $outputQuestions .= ""; $outputQuestions .= "
" . $i . ". \n"; $outputQuestions .= ""; $outputQuestions .= ""; $outputQuestions .= ""; $outputQuestions .= "
\n"; // **** Prepare output text **** // (Re-)Load current text of the customer $gdcContentText = getFieldValueFromClause("genericdatacontainer", "gdc_content", "gdc_obj_type = '" . $objType . "' AND gdc_obj_id = '" . $objId . "' AND gdc_gen_fieldname = '" . $specialDbFieldNameText . "'"); $f_text_array = getKeyValueArrayFromString($gdcContentText); $f_text = $f_text_array[$f_service]; // Take the text of the current service $outputText .= ""; $outputText .= " "; $outputText .= " "; $outputText .= " "; $outputText .= "
"; $outputText .= " "; $outputText .= "
"; endif; // Only for output if ($objId != "" && ($objType == "cs" || $objType == "cr")) : $cmpId = getFieldValueFromId("customer", "cs_id", $objId, "cmp_id"); $tmpFields = getFieldsValueFromId("company","cmp_id",$cmpId,array("cmp_comp","cmp_comp2")); $title = $tmpFields[0] . " " . $tmpFields[1]; endif; ?> <?php echo $pageTitel ?>