public static function Copy($ID, $newVoteID) { $ID = intVal($ID); if ($ID <= 0) { return false; } $newVoteID = intVal($newVoteID); if ($newVoteID <= 0) { return false; } $res = CVoteQuestion::GetByID($ID); if (!($arQuestion = $res->Fetch())) { return false; } $arQuestion['VOTE_ID'] = $newVoteID; unset($arQuestion['ID']); $newQuestionID = CVoteQuestion::Add($arQuestion); if ($newQuestionID === false) { return false; } $state = true; $rAnswers = CVoteAnswer::GetList($ID); while ($arAnswer = $rAnswers->Fetch()) { $arAnswer['QUESTION_ID'] = $newQuestionID; unset($arAnswer['ID']); $state = $state && CVoteAnswer::Add($arAnswer) !== false; } if (!$state) { return $state; } CVoteQuestion::Reset($newQuestionID); return $newQuestionID; }
<?php require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/img.php"; global $arrSaveColor; if (CModule::IncludeModule("vote")) { $diameter = intval($_REQUEST["dm"]) > 0 ? intval($_REQUEST["dm"]) : 150; $res = CVoteAnswer::GetList($qid, $by = "s_counter", $order = "desc"); $res->NavStart(1000); $totalRecords = $res->SelectedRowsCount(); $arChart = array(); $color = ""; $sum = 0; while ($arAnswer = $res->Fetch()) { $arChart[] = array("COLOR" => strlen($arAnswer["COLOR"]) > 0 ? TrimEx($arAnswer["COLOR"], "#") : ($color = GetNextRGB($color, $totalRecords)), "COUNTER" => $arAnswer["COUNTER"]); $sum += $arAnswer["COUNTER"]; } // create an image $ImageHandle = CreateImageHandle($diameter, $diameter); imagefill($ImageHandle, 0, 0, imagecolorallocate($ImageHandle, 255, 255, 255)); // drawing pie chart if ($sum > 0) { Circular_Diagram($ImageHandle, $arChart, "FFFFFF", $diameter, $diameter / 2, $diameter / 2); } // displaying of the resulting image ShowImageHeader($ImageHandle); }
} /************** Initial list - Get data ****************************/ $rsData = CVoteEvent::GetList($by, $order, $arFilter, $is_filtered); $rsData = new CAdminResult($rsData, $sTableID); $rsData->NavStart(); /************** Initial list - Navigation **************************/ $lAdmin->NavText($rsData->GetNavPrint(GetMessage("VOTE_PAGES"))); $headers = array(array("id" => "ID", "content" => "ID", "sort" => "s_id", "default" => true), array("id" => "VOTE_USER_ID", "content" => GetMessage("VOTE_USER"), "sort" => "s_vote_user", "default" => true), array("id" => "STAT_SESSION_ID", "content" => GetMessage("VOTE_SESSION"), "sort" => "s_session", "default" => true), array("id" => "IP", "content" => "IP", "sort" => "s_ip", "default" => true), array("id" => "DATE_VOTE", "content" => GetMessage("VOTE_DATE"), "sort" => "s_date", "default" => true), array("id" => "VALID", "content" => GetMessage("VOTE_VALID"), "sort" => "s_valid", "default" => true)); $by = 'c_sort'; $order = 'asc'; $arAllQuestions = array(); $rsQuestions = CVoteQuestion::GetList($VOTE_ID, $by, $order, array(), $is_filtered); while ($arQuestion = $rsQuestions->Fetch()) { $headers[] = array("id" => "Q" . $arQuestion["ID"], "content" => htmlspecialcharsbx($arQuestion["QUESTION"]), "sort" => '', "default" => true); $arAllAnswers = array(); $rsAnswers = CVoteAnswer::GetList($arQuestion["ID"]); while ($arAnswer = $rsAnswers->Fetch()) { $arAllAnswers[$arAnswer['ID']] = $arAnswer; } $arAllQuestions[] = array('ID' => $arQuestion["ID"], 'ANSWERS' => $arAllAnswers); } $lAdmin->AddHeaders($headers); $arrUsers = array(); while ($arRes = $rsData->NavNext(true, "f_")) { $row =& $lAdmin->AddRow($f_ID, $arRes); $row->AddViewField("VALID", $f_VALID == "Y" ? GetMessage("MAIN_YES") : GetMessage("MAIN_NO")); $row->AddViewField("VOTE_USER_ID", "<a title=\"" . GetMessage("VOTE_USER_LIST_TITLE") . "\" href=\"vote_user_list.php?lang=" . LANGUAGE_ID . "&find_id={$f_VOTE_USER_ID}&set_filter=Y\">{$f_VOTE_USER_ID}</a>"); if (CModule::IncludeModule("statistic")) { $row->AddViewField("STAT_SESSION_ID", "<a title=\"" . GetMessage("VOTE_SESSIONU_LIST_TITLE") . "\" href=\"session_list.php?lang=" . LANGUAGE_ID . "&find_id={$f_STAT_SESSION_ID}&set_filter=Y\">{$f_STAT_SESSION_ID}</a>"); } if (strlen($f_TITLE) > 0) {
function Copy($ID, $newVoteID) { $err_mess = CAllVoteQuestion::err_mess() . "<br>Function: Copy<br>Line: "; $ID = intVal($ID); if ($ID <= 0) { return false; } $newVoteID = intVal($newVoteID); if ($newVoteID <= 0) { return false; } $res = CVoteQuestion::GetByID($ID); if (!($arQuestion = $res->Fetch())) { return false; } $arQuestion['VOTE_ID'] = $newVoteID; unset($arQuestion['ID']); $newQuestionID = CVoteQuestion::Add($arQuestion); if ($newQuestionID === false) { return false; } $state = true; $rAnswers = CVoteAnswer::GetList($ID); while ($arAnswer = $rAnswers->GetNext()) { $arAnswer['QUESTION_ID'] = $newQuestionID; unset($arAnswer['ID']); unset($arAnswer['~ID']); $state = $state && CVoteAnswer::Add($arAnswer) !== false; } if (!$state) { return $state; } CVoteQuestion::Reset($newQuestionID); return $newQuestionID; }
********************************************************************/ /******************************************************************** Data ********************************************************************/ require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; if ($message) { echo $message->Show(); } $aMenu = array(array("TEXT" => GetMessage("VOTE_LIST"), "TITLE" => GetMessage("VOTE_QUESTIONS_LIST"), "LINK" => "/bitrix/admin/vote_question_list.php?lang=" . LANGUAGE_ID . "&VOTE_ID=" . $VOTE_ID, "ICON" => "btn_list")); if ($VOTE_RIGHT >= "W" && $ID > 0) { $aMenu[] = array("TEXT" => GetMessage("VOTE_CREATE"), "TITLE" => GetMessage("VOTE_CREATE_NEW_RECORD"), "LINK" => "/bitrix/admin/vote_question_edit.php?VOTE_ID={$VOTE_ID}&lang=" . LANGUAGE_ID, "ICON" => "btn_new"); $aMenu[] = array("TEXT" => GetMessage("VOTE_DELETE"), "TITLE" => GetMessage("VOTE_DELETE_RECORD"), "LINK" => "javascript:if(confirm('" . GetMessage("VOTE_DELETE_RECORD_CONFIRM") . "')) window.location='/bitrix/admin/vote_question_list.php?action=delete&ID={$ID}&VOTE_ID={$VOTE_ID}&" . bitrix_sessid_get() . "&lang=" . LANGUAGE_ID . "';", "ICON" => "btn_delete"); } $context = new CAdminContextMenu($aMenu); $context->Show(); $z = CVoteAnswer::GetList($ID); /************** Table of colors ************************************/ $t_COL = array("00", "33", "66", "99", "CC", "FF"); ?> <div id="ColorPick" style="visibility:hidden;position:absolute;top:0;left:0 "> <table cellspacing="0" cellpadding="1" border="0" bgcolor="#666666"> <tr><td colspan=2> <table cellspacing="1" cellpadding="0" border="0" bgcolor="#FFFFFF"> <?php for ($i = 0; $i < 216; $i++) { $t_R = $i % 6; $t_G = floor($i / 36) % 6; $t_B = floor($i / 6) % 6; $t_curCOL = "#" . $t_COL[$t_R] . $t_COL[$t_G] . $t_COL[$t_B]; print $i % 18 == 0 ? "<tr>" : ""; ?>
<?php require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/img.php"; global $arrSaveColor; if (CModule::IncludeModule("vote")) { $diameter = intval($_REQUEST["dm"]) > 0 ? intval($_REQUEST["dm"]) : 150; $res = CVoteAnswer::GetList($qid, $by = "s_counter", $order = "desc", array("ACTIVE" => "Y"), array("nTopCount" => 1000)); $res->NavStart(1000); $totalRecords = $res->SelectedRowsCount(); $arChart = array(); $color = ""; $sum = 0; while ($arAnswer = $res->Fetch()) { $arChart[] = array("COLOR" => strlen($arAnswer["COLOR"]) > 0 ? TrimEx($arAnswer["COLOR"], "#") : ($color = GetNextRGB($color, $totalRecords)), "COUNTER" => $arAnswer["COUNTER"]); $sum += $arAnswer["COUNTER"]; } // create an image $ImageHandle = CreateImageHandle($diameter, $diameter); imagefill($ImageHandle, 0, 0, imagecolorallocate($ImageHandle, 255, 255, 255)); // drawing pie chart if ($sum > 0) { Circular_Diagram($ImageHandle, $arChart, "FFFFFF", $diameter, $diameter / 2, $diameter / 2); } // displaying of the resulting image ShowImageHeader($ImageHandle); }