diff --git a/~dev_rating/application/classes/Controller/Handler/AdmAccounts.php b/~dev_rating/application/classes/Controller/Handler/AdmAccounts.php index 97178e6e8ae81d2287d2eaa57a4d14780f9a3b93..1b56245b99031ba731df31aed7e14d768739d7b6 100644 --- a/~dev_rating/application/classes/Controller/Handler/AdmAccounts.php +++ b/~dev_rating/application/classes/Controller/Handler/AdmAccounts.php @@ -1,16 +1,47 @@ <?php defined('SYSPATH') or die('No direct script access.'); -class Controller_Handler_AdmStudents extends Controller_Handler { +class Controller_Handler_AdmAccounts extends Controller_Handler { public function before() { - $this->model = new Model_Admin_Students(); + $this->model = new Model_Admin_Accounts(); $this->setAccessLevel(self::ACCESS_USER); parent::before(); } public function action_getActivationForStudents() { - + $facultyID = $this->post->offsetGet('facultyID'); + $gradeNum = $this->post->offsetGet('gradeNum'); + $groupsHandled = array(); $i = 0; + $studyGroups = $this->model->getStudyGroups($gradeNum, $facultyID); + foreach ($studyGroups as $group) + { + $i++; $j = 0; + $accounts = $this->model->getStudentsByStudyGroups($group['GroupID']); + $groupsHandled[$i]['Grade'] = $gradeNum; + $groupsHandled[$i]['Num'] = $group['GroupNum']; + $groupsHandled[$i]['Spec'] = $group['SpecName']; + foreach ($accounts as $row) + { + $accInfo = $this->model->getAccountInfoByID($row['StudentAccID']); + if($code = $accInfo->get('AccCode')) + { + $j++; + $groupsHandled[$i]['People'][$j]['LastName'] = $row['StudentLast']; + $groupsHandled[$i]['People'][$j]['FirstName'] = $row['StudentFirst']; + $groupsHandled[$i]['People'][$j]['SecondName'] = $row['StudentSecond']; + $groupsHandled[$i]['People'][$j]['ActivationCode'] = $code; + } + } + $groupsHandled[$i]['PeopleCount'] = $j; + } + $mpdf = View_MPDF::factory('pdf/activationTemplate', array('Groups' => $groupsHandled, + 'System' => array('Title' => ASSEMBLY_SYSTEM_NAME, 'Version' => ASSEMBLY_VERSION))); + $cssPath = 'media/css/acTpl.css'; + $css = file_get_contents($cssPath); + $mpdf->get_mpdf()->WriteHTML($css, 1); + $mpdf->write_to_disk('media/pdf/activationTemplate.pdf'); + $this->response->body($twig); } public function action_getActivationForTeachers() diff --git a/~dev_rating/application/classes/Controller/Handler/AdmStudents.php b/~dev_rating/application/classes/Controller/Handler/AdmStudents.php index 2bcf215cec9d5f19481988bb78ae0c962cae18a7..e1f97fda20a471f0b67cf8fd368fc2138378da76 100644 --- a/~dev_rating/application/classes/Controller/Handler/AdmStudents.php +++ b/~dev_rating/application/classes/Controller/Handler/AdmStudents.php @@ -96,6 +96,27 @@ class Controller_Handler_AdmStudents extends Controller_Handler { } } + public function action_getStudentsByGrade() + { + $facultyID = $this->post->offsetGet('gradeNum'); + $groupID = $this->post->offsetGet('gradeNum'); + if($groupID != 0) + { + $students = $this->model->getStudentsByStudyGroups($groupID); + $studentsHandled = array(); $i = 0; + foreach($students as $row) + { + $i++; + $studentsHandled[$i]['LastName'] = $row['StudentLast']; + $studentsHandled[$i]['FirstName'] = $row['StudentFirst']; + $studentsHandled[$i]['SecondName'] = $row['StudentSecond']; + } + $twig = Twig::factory('admin/students/handler/listOutput'); + $twig->List = $studentsHandled; + $this->response->body($twig); + } + } + public function action_getStudentsByStudyGroup() { $groupID = $this->post->offsetGet('studyGroupID'); diff --git a/~dev_rating/application/classes/Model/Admin/Accounts.php b/~dev_rating/application/classes/Model/Admin/Accounts.php new file mode 100644 index 0000000000000000000000000000000000000000..c4862cbfd06381acccb4c6545c7024c75273adc3 --- /dev/null +++ b/~dev_rating/application/classes/Model/Admin/Accounts.php @@ -0,0 +1,29 @@ +<?php defined('SYSPATH') or die('No direct script access.'); + +class Model_Admin_Accounts extends Model +{ + public function getFaculties() + { + $sql = "CALL `GetFaculties`(); "; + return DB::query(Database::SELECT, $sql)->execute(); + } + + public function getStudyGroups($gradeNum, $facultyID) + { + $sql = "CALL `GetStudyGroups`('$gradeNum', '$facultyID'); "; + return DB::query(Database::SELECT, $sql)->execute(); + } + + public function getStudentsByStudyGroups($groupID) + { + $sql = "CALL `GetStudentsByStudyGroups`('$groupID'); "; + return DB::query(Database::SELECT, $sql)->execute(); + } + + public function getAccountInfoByID($ID) + { + $sql = "CALL `GetAccInfoByID`('$ID'); "; + return DB::query(Database::SELECT, $sql)->execute(); + } + +} \ No newline at end of file diff --git a/~dev_rating/application/views/pdf/activationTemplate.twig b/~dev_rating/application/views/pdf/activationTemplate.twig new file mode 100644 index 0000000000000000000000000000000000000000..1428c3906ee1fd3ffceb8a32e15bacdfeae7b69d --- /dev/null +++ b/~dev_rating/application/views/pdf/activationTemplate.twig @@ -0,0 +1,20 @@ +{% for group in Groups %} + <h1>{{ System.Title }} - коды активации</h1> + <h3>{{ group.Spec }}, курс {{ group.Grade }}, группа {{ group.Num }}</h3> + {% for account in group.People %} + <table width='100%' cellspacing='0'> + <tr> + <td class="cutline" width='10%'> </td> + <td class='personal_info' width='60%'> + {{ loop.index }}. {{ account.LastName }} {{ account.FirstName }} {{ account.SecondName }} + </td> + <td class='activation_code' width='40%'> + {{ account.ActivationCode }} + </td> + </tr> + </table> + {% endfor %} + {% if not loop.last %} + <pagebreak /> + {% endif %} +{% endfor %} \ No newline at end of file diff --git a/~dev_rating/media/css/acTpl.css b/~dev_rating/media/css/acTpl.css new file mode 100644 index 0000000000000000000000000000000000000000..71784e7f87454f4b9e586e0e95f8b8a4bec549e6 --- /dev/null +++ b/~dev_rating/media/css/acTpl.css @@ -0,0 +1,34 @@ +html +{ + font-family: Arial; +} + +tr +{ + margin: 2px 0; +} + +.cutline +{ + border-left: 1px dotted black; + border-right: 1px dotted black; + background: #eee; + border-style: dotted; +} + +.personal_info +{ + padding: 8px; + font-size: 14px; + border-top: 1px solid black; + border-bottom: 1px solid black; +} + +.activation_code +{ + padding: 8px; + font-size: 14px; + text-align: left; + border-top: 1px solid black; + border-bottom: 1px solid black; +} diff --git a/~dev_rating/modules/mpdf/classes/View/MPDF/Core.php b/~dev_rating/modules/mpdf/classes/View/MPDF/Core.php index c856a6ea7e422ed8ce87d9945a5509826533bf90..55efcb3ae774d66292913df02d603ff0954af3bb 100644 --- a/~dev_rating/modules/mpdf/classes/View/MPDF/Core.php +++ b/~dev_rating/modules/mpdf/classes/View/MPDF/Core.php @@ -9,7 +9,7 @@ * @copyright (c) 2009 Woody Gilk * @license MIT */ -abstract class View_MPDF_Core extends View { +abstract class View_MPDF_Core extends Twig { protected $mpdf = NULL; protected $view_file = NULL;