Example #1
0
 public function addDRBAction(Request $request)
 {
     $session = $this->getRequest()->getSession();
     if ($session->get('type') != 1) {
         //if user is login then it will be redirect to login page
         return $this->redirect($this->generateUrl('drp_adminLogin'));
     }
     $number = $session->get('number');
     $code = $_REQUEST['code'];
     $em = $this->getDoctrine()->getEntityManager();
     $lastTransaction = $em->createQueryBuilder()->select('book')->from('DRPAdminBundle:Book', 'book')->addOrderBy('book.id', 'DESC')->setMaxResults(1)->getQuery()->getArrayResult();
     $getType = $em->getRepository('DRPAdminBundle:RegistrationType')->findOneBy(array('code' => $code));
     $registrationType = $em->createQueryBuilder()->select('reg')->from('DRPAdminBundle:RegistrationType', 'reg')->getQuery()->getResult();
     $InstrumentType = $em->createQueryBuilder()->select('reg')->from('DRPAdminBundle:GlobalInstrument', 'reg')->getQuery()->getResult();
     if ($request->getMethod() == 'POST') {
         $note = $request->get('notes');
         $registrationType = $request->get('rtype');
         $serialNumber = $request->get('serialNumber');
         $dateOfReciept = $request->get('drp');
         $situationOfLand = $request->get('sof');
         $dateOfExecution = $request->get('doe');
         $grantor = $request->get('grantor');
         $grantee = $request->get('grantee');
         $rir = $request->get('rir');
         $noi = $request->get('noi');
         $stampDuty = $request->get('sd');
         $orNumber = $request->get('or');
         $recipient = $request->get('recipient');
         $partyRegistring = $request->get('pr');
         $registrarGenralIntials = $request->get('rgi');
         $reciepientDate = $request->get('recipientDate');
         //echo $reciepientDate;die;
         /*$serialNumber = $request->get('sr');
         				$lomp = $request->get('lomp');
         				$lessor = $request->get('lessor');
         				$lease = $request->get('lease');
         	
         				$rd = $request->get('rd');*/
         $company = $request->get('company');
         $firstName = $request->get('firstname');
         $middleName = $request->get('middlename');
         $lastName = $request->get('lastname');
         $nin = $request->get('nin');
         $dob = $request->get('dob');
         $address = $request->get('address');
         $email = $request->get('email');
         $telephone1 = $request->get('tel1');
         $telephone2 = $request->get('tel2');
         $companyLs = $request->get('company1');
         $firstNameLs = $request->get('firstname1');
         $middleNameLs = $request->get('middlename1');
         $lastNameLs = $request->get('lastname1');
         $ninLs = $request->get('nin1');
         $dobLs = $request->get('dob1');
         $addressLs = $request->get('address1');
         $emailLs = $request->get('email1');
         $telephone1Ls = $request->get('tel11');
         $telephone2Ls = $request->get('tel21');
         $companyLs2 = $request->get('company2');
         $firstNameLs2 = $request->get('firstname2');
         $middleNameLs2 = $request->get('middlename2');
         $lastNameLs2 = $request->get('lastname2');
         $ninLs2 = $request->get('nin2');
         $dobLs2 = $request->get('dob2');
         $addressLs2 = $request->get('address2');
         $emailLs2 = $request->get('email2');
         $telephone1Ls2 = $request->get('tel112');
         $telephone2Ls2 = $request->get('tel212');
         $companyLe = $request->get('Lcompany');
         $firstNameLe = $request->get('Lfirstname');
         $middleNameLe = $request->get('Lmiddlename');
         $lastNameLe = $request->get('Llastname');
         $ninLe = $request->get('Lnin');
         $dobLe = $request->get('Ldob');
         $addressLe = $request->get('Laddress');
         $emailLe = $request->get('Lemail');
         $telephone1Le = $request->get('Ltel1');
         $telephone2Le = $request->get('Ltel2');
         $companyLe1 = $request->get('Lcompany1');
         $firstNameLe1 = $request->get('Lfirstname1');
         $middleNameLe1 = $request->get('Lmiddlename1');
         $lastNameLe1 = $request->get('Llastname1');
         $ninLe1 = $request->get('Lnin1');
         $dobLe1 = $request->get('Ldob1');
         $addressLe1 = $request->get('Laddress1');
         $emailLe1 = $request->get('Lemail1');
         $telephone1Le1 = $request->get('Ltel11');
         $telephone2Le1 = $request->get('Ltel2');
         $companyLe2 = $request->get('Lcompany2');
         $firstNameLe2 = $request->get('Lfirstname2');
         $middleNameLe2 = $request->get('Lmiddlename2');
         $lastNameLe2 = $request->get('Llastname2');
         $ninLe2 = $request->get('Lnin2');
         $dobLe2 = $request->get('Ldob2');
         $addressLe2 = $request->get('Laddress2');
         $emailLe2 = $request->get('Lemail2');
         $telephone1Le2 = $request->get('Ltel12');
         $telephone2Le2 = $request->get('Ltel22');
         $companyPR = $request->get('companynamePR');
         $firstNamePR = $request->get('firstnamePR');
         $middleNamePR = $request->get('middlenamePR');
         $lastNamePR = $request->get('lastnamePR');
         $ninPR = $request->get('ninPR');
         $dobPR = $request->get('dobPR');
         //echo $dobPR ;die;
         $addressPR = $request->get('addressPR');
         $emailPR = $request->get('emailPR');
         $telephone1PR = $request->get('tel1PR');
         $telephone2PR = $request->get('tel2PR');
         $companyPR1 = $request->get('companyNamePR1');
         $firstNamePR1 = $request->get('firstNamePR1');
         $middleNamePR1 = $request->get('middleNamePR1');
         $lastNamePR1 = $request->get('lastNamePR1');
         $ninPR1 = $request->get('ninPR1');
         $dobPR1 = $request->get('dobPR1');
         $addressPR1 = $request->get('addressPR1');
         $emailPR1 = $request->get('emailPR1');
         $telephone1PR1 = $request->get('tel1PR1');
         $telephone2PR1 = $request->get('tel2PR1');
         $companyPR2 = $request->get('companyNamePR2');
         $firstNamePR2 = $request->get('firstNamePR2');
         $middleNamePR2 = $request->get('middleNamePR2');
         $lastNamePR2 = $request->get('lastNamePR2');
         $ninPR2 = $request->get('ninPR2');
         $dobPR2 = $request->get('dobPR2');
         $addressPR2 = $request->get('addressPR2');
         $emailPR2 = $request->get('emailPR2');
         $telephone1PR2 = $request->get('tel1PR2');
         $telephone2PR2 = $request->get('tel2PR2');
         $companyRP = $request->get('companynameRP');
         $firstNameRP = $request->get('firstnameRP');
         $middleNameRP = $request->get('middlenameRP');
         $lastNameRP = $request->get('lastnameRP');
         $ninRP = $request->get('ninRP');
         $dobRP = $request->get('dobRP');
         $addressRP = $request->get('addressRP');
         $emailRP = $request->get('emailRP');
         $telephone1RP = $request->get('tel1RP');
         $telephone2RP = $request->get('tel2RP');
         $addProperty = new Book();
         $addProperty->setRegistrationType($code);
         $addProperty->setNote($note);
         $addProperty->setReceiptDate($dateOfReciept);
         $addProperty->setExecutionDate($dateOfExecution);
         //$addProperty->setLomp($lomp);
         //$addProperty->setLessor($lessor);
         $addProperty->setGrantor($grantor);
         $addProperty->setGrantee($grantee);
         $addProperty->setStampDuty($stampDuty);
         $addProperty->setOrNumber($orNumber);
         $addProperty->setRecipient($recipient);
         $addProperty->setInstrumentType($noi);
         $addProperty->setRecipientDate($reciepientDate);
         $addProperty->setRegistrarGeneralInitial($registrarGenralIntials);
         $addProperty->setLandSituation($situationOfLand);
         $addProperty->setSerialNumber($serialNumber);
         $newReferenceNumber = $request->get('hidRegNumber');
         //echo $newReferenceNumber;die;
         $addProperty->setReferenceNumber($newReferenceNumber);
         $addProperty->setReferenceInRegister($rir);
         $addProperty->setRegisteringParty($partyRegistring);
         $em->persist($addProperty);
         $em->flush();
         $bookId = $addProperty->getId();
         $registrationStatus = new RegistrationStatus();
         $registrationStatus->setBookId($bookId);
         $registrationStatus->setStatus(0);
         $registrationStatus->setPropertyType('drb');
         $em->persist($registrationStatus);
         $em->flush();
         $addLessor = new Company();
         $addLessor->setCompanyName($company);
         $addLessor->setFirstName($firstName);
         $addLessor->setMiddleName($middleName);
         $addLessor->setLastName($lastName);
         $addLessor->setNin($nin);
         $addLessor->setTelephone1($telephone1);
         $addLessor->setTelephone2($telephone2);
         $addLessor->setDob($dob);
         $addLessor->setAddress($address);
         $addLessor->setType('GR');
         $addLessor->setEmail($email);
         $addLessor->setBookId($bookId);
         $em->persist($addLessor);
         $em->flush();
         if ($firstNameLs || $firstNameLs != "") {
             $addGrantor1 = new Company();
             $addGrantor1->setCompanyName($companyLs);
             $addGrantor1->setFirstName($firstNameLs);
             $addGrantor1->setMiddleName($middleNameLs);
             $addGrantor1->setLastName($lastNameLs);
             $addGrantor1->setNin($ninLs);
             $addGrantor1->setTelephone1($telephone1Ls);
             $addGrantor1->setTelephone2($telephone2Ls);
             $addGrantor1->setDob($dobLs);
             $addGrantor1->setAddress($addressLs);
             $addGrantor1->setType('GR');
             $addGrantor1->setEmail($emailLs);
             $addGrantor1->setBookId($bookId);
             $em->persist($addGrantor1);
             $em->flush();
             $addGrantor2 = new Company();
             $addGrantor2->setCompanyName($companyLs2);
             $addGrantor2->setFirstName($firstNameLs2);
             $addGrantor2->setMiddleName($middleNameLs2);
             $addGrantor2->setLastName($lastNameLs2);
             $addGrantor2->setNin($ninLs2);
             $addGrantor2->setTelephone1($telephone1Ls2);
             $addGrantor2->setTelephone2($telephone2Ls2);
             $addGrantor2->setDob($dobLs2);
             $addGrantor2->setAddress($addressLs2);
             $addGrantor2->setType('GR');
             $addGrantor2->setEmail($emailLs2);
             $addGrantor2->setBookId($bookId);
             $em->persist($addGrantor2);
             $em->flush();
         }
         $addNewLease = new Company();
         $addNewLease->setCompanyName($companyLe);
         $addNewLease->setFirstName($firstNameLe);
         $addNewLease->setMiddleName($middleNameLe);
         $addNewLease->setLastName($lastNameLe);
         $addNewLease->setNin($ninLe);
         $addNewLease->setTelephone1($telephone1Le);
         $addNewLease->setTelephone2($telephone2Le);
         $addNewLease->setDob($dobLe);
         $addNewLease->setAddress($addressLe);
         $addNewLease->setEmail($emailLe);
         $addNewLease->setBookId($bookId);
         $addNewLease->setType('GE');
         $em->persist($addNewLease);
         $em->flush();
         if ($firstNameLe1 || $firstNameLe2 != "") {
             $addNewGrantee1 = new Company();
             $addNewGrantee1->setCompanyName($companyLe1);
             $addNewGrantee1->setFirstName($firstNameLe1);
             $addNewGrantee1->setMiddleName($middleNameLe1);
             $addNewGrantee1->setLastName($lastNameLe1);
             $addNewGrantee1->setNin($ninLe1);
             $addNewGrantee1->setTelephone1($telephone1Le1);
             $addNewGrantee1->setTelephone2($telephone2Le1);
             $addNewGrantee1->setDob($dobLe1);
             $addNewGrantee1->setAddress($addressLe1);
             $addNewGrantee1->setEmail($emailLe1);
             $addNewGrantee1->setBookId($bookId);
             $addNewGrantee1->setType('GE');
             $em->persist($addNewGrantee1);
             $em->flush();
             $addNewGrantee2 = new Company();
             $addNewGrantee2->setCompanyName($companyLe2);
             $addNewGrantee2->setFirstName($firstNameLe2);
             $addNewGrantee2->setMiddleName($middleNameLe2);
             $addNewGrantee2->setLastName($lastNameLe2);
             $addNewGrantee2->setNin($ninLe2);
             $addNewGrantee2->setTelephone1($telephone1Le2);
             $addNewGrantee2->setTelephone2($telephone2Le2);
             $addNewGrantee2->setDob($dobLe2);
             $addNewGrantee2->setAddress($addressLe2);
             $addNewGrantee2->setEmail($emailLe2);
             $addNewGrantee2->setBookId($bookId);
             $addNewGrantee2->setType('GE');
             $em->persist($addNewGrantee2);
             $em->flush();
         }
         $addPartyRegistring = new Company();
         $addPartyRegistring->setCompanyName($companyPR);
         $addPartyRegistring->setFirstName($firstNamePR);
         $addPartyRegistring->setMiddleName($middleNamePR);
         $addPartyRegistring->setLastName($lastNamePR);
         $addPartyRegistring->setNin($ninPR);
         $addPartyRegistring->setTelephone1($telephone1PR);
         $addPartyRegistring->setTelephone2($telephone2PR);
         $addPartyRegistring->setDob($dobPR);
         $addPartyRegistring->setAddress($addressPR);
         $addPartyRegistring->setEmail($emailPR);
         $addPartyRegistring->setBookId($bookId);
         $addPartyRegistring->setType('PR');
         $em->persist($addPartyRegistring);
         $em->flush();
         if ($firstNamePR1 || $firstNamePR2 != "") {
             $addPartyRegistring1 = new Company();
             $addPartyRegistring1->setCompanyName($companyPR1);
             $addPartyRegistring1->setFirstName($firstNamePR1);
             $addPartyRegistring1->setMiddleName($middleNamePR1);
             $addPartyRegistring1->setLastName($lastNamePR1);
             $addPartyRegistring1->setNin($ninPR1);
             $addPartyRegistring1->setTelephone1($telephone1PR1);
             $addPartyRegistring1->setTelephone2($telephone2PR1);
             $addPartyRegistring1->setDob($dobPR1);
             $addPartyRegistring1->setAddress($addressPR1);
             $addPartyRegistring->setEmail($emailPR1);
             $addPartyRegistring1->setBookId($bookId);
             $addPartyRegistring1->setType('PR');
             $em->persist($addPartyRegistring1);
             $em->flush();
             $addPartyRegistring2 = new Company();
             $addPartyRegistring2->setCompanyName($companyPR2);
             $addPartyRegistring2->setFirstName($firstNamePR2);
             $addPartyRegistring2->setMiddleName($middleNamePR2);
             $addPartyRegistring2->setLastName($lastNamePR2);
             $addPartyRegistring2->setNin($ninPR2);
             $addPartyRegistring2->setTelephone1($telephone1PR2);
             $addPartyRegistring2->setTelephone2($telephone2PR2);
             $addPartyRegistring2->setDob($dobPR2);
             $addPartyRegistring2->setAddress($addressPR2);
             $addPartyRegistring2->setEmail($emailPR2);
             $addPartyRegistring2->setBookId($bookId);
             $addPartyRegistring2->setType('PR');
             $em->persist($addPartyRegistring2);
             $em->flush();
         }
         $addRecipient = new Company();
         $addRecipient->setFirstName($firstNameRP);
         $addRecipient->setCompanyName($companyRP);
         $addRecipient->setMiddleName($middleNameRP);
         $addRecipient->setLastName($lastNameRP);
         $addRecipient->setNin($ninRP);
         $addRecipient->setTelephone1($telephone1RP);
         $addRecipient->setTelephone2($telephone2RP);
         $addRecipient->setDob($dobRP);
         $addRecipient->setAddress($addressRP);
         $addRecipient->setEmail($emailRP);
         $addRecipient->setType('RP');
         $addRecipient->setBookId($bookId);
         $em->persist($addRecipient);
         $em->flush();
         $ipAddress = $_SERVER['REMOTE_ADDR'];
         $params['event'] = $this->getLogEventTitleAction('ADD_DRB');
         $params['description'] = $this->getLogEventDescriptionAction('ADD_DRB');
         $params['userId'] = $session->get('userId');
         $params['ipAddress'] = $ipAddress;
         $params['creatorId'] = $session->get('userId');
         $this->setLogAction($params);
         return $this->redirect($this->generateUrl('drp_showpdrb', array('code' => $code, 'number' => $number)));
     }
     return $this->render('DRPAdminBundle:Pages:addDrb.html.twig', array('registrationType' => $registrationType, 'instrumentType' => $InstrumentType, 'getType' => $getType));
 }