Commit fa94acb4 authored by notebook's avatar notebook
Browse files

Merge origin/master into skuska

Conflicts:
	composer.lock
	config/packages/security.yaml
	src/Controller/Admin/DashboardController.php
	symfony.lock
parent 6c993599
......@@ -48,7 +48,7 @@ public function viewOrderDetailAction(Request $request , $id)
$ordersitems = $em->getRepository('App:OrderItem')->findOrderItemsbyId($id);
return $this->render('orders/order_detail.html.twig', array(
'orders' => $orders->getQuery()->execute() , 'ordersitem' => $ordersitems->getQuery()->execute()
'orders' => $orders->getQuery()->execute() , 'ordersitem' => $ordersitems
));
}
/**
......@@ -87,7 +87,7 @@ public function addOrderingAction(Request $request)
$creation_date = date('Y-m-d', strtotime($creation_date));
$deliveryDate = date('Y-m-d', strtotime($deliverydate));
$em = $this->getDoctrine()->getManager();
$last_orders = $em->getRepository("App:Orders")->findLastInserted();
$last_orders = $em->getRepository("App:Orders")->findLastInserted();
$currentDate = date("Y-m-d");
$newindex = date('Ym', strtotime($currentDate))*10000 + 1;
if (isset($last_orders)){
......@@ -133,9 +133,9 @@ public function addOrderingAction(Request $request)
/**
* @Route("/addOrderItem", name="addOrderItem")
* @Route("/addOrderItem/{id}", name="addOrderItem")
*/
public function addOrderItemAction(Request $request)
public function addOrderItemAction(Request $request, $id)
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
......@@ -154,6 +154,57 @@ public function addOrderItemAction(Request $request)
$form = $this->createForm(AddOrderItemFormType::class, $orderitem);
$form->handleRequest($request);
try {
if ($form->isSubmitted() && $form->isValid()) {
$name = $form['name']->getData();
$qty = $form['qty']->getData();
$mu = $form['mu']->getData();
$unit_price = $form['unit_price']->getData();
$sum_total = $qty * $unit_price;
$em = $this->getDoctrine()->getManager();
$orders = $em
->getRepository(Orders::class)
->findOneBy(array(
'id' => $id
)
);
$orderitem = new OrderItem();
$orderitem->setName( $name );
$orderitem->setQty( $qty );
$orderitem->setMu( $mu );
$orderitem->setUnitPrice($unit_price);
$orderitem->setSumTotal($unit_price);
$orderitem->setOrders( $orders );
$em->persist($orderitem);
$em->flush();
$this->addFlash(
'success',
'Položka objednávky bola vytvorená.'
);
return $this->redirectToRoute("viewOrderDetail",array(
'id' => $id,));
}
} catch (DBALException $e){
$this->addFlash(
'danger',
"Objednávka nebola vytvorená."
);
}
return $this->render('forms/addorderitem.html.twig', array(
'form' => $form->createView()
));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment