Пример #1
0
 public function resultDRBAction(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');
         $ref = $request->get('ref');
         $serialNumber = $request->get('serialNumber');
         $grantorName = $request->get('grantorName');
         $grantorNIN = $request->get('grantorNIN');
         $granteeName = $request->get('granteeName');
         //echo $granteeName ;die;
         $granteeNIN = $request->get('granteeNIN');
         $orNumber = $request->get('orNumber');
         $searchHistory = new SearchHistory();
         $searchHistory->setReferenceNumber($ref);
         $searchHistory->setSerialNumber($serialNumber);
         $searchHistory->setGrantorName($grantorName);
         $searchHistory->setGranteeNin($granteeNIN);
         $searchHistory->setUserId($session->get('userId'));
         $searchHistory->setGranteeName($granteeName);
         $searchHistory->setGrantorNin($grantorNIN);
         $searchHistory->setOrNumber($orNumber);
         $searchHistory->setType($code);
         $em->persist($searchHistory);
         $em->flush();
         $type = 'GR';
         $nType = 'GE';
         $searchProperties = $em->createQueryBuilder()->select('rType.type,properties.id,properties.reference_number,properties.execution_date 	receipt_date,properties.execution_date,properties.lomp,properties.serial_number,properties.land_situation,properties.or_number,grantee.first_name as granteeName,grantor.first_name as grantorName,grantee.nin as granteeNIN,grantor.nin as grantorNIN,pr.first_name as prName,rp.first_name as rpName')->from('DRPAdminBundle:Book', 'properties')->leftJoin('DRPAdminBundle:GlobalInstrument', 'rType', "WITH", "rType.id=properties.instrument_type")->leftJoin('DRPAdminBundle:Company', 'grantor', "WITH", "grantor.book_id=properties.id")->leftJoin('DRPAdminBundle:Company', 'grantee', "WITH", "grantee.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.or_number like :orNumber')->setParameter('orNumber', '%' . $orNumber . '%')->andwhere('grantor.first_name like :name')->setParameter('name', '%' . $grantorName . '%')->andwhere('grantor.nin like :lessnin')->setParameter('lessnin', '%' . $grantorNIN . '%')->andwhere('grantee.first_name like :fname')->setParameter('fname', '%' . $granteeName . '%')->andwhere('grantee.nin like :lnin')->setParameter('lnin', '%' . $granteeNIN . '%')->andwhere('grantee.type = :ltype')->setParameter('ltype', $nType)->andwhere('pr.type = :prtype')->setParameter('prtype', 'RP')->andwhere('rp.type = :rptype')->setParameter('rptype', 'PR')->andwhere('grantor.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"<pre>";print_r($searchProperties);die;
         $instrumentType = $em->createQueryBuilder()->select('instrument')->from('DRPAdminBundle:GlobalInstrument', 'instrument')->getQuery()->getArrayResult();
         //echo"<pre>";print_r($searchProperties);die;
         //echo"<pre>";print_r($code);die;
         $arrProperty = array();
         $arrAllProperties = array();
         if (is_array($searchProperties) && count($searchProperties) > 0) {
             $grantorFN = '';
             $grantorLN = '';
             $grantortel1 = '';
             $granteeFN = '';
             $granteeLN = '';
             $granteetel1 = '';
             $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();
                 foreach ($propertyDetail as $propertyObject) {
                     if ($propertyObject['type'] == 'GR') {
                         $grantorFN = $propertyObject['first_name'];
                         $grantorLN = $propertyObject['last_name'];
                         $grantortel1 = $propertyObject['telephone1'];
                     }
                     //echo $lessorFN;die;
                     if ($propertyObject['type'] == 'GE') {
                         $granteeFN = $propertyObject['first_name'];
                         $granteeLN = $propertyObject['last_name'];
                         $granteetel1 = $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['grantorFN'] = $grantorFN;
             $arrProperty['grantorLN'] = $grantorLN;
             $arrProperty['grantortel1'] = $grantortel1;
             $arrProperty['granteeFN'] = $granteeFN;
             $arrProperty['granteeLN'] = $granteeLN;
             $arrProperty['granteetel1'] = $granteetel1;
             $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 = '';
         }
     }
     return $this->render('DRPUserBundle:Pages:searchDrb.html.twig', array('properties' => $searchProperties, 'type' => $code, 'searchProperties' => $arrAllProperties, 'code' => $type, 'instrumentType' => $instrumentType));
 }
Пример #2
0
 public function resultGlobalDRBAction(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') {
         $ref = ltrim($request->get('ref'));
         $serialNumber = ltrim($request->get('serialNumber'));
         $grantorName = ltrim($request->get('grantorName'));
         $grantorNIN = ltrim($request->get('grantorNIN'));
         $granteeName = ltrim($request->get('granteeName'));
         $granteeNIN = $request->get('granteeNIN');
         $orNumber = $request->get('orNumber');
         $searchHistory = new SearchHistory();
         $searchHistory->setReferenceNumber($ref);
         $searchHistory->setSerialNumber($serialNumber);
         $searchHistory->setGrantorName($grantorName);
         $searchHistory->setGranteeNin($granteeNIN);
         $searchHistory->setUserId($session->get('userId'));
         $searchHistory->setGranteeName($granteeName);
         $searchHistory->setGrantorNin($grantorNIN);
         $searchHistory->setOrNumber($orNumber);
         $em->persist($searchHistory);
         $em->flush();
         $type = 'GR';
         $nType = 'GE';
         $searchProperties = $em->createQueryBuilder()->select('rType.type,properties.id,properties.reference_number,properties.execution_date 	receipt_date,properties.execution_date,properties.lomp,properties.serial_number,properties.land_situation,properties.or_number,grantee.first_name as granteeName,grantee.last_name as granteeLast,grantor.first_name as grantorName,grantor.last_name as grantorLast,grantee.nin as granteeNIN,grantor.nin as grantorNIN,pr.first_name as prName,pr.last_name as prLast,pr.nin as prNIN,rp.first_name as rpName,rp.last_name as rpLast,rp.nin as rpNIN')->from('DRPAdminBundle:Book', 'properties')->leftJoin('DRPAdminBundle:GlobalInstrument', 'rType', "WITH", "rType.id=properties.instrument_type")->leftJoin('DRPAdminBundle:Company', 'grantor', "WITH", "grantor.book_id=properties.id")->leftJoin('DRPAdminBundle:Company', 'grantee', "WITH", "grantee.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.reference_number like :reference')->setParameter('reference', '%' . $ref . '%')->andwhere('properties.or_number like :orNumber')->setParameter('orNumber', '%' . $orNumber . '%')->andwhere('grantor.first_name like :name')->setParameter('name', '%' . $grantorName . '%')->andwhere('grantor.nin like :lessnin')->setParameter('lessnin', '%' . $grantorNIN . '%')->andwhere('grantee.first_name like :fname')->setParameter('fname', '%' . $granteeName . '%')->andwhere('grantee.nin like :lnin')->setParameter('lnin', '%' . $granteeNIN . '%')->andwhere('grantee.type = :ltype')->setParameter('ltype', $nType)->andwhere('pr.type = :prtype')->setParameter('prtype', 'PR')->andwhere('rp.type = :rptype')->setParameter('rptype', 'RP')->andwhere('grantor.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:resultGlobalDRB.html.twig', array('searchProperties' => $searchProperties));
     }
     $searchProperties = '';
     return $this->render('DRPUserBundle:Pages:resultGlobalDRB.html.twig', array('searchProperties' => $searchProperties));
 }