header("Content-Type: application/json"); $answer_id = isset($_POST['answer_id']) ? (int) $_POST['answer_id'] : null; if ($answer_id && $question_model->is_provider_answer($provider_id, $answer_id)) { $question_model->delete_answer($answer_id); $result = array('success' => true, 'answer_id' => $answer_id); } else { $result = array('success' => false, 'error' => 'answer_id is null'); } echo json_encode($result); die; } else { if ($action == 'get_helps') { $question_id = isset($_POST['question_id']) ? (int) $_POST['question_id'] : null; if ($question_id && $question_model->is_provider_question($provider_id, $question_id)) { $result = ''; $helps = $question_model->get_helps($question_id); if (count($helps) > 0) { foreach ($helps as $help) { $help_status = $help['help_status']; $result .= "<div id='help_" . $help['help_id'] . "' style='margin-bottom: 5px;'>" . "<input type='text' name='answers[]' value=" . $help['help'] . " class='text ui-widget-content ui-corner-all' style='margin: 0px; background: #ededed; width: 83%; display: inline;' disabled />" . "<select class='ui-widget-content ui-corner-all' style='width: 88%; background: #ededed; display: inline;'><option>" . $HELP_STATUS_ARRAY[$help_status] . "</option></select>" . "<nobr style='float: right; margin-top: -7px;'>[ <a href='#' onclick='javascript:delete_help(" . $help['help_id'] . "); return false;' style='text-decoration: none; color: red; font-weight: bold;'>x</a> ]</nobr>" . "<br /></div>\n <div class='help_status_x' style='margin-top: -10px;'>\n <label for='x' id='x_label' style='display: inline;'>X: </label><input type='text' value=" . $help['X'] . " class='text ui-widget-content ui-corner-all' style='width: 100px; display: inline;'>\n </div>"; } } else { $result = 'Нет подсказок'; } } echo $result; die; } else { if ($action == 'delete_help') { header("Content-Type: application/json"); $help_id = isset($_POST['help_id']) ? (int) $_POST['help_id'] : null;