//require_login();
if ($action == 'excel') {
print_table_to_excel(nabor_table($tab, $tab2, $fid, $facid, $planid), 6);
exit();
}
$PAGE->set_context(context_system::instance());
$PAGE->requires->js('/lib/jquery/jquery-3.1.0.min.js', true);
$PAGE->requires->js('/blocks/contest/js/contest.js', true);
$page = 'Список участников';
$title = $page;
$PAGE->navbar->add($page);
$PAGE->set_pagelayout('report');
$PAGE->set_url('/blocks/rss_client/editfeed.php');
$PAGE->set_title('Список участников');
$PAGE->set_heading($title);
echo $OUTPUT->header();
//echo html_writer::table(participants_table());
$scriptname = "participants.php";
echo listbox_regions($scriptname, $regionid);
$fromcontext = context_block::instance(63);
if(isloggedin() && has_capability('block/contest_participants:view', $fromcontext))
$flag = true;
else
$flag = false;
echo html_writer::table(participants_short_table($regionid, $flag));
echo '
';
echo '';
echo '
';
echo $OUTPUT->footer();
function listbox_regions($scriptname, $regionid)
{
global $DB, $OUTPUT;
$regions_menu = array();
$regions = $DB->get_records_sql("select * from mdl_contest_regions");
if($regions){
foreach ($regions as $region){
$regions_menu[$region->id] = $region->name;
}
$ret = '' . 'Субъект Российской Федерации' . ': | ';
$ret .= $OUTPUT->single_select($scriptname, 'regionid', $regions_menu, $regionid, null, 'switchregion');
$ret .= ' |
';
}
return $ret;
}
function participants_short_table($regionid, $flag) {
global $DB, $USER, $CFG;
$table = new html_table();
if($flag == true){
$sql = "SELECT * FROM mdl_contest_participants where regions=$regionid order by userid";
$table->head = array ('Образовательная организация', 'Заявление', 'Конкурсные материалы', '', '', 'Одобрить');
$table->align = array ('left','center','center','center','center','center');
}else{
$sql = "SELECT * FROM mdl_contest_participants where regions=$regionid and approve=1 order by userid";
$table->head = array ('Образовательная организация');
$table->align = array ('left');
}
if($participants = $DB->get_records_sql($sql)){
// $table->size = array ('10%','13%','12%','10%','20%','5%','15%','15%','15%');
$table->data[] = array();
foreach($participants as $participant){
$organization = $participant->organization;
$zayavlenie = $DB->get_record_sql("select * from mdl_files where itemid=$participant->zayavlenie and filename<>'.'");
$zayav_link = "$zayavlenie->filename";
$work = $DB->get_record_sql("select * from mdl_files where itemid=$participant->work and filename<>'.'");
$work_link = "$work->filename";
$zayavka = 'Заявка';
$zayavka = ''.$zayavka.'';
$anketa = 'Анкета';
$anketa = ''.$anketa.'';
if($participant->approve == 1){
$checked='checked';
$action_href = "";
}else{
$checked='';
$action_href = "";
}
if($flag == true){
$table->data[] = array($organization, $zayav_link, $work_link, $zayavka, $anketa, $action_href);
}else{
$table->data[] = array($organization);
}
}
}else{
$table->head = '';
$table->align = '';
echo 'Заявки отсутствуют';
}
return $table;
}
function participants_table() {
global $DB, $USER, $CFG;
$table = new html_table();
$table->head = array ('Субъект РФ', 'Номинация', 'Образовательая организация', 'Телефон', 'ФИО руководителя', 'Конкурсная работа', 'Email', 'Заявление', 'Конкурсные материалы');
$table->align = array ('center','center','center','center','center','center','center','center','center');
// $table->size = array ('10%','13%','12%','10%','20%','5%','15%','15%','15%');
$table->data[] = array();
$sql = "SELECT * FROM mdl_contest_participants order by userid";
if($participants = $DB->get_records_sql($sql)){
foreach($participants as $participant){
$regions = $participant->regions;
$nomination = $participant->nomination;
$organization = $participant->organization;
$phone = $participant->phone;
$fio = $participant->fio;
$workname = $participant->workname;
$email = $participant->email;
$region = $DB->get_record('contest_regions', array('id' => $regions));
$nominationname = $DB->get_record('contest_nomination', array('id' => $nomination));
$zayavlenie = $DB->get_record_sql("select * from mdl_files where itemid=$participant->zayavlenie and filename<>'.'");
$zayav_link = "$zayavlenie->filename";
$work = $DB->get_record_sql("select * from mdl_files where itemid=$participant->work and filename<>'.'");
$work_link = "$work->filename";
$table->data[] = array($region->name, $nominationname->name, $organization, $phone, $fio, $workname, $email, $zayav_link, $work_link);
}
}
return $table;
}
?>