<?php

$jQuery = 1;
$jQuery_chosen = 1;
$currentSection = 'admin';
require '../includes/_header.php';
adminHeadline('Upload Competition Results &amp; Scrambles');
$scripts = new WCAClasses\WCAScripts();
$scripts->add('data_upload_help.js');
print $scripts->getHTMLAll();
// create form structure
$form = new WCAClasses\FormBuilder("results-submission", array('method' => 'POST', 'enctype' => 'multipart/form-data'));
$form->addEntity(new WCAClasses\FormBuilderEntities\Markup("<fieldset><legend>Upload Results &amp; Scrambles</legend>"));
// competition to upload JSON for
$competitions_query = "SELECT id, name, countryId\n                       FROM Competitions\n                       ORDER BY (STR_TO_DATE(CONCAT(year,',',month,',',day),'%Y,%m,%d') BETWEEN DATE_SUB(NOW(), INTERVAL 7 DAY) AND DATE_ADD(NOW(), INTERVAL 7 DAY)) DESC,\n                          year DESC, month DESC, day DESC\n                       ";
$competitions = $wcadb_conn->dbQuery($competitions_query);
$options = array();
foreach ($competitions as $competition) {
    $options[$competition->id] = $competition->name . " | " . $competition->id . " | " . $competition->countryId;
}
$competition_element = new WCAClasses\FormBuilderEntities\Select("competitionId", $options);
$competition_element->label("Competition");
$form->addEntity($competition_element);
// competition data area
$form->addEntity(new WCAClasses\FormBuilderEntities\Markup("<div id='notice_area' style='clear: both;'></div>"));
$form->addEntity(new WCAClasses\FormBuilderEntities\Markup("<div class='thick-outlined'>"));
// json file upload element
$file_element = new WCAClasses\FormBuilderEntities\Input("json", "file");
$file_element->attribute("accept", ".json")->label("Select JSON File to Import")->validator("");
$form->addEntity($file_element);
// submit button
<?php

#----------------------------------------------------------------------
#   Initialization and page contents.
#----------------------------------------------------------------------
$currentSection = 'admin';
require '../includes/_header.php';
require '../includes/_check.php';
analyzeChoices();
adminHeadline('Check results');
$scripts = new WCAClasses\WCAScripts();
$scripts->add('check_results_help.js');
print $scripts->getHTMLAll();
showDescription();
showChoices();
if ($chosenShow) {
    switch ($chosenWhat) {
        case '':
            # Run them all!
        # Run them all!
        case 'individual':
            checkIndividually();
            if ($chosenWhat != '') {
                break;
            }
        case 'ranks':
            checkRelatively();
            if ($chosenWhat != '') {
                break;
            }
        case 'similar':
?><!doctype html><html lang="en">
<head>
<title>World Cube Association - Official Results</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="WCA Website Team" />
<meta name="description" content="Official World Cube Association Competition Results" />
<meta name="keywords" content="rubik's cube,puzzles,competition,official results,statistics,WCA" />
<link rel="shortcut icon" href="<?php print pathToRoot(); ?>images/wca.ico" />

<?php

$jQuery = true; // For bootstrap.

/* Deal with scripts here, for now */
$scripts = new WCAClasses\WCAScripts();
if(isset($jQuery) && $jQuery) {
  $scripts->add('//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js');
}
if(isset($jQueryUI) && $jQueryUI) {
  $scripts->add('//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js');
}
if(!isset($is_admin) || !$is_admin) {
  $scripts->add('ga.js');
}
if(isset($mapsAPI) && $mapsAPI) {
  $maps_settings = $config->get("maps");
  $scripts->add('https://maps.googleapis.com/maps/api/js?v=3.17&amp;key='.($maps_settings['api_key']).'&amp;sensor=false&amp;libraries=places');
  $scripts->add('markerclusterer_compiled.js');
  $scripts->add('oms.js');
}