Диплом: Автоматизация учета работ по ремонту компьютерного оборудования в компании ООО "ЭР-СТАЙЛ СИБИРЬ ИНТЕГРАЦИЯ"

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
104
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)) {
$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();
105
$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")
*/
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);
106
$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');
}
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")
107
* @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);
}
}
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())
108
);
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
{
/**
* @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)
109
->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))) {
return $this->redirectToRoute('homepage');
}
else {
$equipment = new Equipment();
$form = $this->createForm(new EquipmentFormType(),
$equipment);
$form->handleRequest($this->request);
if ($this->request->isMethod('POST')) {
if ($form->isSubmitted() && $form->isValid()) {
$valid = true;
if ($valid) {
$this->manager->persist($equipment);
$this->manager->flush();
//освязываем добавленные
foreach ($equipment->getUnits() as $unit) {
$unit->setEquipment($equipment);
$this->manager->persist($unit);
$this->manager->flush();
}
$this->addNotice('success',
'equipment.html.twig',
array('notice' => 'added', 'place' =>
$equipment->getPlace())
);
return $this-
>redirectToRoute('site_equipment_index');
}
}
}
$this->view['equipment']=null;
$this->forms['equipment'] = $form->createView();
$this->navigation = array('active' => 'equipments');
return $this-
>render('AppBundle:Equipments:equipment.html.twig');
}
}
/**
* @param Equipment $equipment
110
* @return RedirectResponse|Response
* @Config\Route("/equipment/{equipment}/edit", name =
"site_equipment_edit")
* @Config\ParamConverter("equipment", options = {"mapping":
{"equipment": "id"}})
*/
public function editAction(Equipment $equipment)
{
if (!($this->authChecker->isGranted(Role::ADMIN))) {
return $this->redirectToRoute('homepage');
}
else {
$form = $this->createForm(new EquipmentFormType(),
$equipment);
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
$valid = true;
if ($valid) {
$units = $equipment->getUnits();
foreach($units as $unit) {
$unit->setEquipment($equipment);
$this->manager->persist($unit);
$this->manager->flush();
}
$this->manager->persist($equipment);
$this->manager->flush();
$this->addNotice('success',
'equipment.html.twig',
array('notice' => 'changed', 'place' =>
$equipment->getPlace())
);
return $this-
>redirectToRoute('site_equipment_index');
}
}
$this->forms['equipment'] = $form->createView();
$this->view['equipment'] = $equipment;
$this->navigation = array('active' => 'equipments');
return $this-
>render('AppBundle:Equipments:equipment.html.twig');
}
}
/**
* @param Equipment $equipment
* @return Response
* @Config\Route("/equipment/{equipment}/remove", name =
"site_equipment_remove")
* @Config\ParamConverter("equipment", options = {"mapping":
{"equipment": "id"}})
*/
public function removeAction(Equipment $equipment)
{
$this->manager->remove($equipment);
$this->manager->flush();
$this->addNotice('error',
'equipment.html.twig',
111
array('notice' => 'removed', 'place' => $equipment-
>getPlace())
);
return $this->redirectToRoute('site_equipment_index');
}
}
<?php
namespace AppBundle\Controller;
use AppBundle\Entity\Vendor;
use AppBundle\Entity\Role;
use AppBundle\Form\Type\VendorFilterFormType;
use AppBundle\Form\Type\VendorFormType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration as Config;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
class VendorController extends InitializableController
{
/**
* @return RedirectResponse|Response
* @Config\Route("/vendor/index/{pagenum}", name =
"site_vendor_index", defaults={ "pagenum": "1"})
*/
public function indexAction($pagenum=1)
{
if (!($this->authChecker->isGranted(Role::ADMIN))) {
return $this->redirectToRoute('homepage');
}
else {
$form=$this->createForm(new VendorFilterFormType());
$caption = null;
$form->handleRequest($this->request);
$query = $this->getRepository('Vendor')-
>createQueryBuilder('v')
->orderBy('v.caption', 'DESC');
$countquery = $this->getRepository('Vendor')-
>createQueryBuilder('v')
->select('COUNT(DISTINCT v.id)');
if ($form->isSubmitted() && $form->isValid()) {
$caption = $form->get('caption')->getData();
}
if (!empty($caption)) {
$query->andWhere('LOWER(v.caption) LIKE LOWER(:caption)
')->setParameter('caption', '%' . trim($caption) . '%');
$countquery->andWhere('LOWER(v.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;
$vendors = $query->setFirstResult(($pagenum - 1) * 20)
112
->setMaxResults(20)
->getQuery()->getResult();
$this->view['page']=$pagenum;
$this->view['pages']=$pages;
$this->view['vendors'] = $vendors;
$this->view['form'] = $form->createView();
$this->navigation = array('active' => 'vendors');
return $this->render('AppBundle:Vendors:index.html.twig');
}
}
/**
* @return RedirectResponse|Response
* @Config\Route("/vendor/add", name = "site_vendor_add")
*/
public function addAction()
{
if (!($this->authChecker->isGranted(Role::ADMIN))) {
return $this->redirectToRoute('homepage');
}
else {
$vendor = new Vendor();
$form = $this->createForm(new VendorFormType(), $vendor);
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
$valid = true;
$sames = $this->getRepository('Vendor')-
>createQueryBuilder('v')
->select('COUNT(v.id) AS id')
->where('v.caption = :caption')
->setParameters(array('caption' => $vendor-
>getCaption()))
->getQuery()->getSingleScalarResult();
if ($sames > 0) {
$form->get('caption')->addError(new
FormError('Вендор с таким названием уже имеется в базе'));
$valid = false;
}
if ($valid) {
$this->manager->persist($vendor);
$this->manager->flush();
$this->addNotice('success',
'vendor.html.twig',
array('notice' => 'added', 'caption' => $vendor-
>getCaption())
);
return $this->redirectToRoute('site_vendor_index');
}
}
$this->view['vendor']=null;
$this->forms['vendor'] = $form->createView();
$this->navigation = array('active' => 'vendors');
return $this->render('AppBundle:Vendors:vendor.html.twig');
}
}
/**
113
* @param Vendor $vendor
* @return RedirectResponse|Response
* @Config\Route("/vendor/{vendor}/edit", name =
"site_vendor_edit")
* @Config\ParamConverter("vendor", options = {"mapping": {"vendor":
"id"}})
*/
public function editAction(Vendor $vendor)
{
if (!($this->authChecker->isGranted(Role::ADMIN))) {
return $this->redirectToRoute('homepage');
}
else {
$form = $this->createForm(new VendorFormType(), $vendor);
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
$valid = true;
$sames = $this->getRepository('Vendor')-
>createQueryBuilder('v')
->select('COUNT(v.id) AS id')
->where('v.caption = :caption')
->setParameters(array('caption' => $vendor-
>getCaption()))
->getQuery()->getSingleScalarResult();
if ($sames > 0) {
$form->get('caption')->addError(new
FormError('Компания с таким названием уже имеется в базе'));
$valid = false;
}
if ($valid) {
$this->manager->persist($vendor);
$this->manager->flush();
$this->addNotice('success',
'vendor.html.twig',
array('notice' => 'changed', 'caption' =>
$vendor->getCaption())
);
return $this->redirectToRoute('site_vendor_index');
}
}
$this->forms['vendor'] = $form->createView();
$this->view['vendor'] = $vendor;
$this->navigation = array('active' => 'vendor');
return $this->render('AppBundle:Vendors:vendor.html.twig');
}
}
/**
* @param Vendor $vendor
* @return Response
* @Config\Route("/vendor/{vendor}/remove", name =
"site_vendor_remove")
* @Config\ParamConverter("vendor", options = {"mapping": {"vendor":
"id"}})
*/
public function removeAction(Vendor $vendor)
{

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

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