Диплом: Автоматизация управления поставками для ООО «Альфа Тренд»

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
97
ALTER TABLE delivery ADD FOREIGN KEY R_6 (intervalid)
REFERENCES interval(id);
ALTER TABLE delivery ADD FOREIGN KEY R_14 (driverid)
REFERENCES driver(id);
ALTER TABLE delivery ADD FOREIGN KEY R_15 (carid) REFERENCES
car(id);
ALTER TABLE delivery ADD FOREIGN KEY R_16 (userid) REFERENCES
user(id);
98
Приложение 2. Исходный код программных модулей
<?php
namespace AppBundle\Controller;
use AppBundle\Form\LoginFormType;
use AppBundle\Controller\ParentController;
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;
use
Symfony\Component\Security\Core\Authentication\Token\UsernameP
asswordToken;
lass SecurityController extends ParentController
{
/**
* @return RedirectResponse|Response
* @Config\Route("/login", name = "site_security_login")
*/
public function loginAction()
{
if ($this->authChecker->isGranted(Role::USER)) return
$this->redirectToRoute('site_general_index');
$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);
}
$form = $this->createForm(new LoginFormType(), new
User());
if (!is_null($error))
$form->addError(new FormError('Неправильный логин
или пароль'));
$this->forms = array(
'login' => $form->createView(),
'last_username' => $this->session-
>get(Security::LAST_USERNAME, null)
);
99
return $this-
>render('AppBundle:General:login.html.twig');
}
/**
* @return RedirectResponse|Response
* @Config\Route("/register", name =
"site_security_register")
*/
public function registerAction()
{
$user = new User();
$user->getRolesCollection()->add($this-
>getRepository('Role')->findOneByRole(Role::USER));
$form = $this->createForm(new UserRegisterFormType(),
$user);
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
$valid = true;
$samesname = $this->getRepository('User')-
>createQueryBuilder('u')
->select('COUNT(u.id) AS id')
->where('u.username = :username')
->setParameters(array('username' => $user-
>getUsername()))
->getQuery()->getSingleScalarResult();
if ($samesname > 0) {
$form->get('username')->addError(new
FormError('Пользователь с таким именем уже существует.'));
$valid = false;
}
if (is_null($form->get('password')->getData())) {
$form->get('password')->addError(new
FormError('Пожалуйста, укажите пароль пользователя.'));
$valid = false;
}
if (preg_match("/[а-я]/i", $form->get('username')-
>getData() )) {
$form->get('username')->addError(new
FormError('В имени пользователя нельзя использовать кириллицу
'));
$valid = false;
}
if ($valid) {
/** @var UserPasswordEncoder $encoder */
$encoder = $this-
>get('security.password_encoder');
$user->setSalt(User::generateSalt())
->setPassword($encoder-
>encodePassword($user, $user->getPassword()));
$this->manager->persist($user);
$this->manager->flush();
100
$token = new UsernamePasswordToken($user,
null, 'user_provider', $user->getRoles());
$this->get('security.context')-
>setToken($token);
return $this-
>redirectToRoute('site_general_index');
}
}
$this->forms['user'] = $form->createView();
return $this-
>render('AppBundle:General:register.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()
{
}
}
<?php
namespace AppBundle\Controller;
use AppBundle\Entity\Department;
use AppBundle\Entity\Kind;
use AppBundle\Entity\ProductCategory;
use AppBundle\Entity\RateSystem;
use AppBundle\Entity\Type;
use AppBundle\Form\Type\DepartmentFormType;
use AppBundle\Form\Type\KindFormType;
use AppBundle\Form\Type\ProductCategoryFilterFormType;
use AppBundle\Form\Type\ProductCategoryFormType;
101
use AppBundle\Form\Type\ProductFormType;
use AppBundle\Entity\Role;
use AppBundle\Entity\Product;
use AppBundle\Form\Type\RateSystemFormType;
use AppBundle\Form\Type\TypeFormType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration as
Config;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
class SpravController extends InitializableController
{
/**
* @return RedirectResponse|Response
* @Config\Route("/", name = "site_sprav_index")
*/
public function indexAction()
{
$this->navigation = array('active' => 'sprav');
return $this-
>render('AppBundle:Sprav:index.html.twig');
}
/**
* @return RedirectResponse|Response
* @Config\Route("/kinds", name = "site_kinds_index")
*/
public function kindindexAction()
{
$kinds = $this->getRepository('Kind')-
>createQueryBuilder('k')
->orderBy('k.caption')->getQuery()->getResult();
$this->view['kinds'] = $kinds;
$this->navigation = array('active' => 'sprav');
return $this-
>render('AppBundle:Sprav:kindindex.html.twig');
}
/**
* @return RedirectResponse|Response
* @Config\Route("/kinds/add", name = "site_kinds_add")
*/
public function kindaddAction()
{
$kind = new Kind();
$form = $this->createForm(new KindFormType(), $kind);
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
$this->manager->persist($kind);
102
$this->manager->flush();
$this->addNotice('success',
'sprav.html.twig',
array('notice' => 'kind_added', 'caption'
=> $kind->getCaption())
);
return $this-
>redirectToRoute('site_kinds_index');
}
$this->forms['kind'] = $form->createView();
$this->view['kind'] = null;
$this->navigation = array('active' => 'sprav');
return $this-
>render('AppBundle:Sprav:kind.html.twig');
}
/**
* @param Kind $kind
* @return RedirectResponse|Response
* @Config\Route("/kinds/{kind}/edit", name =
"site_kinds_edit")
* @Config\ParamConverter("kind", options = {"mapping":
{"kind": "id"}})
*/
public function kindeditAction(Kind $kind)
{
$form = $this->createForm(new KindFormType(), $kind);
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
$this->manager->persist($kind);
$this->manager->flush();
$this->addNotice('success',
'sprav.html.twig',
array('notice' => 'kind_changed',
'caption' => $kind->getCaption())
);
return $this-
>redirectToRoute('site_kinds_index');
}
$this->forms['kind'] = $form->createView();
$this->view['kind'] = $kind;
$this->navigation = array('active' => 'sprav');
return $this-
>render('AppBundle:Sprav:kind.html.twig');
}
/**
* @param Kind $kind
* @return RedirectResponse|Response
* @Config\Route("/kinds/{kind}/remove", name =
"site_kinds_remove")
103
* @Config\ParamConverter("kind", options = {"mapping":
{"kind": "id"}})
*/
public function kindremoveAction(Kind $kind)
{
$this->manager->remove($kind);
$this->manager->flush();
$this->addNotice('error',
'sprav.html.twig',
array('notice' => 'kind_removed', 'caption' => $kind-
>getCaption())
);
return $this->redirectToRoute('site_kinds_index');
}
/**
* @return RedirectResponse|Response
* @Config\Route("/types", name = "site_types_index")
*/
public function typeindexAction()
{
$types = $this->getRepository('Type')-
>createQueryBuilder('t')
->orderBy('t.caption')->getQuery()->getResult();
$this->view['types'] = $types;
$this->navigation = array('active' => 'sprav');
return $this-
>render('AppBundle:Sprav:typeindex.html.twig');
}
/**
* @return RedirectResponse|Response
* @Config\Route("/types/add", name = "site_types_add")
*/
public function typeaddAction()
{
$type = new Type();
$form = $this->createForm(new TypeFormType(), $type);
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
$this->manager->persist($type);
$this->manager->flush();
$this->addNotice('success',
'sprav.html.twig',
array('notice' => 'type_added', 'caption' =>
$type->getCaption())
);
return $this->redirectToRoute('site_types_index');
}
$this->forms['type'] = $form->createView();
$this->view['type'] = null;
$this->navigation = array('active' => 'sprav');
104
return $this-
>render('AppBundle:Sprav:type.html.twig');
}
/**
* @param Type $type
* @return RedirectResponse|Response
* @Config\Route("/types/{type}/edit", name =
"site_types_edit")
* @Config\ParamConverter("type", options = {"mapping":
{"type": "id"}})
*/
public function typeeditAction(Type $type)
{
$form = $this->createForm(new TypeFormType(), $type);
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
$this->manager->persist($type);
$this->manager->flush();
$this->addNotice('success',
'sprav.html.twig',
array('notice' => 'type_changed', 'caption' =>
$type->getCaption())
);
return $this->redirectToRoute('site_types_index');
}
$this->forms['type'] = $form->createView();
$this->view['type'] = $type;
$this->navigation = array('active' => 'sprav');
return $this-
>render('AppBundle:Sprav:type.html.twig');
}
/**
* @param Type $type
* @return RedirectResponse|Response
* @Config\Route("/types/{type}/remove", name =
"site_types_remove")
* @Config\ParamConverter("type", options = {"mapping":
{"type": "id"}})
*/
public function typeremoveAction(Type $type)
{
$this->manager->remove($type);
$this->manager->flush();
$this->addNotice('error',
'sprav.html.twig',
array('notice' => 'type_removed', 'caption' =>
$type->getCaption())
);
return $this->redirectToRoute('site_types_index');
}
105
/**
* @return RedirectResponse|Response
* @Config\Route("/ratesystems", name =
"site_ratesystems_index")
*/
public function ratesystemindexAction()
{
$ratesystems = $this->getRepository('RateSystem')-
>createQueryBuilder('rs')
->orderBy('rs.caption')->getQuery()->getResult();
$this->view['ratesystems'] = $ratesystems;
$this->navigation = array('active' => 'sprav');
return $this-
>render('AppBundle:Sprav:ratesystemindex.html.twig');
}
/**
* @return RedirectResponse|Response
* @Config\Route("/ratesystems/add", name =
"site_ratesystems_add")
*/
public function ratesystemaddAction()
{
$ratesystem = new RateSystem();
$form = $this->createForm(new RateSystemFormType(),
$ratesystem);
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
$this->manager->persist($ratesystem);
$this->manager->flush();
$this->addNotice('success',
'sprav.html.twig',
array('notice' => 'ratesystem_added',
'caption' => $ratesystem->getCaption())
);
return $this-
>redirectToRoute('site_ratesystems_index');
}
$this->forms['ratesystem'] = $form->createView();
$this->view['ratesystem'] = null;
$this->navigation = array('active' => 'sprav');
return $this-
>render('AppBundle:Sprav:ratesystem.html.twig');
}
/**
* @param RateSystem $ratesystem
* @return RedirectResponse|Response
* @Config\Route("/ratesystems/{ratesystem}/edit", name =
"site_ratesystems_edit")
106
* @Config\ParamConverter("ratesystem", options =
{"mapping": {"ratesystem": "id"}})
*/
public function ratesystemeditAction(RateSystem
$ratesystem)
{
$form = $this->createForm(new RateSystemFormType(),
$ratesystem);
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
$this->manager->persist($ratesystem);
$this->manager->flush();
$this->addNotice('success',
'sprav.html.twig',
array('notice' => 'ratesystem_changed',
'caption' => $ratesystem->getCaption()) );
return $this-
>redirectToRoute('site_ratesystems_index');
}
$this->forms['ratesystem'] = $form->createView();
$this->view['ratesystem'] = $ratesystem;
$this->navigation = array('active' => 'sprav');
return $this-
>render('AppBundle:Sprav:ratesystem.html.twig');
}
/**
* @param RateSystem $ratesystem
* @return RedirectResponse|Response
* @Config\Route("/ratesystems/{ratesystem}/remove", name
= "site_ratesystems_remove")
* @Config\ParamConverter("ratesystem", options =
{"mapping": {"ratesystem": "id"}})
*/
public function ratesystemremoveAction(RateSystem
$ratesystem)
{
$this->manager->remove($ratesystem);
$this->manager->flush();
$this->addNotice('error',
'sprav.html.twig',
array('notice' => 'ratesystem_removed', 'caption'
=> $ratesystem->getCaption())
);
return $this-
>redirectToRoute('site_ratesystems_index');
}
}

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

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