77 lines
2.2 KiB
PHP
77 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Ramcar\BaseController;
|
|
use App\Ramcar\ServiceType;
|
|
use App\Ramcar\JOStatus;
|
|
use App\Entity\JobOrder;
|
|
use App\Entity\BatteryManufacturer;
|
|
use App\Entity\Customer;
|
|
use App\Entity\CustomerVehicle;
|
|
use App\Entity\Outlet;
|
|
use App\Entity\Rider;
|
|
|
|
use Doctrine\ORM\Query;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
|
|
|
use App\Menu\Generator as MenuGenerator;
|
|
use App\Access\Generator as ACLGenerator;
|
|
|
|
class JobOrderController extends BaseController
|
|
{
|
|
protected $acl_gen;
|
|
|
|
public function __construct(MenuGenerator $menu_gen, ACLGenerator $acl_gen)
|
|
{
|
|
$this->acl_gen = $acl_gen;
|
|
parent::__construct($menu_gen);
|
|
}
|
|
|
|
public function incomingForm()
|
|
{
|
|
$this->denyAccessUnlessGranted('jo_in.list', null, 'No access.');
|
|
|
|
$params = $this->initParameters('jo_in');
|
|
$params['obj'] = new JobOrder();
|
|
$params['mode'] = 'create';
|
|
|
|
$em = $this->getDoctrine()->getManager();
|
|
|
|
// get parent associations
|
|
$params['bmfgs'] = $em->getRepository(BatteryManufacturer::class)->findAll();
|
|
$params['customers'] = $em->getRepository(Customer::class)->findAll();
|
|
$params['outlet'] = $em->getRepository(Outlet::class)->findAll();
|
|
$params['rider'] = $em->getRepository(Rider::class)->findAll();
|
|
$params['service_types'] = ServiceType::getCollection();
|
|
$params['statuses'] = JOStatus::getCollection();
|
|
|
|
// response
|
|
return $this->render('job-order/incoming.html.twig', $params);
|
|
}
|
|
|
|
public function incomingSubmit(Request $req)
|
|
{
|
|
$this->denyAccessUnlessGranted('jo_in.list', null, 'No access.');
|
|
|
|
// create new row
|
|
$em = $this->getDoctrine()->getManager();
|
|
$row = new JobOrder();
|
|
|
|
// TODO: Validation, handling of job order
|
|
|
|
// DEBUG: Get all variables
|
|
error_log(print_r($req->request->all(), true));
|
|
|
|
// DEBUG: Fake error array
|
|
$error_array = [];
|
|
|
|
// DEBUG: Error response for now
|
|
return $this->json([
|
|
'success' => false,
|
|
'errors' => $error_array
|
|
], 422);
|
|
}
|
|
}
|