| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 
 |  
public function filteredAction($companyId = '', $contactId = '', $projectId = '', $das = '', $solution = '') {
 
 
        $em = $this->getDoctrine()->getManager();
        $request = $this->getRequest();
 
        $controllerFull = strstr($this->getRequest()->get('_controller'), ':', 1) ;
        $pos = strrpos($controllerFull, '\\');
        $controller = substr(substr($controllerFull, $pos), 1);
 
        if($request->isXmlHttpRequest()){
            if($companyId != ''){
 
                $company = $em->getRepository('AsmoldingBundle:Company')->find($companyId);
 
                if($this->get('security.context')->isGranted('ROLE_CHEFPROJET')){
                    $cp = $this->getUser();
                    $molds = $em->getRepository('AsmoldingBundle:Mold')->getNotArchivedByCPAndByClient($cp, $company); 
                }
                else{
                    $molds = $em->getRepository('AsmoldingBundle:Mold')->getNotArchivedByClient($company);
                }  
            } else if($contactId != ''){
 
                if($this->get('security.context')->isGranted('ROLE_CHEFPROJET')){
                    $cp = $this->getUser();
                } else{
                    $cp = $em->getRepository('AsmoldingBundle:Contact')->find($contactId);
                }
                $molds = $em->getRepository('AsmoldingBundle:Mold')->getNotArchivedMoldsByCP($cp);  
            } else if($projectId != ''){
 
                $project = $em->getRepository('AsmoldingBundle:project')->find($projectId);
 
                if($this->get('security.context')->isGranted('ROLE_CHEFPROJET')){
                    $cp = $this->getUser();
                    $molds = $em->getRepository('AsmoldingBundle:Mold')->getNotArchivedByCPAndByProject($cp, $project);
                } else{
                    $molds = $em->getRepository('AsmoldingBundle:Mold')->getNotArchivedByProject($project);   
                }
            } else if($das != ''){
 
                if($this->get('security.context')->isGranted('ROLE_CHEFPROJET')){
                    $cp = $this->getUser();
                    $molds = $em->getRepository('AsmoldingBundle:Mold')->getNotArchivedByCPAndByDas($cp, $das);
                } else{
                    $molds = $em->getRepository('AsmoldingBundle:Mold')->getNotArchivedByDas($das);
                }
            } else if($solution != ''){
 
                if($this->get('security.context')->isGranted('ROLE_CHEFPROJET')){
                    $cp = $this->getUser();
                    $molds = $em->getRepository('AsmoldingBundle:Mold')->getNotArchivedByCPAndBySolution($cp, $solution);
                } else{
                    $molds = $em->getRepository('AsmoldingBundle:Mold')->getNotArchivedBySolution($solution);
                }
            }
 
 
            $milestones = $em->getRepository('AsmoldingBundle:Milestone')->getAll();    
 
            $generalPlans = $em->getRepository('AsmoldingBundle:GeneralPlan')->getAll();
 
            if($companyId != ''){
                $lastUpdate = $em->getRepository('AsmoldingBundle:GeneralPlan')->getRecentUpdateTimeByClient($company);     
            } else if($projectId != ''){
                $lastUpdate = $em->getRepository('AsmoldingBundle:GeneralPlan')->getRecentUpdateTimeByProject($project);
            }
            else{
                $lastUpdate = $em->getRepository('AsmoldingBundle:GeneralPlan')->getRecentUpdateTime();
            }
 
            if(!$molds){
                throw new NotFoundHttpException('Aucun planning pour cette recherche');
            }
 
            $today = date('d-m-Y');
            $numWeek = date("W", strtotime($today));
            $year = date("Y", strtotime($today));
 
            return $this->render('AsmoldingBundle:Admin:generalPlan.html.twig', array('molds' => $molds, 'generalPlans' => $generalPlans,'milestones' => $milestones,'numWeek' => $numWeek, 'year' => $year, 'lastUpdate' => $lastUpdate, 'controller' => $controller));
 
        } else{
            return null;
        }
} | 
Partager