Ejemplo n.º 1
0
 public function resultLeaseAction(Request $request)
 {
     $session = $this->getRequest()->getSession();
     $em = $this->getDoctrine()->getEntityManager();
     if ($session->get('type') != 4) {
         return $this->redirect($this->generateUrl('user_home'));
     }
     if ($request->getMethod() == 'POST') {
         $code = $request->get('hidCode');
         $serialNumber = $request->get('serialNumber');
         //echo $serialNumber;die;
         $lomp = $request->get('lomp');
         $lessor = $request->get('lessor');
         $lessee = $request->get('lessee');
         $dateOfExe = $request->get('doe');
         $dateOfRcp = $request->get('dor');
         $situationOfLand = $request->get('sol');
         $partyRegistring = $request->get('pr');
         $recipient = $request->get('recipient');
         $lessorName = $request->get('lessorName');
         $lessorNIN = $request->get('lessorNin');
         $lesseeName = $request->get('lesseeName');
         $lesseeNIN = $request->get('lesseeNin');
         $orNumber = $request->get('orNumber');
         $searchHistory = new SearchHistory();
         $searchHistory->setSerialNumber($serialNumber);
         $searchHistory->setLessorName($lessorName);
         $searchHistory->setLesseeName($lesseeName);
         $searchHistory->setLessorNin($lessorNIN);
         $searchHistory->setLesseeNin($lesseeNIN);
         $searchHistory->setUserId($session->get('userId'));
         $searchHistory->setOrNumber($orNumber);
         $searchHistory->setLandSituation($situationOfLand);
         $searchHistory->setType($code);
         $em->persist($searchHistory);
         $em->flush();
         $type = 'LE';
         $nType = 'LR';
         $searchProperties = $em->createQueryBuilder()->select('properties.id,properties.execution_date 	receipt_date,properties.execution_date,properties.lomp,properties.serial_number,properties.land_situation,properties.or_number,lessee.first_name as lesseeName,lessor.first_name as lessorName,lessee.nin as lesseeNIN,lessor.nin as lessorNIN,pr.first_name as prName,rp.first_name as rpName')->from('DRPAdminBundle:Book', 'properties')->leftJoin('DRPAdminBundle:Company', 'lessee', "WITH", "lessee.book_id=properties.id")->leftJoin('DRPAdminBundle:Company', 'lessor', "WITH", "lessor.book_id=properties.id")->leftJoin('DRPAdminBundle:Company', 'pr', "WITH", "pr.book_id=properties.id")->leftJoin('DRPAdminBundle:Company', 'rp', "WITH", "rp.book_id=properties.id")->where('properties.registration_type=:type')->setParameter('type', $code)->andwhere('properties.serial_number like :serialNumber')->setParameter('serialNumber', '%' . $serialNumber . '%')->andwhere('properties.land_situation like :land')->setParameter('land', '%' . $situationOfLand . '%')->andwhere('properties.or_number like :orNumber')->setParameter('orNumber', '%' . $orNumber . '%')->andwhere('lessee.first_name like :name')->setParameter('name', '%' . $lesseeName . '%')->andwhere('lessee.nin like :lnin')->setParameter('lnin', '%' . $lesseeNIN . '%')->andwhere('lessor.first_name like :fname')->setParameter('fname', '%' . $lessorName . '%')->andwhere('lessor.nin like :lessnin')->setParameter('lessnin', '%' . $lessorNIN . '%')->andwhere('lessee.type = :ltype')->setParameter('ltype', $nType)->andwhere('pr.type = :prtype')->setParameter('prtype', 'RP')->andwhere('rp.type = :rptype')->setParameter('rptype', 'PR')->andwhere('lessor.type = :lesType')->setParameter('lesType', $type)->getQuery()->getArrayResult();
         //echo"<pre>";print_r($searchProperties);die;
         $getType = $em->createQueryBuilder()->select('properties')->from('DRPAdminBundle:RegistrationType', 'properties')->where('properties.code=:code')->setParameter('code', $code)->setMaxResults(1)->getQuery()->getArrayResult();
         $type = $getType[0]['type'];
         //echo $type;die;
         $arrProperty = array();
         $arrAllProperties = array();
         if (is_array($searchProperties) && count($searchProperties) > 0) {
             $lessorFN = '';
             $lessorLN = '';
             $lessorTel1 = '';
             $lesseeFN = '';
             $lesseeLN = '';
             $partyRegistringFN = '';
             $partyRegistringLN = '';
             $recipientFN = '';
             $recipientLN = '';
             foreach ($searchProperties as $property) {
                 $arrProperty = $property;
                 $propertyDetail = $em->createQueryBuilder()->select('propertyDetail')->from('DRPAdminBundle:Company', 'propertyDetail')->where('propertyDetail.book_id=:bookId')->setParameter('bookId', $property['id'])->getQuery()->getArrayResult();
                 //echo"<pre>";print_r($propertyDetail);die;
                 foreach ($propertyDetail as $propertyObject) {
                     if ($propertyObject['type'] == 'LR') {
                         $lessorFN = $propertyObject['first_name'];
                         $lessorLN = $propertyObject['last_name'];
                         $lessorTel1 = $propertyObject['telephone1'];
                     }
                     if ($propertyObject['type'] == 'LE') {
                         $lesseeFN = $propertyObject['first_name'];
                         $lesseeLN = $propertyObject['last_name'];
                         $lesseeTel1 = $propertyObject['telephone1'];
                     }
                     if ($propertyObject['type'] == 'PR') {
                         $partyRegistringFN = $propertyObject['first_name'];
                         $partyRegistringLN = $propertyObject['last_name'];
                     }
                     if ($propertyObject['type'] == 'RP') {
                         $recipientFN = $propertyObject['first_name'];
                         $recipientLN = $propertyObject['last_name'];
                     }
                 }
             }
             $arrProperty['lessorFN'] = $lessorFN;
             $arrProperty['lessorLN'] = $lessorLN;
             $arrProperty['lessorTelephone1'] = $lessorTel1;
             $arrProperty['lesseeFN'] = $lesseeFN;
             $arrProperty['lesseeLN'] = $lesseeLN;
             $arrProperty['lesseeTelephone1'] = $lessorTel1;
             $arrProperty['partyRegistringFN'] = $partyRegistringFN;
             $arrProperty['partyRegistringLN'] = $partyRegistringLN;
             $arrProperty['recipientFN'] = $recipientFN;
             $arrProperty['recipientLN'] = $recipientLN;
             //echo"<pre>";print_r($arrProperty);die;
             array_push($arrAllProperties, $arrProperty);
             $session = $this->getRequest()->getSession();
             $currentSearches = $em->createQueryBuilder()->select('User')->from('DRPAdminBundle:User', 'User')->where('User.id=:Id')->setParameter('Id', $session->get('userId'))->getQuery()->getArrayResult();
             $balanceSearch = $currentSearches[0]['search_count_balance'] - 1;
             $usedSearch = $currentSearches[0]['search_count_used'] + 1;
             $updateBalanceSearch = $em->createQueryBuilder()->select('userPlan')->update('DRPAdminBundle:User', 'userPlan')->set('userPlan.search_count_balance', ':balance')->where('userPlan.id = :id')->setParameter('balance', $balanceSearch)->setParameter('id', $session->get('userId'))->getQuery()->getResult();
             $updateUsedSearch = $em->createQueryBuilder()->select('userPlan')->update('DRPAdminBundle:User', 'userPlan')->set('userPlan.search_count_used', ':Used')->where('userPlan.id = :id')->setParameter('Used', $usedSearch)->setParameter('id', $session->get('userId'))->getQuery()->getResult();
             $ipAddress = $_SERVER['REMOTE_ADDR'];
             $params['event'] = $this->getLogEventTitleAction('SEARCH');
             $params['description'] = $this->getLogEventDescriptionAction('SEARCH');
             $params['userId'] = $session->get('userId');
             $params['ipAddress'] = $ipAddress;
             $params['creatorId'] = $session->get('userId');
             $this->setLogAction($params);
         } else {
             $arrAllProperties = '';
         }
     }
     //echo "<PRE>";print_r($arrAllProperties);die;
     return $this->render('DRPUserBundle:Pages:searchLease.html.twig', array('properties' => $searchProperties, 'type' => $code, 'searchProperties' => $searchProperties, 'code' => $type));
 }
Ejemplo n.º 2
0
 public function resultGlobalLeaseAction(Request $request)
 {
     $session = $this->getRequest()->getSession();
     $em = $this->getDoctrine()->getEntityManager();
     if ($session->get('type') != 4) {
         return $this->redirect($this->generateUrl('user_home'));
     }
     if ($request->getMethod() == 'POST') {
         $serialNumber = ltrim($request->get('serialNumber'));
         $lomp = ltrim($request->get('lomp'));
         $lessor = ltrim($request->get('lessor'));
         $lessee = ltrim($request->get('lessee'));
         $situationOfLand = ltrim($request->get('sol'));
         $partyRegistring = ltrim($request->get('pr'));
         $recipient = ltrim($request->get('recipient'));
         $lessorName = ltrim($request->get('lessorName'));
         $lessorNIN = ltrim($request->get('lessorNin'));
         $lesseeName = ltrim($request->get('lesseeName'));
         $lesseeNIN = ltrim($request->get('lesseeNin'));
         $orNumber = ltrim($request->get('orNumber'));
         $searchHistory = new SearchHistory();
         $searchHistory->setSerialNumber($serialNumber);
         $searchHistory->setLessorName($lessorName);
         $searchHistory->setLesseeName($lesseeName);
         $searchHistory->setLessorNin($lessorNIN);
         $searchHistory->setLesseeNin($lesseeNIN);
         $searchHistory->setUserId($session->get('userId'));
         $searchHistory->setOrNumber($orNumber);
         $searchHistory->setLandSituation($situationOfLand);
         $em->persist($searchHistory);
         $em->flush();
         $type = 'LR';
         $nType = 'LE';
         $searchProperties = $em->createQueryBuilder()->select('properties.id,properties.execution_date,properties. 	receipt_date,properties.lomp,properties.serial_number,properties.land_situation,properties.or_number,lessee.first_name as lesseeName,lessee.last_name as lesseeLast,lessor.first_name as lessorName,lessor.last_name as lessorLast,lessee.nin as lesseeNIN,lessor.nin as lessorNIN,pr.first_name as prName,pr.last_name as prLast,rp.first_name as rpName,rp.last_name as rpLast,rp.nin as rpNIN,pr.nin as prNIN')->from('DRPAdminBundle:Book', 'properties')->leftJoin('DRPAdminBundle:Company', 'lessee', "WITH", "lessee.book_id=properties.id")->leftJoin('DRPAdminBundle:Company', 'lessor', "WITH", "lessor.book_id=properties.id")->leftJoin('DRPAdminBundle:Company', 'pr', "WITH", "pr.book_id=properties.id")->leftJoin('DRPAdminBundle:Company', 'rp', "WITH", "rp.book_id=properties.id")->andwhere('properties.serial_number like :serialNumber')->setParameter('serialNumber', '%' . $serialNumber . '%')->andwhere('properties.land_situation like :land')->setParameter('land', '%' . $situationOfLand . '%')->andwhere('properties.or_number like :orNumber')->setParameter('orNumber', '%' . $orNumber . '%')->andwhere('lessee.first_name like :name')->setParameter('name', '%' . $lesseeName . '%')->andwhere('lessee.nin like :lnin')->setParameter('lnin', '%' . $lesseeNIN . '%')->andwhere('lessor.first_name like :fname')->setParameter('fname', '%' . $lessorName . '%')->andwhere('lessor.nin like :lessnin')->setParameter('lessnin', '%' . $lessorNIN . '%')->andwhere('lessee.type = :ltype')->setParameter('ltype', $nType)->andwhere('pr.type = :prtype')->setParameter('prtype', 'PR')->andwhere('rp.type = :rptype')->setParameter('rptype', 'RP')->andwhere('lessor.type = :lesType')->setParameter('lesType', $type)->getQuery()->getArrayResult();
         if (is_array($searchProperties) && count($searchProperties) > 0) {
             $session = $this->getRequest()->getSession();
             $currentSearches = $em->createQueryBuilder()->select('User')->from('DRPAdminBundle:User', 'User')->where('User.id=:Id')->setParameter('Id', $session->get('userId'))->getQuery()->getArrayResult();
             $balanceSearch = $currentSearches[0]['search_count_balance'] - 1;
             $usedSearch = $currentSearches[0]['search_count_used'] + 1;
             $updateBalanceSearch = $em->createQueryBuilder()->select('userPlan')->update('DRPAdminBundle:User', 'userPlan')->set('userPlan.search_count_balance', ':balance')->where('userPlan.id = :id')->setParameter('balance', $balanceSearch)->setParameter('id', $session->get('userId'))->getQuery()->getResult();
             $updateUsedSearch = $em->createQueryBuilder()->select('userPlan')->update('DRPAdminBundle:User', 'userPlan')->set('userPlan.search_count_used', ':Used')->where('userPlan.id = :id')->setParameter('Used', $usedSearch)->setParameter('id', $session->get('userId'))->getQuery()->getResult();
         } else {
             $searchProperties = '';
         }
         $ipAddress = $_SERVER['REMOTE_ADDR'];
         $params['event'] = $this->getLogEventTitleAction('SEARCH');
         $params['description'] = $this->getLogEventDescriptionAction('SEARCH');
         $params['userId'] = $session->get('userId');
         $params['ipAddress'] = $ipAddress;
         $params['creatorId'] = $session->get('userId');
         $this->setLogAction($params);
         return $this->render('DRPUserBundle:Pages:globalResultLease.html.twig', array('searchProperties' => $searchProperties));
     }
     $searchProperties = '';
     return $this->render('DRPUserBundle:Pages:globalResultLease.html.twig', array('searchProperties' => $searchProperties));
 }