Файл: Проектирование реализации операций бизнес-процесса «Планирование закупок и размещение заказов поставщикам».pdf
Добавлен: 29.06.2023
Просмотров: 69
Скачиваний: 2
СОДЕРЖАНИЕ
1.1. Выбор комплекса задач автоматизации
1.2. Характеристика существующих бизнес – процессов
1.3. Характеристика документооборота, возникающего при решении задачи
1.4. Обоснование проектных решений по информационному обеспечению
1.5. Обоснование проектных решений по программному обеспечению
2.1. Информационная модель и её описание
2.2. Характеристика нормативно-справочной, входной и оперативной информации
2.3. Характеристика результатной информации
2.4. Общие положения (дерево функций и сценарий диалога)
2.5. Характеристика базы данных
2.6. Структурная схема пакета (дерево вызова программных модулей)
14. Макдональд, М. Созданиец Web-сайта. Недостающее руководство / М. Макдональд. – Спб. : БХВ-Петербург, 2013. – 624 с.
17. Маклаков С.В. BPwin и Erwin. CASE-средства разработки информационных систем / С.В. Маклаков. – М. : ДИАЛОГ–МИФИ, 2014. – 369 c.
18. Тельнов, Ю.Ф. Информационные системы и технологии. Information System and Technologies: науч. издание под ред. Тельнова Ю. Ф. – М: Юнити-Дана, 2012 – 303 с.
19. Флэнаган, Д. Javascript. Подробное руководство / Д. Флэнаган : пер с англ. – М. : Символ-Плюс, 2013. – 1080 с.
ПРИЛОЖЕНИЯ
<?php
namespace AppBundle\Controller;
use AppBundle\Entity\Notification;
use AppBundle\Entity\Order;
use AppBundle\Entity\OrderComment;
use AppBundle\Entity\OrderProduct;
use AppBundle\Entity\OrderProvider;
use AppBundle\Entity\OrderProviderComment;
use AppBundle\Entity\OrderStatus;
use AppBundle\Entity\ProviderProduct;
use AppBundle\Entity\User;
use AppBundle\Form\Type\OrderCommentFormType;
use AppBundle\Form\Type\OrderEndFormType;
use AppBundle\Form\Type\OrderFilterFormType;
use AppBundle\Form\Type\OrderFormType;
use AppBundle\Form\Type\OrderProductFormType;
use AppBundle\Form\Type\OrderProviderCommentFormType;
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 OrderController extends InitializableController
{
/**
* @return RedirectResponse|Response
* @Config\Route("/orders/index/{pagenum}", name = "site_orders_index", defaults={ "pagenum": "1"})
*/
public function indexAction($pagenum=1)
{
$form=$this->createForm(new OrderFilterFormType());
$caption = null;
$form->handleRequest($this->request);
$ordersquery = $this->getRepository('Order')->createQueryBuilder('o')
->leftJoin('o.specs', 's')
->where('o.deleted = 0')
->orderBy('o.vip', 'DESC')
->addOrderBy('o.status', 'ASC')
->addOrderBy('o.plandate', 'ASC');
$ordersquerycount = $this->getRepository('Order')->createQueryBuilder('o')
->select('COUNT(DISTINCT o.id)')
->leftJoin('o.specs', 's')
->where('o.deleted = 0')
->orderBy('o.plandate', 'DESC');
if ($form->isSubmitted() && $form->isValid()) {
$id = $form->get('id')->getData();
$status=$form->get('status')->getData();
$spec=$form->get('spec')->getData();
}
if (!empty($id)) {
$ordersquery->andWhere('o.id = :id')->setParameter('id', $id);
$ordersquerycount->andWhere('o.id = :id')->setParameter('id', $id);
}
if (!empty($status)) {
$ordersquery->andWhere('o.status = :status')->setParameter('status', $status);
$ordersquerycount->andWhere('o.status = :status')->setParameter('status', $status);
}
if (!empty($spec)) {
$ordersquery->andWhere('s.id = :spec')->setParameter('spec', $spec);
$ordersquerycount->andWhere('s.id = :spec')->setParameter('spec', $spec);
}
$count=$ordersquerycount->getQuery()->getSingleScalarResult();
$pages = floor($count / 20) + ($count % 20 > 0 ? 1 : 0);
if ($pages < 1) $pages = 1;
if ($pagenum > $pages) $pagenum = $pages;
$orders = $ordersquery->setFirstResult(($pagenum - 1) * 20)
->setMaxResults(20)
->getQuery()->getResult();
$this->view['orders'] = $orders;
$this->view['form'] = $form->createView();
$this->view['page']=$pagenum;
$this->view['pages']=$pages;
$this->navigation = array('active' => 'orders');
return $this->render('AppBundle:Orders:index.html.twig');
}
/**
* @return RedirectResponse|Response
* @Config\Route("/orders/add", name = "site_orders_add")
*/
public function addAction()
{
$order = new Order();
$form = $this->createForm(new OrderFormType(), $order);
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
/** @var OrderStatus $newstatus**/
$newstatus = $this->getRepository('OrderStatus')->findOneBy(array('id'=>1));
$order->setStatus($newstatus);
foreach ($order->getSpecs() as $spec) {
$spec->getOrders()->add($order);
}
$this->manager->persist($order);
$this->manager->flush();
$this->addNotice('success',
'orders.html.twig',
array('notice' => 'order_added', 'caption' => $order->getId())
);
return $this->redirectToRoute('site_orders_edit',array('order' => $order->getId(), 'step' => 1));
}
$this->view['order'] = null;
$this->forms['order'] = $form->createView();
$this->navigation = array('active' => 'orders');
return $this->render('AppBundle:Orders:order1.html.twig');
}
/**
* @param Order $order
* @return RedirectResponse|Response
* @Config\Route("/orders/{order}/edit/{step}", name = "site_orders_edit")
* @Config\ParamConverter("order", options = {"mapping": {"order": "id"}})
*/
public function editAction(Order $order, $step)
{
if ($step > 4) {
$step = 4;
}
switch ($step) {
//общие данные
case 1:
$form = $this->createForm(new OrderFormType(), $order);
$specs=array();
foreach ($order->getSpecs() as $spec) {
array_push($specs, $spec);
}
$form2 = $this->createForm(new OrderEndFormType());
if ($this->request->isMethod('POST')) {
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
//проверяем был ли добавлен новый специалист и если был - отправляем ему уведомление
foreach ($order->getSpecs() as $spec) {
if (!(in_array($spec,$specs ))) {
$this->addNotification($spec,"Вам назначен заказ №".$order->getId().". <a href='".$this->generateUrl('site_orders_edit', array('order'=>$order->getId(), 'step'=>1))."'>Подробнее</a>" );
$spec->getOrders()->add($order);
}
}
$specsnew=array();
foreach ($order->getSpecs() as $spec) {
array_push($specsnew, $spec);
}
//проверяем, был ли удален пользователь с заказа, если был - отправляем ему уведомление
foreach ($specs as $spec) {
if (!(in_array($spec,$specsnew ))) {
$this->addNotification($spec,"С Вас было снято назначение на заказ №".$order->getId().". <a href='".$this->generateUrl('site_orders_edit', array('order'=>$order->getId(), 'step'=>1))."'>Подробнее</a>" );
$spec->getOrders()->removeElement($order);
}
}
$this->manager->persist($order);
$this->manager->flush();
$this->addNotice('success',
'orders.html.twig',
array('notice' => 'order_changed', 'caption' => $order->getId())
);
return $this->redirectToRoute(
'site_orders_edit',
array('order' => $order->getId(), 'step' => 1)
);
}
$form2->handleRequest($this->request);
if ($form2->isSubmitted() && $form2->isValid()) {
//ставим дату
$order->setFactdate($form2->get('factdate')->getData());
//ставим статус
/** @var OrderStatus $newstatus**/
$newstatus = $this->getRepository('OrderStatus')->findOneBy(array('id'=>7));
$order->setStatus($newstatus);
//ищем выбранного поставщика
/** @var OrderProvider $orderprovider */
$orderprovider=$this->getRepository('OrderProvider')->createQueryBuilder('op')
->where('op.order = :order')
->andWhere('op.selected = true')
->setParameters(array('order'=>$order))->getQuery()->getOneOrNullResult();
if ($orderprovider) {
//добавляем коммент
$comment= new OrderProviderComment();
$comment->setUser($this->getUser());
$comment->setOrderprovider($orderprovider);
$comment->setDescription($form2->get('comment')->getData());
$this->manager->persist($comment);
$this->manager->flush();
//обновляем рейтинг
$orderprovider->setBall($form2->get('ball')->getData());
$this->manager->persist($orderprovider);
$newrate=$this->getRepository('OrderProvider')->createQueryBuilder('op')
->select('AVG (op.ball)')
->where('op.provider = :provider')
->andWhere('op.selected = true')
->setParameters(array('provider'=>$orderprovider->getProvider()))
->getQuery()->getSingleScalarResult();
$provider= $orderprovider->getProvider();
$provider->setRate($newrate);
$this->manager->persist($provider);
}
$this->manager->persist($order);
$this->manager->flush();
$this->addNotice('success',
'orders.html.twig',
array('notice' => 'order_ended', 'caption' => $order->getId())
);
//отправляем уведомление админу
/** @var user $adminuser**/
$adminuser = $this->getRepository('User')->findOneBy(array('username'=>'admin'));
$this->addNotification($adminuser,"Пользователь ".$this->getUser()->getUserfio()." завершил заказ №".$order->getId().". <a href='".$this->generateUrl('site_orders_edit', array('order'=>$order->getId(), 'step'=>1))."'>Подробнее</a>" );
return $this->redirectToRoute('site_orders_index');
}
}
$this->view['order'] = $order;
$this->forms['order'] = $form->createView();
$this->forms['endorder'] = $form2->createView();
$this->navigation = array('active' => 'orders');
return $this->render('AppBundle:Orders:order1.html.twig');
break;
//список товаров
case 2:
$form = $this->createForm(new OrderProductFormType());
$products=$this->getRepository('OrderProduct')->createQueryBuilder('op')
->leftJoin('op.product','p')
->where('p.deleted <> 1')
->andWhere('op.order = :order')
->setParameters(array('order'=>$order))
->orderBy('p.category')->getQuery()->getResult();
if ($this->request->isXmlHttpRequest() && $this->request->isMethod('POST')) {
return $this->handleProductsAjaxRequest();
}
if ($this->request->isMethod('POST')) {
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
$orderproduct = $form->getData();
$orderproduct->setOrder($order);
$this->manager->persist($orderproduct);
$this->manager->flush();
return $this->redirectToRoute(
'site_orders_edit',
array('order' => $order->getId(), 'step' => 2)
);
}
}
$this->view['order'] = $order;
$this->view['products'] = $products;
$this->forms['orderproduct'] = $form->createView();
$this->navigation = array('active' => 'orders');
return $this->render('AppBundle:Orders:order2.html.twig');
break;
//список поставщиков
case 3:
$orderproviders=$this->getRepository('OrderProvider')->createQueryBuilder('op')
->leftJoin('op.provider','pr')
->where('op.order = :order')
->orderBy('op.selected', 'DESC')
->addOrderBy('op.active', 'DESC')
->addOrderBy('pr.rate', 'DESC')
->setParameters(array('order'=>$order))
->getQuery()->getResult();
$this->view['order'] = $order;
$this->view['orderproviders'] = $orderproviders;
$this->navigation = array('active' => 'orders');
return $this->render('AppBundle:Orders:order3.html.twig');
break;
//комментарии
case 4:
$ordercomments=$this->getRepository('OrderComment')->createQueryBuilder('oc')
->where('oc.order = :order')
->orderBy('oc.id')
->setParameters(array('order'=>$order))
->getQuery()->getResult();
$ordercomment=new OrderComment();
$form=$this->createForm(new OrderCommentFormType(),$ordercomment );
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
$ordercomment->setOrder($order);
$ordercomment->setUser($this->getUser());
$this->manager->persist($ordercomment);
$this->manager->flush();
return $this->redirectToRoute(
'site_orders_edit',
array('order' => $order->getId(), 'step' => 4)
);
}
$this->view['order'] = $order;
$this->view['ordercomments'] = $ordercomments;
$this->forms['ordercomment']=$form->createView();
$this->navigation = array('active' => 'orders');
return $this->render('AppBundle:Orders:order4.html.twig');
break;
}
return $this->redirect('site_orders_index');
}
protected function handleProductsAjaxRequest()
{
$category = $this->request->get('category', null);
if (is_null($category)) return new JsonResponse();
$products=$this->getRepository('Product')->createQueryBuilder('p')
->select('p.id as id')
->where('p.category = :category')
->andWhere('p.deleted=0')
->setParameters(array('category'=> $category))
->getQuery()->getResult(Query::HYDRATE_ARRAY);
return new JsonResponse($products);
}
/**
* @param Order $order
* @return Response
* @Config\Route("/orders/{order}/remove", name = "site_orders_remove")
* @Config\ParamConverter("order", options = {"mapping": {"order": "id"}})
*/
public function removeAction(Order $order)
{
$order->setDeleted(true);
$this->manager->persist($order);
$this->manager->flush();
return $this->redirectToRoute('site_orders_index');
}
//добавление поставщиков к заказу
/**
* @param Order $order
* @return Response
* @Config\Route("/orders/{order}/providersadd", name = "site_orders_providers_add")
* @Config\ParamConverter("order", options = {"mapping": {"order": "id"}})
*/
public function providersaddAction(Order $order)
{
//Формируем массив поставшиков с нужными товарами
$products=$this->getRepository('Product')->createQueryBuilder('p')
->innerJoin('p.orderproducts','op')
->where('op.order = :order')
->setParameters(array('order'=>$order))
->getQuery()
->getResult();
$providersp=$this->getRepository('Provider')->createQueryBuilder('p')
->leftJoin('p.providerproducts','pp')
->where('pp.product IN (:products)')
->setParameters(array('products'=>$products))
->getQuery()
->getResult();
//Формируем поставщиков с нужными категориями товаров
$categories=$this->getRepository('ProductCategory')->createQueryBuilder('pc')
->innerJoin('pc.products', 'p')
->innerJoin('p.orderproducts','op')
->where('op.order = :order')
->setParameters(array('order'=>$order))
->getQuery()
->getResult();
$providersc=$this->getRepository('Provider')->createQueryBuilder('p')
->leftJoin('p.providerproducts','pp')
->leftJoin('pp.product', 'pr')
->where('pr.category IN (:categories)')
->setParameters(array('categories'=>$categories))
->getQuery()
->getResult();
//склеиваем массивы
$providers=array_merge($providersp,$providersc);
//убирем повторения
$providers=array_unique($providers, SORT_REGULAR );
$countpr=0;
$countc=0;
// в цикле добавляем поставщиков к заказам
/** @var User $usersystem**/
$usersystem = $this->getRepository('User')->findOneBy(array('username'=>'system'));
foreach ($providers as $provider){
$orderProvider=new OrderProvider();
$orderProvider->setProvider($provider);
$orderProvider->setOrder($order);
//и добавляем к каждому комментарий
$orderProviderComment = new OrderProviderComment();
if ( in_array($provider,$providersp)) {
$orderProviderComment->setDescription('Совпадение по товарам');
$countpr++;
}
else {
$orderProviderComment->setDescription('Совпадение по категориям');
$countc++;
}
$orderProviderComment->setOrderprovider($orderProvider);
$orderProviderComment->setUser($usersystem);
$this->manager->persist($orderProvider);
$this->manager->persist($orderProviderComment);
$this->manager->flush();
}
//Добавляем коммент о сформированном списке поставщиков
$ordercomment = new OrderComment();
$ordercomment->setUser($usersystem);
$ordercomment->setOrder($order);
$ordercomment->setDescription('Автоматически сформирован список потенциальных поставщиков. Всего: '.count($providers).'. Совпадений по товарам:'.$countpr.'. Совпадений по категориям: '.$countc);
$this->manager->persist($ordercomment);
$this->manager->flush();
return $this->redirectToRoute(
'site_orders_edit',
array('order' => $order->getId(), 'step' => 3)
);
}
/**
* @param Order $order
* @return Response
* @Config\Route("/orders/{order}/changestatus/{status}", name = "site_orders_changestatus")
* @Config\ParamConverter("order", options = {"mapping": {"order": "id"}})
*/
public function changestatusAction(Order $order, $status)
{
$oldstatus=$order->getStatus()->getId();
/** @var OrderStatus $newstatus**/
$newstatus = $this->getRepository('OrderStatus')->findOneBy(array('id'=>$status));
$order->setStatus($newstatus);
//отправляем уведомление пользователю
$descriptiontext='';
$notifusers=$order->getSpecs();
switch ($status) {
case 2:
$descriptiontext="Вам был назначен новый заказ № ".$order->getId().". Не забудьте подтвердить принятие в работу. <a href='".$this->generateUrl('site_orders_edit', array('order'=>$order->getId(), 'step'=>1))."'>Подробнее</a> ";
break;
case 3:
//если перед этим был статус "Ждет подтверждения"
if ($oldstatus==4) {
$descriptiontext="Заказ № ".$order->getId()." был вернут в работу. <a href='".$this->generateUrl('site_orders_edit', array('order'=>$order->getId(), 'step'=>1))."'>Подробнее</a> ";
//отменяем выбор поставщика
foreach ($order->getOrderproviders() as $orderprovider) {
$orderprovider->setSelected(false);
$this->manager->persist($orderprovider);
$this->manager->flush();
}
}
//иначе увеомление админу
else {
$descriptiontext="Пользователь ".$this->getUser()->getUserfio()." принял заказ № ".$order->getId()." в работу. <a href='".$this->generateUrl('site_orders_edit', array('order'=>$order->getId(), 'step'=>1))."'>Подробнее</a> ";
$notifusers=array();
/** @var User $notifuser**/
$notifuser = $this->getRepository('User')->findOneBy(array('username'=>'admin'));
array_push($notifusers,$notifuser );
}
break;
case 5: $descriptiontext="Выбор поставщика в заказе №".$order->getId()." был утвержден. <a href='".$this->generateUrl('site_orders_edit', array('order'=>$order->getId(), 'step'=>1))."'>Подробнее</a>";
break;
case 6: $descriptiontext="Заказ №".$order->getId()." был отменен. <a href='".$this->generateUrl('site_orders_edit', array('order'=>$order->getId(), 'step'=>1))."'>Подробнее</a>";
break;
}
foreach ( $notifusers as $notifuser) {
$this->addNotification($notifuser,$descriptiontext);
}
$this->manager->persist($order);
$this->manager->flush();
$this->addNotice('success',
'orders.html.twig',
array('notice' => 'order_changestatus', 'caption' => $order->getId())
);
return $this->redirectToRoute('site_orders_edit', array('order' => $order->getId(), 'step' => 1));
}
/**
* @param OrderProduct $orderproduct
* @param Order $order
* @return Response
* @Config\Route("/orders/{order}/orderproducts/{orderproduct}/remove", name = "site_orderproducts_remove")
* @Config\ParamConverter("orderproduct", options = {"mapping": {"orderproduct": "id"}})
* @Config\ParamConverter("order", options = {"mapping": {"order": "id"}})
*/
public function removeproductAction(OrderProduct $orderproduct, Order $order)
{
$this->manager->remove($orderproduct);
$this->manager->flush();
return $this->redirectToRoute('site_orders_edit', array('order'=>$order->getId(), 'step'=>2));
}
/**
* @param OrderProvider $orderprovider
* @param Order $order
* @return Response
* @Config\Route("/orders/{order}/orderproviders/{orderprovider}/edit", name = "site_orderprovider_edit")
* @Config\ParamConverter("orderprovider", options = {"mapping": {"orderprovider": "id"}})
* @Config\ParamConverter("order", options = {"mapping": {"order": "id"}})
*/
public function orderproviderAction(OrderProvider $orderprovider, Order $order)
{
//Инфа по продуктам
//в цикле перебираем продукты
$products=array();
$orderproducts=$this->getRepository('OrderProduct')->createQueryBuilder('op')
->leftJoin('op.product', 'p')
->where('op.order = :order')
->andWhere('p.deleted = false')
->setParameters(array('order'=>$order))
->getQuery()->getResult();
foreach ($orderproducts as $orderproduct) {
//собираем в массив данные по каждому
$product=array();
$product['product']=$orderproduct->getProduct();
//запрашиваем цену, предоплату и срок поступления
/** @var ProviderProduct $providerproduct**/
$providerproduct=$this->getRepository('ProviderProduct')->createQueryBuilder('pp')
->where('pp.product = :product')
->andWhere('pp.provider = :provider')
->setParameters(array('product'=>$orderproduct->getProduct(), 'provider'=>$orderprovider->getProvider() ))
->getQuery()->getOneOrNullResult();
//если есть - пихаем в массив
if ($providerproduct) {
$product['price']=$providerproduct->getPrice();
$product['prepay']=$providerproduct->getPrepay();
$product['delivarytime']=$providerproduct->getDelivarytime();
}
else {
$product['price']=null;
$product['prepay']=null;
$product['delivarytime']=null;
}
//запрашиваем сколько заказов было выполнено поставщиком с таким товаром
$countorders = $this->getRepository('Order')->createQueryBuilder('o')
->leftJoin('o.orderproviders','op')
->leftJoin('o.orderproducts', 'opr')
->where('op.provider = :provider')
->andWhere('opr.product = :product')
->andWhere('op.selected =1')
->setParameters(array('provider'=>$orderprovider->getProvider(), 'product'=>$orderproduct->getProduct()))
->getQuery()->getArrayResult();
$countorders=count($countorders);
//если есть - пихаем в массив
$product['countorders']=$countorders;
array_push($products, $product);
}
//Комментарии
$orderprovidercomments = $this->getRepository('OrderProviderComment')->createQueryBuilder('opc')
->where('opc.orderprovider = :orderprovider')
->orderBy('opc.id')
->setParameters(array('orderprovider'=>$orderprovider))
->getQuery()->getResult();
$orderprovidercomment=new OrderProviderComment();
$form=$this->createForm(new OrderProviderCommentFormType(),$orderprovidercomment );
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
$orderprovidercomment->setOrderprovider($orderprovider);
$orderprovidercomment->setUser($this->getUser());
$this->manager->persist($orderprovidercomment);
$this->manager->flush();
return $this->redirectToRoute(
'site_orderprovider_edit',
array('order' => $order->getId(), 'orderprovider' => $orderprovider->getId())
);
}
$this->view['order'] = $order;
$this->view['orderprovider'] = $orderprovider;
$this->view['products']=$products;
$this->view['orderprovidercomments'] = $orderprovidercomments;
$this->forms['orderprovidercomment']=$form->createView();
$this->navigation = array('active' => 'orders');
return $this->render('AppBundle:Orders:orderprovider.html.twig');
}
//скрытие заказа
/**
* @param OrderProvider $orderprovider
* @param Order $order
* @return Response
* @Config\Route("/orders/{order}/orderproviders/{orderprovider}/disabled", name = "site_orderprovider_disabled")
* @Config\ParamConverter("orderprovider", options = {"mapping": {"orderprovider": "id"}})
* @Config\ParamConverter("order", options = {"mapping": {"order": "id"}})
*/
public function orderproviderdisapledAction(OrderProvider $orderprovider, Order $order)
{
$orderprovider->setActive(false);
$this->manager->persist($orderprovider);
$this->manager->flush();
return $this->redirectToRoute(
'site_orderprovider_edit',
array('order' => $order->getId(), 'orderprovider' => $orderprovider->getId())
);
}
//Открытие заказа
/**
* @param OrderProvider $orderprovider
* @param Order $order
* @return Response
* @Config\Route("/orders/{order}/orderproviders/{orderprovider}/enabled", name = "site_orderprovider_enabled")
* @Config\ParamConverter("orderprovider", options = {"mapping": {"orderprovider": "id"}})
* @Config\ParamConverter("order", options = {"mapping": {"order": "id"}})
*/
public function orderproviderenapledAction(OrderProvider $orderprovider, Order $order)
{
$orderprovider->setActive(true);
$this->manager->persist($orderprovider);
$this->manager->flush();
return $this->redirectToRoute(
'site_orderprovider_edit',
array('order' => $order->getId(), 'orderprovider' => $orderprovider->getId())
);
}
//выбор заказа
/**
* @param OrderProvider $orderprovider
* @param Order $order
* @return Response
* @Config\Route("/orders/{order}/orderproviders/{orderprovider}/selected", name = "site_orderprovider_selected")
* @Config\ParamConverter("orderprovider", options = {"mapping": {"orderprovider": "id"}})
* @Config\ParamConverter("order", options = {"mapping": {"order": "id"}})
*/
public function orderproviderselectedAction(OrderProvider $orderprovider, Order $order)
{
$orderprovider->setSelected(true);
/** @var OrderStatus $newstatus**/
$newstatus = $this->getRepository('OrderStatus')->findOneBy(array('id'=>4));
$order->setStatus($newstatus);
/** @var user $adminuser**/
$adminuser = $this->getRepository('User')->findOneBy(array('username'=>'admin'));
//отправляем уведомление пользователю
$notificationtext="Пользователь".$this->getUser()->getUserfio()." выбрал поставщика для заказа № ".$order->getId().". Необходимо подтвердит результат. <a href='".$this->generateUrl('site_orders_edit', array('order'=>$order->getId(), 'step'=>3))."'>Подробнее</a> ";
$this->addNotification($adminuser, $notificationtext);
$this->manager->persist($order);
$this->manager->flush();
return $this->redirectToRoute(
'site_orders_edit',
array('order' => $order->getId(), 'step' => 3)
);
}
public function addNotification (User $user, $description) {
$notification = new Notification();
$notification->setUser($user);
$notification->setDescription($description);
$this->manager->persist($notification);
$this->manager->flush();
}
}