ResultManager/subs/part/wizard.php
2019-08-08 16:58:29 +03:00

243 lines
12 KiB
PHP

<?php
/**
* /subs/wizard.php
* @version 1.1
* @desc wizard for easy data input
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
$oid=0;
?>
<div class="selfcenter">
<!-- language, config -->
<span id="wizardDeleteConfirm" style="display: none"><?php echo $lang['delete_confirm'] ?></span>
<span id="wizardCurrentId" style="display: none"><?php echo $_SESSION['id'] ?></span>
<!-- instructions -->
<p><?php echo $lang['wizinst'] ?></p>
<!-- steps -->
<div id="steps">
<form method="POST" class="ajaxform" id="wizform" autocomplete="off">
<input type="hidden" name="new">
<!-- step1/student -->
<div id="step1" class="dropdown selfcenter" style="width: 95%">
<div class="dropdown header">
<span class="number">1</span>
<span><?php echo $lang['wiz_step1'] ?></span>
</div>
<div class="dropdown content" id="step1_content" style="display: block">
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..." ?>" onkeyup="search(this, '#studentSearchNew')">
<ul id="studentSearchNew">
<?php
$sql=$db->prepare("SELECT id, fullname, class FROM users WHERE accesslevel=0 and id<>1 ORDER BY class ASC, fullname ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"radio\" name=\"student\" value=\"".$row['id']."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$row['fullname']." (".$row['class'].")</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
<br>
<br>
<button type="button" onclick="wizardNextStep(this)" style="float: right"><?php echo $lang['proceed'] ?></button>
</div>
</div>
<br>
<!-- step2/contest -->
<div id="step2" class="dropdown selfcenter" style="width: 95%">
<div class="dropdown header">
<span class="number">2</span>
<span><?php echo $lang['wiz_step2'] ?></span>
</div>
<div class="dropdown content" id="step2_content">
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..." ?>" onkeyup="search(this, '#contestSearchNew')">
<ul id="contestSearchNew">
<?php
$sql=$db->prepare("SELECT c.id, c.name_1, c.name_2, s.name_1 AS subject_1, s.name_2 AS subject_2 FROM contests AS c INNER JOIN subjects AS s ON (s.id=c.subject) WHERE c.schoolyear=:sy ORDER BY s.name_1 ASC, s.name_2 ASC, c.name_1 ASC, c.name_2 ASC");
$sql->execute(array(":sy"=>$schoolyear));
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"radio\" name=\"contest\" value=\"".$row['id']."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$row['name_1'].", ".$row['name_2']." (".$row['subject_1'].", ".$row['subject_2'].")</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
<br>
<br>
<button type="button" onclick="wizardPrevStep(this)" style="float: left"><?php echo $lang['back'] ?></button>
<button type="button" onclick="wizardNextStep(this)" style="float: right"><?php echo $lang['proceed'] ?></button>
</div>
</div>
<br>
<!-- step3/phase -->
<div id="step3" class="dropdown selfcenter" style="width: 95%">
<div class="dropdown header">
<span class="number">3</span>
<span><?php echo $lang['wiz_step3'] ?></span>
</div>
<div class="dropdown content" id="step3_content">
<?php
$sql=$db->prepare("SELECT id, name_1, name_2 FROM phases ORDER BY name_1 ASC, name_2 ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<input type=\"radio\" name=\"phase\" value=\"".$row['id']."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$row['name_1'].", ".$row['name_2']."</label>
<br>
";
$oid++;
}
?>
<br>
<br>
<button type="button" onclick="wizardPrevStep(this)" style="float: left"><?php echo $lang['back'] ?></button>
<button type="button" onclick="wizardNextStep(this)" style="float: right"><?php echo $lang['proceed'] ?></button>
</div>
</div>
<br>
<!-- step4/teacher -->
<div id="step4" class="dropdown selfcenter" style="width: 95%">
<div class="dropdown header">
<span class="number">4</span>
<span><?php echo $lang['wiz_step4'] ?></span>
</div>
<div class="dropdown content" id="step4_content">
<button type="button" onclick="wizardSelectMeAsTeacher()"><?php echo $lang['selectme'] ?></button>
<br>
<br>
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..."?>" onkeyup="search(this, '#teacherSearchNew')">
<ul id="teacherSearchNew">
<?php
$sql=$db->prepare("SELECT id, fullname FROM users WHERE id<>0 and accesslevel>0 ORDER BY fullname ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"radio\" name=\"teacher\" value=\"".$row['id']."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$row['fullname']."</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
<br>
<br>
<button type="button" onclick="wizardPrevStep(this)" style="float: left"><?php echo $lang['back'] ?></button>
<button type="button" onclick="wizardNextStep(this)" style="float: right"><?php echo $lang['proceed'] ?></button>
</div>
</div>
<br>
<!-- step5/place -->
<div id="step5" class="dropdown selfcenter" style="width: 95%">
<div class="dropdown header">
<span class="number">5</span>
<span><?php echo $lang['wiz_step5'] ?></span>
</div>
<div class="dropdown content" id="step5_content">
<?php
for($i=-3; $i<0; $i++){
echo "
<input type=\"radio\" name=\"place\" value=\"".$i."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$lang['places'][$i]."</label>
<br>
";
$oid++;
}
?>
<input type="radio" name="place" value="0" id="o_<?php echo $oid ?>" required>
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['custom'] ?></label>
<br>
<div id="registerCustomPlaceNew" style="display: none">
<span><?php echo $lang['custom'].": "?></span>
<input type="number" name="place_c" placeholder="<?php echo $lang['place']."..." ?>" min=1>
</div>
<br>
<br>
<button type="button" onclick="wizardPrevStep(this)" style="float: left"><?php echo $lang['back'] ?></button>
<button type="button" onclick="wizardNextStep(this)" style="float: right"><?php echo $lang['proceed'] ?></button>
</div>
</div>
<br>
<!-- step6/mention -->
<div id="step6" class="dropdown selfcenter" style="width: 95%">
<div class="dropdown header">
<span class="number">6</span>
<span><?php echo $lang['wiz_step6'] ?></span>
</div>
<div class="dropdown content" id="step6_content">
<textarea name="mention" cols="50" rows="5" placeholder="<?php echo $lang['mention']."..." ?>"></textarea>
<br>
<br>
<button type="button" onclick="wizardPrevStep(this)" style="float: left"><?php echo $lang['back'] ?></button>
<button type="button" onclick="wizardLoadPrevRecords(this)" style="float: right"><?php echo $lang['proceed'] ?></button>
</div>
</div>
</form>
<br>
<!-- step7/finalize -->
<div id="step7" class="dropdown selfcenter" style="width: 95%">
<div class="dropdown header">
<span class="number">7</span>
<span><?php echo $lang['wiz_step7'] ?></span>
</div>
<div class="dropdown content" id="step7_content">
<input type="hidden" name="recordParams">
<p><?php echo $lang['do_before_new_record'] ?></p>
<p><?php echo $lang['prev_found'].":" ?></p>
<table id="wizardPrevContent" style="text-align: left">
<thead>
<th><?php echo $lang['id'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['phase_1'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['phase_2'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['teacher'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['place'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['mention'] ?></th>
<th><?php echo $lang['tools'] ?></th>
</thead>
<tbody>
<!-- previous records -->
</tbody>
</table>
<br>
<br>
<button type="button" onclick="wizardPrevStep(this)" style="float: left"><?php echo $lang['back'] ?></button>
<button type="button" onclick="wizardSubmitRecord()" style="float: right"><?php echo $lang['finalize'] ?></button>
</div>
</div>
</div>
</div>