Диплом: Автоматизация и обеспечение информационной безопасности приема заявок на ремонт и модернизацию персональных компьютеров в ООО "Бизнес Решения"

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
96
}
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();
$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())
97
);
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);
if (is_null($ticket->getUser()) && $this->user != $ticket-
>getAuthor()) {
$ticket->setUser($this->user);
$this->manager->persist($ticket);
}
$comment->upload();
$this->manager->persist($comment);
$this->manager->flush();
return $this->redirectToRoute('site_tickets_edit',
array('ticket'=>$ticket->getId()));
}
$this->forms['comment'] = $form->createView();
$this->view['ticket'] = $ticket;
$this->navigation = array('active' => 'tickets');
return $this->render('AppBundle:Tickets:edit.html.twig');
}
/**
* @param Ticket $ticket
* @param TicketStatus $status
* @return RedirectResponse|Response
* @Config\Route("/tickets/{ticket}/change/{status}", name =
"site_tickets_change")
* @Config\ParamConverter("ticket", options = {"mapping":
{"ticket": "id"}})
* @Config\ParamConverter("status", options = {"mapping":
{"srarus": "id"}})
*/
public function changeAction(Ticket $ticket, TicketStatus $status)
{
$ticket->setStatus($status);
if ($status->getId()==4) {
$this->addNotice('success',
98
'tickets.html.twig',
array('notice' => 'closed', 'id' => $ticket->getId())
);
}
if ($status->getId()==3) {
$this->addNotice('info',
'tickets.html.twig',
array('notice' => 'sendmodified', 'id' => $ticket-
>getId())
);
$ticket->setUser(null);
}
$this->manager->persist($ticket);
$this->manager->flush();
$this->navigation = array('active' => 'tickets');
return $this->render('AppBundle:Tickets:index.html.twig');
}
}
<?php
namespace AppBundle\Controller;
use AppBundle\Form\Type\LoginFormType;
use AppBundle\Form\Type\ProfileFormType;
use AppBundle\Controller\InitializableController;
use AppBundle\Entity\Role;
use AppBundle\Entity\User;
use Sensio\Bundle\FrameworkExtraBundle\Configuration as Config;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoder;
use Symfony\Component\Security\Core\Security;
class SecurityController extends InitializableController
{
/**
* @return RedirectResponse|Response
* @Config\Route("/login", name = "site_security_login")
*/
public function loginAction()
{
if ($this->authChecker->isGranted(Role::USER)) return $this-
>redirectToRoute('homepage');
$error = null;
if ($this->request->attributes-
>has(Security::AUTHENTICATION_ERROR))
$error = $this->request->attributes-
>get(Security::AUTHENTICATION_ERROR);
else {
$error = $this->session-
>get(Security::AUTHENTICATION_ERROR, null);
$this->session->remove(Security::AUTHENTICATION_ERROR);
}
if (!is_null($error)) {
$this-
>addNotice('error', 'security_login.html.twig',
array('notice' => 'auth_error'));
}
$form = $this->createForm(new LoginFormType(), new User());
99
$this->navigation = array('active' => 'login');
$this->forms = array(
'login' => $form->createView(),
'last_username' => $this->session-
>get(Security::LAST_USERNAME, null)
);
return $this->render('AppBundle:Security:login.html.twig');
}
/**
* @throws NotFoundHttpException
* @Config\Route("/login-
check", name =
"site_security_login_check")
*/
public function loginCheckAction()
{
throw $this->createNotFoundException();
}
/**
* @throws NotFoundHttpException
* @Config\Route("/logout", name = "site_security_logout")
*/
public function logoutAction()
{
throw $this->createNotFoundException();
}
/**
* @return RedirectResponse|Response
* @Config\Route("/profile", name = "site_security_profile")
*/
public function profileAction()
{
$form = $this->createForm(new ProfileFormType(), $this->user);
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
if (!is_null($form->get('password')->getData())) {
/** @var UserPasswordEncoder $encoder */
$encoder = $this->get('security.password_encoder');
$this->user->setSalt(User::generateSalt())
->setPassword($encoder->encodePassword($this-
>user, $this->user->getPassword()));
$this->manager->persist($this->user);
$this->manager->flush();
}
$this->addNotice('success',
'security_profile.html.twig',
array('notice' => 'user_changed')
);
return $this->redirectToRoute('homepage');
}
$this->forms['profile'] = $form->createView();
$this->navigation = array('active' => 'homepage');
return $this->render('AppBundle:Security:profile.html.twig');
}
}
<?php
100
namespace AppBundle\Controller;
use AppBundle\Entity\CrossOver;
use AppBundle\Form\Type\CrossOverAddFormType;
use AppBundle\Form\Type\CrossOverEditFormType;
use AppBundle\Form\Type\CrossOverFilterFormType;
use AppBundle\Form\Type\CrossOverFormType;
use AppBundle\Entity\Role;
use AppBundle\Form\Type\CrossOverShowFormType;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Query;
use Sensio\Bundle\FrameworkExtraBundle\Configuration as Config;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
class CrossOverController extends InitializableController
{
/**
* @return RedirectResponse|Response
* @Config\Route("/crossovers/index/{pagenum}", name =
"site_crossover_index", defaults={ "pagenum": "1"})
*/
public function indexAction($pagenum=1)
{
$form=$this->createForm(new CrossOverFilterFormType());
$code = null;
$company=null;
$type=null;
$installTicket=null;
$destructTicket=null;
$stoika=null;
$form->handleRequest($this->request);
$crossoverquery = $this->getRepository('CrossOver')-
>createQueryBuilder('co')
->leftJoin('co.unitA','ua')
->leftJoin('ua.equipment', 'ea')
->leftJoin('co.unitB','ub')
->leftJoin('ub.equipment', 'eb')
->orderBy('co.id');
$crossovercountquery = $this->getRepository('CrossOver')-
>createQueryBuilder('co')
->select('COUNT(DISTINCT co.id)')
->leftJoin('co.unitA','ua')
->leftJoin('ua.equipment', 'ea')
->leftJoin('co.unitB','ub')
->leftJoin('ub.equipment', 'eb');
if ($form->isSubmitted() && $form->isValid()) {
$code = $form->get('code')->getData();
$company = $form->get('company')->getData();
$type = $form->get('type')->getData();
$installTicket = $form->get('installTicket')-
>getData();
$destructTicket = $form->get('destructTicket')-
>getData();
$stoika = $form->get('stoika')->getData();
}
if (!empty($code)) {
101
$crossoverquery->andWhere('co.code = :code ')-
>setParameter('code', (substr($code,strpos($code,'-')+1 )));
$crossovercountquery->andWhere('co.code = :code ')-
>setParameter('code', (substr($code,strpos($code,'-')+1 )));
}
if (!empty($company)) {
$crossoverquery->andWhere('ea.company = :company or
eb.company = :company')->setParameter('company',$company);
$crossovercountquery->andWhere('ea.company = :company
or eb.company = :company')->setParameter('company',$company);;
}
if (!empty($type)) {
$crossoverquery-
>andWhere('LOWER(co.type) LIKE
LOWER(:type) ')->setParameter('type', '%' . trim($type) . '%');
$crossovercountquery->andWhere('LOWER(co.type) LIKE
LOWER(:type) ')->setParameter('type', '%' . trim($type) . '%');
}
if (!empty($installTicket)) {
$crossoverquery-
>andWhere('co.installTicket =
:installTicket ')->setParameter('installTicket',$installTicket);
$crossovercountquery->andWhere('co.installTicket =
:installTicket ')->setParameter('installTicket',$installTicket);
}
if (!empty($destructTicket)) {
$crossoverquery-
>andWhere('co.destructTicket =
:destructTicket ')->setParameter('destructTicket',$destructTicket);
$crossovercountquery->andWhere('co.destructTicket =
:destructTicket ')->setParameter('destructTicket',$destructTicket);
}
if (!empty($stoika)) {
$crossoverquery->andWhere('co.standA LIKE :stand OR
co.standB LIKE :stand ')->setParameter('stand', trim($stoika) . '%');
$crossovercountquery->andWhere('co.standA LIKE :stand
OR co.standB LIKE :stand ')->setParameter('stand', trim($stoika) .
'%');
}
$count=$crossovercountquery->getQuery()-
>getSingleScalarResult();
$pages = floor($count / 20) + ($count % 20 > 0 ? 1 : 0);
if ($pages < 1) $pages = 1;
if ($pagenum > $pages) $pagenum = $pages;
$companies = $crossoverquery->setFirstResult(($pagenum -
1) * 20)
->setMaxResults(20)
->getQuery()->getResult();
$this->view['page']=$pagenum;
$this->view['pages']=$pages;
$this->view['crossovers'] = $companies;
$this->view['form'] = $form->createView();
$this->navigation = array('active' => 'crossovers');
return $this-
>render('AppBundle:CrossOvers:index.html.twig');
}
/**
* @return RedirectResponse|Response
* @Config\Route("/crossovers/add", name = "site_crossover_add")
102
*/
public function addAction()
{
if ($this->request->isXmlHttpRequest()) {
return $this->handleAjaxRequest();
}
$crossover = new CrossOver();
if (!($this->authChecker->isGranted(Role::ADMIN))) {
$crossover->getInstallUsers()->add($this->user);
$form = $this->createForm(new CrossOverAddFormType(),
$crossover);
}
else {
$form = $this->createForm(new CrossOverFormType(),
$crossover);
}
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
$valid = true;
if ($valid) {
//генерируем код
$curdate=new \DateTime();
/** @var ArrayCollection|CrossOver $lastcross */
$lastcross=$this->getRepository('CrossOver')-
>createQueryBuilder('co')
->orderBy('co.id', 'DESC')
->getQuery()->getResult();
//если есть кроссировки
if ($lastcross) {
//сравниваем год последней
записи
if ($lastcross[0]->getCreatedAt()-
>format('y')==$curdate->format('y')) {
$code=$lastcross[0]->getCode()+1;
}
else {
$code=1;
}
}
else {
$code=1;
}
$crossover->setCode($code);
$this->manager->persist($crossover);
$this->manager->flush();
$this->addNotice('success',
'crossover.html.twig',
array('notice' => 'added')
);
return $this->redirectToRoute('site_crossover_index');
}
}
$this->view['crossover']=null;
$this->forms['crossover'] = $form->createView();
$this->navigation = array('active' => 'addcrossover');
return $this-
>render('AppBundle:CrossOvers:crossover.html.twig');
}
103
protected function handleAjaxRequest()
{
$action = $this->request->get('action', null);
if (is_null($action)) return new JsonResponse();
if ($action == 'getequipments') {
$company = $this->request->get('company', null);
if (!(is_null($company))) {
$results=$this->getRepository('Equipment')-
>createQueryBuilder('e')
->select('e.id as id')
->where('e.company = :company')
->setParameters(array('company'=> $company))
->getQuery()->getResult(Query::HYDRATE_ARRAY);
}
else {
$results=new JsonResponse();
}
}
elseif($action == 'getunits') {
$equipment = $this->request->get('equipment', null);
if (!(is_null($equipment))) {
$results=$this->getRepository('Unit')-
>createQueryBuilder('u')
->select('u.id as id')
->where('u.equipment = :equipment')
->setParameters(array('equipment'=> $equipment))
->getQuery()->getResult(Query::HYDRATE_ARRAY);
}
else {
$results=new JsonResponse();
}
}
else {
$results=new JsonResponse();
}
return new JsonResponse($results);
}
/**
* @param CrossOver $crossover
* @return RedirectResponse|Response
* @Config\Route("/crossovers/{crossover}/edit", name =
"site_crossover_edit")
* @Config\ParamConverter("crossover", options = {"mapping":
{"crossover": "id"}})
*/
public function editAction(CrossOver $crossover)
{
if (!($this->authChecker->isGranted(Role::ADMIN))) {
if ($crossover->getDestructDate()) {
$form = $this->createForm(new CrossOverShowFormType(),
$crossover);
}
else {
$crossover->getDestructUsers()->add($this->user);
$form = $this->createForm(new CrossOverEditFormType(),
$crossover);
}
}
104
else {
$form = $this->createForm(new CrossOverFormType(),
$crossover);
}
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
$valid = true;
if ($valid) {
$this->manager->persist($crossover);
$this->manager->flush();
$this->addNotice('success',
'crossover.html.twig',
array('notice' => 'changed', 'code' => $crossover-
>getCode())
);
return $this->redirectToRoute('site_crossover_index');
}
}
$this->forms['crossover'] = $form->createView();
$this->view['crossover'] = $crossover;
$this->navigation = array('active' => 'crossvers');
return $this-
>render('AppBundle:CrossOvers:crossover.html.twig');
}
/**
* @param CrossOver $crossover
* @return Response
* @Config\Route("/crossovers/{crossover}/remove", name =
"site_crossover_remove")
* @Config\ParamConverter("crossover", options = {"mapping":
{"crossover": "id"}})
*/
public function removeAction(CrossOver $crossover)
{
$this->manager->remove($crossover);
$this->manager->flush();
$this->addNotice('error',
'crossover.html.twig',
array('notice' => 'removed', 'code' => $crossover-
>getCode())
);
return $this->redirectToRoute('site_crossover_index');
}
}
<?php
namespace AppBundle\Controller;
use AppBundle\Entity\Equipment;
use AppBundle\Form\Type\EquipmentFilterFormType;
use AppBundle\Form\Type\EquipmentFormType;
use AppBundle\Entity\Role;
use Doctrine\ORM\Query;
use Sensio\Bundle\FrameworkExtraBundle\Configuration as Config;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
class EquipmentController extends InitializableController
105
{
/**
* @return RedirectResponse|Response
* @Config\Route("/equipment/index/{pagenum}", name =
"site_equipment_index", defaults={ "pagenum": "1"})
*/
public function indexAction($pagenum=1)
{
if (!($this->authChecker->isGranted(Role::ADMIN))) {
return $this->redirectToRoute('homepage');
}
else {
$form=$this->createForm(new EquipmentFilterFormType());
$caption = null;
$form->handleRequest($this->request);
$query = $this->getRepository('Equipment')-
>createQueryBuilder('e')
->orderBy('e.id', 'DESC');
$countquery = $this->getRepository('Equipment')-
>createQueryBuilder('e')
->select('COUNT(DISTINCT e.id)');
if ($form->isSubmitted() && $form->isValid()) {
$caption = $form->get('caption')->getData();
}
if (!empty($caption)) {
$query-
>andWhere('LOWER(c.caption) LIKE
LOWER(:caption) ')->setParameter('caption', '%' . trim($caption) .
'%');
$countquery->andWhere('LOWER(
c.caption) LIKE
LOWER(:caption) ')->setParameter('caption', '%' . trim($caption) .
'%');
}
$count=$countquery->getQuery()->getSingleScalarResult();
$pages = floor($count / 20) + ($count % 20 > 0 ? 1 : 0);
if ($pages < 1) $pages = 1;
if ($pagenum > $pages) $pagenum = $pages;
$equipments = $query->setFirstResult(($pagenum - 1) * 20)
->setMaxResults(20)
->getQuery()->getResult();
$this->view['page']=$pagenum;
$this->view['pages']=$pages;
$this->view['equipments'] = $equipments;
$this->view['form'] = $form->createView();
$this->navigation = array('active' => 'equipments');
return $this-
>render('AppBundle:Equipments:index.html.twig');
}
}
/**
* @return RedirectResponse|Response
* @Config\Route("/equipment/add", name = "site_equipment_add")
*/
public function addAction()
{
if (!($this->authChecker->isGranted(Role::ADMIN))) {

Смотрите также:

"Автоматизация обработки заявок ООО "Проектно-Строительная Компания"
"Автоматизация процесса аттестации персонала для ООО "Нэт Бай Нэт Холдинг"
"Анализ интернет-активности конкурентов ( на примере конкурентов "Газпром нефть")
"Бухгалтерский учёт и аудит расчётов с подотчётними лицами в организации на примере ООО "ЛОЦ 10""
«Психологическое сопровождение персонала в организации на примере ООО «Крокус»
Cовершенствование деловой оценки персонала в организации (на примере ООО "Даймонд кейтеринг развитие")
IPO - инструмент финансирования деятельности организации. На примере ПАО «Нефтяная компания «Лукойл»
PR как средство продвижения организации (на примере ПАО "Тамбовский завод "Комсомолец им. Н.С. Артемова")
PR-коммуникации в сфере общественного питания (на примере кафе-кондитерской «Cream Cheese»)
SMM как средство повышения эффективности работы учреждений социокультурной сферы (на примере Малого театра)