function getAllQuestionsAccountType($account_post_val, $param) { global $QuestionService; global $AccountTypeToGenderService; // global $BOL_AvatarService_inst; global $QUESTION_PRESENTATION_RANGE; global $QUESTION_PRESENTATION_BIRTHDATE; global $QUESTION_PRESENTATION_AGE; global $QUESTION_PRESENTATION_DATE; global $Userservice; global $language; $app = \Slim\Slim::getInstance(); $app->response->headers->set('Content-Type', 'application/json'); $app->response->setStatus(200); //Lang Call Start $hammu_lang_id = $app->request()->params("lang_id"); if (!empty($hammu_lang_id)) { getCurrentLanguages($hammu_lang_id); } //Lang Call end $fields = $param["fields"]; $accountType = $AccountTypeToGenderService->getAccountType($account_post_val); $questionNames = array(); $questionNames[] = "sex"; foreach ($QuestionService->findSignUpQuestionsForAccountType($accountType) as $question) { $questionNames[] = $question['name']; } $questionList = $QuestionService->findQuestionByNameList($questionNames); $sectionNameList = array(); foreach ($questionList as $question) { if (!in_array($question->sectionName, $sectionNameList)) { $sectionNameList[] = $question->sectionName; } } $sectionList = $QuestionService->findSectionBySectionNameList($sectionNameList); usort($questionList, function ($a, $b) use($sectionList) { $sectionNameA = $a->sectionName; $sectionNameB = $b->sectionName; if ($sectionNameA === $sectionNameB) { return (int) $a->sortOrder < (int) $b->sortOrder ? -1 : 1; } if (!isset($sectionList[$sectionNameA]) || !isset($sectionList[$sectionNameB])) { return 1; } return (int) $sectionList[$sectionNameA]->sortOrder < (int) $sectionList[$sectionNameB]->sortOrder ? -1 : 1; }); $questionOptions = $QuestionService->findQuestionsValuesByQuestionNameList($questionNames); $questions = $category = array(); foreach ($questionList as $question) { if (in_array($question->name, $fields)) { $custom = json_decode($question->custom, true); $value = null; switch ($question->presentation) { case $QUESTION_PRESENTATION_RANGE: $value = '18-33'; break; case $QUESTION_PRESENTATION_BIRTHDATE: case $QUESTION_PRESENTATION_AGE: case $QUESTION_PRESENTATION_DATE: $value = date('Y-m-d H:i:s', strtotime('-18 year')); break; } if (!isset($category[$question->sectionName])) { $category[$question->sectionName] = array('category' => $question->sectionName, 'label' => $QuestionService->getSectionLang($question->sectionName)); } $questions[] = array('name' => $question->name, 'label' => $QuestionService->getQuestionLang($question->name), 'presentation' => $question->name == 'googlemap_location' ? $question->name : $question->presentation, 'options' => formatOptionsForQuestion($question->name, $questionOptions)); } } return $questions; }
function getallquestions($param) { global $QuestionService; global $AccountTypeToGenderService; global $BOL_AvatarService_inst; global $QUESTION_PRESENTATION_RANGE; global $QUESTION_PRESENTATION_BIRTHDATE; global $QUESTION_PRESENTATION_AGE; global $QUESTION_PRESENTATION_DATE; global $Userservice; $app = \Slim\Slim::getInstance(); $app->response->headers->set('Content-Type', 'application/json'); $app->response->setStatus(200); $fields = $param["fields"]; $user_id = $param["user_id"]; if (empty($user_id)) { $return_data = array("message" => "Please provide User id!", "status" => "false"); $app->response->setBody(json_encode($return_data)); } $user = $Userservice->findUserById($user_id); if (!empty($user)) { $account = $user->getAccountType(); if ($account == "8cc28eaddb382d7c6a94aeea9ec029fb") { // $sex = "lady"; $account_type = 2; } else { $account_type = 1; //$sex = "gentleman"; } $accountType = $AccountTypeToGenderService->getAccountType($account_type); $questionNames = array(); $questionNames[] = "sex"; foreach ($QuestionService->findSignUpQuestionsForAccountType($accountType) as $question) { $questionNames[] = $question['name']; } $questionList = $QuestionService->findQuestionByNameList($questionNames); $sectionNameList = array(); foreach ($questionList as $question) { if (!in_array($question->sectionName, $sectionNameList)) { $sectionNameList[] = $question->sectionName; } } $sectionList = $QuestionService->findSectionBySectionNameList($sectionNameList); usort($questionList, function ($a, $b) use($sectionList) { $sectionNameA = $a->sectionName; $sectionNameB = $b->sectionName; if ($sectionNameA === $sectionNameB) { return (int) $a->sortOrder < (int) $b->sortOrder ? -1 : 1; } if (!isset($sectionList[$sectionNameA]) || !isset($sectionList[$sectionNameB])) { return 1; } return (int) $sectionList[$sectionNameA]->sortOrder < (int) $sectionList[$sectionNameB]->sortOrder ? -1 : 1; }); $questionOptions = $QuestionService->findQuestionsValuesByQuestionNameList($questionNames); $questions = $category = array(); foreach ($questionList as $question) { if (in_array($question->name, $fields)) { $custom = json_decode($question->custom, true); $value = null; switch ($question->presentation) { case $QUESTION_PRESENTATION_RANGE: $value = '18-33'; break; case $QUESTION_PRESENTATION_BIRTHDATE: case $QUESTION_PRESENTATION_AGE: case $QUESTION_PRESENTATION_DATE: $value = date('Y-m-d H:i:s', strtotime('-18 year')); break; } if (!isset($category[$question->sectionName])) { $category[$question->sectionName] = array('category' => $question->sectionName, 'label' => $QuestionService->getSectionLang($question->sectionName)); } $questions[] = array('name' => $question->name, 'label' => $QuestionService->getQuestionLang($question->name), 'presentation' => $question->name == 'googlemap_location' ? $question->name : $question->presentation, 'options' => formatOptionsForQuestion($question->name, $questionOptions), 'value' => $value, 'userSelectedValue' => renderQuestion($user_id, $question->name), 'userSelectedLabel' => renderQuestion($user_id, $question->name, true), 'required' => $question->required); } } if (in_array('avatar', $fields)) { $avatar = $BOL_AvatarService_inst->getAvatarUrl($user_id); // $questions[] = array('name' => "avatar", "userSelectedValue" => $avatar); $questions[] = array('name' => "avatar", 'label' => "Avatar", 'custom' => $custom, 'presentation' => "upload", 'options' => array(), 'value' => null, 'rawValue' => $value, 'userSelectedValue' => $avatar, 'userSelectedLabel' => "Avatar", 'required' => "0"); } return $questions; } }