<?php
namespace App\Controller;
use App\Entity\Category;
use App\Entity\ClientOrder;
use App\Entity\Doctor;
use App\Entity\Exam;
use App\Entity\ExamParam;
use App\Entity\ExamParamVariant;
use App\Entity\ExamRequest;
use App\Entity\ExamRequestItem;
use App\Entity\ExamRequestItemParam;
use App\Entity\ExamType;
use App\Entity\InsuranceCompany;
use App\Entity\MedicalPrescription;
use App\Entity\Order;
use App\Entity\Patient;
use App\Entity\PaymentAdvance;
use App\Entity\Product;
use App\Entity\ProductCalendarExpiration;
use App\Entity\ProductOutRequest;
use App\Entity\ProductStore;
use App\Entity\Provider;
use App\Entity\Role;
use App\Entity\Save;
use App\Entity\Statut;
use App\Entity\Store;
use App\Entity\System;
use App\Entity\User;
use App\Entity\UserType;
use App\Repository\ProductOutRepository;
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use App\Twig\AppExtension;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use function Symfony\Component\String\b;
class WebController extends AbstractController implements LogginInterfaceController
{
private $mycontainer;
private $token;
private $locale;
private $tokenUser;
private $session;
private $extension;
private $currentUser;
private $currentUserRoles;
private $em;
/**
* WebController constructor.
* @param ContainerInterface $c
* @param SessionInterface $s
* @param EntityManagerInterface $em
*/
public function __construct(ContainerInterface $c,SessionInterface $s,EntityManagerInterface $em)
{
$this->currentUser = null;
$this->currentUserRoles = [];
$this->extension = new AppExtension($c);
$this->session = $s;
$this->mycontainer = $c;
$this->locale="fr";
$this->em=$em;
$this->mycontainer->get('translator')->setLocale($this->locale);
$lang = $this->mycontainer->get("request_stack")->getCurrentRequest()->cookies->get("lang");
if(in_array($lang,["fr","en"])) {
$this->mycontainer->get('translator')->setLocale($lang);
$this->locale = $lang;
}
$token = $this->mycontainer->get("request_stack")->getCurrentRequest()->cookies->get("token");
if($token === null || $token === "null") {
$this->tokenUser = null;
}
else{
$this->connected = true;
$this->token =$token;
$tokenPayload=null;
if($this->token !== null)
{
$tokenParts = explode(".", $this->token);
//$tokenHeader = base64_decode($tokenParts[0]);
$tokenPayload = base64_decode($tokenParts[1]);
$this->tokenUser= json_decode($tokenPayload);
}
}
$tokenUser = $this->mycontainer->get('security.token_storage')->getToken();
if($tokenUser === null){
$this->currentUser = "anon.";
}
else{
$this->currentUser = $tokenUser->getUser();
}
$tab=[];
if($this->currentUser !== "anon.")
{
if(in_array($this->currentUser->getRoles()[0],['SADMIN','ADMIN']))
{
$roles = $this->em->getRepository(Role::class)->findBy(array("isActive"=>true));
foreach ($roles as $r)
{
$tab[]=$r->getCode();
}
}
else
{
$roles1=$this->currentUser->getUserRoles();
foreach ($roles1 as $r)
{
if(!in_array($r->getCode(),$tab)) $tab[]=$r->getCode();
}
}
}
$this->currentUserRoles = $tab;
$res = $this->mycontainer->get("user_manager")->getSystemInfo();
$this->mycontainer->get('session')->set('AppData',$res["data"]);
$this->mycontainer->get('session')->set('roles',$tab);
$stores = $this->em->getRepository(Store::class)->findBy(['isActive'=>true]);
if(count($stores)==0){
$store = new Store();
$store->setTitle('DEFAULT');
$this->em->persist($store);
$this->em->flush();
$stores=[$store];
}
$sts = [];
foreach ($stores as $s){
$sts[]=['name'=>$s->getTitle(),'slug'=>$s->getSlug()];
}
$this->mycontainer->get('session')->set('stores',$sts);
}
private function testRole($role): bool
{
$test = false;
$roles1=$this->currentUserRoles;
foreach ($roles1 as $r)
{
if($r == $role) $test=true;
}
if(gettype($this->currentUser)==="object"){
if(in_array($this->currentUser->getRoles()[0],["SADMIN","ADMIN"]))$test=true;
}
return $test;
}
private function ageCalculator(\DateTime $born){
//set current date
$now = new \DateTime;
//get differ between born date and current date
$diff = $now->diff($born);
$total_days = $diff->days;
$total_week = ($diff->days / 7);
/*if($diff->days % 7 > 0){
$total_week = $total_week +1;
}*/
$total_months = ($diff->y * 12) + $diff->m;
$total_years = $diff->y;
return ['year'=>$total_years,'month'=>$total_months,'week'=>$total_week,'day'=>$total_days];
}
public function home(Request $request)
{
if($this->currentUser !== 'anon.') return $this->redirectToRoute('web_app_dashboard');
$res = $this->mycontainer->get("user_manager")->getSystemInfo();
return $this->render('login.html.twig',["system"=>$res["data"]]);
}
public function dashboard(Request $request)
{
if($this->currentUser === 'anon.'){
return $this->redirectToRoute('web_logout');
}
$save = $this->em->getRepository(Save::class)->findBy(array("isActive"=>true),array("id"=>"DESC"),1,0);
$date=$this->mycontainer->get('translator')->trans("no_save");
if(count($save)>0)
{
$date = $save[0]->getDate()->format("d/m/Y h:i:s");
}
$simple=0;
$activeProduct = $this->em->getRepository(Product::class)->getTotalActive();
$totalProduct = $this->em->getRepository(Product::class)->getTotal();;
$ProductOutRequest = $this->em->getRepository(ProductOutRequest::class)->totalNb();
$ProductStockExceed = $this->em->getRepository(Product::class)->totalProductStockExceed();
$response = $this->render('dashboard.html.twig',
["dossiers"=>$simple,
"active_product"=>$activeProduct[0]['nb'],
"total_product"=>$totalProduct[0]['nb'],
"product_out_request"=>$ProductOutRequest[0]['nb'],
"product_stock_exceed"=>$ProductStockExceed[0]['nb']]);
return $response;
}
public function systeme(Request $request)
{
if($this->testRole('M_SYS')==false) return $this->redirectToRoute('web_app_dashboard');
$res = $this->mycontainer->get("user_manager")->getSystemInfo();
return $this->render('systeme.html.twig',["system"=>$res["data"]]);
}
public function utilisateur(Request $request)
{
if($this->testRole('M_USER')==false) return $this->redirectToRoute('web_app_dashboard');
$userTypes = $this->em->getRepository(UserType::class)->findExceptSuperAdmin();
$users = $this->em->getRepository(User::class)->loadAllUsers(10000,0);
$roles = $this->em->getRepository(Role::class)->findBy(array("isActive"=>true),array("id"=>"ASC"));
foreach ($roles as $r){
$r->setTranslatableLocale($this->locale);
$this->em->refresh($r);
}
foreach ($userTypes as $r){
$r->setTranslatableLocale($this->locale);
$this->em->refresh($r);
}
return $this->render('utilisateur.html.twig',["user_types"=>$userTypes,"users"=>$users,'roles'=>$roles]);
}
public function sauvegarde(Request $request)
{
if($this->testRole('AD_S1')==false) return $this->redirectToRoute('web_app_dashboard');
$all = $this->em->getRepository(Save::class)->findBy(array("isActive"=>true),array("id"=>"DESC"));
$todaydb = $this->em->getRepository(Save::class)->findForTodayDb();
$todayar = $this->em->getRepository(Save::class)->findForTodayArchive();
$today=[];
foreach ($todaydb as $t)
{
$today[]=$t;
}
foreach ($todayar as $t)
{
$today[]=$t;
}
return $this->render('sauvegarde.html.twig',["all"=>$all,"today"=>$today]);
}
public function profile(Request $request)
{
// $this->addFlash('notice',$this->mycontainer->get('translator')->trans("eeeeee"));
return $this->render('profile.html.twig');
}
public function support(Request $request)
{
$news = $this->em->getRepository(News::class)->findBy(array("isActive"=>true,"status"=>true));
return $this->render('support.html.twig',["faq"=>$news]);
}
public function upload(Request $request)
{
$file = $request->files;
return new Response();
}
public function readFile(Request $request,$name)
{
if($this->currentUser === 'anon.') return $this->redirectToRoute('api_home');
$fu = $this->mycontainer->get('upload_service');
$res = $fu->getFileBinary($name);
if($res['error']==true) return new Response('file not found '.$name,401);
if(!in_array($name,['man.png', 'woman.png'])){
$original = $this->mycontainer->get('upload_service')->getFile($name);
if($original !== null){
$resp = new BinaryFileResponse($res["data"]);
$resp->setContentDisposition(
ResponseHeaderBag::DISPOSITION_ATTACHMENT,''
);
return $resp;
}
}
return new BinaryFileResponse($res["data"]);
}
public function readFileOld(Request $request,$name)
{
if($this->currentUser === 'anon.') return $this->redirectToRoute('api_home');
$fu = $this->mycontainer->get('upload_service');
$res = $fu->getFileBinary($name);
if($res['error']==true) return new Response('file not found '.$res['data'],401);
if(!in_array($name,['man.png', 'woman.png'])){
$original = $this->mycontainer->get('user_manager')->getFile(['name'=>$name]);
if($original !== null && !in_array(explode('/',$original['type'])[0],['image','pdf'])){
$resp = new BinaryFileResponse($res["data"]);
$resp->setContentDisposition(
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
$original['nom']
);
return $resp;
}
}
// return new BinaryFileResponse($res["data"]);
}
public function showNotif(Request $request,$id)
{
$status = $this->em->getRepository(Statut::class)->findOneBy(array('id' =>$id, 'user' =>$this->currentUser,'isActive'=>true));
if($status === null) return $this->redirectToRoute("web_app_dashboard");
if($status->getStatut()==0)
{
$status->setStatut(1);
$this->em->persist($status);
$this->em->flush();
}
/*if(in_array($status->getNotification()->getCode(),[30,31,33,35,36,37,38,39])){
return $this->redirectToRoute("web_my_mail");
}*/
switch ($status->getNotification()->getCode())
{
case 30:
return $this->redirectToRoute("web_app_order");
case 40:
return $this->redirectToRoute("web_app_product_store_request",['slug'=>$status->getNotification()->getProductOutRequest()->getStore()->getSlug()]);
case 50:
return $this->redirectToRoute("web_app_exam_request_result");
case 60:
return $this->redirectToRoute("web_app_product");
case 70:
return $this->redirectToRoute("web_app_exam_item");
default:
return $this->redirectToRoute("web_app_dashboard");
}
}
public function allUserExecptAdmin(Request $request)
{
//$data = $this->postData;
$res = $this->container->get("user_manager")->allUserExecptAdmin([]);
if($res["statut"]==false)
{
$this->response->setStatut(401);
$this->response->setContent($res);
return $this->response->getResponse();
}
$this->response->setStatut(201);
$this->response->setContent($res);
return $this->response->getResponse();
}
public function readFileUserSignature(Request $request,$name)
{
if($this->currentUser === 'anon.') return $this->redirectToRoute('api_home');
$fu = $this->mycontainer->get('upload_service');
$res = $fu->getFileBinaryUserSignature($name);
if($res['error']==true) return new Response('file not found',404);
return new BinaryFileResponse($res["data"]);
}
/** NEW* **/
public function productCategory(Request $request)
{
if($this->testRole('M_PRODUCT_CAT')==false) return $this->redirectToRoute('web_app_dashboard');
$data = $this->em->getRepository(Category::class)->findBy(['isActive'=>true],['title'=>'ASC']);
foreach ($data as $r){
$r->setTranslatableLocale($this->locale);
$this->em->refresh($r);
}
return $this->render('product_category.html.twig',["data_list"=>$data]);
}
public function wareHouse(Request $request)
{
if($this->testRole('M_WAREHOUSE')==false) return $this->redirectToRoute('web_app_dashboard');
$data = $this->em->getRepository(Store::class)->findBy(['isActive'=>true],['title'=>'ASC']);
return $this->render('warehouse.html.twig',["data_list"=>$data]);
}
public function product(Request $request)
{
if($this->testRole('M_PRODUCT')==false) return $this->redirectToRoute('web_app_dashboard');
$data = $this->em->getRepository(Product::class)->findBy(['isActive'=>true],['title'=>'ASC']);
$categories = $this->em->getRepository(Category::class)->findBy(['isActive'=>true],['title'=>'ASC']);
$stores = $this->em->getRepository(Store::class)->findBy(['isActive'=>true],['title'=>'ASC']);
$dateFrom = new \DateTime();
$dateTo = new \DateTime();
$sys = $this->em->getRepository(System::class)->findOneBy([]);
if($sys !== null){
$dateTo->add(new \DateInterval('P'.$sys->getNbDayAlertProductExpiration().'D'));
}
$pE = $this->em->getRepository(ProductCalendarExpiration::class)->findExpiredBeforeNbDay($dateFrom->format("Y-m-d")." 00:00:00",$dateTo->format("Y-m-d")." 23:59:59");
foreach ($categories as $r){
$r->setTranslatableLocale($this->locale);
$this->em->refresh($r);
}
foreach ($data as $r){
$r->setTranslatableLocale($this->locale);
$this->em->refresh($r);
}
return $this->render('product.html.twig',["data_list"=>$data,"data_list2"=>$pE,'categories'=>$categories,'stores'=>$stores,'code'=>$this->mycontainer->get('user_manager')->generateReference('PR')]);
}
public function provider(Request $request)
{
if($this->testRole('M_SUPPLIER')==false) return $this->redirectToRoute('web_app_dashboard');
$data = $this->em->getRepository(Provider::class)->findBy(['isActive'=>true],['title'=>'ASC']);
return $this->render('provider.html.twig',["data_list"=>$data]);
}
public function patient(Request $request)
{
if($this->testRole('M_PAT')==false) return $this->redirectToRoute('web_app_dashboard');
$data = $this->em->getRepository(Patient::class)->findBy(['isActive'=>true],['name'=>'ASC','surname'=>'ASC']);
return $this->render('patient.html.twig',["data_list"=>$data]);
}
public function patientProfile(Request $request, $slug)
{
$referer = $request->headers->get('referer');
$test1 = $this->testRole('M_EXAM_REQUEST');
$test2 = $this->testRole('M_EXAM_RESULT');
$test3 = $this->testRole('M_PAT');
if($test1==false && $test2==false && $test3==false) return $this->redirectToRoute('web_app_dashboard');
$patient = $this->em->getRepository(Patient::class)->findOneBy(['slug'=>$slug]);
if($patient === null){
$this->mycontainer->get('session')->getFlashBag()->add('notice','Patient '.$this->mycontainer->get('translator')->trans("not_found"));
return $this->redirect($referer ?? '/');
}
$oldExams = $this->em->getRepository(ExamRequest::class)->findBy(['patient'=>$patient,'isActive'=>true]);
return $this->render('patient_profile.html.twig',["patient"=>$patient,"exam_requests"=>$oldExams]);
}
public function productOrder(Request $request)
{
if($this->testRole('M_ORDER')==false) return $this->redirectToRoute('web_app_dashboard');
$data = $this->em->getRepository(Order::class)->findBy(['isActive'=>true],['dateOrder'=>'DESC']);
$products = $this->em->getRepository(Product::class)->findBy(['isActive'=>true],['title'=>'DESC']);
$providers = $this->em->getRepository(Provider::class)->findBy(['isActive'=>true],['title'=>'ASC']);
foreach ($products as $r){
$r->setTranslatableLocale($this->locale);
$this->em->refresh($r);
}
return $this->render('order.html.twig',["data_list"=>$data,'products'=>$products,'providers'=>$providers,'code'=>$this->mycontainer->get('user_manager')->generateReference('OR')]);
}
public function displayOrder(Request $request, $slug){
$test2 = $this->testRole('M_ORDER');
$test3 = $this->testRole('M_BILL');
if($test2==false && $test3 ==false) return $this->redirectToRoute('web_app_dashboard');
$order = $this->em->getRepository(Order::class)->findOneBy(['reference'=>$slug]);
if($order === null){
$this->mycontainer->get('session')->getFlashBag()->add('notice','Order '.$this->mycontainer->get('translator')->trans("not_found"));
return $this->redirectToRoute('web_app_order');
}
foreach ($order->getOrderItems() as $item){
$item->getProduct()->setTranslatableLocale($this->locale);
$this->em->refresh( $item->getProduct());
}
$system = $this->em->getRepository(System::class)->findOneBy([]);
return $this->render('display_order.html.twig',["order"=>$order,'system'=>$system]);
}
public function productRequest(Request $request, $slug)
{
if($this->testRole('M_BORROW')==false) return $this->redirectToRoute('web_app_dashboard');
$store = $this->em->getRepository(Store::class)->findOneBy(['slug'=>$slug]);
if($store === null){
$this->mycontainer->get('session')->getFlashBag()->add('notice','Store '.$this->mycontainer->get('translator')->trans("not_found"));
return $this->redirectToRoute('web_app_product_request_main');
}
$data = $this->em->getRepository(ProductOutRequest::class)->findBy(['isActive'=>true,'store'=>$store],['dateRequest'=>'DESC']);
$products = $this->em->getRepository(ProductStore::class)->findByStore($store->getId());
foreach ($products as $r){
$r->getProduct()->setTranslatableLocale($this->locale);
$this->em->refresh($r->getProduct());
}
return $this->render('product_request.html.twig',["data_list"=>$data,'products'=>$products,'store'=>$store,'code'=>$this->mycontainer->get('user_manager')->generateReference('PR_R')]);
}
public function productStoreList(Request $request,$slug)
{
if($this->testRole('M_WAREHOUSE')==false) return $this->redirectToRoute('web_app_dashboard');
$store = $this->em->getRepository(Store::class)->findOneBy(['slug'=>$slug]);
if($store === null){
$this->mycontainer->get('session')->getFlashBag()->add('notice','Store '.$this->mycontainer->get('translator')->trans("not_found"));
return $this->redirectToRoute('web_app_warehouse');
}
$stores = $this->em->getRepository(Store::class)->findExcept($store->getId());
$products = $this->em->getRepository(ProductStore::class)->findBy(['isActive'=>true,'store'=>$store],['id'=>'ASC']);
foreach ($products as $p){
$p->getProduct()->setTranslatableLocale($this->locale);
$this->em->refresh($p->getProduct());
}
return $this->render('warehouse_product.html.twig',["data_list"=>$products,'store'=>$store,'stores'=>$stores]);
}
public function productRequestMain(Request $request){
if($this->testRole('M_BORROW')==false) return $this->redirectToRoute('web_app_dashboard');
$data = $this->em->getRepository(Store::class)->findBy(['isActive'=>true],['title'=>'ASC']);
return $this->render('product_request_main.html.twig',["data_list"=>$data]);
}
public function displayRequest(Request $request, $slug){
if($this->testRole('M_BORROW')==false) return $this->redirectToRoute('web_app_dashboard');
$order = $this->em->getRepository(ProductOutRequest::class)->findOneBy(['slug'=>$slug]);
if($order === null){
$this->mycontainer->get('session')->getFlashBag()->add('notice','Request '.$this->mycontainer->get('translator')->trans("not_found"));
return $this->redirectToRoute('web_app_product_request_main');
}
foreach ($order->getProductOuts() as $item){
$item->getProductStore()->getProduct()->setTranslatableLocale($this->locale);
$this->em->refresh( $item->getProductStore()->getProduct());
}
$system = $this->em->getRepository(System::class)->findOneBy([]);
return $this->render('display_request.html.twig',["order"=>$order,'system'=>$system]);
}
public function bill(Request $request)
{
if($this->testRole('M_BILL')==false) return $this->redirectToRoute('web_app_dashboard');
$referer = $request->headers->get('referer');
$params = $request->query->all();
$tabKeys = ['start_date'=>'','end_date'=>'','patient'=>'','provider'=>'','type'=>''];
$test = false;
foreach ($tabKeys as $k=>$val){
if(array_key_exists($k,$params)){
$test=true;
$tabKeys[$k]=$params[$k];
}
}
if($test === false){
$data = $this->em->getRepository(ClientOrder::class)->findBy(['isActive'=>true],['dateOrder'=>'DESC']);
$data2 = $this->em->getRepository(Order::class)->findBy(['isActive'=>true],['dateOrder'=>'DESC']);
}
else{
if(strlen($tabKeys['start_date'])>0){
try {
$start = \DateTime::createFromFormat('d/m/Y',$tabKeys["start_date"])->format("Y-m-d")." 00:00:00";
$tabKeys['start_date']=$start;
}
catch (\Exception $e)
{
$this->mycontainer->get('session')->getFlashBag()->add('notice','incorrect date');
return $this->redirect($referer ?? '/');
}
}
if(strlen($tabKeys['end_date'])>0){
try {
$start = \DateTime::createFromFormat('d/m/Y',$tabKeys["end_date"])->format("Y-m-d")." 23:59:59";
$tabKeys['end_date']=$start;
}
catch (\Exception $e)
{
$this->mycontainer->get('session')->getFlashBag()->add('notice','incorrect date');
return $this->redirect($referer ?? '/');
}
}
if($tabKeys['type']==0){
$data = $this->em->getRepository(ClientOrder::class)->findFilterBill($tabKeys);
$data2=[];
}else{
$data2 = $this->em->getRepository(Order::class)->findFilterBill($tabKeys);
$data=[];
}
}
$dateInt = 2;
$sys = $this->em->getRepository(System::class)->findOneBy([]);
if($sys !== null){
$dateInt = $sys->getNbDayAlertBill();
}
return $this->render('bill.html.twig',["data_list"=>$data,'data_list2'=>$data2,'date_int'=>$dateInt]);
}
public function statistiques(Request $request)
{
if($this->testRole('M_STA')==false) return $this->redirectToRoute('web_app_dashboard');
return $this->render('statistiques.html.twig',['date'=>(new \DateTime())->format('d/m/Y')]);
}
public function journal(Request $request)
{
if($this->testRole('M_LOG')==false) return $this->redirectToRoute('web_app_dashboard');
//$this->mycontainer->get('session')->getFlashBag()->add('notice','hello');
return $this->render('journal.html.twig');
}
public function insurance(Request $request)
{
if($this->testRole('M_PAT')==false) return $this->redirectToRoute('web_app_dashboard');
$data = $this->em->getRepository(InsuranceCompany::class)->findBy(['isActive'=>true],['name'=>'ASC']);
return $this->render('insurance.html.twig',["data_list"=>$data]);
}
public function medicalPrescription(Request $request)
{
if($this->testRole('M_PAT')==false) return $this->redirectToRoute('web_app_dashboard');
$data = $this->em->getRepository(MedicalPrescription::class)->findBy(['isActive'=>true],['date'=>'DESC']);
return $this->render('medical_prescription.html.twig',["data_list"=>$data,'code'=>$this->mycontainer->get('user_manager')->generateReference('ORD')]);
}
public function clientOrder(Request $request, $store_slug)
{
if($this->testRole('M_EXAM_REQUEST')==false) return $this->redirectToRoute('web_app_dashboard');
$store = $this->em->getRepository(Store::class)->findOneBy(['slug'=>$store_slug]);
if($store === null) return $this->redirectToRoute('web_app_dashboard');
$data = $this->em->getRepository(ClientOrder::class)->findBy(['isActive'=>true,'store'=>$store],['date'=>'DESC']);
$productsStore = $this->em->getRepository(ProductStore::class)->findBy(['store'=>$store]);
$products = [];
foreach ($productsStore as $pr){
$p = $pr->getProduct();
$p->setQuantity($pr->getQuantity());
$p->setProductStoreId($pr->getId());
$products[]=$p;
}
foreach ($products as $r){
$r->setTranslatableLocale($this->locale);
$this->em->refresh($r);
}
$toDayAmount = $this->em->getRepository(ClientOrder::class)->findToDayUserPayment($this->currentUser->getId());
return $this->render('client_order.html.twig',['today_payment'=>$toDayAmount[0]['amount'],"store"=>$store, "data_list"=>$data,'products'=>$products,'code'=>$this->mycontainer->get('user_manager')->generateReference('COR')]);
}
public function displayClientOrder(Request $request, $slug){
$order = $this->em->getRepository(ClientOrder::class)->findOneBy(['reference'=>$slug]);
if($order === null){
$this->mycontainer->get('session')->getFlashBag()->add('notice','Order '.$this->mycontainer->get('translator')->trans("not_found"));
return $this->redirectToRoute('web_app_dashboard');
}
foreach ($order->getSaleItems() as $item){
$item->getProduct()->setTranslatableLocale($this->locale);
$this->em->refresh( $item->getProduct());
}
$system = $this->em->getRepository(System::class)->findOneBy([]);
return $this->render('display_client_order.html.twig',["order"=>$order,'system'=>$system]);
}
}