src/Controller/Admin/OrderCrudController.php line 850

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Admin;
  3. use App\Controller\Admin\Order\Partial\OrderPartialControllerDynamicFields;
  4. use App\Controller\Admin\Order\Partial\OrderPartialControllerDynamicLists;
  5. use App\Controller\Admin\Order\Partial\OrderPartialControllerFields01;
  6. use App\Controller\Admin\Order\Partial\OrderPartialControllerLeges;
  7. use App\Controller\Admin\Order\Partial\OrderPartialControllerModel;
  8. use App\Controller\Admin\Order\Partial\OrderPartialControllerOntwerp;
  9. use App\Controller\Admin\Order\Partial\OrderPartialControllerStep01;
  10. use App\Controller\Admin\Order\Partial\OrderPartialControllerStep02;
  11. use App\Controller\Admin\Order\Partial\OrderPartialControllerStep03;
  12. use App\Controller\Admin\Order\Partial\OrderPartialControllerStep04;
  13. use App\Controller\Admin\Order\Partial\OrderPartialControllerStep05;
  14. use App\Controller\Admin\Order\Partial\TabOooController;
  15. use App\Controller\Admin\Orderonderdeel\Sub\OrderonderdeelSubController;
  16. use App\Controller\Admin\Orderregel\Sub\OrderregelSubController;
  17. use App\Controller\Admin\Reminder\ReminderCrudController;
  18. use App\Controller\Admin\Traits\ReferrerTrait;
  19. use App\EasyAdmin\BewerkTabField;
  20. use App\EasyAdmin\OrderInfoRecordField;
  21. use App\EasyAdmin\OrderMeldingField;
  22. use App\Entity\Order;
  23. use DateTimeImmutable;
  24. use App\Entity\Familie;
  25. use App\Entity\Prospect;
  26. use App\Service\OpenTBS;
  27. use App\Entity\Orderstatus;
  28. use Doctrine\ORM\QueryBuilder;
  29. use App\Service\DefineIndexList;
  30. use App\Service\TbsTemplateVars;
  31. use App\Service\UploadedfileService;
  32. use App\Service\CreateDbEntryService;
  33. use App\EasyAdmin\OrderUitgelichtField;
  34. use Doctrine\ORM\EntityManagerInterface;
  35. use App\Service\DefineOfferteOrderService;
  36. use App\EasyAdmin\OrderOverzichtBasisField;
  37. use App\EasyAdmin\OrderOverzichtRecordField;
  38. use App\Service\DefineNewOrdernummerService;
  39. use App\EasyAdmin\OrderOverzichtWorkflowField;
  40. use App\EasyAdmin\OrderSummaryField;
  41. use App\EasyAdmin\WorkflowOrderField;
  42. use App\Entity\Orderonderdeel;
  43. use App\Service\AdminReferrer;
  44. use App\Service\ChangeSetService;
  45. use App\Service\FinanceOrderService;
  46. use App\Service\OrderChecker;
  47. use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
  48. use EasyCorp\Bundle\EasyAdminBundle\Field\Field;
  49. use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
  50. use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
  51. use EasyCorp\Bundle\EasyAdminBundle\Config\Filters;
  52. use EasyCorp\Bundle\EasyAdminBundle\Field\DateField;
  53. use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
  54. use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
  55. use EasyCorp\Bundle\EasyAdminBundle\Field\MoneyField;
  56. use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
  57. use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
  58. use Symfony\Component\HttpFoundation\RedirectResponse;
  59. use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField;
  60. use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
  61. use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
  62. use EasyCorp\Bundle\EasyAdminBundle\Field\CollectionField;
  63. use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
  64. use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
  65. use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
  66. use Symfony\Component\HttpFoundation\Request;
  67. use Symfony\Component\HttpFoundation\Response;
  68. use Symfony\Component\Security\Core\Security;
  69. class OrderCrudController extends AbstractCrudController
  70. {
  71.     //use ReferrerTrait;
  72.     public $user;
  73.     public string $controllerFqcnAfterSetStatus;
  74.     public string $actionAfterSetStatus;
  75.     public string $tabAfterSetStatus;
  76.     public int $entityIdAfterSetStatus;
  77.     private array $partialFields;
  78.     public array $httpVars;
  79.     public array $changeSet;
  80.     public function __construct(
  81.         private UploadedfileService $uploadedfileService,
  82.         private CreateDbEntryService $createDbEntryService,
  83.         private EntityManagerInterface $entityManager,
  84.         public DefineOfferteOrderService $defineOfferteOrderService,
  85.         public DefineNewOrdernummerService $defineNewOrdernummerService,
  86.         public OpenTBS $OpenTBS,
  87.         private AdminUrlGenerator $adminUrlGenerator,
  88.         public TbsTemplateVars $tbsTemplateVars,
  89.         public DefineIndexList $defineIndexList,
  90.         public Security $security,
  91.         public FinanceOrderService $financeOrderService,
  92.     ) {
  93.         //dd(phpinfo());
  94.         //dd($_REQUEST,$_GET, $_POST);
  95.         $this->uploadedfileService $uploadedfileService;
  96.         $this->createDbEntryService $createDbEntryService;
  97.         $this->entityManager $entityManager;
  98.         $this->defineOfferteOrderService $defineOfferteOrderService;
  99.         $this->defineNewOrdernummerService $defineNewOrdernummerService;
  100.         $this->OpenTBS $OpenTBS;
  101.         $this->adminUrlGenerator =  $adminUrlGenerator;
  102.         $this->tbsTemplateVars $tbsTemplateVars;
  103.         $this->defineIndexList $defineIndexList;
  104.         $this->security $security;
  105.         $this->controllerFqcnAfterSetStatus get_class($this);
  106.         $this->actionAfterSetStatus Action::DETAIL;
  107.         $this->entityIdAfterSetStatus 0;
  108.         $this->httpVars = array();
  109.         $this->partialFields = array();
  110.         $this->changeSet = array();
  111.         $this->financeOrderService $financeOrderService;
  112.     }
  113.     public static function getEntityFqcn(): string
  114.     {
  115.         return Order::class;
  116.     }
  117.     public function getEntityManager(): EntityManagerInterface
  118.     {
  119.         return $this->entityManager;
  120.     }
  121.     public function detail(AdminContext $adminContext)
  122.     {
  123.         $this->financeOrderService->calculateAndWritePrijs($adminContext->getEntity()->getInstance());
  124.         return parent::detail($adminContext);
  125.     }
  126.     // public function configureCrud(Crud $crud): Crud
  127.     // {
  128.     //     return $crud
  129.     //         //->setFormThemes(['admin/fields/attachments.form.twig', '@EasyAdmin/crud/form_theme.html.twig'])
  130.     //         ->showEntityActionsInlined()
  131.     //         ;
  132.     // }
  133.     public function configureActions(Actions $actions): Actions
  134.     {
  135.         if (isset($_REQUEST['entityId'])) {
  136.             $entityId $_REQUEST['entityId'];
  137.             $documentsDropdown Action::new('Genereer documenten')
  138.                 ->displayAsButton()
  139.                 ->setTemplatePath('admin/buttons/dropdownButton.html.twig')
  140.                 ->linkToCrudAction('detail')
  141.                 ->addCssClass('btn btn-secundary ');
  142.             // We gebruiken de translationParameters om de actionUrl's door te geven aan twig.
  143.             //$actionUrl = 'http://localhost/admin?crudAction=downloadAfhaalbon&amp;crudControllerFqcn=App%5CController%5CAdmin%5COrderCrudController&amp;entityId=29&amp;menuIndex=3&amp;referrer=http://localhost/admin?crudAction%3Ddetail%26crudControllerFqcn%3DApp%255CController%255CAdmin%255COrderCrudController%26entityId%3D29%26menuIndex%3D3%26submenuIndex%3D0&amp;submenuIndex=0"';
  144.             $afhaalbonUrl $this->adminUrlGenerator
  145.                 ->setController(OrderCrudController::class)
  146.                 ->setAction('downloadAfhaalbon')
  147.                 ->setEntityId($entityId)
  148.                 ->unset('method')
  149.                 ->generateUrl();
  150.             $offerteUrl $this->adminUrlGenerator
  151.                 ->setController(OrderCrudController::class)
  152.                 ->setAction('downloadKlantBrief')
  153.                 ->setEntityId($entityId)
  154.                 ->set('templatePath''/home/easy_admin/templates/offerte/offerte.odt')
  155.                 ->set('documentName''Offerte')
  156.                 ->unset('method')
  157.                 ->generateUrl();
  158.             $offerteNieuwUrl $this->adminUrlGenerator
  159.                 ->setController(OrderCrudController::class)
  160.                 ->setAction('downloadKlantBrief')
  161.                 ->setEntityId($entityId)
  162.                 ->set('templatePath''/home/easy_admin/templates/offerte/offerte_nieuw.odt')
  163.                 ->set('documentName''Offerte_nieuw')
  164.                 ->unset('method')
  165.                 ->generateUrl();
  166.             $offerteBestaandUrl $this->adminUrlGenerator
  167.                 ->setController(OrderCrudController::class)
  168.                 ->setAction('downloadKlantBrief')
  169.                 ->set('templatePath''/home/easy_admin/templates/offerte/offerte_bestaand.odt')
  170.                 ->set('documentName''Offerte_bestaand')
  171.                 ->setEntityId($entityId)
  172.                 ->unset('method')
  173.                 ->generateUrl();
  174.             $orderBevestigingUrl $this->adminUrlGenerator
  175.                 ->setController(OrderCrudController::class)
  176.                 ->setAction('downloadKlantBrief')
  177.                 ->setEntityId($entityId)
  178.                 ->set('templatePath''/home/easy_admin/templates/order/orderbevestiging.odt')
  179.                 ->set('documentName''Orderbevestiging')
  180.                 ->unset('method')
  181.                 ->generateUrl();
  182.             $orderBevestiging2VoudUrl $this->adminUrlGenerator
  183.                 ->setController(OrderCrudController::class)
  184.                 ->setAction('downloadKlantBrief')
  185.                 ->setEntityId($entityId)
  186.                 ->set('templatePath''/home/easy_admin/templates/order/orderbevestiging_2voud.odt')
  187.                 ->set('documentName''Orderbevestiging_2voud')
  188.                 ->unset('method')
  189.                 ->generateUrl();
  190.             $orderNieuwUrl $this->adminUrlGenerator
  191.                 ->setController(OrderCrudController::class)
  192.                 ->setAction('downloadKlantBrief')
  193.                 ->setEntityId($entityId)
  194.                 ->set('templatePath''/home/easy_admin/templates/order/orderbevestiging_nieuw.odt')
  195.                 ->set('documentName''Order_nieuw')
  196.                 ->unset('method')
  197.                 ->generateUrl();
  198.             $orderNieuw2VoudUrl $this->adminUrlGenerator
  199.                 ->setController(OrderCrudController::class)
  200.                 ->setAction('downloadKlantBrief')
  201.                 ->setEntityId($entityId)
  202.                 ->set('templatePath''/home/easy_admin/templates/order/orderbevestiging_nieuw_2-voud.odt')
  203.                 ->set('documentName''Order_nieuw_2-voud')
  204.                 ->unset('method')
  205.                 ->generateUrl();
  206.             $orderBestaandUrl $this->adminUrlGenerator
  207.                 ->setController(OrderCrudController::class)
  208.                 ->setAction('downloadKlantBrief')
  209.                 ->setEntityId($entityId)
  210.                 ->set('templatePath''/home/easy_admin/templates/order/orderbevestiging_bestaand.odt')
  211.                 ->set('documentName''Order_bestaand')
  212.                 ->unset('method')
  213.                 ->generateUrl();
  214.             $orderBestaand2VoudUrl $this->adminUrlGenerator
  215.                 ->setController(OrderCrudController::class)
  216.                 ->setAction('downloadKlantBrief')
  217.                 ->setEntityId($entityId)
  218.                 ->set('templatePath''/home/easy_admin/templates/order/orderbevestiging_bestaand_2-voud.odt')
  219.                 ->set('documentName''Order_bestaand (2voud)')
  220.                 ->unset('method')
  221.                 ->generateUrl();
  222.             $order $this->entityManager->getRepository(Order::class)->findOneBy(['id' => $entityId]);
  223.             $ordersoort $order->getOrdersoort();
  224.             $recordtype $order->getRecordtype();
  225.             // bepaal welke documenten moeten worden getoond.
  226.             $showDocument['afhaalbon'] = 0;
  227.             $showDocument['offerte'] = 0;
  228.             $showDocument['offerteNieuw'] = 0;
  229.             $showDocument['offerteBestaand'] = 0;
  230.             $showDocument['orderBevestiging'] = 0;
  231.             $showDocument['orderBevestiging2Voud'] = 0;
  232.             $showDocument['orderNieuw'] = 0;
  233.             $showDocument['orderNieuw2Voud'] = 0;
  234.             $showDocument['orderBestaand'] = 0;
  235.             $showDocument['orderBestaand2Voud'] = 0;
  236.             if ($ordersoort == 'Afhaler') {
  237.                 $showDocument['afhaalbon'] = 1;
  238.             }
  239.             if ($recordtype == 'Offerte') {
  240.                 $showDocument['offerte'] = 1;
  241.                 $showDocument['offerteNieuw'] = 0;
  242.                 $showDocument['offerteBestaand'] = 0;
  243.             }
  244.             if ($recordtype == 'Order') {
  245.                 $showDocument['orderBevestiging'] = 1;
  246.                 $showDocument['orderBevestiging2Voud'] = 1;
  247.                 $showDocument['orderNieuw'] = 0;
  248.                 $showDocument['orderNieuw2Voud'] = 0;
  249.                 $showDocument['orderBestaand'] = 0;
  250.                 $showDocument['orderBestaand2Voud'] = 0;
  251.             }
  252.             $dropDownArray = [];
  253.             if ($showDocument['afhaalbon']) {
  254.                 $dropDownArray['Afhaalbon'] = $afhaalbonUrl;
  255.             };
  256.             if ($showDocument['offerte']) {
  257.                 $dropDownArray['Offerte'] = $offerteUrl;
  258.             };
  259.             if ($showDocument['offerteNieuw']) {
  260.                 $dropDownArray['Offerte nieuw'] = $offerteNieuwUrl;
  261.             };
  262.             if ($showDocument['offerteBestaand']) {
  263.                 $dropDownArray['Offerte bestaand'] = $offerteBestaandUrl;
  264.             };
  265.             if ($showDocument['orderBevestiging']) {
  266.                 $dropDownArray['Orderbevestiging'] = $orderBevestigingUrl;
  267.             };
  268.             if ($showDocument['orderBevestiging2Voud']) {
  269.                 $dropDownArray['Orderbevestiging (2voud)'] = $orderBevestiging2VoudUrl;
  270.             };
  271.             if ($showDocument['orderNieuw']) {
  272.                 $dropDownArray['Order nieuw'] = $orderNieuwUrl;
  273.             };
  274.             if ($showDocument['orderNieuw2Voud']) {
  275.                 $dropDownArray['Order nieuw (2voud)'] = $orderNieuw2VoudUrl;
  276.             };
  277.             if ($showDocument['orderBestaand']) {
  278.                 $dropDownArray['Order bestaand'] = $orderBestaandUrl;
  279.             };
  280.             if ($showDocument['orderBestaand2Voud']) {
  281.                 $dropDownArray['Order bestaand (2voud)'] = $orderBestaand2VoudUrl;
  282.             };
  283.             $documentsDropdown->setTranslationParameters(
  284.                 $dropDownArray
  285.             );
  286.             $actions->add(Crud::PAGE_DETAIL$documentsDropdown);
  287.         };
  288.         // action new recordInStappen alleen toevoegen bij "alle records"
  289.         if (OrderCrudController::class == get_class($this)) {
  290.             //Order
  291.             $recordNewOrderUrl $this->adminUrlGenerator
  292.                 ->setController(OrderPartialControllerStep01::class)
  293.                 ->setAction(Action::NEW)
  294.                 ->set('recordType''Order')
  295.                 ->generateUrl();
  296.             $actionNewOrder Action::new('nweOrder''Nieuwe Order')
  297.                 ->linkToUrl($recordNewOrderUrl)
  298.                 ->setCssClass('btn btn-primary')
  299.                 ->createAsGlobalAction();
  300.             $actions->add(Crud::PAGE_INDEX$actionNewOrder);
  301.             //Offerte
  302.             $recordNewOrderUrl $this->adminUrlGenerator
  303.                 ->setController(OrderPartialControllerStep01::class)
  304.                 ->setAction(Action::NEW)
  305.                 ->set('recordType''Offerte')
  306.                 ->generateUrl();
  307.             $actionNewOfferte Action::new('nweOfferte''Nieuwe Offerte')
  308.                 ->linkToUrl($recordNewOrderUrl)
  309.                 ->setCssClass('btn btn-primary')
  310.                 ->createAsGlobalAction();
  311.             $actions->add(Crud::PAGE_INDEX$actionNewOfferte);
  312.         }
  313.         // Editaction redirect to invoerstep
  314.         $actionEditStepOrderDetail Action::new('actionBewerkStepDetail''Maak de invoerstappen af')
  315.             ->linkToCrudAction('actionBewerkStep')
  316.             ->setCssClass('btn btn-danger me-2');
  317.         $actionEditStepOrder Action::new('actionBewerkStep''Invoerstappen afmaken')
  318.             ->linkToCrudAction('actionBewerkStep')
  319.             ->setCssClass('text-danger');
  320.         $actions->add(Crud::PAGE_INDEX$actionEditStepOrder);
  321.         $actions->add(Crud::PAGE_DETAIL$actionEditStepOrderDetail);
  322.         //check op invoerstappen INDEX screen
  323.         $actions->update(Crud::PAGE_INDEXAction::EDIT, function (Action $action) {
  324.             $action->displayIf(
  325.                 static function (Order $order) {
  326.                     // dd($order);
  327.                     if ($order->getStep() == 5) {
  328.                         return  true;
  329.                     } else {
  330.                         return false;
  331.                     }
  332.                 }
  333.             );
  334.             return $action;
  335.         });
  336.         $actions->update(Crud::PAGE_INDEX$actionEditStepOrder, function (Action $action) {
  337.             $action->displayIf(
  338.                 static function (Order $order) {
  339.                     // dd($order);
  340.                     if ($order->getStep() <> 5) {
  341.                         return  true;
  342.                     } else {
  343.                         return false;
  344.                     }
  345.                 }
  346.             );
  347.             return $action;
  348.         });
  349.         //check op invoerstappen DETAIL screen
  350.         $actions->update(Crud::PAGE_DETAILAction::EDIT, function (Action $action) {
  351.             $action->displayIf(
  352.                 static function (Order $order) {
  353.                     if ($order->getStep() == 5) {
  354.                         return  true;
  355.                     } else {
  356.                         return false;
  357.                     }
  358.                 }
  359.             );
  360.             return $action;
  361.         });
  362.         $actions->update(Crud::PAGE_DETAIL$actionEditStepOrderDetail, function (Action $action) {
  363.             $action->displayIf(
  364.                 static function (Order $order) {
  365.                     if ($order->getStep() <> 5) {
  366.                         return  true;
  367.                     } else {
  368.                         return false;
  369.                     }
  370.                 }
  371.             );
  372.             return $action;
  373.         });
  374.         //dd($documentsDropdown);
  375.         return $actions
  376.             ->disable(Action::NEW)
  377.             ->disable(Action::DELETE)
  378.             ->add(Crud::PAGE_EDITAction::DETAIL)
  379.             ->disable(Action::SAVE_AND_ADD_ANOTHER)
  380.             ->remove(Crud::PAGE_DETAILAction::EDIT)
  381.             ->remove(Crud::PAGE_INDEXAction::EDIT)
  382.             //->reorder(crud::PAGE_DETAIL, [Action::INDEX, $documentsDropdown::class, $actionEditStepOrderDetail::class])
  383.             //->reorder(crud::PAGE_DETAIL, [Action::INDEX,'Genereer documenten']);
  384.         ;
  385.     }
  386.     public function configureFields(string $pageName): iterable
  387.     {
  388.         //We kunnen vanuit deze controller via de Fields de volgende controllers aanroepen
  389.         //OrderonderdeelSubController
  390.         //OrderregelsSubcontroller
  391.         //We zetten alvast de referrers
  392.         //Let wel het tabblad weten we nog niet, dat zetten we in de volgende controller in configureFields
  393.         $adminRefferer AdminReferrer::new($this->getContext())
  394.             ->setReferrer(OrderregelSubController::class)
  395.             ->setReferrer(OrderonderdeelSubController::class)
  396.             ->setReferrer(OrderPartialControllerLeges::class)
  397.             ->setReferrer(OrderPartialControllerModel::class)
  398.             ->setReferrer(TabOooController::class);
  399.         $context $this->getContext();
  400.         $order $context->getEntity()->getInstance();
  401.         $crudControllerFqcn $context->getRequest()->get('crudControllerFqcn');
  402.         $indexList $this->defineIndexList->getOrderIndexList($crudControllerFqcn);
  403.         //dd($indexList);
  404.         //nu de velden definieren
  405.         // Overzicht
  406.         $fields['Overzicht'] =  FormField::addTab('Overzicht')
  407.             ->onlyOnDetail();
  408.         $fields[] = WorkflowOrderField::new('statusbalk1'$this->entityManager)
  409.             ->onlyOnDetail()
  410.             ->setValue('Overzicht')
  411.             ->setLabel('Status');
  412.         if ($order) {
  413.             if ($order->isVooruitbesteld()) {
  414.                 $fields[] = OrderMeldingField::new('Melding1'$this->entityManager)
  415.                     ->onlyOnDetail()
  416.                     ->setlabel('')
  417.                     ->setValue('Test')
  418.                     ->setFormattedValue('Deze order is vooruitbesteld !');
  419.             }
  420.         }
  421.         if ($order) {
  422.             if ($order->isPlaatsenFamilieAanwezig()) {
  423.                 $fields[] = OrderMeldingField::new('Melding2'$this->entityManager)
  424.                     ->onlyOnDetail()
  425.                     ->setlabel('')
  426.                     ->setValue('Test')
  427.                     ->setFormattedValue('De familie wil aanwezig zijn bij plaatsing !');
  428.             }
  429.         }
  430.         if ($order) {
  431.             if ($order->getPlaatsenVoorDatum()) {
  432.                 $melding sprintf("Plaatsen voor datum: %s !"$order->getPlaatsenVoorDatum()->format('d-m-Y'));
  433.                 $fields[] = OrderMeldingField::new('Melding3'$this->entityManager)
  434.                     ->onlyOnDetail()
  435.                     ->setlabel('')
  436.                     ->setValue('Test')
  437.                     ->setFormattedValue($melding);
  438.             }
  439.         }
  440.         $fields[] = OrderSummaryField::new('Summary'$this->entityManager)
  441.             ->setLabel('Overzicht')
  442.             ->onlyOnDetail()
  443.             ->setValue('Test');
  444.         //$fields[] = OrderOverzichtRecordField::new('Record', $this->entityManager)
  445.         //    ->onlyOnDetail()
  446.         //    ->setValue('Test');
  447.         //$fields[] = OrderOverzichtBasisField::new('Basisgegevens', $this->entityManager)
  448.         //    ->onlyOnDetail()
  449.         //    ->setValue('Test');
  450.         $fields[] = OrderOverzichtWorkflowField::new('Workflow'$this->entityManager'Workflow',  $this->defineOfferteOrderService)
  451.             ->onlyOnDetail()
  452.             ->setValue('Test')
  453.             ->setHelp('
  454.             In dit workflow overzicht kun je zien wat er nog moet gebeuren in de uitvoering van de offerte/order.
  455.             <br>
  456.             Achter elk onderwerp wordt een icoontje getoond:
  457.             <br><br>Rood kruis: betekent dat er nog niks is gedaan aan dit onderwerp.
  458.             <br><br>Grijs kruis: Het onderwerp is in behandeling genomen, maar nog niet afgerond (Bijv. vergunning is wel verstuurd maar nog niet ontvangen)
  459.             <br><br>Groene vink: Dit onderwerp is afgerond.
  460.             <br><br><br>Als het onderwerp niet van toepassing is op deze offerte/order, dan staat er geen icoontje.
  461.             ');
  462.         $fields[] = OrderUitgelichtField::new('Uitgelicht'$this->entityManager'Uitgelicht')
  463.             ->onlyOnDetail()
  464.             ->setValue('Test')
  465.             ->setHelp('Hier moet de meest recente tekening of belangrijk document getoond worden, 
  466.             je kunt een tekening of bestand op "uitgelicht" zetten onder het tabblad "Bestanden"
  467.             ');
  468.         // Basisgegevens    
  469.         $fields['Basisgegevens'] = FormField::addTab('Basisgegevens')
  470.             ->hideWhenCreating();
  471.         $fields[] = WorkflowOrderField::new('statusbalk2'$this->entityManager)
  472.             ->onlyOnDetail()
  473.             ->setValue('Basisgegevens')
  474.             ->setLabel('Status');
  475.         $fieldName 'ordernummer';
  476.         $fields[$fieldName] = NumberField::new($fieldName)
  477.             ->hideWhenCreating()
  478.             ->setNumberFormat('%s')
  479.             ->setLabel('Nummer');
  480.         $fieldName 'record_type';
  481.         $fields[$fieldName] = ChoiceField::new($fieldName)
  482.             ->setLabel('Type')
  483.             ->setChoices(['Onbekend' => 'Onbekend''Offerte' => 'Offerte''Order' => 'Order'])
  484.             ->setHelp('"Offerte" of "Order".<br>"Onbekend" bij bijv. afhaler (nog geen contact gehad met familie).');
  485.         $fieldName 'createdAt';
  486.         $fields[$fieldName] = DateField::new($fieldName)
  487.             ->setLabel('Aanmaakdatum')
  488.             ->setFormat('d-M-Y');
  489.         $fieldName 'vestiging';
  490.         $fields[$fieldName] = AssociationField::new($fieldName);
  491.         $fieldName 'ordersoort';
  492.         $fields[$fieldName] = AssociationField::new($fieldName)
  493.             ->setHelp('"Bestaand" voor bijv. restauratie, "Afhaler" voor bijzetting, "Overig" voor bijv. tekst inschilderen. NB. dit veld nooit wijzigen!');
  494.         $fieldName 'familie';
  495.         $fields[$fieldName] = AssociationField::new($fieldName)
  496.             ->autocomplete()
  497.             ->setLabel('Familie');
  498.         $fieldName 'comm';
  499.         $fields[$fieldName] = AssociationField::new($fieldName)
  500.             ->autocomplete()
  501.             ->setLabel('Communicatie')
  502.             ->setHelp('De wijze van contact met de familie');
  503.         $fieldName 'overledene_naam';
  504.         $fields[$fieldName] = TextField::new($fieldName);
  505.         $fieldName 'geb_datum';
  506.         $fields[$fieldName] = DateField::new($fieldName)
  507.             ->setFormat('d-M-Y');
  508.         $fieldName 'overl_datum';
  509.         $fields[$fieldName] = DateField::new($fieldName)
  510.             ->setFormat('d-M-Y');
  511.         $fieldName 'begraafplaats';
  512.         $fields[$fieldName] = AssociationField::new($fieldName)
  513.             ->autocomplete();
  514.         $fieldName 'grafnummer';
  515.         $fields[$fieldName] = TextField::new($fieldName);
  516.         $fieldName 'uitvaartvereniging';
  517.         $fields[$fieldName] = AssociationField::new($fieldName)
  518.             ->setLabel('Uitvaartvereniging')
  519.             ->autocomplete();
  520.         $fieldName 'opmerkingen';
  521.         $fields[$fieldName] = TextareaField::new($fieldName)
  522.             ->setHelp('Iedereen moet hier kunnen zien of er iets aparts aan de order is.<br>
  523.                     <i>Bijv. familie aanwezig bij plaatsing, factuur via uitvaarleider, familie in werkplaats voor indeling tekst, zoon bellen na plaatsen, etc.</i>
  524.                     ');
  525.         $fieldName 'opmerkingen_werkbon';
  526.         $fields[$fieldName] = TextareaField::new($fieldName)
  527.             ->setHelp('Plaats hier de opmerkingen die van belang zijn voor de werkplaats.<br>
  528.                     <i>Bijv. Alleen letterplaat meenemen, eerst melden bij beheerder (0612345678), etc.</i>
  529.                     ');
  530.         $fields[] = BewerkTabField::new('_bewerk1'$this->entityManager)
  531.             ->onlyOnDetail()
  532.             ->setLabel('')
  533.             ->setValue('Basisgegevens');
  534.         // Offerte/Order
  535.         $fields['Ooo'] = FormField::addTab('Offerte/Order/Ontwerp')
  536.             ->hideWhenCreating();
  537.         $fields[] = WorkflowOrderField::new('statusbalk3'$this->entityManager)
  538.             ->onlyOnDetail()
  539.             ->setValue('Ooo')
  540.             ->setLabel('Status');
  541.         $fieldName 'orderstatus';
  542.         $fields[$fieldName] = AssociationField::new($fieldName)
  543.             ->setLabel('Status')
  544.             ->hideWhenCreating()
  545.             ->hideOnDetail()
  546.             ->setQueryBuilder(function (QueryBuilder $queryBuilder) {
  547.                 $queryBuilder->orderby('entity.volgorde, entity.id');
  548.             })
  549.             ->sethelp('In welke fase is de offerte of order?<br>Als het veld "Aanpassing" is aangevinkt, dan toont de status wat er veranderd moet worden.');
  550.         $fieldName 'aanpassing_nodig';
  551.         $fields[$fieldName] = BooleanField::new($fieldName)
  552.             ->setLabel('Aanpassing ?')
  553.             ->hideWhenCreating()
  554.             ->renderAsSwitch(false)
  555.             ->setHelp('Is er een wijziging doorgegeven die nog moet worden verwerkt?
  556.             <br>
  557.             Als dit veld wordt aangevinkt (ja), geef dan in de status aan wat er veranderd moet worden. Dit zal vaak gaan om een aanpassing in de tekening of order.
  558.                       ');
  559.         //Offerte Panel
  560.         if ($order) {
  561.             if ($order->getRecordType() == 'Offerte' || $order->getOfferteDatum() !== null) {
  562.                 $fields[] = FormField::addPanel('Offerte')->collapsible()
  563.                     ->hideWhenCreating();
  564.             } else {
  565.                 $fields[] = FormField::addPanel('Offerte')
  566.                     ->renderCollapsed()
  567.                     ->hideWhenCreating();
  568.             }
  569.         }
  570.         $fieldName 'offerte_medewerker';
  571.         $fields[$fieldName] = AssociationField::new($fieldName)
  572.             //->hideWhenCreating()
  573.             ->setColumns(3)
  574.             ->setHelp('Wie heeft de offerte genoteerd van de klant. (Niet degene die de offerte heeft verwerkt)');
  575.         $fieldName 'offerte_datum';
  576.         $fields[$fieldName] = DateField::new($fieldName)
  577.             ->setLabel('Datum verkrijging offerte')
  578.             ->setFormat('d-M-Y')
  579.             ->setColumns(9)
  580.             ->sethelp('Datum dat eerste offerte gekregen is.<br>(Meerdere offertes? Meld dit dan in veld "Opmerkingen" bij "Basisgegevens".)');
  581.         $fieldName 'offerte_datum_verstuurd';
  582.         $fields[$fieldName] = DateField::new($fieldName)
  583.             ->hideWhenCreating()
  584.             ->setFormat('d-M-Y')
  585.             ->setLabel('Datum offerte verstuurd')
  586.             ->setColumns(9);
  587.         //Order panel
  588.         if ($order) {
  589.             if ($order->getRecordType() == 'Order') {
  590.                 $fields[] = FormField::addPanel('Order')->collapsible()
  591.                     ->hideWhenCreating();
  592.             } else {
  593.                 $fields[] = FormField::addPanel('Order')
  594.                     ->renderCollapsed()
  595.                     ->hideWhenCreating();
  596.             }
  597.         }
  598.         $fieldName 'order_medewerker';
  599.         $fields[$fieldName] = AssociationField::new($fieldName)
  600.             //->hideWhenCreating()
  601.             ->setHelp('Dit is de medewerker die de order van de klant heeft gekregen')
  602.             ->setColumns(3);
  603.         $fieldName 'order_datum';
  604.         $fields[$fieldName] = DateField::new($fieldName)
  605.             ->setLabel('Datum verkrijging order')
  606.             ->setFormat('d-M-Y')
  607.             ->setColumns(9);
  608.         $fieldName 'datum_order_verstuurd';
  609.         $fields[$fieldName] = DateField::new($fieldName)
  610.             ->setLabel('Datum order verstuurd')
  611.             ->setFormat('d-M-Y')
  612.             ->hideWhenCreating()
  613.             ->setColumns(9);
  614.         $fieldName 'order_akkoord';
  615.         $fields[$fieldName] = BooleanField::new($fieldName)
  616.             ->setLabel('Akkoord?')
  617.             ->renderAsSwitch(false)
  618.             ->setHelp('Een order is "Akkoord" als: 
  619.                 <br>-bij de verkoop een handtekening is gezet
  620.                 <br>-via de mail een akkoord is gegeven
  621.                 <br>-de offerte/order ondertekend is ontvangen.
  622.                 <br><i>Als er via de telefoon akkoord wordt gegeven, 
  623.                 vraag dan altijd of de klant het op de mail wil zetten</i>
  624.                 ');
  625.         $fieldName 'vooruitbesteld';
  626.         $fields[$fieldName] = BooleanField::new($fieldName)
  627.             ->setLabel('Vooruitbesteld?')
  628.             ->setHelp('Een vooruitbestelde order wordt "geparkeerd" voor afroep.
  629.                     <br>-deze order is (nadat deze is vertuurd) alleen zichtbaar in de lijst "Orders vooruitbesteld"
  630.                         ');
  631.         $fields[] = FormField::addRow();
  632.         //Ontwerpen Panel
  633.         if ($order) {
  634.             if ($order->isOntwerpNodig()) {
  635.                 $fields[] = FormField::addPanel('Ontwerp')->collapsible()
  636.                     ->hideWhenCreating();
  637.             } else {
  638.                 $fields[] = FormField::addPanel('Ontwerp')
  639.                     ->renderCollapsed()
  640.                     ->hideWhenCreating();
  641.             }
  642.         }
  643.         $fieldName 'ontwerp_nodig';
  644.         $fields[$fieldName] = BooleanField::new($fieldName)
  645.             ->setColumns(3);
  646.         $fieldName 'ontwerp_medewerker';
  647.         $fields[$fieldName] = AssociationField::new($fieldName)
  648.             ->hideWhenCreating()
  649.             ->setColumns(3);
  650.         $fieldName 'ontwerp_datum';
  651.         $fields[$fieldName] = DateField::new($fieldName)
  652.             ->hideWhenCreating()
  653.             ->setFormat('d-M-Y')
  654.             ->setColumns(3)
  655.             ->setHelp('Datum dat eerste ontwerp is gemaakt.<br>Bij meerdere ontwerpen kun je de datums zien bij "Bestanden".');
  656.         $fields[] = FormField::addRow();
  657.         //Ontwerpen Panel
  658.         if ($order) {
  659.             if ($order->isOntwerpNodig()) {
  660.                 $fields[] = FormField::addPanel('Belettering')->collapsible()
  661.                     ->hideWhenCreating();
  662.             } else {
  663.                 $fields[] = FormField::addPanel('Belettering')
  664.                     ->renderCollapsed()
  665.                     ->hideWhenCreating();
  666.             }
  667.         }
  668.         $fieldName 'belettering';
  669.         $fields[$fieldName] = AssociationField::new($fieldName)
  670.             ->hideWhenCreating()
  671.             ->setLabel('Belettering')
  672.             ->setColumns(3);
  673.         $fieldName 'belettering_lettertype';
  674.         $fields[$fieldName] = AssociationField::new($fieldName)
  675.             ->hideWhenCreating()
  676.             ->setLabel('Lettertype')
  677.             ->setColumns(3);
  678.         $fieldName 'belettering_kleur';
  679.         $fields[$fieldName] = AssociationField::new($fieldName)
  680.             ->hideWhenCreating()
  681.             ->setLabel('Kleur')
  682.             ->setColumns(3);
  683.         $fieldName 'belettering_opmerking';
  684.         $fields[$fieldName] = TextField::new($fieldName)
  685.             ->setLabel('Opmerking')
  686.             ->hideWhenCreating()
  687.             ->setColumns(3);
  688.         $fields[] = FormField::addPanel('')
  689.             //->renderCollapsed()
  690.             ->hideWhenCreating();
  691.         $fields[] = BewerkTabField::new('_bewerk2'$this->entityManager)
  692.             ->onlyOnDetail()
  693.             ->setLabel('')
  694.             ->setValue('Ooo'); 
  695.         //Orderregels
  696.         $fieldName 'Orderregels';
  697.         $fields[$fieldName] = FormField::addTab('Orderregels')
  698.             ->onlyOnDetail();
  699.         $fields[] = WorkflowOrderField::new('statusbalk4'$this->entityManager)
  700.             ->onlyOnDetail()
  701.             ->setValue('Orderregels')
  702.             ->setLabel('Status');
  703.         $fieldName 'orderregels';
  704.         $fields[$fieldName] = AssociationField::new('orderregels')
  705.             ->setLabel('Orderregels')
  706.             ->setCrudController(OrderregelSubController::class)
  707.             ->setTemplatePath('admin/fields/orderregels.html.twig')
  708.             ->hideWhenCreating()
  709.             ->hideOnForm()
  710.             ->onlyOnDetail();
  711.         //Onderdelen
  712.         $fieldName 'Onderdelen';
  713.         $fields[$fieldName] = FormField::addTab('Onderdelen')
  714.             ->onlyOnDetail();
  715.         $fields[] = WorkflowOrderField::new('statusbalk5'$this->entityManager)
  716.             ->onlyOnDetail()
  717.             ->setValue('Onderdelen')
  718.             ->setLabel('Status');
  719.         $fieldName 'onderdelen_nodig';
  720.         $fields[$fieldName] = BooleanField::new($fieldName)
  721.             ->setlabel('Onderdelen nodig?')
  722.             ->onlyOnDetail()
  723.             ->setHelp('Moeten er onderdelen geleverd worden bij deze order?');
  724.         $fieldName 'orderonderdeel';
  725.         $fields[$fieldName] = AssociationField::new('orderonderdeels')
  726.             ->setLabel('Onderdelen')
  727.             ->setCrudController(OrderonderdeelSubController::class)
  728.             ->setTemplatePath('admin/fields/orderonderdelen.html.twig')
  729.             ->hideWhenCreating()
  730.             ->hideOnForm()
  731.             ->onlyOnDetail();
  732.         $fields[] = FormField::addPanel('')
  733.             //->renderCollapsed()
  734.             ->hideWhenCreating();
  735.         $fields[] = BewerkTabField::new('_bewerk3'$this->entityManager)
  736.             ->onlyOnDetail()
  737.             ->setLabel('')
  738.             ->setValue('Onderdelen');
  739.         // Workflow/acties
  740.         $fields['Workflow'] = FormField::addTab('Workflow')
  741.             ->setValue('workflow')
  742.             ->hideWhenCreating();
  743.         $fields[] = WorkflowOrderField::new('statusbalk6'$this->entityManager)
  744.             ->onlyOnDetail()
  745.             ->setValue('workflow')
  746.             ->setLabel('Status');
  747.         //Afhaler panel
  748.         if ($order) {
  749.             if ($order->getOrdersoort() == "Afhaler") {
  750.                 $fields[] = FormField::addPanel('Afhaler')->collapsible()
  751.                     ->hideWhenCreating();
  752.             } else {
  753.                 $fields[] = FormField::addPanel('Afhaler')
  754.                     ->renderCollapsed()
  755.                     ->hideWhenCreating();
  756.             }
  757.         }
  758.         $fieldName 'afhaler_opdrachtgever';
  759.         $fields[$fieldName] = TextField::new($fieldName)
  760.             ->setLabel("Opdrachtgever")
  761.             ->hideWhenCreating();
  762.         $fieldName 'afhaler_naam_op_steen';
  763.         $fields[$fieldName] = TextField::new($fieldName)
  764.             ->setLabel("Naam op steen")
  765.             ->hideWhenCreating();
  766.         $fieldName 'afhaler_overlijdensdatum_op_steen';
  767.         $fields[$fieldName] = DateField::new($fieldName)
  768.             ->setlabel("Overlijdensdatum op steen")
  769.             ->setFormat('d-M-Y')
  770.             ->hideWhenCreating()
  771.             ->setColumns(3);
  772.         $fieldName 'begraaf_datum';
  773.         $fields[$fieldName] =  DateField::new($fieldName)
  774.             ->setFormat('d-M-Y')
  775.             ->hideWhenCreating()
  776.             ->setHelp('Datum begrafenis van persoon die bijgezet wordt.')
  777.             ->setColumns(3);
  778.         $fieldName 'afhaal_datum';
  779.         $fields[$fieldName] = DateField::new($fieldName)
  780.             ->setFormat('d-M-Y')
  781.             ->hideWhenCreating()
  782.             ->setColumns(6)
  783.             ->setHelp('Datum dat het monument van de begraafplaats is gehaald.');
  784.         $fieldName 'afhaler_contactdatum';
  785.         $fields[$fieldName] = DateField::new($fieldName)
  786.             ->setFormat('d-M-Y')
  787.             ->hideWhenCreating()
  788.             ->setColumns(3)
  789.             ->setHelp('Datum van contact met de familie over het afgehaalde monument.
  790.             <br><i>Als de datum is ingevuld dan verdwijnt deze afhaler uit de lijst "Afhalers > 3 weken".</i>');
  791.         $fieldName 'afhaler_contactmedewerker';
  792.         $fields[$fieldName] = AssociationField::new($fieldName)
  793.             ->hideWhenCreating()
  794.             ->setColumns(3);
  795.         //Ophaler panel
  796.         if ($order) {
  797.             if ($order->getOrdersoort() == "Bestaand" || $order->isOphalenOnderdelen()) {
  798.                 $fields[] = FormField::addPanel('Ophaler (Bestaand)')->collapsible()
  799.                     ->hideWhenCreating();
  800.             } else {
  801.                 $fields[] = FormField::addPanel('Ophaler (Bestaand)')
  802.                     ->renderCollapsed()
  803.                     ->hideWhenCreating();
  804.             }
  805.         }
  806.         $fieldName 'ophalen_onderdelen';
  807.         $fields[$fieldName] = BooleanField::new($fieldName)
  808.             ->setColumns(3)
  809.             ->setHelp('Hier geef je aan of er onderdelen opgehaald moeten worden van de begraafplaats');
  810.         $fieldName 'ophaler_alleen_letterplaat';
  811.         $fields[$fieldName] = BooleanField::new($fieldName)
  812.             ->setColumns(3)
  813.             ->setlabel('Ophalen alleen letterplaat?');
  814.         $fieldName 'ophaler_datum';
  815.         $fields[$fieldName] = DateField::new($fieldName)
  816.             ->setFormat('d-M-Y')
  817.             ->hideWhenCreating()
  818.             ->setColumns(6)
  819.             ->setHelp('Datum wanneer de onderdelen zijn opgehaald.');
  820.         //Vergunning Panel
  821.         if ($order) {
  822.             if ($order->isVergunningNodig()) {
  823.                 $fields[] = FormField::addPanel('Vergunning')->collapsible()
  824.                     ->hideWhenCreating();
  825.             } else {
  826.                 $fields[] = FormField::addPanel('Vergunning')
  827.                     ->renderCollapsed()
  828.                     ->hideWhenCreating();
  829.             }
  830.         }
  831.         $fieldName 'vergunning_nodig';
  832.         $fields[$fieldName] = Field::new($fieldName);
  833.         $fieldName 'vergunning_datum_aanvraagformulier_ingevoerd';
  834.         $fields[$fieldName] = Field::new($fieldName)
  835.             ->setLabel('Aanvraagformulier ingevoerd')
  836.             ->hideWhenCreating()
  837.             ->setColumns(3);
  838.         $fieldName 'vergunning_aanvraagformulier_ingevoerd_door';
  839.         $fields[$fieldName] = AssociationField::new($fieldName)
  840.             ->setlabel('Aanvraagformulier ingevoerd door')
  841.             ->hideWhenCreating()
  842.             ->setColumns(9);
  843.         $fieldName 'vergunning_datum_aanvraagformulier_gecontroleerd';
  844.         $fields[$fieldName] = Field::new($fieldName)
  845.             ->setLabel('Aanvraagformulier gecontroleerd')
  846.             ->hideWhenCreating()
  847.             ->setColumns(3);
  848.         $fieldName 'vergunning_aanvraagformulier_gecontroleerd_door';
  849.         $fields[$fieldName] = AssociationField::new($fieldName)
  850.             ->setlabel('Aanvraagformulier gecontroleer door')
  851.             ->hideWhenCreating()
  852.             ->setColumns(6);
  853.         $fields[] = FormField::addRow();
  854.         $fieldName 'vergunning_verzenddatum';
  855.         $fields[$fieldName] = Field::new($fieldName)
  856.             ->hideWhenCreating()
  857.             ->setColumns(3);
  858.         $fieldName 'vergunning_medewerker';
  859.         $fields[$fieldName] = AssociationField::new($fieldName)
  860.             ->setlabel('Vergunning verzonden door')
  861.             ->hideWhenCreating()
  862.             ->setColumns(9);
  863.         $fieldName 'vergunning_ontvangstdatum';
  864.         $fields[$fieldName] = Field::new($fieldName)
  865.             ->hideWhenCreating()
  866.             ->setColumns(3);
  867.         //Bestellingen Panel
  868.         if ($order) {
  869.             if ($order->isBestellingNodig()) {
  870.                 $fields[] = FormField::addPanel('Bestelling (Oud-> nu bij onderdelen)')->collapsible()
  871.                     ->hideWhenCreating()
  872.                     ->onlyOnDetail();
  873.             } else {
  874.                 $fields[] = FormField::addPanel('Bestelling (Oud-> nu bij onderdelen)')
  875.                     ->renderCollapsed()
  876.                     ->hideWhenCreating()
  877.                     ->onlyOnDetail();
  878.             }
  879.         }
  880.         $fieldName 'bestelling_nodig';
  881.         $fields[$fieldName] = Field::new($fieldName)
  882.             ->onlyOnDetail();
  883.         $fieldName 'bestelling_datum_bestelbon_ingevoerd';
  884.         $fields[$fieldName] = Field::new($fieldName)
  885.             ->setLabel('Bestelbon ingevoerd')
  886.             ->hideWhenCreating()
  887.             ->setColumns(3)->onlyOnDetail();
  888.         $fieldName 'bestelling_bestelbon_ingevoerd_door';
  889.         $fields[$fieldName] = AssociationField::new($fieldName)
  890.             ->setlabel('Bestelbon ingevoerd door')
  891.             ->hideWhenCreating()
  892.             ->setColumns(9)->onlyOnDetail();
  893.         $fieldName 'bestelling_datum_bestelbon_gecontroleerd';
  894.         $fields[$fieldName] = Field::new($fieldName)
  895.             ->setLabel('Bestelbon gecontroleerd')
  896.             ->hideWhenCreating()
  897.             ->setColumns(3)->onlyOnDetail();
  898.         $fieldName 'bestelling_bestelbon_gecontroleerd_door';
  899.         $fields[$fieldName] = AssociationField::new($fieldName)
  900.             ->setlabel('Bestelbon gecontroleerd door')
  901.             ->hideWhenCreating()
  902.             ->hideOnIndex()->onlyOnDetail()
  903.             ->setColumns(9);
  904.         $fieldName 'bestelling_datum';
  905.         $fields[$fieldName] = DateField::new($fieldName)
  906.             ->setFormat('d-M-Y')
  907.             ->setColumns(3)->onlyOnDetail()
  908.             ->hideWhenCreating();
  909.         $fieldName 'bestelling_medewerker';
  910.         $fields[$fieldName] = AssociationField::new($fieldName)
  911.             ->setlabel('Bestelling verzonden door')
  912.             ->hideWhenCreating()->onlyOnDetail()
  913.             ->setColumns(9);
  914.         $fieldName 'planning_aankomst_leverancier';
  915.         $fields[$fieldName] = Field::new($fieldName)
  916.             ->setColumns(3)
  917.             ->hideWhenCreating()->onlyOnDetail();
  918.         $fieldName 'bestelling_ontvangstdatum';
  919.         $fields[$fieldName] = DateField::new($fieldName)
  920.             ->setFormat('d-M-Y')
  921.             ->setColumns(3)->onlyOnDetail()
  922.             ->hideWhenCreating();
  923.         $fieldName 'bestelling_opmerkingen';
  924.         $fields[$fieldName] = Field::new($fieldName)
  925.             ->setColumns(6)->onlyOnDetail()
  926.             ->hideWhenCreating();
  927.         //Opslag panel
  928.         // if ($order) {
  929.         //     if ($order->isOpslagNodig()) {
  930.         //         $fields[] = FormField::addPanel('Opslag')->collapsible()
  931.         //             ->hideWhenCreating();
  932.         //     } else {
  933.         //         $fields[] = FormField::addPanel('Opslag')
  934.         //             ->renderCollapsed()
  935.         //             ->hideWhenCreating();
  936.         //     }
  937.         // }
  938.         // $fieldName = 'opslag_nodig';
  939.         // $fields[$fieldName] = BooleanField::new($fieldName)
  940.         //     ->setColumns(3)
  941.         //     ->setHelp('Hier geef je aan of er opslag nodig is voor het monument.
  942.         //     <br><i>Bij een afhaler is dit altijd nodig. Meestal ook voor een bestaand monument dat opgeknapt moet worden.</i>');
  943.         // $fieldName = 'opslag_medewerker';
  944.         // $fields[$fieldName] = AssociationField::new($fieldName)
  945.         //     ->hideWhenCreating()
  946.         //     ->setColumns(3);
  947.         // $fieldName = 'opslag_locatie';
  948.         // $fields[$fieldName] = TextField::new($fieldName)
  949.         //     ->hideWhenCreating()
  950.         //     ->setColumns(3)
  951.         //     ->setHelp('Locatie waar het monument is opgeslagen');
  952.         //Levering Panel
  953.         if ($order) {
  954.             if ($order->getLeveringDatum() !== null || $order->getLevermaand() !== null || $order->getLeverweek() !== null) {
  955.                 $fields[] = FormField::addPanel('Levering')->collapsible()
  956.                     ->hideWhenCreating();
  957.             } else {
  958.                 $fields[] = FormField::addPanel('Levering')
  959.                     ->renderCollapsed()
  960.                     ->hideWhenCreating();
  961.             }
  962.         }
  963.         $fields[] = FormField::addRow();
  964.         $fieldName 'plaatsen_familie_aanwezig';
  965.         $fields[$fieldName] = BooleanField::new($fieldName)
  966.             ->setLabel('Familie aanwezig bij plaatsen?')
  967.             //->setHelp('Een vooruitbestelde order wordt "geparkeerd" voor afroep.                      <br>-deze order is (nadat deze is vertuurd) alleen zichtbaar in de lijst "Orders vooruitbesteld"')
  968.         ;
  969.         $fieldName 'plaatsen_voor_datum';
  970.         $fields[$fieldName] = DateField::new($fieldName)
  971.             ->setLabel('Plaatsen voor')
  972.             ->setColumns(2)
  973.             ->setFormat('MMMM y');
  974.         $fields[] = FormField::addRow();
  975.         $fieldName 'levermaand';
  976.         $fields[$fieldName] = DateField::new($fieldName)
  977.             ->setLabel('Planning Levermaand')
  978.             ->setColumns(2)
  979.             ->setFormat('MMMM y');
  980.         $fieldName 'Leverweek';
  981.         $fields[$fieldName] = ChoiceField::new($fieldName)
  982.             ->setChoices($this->defineOfferteOrderService->getWeeknrs())
  983.             ->setColumns(1)
  984.             ->hideWhenCreating();
  985.         $fields[] = FormField::addRow();
  986.         $fieldName 'levering_datum';
  987.         $fields[$fieldName] = DateField::new($fieldName)
  988.             ->setFormat('d-M-Y')
  989.             ->setColumns(3)
  990.             ->hideWhenCreating();
  991.         $fieldName 'levering_datum_klant_informeren';
  992.         $fields[$fieldName] = DateField::new($fieldName)
  993.             ->setFormat('d-M-Y')
  994.             //->setFormat('MMMM y')
  995.             //->renderAsChoice()
  996.             ->hideWhenCreating()
  997.             ->setColumns(3)
  998.             ->setHelp('In te vullen door degene die de familie heeft geïnformeerd over de plaatsing van het monument');
  999.         $fieldName 'levering_medewerker';
  1000.         $fields[$fieldName] = AssociationField::new($fieldName)
  1001.             ->hideWhenCreating()
  1002.             ->setColumns(3)
  1003.             ->setHelp('De medewerker die de familie heeft geïnformeerd over de plaatsing van het monument.');
  1004.         $fieldName 'levering_opmerkingen';
  1005.         $fields[$fieldName] = TextareaField::new($fieldName)
  1006.             ->hideWhenCreating()
  1007.             ->setColumns(6)
  1008.             ->setHelp('Als er tijdens het plaatsen iets is gebeurd wat eventueel vermeld moet worden aan de familie, dan benoemen de jongens van de vrachtwagen dit hier');
  1009.         $fields[] = FormField::addPanel('')
  1010.             //->renderCollapsed()
  1011.             ->hideWhenCreating();
  1012.         $fields[] = BewerkTabField::new('_bewerk4'$this->entityManager)
  1013.             ->onlyOnDetail()
  1014.             ->setLabel('')
  1015.             ->setValue('Workflow');
  1016.         //Financieel
  1017.         $fields['Financieel'] = FormField::addTab('Financieel')
  1018.             ->hideWhenCreating();
  1019.         $fields[] = WorkflowOrderField::new('statusbalk7'$this->entityManager)
  1020.             ->onlyOnDetail()
  1021.             ->setValue('Financieel')
  1022.             ->setLabel('Status');
  1023.         $fieldName 'prijs';
  1024.         $fields[$fieldName] = MoneyField::new($fieldName)
  1025.             //->setDisabled()
  1026.             ->setCurrency('EUR')
  1027.             ->setColumns(3)
  1028.             //->hideWhenCreating()
  1029.         ;
  1030.         $fieldName 'leges';
  1031.         $fields[$fieldName] = MoneyField::new($fieldName)
  1032.             //->setDisabled()
  1033.             ->setCurrency('EUR')
  1034.             ->setColumns(3)
  1035.             ->hideWhenCreating();
  1036.         $fieldName 'provisie';
  1037.         $fields[$fieldName] = MoneyField::new($fieldName)
  1038.             ->setCurrency('EUR')
  1039.             ->setColumns(3)
  1040.             ->hideWhenCreating();
  1041.         $fieldName 'agent';
  1042.         $fields[$fieldName] = AssociationField::new($fieldName)
  1043.             ->autocomplete()
  1044.             ->hideWhenCreating();
  1045.         $fieldName 'provisie_betaald';
  1046.         $fields[$fieldName] = BooleanField::new($fieldName)
  1047.             ->hideWhenCreating();
  1048.         $fields[] = FormField::addPanel('')
  1049.             //->renderCollapsed()
  1050.             ->hideWhenCreating();
  1051.         $fields[] = BewerkTabField::new('_bewerk5'$this->entityManager)
  1052.             ->onlyOnDetail()
  1053.             ->setLabel('')
  1054.             ->setValue('Financieel');
  1055.         // Bestanden
  1056.         $fields['Bestanden'] = FormField::addTab('Bestanden')
  1057.             ->hideWhenCreating();;
  1058.         $fields[] = WorkflowOrderField::new('statusbalk8'$this->entityManager)
  1059.             ->onlyOnDetail()
  1060.             ->setValue('Bestanden')
  1061.             ->setLabel('Status');
  1062.         $fieldName 'attachments';
  1063.         $fields[$fieldName] = collectionField::new($fieldName)
  1064.             ->setFormTypeOption('by_reference'false)
  1065.             //->setFormTypeOptions(['block_name'=>'custom_attachments'])
  1066.             ->setFormTypeOptions(['entry_type' => 'App\Form\AttachmentType'])
  1067.             //->autocomplete()
  1068.             //->setEntryType(AttachmentType::class)
  1069.             //->onlyOnForms()
  1070.             ->setTemplatePath('admin/fields/attachments.html.twig')
  1071.             ->hideWhenCreating()
  1072.             //->autocomplete()
  1073.             //->hideOnForm()
  1074.         ;
  1075.         // $fields[] = FormField::addPanel('')
  1076.         // //->renderCollapsed()
  1077.         // ->hideWhenCreating();
  1078.         // $fields[] = BewerkTabField::new('_bewerk5', $this->entityManager)
  1079.         //     ->onlyOnDetail()
  1080.         //     ->setLabel('')
  1081.         //     ->setValue('Bestanden');
  1082.         $fieldName 'Reminders';
  1083.         $fields[$fieldName] = FormField::addTab('Reminders')
  1084.             ->onlyOnDetail()
  1085.             ->setlabel('Reminders/Notities');
  1086.         $fields[] = WorkflowOrderField::new('statusbalk9'$this->entityManager)
  1087.             ->onlyOnDetail()
  1088.             ->setValue('Reminders')
  1089.             ->setLabel('Status');
  1090.         $fieldName 'reminders';
  1091.         $fields[$fieldName] = AssociationField::new('reminders')
  1092.             ->setCrudController(ReminderCrudController::class)
  1093.             ->setTemplatePath('admin/fields/reminders.html.twig')
  1094.             ->hideWhenCreating()
  1095.             ->hideOnForm()
  1096.             ->onlyOnDetail();
  1097.         $fields['RecordinfoTab'] = FormField::addTab('Recordinfo')
  1098.             ->onlyOnDetail();
  1099.         $fields['Recordinfo'] = OrderInfoRecordField::new('Recordinfo'$this->entityManager)
  1100.             ->onlyOnDetail()
  1101.             ->setValue('Test');
  1102.         //last configuration changes
  1103.         //setting the default tab
  1104.         // if ($context->getRequest()->get("tab") === 'reminders') {
  1105.         //     $fields['Reminders']->setCustomOptions([FormField::OPTION_TAB_IS_ACTIVE => true]);
  1106.         // }
  1107.         // // of in de referrer
  1108.         // $referrer = $context->getRequest()->get('referrer');
  1109.         // if (null !== $referrer) {
  1110.         //     if (Request::create($referrer)->get('tab') === 'reminders') {
  1111.         //         $fields['Reminders']->setCustomOptions([FormField::OPTION_TAB_IS_ACTIVE => true]);
  1112.         //     }
  1113.         // }
  1114.         if ($tab $context->getRequest()->get("tab")) {
  1115.             $tab ucfirst($tab);
  1116.             $fields[$tab]->setCustomOptions([FormField::OPTION_TAB_IS_ACTIVE => true]);
  1117.         }
  1118.         // of in de referrer
  1119.         $referrer $context->getRequest()->get('referrer');
  1120.         if (null !== $referrer) {
  1121.             if ($tab Request::create($referrer)->get('tab')) {
  1122.                 $tab ucfirst($tab);
  1123.                 $fields[$tab]->setCustomOptions([FormField::OPTION_TAB_IS_ACTIVE => true]);
  1124.             }
  1125.         }
  1126.         foreach ($fields as $fieldName => $fieldObject) {
  1127.             if (!in_array($fieldName$indexList)) {
  1128.                 $fields[$fieldName]->hideOnIndex();
  1129.             }
  1130.             // if ($fieldName == 'prijs' && $context->getRequest()->get('crudAction') == 'edit'){
  1131.             //     $fieldObject->setDisabled();
  1132.             // }
  1133.             yield $fieldObject;
  1134.         }
  1135.         return;
  1136.         // yield TextField::new('uploadedBestand')
  1137.         // ->setFormType(FileUploadType::class)
  1138.         // ->onlyOnForms()
  1139.         // ->addJsFiles(Asset::fromEasyAdminAssetPackage('field-image.js'), Asset::fromEasyAdminAssetPackage('field-file-upload.js'))
  1140.         // ->setFormTypeOption('upload_new', 
  1141.         //     function(  ){
  1142.         //         $this->uploadedfileService->uploadFile($_REQUEST['entityId']);
  1143.         //         $this->createDbEntryService->createDbEntry( $_REQUEST['entityId']);
  1144.         //     })
  1145.         // ->setFormTypeOption('mapped', false)  ;      
  1146.     }
  1147.     public function configureCrud(Crud $crud): Crud
  1148.     {
  1149.         if (isset($_GET['entityId'])) {
  1150.             $entityId $_GET['entityId'];
  1151.             $recInfo $this->defineOfferteOrderService->getStatus($entityId);
  1152.         } else {
  1153.             $recInfo = ['status' => 'Onbekend''recordnr' => 0];
  1154.         }
  1155.         if (!isset($recInfo['ordernummer'])) {
  1156.             $recInfo['ordernummer'] = '00000000';
  1157.         };
  1158.         $crud->setPageTitle(CRUD::PAGE_INDEX'Alle Offertes/Orders');
  1159.         $crud->setPageTitle(CRUD::PAGE_DETAIL$recInfo['status'] . ' ' $recInfo['ordernummer']);
  1160.         $crud->setPageTitle(CRUD::PAGE_EDIT$recInfo['status'] . ' ' $recInfo['ordernummer']);
  1161.         $crud->setPageTitle(CRUD::PAGE_NEW'Maak nieuwe offerte/order');
  1162.         $crud->setDefaultSort(['ordernummer' => 'DESC']);
  1163.         return $crud;
  1164.     }
  1165.     public function configureFilters(Filters $filters): Filters
  1166.     {
  1167.         return $filters
  1168.             ->add('vestiging')
  1169.             ->add('record_type')
  1170.             ->add('orderstatus')
  1171.             ->add('ordersoort')
  1172.             ->add('begraafplaats')
  1173.             ->add('levermaand')
  1174.             ->add('leverweek');
  1175.     }
  1176.     public function updateEntity(EntityManagerInterface $entityManager$entityInstance): void
  1177.     {
  1178.         // setblameabels en actionsAfterUpdate
  1179.         //$changeSetService = new ChangeSetService($this->entityManager, $this->security);
  1180.         $changeSetService = new ChangeSetService($entityManager$this->security);
  1181.         $changeSet $changeSetService->getChangeSet($entityInstance);
  1182.         //dd($changeSet);
  1183.         if (count($changeSet) > 0) {
  1184.             $changeSetService->setBlameableChange($entityInstance$changeSet);
  1185.             //$changeSetService->setBlameableStatus($entityInstance, $changeSet);
  1186.         }
  1187.         //$this->entityManager->persist($entityInstance);
  1188.         //$this->entityManager->flush();
  1189.         $entityManager->persist($entityInstance);
  1190.         $entityManager->flush();
  1191.         // zet de levermaand altijd op de eerste dag van de maand.
  1192.         if ($entityInstance->getLevermaand() !== null) {
  1193.             $leverjaar $entityInstance->getLevermaand()->format('Y');
  1194.             $levermaand $entityInstance->getLevermaand()->format('m');
  1195.             $levermaandjaar = new DateTimeImmutable(sprintf('%s-%s-01 00:00:00'$leverjaar$levermaand));
  1196.             $entityInstance->setLevermaand($levermaandjaar);
  1197.         }
  1198.         parent::updateEntity($entityManager$entityInstance);
  1199.         // mogelijk is het een wijzinging die verdere acties nodig heeft.
  1200.         // dus de changeSet doorgeven aan de betreffende class voor getRedirectResponseAfterSave
  1201.         $this->changeSet $changeSet;
  1202.   
  1203.         //$entityManager->persist($entityInstance);
  1204.         //$entityManager->flush();
  1205.     }
  1206.     public function createEntity(string $entityFqcn)
  1207.     {
  1208.         $context $this->getContext();
  1209.         $recordType $context->getRequest()->get('recordType');
  1210.         $user $this->security->getUser();
  1211.         $createdAt =  new DateTimeImmutable('now');
  1212.         $order = new Order();
  1213.         $order->setCreatedAt($createdAt); // get depricated
  1214.         $order->setIngevoerdDatum($createdAt);
  1215.         $order->setIngevoerdDoor($user);
  1216.         $order->setStep(1);
  1217.         $order->setRecordType($recordType);
  1218.         if ($recordType == 'Order') {
  1219.             $order->setOrderMedewerker($user);
  1220.         }
  1221.         if ($recordType == 'Offerte') {
  1222.             $order->setOfferteMedewerker($user);
  1223.         }
  1224.         //orderstatus nieuw = 1
  1225.         $orderstatus $this->entityManager->getRepository(Orderstatus::class)->findOneBy(['id' => 1]);
  1226.         $order->setOrderstatus($orderstatus);
  1227.         //set familieId als aangelegd vanuit Familie
  1228.         $familieId $context->getRequest()->get('familieId');
  1229.         $familie $this->entityManager->getRepository(Familie::class)->findOneBy(['id' => $familieId]);
  1230.         $order->setFamilie($familie);
  1231.         //aanpassingNodig
  1232.         $aanpassing 0;
  1233.         $order->setAanpassingNodig($aanpassing);
  1234.         // vul velden vanuit prospectToOrder
  1235.         if ($context->getRequest()->get('prospectToOrder')) {
  1236.             $prospectId $context->getRequest()->get('prospectId');
  1237.             $prospect $this->entityManager->getRepository(Prospect::class)->findOneBy(['id' => $prospectId]);
  1238.             $order->setVestiging($prospect->getVestiging());
  1239.             $order->setOrdersoort($prospect->getOrdersoort());
  1240.             $order->setfamilie($prospect->getFamilie());
  1241.             $order->setOverledeneNaam($prospect->getOverledenenaam());
  1242.             $order->setGebDatum($prospect->getGebDatum());
  1243.             $order->setOverlDatum($prospect->getOverlDatum());
  1244.             $order->setBegraafplaats($prospect->getBegraafplaats());
  1245.             $order->setGrafnummer($prospect->getGrafnummer());
  1246.             $order->setUitvaartvereniging($prospect->getUitvaartvereniging());
  1247.             $order->setOpmerkingen($prospect->getOpmerkingen());
  1248.             //aanpassingNodig
  1249.             $aanpassing 0;
  1250.             $order->setAanpassingNodig($aanpassing);
  1251.         }
  1252.         return $order;
  1253.     }
  1254.     public function persistEntity(EntityManagerInterface $entityManager$entityInstance): void
  1255.     {
  1256.         //ordernummer
  1257.         $generatedOrdernummer $this->defineNewOrdernummerService->getNewOrdernummer();
  1258.         $entityInstance->setOrdernummer($generatedOrdernummer);
  1259.         parent::persistEntity($entityManager$entityInstance);
  1260.     }
  1261.     public function downloadAfhaalbon(AdminContext $adminContextEntityManagerInterface $entityManagerAdminUrlGenerator $adminUrlGenerator)
  1262.     {
  1263.         //Get variables
  1264.         $order $adminContext->getEntity()->getInstance();
  1265.         if (!$order instanceof Order) {
  1266.             throw new \LogicException('Entity is missing or not an Order');
  1267.         };
  1268.         //generate document
  1269.         $vars $this->tbsTemplateVars->getOrderVars($order);
  1270.         $this->OpenTBS->LoadTemplate('/home/easy_admin/templates/afhaler/afhaalbon.odt''already_utf8');
  1271.         //$this->OpenTBS->LoadTemplate($templatePath, 'already_utf8');
  1272.         $this->OpenTBS->MergeField('order'$vars);
  1273.         $documentName sprintf("afhaalbon_%s.odt"$order->getOrdernummer());
  1274.         $this->OpenTBS->Show(1$documentName);
  1275.         //now return response same page.
  1276.         $targetUrl $adminUrlGenerator
  1277.             ->setController(self::class)
  1278.             ->setAction(Crud::PAGE_DETAIL)
  1279.             ->setEntityId($order->getId())
  1280.             ->generateUrl();
  1281.         return $this->redirect($targetUrl);
  1282.     }
  1283.     public function downloadKlantBrief(AdminContext $adminContextEntityManagerInterface $entityManagerAdminUrlGenerator $adminUrlGenerator)
  1284.     {
  1285.         //Get variables
  1286.         $order $adminContext->getEntity()->getInstance();
  1287.         if (!$order instanceof Order) {
  1288.             throw new \LogicException('Entity is missing or not an Order');
  1289.         };
  1290.         $templatePath $adminContext->getRequest()->get('templatePath');
  1291.         $documentName $adminContext->getRequest()->get('documentName');
  1292.         //generate document
  1293.         $vars $this->tbsTemplateVars->getOrderVars($order);
  1294.         //dd($vars);
  1295.         $documentName sprintf("%s_%s.odt"$documentName$order->getOrdernummer());
  1296.         $this->OpenTBS->LoadTemplate($templatePath'already_utf8');
  1297.         $this->OpenTBS->MergeField('record'$vars);
  1298.         $this->OpenTBS->MergeBlock('regel'$vars['orderregels']);
  1299.         $this->OpenTBS->MergeBlock('slotregel'$vars['slotregels']);
  1300.         $this->OpenTBS->Show(1$documentName);
  1301.         //now return response same page.
  1302.         $targetUrl $adminUrlGenerator
  1303.             ->setController(self::class)
  1304.             ->setAction(Crud::PAGE_DETAIL)
  1305.             ->setEntityId($order->getId())
  1306.             ->generateUrl();
  1307.         return $this->redirect($targetUrl);
  1308.     }
  1309.     protected function getRedirectResponseAfterSave(AdminContext $contextstring $action): RedirectResponse
  1310.     {
  1311.         $submitButtonName $context->getRequest()->request->all()['ea']['newForm']['btn'];
  1312.         if (Action::SAVE_AND_CONTINUE === $submitButtonName) {
  1313.             $url $this->container->get(AdminUrlGenerator::class)
  1314.                 ->setAction(Action::EDIT)
  1315.                 ->setEntityId($context->getEntity()->getPrimaryKeyValue())
  1316.                 ->generateUrl();
  1317.             return $this->redirect($url);
  1318.         }
  1319.         if (Action::SAVE_AND_RETURN === $submitButtonName) {
  1320.             $controller get_class($this);
  1321.             if ($this->controllerFqcnAfterSetStatus != '') {
  1322.                 $controller $this->controllerFqcnAfterSetStatus;
  1323.             }
  1324.             $entityId $context->getEntity()->getPrimaryKeyValue();
  1325.             if ($this->entityIdAfterSetStatus != 0) {
  1326.                 $entityId $this->entityIdAfterSetStatus;
  1327.             }
  1328.             if (isset($this->tabAfterSetStatus)) {
  1329.                 if ($this->tabAfterSetStatus) {
  1330.                     $tab $this->tabAfterSetStatus;
  1331.                 }
  1332.             }
  1333.             $action Action::DETAIL;
  1334.             if ($this->actionAfterSetStatus != '') {
  1335.                 $action $this->actionAfterSetStatus;
  1336.             }
  1337.             //dd($this);
  1338.             $urlGenerator =  $this->container->get(AdminUrlGenerator::class)
  1339.                 ->setController($controller)
  1340.                 ->setEntityId($entityId)
  1341.                 ->setAction($action)
  1342.                 ->set('entityIdAfterSetStatus'$this->entityIdAfterSetStatus)
  1343.                 ->set('actionAfterSetStatus'$this->actionAfterSetStatus)
  1344.                 ->set('controllerFqcnAfterSetStatus'$this->controllerFqcnAfterSetStatus);
  1345.             foreach ($this->httpVars as $httpVar => $value) {
  1346.                 $urlGenerator
  1347.                     ->set($httpVar$value);
  1348.             }
  1349.             $urlGenerator
  1350.                 ->set('partialFields'$this->partialFields);
  1351.             $url $urlGenerator->generateUrl();
  1352.             return $this->redirect($url);
  1353.         }
  1354.         return $this->redirectToRoute($context->getDashboardRouteName());
  1355.     }
  1356.     public function actionBewerkStep()
  1357.     {
  1358.         //we zetten de referrers van de verschillende controllers in de stappen.
  1359.         $urlStep01 $this->adminUrlGenerator
  1360.             ->setAction(Action::EDIT)
  1361.             ->setEntityId($this->getContext()->getEntity()->getPrimaryKeyValue())
  1362.             ->setController(OrderPartialControllerStep01::class)
  1363.             ->generateUrl();
  1364.         $urlStep02 $this->adminUrlGenerator
  1365.             ->setAction(Action::EDIT)
  1366.             ->setEntityId($this->getContext()->getEntity()->getPrimaryKeyValue())
  1367.             ->setController(OrderPartialControllerStep02::class)
  1368.             ->generateUrl();
  1369.         $urlStep03 $this->adminUrlGenerator
  1370.             ->setAction(Action::EDIT)
  1371.             ->setEntityId($this->getContext()->getEntity()->getPrimaryKeyValue())
  1372.             ->setController(OrderPartialControllerStep03::class)
  1373.             ->generateUrl();
  1374.         $urlStep04 $this->adminUrlGenerator
  1375.             ->setAction(Action::EDIT)
  1376.             ->setEntityId($this->getContext()->getEntity()->getPrimaryKeyValue())
  1377.             ->setController(OrderPartialControllerStep04::class)
  1378.             ->generateUrl();
  1379.         $adminRefferer AdminReferrer::new($this->getContext())
  1380.             ->setReferrer(OrderPartialControllerStep02::class, $urlStep01)
  1381.             ->setReferrer(OrderPartialControllerStep03::class, $urlStep02)
  1382.             ->setReferrer(OrderPartialControllerStep04::class, $urlStep03)
  1383.             ->setReferrer(OrderPartialControllerStep05::class, $urlStep04);
  1384.         //dd($this->getContext()->getRequest()->getSession()->get('referrer'));
  1385.         $step $this->getContext()->getEntity()->getInstance()->getStep();
  1386.         switch ($step) {
  1387.             case 0:
  1388.                 $controller OrderPartialControllerStep01::class;
  1389.                 $action Action::EDIT;
  1390.                 break;
  1391.             case 1:
  1392.                 $controller OrderPartialControllerStep02::class;
  1393.                 $action Action::EDIT;
  1394.                 break;
  1395.             case 2:
  1396.                 $controller OrderPartialControllerStep03::class;
  1397.                 $action Action::EDIT;
  1398.                 break;
  1399.             case 3:
  1400.                 $controller OrderPartialControllerStep04::class;
  1401.                 $action Action::EDIT;
  1402.                 break;
  1403.             case 4:
  1404.                 $controller OrderPartialControllerStep05::class;
  1405.                 $action Action::DETAIL;
  1406.                 break;
  1407.             case 5:
  1408.                 dd('Dit zou niet moeten kunnen, de actielink had verborgen moeten zijn');
  1409.             case null:
  1410.                 dd('Dit zou niet moeten kunnen, de actielink had verborgen moeten zijn');
  1411.         }
  1412.         $meldingtekst 'Het record is nog niet volledig ingevoerd, <br>
  1413.                             ga hieronder verder met stap ' $step 1;
  1414.         $flash sprintf('<div class="text-center "><h2>%s</h2></div>'$meldingtekst);
  1415.         $this->addFlash('warning'$flash);
  1416.         $this->adminUrlGenerator
  1417.             ->setAction($action)
  1418.             ->setEntityId($this->getContext()->getEntity()->getPrimaryKeyValue())
  1419.             ->setController($controller)
  1420.         ;
  1421.         $url $this->adminUrlGenerator->generateUrl();
  1422.         //dd($url);
  1423.         return $this->redirect($url);
  1424.     }
  1425.     public function setStatus(AdminContext $context)
  1426.     {
  1427.         $this->entityIdAfterSetStatus $this->getContext()->getEntity()->getPrimaryKeyValue();
  1428.         $status = ($this->getContext()->getRequest()->get('status'));
  1429.         $orderstatus $this->entityManager->getRepository(Orderstatus::class)->findOneBy(['status' => $status]);
  1430.         $order $this->getContext()->getEntity()->getInstance();
  1431.         $order->setOrderstatus($orderstatus);
  1432.         // setblameables en actionsAfterUpdate
  1433.         $changeSetService = new ChangeSetService($this->entityManager$this->security);
  1434.         $changeSet $changeSetService->getChangeSet($order);
  1435.         //dd($changeSet);
  1436.         if (count($changeSet) > 0) {
  1437.             $changeSetService->setBlameableChange($order$changeSet);
  1438.             $changeSetService->setBlameableStatus($order$changeSet);
  1439.             $this->entityManager->persist($order);
  1440.             $this->entityManager->flush();
  1441.             //check of er gewenste velden niet zijn ingevuld. OrderpartialControllerField::checkFields 
  1442.             //$status = $changeSet['orderstatus']['new'];
  1443.             $status $order->getOrderstatus();
  1444.             //Eerst algemene orderChecker.
  1445.             $orderChecker = new Orderchecker($order);
  1446.             $warnings $orderChecker->getStatusWarnings($status);
  1447.             //dd($warnings);
  1448.             foreach ($warnings as $melding) {
  1449.                 $flash sprintf('<div class="text-center "><h2>%s!</h2></div>'$melding);
  1450.                 $this->addFlash('warning'$flash);
  1451.             }
  1452.             //Nu checken op niet ingevulde velden of lijsten.
  1453.             $this->partialFields OrderPartialControllerDynamicFields::checkFields($order$status);
  1454.             if (count($this->partialFields) > 0) {
  1455.                 foreach ($this->partialFields as $field => $melding) {
  1456.                     $flash sprintf('<div class="text-center "><h2>%s!</h2></div>'$melding);
  1457.                     $this->addFlash('warning'$flash);
  1458.                 }
  1459.                 // Referrer nwe stijl
  1460.                 // Plaats de refferer voor de volgende controller.
  1461.                 $referrer $this->getContext()->getRequest()->getRequestUri();
  1462.                 //we halen de tab uit de referrer want we willen terugkomen in het overzichtscherm van de order
  1463.                 //en de crudAction moet detail worden ipv setStatus
  1464.                 $adminRefferer AdminReferrer::new($context);
  1465.                 $adminRefferer->setReferrer(OrderPartialControllerDynamicFields::class)
  1466.                     ->removeParameters(OrderPartialControllerDynamicFields::class, ['tab''crudAction'])
  1467.                     ->addParameters(OrderPartialControllerDynamicFields::class, ['crudAction' => 'detail'])
  1468.                 ;
  1469.                 //zetten ook alvast voor de Listst
  1470.                 $adminRefferer->setReferrer(OrderPartialControllerDynamicLists::class)
  1471.                     ->removeParameters(OrderPartialControllerDynamicLists::class, ['tab''crudAction'])
  1472.                     ->addParameters(OrderPartialControllerDynamicLists::class, ['crudAction' => 'detail']);
  1473.                 //We sturen door naar OrderpartialControllerField::EDIT ??
  1474.                 $url $this->adminUrlGenerator
  1475.                     ->setController(OrderPartialControllerDynamicFields::class)
  1476.                     ->setAction(Action::EDIT)
  1477.                     ->setEntityId($order->getId())
  1478.                     ->set('partialFields'$this->partialFields)
  1479.                     ->generateUrl();
  1480.                 return $this->redirect($url);
  1481.             }
  1482.             //controleren op niet ingevulde lists
  1483.             $this->partialFields OrderPartialControllerDynamicLists::checkLists($order$status);
  1484.             if (count($this->partialFields) > 0) {
  1485.                 foreach ($this->partialFields as $field => $melding) {
  1486.                     $flash sprintf('<div class="text-center "><h2>%s!</h2></div>'$melding);
  1487.                     $this->addFlash('warning'$flash);
  1488.                 }
  1489.                 // Referrer nwe stijl
  1490.                 // Plaats de refferer voor de volgende controller.
  1491.                 $adminRefferer AdminReferrer::new($context);
  1492.                 $adminRefferer->setReferrer(OrderPartialControllerDynamicLists::class)
  1493.                     ->removeParameters(OrderPartialControllerDynamicLists::class, ['tab''crudAction'])
  1494.                     ->addParameters(OrderPartialControllerDynamicLists::class, ['crudAction' => 'detail'])
  1495.                 ;
  1496.                 // $referrer = $this->getContext()->getRequest()->getRequestUri();
  1497.                 // $this->setReferrer(OrderPartialControllerDynamicLists::class, $referrer);              
  1498.                 // $this->removeParametersReferrer(OrderPartialControllerDynamicLists::class,['tab','crudAction']);
  1499.                 // $this->addToReferrer(OrderPartialControllerDynamicLists::class, 'crudAction', 'detail');
  1500.                 //We sturen door naar OrderpartialControllerLists::EDIT ??
  1501.                 $url $this->adminUrlGenerator
  1502.                     ->setController(OrderPartialControllerDynamicLists::class)
  1503.                     ->setAction(Action::DETAIL)
  1504.                     ->setEntityId($order->getId())
  1505.                     ->set('partialFields'$this->partialFields)
  1506.                     ->generateUrl();
  1507.                 return $this->redirect($url);
  1508.             }
  1509.             //Geen niet ingevulde velden en lijsten, dus terug naar het record.
  1510.             $url $this->adminUrlGenerator
  1511.                 ->setController(OrderCrudController::class)
  1512.                 ->setAction(Action::DETAIL)
  1513.                 ->setEntityId($order->getId())
  1514.                 ->unset('tab')
  1515.                 ->generateUrl();
  1516.             //dd($url);
  1517.             return $this->redirect($url);
  1518.         }
  1519.         dd('Denk niet dat we hieronder komen');
  1520.         $url $this->adminUrlGenerator
  1521.             //->setAction(Action::DETAIL)
  1522.             //->setEntityId($this->getContext()->getEntity()->getPrimaryKeyValue())
  1523.             ->setController($this->controllerFqcnAfterSetStatus)
  1524.             ->setAction($this->actionAfterSetStatus)
  1525.             ->setEntityId($this->entityIdAfterSetStatus)
  1526.             //->setReferrer($this->getContext()->getReferrer())
  1527.         ;
  1528.         foreach ($this->httpVars as $httpVar => $value) {
  1529.             $this->adminUrlGenerator
  1530.                 ->set($httpVar$value);
  1531.         };
  1532.         //$partialFields = [0,1];
  1533.         $this->adminUrlGenerator
  1534.             ->set('partialFields'$this->partialFields);
  1535.         $url $this->adminUrlGenerator->generateUrl();
  1536.         //dd($url);
  1537.         return $this->redirect($url);
  1538.     }
  1539. }