Skip to content
Snippets Groups Projects
Commit 66486b5c authored by Ангелина Елизарова's avatar Ангелина Елизарова Committed by xamgore
Browse files

Model teacher is a container now

parent 28ab7af3
Branches
Tags
No related merge requests found
......@@ -1368,4 +1368,17 @@ BEGIN
LIMIT 1;
END //
DROP PROCEDURE IF EXISTS Teacher_GetInfo //
CREATE PROCEDURE Teacher_GetInfo(
IN pID INT(11)
) NO SQL
BEGIN
SELECT
view_teachers.TeacherID AS 'ID',
view_teachers.* # todo: expand list?
FROM `view_teachers` WHERE pID = view_teachers.TeacherID
LIMIT 1;
END //
DELIMITER ;
......@@ -69,11 +69,10 @@ class Controller_Handler_AdmStudents extends Controller_Handler
$id = $row['SpecID'];
}
$j++;
if (is_null($row['SpecName'])) {
$groupsHandled[$i]['SpecName'] = "<без специализации>";
} else {
$groupsHandled[$i]['SpecName'] = $row['SpecName'];
}
$groupsHandled[$i]['SpecName'] = is_null($row['SpecName']) ? 'Без специализации' : $row['SpecName'];
$groupsHandled[$i]['SpecAbbr'] = is_null($row['SpecAbbr']) ? '' : $row['SpecAbbr'];
$groupsHandled[$i]['Groups'][$j]['ID'] = $row['ID'];
$groupsHandled[$i]['Groups'][$j]['Num'] = $row['GroupNum'];
}
......@@ -140,4 +139,4 @@ class Controller_Handler_AdmStudents extends Controller_Handler
//Model_Student::load($id)
// ->attach()
}
}
\ No newline at end of file
}
......@@ -37,10 +37,16 @@ class Controller_Office_Students extends Controller_Environment_Office
public function action_profile() {
$id = $this->request->param('id');
if (!$id) $this->redirect(Route::get('office:common')->uri());
$student = Model_Student::load($id);
$this->twig->set([
'Profile' => $student,
'Grades' => Model_Grades::loadAll(),
'Account' => Model_Account::with($student->AccountID),
'Groups' => Model_Faculty::with($student->FacultyID)->getGroups($student->GradeNum),
])->set_filename(static::OFFICE . 'students/profile');
}
}
......@@ -37,7 +37,6 @@ class Controller_Office_Teachers extends Controller_Environment_Office
}
public function action_profile() {
# todo: load teacher's account id
$id = $this->request->param('id');
if (!$id) $this->redirect(Route::get('office:common')->uri());
......
<?php defined('SYSPATH') or die('No direct script access.');
class Model_Teacher extends Model
/**
* Class Model_Teacher
*
* @property $ID int
* @property $LastName string
* @property $FirstName string
* @property $SecondName string
* @property $AccountID int
* @property $TeacherID int
* @property $JobPositionID int
* @property $JobPositionName string
* @property $DepID int
* @property $DepName string
* @property $FacultyID int
* @property $FacultyName string
* @property $FacultyAbbr string
*/
class Model_Teacher extends Model_Container
{
public $ID;
protected function getRawData($id) {
$sql = 'CALL `Teacher_GetInfo`(:id)';
$info = DB::query(Database::SELECT, $sql)
->param(':id', $id)->execute();
if ($info->count() == 0)
throw new InvalidArgumentException('Teacher with not found');
return $info[0];
}
# todo: conflict with self::load()
public static function with($id) {
//fixme: teacher may not exist
if (!is_numeric($id) || $id <= 0)
throw new LogicException(Error::ID_IS_INCORRECT);
return self::load($id);
}
$t = new self();
$t->ID = (int) $id;
return $t;
protected function create() {
// TODO: Implement create() method.
throw new BadMethodCallException('Method is not implemented yet!');
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment