Дипломная работа: Автоматизация учета и обработки заявок пользователей на ТО и ремонт оргтехники (Help Desk) в ГБОУ Школа № 937

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
112
<div>
{% if not (
is_granted(constant('AppBundle\\Entity\\Role::ADMIN'))
and
is_granted(constant('AppBundle\\Entity\\Role::TEHNIC'))
and
is_granted(constant('AppBundle\\Entity\\Role::PROGER'))) %}
<a href="{{ url('site_tickets_add') }}" class="btn
btn-success" title="Добавить нвую заявку">
<span class="glyphicon glyphicon-plus" aria-
hidden="true"></span>
</a>
{% endif %}
<a href="javascript:void(0);" class="btn btn-info"
title="Открыть поиск" onclick="swithfilter();">
<span class="glyphicon glyphicon-search" aria-
hidden="true"></span>
</a>
<a href="javascript:window.location.reload();"
class="btn btn-default" title="Обновить">
<span class="glyphicon glyphicon-refresh" aria-
hidden="true"></span>
</a>
</div>
{% set form = view.form %}
<div id="formfilter" {% if app.request.get('form_filter')
is empty %}style="display: none;" {% endif %}>
{{ form_start(form, {'attr': {'class': 'form-full'}}) }}
<table class="table table-striped">
<tr>
<td>
{{ form_label(form.id, null, {'label_attr':
{'class': 'control-label'}}) }}
{{ form_widget(form.id, {'attr': {'class':
'form-control', 'autofocus': true}}) }}
</td>
<td>
{{ form_label(form.status, null,
{'label_attr': {'class': 'control-label'}}) }}
{{ form_widget(form.status, {'attr':
{'class': 'form-control', 'autofocus': true}}) }}
</td>
{% if
is_granted(constant('AppBundle\\Entity\\Role::TEHNIC'))
and
is_granted(constant('AppBundle\\Entity\\Role::PROGER')) %}
<td>
{{ form_label(form.my, null, {'label_attr':
{'class': 'control-label'}}) }}
{{ form_widget(form.my, {'attr': {'class':
'form-control', 'autofocus': true}}) }}
</td>
113
{% endif %}
<td width="200px">
<button type="submit" class="btn btn-success"
style="min-width: 170px;">
<span class="glyphicon glyphicon-search"
aria-hidden="true"></span> Поиск
</button>
<a href="{{ url('site_tickets_index') }}"
class="btn btn-default" style="margin-top:5px;width: 170px;">
<span class="glyphicon glyphicon-remove"
aria-hidden="true"></span> Сбросить
</a>
</td>
</tr>
</table>
{{ form_end(form) }}
</div>
<table class="table table-striped">
<thead>
<tr>
<th>№</th>
<th>Дата создания</th>
<th>Тип неисправности</th>
<th>Статус</th>
<th>Сотрудник</th>
</tr>
</thead>
<tbody>
{% for ticket in view.tickets %}
<tr>
<td><a class="btn btn-warning" href="{{
url('site_tickets_edit', {'ticket': ticket.id}) }}">
<span class="glyphicon glyphicon-
pencil" title="Редактировать №{{ ticket.id|e }}" aria-
hidden="true"></span>
</a>
{{ ticket.id|e }}</td>
<td>
{{ ticket.createdat|date("d-m-Y h:m:s")
}}
</td>
<td>
{{ ticket.type.caption|e }}
</td>
<td>
{{ ticket.status.caption|e }}
</td>
<td>
{% if ticket.user is not empty %}
{{ ticket.user.userfio|e }}
{% endif %}
</td>
114
</tr>
{% else %}
<tr>
<td colspan="5">Заявок нет</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
{% block body_additions %}
<script>
function swithfilter(){
if ( $('#formfilter').attr('style')=='display:
none;') {
$('#formfilter').slideDown(250);
}
else {
$('#formfilter').slideUp(250);
}
}
</script>
{% endblock %}
<?php
namespace AppBundle\Controller;
use AppBundle\Entity\Comment;
use AppBundle\Entity\Ticket;
use AppBundle\Entity\TicketStatus;
use AppBundle\Form\Type\MyTicketFilterFormType;
use AppBundle\Entity\Role;
use AppBundle\Form\Type\TicketCommentFormType;
use AppBundle\Form\Type\TicketFilterFormType;
use AppBundle\Form\Type\TicketFormType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration as Config;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
class TicketController extends InitializableController
{
/**
* @return RedirectResponse|Response
* @Config\Route("/ticketes", name = "site_tickets_index")
*/
public function indexAction()
{
if (($this->authChecker->isGranted(Role::TEHNIC)) ||
($this->authChecker->isGranted(Role::PROGER))) {
$form=$this->createForm(new
MyTicketFilterFormType());
$id = null;
$status=null;
$my = null;
115
$form->handleRequest($this->request);
$tickets = $this->getRepository('Ticket')-
>createQueryBuilder('t')
->leftJoin('t.status', 's')
->leftJoin('t.user', 'u')
->where('1=1');
if ($form->isSubmitted() && $form->isValid()) {
$id = $form->get('id')->getData();
$status = $form->get('status')->getData();
$my = $form->get('my')->getData();
}
if (!empty($id)) {
$tickets->andWhere('t.id = :id ')-
>setParameter('id', $id);
}
if (!empty($status)) {
$tickets->andWhere('s.id = :status ')-
>setParameter('status', $status);
}
if (!empty($my)) {
$tickets->andWhere('u.id = :user ')-
>setParameter('user', $this->user->getId());
}
}
else {
$form=$this->createForm(new TicketFilterFormType());
$id = null;
$status=null;
$form->handleRequest($this->request);
$tickets = $this->getRepository('Ticket')-
>createQueryBuilder('t')
->leftJoin('t.status', 's')
->leftJoin('t.author', 'u')
->where('1=1');
if ($form->isSubmitted() && $form->isValid()) {
$id = $form->get('id')->getData();
$status = $form->get('status')->getData();
}
if (!empty($id)) {
$tickets->andWhere('t.id = :id ')-
>setParameter('id', $id);
}
if (!empty($status)) {
$tickets->andWhere('s.id = :status ')-
>setParameter('status', $status);
}
$tickets->andWhere('u.id = :user ')-
>setParameter('user', $this->user->getId());
}
$tickets=$tickets->getQuery()->getResult();
$this->view['tickets'] = $tickets;
$this->view['form'] = $form->createView();
116
$this->navigation = array('active' => 'tickets');
return $this-
>render('AppBundle:Tickets:index.html.twig');
}
/**
* @return RedirectResponse|Response
* @Config\Route("/tickets/add", name = "site_tickets_add")
*/
public function addAction()
{
$ticket = new Ticket();
$form = $this->createForm(new TicketFormType(), $ticket);
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
$ticket->setAuthor($this->user);
/* @var TicketStatus $status*/
$status=$this->getRepository('TicketStatus')-
>findOneBy(array('id'=>1));
$ticket->setStatus($status);
$this->manager->persist($ticket);
$this->manager->flush();
$this->addNotice('success',
'tickets.html.twig',
array('notice' => 'added', 'id' => $ticket-
>getId())
);
return $this-
>redirectToRoute('site_tickets_index');
}
$this->forms['ticket'] = $form->createView();
$this->navigation = array('active' => 'tickets');
$this->view['ticket']=null;
return $this->render('AppBundle:Tickets:add.html.twig');
}
/**
* @param Ticket $ticket
* @return RedirectResponse|Response
* @Config\Route("/tickets/{ticket}/edit", name =
"site_tickets_edit")
* @Config\ParamConverter("ticket", options = {"mapping":
{"ticket": "id"}})
*/
public function editAction(Ticket $ticket)
{
$comment= new Comment();
$form = $this->createForm(new TicketCommentFormType(),
$comment);
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
$comment->setTicket($ticket);
$comment->setAuthor($this->user);
Источник: https://baza.diplomsite.ru/previewfile/2375