<?php
namespace App\Controller\Admin;
use App\Controller\Admin\Order\Partial\OrderPartialControllerDynamicFields;
use App\Controller\Admin\Order\Partial\OrderPartialControllerDynamicLists;
use App\Controller\Admin\Order\Partial\OrderPartialControllerFields01;
use App\Controller\Admin\Order\Partial\OrderPartialControllerLeges;
use App\Controller\Admin\Order\Partial\OrderPartialControllerModel;
use App\Controller\Admin\Order\Partial\OrderPartialControllerOntwerp;
use App\Controller\Admin\Order\Partial\OrderPartialControllerStep01;
use App\Controller\Admin\Order\Partial\OrderPartialControllerStep02;
use App\Controller\Admin\Order\Partial\OrderPartialControllerStep03;
use App\Controller\Admin\Order\Partial\OrderPartialControllerStep04;
use App\Controller\Admin\Order\Partial\OrderPartialControllerStep05;
use App\Controller\Admin\Order\Partial\TabOooController;
use App\Controller\Admin\Orderonderdeel\Sub\OrderonderdeelSubController;
use App\Controller\Admin\Orderregel\Sub\OrderregelSubController;
use App\Controller\Admin\Reminder\ReminderCrudController;
use App\Controller\Admin\Traits\ReferrerTrait;
use App\EasyAdmin\BewerkTabField;
use App\EasyAdmin\OrderInfoRecordField;
use App\EasyAdmin\OrderMeldingField;
use App\Entity\Order;
use DateTimeImmutable;
use App\Entity\Familie;
use App\Entity\Prospect;
use App\Service\OpenTBS;
use App\Entity\Orderstatus;
use Doctrine\ORM\QueryBuilder;
use App\Service\DefineIndexList;
use App\Service\TbsTemplateVars;
use App\Service\UploadedfileService;
use App\Service\CreateDbEntryService;
use App\EasyAdmin\OrderUitgelichtField;
use Doctrine\ORM\EntityManagerInterface;
use App\Service\DefineOfferteOrderService;
use App\EasyAdmin\OrderOverzichtBasisField;
use App\EasyAdmin\OrderOverzichtRecordField;
use App\Service\DefineNewOrdernummerService;
use App\EasyAdmin\OrderOverzichtWorkflowField;
use App\EasyAdmin\OrderSummaryField;
use App\EasyAdmin\WorkflowOrderField;
use App\Entity\Orderonderdeel;
use App\Service\AdminReferrer;
use App\Service\ChangeSetService;
use App\Service\FinanceOrderService;
use App\Service\OrderChecker;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Field\Field;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Filters;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Field\MoneyField;
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use Symfony\Component\HttpFoundation\RedirectResponse;
use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use EasyCorp\Bundle\EasyAdminBundle\Field\CollectionField;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Security;
class OrderCrudController extends AbstractCrudController
{
//use ReferrerTrait;
public $user;
public string $controllerFqcnAfterSetStatus;
public string $actionAfterSetStatus;
public string $tabAfterSetStatus;
public int $entityIdAfterSetStatus;
private array $partialFields;
public array $httpVars;
public array $changeSet;
public function __construct(
private UploadedfileService $uploadedfileService,
private CreateDbEntryService $createDbEntryService,
private EntityManagerInterface $entityManager,
public DefineOfferteOrderService $defineOfferteOrderService,
public DefineNewOrdernummerService $defineNewOrdernummerService,
public OpenTBS $OpenTBS,
private AdminUrlGenerator $adminUrlGenerator,
public TbsTemplateVars $tbsTemplateVars,
public DefineIndexList $defineIndexList,
public Security $security,
public FinanceOrderService $financeOrderService,
) {
//dd(phpinfo());
//dd($_REQUEST,$_GET, $_POST);
$this->uploadedfileService = $uploadedfileService;
$this->createDbEntryService = $createDbEntryService;
$this->entityManager = $entityManager;
$this->defineOfferteOrderService = $defineOfferteOrderService;
$this->defineNewOrdernummerService = $defineNewOrdernummerService;
$this->OpenTBS = $OpenTBS;
$this->adminUrlGenerator = $adminUrlGenerator;
$this->tbsTemplateVars = $tbsTemplateVars;
$this->defineIndexList = $defineIndexList;
$this->security = $security;
$this->controllerFqcnAfterSetStatus = get_class($this);
$this->actionAfterSetStatus = Action::DETAIL;
$this->entityIdAfterSetStatus = 0;
$this->httpVars = array();
$this->partialFields = array();
$this->changeSet = array();
$this->financeOrderService = $financeOrderService;
}
public static function getEntityFqcn(): string
{
return Order::class;
}
public function getEntityManager(): EntityManagerInterface
{
return $this->entityManager;
}
public function detail(AdminContext $adminContext)
{
$this->financeOrderService->calculateAndWritePrijs($adminContext->getEntity()->getInstance());
return parent::detail($adminContext);
}
// public function configureCrud(Crud $crud): Crud
// {
// return $crud
// //->setFormThemes(['admin/fields/attachments.form.twig', '@EasyAdmin/crud/form_theme.html.twig'])
// ->showEntityActionsInlined()
// ;
// }
public function configureActions(Actions $actions): Actions
{
if (isset($_REQUEST['entityId'])) {
$entityId = $_REQUEST['entityId'];
$documentsDropdown = Action::new('Genereer documenten')
->displayAsButton()
->setTemplatePath('admin/buttons/dropdownButton.html.twig')
->linkToCrudAction('detail')
->addCssClass('btn btn-secundary ');
// We gebruiken de translationParameters om de actionUrl's door te geven aan twig.
//$actionUrl = 'http://localhost/admin?crudAction=downloadAfhaalbon&crudControllerFqcn=App%5CController%5CAdmin%5COrderCrudController&entityId=29&menuIndex=3&referrer=http://localhost/admin?crudAction%3Ddetail%26crudControllerFqcn%3DApp%255CController%255CAdmin%255COrderCrudController%26entityId%3D29%26menuIndex%3D3%26submenuIndex%3D0&submenuIndex=0"';
$afhaalbonUrl = $this->adminUrlGenerator
->setController(OrderCrudController::class)
->setAction('downloadAfhaalbon')
->setEntityId($entityId)
->unset('method')
->generateUrl();
$offerteUrl = $this->adminUrlGenerator
->setController(OrderCrudController::class)
->setAction('downloadKlantBrief')
->setEntityId($entityId)
->set('templatePath', '/home/easy_admin/templates/offerte/offerte.odt')
->set('documentName', 'Offerte')
->unset('method')
->generateUrl();
$offerteNieuwUrl = $this->adminUrlGenerator
->setController(OrderCrudController::class)
->setAction('downloadKlantBrief')
->setEntityId($entityId)
->set('templatePath', '/home/easy_admin/templates/offerte/offerte_nieuw.odt')
->set('documentName', 'Offerte_nieuw')
->unset('method')
->generateUrl();
$offerteBestaandUrl = $this->adminUrlGenerator
->setController(OrderCrudController::class)
->setAction('downloadKlantBrief')
->set('templatePath', '/home/easy_admin/templates/offerte/offerte_bestaand.odt')
->set('documentName', 'Offerte_bestaand')
->setEntityId($entityId)
->unset('method')
->generateUrl();
$orderBevestigingUrl = $this->adminUrlGenerator
->setController(OrderCrudController::class)
->setAction('downloadKlantBrief')
->setEntityId($entityId)
->set('templatePath', '/home/easy_admin/templates/order/orderbevestiging.odt')
->set('documentName', 'Orderbevestiging')
->unset('method')
->generateUrl();
$orderBevestiging2VoudUrl = $this->adminUrlGenerator
->setController(OrderCrudController::class)
->setAction('downloadKlantBrief')
->setEntityId($entityId)
->set('templatePath', '/home/easy_admin/templates/order/orderbevestiging_2voud.odt')
->set('documentName', 'Orderbevestiging_2voud')
->unset('method')
->generateUrl();
$orderNieuwUrl = $this->adminUrlGenerator
->setController(OrderCrudController::class)
->setAction('downloadKlantBrief')
->setEntityId($entityId)
->set('templatePath', '/home/easy_admin/templates/order/orderbevestiging_nieuw.odt')
->set('documentName', 'Order_nieuw')
->unset('method')
->generateUrl();
$orderNieuw2VoudUrl = $this->adminUrlGenerator
->setController(OrderCrudController::class)
->setAction('downloadKlantBrief')
->setEntityId($entityId)
->set('templatePath', '/home/easy_admin/templates/order/orderbevestiging_nieuw_2-voud.odt')
->set('documentName', 'Order_nieuw_2-voud')
->unset('method')
->generateUrl();
$orderBestaandUrl = $this->adminUrlGenerator
->setController(OrderCrudController::class)
->setAction('downloadKlantBrief')
->setEntityId($entityId)
->set('templatePath', '/home/easy_admin/templates/order/orderbevestiging_bestaand.odt')
->set('documentName', 'Order_bestaand')
->unset('method')
->generateUrl();
$orderBestaand2VoudUrl = $this->adminUrlGenerator
->setController(OrderCrudController::class)
->setAction('downloadKlantBrief')
->setEntityId($entityId)
->set('templatePath', '/home/easy_admin/templates/order/orderbevestiging_bestaand_2-voud.odt')
->set('documentName', 'Order_bestaand (2voud)')
->unset('method')
->generateUrl();
$order = $this->entityManager->getRepository(Order::class)->findOneBy(['id' => $entityId]);
$ordersoort = $order->getOrdersoort();
$recordtype = $order->getRecordtype();
// bepaal welke documenten moeten worden getoond.
$showDocument['afhaalbon'] = 0;
$showDocument['offerte'] = 0;
$showDocument['offerteNieuw'] = 0;
$showDocument['offerteBestaand'] = 0;
$showDocument['orderBevestiging'] = 0;
$showDocument['orderBevestiging2Voud'] = 0;
$showDocument['orderNieuw'] = 0;
$showDocument['orderNieuw2Voud'] = 0;
$showDocument['orderBestaand'] = 0;
$showDocument['orderBestaand2Voud'] = 0;
if ($ordersoort == 'Afhaler') {
$showDocument['afhaalbon'] = 1;
}
if ($recordtype == 'Offerte') {
$showDocument['offerte'] = 1;
$showDocument['offerteNieuw'] = 0;
$showDocument['offerteBestaand'] = 0;
}
if ($recordtype == 'Order') {
$showDocument['orderBevestiging'] = 1;
$showDocument['orderBevestiging2Voud'] = 1;
$showDocument['orderNieuw'] = 0;
$showDocument['orderNieuw2Voud'] = 0;
$showDocument['orderBestaand'] = 0;
$showDocument['orderBestaand2Voud'] = 0;
}
$dropDownArray = [];
if ($showDocument['afhaalbon']) {
$dropDownArray['Afhaalbon'] = $afhaalbonUrl;
};
if ($showDocument['offerte']) {
$dropDownArray['Offerte'] = $offerteUrl;
};
if ($showDocument['offerteNieuw']) {
$dropDownArray['Offerte nieuw'] = $offerteNieuwUrl;
};
if ($showDocument['offerteBestaand']) {
$dropDownArray['Offerte bestaand'] = $offerteBestaandUrl;
};
if ($showDocument['orderBevestiging']) {
$dropDownArray['Orderbevestiging'] = $orderBevestigingUrl;
};
if ($showDocument['orderBevestiging2Voud']) {
$dropDownArray['Orderbevestiging (2voud)'] = $orderBevestiging2VoudUrl;
};
if ($showDocument['orderNieuw']) {
$dropDownArray['Order nieuw'] = $orderNieuwUrl;
};
if ($showDocument['orderNieuw2Voud']) {
$dropDownArray['Order nieuw (2voud)'] = $orderNieuw2VoudUrl;
};
if ($showDocument['orderBestaand']) {
$dropDownArray['Order bestaand'] = $orderBestaandUrl;
};
if ($showDocument['orderBestaand2Voud']) {
$dropDownArray['Order bestaand (2voud)'] = $orderBestaand2VoudUrl;
};
$documentsDropdown->setTranslationParameters(
$dropDownArray
);
$actions->add(Crud::PAGE_DETAIL, $documentsDropdown);
};
// action new recordInStappen alleen toevoegen bij "alle records"
if (OrderCrudController::class == get_class($this)) {
//Order
$recordNewOrderUrl = $this->adminUrlGenerator
->setController(OrderPartialControllerStep01::class)
->setAction(Action::NEW)
->set('recordType', 'Order')
->generateUrl();
$actionNewOrder = Action::new('nweOrder', 'Nieuwe Order')
->linkToUrl($recordNewOrderUrl)
->setCssClass('btn btn-primary')
->createAsGlobalAction();
$actions->add(Crud::PAGE_INDEX, $actionNewOrder);
//Offerte
$recordNewOrderUrl = $this->adminUrlGenerator
->setController(OrderPartialControllerStep01::class)
->setAction(Action::NEW)
->set('recordType', 'Offerte')
->generateUrl();
$actionNewOfferte = Action::new('nweOfferte', 'Nieuwe Offerte')
->linkToUrl($recordNewOrderUrl)
->setCssClass('btn btn-primary')
->createAsGlobalAction();
$actions->add(Crud::PAGE_INDEX, $actionNewOfferte);
}
// Editaction redirect to invoerstep
$actionEditStepOrderDetail = Action::new('actionBewerkStepDetail', 'Maak de invoerstappen af')
->linkToCrudAction('actionBewerkStep')
->setCssClass('btn btn-danger me-2');
$actionEditStepOrder = Action::new('actionBewerkStep', 'Invoerstappen afmaken')
->linkToCrudAction('actionBewerkStep')
->setCssClass('text-danger');
$actions->add(Crud::PAGE_INDEX, $actionEditStepOrder);
$actions->add(Crud::PAGE_DETAIL, $actionEditStepOrderDetail);
//check op invoerstappen INDEX screen
$actions->update(Crud::PAGE_INDEX, Action::EDIT, function (Action $action) {
$action->displayIf(
static function (Order $order) {
// dd($order);
if ($order->getStep() == 5) {
return true;
} else {
return false;
}
}
);
return $action;
});
$actions->update(Crud::PAGE_INDEX, $actionEditStepOrder, function (Action $action) {
$action->displayIf(
static function (Order $order) {
// dd($order);
if ($order->getStep() <> 5) {
return true;
} else {
return false;
}
}
);
return $action;
});
//check op invoerstappen DETAIL screen
$actions->update(Crud::PAGE_DETAIL, Action::EDIT, function (Action $action) {
$action->displayIf(
static function (Order $order) {
if ($order->getStep() == 5) {
return true;
} else {
return false;
}
}
);
return $action;
});
$actions->update(Crud::PAGE_DETAIL, $actionEditStepOrderDetail, function (Action $action) {
$action->displayIf(
static function (Order $order) {
if ($order->getStep() <> 5) {
return true;
} else {
return false;
}
}
);
return $action;
});
//dd($documentsDropdown);
return $actions
->disable(Action::NEW)
->disable(Action::DELETE)
->add(Crud::PAGE_EDIT, Action::DETAIL)
->disable(Action::SAVE_AND_ADD_ANOTHER)
->remove(Crud::PAGE_DETAIL, Action::EDIT)
->remove(Crud::PAGE_INDEX, Action::EDIT)
//->reorder(crud::PAGE_DETAIL, [Action::INDEX, $documentsDropdown::class, $actionEditStepOrderDetail::class])
//->reorder(crud::PAGE_DETAIL, [Action::INDEX,'Genereer documenten']);
;
}
public function configureFields(string $pageName): iterable
{
//We kunnen vanuit deze controller via de Fields de volgende controllers aanroepen
//OrderonderdeelSubController
//OrderregelsSubcontroller
//We zetten alvast de referrers
//Let wel het tabblad weten we nog niet, dat zetten we in de volgende controller in configureFields
$adminRefferer = AdminReferrer::new($this->getContext())
->setReferrer(OrderregelSubController::class)
->setReferrer(OrderonderdeelSubController::class)
->setReferrer(OrderPartialControllerLeges::class)
->setReferrer(OrderPartialControllerModel::class)
->setReferrer(TabOooController::class);
$context = $this->getContext();
$order = $context->getEntity()->getInstance();
$crudControllerFqcn = $context->getRequest()->get('crudControllerFqcn');
$indexList = $this->defineIndexList->getOrderIndexList($crudControllerFqcn);
//dd($indexList);
//nu de velden definieren
// Overzicht
$fields['Overzicht'] = FormField::addTab('Overzicht')
->onlyOnDetail();
$fields[] = WorkflowOrderField::new('statusbalk1', $this->entityManager)
->onlyOnDetail()
->setValue('Overzicht')
->setLabel('Status');
if ($order) {
if ($order->isVooruitbesteld()) {
$fields[] = OrderMeldingField::new('Melding1', $this->entityManager)
->onlyOnDetail()
->setlabel('')
->setValue('Test')
->setFormattedValue('Deze order is vooruitbesteld !');
}
}
if ($order) {
if ($order->isPlaatsenFamilieAanwezig()) {
$fields[] = OrderMeldingField::new('Melding2', $this->entityManager)
->onlyOnDetail()
->setlabel('')
->setValue('Test')
->setFormattedValue('De familie wil aanwezig zijn bij plaatsing !');
}
}
if ($order) {
if ($order->getPlaatsenVoorDatum()) {
$melding = sprintf("Plaatsen voor datum: %s !", $order->getPlaatsenVoorDatum()->format('d-m-Y'));
$fields[] = OrderMeldingField::new('Melding3', $this->entityManager)
->onlyOnDetail()
->setlabel('')
->setValue('Test')
->setFormattedValue($melding);
}
}
$fields[] = OrderSummaryField::new('Summary', $this->entityManager)
->setLabel('Overzicht')
->onlyOnDetail()
->setValue('Test');
//$fields[] = OrderOverzichtRecordField::new('Record', $this->entityManager)
// ->onlyOnDetail()
// ->setValue('Test');
//$fields[] = OrderOverzichtBasisField::new('Basisgegevens', $this->entityManager)
// ->onlyOnDetail()
// ->setValue('Test');
$fields[] = OrderOverzichtWorkflowField::new('Workflow', $this->entityManager, 'Workflow', $this->defineOfferteOrderService)
->onlyOnDetail()
->setValue('Test')
->setHelp('
In dit workflow overzicht kun je zien wat er nog moet gebeuren in de uitvoering van de offerte/order.
<br>
Achter elk onderwerp wordt een icoontje getoond:
<br><br>Rood kruis: betekent dat er nog niks is gedaan aan dit onderwerp.
<br><br>Grijs kruis: Het onderwerp is in behandeling genomen, maar nog niet afgerond (Bijv. vergunning is wel verstuurd maar nog niet ontvangen)
<br><br>Groene vink: Dit onderwerp is afgerond.
<br><br><br>Als het onderwerp niet van toepassing is op deze offerte/order, dan staat er geen icoontje.
');
$fields[] = OrderUitgelichtField::new('Uitgelicht', $this->entityManager, 'Uitgelicht')
->onlyOnDetail()
->setValue('Test')
->setHelp('Hier moet de meest recente tekening of belangrijk document getoond worden,
je kunt een tekening of bestand op "uitgelicht" zetten onder het tabblad "Bestanden"
');
// Basisgegevens
$fields['Basisgegevens'] = FormField::addTab('Basisgegevens')
->hideWhenCreating();
$fields[] = WorkflowOrderField::new('statusbalk2', $this->entityManager)
->onlyOnDetail()
->setValue('Basisgegevens')
->setLabel('Status');
$fieldName = 'ordernummer';
$fields[$fieldName] = NumberField::new($fieldName)
->hideWhenCreating()
->setNumberFormat('%s')
->setLabel('Nummer');
$fieldName = 'record_type';
$fields[$fieldName] = ChoiceField::new($fieldName)
->setLabel('Type')
->setChoices(['Onbekend' => 'Onbekend', 'Offerte' => 'Offerte', 'Order' => 'Order'])
->setHelp('"Offerte" of "Order".<br>"Onbekend" bij bijv. afhaler (nog geen contact gehad met familie).');
$fieldName = 'createdAt';
$fields[$fieldName] = DateField::new($fieldName)
->setLabel('Aanmaakdatum')
->setFormat('d-M-Y');
$fieldName = 'vestiging';
$fields[$fieldName] = AssociationField::new($fieldName);
$fieldName = 'ordersoort';
$fields[$fieldName] = AssociationField::new($fieldName)
->setHelp('"Bestaand" voor bijv. restauratie, "Afhaler" voor bijzetting, "Overig" voor bijv. tekst inschilderen. NB. dit veld nooit wijzigen!');
$fieldName = 'familie';
$fields[$fieldName] = AssociationField::new($fieldName)
->autocomplete()
->setLabel('Familie');
$fieldName = 'comm';
$fields[$fieldName] = AssociationField::new($fieldName)
->autocomplete()
->setLabel('Communicatie')
->setHelp('De wijze van contact met de familie');
$fieldName = 'overledene_naam';
$fields[$fieldName] = TextField::new($fieldName);
$fieldName = 'geb_datum';
$fields[$fieldName] = DateField::new($fieldName)
->setFormat('d-M-Y');
$fieldName = 'overl_datum';
$fields[$fieldName] = DateField::new($fieldName)
->setFormat('d-M-Y');
$fieldName = 'begraafplaats';
$fields[$fieldName] = AssociationField::new($fieldName)
->autocomplete();
$fieldName = 'grafnummer';
$fields[$fieldName] = TextField::new($fieldName);
$fieldName = 'uitvaartvereniging';
$fields[$fieldName] = AssociationField::new($fieldName)
->setLabel('Uitvaartvereniging')
->autocomplete();
$fieldName = 'opmerkingen';
$fields[$fieldName] = TextareaField::new($fieldName)
->setHelp('Iedereen moet hier kunnen zien of er iets aparts aan de order is.<br>
<i>Bijv. familie aanwezig bij plaatsing, factuur via uitvaarleider, familie in werkplaats voor indeling tekst, zoon bellen na plaatsen, etc.</i>
');
$fieldName = 'opmerkingen_werkbon';
$fields[$fieldName] = TextareaField::new($fieldName)
->setHelp('Plaats hier de opmerkingen die van belang zijn voor de werkplaats.<br>
<i>Bijv. Alleen letterplaat meenemen, eerst melden bij beheerder (0612345678), etc.</i>
');
$fields[] = BewerkTabField::new('_bewerk1', $this->entityManager)
->onlyOnDetail()
->setLabel('')
->setValue('Basisgegevens');
// Offerte/Order
$fields['Ooo'] = FormField::addTab('Offerte/Order/Ontwerp')
->hideWhenCreating();
$fields[] = WorkflowOrderField::new('statusbalk3', $this->entityManager)
->onlyOnDetail()
->setValue('Ooo')
->setLabel('Status');
$fieldName = 'orderstatus';
$fields[$fieldName] = AssociationField::new($fieldName)
->setLabel('Status')
->hideWhenCreating()
->hideOnDetail()
->setQueryBuilder(function (QueryBuilder $queryBuilder) {
$queryBuilder->orderby('entity.volgorde, entity.id');
})
->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.');
$fieldName = 'aanpassing_nodig';
$fields[$fieldName] = BooleanField::new($fieldName)
->setLabel('Aanpassing ?')
->hideWhenCreating()
->renderAsSwitch(false)
->setHelp('Is er een wijziging doorgegeven die nog moet worden verwerkt?
<br>
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.
');
//Offerte Panel
if ($order) {
if ($order->getRecordType() == 'Offerte' || $order->getOfferteDatum() !== null) {
$fields[] = FormField::addPanel('Offerte')->collapsible()
->hideWhenCreating();
} else {
$fields[] = FormField::addPanel('Offerte')
->renderCollapsed()
->hideWhenCreating();
}
}
$fieldName = 'offerte_medewerker';
$fields[$fieldName] = AssociationField::new($fieldName)
//->hideWhenCreating()
->setColumns(3)
->setHelp('Wie heeft de offerte genoteerd van de klant. (Niet degene die de offerte heeft verwerkt)');
$fieldName = 'offerte_datum';
$fields[$fieldName] = DateField::new($fieldName)
->setLabel('Datum verkrijging offerte')
->setFormat('d-M-Y')
->setColumns(9)
->sethelp('Datum dat eerste offerte gekregen is.<br>(Meerdere offertes? Meld dit dan in veld "Opmerkingen" bij "Basisgegevens".)');
$fieldName = 'offerte_datum_verstuurd';
$fields[$fieldName] = DateField::new($fieldName)
->hideWhenCreating()
->setFormat('d-M-Y')
->setLabel('Datum offerte verstuurd')
->setColumns(9);
//Order panel
if ($order) {
if ($order->getRecordType() == 'Order') {
$fields[] = FormField::addPanel('Order')->collapsible()
->hideWhenCreating();
} else {
$fields[] = FormField::addPanel('Order')
->renderCollapsed()
->hideWhenCreating();
}
}
$fieldName = 'order_medewerker';
$fields[$fieldName] = AssociationField::new($fieldName)
//->hideWhenCreating()
->setHelp('Dit is de medewerker die de order van de klant heeft gekregen')
->setColumns(3);
$fieldName = 'order_datum';
$fields[$fieldName] = DateField::new($fieldName)
->setLabel('Datum verkrijging order')
->setFormat('d-M-Y')
->setColumns(9);
$fieldName = 'datum_order_verstuurd';
$fields[$fieldName] = DateField::new($fieldName)
->setLabel('Datum order verstuurd')
->setFormat('d-M-Y')
->hideWhenCreating()
->setColumns(9);
$fieldName = 'order_akkoord';
$fields[$fieldName] = BooleanField::new($fieldName)
->setLabel('Akkoord?')
->renderAsSwitch(false)
->setHelp('Een order is "Akkoord" als:
<br>-bij de verkoop een handtekening is gezet
<br>-via de mail een akkoord is gegeven
<br>-de offerte/order ondertekend is ontvangen.
<br><i>Als er via de telefoon akkoord wordt gegeven,
vraag dan altijd of de klant het op de mail wil zetten</i>
');
$fieldName = 'vooruitbesteld';
$fields[$fieldName] = BooleanField::new($fieldName)
->setLabel('Vooruitbesteld?')
->setHelp('Een vooruitbestelde order wordt "geparkeerd" voor afroep.
<br>-deze order is (nadat deze is vertuurd) alleen zichtbaar in de lijst "Orders vooruitbesteld"
');
$fields[] = FormField::addRow();
//Ontwerpen Panel
if ($order) {
if ($order->isOntwerpNodig()) {
$fields[] = FormField::addPanel('Ontwerp')->collapsible()
->hideWhenCreating();
} else {
$fields[] = FormField::addPanel('Ontwerp')
->renderCollapsed()
->hideWhenCreating();
}
}
$fieldName = 'ontwerp_nodig';
$fields[$fieldName] = BooleanField::new($fieldName)
->setColumns(3);
$fieldName = 'ontwerp_medewerker';
$fields[$fieldName] = AssociationField::new($fieldName)
->hideWhenCreating()
->setColumns(3);
$fieldName = 'ontwerp_datum';
$fields[$fieldName] = DateField::new($fieldName)
->hideWhenCreating()
->setFormat('d-M-Y')
->setColumns(3)
->setHelp('Datum dat eerste ontwerp is gemaakt.<br>Bij meerdere ontwerpen kun je de datums zien bij "Bestanden".');
$fields[] = FormField::addRow();
//Ontwerpen Panel
if ($order) {
if ($order->isOntwerpNodig()) {
$fields[] = FormField::addPanel('Belettering')->collapsible()
->hideWhenCreating();
} else {
$fields[] = FormField::addPanel('Belettering')
->renderCollapsed()
->hideWhenCreating();
}
}
$fieldName = 'belettering';
$fields[$fieldName] = AssociationField::new($fieldName)
->hideWhenCreating()
->setLabel('Belettering')
->setColumns(3);
$fieldName = 'belettering_lettertype';
$fields[$fieldName] = AssociationField::new($fieldName)
->hideWhenCreating()
->setLabel('Lettertype')
->setColumns(3);
$fieldName = 'belettering_kleur';
$fields[$fieldName] = AssociationField::new($fieldName)
->hideWhenCreating()
->setLabel('Kleur')
->setColumns(3);
$fieldName = 'belettering_opmerking';
$fields[$fieldName] = TextField::new($fieldName)
->setLabel('Opmerking')
->hideWhenCreating()
->setColumns(3);
$fields[] = FormField::addPanel('')
//->renderCollapsed()
->hideWhenCreating();
$fields[] = BewerkTabField::new('_bewerk2', $this->entityManager)
->onlyOnDetail()
->setLabel('')
->setValue('Ooo');
//Orderregels
$fieldName = 'Orderregels';
$fields[$fieldName] = FormField::addTab('Orderregels')
->onlyOnDetail();
$fields[] = WorkflowOrderField::new('statusbalk4', $this->entityManager)
->onlyOnDetail()
->setValue('Orderregels')
->setLabel('Status');
$fieldName = 'orderregels';
$fields[$fieldName] = AssociationField::new('orderregels')
->setLabel('Orderregels')
->setCrudController(OrderregelSubController::class)
->setTemplatePath('admin/fields/orderregels.html.twig')
->hideWhenCreating()
->hideOnForm()
->onlyOnDetail();
//Onderdelen
$fieldName = 'Onderdelen';
$fields[$fieldName] = FormField::addTab('Onderdelen')
->onlyOnDetail();
$fields[] = WorkflowOrderField::new('statusbalk5', $this->entityManager)
->onlyOnDetail()
->setValue('Onderdelen')
->setLabel('Status');
$fieldName = 'onderdelen_nodig';
$fields[$fieldName] = BooleanField::new($fieldName)
->setlabel('Onderdelen nodig?')
->onlyOnDetail()
->setHelp('Moeten er onderdelen geleverd worden bij deze order?');
$fieldName = 'orderonderdeel';
$fields[$fieldName] = AssociationField::new('orderonderdeels')
->setLabel('Onderdelen')
->setCrudController(OrderonderdeelSubController::class)
->setTemplatePath('admin/fields/orderonderdelen.html.twig')
->hideWhenCreating()
->hideOnForm()
->onlyOnDetail();
$fields[] = FormField::addPanel('')
//->renderCollapsed()
->hideWhenCreating();
$fields[] = BewerkTabField::new('_bewerk3', $this->entityManager)
->onlyOnDetail()
->setLabel('')
->setValue('Onderdelen');
// Workflow/acties
$fields['Workflow'] = FormField::addTab('Workflow')
->setValue('workflow')
->hideWhenCreating();
$fields[] = WorkflowOrderField::new('statusbalk6', $this->entityManager)
->onlyOnDetail()
->setValue('workflow')
->setLabel('Status');
//Afhaler panel
if ($order) {
if ($order->getOrdersoort() == "Afhaler") {
$fields[] = FormField::addPanel('Afhaler')->collapsible()
->hideWhenCreating();
} else {
$fields[] = FormField::addPanel('Afhaler')
->renderCollapsed()
->hideWhenCreating();
}
}
$fieldName = 'afhaler_opdrachtgever';
$fields[$fieldName] = TextField::new($fieldName)
->setLabel("Opdrachtgever")
->hideWhenCreating();
$fieldName = 'afhaler_naam_op_steen';
$fields[$fieldName] = TextField::new($fieldName)
->setLabel("Naam op steen")
->hideWhenCreating();
$fieldName = 'afhaler_overlijdensdatum_op_steen';
$fields[$fieldName] = DateField::new($fieldName)
->setlabel("Overlijdensdatum op steen")
->setFormat('d-M-Y')
->hideWhenCreating()
->setColumns(3);
$fieldName = 'begraaf_datum';
$fields[$fieldName] = DateField::new($fieldName)
->setFormat('d-M-Y')
->hideWhenCreating()
->setHelp('Datum begrafenis van persoon die bijgezet wordt.')
->setColumns(3);
$fieldName = 'afhaal_datum';
$fields[$fieldName] = DateField::new($fieldName)
->setFormat('d-M-Y')
->hideWhenCreating()
->setColumns(6)
->setHelp('Datum dat het monument van de begraafplaats is gehaald.');
$fieldName = 'afhaler_contactdatum';
$fields[$fieldName] = DateField::new($fieldName)
->setFormat('d-M-Y')
->hideWhenCreating()
->setColumns(3)
->setHelp('Datum van contact met de familie over het afgehaalde monument.
<br><i>Als de datum is ingevuld dan verdwijnt deze afhaler uit de lijst "Afhalers > 3 weken".</i>');
$fieldName = 'afhaler_contactmedewerker';
$fields[$fieldName] = AssociationField::new($fieldName)
->hideWhenCreating()
->setColumns(3);
//Ophaler panel
if ($order) {
if ($order->getOrdersoort() == "Bestaand" || $order->isOphalenOnderdelen()) {
$fields[] = FormField::addPanel('Ophaler (Bestaand)')->collapsible()
->hideWhenCreating();
} else {
$fields[] = FormField::addPanel('Ophaler (Bestaand)')
->renderCollapsed()
->hideWhenCreating();
}
}
$fieldName = 'ophalen_onderdelen';
$fields[$fieldName] = BooleanField::new($fieldName)
->setColumns(3)
->setHelp('Hier geef je aan of er onderdelen opgehaald moeten worden van de begraafplaats');
$fieldName = 'ophaler_alleen_letterplaat';
$fields[$fieldName] = BooleanField::new($fieldName)
->setColumns(3)
->setlabel('Ophalen alleen letterplaat?');
$fieldName = 'ophaler_datum';
$fields[$fieldName] = DateField::new($fieldName)
->setFormat('d-M-Y')
->hideWhenCreating()
->setColumns(6)
->setHelp('Datum wanneer de onderdelen zijn opgehaald.');
//Vergunning Panel
if ($order) {
if ($order->isVergunningNodig()) {
$fields[] = FormField::addPanel('Vergunning')->collapsible()
->hideWhenCreating();
} else {
$fields[] = FormField::addPanel('Vergunning')
->renderCollapsed()
->hideWhenCreating();
}
}
$fieldName = 'vergunning_nodig';
$fields[$fieldName] = Field::new($fieldName);
$fieldName = 'vergunning_datum_aanvraagformulier_ingevoerd';
$fields[$fieldName] = Field::new($fieldName)
->setLabel('Aanvraagformulier ingevoerd')
->hideWhenCreating()
->setColumns(3);
$fieldName = 'vergunning_aanvraagformulier_ingevoerd_door';
$fields[$fieldName] = AssociationField::new($fieldName)
->setlabel('Aanvraagformulier ingevoerd door')
->hideWhenCreating()
->setColumns(9);
$fieldName = 'vergunning_datum_aanvraagformulier_gecontroleerd';
$fields[$fieldName] = Field::new($fieldName)
->setLabel('Aanvraagformulier gecontroleerd')
->hideWhenCreating()
->setColumns(3);
$fieldName = 'vergunning_aanvraagformulier_gecontroleerd_door';
$fields[$fieldName] = AssociationField::new($fieldName)
->setlabel('Aanvraagformulier gecontroleer door')
->hideWhenCreating()
->setColumns(6);
$fields[] = FormField::addRow();
$fieldName = 'vergunning_verzenddatum';
$fields[$fieldName] = Field::new($fieldName)
->hideWhenCreating()
->setColumns(3);
$fieldName = 'vergunning_medewerker';
$fields[$fieldName] = AssociationField::new($fieldName)
->setlabel('Vergunning verzonden door')
->hideWhenCreating()
->setColumns(9);
$fieldName = 'vergunning_ontvangstdatum';
$fields[$fieldName] = Field::new($fieldName)
->hideWhenCreating()
->setColumns(3);
//Bestellingen Panel
if ($order) {
if ($order->isBestellingNodig()) {
$fields[] = FormField::addPanel('Bestelling (Oud-> nu bij onderdelen)')->collapsible()
->hideWhenCreating()
->onlyOnDetail();
} else {
$fields[] = FormField::addPanel('Bestelling (Oud-> nu bij onderdelen)')
->renderCollapsed()
->hideWhenCreating()
->onlyOnDetail();
}
}
$fieldName = 'bestelling_nodig';
$fields[$fieldName] = Field::new($fieldName)
->onlyOnDetail();
$fieldName = 'bestelling_datum_bestelbon_ingevoerd';
$fields[$fieldName] = Field::new($fieldName)
->setLabel('Bestelbon ingevoerd')
->hideWhenCreating()
->setColumns(3)->onlyOnDetail();
$fieldName = 'bestelling_bestelbon_ingevoerd_door';
$fields[$fieldName] = AssociationField::new($fieldName)
->setlabel('Bestelbon ingevoerd door')
->hideWhenCreating()
->setColumns(9)->onlyOnDetail();
$fieldName = 'bestelling_datum_bestelbon_gecontroleerd';
$fields[$fieldName] = Field::new($fieldName)
->setLabel('Bestelbon gecontroleerd')
->hideWhenCreating()
->setColumns(3)->onlyOnDetail();
$fieldName = 'bestelling_bestelbon_gecontroleerd_door';
$fields[$fieldName] = AssociationField::new($fieldName)
->setlabel('Bestelbon gecontroleerd door')
->hideWhenCreating()
->hideOnIndex()->onlyOnDetail()
->setColumns(9);
$fieldName = 'bestelling_datum';
$fields[$fieldName] = DateField::new($fieldName)
->setFormat('d-M-Y')
->setColumns(3)->onlyOnDetail()
->hideWhenCreating();
$fieldName = 'bestelling_medewerker';
$fields[$fieldName] = AssociationField::new($fieldName)
->setlabel('Bestelling verzonden door')
->hideWhenCreating()->onlyOnDetail()
->setColumns(9);
$fieldName = 'planning_aankomst_leverancier';
$fields[$fieldName] = Field::new($fieldName)
->setColumns(3)
->hideWhenCreating()->onlyOnDetail();
$fieldName = 'bestelling_ontvangstdatum';
$fields[$fieldName] = DateField::new($fieldName)
->setFormat('d-M-Y')
->setColumns(3)->onlyOnDetail()
->hideWhenCreating();
$fieldName = 'bestelling_opmerkingen';
$fields[$fieldName] = Field::new($fieldName)
->setColumns(6)->onlyOnDetail()
->hideWhenCreating();
//Opslag panel
// if ($order) {
// if ($order->isOpslagNodig()) {
// $fields[] = FormField::addPanel('Opslag')->collapsible()
// ->hideWhenCreating();
// } else {
// $fields[] = FormField::addPanel('Opslag')
// ->renderCollapsed()
// ->hideWhenCreating();
// }
// }
// $fieldName = 'opslag_nodig';
// $fields[$fieldName] = BooleanField::new($fieldName)
// ->setColumns(3)
// ->setHelp('Hier geef je aan of er opslag nodig is voor het monument.
// <br><i>Bij een afhaler is dit altijd nodig. Meestal ook voor een bestaand monument dat opgeknapt moet worden.</i>');
// $fieldName = 'opslag_medewerker';
// $fields[$fieldName] = AssociationField::new($fieldName)
// ->hideWhenCreating()
// ->setColumns(3);
// $fieldName = 'opslag_locatie';
// $fields[$fieldName] = TextField::new($fieldName)
// ->hideWhenCreating()
// ->setColumns(3)
// ->setHelp('Locatie waar het monument is opgeslagen');
//Levering Panel
if ($order) {
if ($order->getLeveringDatum() !== null || $order->getLevermaand() !== null || $order->getLeverweek() !== null) {
$fields[] = FormField::addPanel('Levering')->collapsible()
->hideWhenCreating();
} else {
$fields[] = FormField::addPanel('Levering')
->renderCollapsed()
->hideWhenCreating();
}
}
$fields[] = FormField::addRow();
$fieldName = 'plaatsen_familie_aanwezig';
$fields[$fieldName] = BooleanField::new($fieldName)
->setLabel('Familie aanwezig bij plaatsen?')
//->setHelp('Een vooruitbestelde order wordt "geparkeerd" voor afroep. <br>-deze order is (nadat deze is vertuurd) alleen zichtbaar in de lijst "Orders vooruitbesteld"')
;
$fieldName = 'plaatsen_voor_datum';
$fields[$fieldName] = DateField::new($fieldName)
->setLabel('Plaatsen voor')
->setColumns(2)
->setFormat('MMMM y');
$fields[] = FormField::addRow();
$fieldName = 'levermaand';
$fields[$fieldName] = DateField::new($fieldName)
->setLabel('Planning Levermaand')
->setColumns(2)
->setFormat('MMMM y');
$fieldName = 'Leverweek';
$fields[$fieldName] = ChoiceField::new($fieldName)
->setChoices($this->defineOfferteOrderService->getWeeknrs())
->setColumns(1)
->hideWhenCreating();
$fields[] = FormField::addRow();
$fieldName = 'levering_datum';
$fields[$fieldName] = DateField::new($fieldName)
->setFormat('d-M-Y')
->setColumns(3)
->hideWhenCreating();
$fieldName = 'levering_datum_klant_informeren';
$fields[$fieldName] = DateField::new($fieldName)
->setFormat('d-M-Y')
//->setFormat('MMMM y')
//->renderAsChoice()
->hideWhenCreating()
->setColumns(3)
->setHelp('In te vullen door degene die de familie heeft geïnformeerd over de plaatsing van het monument');
$fieldName = 'levering_medewerker';
$fields[$fieldName] = AssociationField::new($fieldName)
->hideWhenCreating()
->setColumns(3)
->setHelp('De medewerker die de familie heeft geïnformeerd over de plaatsing van het monument.');
$fieldName = 'levering_opmerkingen';
$fields[$fieldName] = TextareaField::new($fieldName)
->hideWhenCreating()
->setColumns(6)
->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');
$fields[] = FormField::addPanel('')
//->renderCollapsed()
->hideWhenCreating();
$fields[] = BewerkTabField::new('_bewerk4', $this->entityManager)
->onlyOnDetail()
->setLabel('')
->setValue('Workflow');
//Financieel
$fields['Financieel'] = FormField::addTab('Financieel')
->hideWhenCreating();
$fields[] = WorkflowOrderField::new('statusbalk7', $this->entityManager)
->onlyOnDetail()
->setValue('Financieel')
->setLabel('Status');
$fieldName = 'prijs';
$fields[$fieldName] = MoneyField::new($fieldName)
//->setDisabled()
->setCurrency('EUR')
->setColumns(3)
//->hideWhenCreating()
;
$fieldName = 'leges';
$fields[$fieldName] = MoneyField::new($fieldName)
//->setDisabled()
->setCurrency('EUR')
->setColumns(3)
->hideWhenCreating();
$fieldName = 'provisie';
$fields[$fieldName] = MoneyField::new($fieldName)
->setCurrency('EUR')
->setColumns(3)
->hideWhenCreating();
$fieldName = 'agent';
$fields[$fieldName] = AssociationField::new($fieldName)
->autocomplete()
->hideWhenCreating();
$fieldName = 'provisie_betaald';
$fields[$fieldName] = BooleanField::new($fieldName)
->hideWhenCreating();
$fields[] = FormField::addPanel('')
//->renderCollapsed()
->hideWhenCreating();
$fields[] = BewerkTabField::new('_bewerk5', $this->entityManager)
->onlyOnDetail()
->setLabel('')
->setValue('Financieel');
// Bestanden
$fields['Bestanden'] = FormField::addTab('Bestanden')
->hideWhenCreating();;
$fields[] = WorkflowOrderField::new('statusbalk8', $this->entityManager)
->onlyOnDetail()
->setValue('Bestanden')
->setLabel('Status');
$fieldName = 'attachments';
$fields[$fieldName] = collectionField::new($fieldName)
->setFormTypeOption('by_reference', false)
//->setFormTypeOptions(['block_name'=>'custom_attachments'])
->setFormTypeOptions(['entry_type' => 'App\Form\AttachmentType'])
//->autocomplete()
//->setEntryType(AttachmentType::class)
//->onlyOnForms()
->setTemplatePath('admin/fields/attachments.html.twig')
->hideWhenCreating()
//->autocomplete()
//->hideOnForm()
;
// $fields[] = FormField::addPanel('')
// //->renderCollapsed()
// ->hideWhenCreating();
// $fields[] = BewerkTabField::new('_bewerk5', $this->entityManager)
// ->onlyOnDetail()
// ->setLabel('')
// ->setValue('Bestanden');
$fieldName = 'Reminders';
$fields[$fieldName] = FormField::addTab('Reminders')
->onlyOnDetail()
->setlabel('Reminders/Notities');
$fields[] = WorkflowOrderField::new('statusbalk9', $this->entityManager)
->onlyOnDetail()
->setValue('Reminders')
->setLabel('Status');
$fieldName = 'reminders';
$fields[$fieldName] = AssociationField::new('reminders')
->setCrudController(ReminderCrudController::class)
->setTemplatePath('admin/fields/reminders.html.twig')
->hideWhenCreating()
->hideOnForm()
->onlyOnDetail();
$fields['RecordinfoTab'] = FormField::addTab('Recordinfo')
->onlyOnDetail();
$fields['Recordinfo'] = OrderInfoRecordField::new('Recordinfo', $this->entityManager)
->onlyOnDetail()
->setValue('Test');
//last configuration changes
//setting the default tab
// if ($context->getRequest()->get("tab") === 'reminders') {
// $fields['Reminders']->setCustomOptions([FormField::OPTION_TAB_IS_ACTIVE => true]);
// }
// // of in de referrer
// $referrer = $context->getRequest()->get('referrer');
// if (null !== $referrer) {
// if (Request::create($referrer)->get('tab') === 'reminders') {
// $fields['Reminders']->setCustomOptions([FormField::OPTION_TAB_IS_ACTIVE => true]);
// }
// }
if ($tab = $context->getRequest()->get("tab")) {
$tab = ucfirst($tab);
$fields[$tab]->setCustomOptions([FormField::OPTION_TAB_IS_ACTIVE => true]);
}
// of in de referrer
$referrer = $context->getRequest()->get('referrer');
if (null !== $referrer) {
if ($tab = Request::create($referrer)->get('tab')) {
$tab = ucfirst($tab);
$fields[$tab]->setCustomOptions([FormField::OPTION_TAB_IS_ACTIVE => true]);
}
}
foreach ($fields as $fieldName => $fieldObject) {
if (!in_array($fieldName, $indexList)) {
$fields[$fieldName]->hideOnIndex();
}
// if ($fieldName == 'prijs' && $context->getRequest()->get('crudAction') == 'edit'){
// $fieldObject->setDisabled();
// }
yield $fieldObject;
}
return;
// yield TextField::new('uploadedBestand')
// ->setFormType(FileUploadType::class)
// ->onlyOnForms()
// ->addJsFiles(Asset::fromEasyAdminAssetPackage('field-image.js'), Asset::fromEasyAdminAssetPackage('field-file-upload.js'))
// ->setFormTypeOption('upload_new',
// function( ){
// $this->uploadedfileService->uploadFile($_REQUEST['entityId']);
// $this->createDbEntryService->createDbEntry( $_REQUEST['entityId']);
// })
// ->setFormTypeOption('mapped', false) ;
}
public function configureCrud(Crud $crud): Crud
{
if (isset($_GET['entityId'])) {
$entityId = $_GET['entityId'];
$recInfo = $this->defineOfferteOrderService->getStatus($entityId);
} else {
$recInfo = ['status' => 'Onbekend', 'recordnr' => 0];
}
if (!isset($recInfo['ordernummer'])) {
$recInfo['ordernummer'] = '00000000';
};
$crud->setPageTitle(CRUD::PAGE_INDEX, 'Alle Offertes/Orders');
$crud->setPageTitle(CRUD::PAGE_DETAIL, $recInfo['status'] . ' ' . $recInfo['ordernummer']);
$crud->setPageTitle(CRUD::PAGE_EDIT, $recInfo['status'] . ' ' . $recInfo['ordernummer']);
$crud->setPageTitle(CRUD::PAGE_NEW, 'Maak nieuwe offerte/order');
$crud->setDefaultSort(['ordernummer' => 'DESC']);
return $crud;
}
public function configureFilters(Filters $filters): Filters
{
return $filters
->add('vestiging')
->add('record_type')
->add('orderstatus')
->add('ordersoort')
->add('begraafplaats')
->add('levermaand')
->add('leverweek');
}
public function updateEntity(EntityManagerInterface $entityManager, $entityInstance): void
{
// setblameabels en actionsAfterUpdate
//$changeSetService = new ChangeSetService($this->entityManager, $this->security);
$changeSetService = new ChangeSetService($entityManager, $this->security);
$changeSet = $changeSetService->getChangeSet($entityInstance);
//dd($changeSet);
if (count($changeSet) > 0) {
$changeSetService->setBlameableChange($entityInstance, $changeSet);
//$changeSetService->setBlameableStatus($entityInstance, $changeSet);
}
//$this->entityManager->persist($entityInstance);
//$this->entityManager->flush();
$entityManager->persist($entityInstance);
$entityManager->flush();
// zet de levermaand altijd op de eerste dag van de maand.
if ($entityInstance->getLevermaand() !== null) {
$leverjaar = $entityInstance->getLevermaand()->format('Y');
$levermaand = $entityInstance->getLevermaand()->format('m');
$levermaandjaar = new DateTimeImmutable(sprintf('%s-%s-01 00:00:00', $leverjaar, $levermaand));
$entityInstance->setLevermaand($levermaandjaar);
}
parent::updateEntity($entityManager, $entityInstance);
// mogelijk is het een wijzinging die verdere acties nodig heeft.
// dus de changeSet doorgeven aan de betreffende class voor getRedirectResponseAfterSave
$this->changeSet = $changeSet;
//$entityManager->persist($entityInstance);
//$entityManager->flush();
}
public function createEntity(string $entityFqcn)
{
$context = $this->getContext();
$recordType = $context->getRequest()->get('recordType');
$user = $this->security->getUser();
$createdAt = new DateTimeImmutable('now');
$order = new Order();
$order->setCreatedAt($createdAt); // get depricated
$order->setIngevoerdDatum($createdAt);
$order->setIngevoerdDoor($user);
$order->setStep(1);
$order->setRecordType($recordType);
if ($recordType == 'Order') {
$order->setOrderMedewerker($user);
}
if ($recordType == 'Offerte') {
$order->setOfferteMedewerker($user);
}
//orderstatus nieuw = 1
$orderstatus = $this->entityManager->getRepository(Orderstatus::class)->findOneBy(['id' => 1]);
$order->setOrderstatus($orderstatus);
//set familieId als aangelegd vanuit Familie
$familieId = $context->getRequest()->get('familieId');
$familie = $this->entityManager->getRepository(Familie::class)->findOneBy(['id' => $familieId]);
$order->setFamilie($familie);
//aanpassingNodig
$aanpassing = 0;
$order->setAanpassingNodig($aanpassing);
// vul velden vanuit prospectToOrder
if ($context->getRequest()->get('prospectToOrder')) {
$prospectId = $context->getRequest()->get('prospectId');
$prospect = $this->entityManager->getRepository(Prospect::class)->findOneBy(['id' => $prospectId]);
$order->setVestiging($prospect->getVestiging());
$order->setOrdersoort($prospect->getOrdersoort());
$order->setfamilie($prospect->getFamilie());
$order->setOverledeneNaam($prospect->getOverledenenaam());
$order->setGebDatum($prospect->getGebDatum());
$order->setOverlDatum($prospect->getOverlDatum());
$order->setBegraafplaats($prospect->getBegraafplaats());
$order->setGrafnummer($prospect->getGrafnummer());
$order->setUitvaartvereniging($prospect->getUitvaartvereniging());
$order->setOpmerkingen($prospect->getOpmerkingen());
//aanpassingNodig
$aanpassing = 0;
$order->setAanpassingNodig($aanpassing);
}
return $order;
}
public function persistEntity(EntityManagerInterface $entityManager, $entityInstance): void
{
//ordernummer
$generatedOrdernummer = $this->defineNewOrdernummerService->getNewOrdernummer();
$entityInstance->setOrdernummer($generatedOrdernummer);
parent::persistEntity($entityManager, $entityInstance);
}
public function downloadAfhaalbon(AdminContext $adminContext, EntityManagerInterface $entityManager, AdminUrlGenerator $adminUrlGenerator)
{
//Get variables
$order = $adminContext->getEntity()->getInstance();
if (!$order instanceof Order) {
throw new \LogicException('Entity is missing or not an Order');
};
//generate document
$vars = $this->tbsTemplateVars->getOrderVars($order);
$this->OpenTBS->LoadTemplate('/home/easy_admin/templates/afhaler/afhaalbon.odt', 'already_utf8');
//$this->OpenTBS->LoadTemplate($templatePath, 'already_utf8');
$this->OpenTBS->MergeField('order', $vars);
$documentName = sprintf("afhaalbon_%s.odt", $order->getOrdernummer());
$this->OpenTBS->Show(1, $documentName);
//now return response same page.
$targetUrl = $adminUrlGenerator
->setController(self::class)
->setAction(Crud::PAGE_DETAIL)
->setEntityId($order->getId())
->generateUrl();
return $this->redirect($targetUrl);
}
public function downloadKlantBrief(AdminContext $adminContext, EntityManagerInterface $entityManager, AdminUrlGenerator $adminUrlGenerator)
{
//Get variables
$order = $adminContext->getEntity()->getInstance();
if (!$order instanceof Order) {
throw new \LogicException('Entity is missing or not an Order');
};
$templatePath = $adminContext->getRequest()->get('templatePath');
$documentName = $adminContext->getRequest()->get('documentName');
//generate document
$vars = $this->tbsTemplateVars->getOrderVars($order);
//dd($vars);
$documentName = sprintf("%s_%s.odt", $documentName, $order->getOrdernummer());
$this->OpenTBS->LoadTemplate($templatePath, 'already_utf8');
$this->OpenTBS->MergeField('record', $vars);
$this->OpenTBS->MergeBlock('regel', $vars['orderregels']);
$this->OpenTBS->MergeBlock('slotregel', $vars['slotregels']);
$this->OpenTBS->Show(1, $documentName);
//now return response same page.
$targetUrl = $adminUrlGenerator
->setController(self::class)
->setAction(Crud::PAGE_DETAIL)
->setEntityId($order->getId())
->generateUrl();
return $this->redirect($targetUrl);
}
protected function getRedirectResponseAfterSave(AdminContext $context, string $action): RedirectResponse
{
$submitButtonName = $context->getRequest()->request->all()['ea']['newForm']['btn'];
if (Action::SAVE_AND_CONTINUE === $submitButtonName) {
$url = $this->container->get(AdminUrlGenerator::class)
->setAction(Action::EDIT)
->setEntityId($context->getEntity()->getPrimaryKeyValue())
->generateUrl();
return $this->redirect($url);
}
if (Action::SAVE_AND_RETURN === $submitButtonName) {
$controller = get_class($this);
if ($this->controllerFqcnAfterSetStatus != '') {
$controller = $this->controllerFqcnAfterSetStatus;
}
$entityId = $context->getEntity()->getPrimaryKeyValue();
if ($this->entityIdAfterSetStatus != 0) {
$entityId = $this->entityIdAfterSetStatus;
}
if (isset($this->tabAfterSetStatus)) {
if ($this->tabAfterSetStatus) {
$tab = $this->tabAfterSetStatus;
}
}
$action = Action::DETAIL;
if ($this->actionAfterSetStatus != '') {
$action = $this->actionAfterSetStatus;
}
//dd($this);
$urlGenerator = $this->container->get(AdminUrlGenerator::class)
->setController($controller)
->setEntityId($entityId)
->setAction($action)
->set('entityIdAfterSetStatus', $this->entityIdAfterSetStatus)
->set('actionAfterSetStatus', $this->actionAfterSetStatus)
->set('controllerFqcnAfterSetStatus', $this->controllerFqcnAfterSetStatus);
foreach ($this->httpVars as $httpVar => $value) {
$urlGenerator
->set($httpVar, $value);
}
$urlGenerator
->set('partialFields', $this->partialFields);
$url = $urlGenerator->generateUrl();
return $this->redirect($url);
}
return $this->redirectToRoute($context->getDashboardRouteName());
}
public function actionBewerkStep()
{
//we zetten de referrers van de verschillende controllers in de stappen.
$urlStep01 = $this->adminUrlGenerator
->setAction(Action::EDIT)
->setEntityId($this->getContext()->getEntity()->getPrimaryKeyValue())
->setController(OrderPartialControllerStep01::class)
->generateUrl();
$urlStep02 = $this->adminUrlGenerator
->setAction(Action::EDIT)
->setEntityId($this->getContext()->getEntity()->getPrimaryKeyValue())
->setController(OrderPartialControllerStep02::class)
->generateUrl();
$urlStep03 = $this->adminUrlGenerator
->setAction(Action::EDIT)
->setEntityId($this->getContext()->getEntity()->getPrimaryKeyValue())
->setController(OrderPartialControllerStep03::class)
->generateUrl();
$urlStep04 = $this->adminUrlGenerator
->setAction(Action::EDIT)
->setEntityId($this->getContext()->getEntity()->getPrimaryKeyValue())
->setController(OrderPartialControllerStep04::class)
->generateUrl();
$adminRefferer = AdminReferrer::new($this->getContext())
->setReferrer(OrderPartialControllerStep02::class, $urlStep01)
->setReferrer(OrderPartialControllerStep03::class, $urlStep02)
->setReferrer(OrderPartialControllerStep04::class, $urlStep03)
->setReferrer(OrderPartialControllerStep05::class, $urlStep04);
//dd($this->getContext()->getRequest()->getSession()->get('referrer'));
$step = $this->getContext()->getEntity()->getInstance()->getStep();
switch ($step) {
case 0:
$controller = OrderPartialControllerStep01::class;
$action = Action::EDIT;
break;
case 1:
$controller = OrderPartialControllerStep02::class;
$action = Action::EDIT;
break;
case 2:
$controller = OrderPartialControllerStep03::class;
$action = Action::EDIT;
break;
case 3:
$controller = OrderPartialControllerStep04::class;
$action = Action::EDIT;
break;
case 4:
$controller = OrderPartialControllerStep05::class;
$action = Action::DETAIL;
break;
case 5:
dd('Dit zou niet moeten kunnen, de actielink had verborgen moeten zijn');
case null:
dd('Dit zou niet moeten kunnen, de actielink had verborgen moeten zijn');
}
$meldingtekst = 'Het record is nog niet volledig ingevoerd, <br>
ga hieronder verder met stap ' . $step + 1;
$flash = sprintf('<div class="text-center "><h2>%s</h2></div>', $meldingtekst);
$this->addFlash('warning', $flash);
$this->adminUrlGenerator
->setAction($action)
->setEntityId($this->getContext()->getEntity()->getPrimaryKeyValue())
->setController($controller)
;
$url = $this->adminUrlGenerator->generateUrl();
//dd($url);
return $this->redirect($url);
}
public function setStatus(AdminContext $context)
{
$this->entityIdAfterSetStatus = $this->getContext()->getEntity()->getPrimaryKeyValue();
$status = ($this->getContext()->getRequest()->get('status'));
$orderstatus = $this->entityManager->getRepository(Orderstatus::class)->findOneBy(['status' => $status]);
$order = $this->getContext()->getEntity()->getInstance();
$order->setOrderstatus($orderstatus);
// setblameables en actionsAfterUpdate
$changeSetService = new ChangeSetService($this->entityManager, $this->security);
$changeSet = $changeSetService->getChangeSet($order);
//dd($changeSet);
if (count($changeSet) > 0) {
$changeSetService->setBlameableChange($order, $changeSet);
$changeSetService->setBlameableStatus($order, $changeSet);
$this->entityManager->persist($order);
$this->entityManager->flush();
//check of er gewenste velden niet zijn ingevuld. OrderpartialControllerField::checkFields
//$status = $changeSet['orderstatus']['new'];
$status = $order->getOrderstatus();
//Eerst algemene orderChecker.
$orderChecker = new Orderchecker($order);
$warnings = $orderChecker->getStatusWarnings($status);
//dd($warnings);
foreach ($warnings as $melding) {
$flash = sprintf('<div class="text-center "><h2>%s!</h2></div>', $melding);
$this->addFlash('warning', $flash);
}
//Nu checken op niet ingevulde velden of lijsten.
$this->partialFields = OrderPartialControllerDynamicFields::checkFields($order, $status);
if (count($this->partialFields) > 0) {
foreach ($this->partialFields as $field => $melding) {
$flash = sprintf('<div class="text-center "><h2>%s!</h2></div>', $melding);
$this->addFlash('warning', $flash);
}
// Referrer nwe stijl
// Plaats de refferer voor de volgende controller.
$referrer = $this->getContext()->getRequest()->getRequestUri();
//we halen de tab uit de referrer want we willen terugkomen in het overzichtscherm van de order
//en de crudAction moet detail worden ipv setStatus
$adminRefferer = AdminReferrer::new($context);
$adminRefferer->setReferrer(OrderPartialControllerDynamicFields::class)
->removeParameters(OrderPartialControllerDynamicFields::class, ['tab', 'crudAction'])
->addParameters(OrderPartialControllerDynamicFields::class, ['crudAction' => 'detail'])
;
//zetten ook alvast voor de Listst
$adminRefferer->setReferrer(OrderPartialControllerDynamicLists::class)
->removeParameters(OrderPartialControllerDynamicLists::class, ['tab', 'crudAction'])
->addParameters(OrderPartialControllerDynamicLists::class, ['crudAction' => 'detail']);
//We sturen door naar OrderpartialControllerField::EDIT ??
$url = $this->adminUrlGenerator
->setController(OrderPartialControllerDynamicFields::class)
->setAction(Action::EDIT)
->setEntityId($order->getId())
->set('partialFields', $this->partialFields)
->generateUrl();
return $this->redirect($url);
}
//controleren op niet ingevulde lists
$this->partialFields = OrderPartialControllerDynamicLists::checkLists($order, $status);
if (count($this->partialFields) > 0) {
foreach ($this->partialFields as $field => $melding) {
$flash = sprintf('<div class="text-center "><h2>%s!</h2></div>', $melding);
$this->addFlash('warning', $flash);
}
// Referrer nwe stijl
// Plaats de refferer voor de volgende controller.
$adminRefferer = AdminReferrer::new($context);
$adminRefferer->setReferrer(OrderPartialControllerDynamicLists::class)
->removeParameters(OrderPartialControllerDynamicLists::class, ['tab', 'crudAction'])
->addParameters(OrderPartialControllerDynamicLists::class, ['crudAction' => 'detail'])
;
// $referrer = $this->getContext()->getRequest()->getRequestUri();
// $this->setReferrer(OrderPartialControllerDynamicLists::class, $referrer);
// $this->removeParametersReferrer(OrderPartialControllerDynamicLists::class,['tab','crudAction']);
// $this->addToReferrer(OrderPartialControllerDynamicLists::class, 'crudAction', 'detail');
//We sturen door naar OrderpartialControllerLists::EDIT ??
$url = $this->adminUrlGenerator
->setController(OrderPartialControllerDynamicLists::class)
->setAction(Action::DETAIL)
->setEntityId($order->getId())
->set('partialFields', $this->partialFields)
->generateUrl();
return $this->redirect($url);
}
//Geen niet ingevulde velden en lijsten, dus terug naar het record.
$url = $this->adminUrlGenerator
->setController(OrderCrudController::class)
->setAction(Action::DETAIL)
->setEntityId($order->getId())
->unset('tab')
->generateUrl();
//dd($url);
return $this->redirect($url);
}
dd('Denk niet dat we hieronder komen');
$url = $this->adminUrlGenerator
//->setAction(Action::DETAIL)
//->setEntityId($this->getContext()->getEntity()->getPrimaryKeyValue())
->setController($this->controllerFqcnAfterSetStatus)
->setAction($this->actionAfterSetStatus)
->setEntityId($this->entityIdAfterSetStatus)
//->setReferrer($this->getContext()->getReferrer())
;
foreach ($this->httpVars as $httpVar => $value) {
$this->adminUrlGenerator
->set($httpVar, $value);
};
//$partialFields = [0,1];
$this->adminUrlGenerator
->set('partialFields', $this->partialFields);
$url = $this->adminUrlGenerator->generateUrl();
//dd($url);
return $this->redirect($url);
}
}