diff --git a/~dev_rating/application/classes/Controller/Handler/XMLCreator.php b/~dev_rating/application/classes/Controller/Handler/XMLCreator.php new file mode 100644 index 0000000000000000000000000000000000000000..3f0e5fcdd960bd726dd9bf74a43d7d7d0dc756ae --- /dev/null +++ b/~dev_rating/application/classes/Controller/Handler/XMLCreator.php @@ -0,0 +1,131 @@ +<?php defined('SYSPATH') or die('No direct script access.'); + +class Controller_Handler_XMLCreator extends Controller_Handler +{ + // Таблица баллов (СЃРѕ страницы оценивания) [dev version] + public function action_GenerateXMLFile() { + + $disciplineID = $this->post['disciplineID']; + $groupID = $this->post['studyGroupID']; + + // make form from template + $info = Model_Rating::getFinalFormInfo($disciplineID, $groupID)[0]; + $info['DisciplineID'] = $disciplineID; + + // prepare filename + $grade = $info["GradeNum"]; + $group = $info["GroupNum"]; + $faculty = $info['FacultyName']; + $subjName = $info["SubjectName"]; + + + $type = $info['ExamType']; + + $stage = 1; // TODO: user should provide stage + $rates = Model_Rating::getRatesForStudentsGroupByStage($disciplineID, $groupID, $stage); + + $examHold = 1; + // if ($type === 'exam') + // $examHold = $this->checkExamIsHold($rates); + + $filename = $type."_".$grade."_".$group; + + $fp = fopen ("test.xml", "w+"); + $degree = $info['Degree']; + + if ($degree=="bachelor") + $degree="Бакалавр"; + else if ($degree=="master") + $degree="Магистр"; + else + $degree="Специалист"; + + if ($type=="exam") + $type="Ркзамен"; + else if ($type=="credit") + $type="Зачет"; + else + $type="Дифференцированный зачет"; + + $gradeNum = $info['GradeNum']; + fputs($fp,"<?xml version='1.0' encoding='UTF-8'?>\n"); + fputs($fp,"<document\n>"); + fputs($fp,"<header\n>"); + $semester = $info['SemesterNum']; + fputs($fp,"<semester>\n".$semester."</semester>\n"); + fputs($fp,"<faculty>\n".$faculty."</faculty>\n"); + fputs($fp,"<grade>\n".$gradeNum."</grade>\n"); + fputs($fp,"<degree>\n".$degree."</degree>\n"); + fputs($fp,"<spec>\n".$info['SpecName']." ".$info['SpecCode']."</spec>\n"); + fputs($fp,"<group>\n".$group."</group>\n"); + fputs($fp,"<subjName>\n".$subjName."</subjName>\n"); + + fputs($fp,"<examtype>\n".$type."</examtype>\n"); + + $countteachers = Model_Teachers::getNamesForDiscipline($info['DisciplineID'],true,true); + $teachers = Model_Teachers::ofDiscipline($info['DisciplineID']); + + + + $teachersStr = ''; + fputs($fp,"<teachers>\n"); + if (count($countteachers)>1){ + foreach ($teachers as $row) { + fputs($fp,"<teacher>\n"); + fputs($fp,"<lastName>\n".$row['LastName']."</lastName>\n"); + fputs($fp,"<firstName>\n".$row['FirstName']."</firstName>\n"); + fputs($fp,"<secondName>\n".$row['SecondName']."</secondName>\n"); + fputs($fp,"</teacher>\n"); + } + /*for($i=0;$i<count($teachers);++$i) + { + fputs($fp,$teachers[$i].' '); + }*/ + } + else + { + fputs($fp,"<teacher>\n"); + fputs($fp,"<lastName>\n".$info['LastName']."</lastName>\n"); + fputs($fp,"<firstName>\n".$info['FirstName']."</firstName>\n"); + fputs($fp,"<secondName>\n".$info['SecondName']."</secondName>\n"); + fputs($fp,"</teacher>\n"); + } + + fputs($fp,"</teachers>\n"); + fputs($fp,"</header\n>"); + + + fputs($fp,"<rates\n>"); + foreach($rates as $studentRates) { + fputs($fp,"<student\n>"); + $lastName = $studentRates['LastName']; + $firstName = $studentRates['FirstName']; + $secondName = $studentRates['SecondName']; + $fullName = $lastName." ".$firstName." ".$secondName; + fputs($fp,"<lastName>\n".$lastName."</lastName>\n"); + fputs($fp,"<firstName>\n".$firstName."</firstName>\n"); + fputs($fp,"<secondName>\n".$secondName."</secondName>\n"); + $ratesSet['semester'] = (int)$studentRates['regular']; + $ratesSet['bonus'] = (int)$studentRates['bonus']; + $ratesSet['extra'] = (int)$studentRates['extra']; + $ratesSet['exam'] = (int)$studentRates['exam']; + + $totalRate = $ratesSet['bonus'] + $ratesSet['exam']+$ratesSet['semester'] + $ratesSet['extra']; + + fputs($fp,"<totalRate>\n".$totalRate."</totalRate>\n"); + //fputs($fp,"<semesterRate>\n".$ratesSet['semester']."</semesterRate>\n"); + // fputs($fp,"<bonusRate>\n".$ratesSet['bonus']."</bonusRate>\n"); + fputs($fp,"</student\n>"); + } + fputs($fp,"</rates\n>"); + fputs($fp,"</document\n>"); + fclose($fp); + + $options = [ + 'mime_type' => File::mime_by_ext('xml'), + 'delete'=>true + ]; + //$filename=self::encodestring($filename); + $this->response->send_file('test.xml', $filename.'.xml', $options); + } +} \ No newline at end of file diff --git a/~dev_rating/application/views/dean_office/sheets.twig b/~dev_rating/application/views/dean_office/sheets.twig index 9e998bcf50ee98dcd1ed0f5ba1e5fe0bab82535f..b5bec52078f84dc32dc5fff29fc27bd97a58be3a 100644 --- a/~dev_rating/application/views/dean_office/sheets.twig +++ b/~dev_rating/application/views/dean_office/sheets.twig @@ -82,6 +82,7 @@ <button class="defaultForm BlueButton HalfWidth" id="DownloadExamDocument" disabled="disabled">Скачать</button> <button class="defaultForm BlueButton HalfWidth" id="BlockExamDiscipline" disabled="disabled">Блокировать</button> <button class="defaultForm BlueButton HalfWidth" id="BlockAndPrintExam" disabled="disabled">Блокировать Рё Скачать</button> + <button class="defaultForm BlueButton HalfWidth" id="DownloadXML" disabled="disabled">Скачать РІ формате XML</button> </div> </div> </div> diff --git a/~dev_rating/media/js/dean_office/dean_office.js b/~dev_rating/media/js/dean_office/dean_office.js index 5ff232b93e6a8d43806eedc32693eb6334053b3f..5c9feb1d9f46da69b9b000acd556e7b53e9f26dd 100644 --- a/~dev_rating/media/js/dean_office/dean_office.js +++ b/~dev_rating/media/js/dean_office/dean_office.js @@ -21,6 +21,7 @@ $(function() { var jDownloadExamDocument = $("#DownloadExamDocument"); var jSelectGroup = $("#SelectGroup"); var jSelectDiscipline = $("#SelectDiscipline"); + var jDownloadXML = $("#DownloadXML"); $("#ExamChoice").change(controlVisualization); $("#CreditChoice").change(controlVisualization); @@ -61,6 +62,7 @@ $(function() { jDownloadStatement.attr("disabled", "disabled"); } jDownloadExamDocument.attr("disabled", "disabled"); + jDownloadXML.attr("disabled", "disabled"); }); $("#SelectGroup").change(function() { @@ -94,14 +96,20 @@ $(function() { } else jDownloadStatement.attr("disabled", "disabled"); + jDownloadXML.attr("disabled", "disabled"); jDownloadExamDocument.attr("disabled", "disabled"); }); $("#SelectDiscipline").change(function() { var disciplineID = parseInt($(this).val()) || 0; - if (disciplineID > 0) + if (disciplineID > 0){ jDownloadExamDocument.removeAttr("disabled"); - else jDownloadExamDocument.attr("disabled", "disabled"); + jDownloadXML.removeAttr("disabled"); + } + else { + jDownloadExamDocument.attr("disabled", "disabled"); + jDownloadXML.attr("disabled", "disabled"); + } }); // Скачать ведомость @@ -140,6 +148,24 @@ $(function() { }); }); + + $('body').on('click', '#DownloadXML', function(){ + $.fileDownload(g_URLdir + 'handler/XMLCreator/GenerateXMLFile', { + httpMethod: "POST", + data: + { + "disciplineID": parseInt($("#SelectDiscipline").val()), + "studyGroupID": parseInt($("#SelectGroup").val()) + }, + successCallback: function () { + + }, + failCallback: function () { + + } + }); + }); + // Блокирование дисциплины // Печать ведомости Рё блокирование дисциплины