<?php
namespace App\Controller;
use App\Entity\DepotDossier;
use App\Entity\Notifications;
use App\Entity\CommentairesControlle;
use App\Entity\Planning;
use App\Form\DepotDossierType;
use App\Repository\DepotDossierRepository;
use App\Repository\DealRepository;
use App\Repository\PlanningRepository;
use App\Repository\OperationStandardRepository;
use App\Repository\ChampsDepotDossierRepository;
use App\Repository\ChampsDeaufDepotDossierRepository;
use App\Repository\EquipeRepository;
use App\Repository\InstallateurRepository;
use App\Repository\ObligesRepository;
use App\Repository\NotificationsRepository;
use App\Repository\CommentairesControlleRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use App\Entity\ChampsDepotDossier;
use App\Entity\Filtre;
use App\Entity\FactureAaf;
use App\Repository\FiltreRepository;
use App\Repository\FactureAafRepository;
use Datetime;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
use Symfony\Component\Security\Csrf\CsrfToken;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\Process\Process;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\HttpFoundation\JsonResponse;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use App\Repository\SoustraitantRepository;
use App\Repository\AppelqualiteRepository;
use App\Entity\Appelqualite;
use App\Repository\CommentaireAppelqualiteRepository;
use App\Entity\CommentaireAppelqualite;
/**
* @Route("/depot")
*/
class DepotDossierController extends AbstractController
{
/**
* @Route("/", name="app_depot_dossier_index", methods={"GET", "POST"})
*/
public function index(Request $request,DepotDossierRepository $depotDossierRepository,EquipeRepository $equipeRepository,InstallateurRepository $installateurRepository,
OperationStandardRepository $operationStandardRepository,ObligesRepository $obligesRepository,FiltreRepository $filtreRepository,FactureAafRepository $factureAafRepository): Response
{
if ($request->getMethod() == "POST") {
$form = $request->request;
//
if ($form->get("chk_dossier") != null) {
$idexporte=0;
$exporte ="non";
//dd($form->get("controller1"));
if ($form->get("aaf") != null) {
$factureAaf = new FactureAaf();
$factureAaf->setDate(new Datetime());
$factureAaf->setDepotaaf($form->get("depotaaf"));
$factureAaf->setNumero($form->get("aaf"));
$factureAafRepository->add($factureAaf, true);
}
foreach ($form->get("chk_dossier") as $key => $value) {
$dossier = $depotDossierRepository->findOneBy(["id"=>intval($value)]);
if ($form->get("controller1") != '-') {
$controller1 = $equipeRepository->findOneBy(["id"=>intval($form->get("controller1"))]);
$dossier->setControler1($controller1);
}
if ($form->get("controller2") != '-') {
$controller2 = $equipeRepository->findOneBy(["id"=>intval($form->get("controller2"))]);
$dossier->setControler2($controller2);
}
if ($form->get("aaf") != null) {
$dossier->setFactureAaf($factureAaf);
$dossier->setStatus("En attente de paiement");
}
$depotDossierRepository->add($dossier, true);
if ($form->get("aaf") != null) {
if ($dossier->getId() != null) {
$factureAaf->addDossier($dossier);
}
}
}
// if ($form->get("aaf") != null) {
// dd($factureAaf);
// }
}
}
$equipes=[];
foreach ($equipeRepository->findBy(["role"=>"ROLE_CONTROLER"]) as $key => $value) {
$equipes[]=$value;
}
// dd($equipes);
$idexporte=0;
$exporte ="non";
if ($this->isGranted('ROLE_INSTALLATEUR')) {
$dossier=[];
$deals=$this->getUser()->getInstallateur()->getDeals();
foreach ($deals as $deal) {
foreach ($depotDossierRepository->findBy(["deal"=>$deal]) as $dls) {
foreach ($depotDossierRepository->findAll() as $value) {
if ($value->getId() == $dls->getId()) {
$dossier[]=$value;
}
}
}
}
//dd($dossier);
}else{
$dossier=[];
$idexporte=0;
if ($request->getMethod() == "POST") {
$form = $request->request;
//
$filtre = new Filtre();
$filtre->setService("Depot Dossier");
$descrtionfiltre="";
if($form->get("filtreinstallateur") != null ){
$descrtionfiltre.=" Installateur : ";
foreach ($form->get("filtreinstallateur") as $value) {
$descrtionfiltre.=$installateurRepository->findOneBy(["id"=>intval($value)])->getSociete().";";
}
}
if ($form->get("filtreoblige") != null) {
$descrtionfiltre.=" Oblige : ";
foreach ($form->get("filtreoblige") as $value) {
$descrtionfiltre.=$obligesRepository->findOneBy(["id"=>intval($value)])->getSociete().";";
}
}
if ($form->get("filtreequipe") != null) {
$descrtionfiltre.=" Equipe : ";
foreach ($form->get("filtreequipe") as $value) {
$descrtionfiltre.=$equipeRepository->findOneBy(["id"=>intval($value)])->getPrenom().";";
}
}
if ($form->get("filtreoperation") != null) {
$descrtionfiltre.=" Operation : ";
foreach ($form->get("filtreoperation") as $value) {
$descrtionfiltre.=explode(':',$operationStandardRepository->findOneBy(["id"=>intval($value)])->getNom())[0].";";
}
}
if ($form->get("filtrestatus") != null) {
$descrtionfiltre.=" Status : ";
foreach ($form->get("filtrestatus") as $value) {
$descrtionfiltre.=$value.";";
}
}
$filtre->setDescription($descrtionfiltre);
$filtre->setDate(new Datetime());
$filtre->setUser($this->getUser());
$filtreRepository->add($filtre, true);
$idexporte=$filtre->getId();
if($form->get("filtreinstallateur") != null ){
foreach ($form->get("filtreinstallateur") as $value) {
foreach ($depotDossierRepository->findBy([], ['id' => 'DESC']) as $depotds) {
if ($depotds->getDeal()->getInstallateur()->getId() == $value) {
if ($form->get("filtreoblige") != null) {
foreach ($form->get("filtreoblige") as $obg) {
if ($depotds->getDeal()->getDealoblige()->getOblige()->getId() == $obg) {
//dd($form->get("filtrestatus"));
if ($form->get("filtrestatus") != null) {
foreach ($form->get("filtrestatus") as $status) {
if ($depotds->getStatus() == $status ) {
if ($form->get("filtreequipe") != null) {
foreach ($form->get("filtreequipe") as $controller) {
if ($depotds->getControler1()->getId() == $controller || $depotds->getControler2()->getId() == $controller ) {
if ($form->get("filtreoperation") != null) {
foreach ($form->get("filtreoperation") as $operation) {
foreach ($depotds->getOperation() as $ops) {
if ($ops->getId()==$operation) {
$dossier[]=$depotds;
}
}
}
}else{
$dossier[]=$depotds;
}
}
}
} else {
$dossier[]=$depotds;
}
}
}
}else{
$dossier[]=$depotds;
}
}
}
} else {
if ($form->get("filtrestatus") != null) {
foreach ($form->get("filtrestatus") as $status) {
if ($depotds->getStatus() == $status ) {
if ($form->get("filtreequipe") != null) {
foreach ($form->get("filtreequipe") as $controller) {
if ($depotds->getControler1()->getId() == $controller || $depotds->getControler2()->getId() == $controller ) {
if ($form->get("filtreoperation") != null) {
foreach ($form->get("filtreoperation") as $operation) {
foreach ($depotds->getOperation() as $ops) {
if ($ops->getId()==$operation) {
$dossier[]=$depotds;
}
}
}
}else{
$dossier[]=$depotds;
}
}
}
} else {
$dossier[]=$depotds;
}
}
}
} else {
$dossier[]=$depotds;
}
}
}
}
}
}else{
if ($form->get("filtreoblige") != null) {
foreach ($depotDossierRepository->findBy([], ['id' => 'DESC']) as $depotds) {
foreach ($form->get("filtreoblige") as $obg) {
if ($depotds->getDeal()->getDealoblige()->getOblige()->getId() == $obg) {
//dd($form->get("filtrestatus"));
if ($form->get("filtrestatus") != null) {
foreach ($form->get("filtrestatus") as $status) {
if ($depotds->getStatus() == $status ) {
if ($form->get("filtreequipe") != null) {
foreach ($form->get("filtreequipe") as $controller) {
if ($depotds->getControler1()->getId() == $controller || $depotds->getControler2()->getId() == $controller ) {
if ($form->get("filtreoperation") != null) {
foreach ($form->get("filtreoperation") as $operation) {
foreach ($depotds->getOperation() as $ops) {
if ($ops->getId()==$operation) {
$dossier[]=$depotds;
}
}
}
}else{
$dossier[]=$depotds;
}
}
}
} else {
$dossier[]=$depotds;
}
}
}
}else{
$dossier[]=$depotds;
}
}
}
}
}else{
if ($form->get("filtrestatus") != null) {
foreach ($depotDossierRepository->findBy([], ['id' => 'DESC']) as $depotds) {
foreach ($form->get("filtrestatus") as $status) {
if ($depotds->getStatus() == $status ) {
if ($form->get("filtreequipe") != null) {
foreach ($form->get("filtreequipe") as $controller) {
if ($depotds->getControler1()->getId() == $controller || $depotds->getControler2()->getId() == $controller ) {
if ($form->get("filtreoperation") != null) {
foreach ($form->get("filtreoperation") as $operation) {
foreach ($depotds->getOperation() as $ops) {
if ($ops->getId()==$operation) {
$dossier[]=$depotds;
}
}
}
}else{
$dossier[]=$depotds;
}
}
}
}else
{
$dossier[]=$depotds;
}
}
}
}
}else{
if ($form->get("filtreequipe") != null) {
foreach ($depotDossierRepository->findBy([], ['id' => 'DESC']) as $depotds) {
foreach ($form->get("filtreequipe") as $controller) {
if ($depotds->getControler1()) {
if ($depotds->getControler1()->getId() == $controller || $depotds->getControler2()->getId() == $controller ) {
if ($form->get("filtreoperation") != null) {
foreach ($form->get("filtreoperation") as $operation) {
foreach ($depotds->getOperation() as $ops) {
if ($ops->getId()==$operation) {
$dossier[]=$depotds;
}
}
}
}else{
$dossier[]=$depotds;
}
}
}
}
}
}else{
if ($form->get("filtreoperation") != null) {
foreach ($depotDossierRepository->findBy([], ['id' => 'DESC']) as $depotds) {
foreach ($form->get("filtreoperation") as $operation) {
foreach ($depotds->getOperation() as $ops) {
if ($ops->getId()==$operation) {
$dossier[]=$depotds;
}
}
}
}
}else{
$dossier= $depotDossierRepository->findBy([], ['id' => 'DESC']);
}
}
}
}
}
$exporte ="oui";
if ($form->get("chk_dossier") != null) {
$idexporte=0;
$exporte ="non";
}
}else{
$exporte ="non";
if ($this->isGranted('ROLE_CONTROLER') ) {
foreach ($depotDossierRepository->findBy(["controler1"=>$this->getUser()->getEquipe()]) as $key => $value) {
$dossier[]=$value;
}
foreach ($depotDossierRepository->findBy(["controler2"=>$this->getUser()->getEquipe()]) as $key => $value) {
$dossier[]=$value;
}
}elseif($this->isGranted('ROLE_CONTROLER')){
foreach ($depotDossierRepository->findBy(["controler1"=>$this->getUser()->getEquipe()]) as $key => $value) {
$dossier[]=$value;
}
foreach ($depotDossierRepository->findBy(["controler2"=>$this->getUser()->getEquipe()]) as $key => $value) {
$dossier[]=$value;
}
//dd($dossier);
} elseif($this->isGranted('ROLE_OBLIGE')){
foreach ($this->getUser()->getObliges()->getDeals() as $deal) {
foreach ($deal->getDepotDossiers() as $value) {
$dossier[]=$value;
}
}
}
else{
$dossier= $depotDossierRepository->findAll();
}
}
}
$tab=[];
$dossiers=[];
// id,type as owner,client as name ,date,file ,batiment
foreach ($dossier as $value) {
if ($value->getStatus() != "archive") {
# code...
$tab['id']=$value->getId();
$tab['name']=$value->getNumero();
$tab['owner']=$value->getDeal()->getNumero();
$tab['owner_id']=$value->getDeal()->getId();
$tab['icone']="ri-archive-line";
if ($value->getControler1()) {
$tab['controller1']=$value->getControler1()->getPrenom();
}
if ($value->getControler2()) {
$tab['controller2']=$value->getControler2()->getPrenom();
}
$ops="";
$opi=0;
foreach ($value->getOperation() as $key => $op) {
if ($opi>0) {
$ops.=";";
}
$ops.=explode(':',$op->getNom())[0];
$opi=$opi + 1;
}
$tab['industry_type']=$ops;
$tab['cumac']=$value->getCumac();
$tab['location']=$value->getNomclient().' '.$value->getPrenomclient();
$tab['contact_email']=$value->getDeal()->getInstallateur()->getEmail();
$tab['employee']="depot";
if ($value->getStatus()=='Validé' || $value->getStatus()=='Payé sur AAF' || $value->getStatus()=='Déposé / AAF en cours' || $value->getStatus()=='En attente de paiement' ) {
$tab['star_value']='<span class="badge progress-green p-2 border-0" >'.$value->getStatus().'</span>';
$tab['row_tr']='row-green';
} elseif($value->getStatus()=="Bloqué" || $value->getStatus()=="Non validé" ) {
$tab['star_value']='<span class="badge progress-red p-2 border-0" >'.$value->getStatus().'</span>';
$tab['row_tr']='row-red';
}elseif($value->getStatus()=="Urgent") {
$tab['star_value']='<span class="badge progress-red p-2 border-0" >'.$value->getStatus().'</span>';
$tab['row_tr']='row-red';
}
elseif($value->getStatus()=="En Attente" || $value->getStatus()=="Prêt pour dépôt"){
$tab['star_value']='<span class="badge progress-yellow p-2 border-0" >'.$value->getStatus().'</span>';
$tab['row_tr']='row-yellow';
}else{
$tab['star_value']='<span class="badge progress-grey p-2 border-0" >Nouveau</span>';
$tab['row_tr']='row-grey';
}
$tab['image_src']="#";
$dossiers[]=$tab;
}
}
//dd($dossiers);
$dossiersjson = json_encode($dossiers);
// var_dump(json_encode($clientjson ));
file_put_contents('assets/json/dossier-list.json', $dossiersjson);
return $this->render('depot_dossier/index.html.twig', [
'depot_dossiers' => $depotDossierRepository->findAll(),
'equipes'=>$equipes,
'listobliges' => $obligesRepository->findAll(),
'allInstallateurs' => $installateurRepository->findAll(),
'operationsStandard' => $operationStandardRepository->findAll(),
'exporte' => $exporte,
'idexporte' => $idexporte
]);
}
/**
* @Route("/dossierarchives", name="app_depot_dossier_archives", methods={"GET", "POST"})
*/
public function dossierarchives(Request $request,DepotDossierRepository $depotDossierRepository,EquipeRepository $equipeRepository,InstallateurRepository $installateurRepository,
OperationStandardRepository $operationStandardRepository,ObligesRepository $obligesRepository,FiltreRepository $filtreRepository,FactureAafRepository $factureAafRepository): Response
{
if ($request->getMethod() == "POST") {
$form = $request->request;
if ($form->get("chk_dossier") != null) {
foreach ($form->get("chk_dossier") as $key => $value) {
$dossier = $depotDossierRepository->findOneBy(["id"=>intval($value)]);
$dossier->setArchive($dossier->getStatus());
$dossier->setStatus("archive");
$depotDossierRepository->add($dossier, true);
}
}
}
$dossier=$depotDossierRepository->findBy(['status' => 'archive'], ['id' => 'DESC']);;
$tab=[];
$dossiers=[];
// id,type as owner,client as name ,date,file ,batiment
foreach ($dossier as $value) {
if ($value->getStatus() == "archive") {
# code...
$tab['id']=$value->getId();
$tab['name']=$value->getNumero();
$tab['owner']=$value->getDeal()->getNumero();
$tab['owner_id']=$value->getDeal()->getId();
$tab['icone']="ri-delete-bin-fill";
if ($value->getControler1()) {
$tab['controller1']=$value->getControler1()->getPrenom();
}
if ($value->getControler2()) {
$tab['controller2']=$value->getControler2()->getPrenom();
}
$ops="";
$opi=0;
foreach ($value->getOperation() as $key => $op) {
if ($opi>0) {
$ops.=";";
}
$ops.=explode(':',$op->getNom())[0];
$opi=$opi + 1;
}
$tab['industry_type']=$ops;
$tab['cumac']=$value->getCumac();
$tab['location']=$value->getNomclient().' '.$value->getPrenomclient();
$tab['contact_email']=$value->getDeal()->getInstallateur()->getEmail();
$tab['employee']="depot";
if($value->getStatus()=="archive") {
$tab['star_value']='<span class="badge progress-red p-2 border-0" >'.$value->getStatus().'</span>';
$tab['row_tr']='row-red';
}
$tab['image_src']="#";
$dossiers[]=$tab;
}
}
//dd($dossiers);
$dossiersjson = json_encode($dossiers);
// var_dump(json_encode($clientjson ));
file_put_contents('assets/json/dossier-list.json', $dossiersjson);
return $this->render('depot_dossier/archives.html.twig', [
'depot_dossiers' => $depotDossierRepository->findAll()
]);
}
/**
* @Route("/dossierdesarchives", name="app_depot_dossier_desarchives", methods={"GET", "POST"})
*/
public function dossierdesarchives(Request $request,DepotDossierRepository $depotDossierRepository,EquipeRepository $equipeRepository,InstallateurRepository $installateurRepository,
OperationStandardRepository $operationStandardRepository,ObligesRepository $obligesRepository,FiltreRepository $filtreRepository,FactureAafRepository $factureAafRepository): Response
{
if ($request->getMethod() == "POST") {
$form = $request->request;
if ($form->get("chk_dossier") != null) {
foreach ($form->get("chk_dossier") as $key => $value) {
$dossier = $depotDossierRepository->findOneBy(["id"=>intval($value)]);
$dossier->setStatus($dossier->getArchive());
$depotDossierRepository->add($dossier, true);
}
}
}
return $this->redirectToRoute('app_depot_dossier_index', [], Response::HTTP_SEE_OTHER);
}
/**
* @Route("/historiquefiltre", name="app_filtre_index", methods={"GET", "POST"})
*/
public function historiquefiltre(Request $request,FiltreRepository $filtreRepository): Response
{
$filtre= $filtreRepository->findAll();
$tab=[];
$filtres=[];
// id,type as owner,client as name ,date,file ,batiment
foreach ($filtre as $value) {
if ($value->getExporte() != null) {
$tab['id']=$value->getId();
$tab['name']=$value->getDate()->format('d-m-Y');
$tab['owner']=$value->getDescription();
$tab['industry_type']=$value->getExporte();
if ($value->getUser()) {
$tab['contact_email']=$value->getUser()->getEquipe()->getPrenom();
}
$filtres[]=$tab;
}
}
//dd($filtres);
$clientjson = json_encode($filtres);
// var_dump(json_encode($clientjson ));
file_put_contents('assets/json/filtre-list.json', $clientjson);
return $this->render('depot_dossier/filtre.html.twig', [
'filtres' => $filtreRepository->findAll(),
]);
}
/**
* @Route("/new", name="app_depot_dossier_new", methods={"GET", "POST"})
*/
public function new(Request $request,DealRepository $dealRepository,DepotDossierRepository $depotDossierRepository,OperationStandardRepository $operationsStandardRepository,
ChampsDeaufDepotDossierRepository $champsDeaufDepotDossierRepository,ChampsDepotDossierRepository $champsDepotDossierRepository,FactureAafRepository $factureAafRepository): Response
{
$depotDossier = new DepotDossier();
// $form = $this->createForm(DepotDossierType::class, $depotDossier);
// $form->handleRequest($request);
if ($request->getMethod() == "POST") {
$form = $request->request;
//dd($form->get('operations'));
// $depotDossier->setClientfiscale($form->get('fiscale'));
$depotDossier->setCivilite($form->get('civilite'));
$depotDossier->setNomclient($form->get('nomclient'));
$depotDossier->setPrenomclient($form->get('prenomclient'));
$depotDossier->setPhone($form->get('phone'));
$depotDossier->setEmail($form->get('email'));
$depotDossier->setAdresse($form->get('adresse'));
$depotDossier->setVille($form->get('ville'));
$depotDossier->setCodepostale($form->get('postale'));
$depotDossier->setNumero($form->get('numero'));
$depotDossier->setCumac($form->get('cumac'));
// $depotDossier->setNatureoccupation($form->get('occupation'));
// $depotDossier->setTypelogement($form->get('typelogement'));
// $depotDossier->setEnergiechauffage($form->get('energiechauffage'));
// $depotDossier->setAnciennete($form->get('anciennetechauffage'));
// $depotDossier->setSystemechauffage($form->get('anciennetechauffage'));
// $depotDossier->setSurfacehabitable($form->get('surfacehabite'));
// $depotDossier->setSuperficiesol($form->get('Superficiesol'));
// $depotDossier->setParcellecadastrale($form->get('Parcelle'));
// $depotDossier->setTypemaison($form->get('Parcelle'));
// $depotDossier->setSoussol($form->get('soussol'));
// $depotDossier->setAnciennetelogement($form->get('ancienneteloge'));
$depotDossier->setStatus("nouveau");
$depotDossier->setDate(new Datetime());
$deal= $dealRepository->findOneBy(["id"=>intval($form->get('deal'))]);
$depotDossier->setDeal($deal);
// $alphas = range('A', 'Z');
// $key = substr($deal->getNumero(), 0, 2).''. random_int(001, 999).''.$alphas[random_int(0, 25)] . '' . $alphas[random_int(0, 25)] ;
// $depotDossier->setNumero($key);
if ($form->get('operations') !=null ) {
foreach ($form->get('operations') as $value) {
$ops= $operationsStandardRepository->findOneBy(["id"=>intval($value)]);
$depotDossier->addOperation($ops);
}
}
$depotDossierRepository->add($depotDossier, true);
foreach ($champsDeaufDepotDossierRepository->findAll() as $chmps) {
$champsDepotDossier = new ChampsDepotDossier();
$champsDepotDossier->setNom($chmps->getNom());
$champsDepotDossier->setType($chmps->getType());
if ($chmps->getType()== 'file') {
$champsDepotDossier->setStatus('Non Transmis');
}
$champsDepotDossier->setDepotdossier($depotDossier);
$champsDepotDossierRepository->add($champsDepotDossier, true);
}
// $factureAaf = new FactureAaf();
// $factureAaf->setDossier($depotDossier);
// $factureAaf->setStatus("Non Transmis");
// $factureAafRepository->add($factureAaf, true);
return $this->redirectToRoute('app_depot_dossier_edit', ['id' =>$depotDossier->getId()], Response::HTTP_SEE_OTHER);
}
if ($this->isGranted('ROLE_INSTALLATEUR')) {
$datejr= new Datetime();
$deal=[];
foreach ($this->getUser()->getInstallateur()->getDeals() as $key => $value) {
if ($value->getStatus()=="Validé" && $value->getDatefin() > $datejr) {
$deal[]=$value;
}
}
}else{
$deal=[];
$datejr= new Datetime();
foreach ( $dealRepository->findBy(['status'=>'Validé']) as $key => $value) {
if ($value->getDatefin() > $datejr) {
$deal[]=$value;
}
}
}
if ($this->isGranted('ROLE_INSTALLATEUR')) {
$operations=$this->getUser()->getInstallateur()->getOperationStandards();
}else{
$operations= $operationsStandardRepository->findAll();
}
if ($request->query->get('ideal') != null ) {
$idealGet = $request->query->get('ideal');
} else {
$idealGet = 0;
}
return $this->renderForm('depot_dossier/new.html.twig', [
'depot_dossier' => $depotDossier,
'depot' => "depot",
'operations' =>$operations,
'dealAll' => $deal,
"idealGet" => $idealGet
]);
}
/**
* @Route("/{id}", name="app_depot_dossier_show", methods={"GET"})
*/
public function show(DepotDossier $depotDossier): Response
{
return $this->render('depot_dossier/show.html.twig', [
'depot_dossier' => $depotDossier,
]);
}
/**
* @Route("/{id}/edit", name="app_depot_dossier_edit", methods={"GET", "POST"})
*/
public function edit(Request $request, DepotDossier $depotDossier, DepotDossierRepository $depotDossierRepository,CsrfTokenManagerInterface $csrfTokenManager,
EquipeRepository $equipeRepository,NotificationsRepository $notificationsRepository,OperationStandardRepository $operationsStandardRepository,
PlanningRepository $planningRepository,SoustraitantRepository $soustraitantRepository,ChampsDeaufDepotDossierRepository $champsDeaufDepotDossierRepository): Response
{
// $form = $this->createForm(DepotDossierType::class, $depotDossier);
// $form->handleRequest($request);
// if ($form->isSubmitted() && $form->isValid()) {
// $depotDossierRepository->add($depotDossier, true);
// return $this->redirectToRoute('app_depot_dossier_index', [], Response::HTTP_SEE_OTHER);
// }
if ($this->isGranted('ROLE_INSTALLATEUR')) {
if ($this->getUser()->getInstallateur()->getId() != $depotDossier->getDeal()->getInstallateur()->getId()) {
return $this->redirectToRoute('app_depot_dossier_index', [], Response::HTTP_SEE_OTHER);
}
}
$csrfToken = $csrfTokenManager->getToken('depot_dossier_edit');
if ($request->getMethod() == "POST") {
$token = $request->request->get('_token');
$id = explode("A@",explode("12OU#@R",$token)[1])[0];
if ($id!=$depotDossier->getId()) {
return $this->redirectToRoute('app_depot_dossier_edit', ['id' => $id], Response::HTTP_SEE_OTHER);
}
$form = $request->request;
if ($form->get('controler2') != null ) {
$depotDossier->setControler2($equipeRepository->findOneBy(["id"=>intval($form->get('controler2'))]));
}
if ($form->get('controler1') != null ) {
$depotDossier->setControler1($equipeRepository->findOneBy(["id"=>intval($form->get('controler1'))]));
}
//dd($form->get('dateprevisite'));
if ($depotDossier->getPlanning()) {
$planning = $depotDossier->getPlanning();
}else{
$planning = new Planning();
}
$dateprevisite = date('d-m-Y', strtotime($form->get('dateprevisite'))) ;
$datetimeprevisite = new Datetime($dateprevisite);
$datedevis = date('d-m-Y', strtotime($form->get('datedevis'))) ;
$datetimedevis = new Datetime($datedevis);
$dateengagement = date('d-m-Y', strtotime($form->get('dateengagement'))) ;
$datetimeengagement = new Datetime($dateengagement);
$datetravaux = date('d-m-Y', strtotime($form->get('datetravaux'))) ;
$datetimetravaux = new Datetime($datetravaux);
$datefacture = date('d-m-Y', strtotime($form->get('datefacture'))) ;
$datetimefacture = new Datetime($datefacture);
$planning->setDateprevisite($datetimeprevisite);
$planning->setIntervenant($form->get('intervation'));
$planning->setDatedevis($datetimedevis);
$planning->setSourcedevis($form->get('sourcedevis'));
$planning->setDateengagement($datetimeengagement);
$planning->setDatetravaux($datetimetravaux);
$planning->setPoseur($form->get('poseur'));
$planning->setConsigne($form->get('consigne'));
$planning->setDatefacture($datetimefacture);
$planning->setSourcefacture($form->get('sourcefacture'));
$planning->setNumerofacture($form->get('numerofacture'));
$planning->setDossier($depotDossier);
$planningRepository->add($planning, true);
// $depotDossier->setClientfiscale($form->get('fiscale'));
$depotDossier->setCivilite($form->get('civilite'));
$depotDossier->setNomclient($form->get('nomclient'));
$depotDossier->setPrenomclient($form->get('prenomclient'));
$depotDossier->setPhone($form->get('phone'));
$depotDossier->setEmail($form->get('email'));
$depotDossier->setNumero($form->get('numero'));
$depotDossier->setCumac($form->get('cumac'));
if ($depotDossier->getBlocage()!="oui") {
$depotDossier->setAdresse($form->get('adresse'));
$depotDossier->setVille($form->get('ville'));
$depotDossier->setCodepostale($form->get('postale'));
}
// $depotDossier->setNatureoccupation($form->get('occupation'));
// $depotDossier->setTypelogement($form->get('typelogement'));
// $depotDossier->setEnergiechauffage($form->get('energiechauffage'));
// $depotDossier->setAnciennete($form->get('anciennetechauffage'));
// $depotDossier->setSystemechauffage($form->get('anciennetechauffage'));
// $depotDossier->setSurfacehabitable($form->get('surfacehabite'));
// $depotDossier->setSuperficiesol($form->get('Superficiesol'));
// $depotDossier->setParcellecadastrale($form->get('Parcelle'));
// $depotDossier->setTypemaison($form->get('Parcelle'));
// $depotDossier->setAnciennetelogement($form->get('ancienneteloge'));
// $depotDossier->setSoussol($form->get('soussol'));
$depotDossier->setStatus($form->get('status'));
$depotDossier->setCommentaire($form->get('commentaire'));
if ($form->get('operations') != null) {
foreach ($depotDossier->getOperation() as $value) {
if (!in_array($value->getId(),$form->get('operations'))) {
$depotDossier->removeOperation($value);
}
}
foreach ($form->get('operations') as $value) {
$ops= $operationsStandardRepository->findOneBy(["id"=>intval($value)]);
$depotDossier->addOperation($ops);
}
}else{
foreach ($depotDossier->getOperation() as $value) {
$depotDossier->removeOperation($value);
}
}
if ($form->get('soustraitants') != null) {
foreach ($depotDossier->getSoustraitants() as $value) {
if (!in_array($value->getId(),$form->get('soustraitants'))) {
$depotDossier->removeSoustraitant($value);
}
}
foreach ($form->get('soustraitants') as $value) {
$soustraitant= $soustraitantRepository->findOneBy(["id"=>intval($value)]);
$depotDossier->addSoustraitant($soustraitant);
}
}else{
foreach ($depotDossier->getSoustraitants() as $value) {
$depotDossier->removeSoustraitant($value);
}
}
$depotDossierRepository->add($depotDossier, true);
return $this->redirectToRoute('app_depot_dossier_edit', ['id' =>$depotDossier->getId()], Response::HTTP_SEE_OTHER);
}
$notif = $notificationsRepository->findOneBy(["user_id" => $this->getUser(),"statuts"=> "non lu","action" => "app_depot_dossier_edit","action_id"=>$depotDossier->getId()]);
if ($notif) {
$notif->setStatuts("lu");
$notificationsRepository->add($notif, true);
}
$dealAll = $depotDossier->getDeal()->getInstallateur()->getDeals();
$operationsStandars = $depotDossier->getDeal()->getInstallateur()->getOperationStandards();
// $controles1=$equipeRepository->findBy(["role"=>'ROLE_CONTROLER']);
// $controles2=$equipeRepository->findBy(["role"=>'ROLE_CONTROLER']);
$equipes=[];
foreach ($equipeRepository->findBy(["role"=>"ROLE_CONTROLER"]) as $key => $value) {
$equipes[]=$value;
}
//dd($csrfToken->getValue().'12OU#@R'.$depotDossier->getId()."A@T9");
// dd($champsDeaufDepotDossierRepository->findAll());
return $this->renderForm('depot_dossier/edit.html.twig', [
"depot" =>"depot",
'depot_dossier' => $depotDossier,
'dealAll' => $dealAll,
'controles1' => $equipes,
'controles2' => $equipes,
'operationsStandars' => $operationsStandars,
"dateday"=>new Datetime(),
'csrf_token' => $csrfToken->getValue().'12OU#@R'.$depotDossier->getId()."A@T9",
'champsDeaufs' => $champsDeaufDepotDossierRepository->findAll()
]);
}
/**
* @Route("/{id}", name="app_depot_dossier_delete", methods={"POST"})
*/
public function delete(Request $request, DepotDossier $depotDossier, DepotDossierRepository $depotDossierRepository,CommentairesControlleRepository $commentairesControlleRepository
, NotificationsRepository $notificationsRepository,ChampsDepotDossierRepository $champsDepotDossierRepository,FactureAafRepository $factureAafRepository,AppelqualiteRepository $appelqualiteRepository,
SoustraitantRepository $soustraitantRepository): Response
{
if ($this->isCsrfTokenValid('delete'.$depotDossier->getId(), $request->request->get('_token'))) {
foreach ($notificationsRepository->findBy(["action_id"=>$depotDossier->getId()]) as $value) {
$notificationsRepository->remove($value, true);
}
foreach ($depotDossier->getCommentairesControlles() as $commentaire) {
$commentairesControlleRepository->remove($commentaire, true);
}
foreach ($depotDossier->getChampsDepotDossiers() as $value) {
$depotDossier->removeChampsDepotDossier($value);
$champsDepotDossierRepository->remove($value, true);
}
foreach ($depotDossier->getSoustraitants() as $value) {
$depotDossier->removeSoustraitant($value);
// $soustraitantRepository->remove($value, true);
}
// foreach ($depotDossier->getFactureAafs() as $value) {
// foreach ($value->getCommentaireFactureaafs() as $commentaire) {
// $value->removeCommentaireFactureaaf($commentaire);
// }
// }
foreach ($depotDossier->getAppelqualites() as $value) {
foreach ($value->getCommentaireAppelqualites() as $commentaire) {
$value->removeCommentaireAppelqualite($commentaire);
// $activiteDealRepository->remove($commentaire, true);
}
$depotDossier->removeAppelqualite($value);
$appelqualiteRepository->remove($value, true);
}
$depotDossierRepository->remove($depotDossier, true);
}
return $this->redirectToRoute('app_depot_dossier_index', [], Response::HTTP_SEE_OTHER);
}
/**
* @Route("/zip/{id}", name="app_depot_dossier_zip", methods={"GET"})
*/
public function zip(DepotDossier $depotDossier): Response
{
$zipFileName = 'depotdossier_'.$depotDossier->getDeal()->getInstallateur()->getSociete().'_' . date('d-m-Y-His') . '.zip';
// Créez le chemin absolu vers le fichier ZIP
$zipFilePath = $this->getParameter('installateur_directory') . '/archiver/' . $zipFileName;
// Utilisez la classe ZipArchive pour créer le fichier ZIP
$zip = new \ZipArchive();
$zip->open($zipFilePath, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
foreach ($depotDossier->getChampsDepotDossiers() as $value) {
if ($value->getType()=="file") {
if ($value->getValeur()!=null) {
$filePath = $this->getParameter('installateur_directory').'/'.$value->getValeur();
$relativePath = 'depotdossier_'.$depotDossier->getDeal()->getInstallateur()->getSociete()."/".$value->getValeur();
$zip->addFile($filePath, $relativePath);
}
}
}
// Fermer le fichier ZIP
$zip->close();
// Envoyer le fichier ZIP en tant que réponse de téléchargement
$response = new BinaryFileResponse($zipFilePath);
$response->headers->set('Content-Type', 'application/zip');
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $zipFileName);
return $response;
}
/**
* @Route("/commentaire/{id}", methods={"POST"})
*/
public function commentaire(Request $request,CommentairesControlleRepository $commentairesControlleRepository,
NotificationsRepository $notificationsRepository,DepotDossier $depotDossier): JsonResponse
{
if ($request->getMethod() == "POST") {
// $file=$request->files->get('validedocument');
$commentaire = $request->request->get('commentaire');
$status= $request->request->get('status');
$assigne= $request->request->get('assigne');
if ($commentaire) {
$commentairesControlle = new CommentairesControlle();
$commentairesControlle->setCommentaire($commentaire);
$commentairesControlle->setDate(new DateTime());
$commentairesControlle->setDossier($depotDossier);
$commentairesControlle->setStatus($status);
$commentairesControlle->setAssigne($assigne);
$commentairesControlle->setControleur($this->getUser()->getEquipe());
$commentairesControlleRepository->add($commentairesControlle, true);
// if ($this->isGranted('ROLE_CONTROLER')) {
// $user = $depotDossier->getControler2()->getUser();
// $notifications = new Notifications();
// $notifications->setUserId($user);
// $notifications->setMessage("Le contrôle n°1 du dossier ".$depotDossier->getNumero()." a été validé.");
// $notifications->setAction("app_depot_dossier_edit");
// $notifications->setActionId($depotDossier->getId());
// $notifications->setSender($this->getUser());
// $notifications->setStatuts("non lu");
// $notifications->setDate(new DateTime());
// $notificationsRepository->add($notifications, true);
// $admins = $equipeRepository->findAll();
// foreach ($admins as $key => $value) {
// $listPermissions = $value->getPermissions();
// foreach ($listPermissions as $v) {
// if($v == "NOTIFICATION" ){
// $notificationsAdmin = new Notifications();
// $notificationsAdmin->setUserId($value->getUser());
// $notificationsAdmin->setMessage("Le contrôle n°1 du dossier ".$depotDossier->getNumero()." a été validé.");
// $notificationsAdmin->setAction("app_depot_dossier_edit");
// $notificationsAdmin->setActionId($depotDossier->getId());
// $notificationsAdmin->setSender($this->getUser());
// $notificationsAdmin->setStatuts("non lu");
// $notificationsAdmin->setDate(new DateTime());
// $notificationsRepository->add($notificationsAdmin, true);
// }
// }
// }
// }else{
// }
return $this->json(['success' => true, 'message' => 'commentaire ajouter ']);
}
}
return $this->json(['success' => false, 'error' => 'Erreur ']);
}
/**
* @Route("/commentaireedite/{id}", methods={"POST"})
*/
public function commentaireedite(Request $request,CommentairesControlleRepository $commentairesControlleRepository,CommentairesControlle $commentairesControlle ): JsonResponse
{
if ($request->getMethod() == "POST") {
// $file=$request->files->get('validedocument');
$commentaire = $request->request->get('commentaire');
if ($commentaire) {
$commentairesControlle->setCommentaire($commentaire);
$commentairesControlle->setDate(new DateTime());
$commentairesControlleRepository->add($commentairesControlle, true);
return $this->json(['success' => true, 'message' => 'commentaire ajouter ']);
}
}
return $this->json(['success' => false, 'error' => 'Erreur ']);
}
/**
* @Route("/suprimercommentaire/{id}", methods={"POST"})
*/
public function suprimercommentaire(Request $request ,CommentairesControlleRepository $commentairesControlleRepository,CommentairesControlle $commentairesControlle): JsonResponse
{
if ($request->getMethod() == "POST") {
// $file=$request->files->get('validedocument');
$id = $request->request->get('id');
if ($id) {
$commentairesControlleRepository->remove($commentairesControlle, true);
return $this->json(['success' => true, 'message' => 'supprimer succès']);
}
}
return $this->json(['success' => false, 'error' => 'Erreur ']);
}
/**
* @Route("/blocage/{id}", methods={"POST"})
*/
public function blocage(Request $request,
NotificationsRepository $notificationsRepository,DepotDossier $depotDossier,DepotDossierRepository $depotDossierRepository): JsonResponse
{
if ($request->getMethod() == "POST") {
// $file=$request->files->get('validedocument');
$lock = $request->request->get('lock');
if ($lock) {
if ($depotDossier->getBlocage()==null || $depotDossier->getBlocage()=='non') {
$depotDossier->setBlocage("oui");
}else{
$depotDossier->setBlocage("non");
}
$depotDossierRepository->add($depotDossier, true);
// if ($this->isGranted('ROLE_CONTROLER')) {
// $user = $depotDossier->getControler2()->getUser();
// $notifications = new Notifications();
// $notifications->setUserId($user);
// $notifications->setMessage("Le contrôle n°1 du dossier ".$depotDossier->getNumero()." a été validé.");
// $notifications->setAction("app_depot_dossier_edit");
// $notifications->setActionId($depotDossier->getId());
// $notifications->setSender($this->getUser());
// $notifications->setStatuts("non lu");
// $notifications->setDate(new DateTime());
// $notificationsRepository->add($notifications, true);
// $admins = $equipeRepository->findAll();
// foreach ($admins as $key => $value) {
// $listPermissions = $value->getPermissions();
// foreach ($listPermissions as $v) {
// if($v == "NOTIFICATION" ){
// $notificationsAdmin = new Notifications();
// $notificationsAdmin->setUserId($value->getUser());
// $notificationsAdmin->setMessage("Le contrôle n°1 du dossier ".$depotDossier->getNumero()." a été validé.");
// $notificationsAdmin->setAction("app_depot_dossier_edit");
// $notificationsAdmin->setActionId($depotDossier->getId());
// $notificationsAdmin->setSender($this->getUser());
// $notificationsAdmin->setStatuts("non lu");
// $notificationsAdmin->setDate(new DateTime());
// $notificationsRepository->add($notificationsAdmin, true);
// }
// }
// }
// }else{
// }
return $this->json(['success' => true, 'message' => 'blocage adresse']);
}
}
return $this->json(['success' => false, 'error' => 'Erreur ']);
}
/**
* @Route("/exportedepot/{id}", name="app_exporte_depot", methods={"GET"})
*/
public function exporte(Filtre $filtre,DepotDossierRepository $depotDossierRepository,FiltreRepository $filtreRepository): Response
{
$jsonFilePath = 'assets/json/dossier-list.json';
// Étape 1 : Récupérer le contenu JSON depuis le fichier
$jsonContent = file_get_contents($jsonFilePath);
// Étape 2 : Décoder le contenu JSON en tableau PHP
$phpArray = json_decode($jsonContent, true);
// Créer un nouveau classeur Excel
$spreadsheet = new Spreadsheet();
// Obtenir la feuille active
$sheet = $spreadsheet->getActiveSheet();
// Écrire des données dans la feuille
$sheet->setCellValue('A1', 'Numéro dossier');
$sheet->setCellValue('B1', 'Operation');
$sheet->setCellValue('C1', 'Nom du Beneficiaire');
$sheet->setCellValue('D1', 'Deal associé');
$sheet->setCellValue('E1', 'Controller');
$sheet->setCellValue('F1', 'Controller');
$sheet->setCellValue('G1', 'Cumac');
$sheet->setCellValue('H1', 'Status');
$i=2;
if ($phpArray === null) {
echo "Erreur lors du décodage JSON : " . json_last_error_msg();
} else {
// Utilisez le tableau PHP $phpArray comme bon vous semble
foreach ($phpArray as $value) {
$dl=$depotDossierRepository->findOneBy(["id"=>intval($value["id"])]);
$sheet->setCellValue('A'.$i, $dl->getNumero());
$ops="";
$opi=0;
foreach ($dl->getOperation() as $key => $op) {
if ($opi>0) {
$ops.=";";
}
$ops.=explode(':',$op->getNom())[0];
$opi=$opi + 1;
}
$sheet->setCellValue('B'.$i, $ops);
$sheet->setCellValue('C'.$i, $dl->getNomclient().' '.$dl->getPrenomclient());
$sheet->setCellValue('D'.$i, $dl->getDeal()->getNumero());
if ($dl->getControler1() != null) {
$sheet->setCellValue('E'.$i, $dl->getControler1()->getPrenom());
}
if ($dl->getControler2() != null) {
$sheet->setCellValue('F'.$i, $dl->getControler2()->getPrenom());
}
$sheet->setCellValue('G'.$i, $dl->getCumac());
$sheet->setCellValue('H'.$i, $dl->getStatus());
$i=$i+1;
}
}
// Créer un objet Writer pour enregistrer le fichier
$writer = new Xlsx($spreadsheet);
// Enregistrer le fichier à un emplacement
$now = new DateTime();
$date = $now->format('d-m-Y H-i-s');
$nomexecel = "deal-".$this->getUser()->getEquipe()->getPrenom()."-".$date;
$cheminFichier =$this->getParameter('installateur_directory') . "/export/export".$nomexecel.".xlsx";
$writer->save($cheminFichier);
$filtre->setExporte("export".$nomexecel.".xlsx");
$filtreRepository->add($filtre, true);
// Renvoyer la réponse avec le fichier Excel en pièce jointe
return $this->file($cheminFichier);
}
/**
* @Route("/{id}/archives", name="app_depot_archives", methods={"GET", "POST"})
*/
public function archives(Request $request,DepotDossier $depotDossier): Response
{
if ($request->getMethod() == "POST") {
$form = $request->request;
// Créez un nom de fichier unique pour le fichier ZIP
$zipFileName = 'DepotDossier_'.$depotDossier->getDeal()->getInstallateur()->getSociete().'_' . date('d-m-Y-His') . '.zip';
// Créez le chemin absolu vers le fichier ZIP
$zipFilePath = $this->getParameter('installateur_directory') . '/archiver/' . $zipFileName;
// Utilisez la classe ZipArchive pour créer le fichier ZIP
$zip = new \ZipArchive();
$zip->open($zipFilePath, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
if ($form->get("chk_archiverdepot") != null ) {
foreach ($form->get("chk_archiverdepot") as $key => $champs) {
foreach ($depotDossier->getChampsDepotDossiers() as $value) {
if ($value->getType()=="file") {
if ($value->getId() == $champs) {
if ($value->getValeur()!=null) {
foreach ($value->getValeur() as $val) {
$filePath = $this->getParameter('installateur_directory').'/'.$val;
$relativePath = $depotDossier->getDeal()->getInstallateur()->getSociete()."/".$val;
$zip->addFile($filePath, $relativePath);
}
}
}
}
}
}
}
// Fermer le fichier ZIP
$zip->close();
// Envoyer le fichier ZIP en tant que réponse de téléchargement
$response = new BinaryFileResponse($zipFilePath);
$response->headers->set('Content-Type', 'application/zip');
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $zipFileName);
// if ($filesystem->exists($sourceFolder)) {
// // Supprimez tous les fichiers et dossiers à l'intérieur du dossier
// $filesystem->remove(glob($sourceFolder . '/*'));
// }
return $response;
}
return $this->redirectToRoute('app_depot_dossier_edit', ['id' =>$depotDossier->getId()], Response::HTTP_SEE_OTHER);
}
/**
* @Route("/{id}/appel", name="app_depot_appel", methods={"GET", "POST"})
*/
public function appel(Request $request,DepotDossier $depotDossier,AppelqualiteRepository $appelqualiteRepository,CommentaireAppelqualiteRepository $commentaireAppelqualiteRepository): Response
{
if ($request->getMethod() == "POST") {
$form = $request->request;
$appelqualite = new Appelqualite();
$appelqualite->setClient($form ->get('questionclient'));
$appelqualite->setAdresse($form ->get('questionadresse'));
$appelqualite->setInstallation($form ->get('questioninstallation'));
$appelqualite->setTerminer($form ->get('questionterminer'));
$appelqualite->setQualite($form ->get('questionqualite'));
$appelqualite->setComplet($form ->get('questioncomplet'));
$appelqualite->setSpecifique($form ->get('questionspecifique'));
$appelqualite->setDossier($depotDossier);
$appelqualite->setStatus($form ->get('statusappel'));
if ($form ->get('nonclient')) {
$appelqualite->setNonclient($form ->get('nonclient'));
}
if ($form ->get('nonadresse')) {
$appelqualite->setNonclient($form ->get('nonadresse'));
}
if ($form ->get('noninstallation')) {
$appelqualite->setNoninstallation($form ->get('noninstallation'));
}
if ($form ->get('nonterminer')) {
$appelqualite->setNontermier($form ->get('nonterminer'));
}
if ($form ->get('noncomplete')) {
$appelqualite->setNoncomplete($form ->get('noncomplete'));
}
if ($form ->get('nonspecifique')) {
$appelqualite->setNonspecifique($form ->get('nonspecifique'));
}
if ($form ->get('ouiqualite')) {
$appelqualite->setOuiqualite($form ->get('ouiqualite'));
}
if ($this->getUser()->getEquipe()) {
$appelqualite->setEquipe($this->getUser()->getEquipe());
}
$appelqualiteRepository->add($appelqualite, true);
if ($form ->get('commentaire') != null) {
$commentaireAppelqualite = new CommentaireAppelqualite();
$commentaireAppelqualite->setCommentaire($form ->get('commentaire'));
$commentaireAppelqualite->setDate(new DateTime());
$commentaireAppelqualite->setAppelqualite($appelqualite);
$commentaireAppelqualite->setUser($this->getUser());
$commentaireAppelqualiteRepository->add($commentaireAppelqualite, true);
}
}
return $this->redirectToRoute('app_depot_dossier_edit', ['id' =>$depotDossier->getId()], Response::HTTP_SEE_OTHER);
}
/**
* @Route("/appel/{id}/edit", name="app_depot_appel_edit", methods={"GET", "POST"})
*/
public function editappel(Request $request,Appelqualite $appelqualite,AppelqualiteRepository $appelqualiteRepository): Response
{
if ($request->getMethod() == "POST") {
$form = $request->request;
$appelqualite->setClient($form ->get('questionclient'));
$appelqualite->setAdresse($form ->get('questionadresse'));
$appelqualite->setInstallation($form ->get('questioninstallation'));
$appelqualite->setTerminer($form ->get('questionterminer'));
$appelqualite->setQualite($form ->get('questionqualite'));
$appelqualite->setComplet($form ->get('questioncomplet'));
$appelqualite->setSpecifique($form ->get('questionspecifique'));
$appelqualite->setStatus($form ->get('statusappel'));
if ($this->getUser()->getEquipe()) {
$appelqualite->setEquipe($this->getUser()->getEquipe());
}
if ($form ->get('nonclient')) {
$appelqualite->setNonclient($form ->get('nonclient'));
}
if ($form ->get('nonadresse')) {
$appelqualite->setNonclient($form ->get('nonadresse'));
}
if ($form ->get('noninstallation')) {
$appelqualite->setNoninstallation($form ->get('noninstallation'));
}
if ($form ->get('nonterminer')) {
$appelqualite->setNontermier($form ->get('nonterminer'));
}
if ($form ->get('noncomplete')) {
$appelqualite->setNoncomplete($form ->get('noncomplete'));
}
if ($form ->get('nonspecifique')) {
$appelqualite->setNonspecifique($form ->get('nonspecifique'));
}
if ($form ->get('ouiqualite')) {
$appelqualite->setOuiqualite($form ->get('ouiqualite'));
}
if ($this->getUser()->getEquipe()) {
$appelqualite->setEquipe($this->getUser()->getEquipe());
}
$appelqualiteRepository->add($appelqualite, true);
}
return $this->redirectToRoute('app_depot_dossier_edit', ['id' =>$appelqualite->getDossier()->getId()], Response::HTTP_SEE_OTHER);
}
/**
* @Route("/archiverdossier/{id}", methods={"POST"})
*/
public function archiverdossier(Request $request,DepotDossier $depotDossier,DepotDossierRepository $depotDossierRepository): JsonResponse
{
if ($request->getMethod() == "POST") {
// $file=$request->files->get('validedocument');
$id = $request->request->get('id');
if ($id) {
$depotDossier->setArchive($depotDossier->getStatus());
$depotDossier->setStatus("archive");
$depotDossierRepository->add($depotDossier, true);
return $this->json(['success' => true, 'message' => 'deal archive']);
}
}
return $this->json(['success' => false, 'error' => 'Erreur ']);
}
}