function edit_poll(poll_id) { $("input[name='poll_id']").attr("value", poll_id); $("#new_poll").css("background-color", "transparent"); $("div[name='poll'][class!='active_poll']").css("background-color", "transparent"); $("div[name='poll'][class='active_poll']").css("background-color", "whitesmoke"); $("div[name='poll'][id='poll_"+poll_id+"']").css("background-color", "orange"); // get poll from database $.getJSON( EOT; $jscript .= "\"" . $CONFIG->wwwroot . "mod/koolielu/actions/retrieve_poll.php\","; $jscript .= <<" + poll['questiontext'] + "").appendTo("#poll_results_form"); $("#poll_results_form").html(poll['answerstext']); if (poll['isActive'] == 1) { // show deactivate buton $("#deactivate_area").attr("style", "display:''"); } else { $("#deactivate_area").attr("style", "display:none"); } } else { $("#deactivate_area").attr("style", "display:none"); $("input[name='save_button']").attr("style", "display:''"); $("input[name='activate_button']").attr("style", "display:''"); $("input[name='deactivate_button']").attr("style", "display:none"); $("#poll_results_form").attr("style", "display:none"); $("#poll_edit_form").attr("style", "display:''"); } } ); } function add_poll() { $("#deactivate_area").attr("style", "display:none"); $("#poll_results_form").attr("style", "display:none"); $("input[name='save_button']").attr("style", "display:''"); $("input[name='activate_button']").attr("style", "display:none"); $("input[name='deactivate_button']").attr("style", "display:none"); $("#poll_edit_form").attr("style", "display:''"); $("input[name='poll_id']").attr("value", ""); $("input[name='questiontext']").attr("value", ""); $("textarea[name='variants']").attr("value", ""); $("div[name='poll'][class!='active_poll']").css("background-color", "transparent"); $("div[name='poll'][class='active_poll']").css("background-color", "whitesmoke"); $("#new_poll").css("background-color", "orange"); } EOT; $previous_polls = ""; $existing_polls = get_all_koolielu_polls(); foreach ($existing_polls as $poll) { $answers_total_count = get_data_row("SELECT COUNT(*) AS total FROM {$CONFIG->dbprefix}koolielu_polls_answers WHERE poll_id={$poll->ID}"); $answers_total = " ({$answers_total_count->total})"; if ($poll->isActive == 1) { $previous_polls .= "
ID}\" onclick=\"edit_poll({$poll->ID})\" class=\"active_poll\" style=\"background-color:whitesmoke;cursor:pointer;\">" . $poll->questiontext . $answers_total . "
"; } else { $previous_polls .= "
ID}\" onclick=\"edit_poll({$poll->ID})\" style=\"cursor:pointer\">" . $poll->questiontext . $answers_total . "
"; } } /*translation:Add new poll*/ $left_block = "
". elgg_echo("koolielu:add_new_poll") ."
"; $left_block .= $previous_polls; //$results_block = "
"; $body .= $jscript; /*translation:Polls*/ $body .= "

"; $body .= "
"; $body .= $left_block; $body .= "
"; $body .= "
"; $body .= elgg_view('koolielu/forms/manage_polls'); //$body .= $results_block; $body .= "
"; // Display main admin menu /*translation:Koolielu management*/ page_draw(elgg_echo('koolielu:koolielu_management'),elgg_view_layout("two_column_left_sidebar", '', $body)); ?>