From 716b4fdc68f8e62d5ec89b5bbf8e2cc58dfa8ea3 Mon Sep 17 00:00:00 2001 From: ViolettaShevchenko <frozenm@yandex.ru> Date: Sat, 2 Jul 2016 01:23:51 +0300 Subject: [PATCH] Add author in support requests + refactor --- db/stored/functions.sql | 26 +++++++++++++++++++ db/stored/procedures.sql | 5 ++-- media/less/support/requests.less | 12 ++++++--- .../views/office/support/requests.twig | 7 ++++- 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/db/stored/functions.sql b/db/stored/functions.sql index 764d603c5..746818f06 100644 --- a/db/stored/functions.sql +++ b/db/stored/functions.sql @@ -2136,6 +2136,32 @@ BEGIN RETURN ROW_COUNT()-1; END// +# return StudentID or TeacherID depending on UserRoleID +DROP FUNCTION IF EXISTS GetUserStudentOrTeacherID// +CREATE FUNCTION GetUserStudentOrTeacherID ( + pAccountID INT(11), + pUserRoleID INT(11) +) RETURNS INT(11) +BEGIN + DECLARE vID INT DEFAULT -1; + + IF pUserRoleID = GetUserRole('student') THEN + SELECT students.ID + INTO vID + FROM students + WHERE students.AccountID = pAccountID + LIMIT 1; + ELSE + SELECT teachers.ID + INTO vID + FROM teachers + WHERE teachers.AccountID = pAccountID + LIMIT 1; + END IF; + + RETURN vID; +END// + # ------------------------------------------------------------------------------------------- diff --git a/db/stored/procedures.sql b/db/stored/procedures.sql index 6a9343519..0e645d37a 100644 --- a/db/stored/procedures.sql +++ b/db/stored/procedures.sql @@ -1394,8 +1394,9 @@ CREATE PROCEDURE GetRequests ( IN pAccountID INT, IN pFilter enum('opened','processed','closed','all')) BEGIN - SELECT requests.* - FROM requests + SELECT requests.*, GetUserFullNameByAccountID(accounts.ID) as FullName, accounts.UserRoleID, + GetUserStudentOrTeacherID(AccountID, accounts.UserRoleID) as PersonalID + FROM requests join accounts on requests.AccountID = accounts.ID WHERE IF(pFilter = 'all', TRUE, requests.Status = pFilter) AND requests.Title != '' AND requests.Description != '' diff --git a/media/less/support/requests.less b/media/less/support/requests.less index f18e4958f..673934fbb 100644 --- a/media/less/support/requests.less +++ b/media/less/support/requests.less @@ -3,9 +3,9 @@ } .RequestsPage { - height: 600px; + height: 650px; padding-right: 10px; - overflow-y: scroll; + overflow-y: auto; overflow-x: hidden; .RequestIssue { @@ -22,8 +22,14 @@ cursor: pointer; } + .RequestAuthor { + font-size: 1.1em; + font-weight: bold; + } + .RequestInfo { - font-size: 0.9em; + font-size: 0.8em; + margin-top: 4px; } } diff --git a/~dev_rating/application/views/office/support/requests.twig b/~dev_rating/application/views/office/support/requests.twig index e419cb23b..e192a0f50 100644 --- a/~dev_rating/application/views/office/support/requests.twig +++ b/~dev_rating/application/views/office/support/requests.twig @@ -25,7 +25,12 @@ <div class="goodClearFix RequestIssue"> <div class="defaultForm FLeft P1Width"> <div id="{{ "requestTitle"~req.ID }}" class="RequestTitle">{{ req.Title }}</div> - <div class="RequestInfo">{{ req.Date }}</div> + {% if req.UserRoleID == 1 %}{% set role = "students/" %}{% else %}{% set role = "teachers/" %}{% endif %} + <div class="RequestInfo"> + <a class="RequestAuthor" href={{ URL.site("office/"~role~req.PersonalID) }} target="_blank"> + {{ req.FullName }}</a> + {{ req.Date }} + </div> </div> <select id="{{ "requestStatus"~req.ID }}" style="width: 10%" class="defaultForm FRight RequestStatus"> <option value="opened" {% if req.Status == 'opened'%}selected{% endif %}>Открыт</option> -- GitLab