Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppBundle\Controller;
- use Composer\CaBundle\CaBundle;
- use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Validation\Category;
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Component\HttpFoundation\Response;
- use AppBundle\Entity\Products;
- use AppBundle\Entity\Productcategory;
- use AppBundle\Entity\Nipples;
- use Symfony\Component\Form\Extension\Core\Type\TextType;
- use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
- use Symfony\Component\Form\Extension\Core\Type\SubmitType;
- use Symfony\Component\Form\Extension\Core\Type\MoneyType;
- use Symfony\Component\Form\Extension\Core\Type\HiddenType;
- use Symfony\Component\Form\Extension\Core\Type\DateType;
- use Symfony\Component\Form\Extension\Core\Type\RangeType;
- use Symfony\Bridge\Doctrine\Form\Type\EntityType;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
- use Symfony\Bundle\FrameworkBundle\Controller\Controller;
- class AdminController extends Controller
- {
- private $product;
- /**
- * @Route("/", name="AdminHome")
- */
- public function indexAction()
- {
- return $this->render('admin/pages/indexPage.html.twig', [
- ]);
- }
- /**
- * @Route("/rotators", name="RotatorsAdminList")
- */
- public function rotatorsAction()
- {
- return $this->render('admin/pages/rotatorList.html.twig', [
- ]);
- }
- /**
- * @Route("/rotators/add", name="RotatorAddNew")
- */
- public function rotatorAddAction()
- {
- $em = $this->getDoctrine()->getManager();
- $this->product = new Products();
- $this->product->setCategory($em->getRepository(Productcategory::class)->find(1));
- return $this->redirect($this->generateUrl('updateProduct'));
- }
- /**
- * @Route("/rotator/update", name="updateProduct")
- *
- */
- public function rotatorUpdateAction(Request $request)
- {
- var_dump($this->product);
- die();
- $em = $this->getDoctrine()->getManager();
- $form = $this->createFormBuilder()
- ->setMethod('POST')
- ->add('title')
- ->add('doublebearing')
- ->add('castiron')
- ->add('extrachannels')
- ->add('oposite')
- ->add('statloadpositive', ChoiceType::class,
- ['choices' => $this->staticLoadOptions(),
- 'placeholder' => 'izvēlies'
- ])
- ->add('torque', ChoiceType::class,
- ['choices' => $this->torqueOptions(),
- 'placeholder' => 'izvēlies'
- ])
- ->add('oilflow', ChoiceType::class,
- ['choices' => $this->oilflowOptions(),
- 'placeholder' => 'izvēlies'
- ])
- ->add('weight')
- ->add('toptype', ChoiceType::class,
- ['choices' => $this->topTypeOptions(),
- 'placeholder' => 'izvēlies'
- ])
- ->add('topsize')
- ->add('bottype')
- ->add('bottsize')
- ->add('rotationpressure', ChoiceType::class,
- ['choices' => $this->maxPressureOptions(),
- 'placeholder' => 'izvēlies'
- ])
- ->add('rotateinputchanel', ChoiceType::class,
- ['choices' => $this->nippleTypes(),
- 'placeholder' => 'izvēlies'
- ])
- ->add('openpressure', ChoiceType::class,
- ['choices' => $this->maxPressureOptions(),
- 'placeholder' => 'izvēlies'
- ])
- ->add('closepressure', ChoiceType::class,
- ['choices' => $this->maxPressureOptions(),
- 'placeholder' => 'izvēlies'
- ])
- ->add('toolinputchanel', ChoiceType::class,
- ['choices' => $this->nippleTypes(),
- 'placeholder' => 'izvēlies'
- ])
- ->add('tooloutputchanel_one', ChoiceType::class,
- ['choices' => $this->nippleTypes(),
- 'placeholder' => 'izvēlies'
- ])
- ->add('tooloutputchanel_two', ChoiceType::class,
- ['choices' => $this->nippleTypes(),
- 'placeholder' => 'izvēlies'
- ])
- ->add('extrapressure', ChoiceType::class,
- ['choices' => $this->maxPressureOptions(),
- 'placeholder' => 'izvēlies'
- ])
- ->add('extrainputchanel', ChoiceType::class,
- ['choices' => $this->nippleTypes(),
- 'placeholder' => 'izvēlies'
- ])
- ->add('extraoutputchanel', ChoiceType::class,
- ['choices' => $this->nippleTypes(),
- 'placeholder' => 'izvēlies'
- ])
- ->add('en_description')
- ->add('de_description')
- ->add('ru_description')
- ->add('lv_description')
- ->add('en_feature')
- ->add('de_feature')
- ->add('ru_feature')
- ->add('lv_feature')
- ->add('forestry')
- ->add('agriculture')
- ->add('construction')
- ->add('generalcargo')
- ->add('recycling')
- ->add('lenght')
- ->add('width')
- ->add('height')
- ->add('mainimage', EntityType::class, [
- 'required' => false,
- 'class' => 'AppBundle:Image',
- 'choice_label' => 'name',
- 'label_format' => 'Renderis',
- ])
- ->add('view_one', EntityType::class, [
- 'required' => false,
- 'class' => 'AppBundle:Image',
- 'choice_label' => 'name',
- 'label_format' => 'Renderis',
- ])
- ->add('view_two', EntityType::class, [
- 'required' => false,
- 'class' => 'AppBundle:Image',
- 'choice_label' => 'name',
- 'label_format' => 'Renderis',
- ])
- ->add('view_three', EntityType::class, [
- 'required' => false,
- 'class' => 'AppBundle:Image',
- 'choice_label' => 'name',
- 'label_format' => 'Renderis',
- ])
- ->add('Submit', SubmitType::class)
- ->getForm();
- $form->handleRequest($request);
- if ($request->isMethod('POST') && $form->isSubmitted() && $form->isValid()) {
- return $this->redirect($this->generateUrl('RotatorsAdminList'));
- }
- return $this->render('admin/pages/addRotatorForm.html.twig', [
- 'form' => $form->createView(),
- 'product' => $product,
- ]);
- }
- public function nippleTypes()
- {
- $em = $this->getDoctrine()->getManager();
- $nipples = $em->getRepository(Nipples::class)->findAll();
- foreach ($nipples as $nipple) {
- $id = $nipple->getId();
- $type = $nipple->getNipletype();
- $size = $nipple->getNiplesize();
- $label = "$type $size";
- $nipplelist[$label] = $id;
- }
- return $nipplelist;
- }
- public function rotatorTopTypes()
- {
- $rotatorTopTypes = [
- '1' => 'eye',
- '2' => 'fork',
- '3' => 'flange',
- ];
- return $rotatorTopTypes;
- }
- public function rotatorBottomTypes()
- {
- $rotatorBottomTypes = [
- '1' => 'axle',
- '2' => 'flange',
- ];
- return $rotatorBottomTypes;
- }
- public function staticLoadOptions()
- {
- $staticLoadOptions = [
- '10' => '10',
- '30' => '30',
- '45' => '45',
- '55' => '55',
- '60' => '60',
- '100' => '100',
- '120' => '120',
- '160' => '160'
- ];
- return $staticLoadOptions;
- }
- public function dynaLoadOptions()
- {
- $dynaLoadOptions = [
- '5' => '5',
- '15' => '15',
- '25' => '25',
- '30' => '30',
- '50' => '50',
- '60' => '60',
- '80' => '80'
- ];
- return $dynaLoadOptions;
- }
- public function maxPressureOptions()
- {
- $maxPressureOptions = [
- '200' => '200',
- '250' => '250',
- '300' => '300'
- ];
- return $maxPressureOptions;
- }
- public function oilflowOptions()
- {
- $oilflowOptions = [
- '10' => '10',
- '20' => '20',
- '25' => '25',
- '30' => '30',
- '35' => '35',
- '40' => '40',
- ];
- return $oilflowOptions;
- }
- public function torqueOptions()
- {
- $torqueOptions = [
- '350' => '350',
- '900' => '900',
- '1200' => '1200',
- '1300' => '1300',
- '1850' => '1850',
- '2800' => '2800',
- '2900' => '2900',
- '3400' => '3400',
- ];
- return $torqueOptions;
- }
- public function topTypeOptions()
- {
- $topTypeOptions = [
- 'A' => '1',
- 'V' => '2',
- 'T' => '3',
- ];
- return $topTypeOptions;
- }
- public function calculateNegativeLoad($n, $x = 5)
- {
- $n = $n * 0.8;
- return (round($n) % $x === 0) ? round($n) : round(($n + $x / 2) / $x) * $x;
- }
- public function calculateDynamicLoad($n)
- {
- if ($n == 55) {
- return 0.5 * $n + 5;
- } else {
- return 0.5 * $n;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement