Exemplo n.º 1
0
 public function importDataAction(Request $request)
 {
     $em = $this->getDoctrine()->getEntityManager();
     $link = mysql_connect('localhost', 'root', 'root');
     if (!$link) {
         die('Could not connect: ' . mysql_error());
     } else {
         mysql_select_db('sample_drp');
         $queryData = "select * from Provincial_Lease";
         $resultData = mysql_query($queryData, $link);
         $arrData = array();
         while ($rowData = mysql_fetch_Array($resultData, MYSQL_ASSOC)) {
             $arrData[] = $rowData;
             //echo"<pre>";print_r($arrData);die;
             $propertyData = new Book();
             $propertyData->SetSerialNumber($rowData['Serial_registration']);
             //$propertyData->SetReferenceNumber($arrCells[0]);
             $propertyData->SetExecutionDate($rowData['Date_of_execution']);
             $propertyData->SetReceiptDate($rowData['Date_of_receipt']);
             $propertyData->SetLandSituation($rowData['Situation_of_land']);
             $propertyData->SetOrNumber($rowData['O_R_Number']);
             $propertyData->SetStampDuty($rowData['Stamp_duty']);
             $propertyData->SetLomp($rowData['LOMP']);
             $propertyData->SetRegistrationType('PL');
             $em->persist($propertyData);
             $em->flush();
             $id = $propertyData->getId();
             $companyDataGR = new Company();
             $companyDataGR->SetFirstName($rowData['Lessor_fname']);
             $companyDataGR->SetLastName($rowData['Lessor_lname']);
             $companyDataGR->SetNin($rowData['Lessor_NIN']);
             $companyDataGR->SetDob($rowData['Lessor_DOB']);
             $companyDataGR->SetTelephone1($rowData['Lessor_tel1']);
             $companyDataGR->SetEmail($rowData['Lessor_email']);
             $companyDataGR->SetAddress($rowData['Lessor_Address']);
             $companyDataGR->SetTelephone2($rowData['Lessor_tel2']);
             $companyDataGR->SetBookId($id);
             $companyDataGR->SetType('LR');
             $em->persist($companyDataGR);
             $em->flush();
             $companyDataGE = new Company();
             $companyDataGE->SetFirstName($rowData['Lessee_fname']);
             $companyDataGE->SetLastName($rowData['lessee_lname']);
             $companyDataGE->SetNin($rowData['Lessee_NIN']);
             $companyDataGE->SetDob($rowData['Lessee_DOB']);
             $companyDataGE->SetTelephone1($rowData['Lessee_tel1']);
             $companyDataGE->SetEmail($rowData['lessee_email']);
             $companyDataGE->SetTelephone2($rowData['Lessee_tel2']);
             $companyDataGE->SetAddress($rowData['Lessee_address']);
             $companyDataGE->SetBookId($id);
             $companyDataGE->SetType('LE');
             $em->persist($companyDataGE);
             $em->flush();
             $companyDataPR = new Company();
             $companyDataPR->SetFirstName($rowData['PR_fname']);
             $companyDataPR->SetLastName($rowData['PR_lname']);
             $companyDataPR->SetNin($rowData['PR_NIN']);
             $companyDataPR->SetDob($rowData['PR_DOB']);
             $companyDataPR->SetTelephone1($rowData['PR_tel1']);
             $companyDataPR->SetEmail($rowData['PR_email']);
             $companyDataPR->SetTelephone2($rowData['PR_tel2']);
             $companyDataPR->SetAddress($rowData['PR_address']);
             $companyDataPR->SetBookId($id);
             $companyDataPR->SetType('PR');
             $em->persist($companyDataPR);
             $em->flush();
             $companyDataRP = new Company();
             $companyDataRP->SetFirstName($rowData['Recipient_fname']);
             $companyDataRP->SetLastName($rowData['recipient_lname']);
             $companyDataRP->SetNin($rowData['recipient_NIN']);
             $companyDataRP->SetDob($rowData['recipient_DOB']);
             $companyDataRP->SetTelephone1($rowData['recipient_tel1']);
             $companyDataRP->SetEmail($rowData['recipient_email']);
             $companyDataRP->SetTelephone2($rowData['recipient_tel2']);
             $companyDataRP->SetAddress($rowData['recipient_address']);
             $companyDataRP->SetBookId($id);
             $companyDataRP->SetType('RP');
             $em->persist($companyDataRP);
             $em->flush();
             $status = new RegistrationStatus();
             $status->SetStatus(0);
             $status->SetPropertyType('lease');
             $status->SetBookId($id);
             $em->persist($status);
             $em->flush();
         }
     }
     mysql_close($link);
     if ($request->getMethod() == 'POST') {
         if (is_uploaded_file($_FILES['file']['tmp_name'])) {
             //readfile($_FILES['file']['tmp_name']);
         }
         $i = 0;
         $handle = fopen($_FILES['file']['tmp_name'], "r");
         while (($data = fgetcsv($handle, 10000000, ",")) !== FALSE) {
             if ($i > 2) {
                 $arrCells = explode(',', $data[0]);
                 echo "<pre>";
                 print_r($arrCells);
                 die;
             }
             $i++;
         }
     }
     return $this->render('DRPAdminBundle:Pages:importData.html.twig');
 }
 public function addLeaseAction(Request $request)
 {
     $session = $this->getRequest()->getSession();
     if ($session->get('type') != 3) {
         //if user is login then it will be redirect to login page
         return $this->redirect($this->generateUrl('registrarAdmin_adminLogin'));
     }
     $code = $_REQUEST['code'];
     $session = $this->getRequest()->getSession();
     $number = $session->get('number');
     $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));
     //echo"<pre>";print_r($getType);die;
     $registrationType = $em->createQueryBuilder()->select('reg')->from('DRPAdminBundle:RegistrationType', 'reg')->getQuery()->getResult();
     //$type = $_SERVER['HTTP_REFERER'];
     //$newType=explode('/',$type);
     //echo "<pre>";print_r($newType);die;
     if ($request->getMethod() == 'POST') {
         //echo "<pre>";print_r($_POST);die;
         $note = $request->get('notes');
         $registrationType = $request->get('rtype');
         $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;
         $lomp = $request->get('lomp');
         $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');
         $checkForm = $request->get('typeform');
         $checkForm2 = $request->get('typeform2');
         $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');
         $addressPR = $request->get('addressPR');
         $emailPR = $request->get('emailPR');
         $telephone1PR = $request->get('tel1PR');
         $telephone2PR = $request->get('tel2PR');
         $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');
         //$lessor = $request->get('lessor');
         //$lease = $request->get('lease');
         //$rd = $request->get('rd');
         $addLease = new Book();
         $addLease->setRegistrationType($code);
         $addLease->setReceiptDate($dateOfReciept);
         $addLease->setExecutionDate($dateOfExecution);
         $addLease->setLomp($lomp);
         $addLease->setNote($note);
         //$addLease->setLessor($lessor);
         //$addLease->setLessee($lease);
         //$addProperty->setGrantor($grantor);
         //$addProperty->setGrantee($grantee);
         $addLease->setStampDuty($stampDuty);
         $addLease->setOrNumber($orNumber);
         $addLease->setRecipient($recipient);
         //$addProperty->setInstrumentType($noi);
         $addLease->setRecipientDate($reciepientDate);
         $addLease->setRegistrarGeneralInitial($registrarGenralIntials);
         $addLease->setLandSituation($situationOfLand);
         $newSerialNumber = $request->get('hidRegNumber');
         //echo $newReferenceNumber;die;
         $addLease->setSerialNumber($newSerialNumber);
         //$addProperty->setReferenceInRegister($rir);
         $addLease->setRegisteringParty($partyRegistring);
         $em->persist($addLease);
         $em->flush();
         $bookId = $addLease->getId();
         $registrationStatus = new RegistrationStatus();
         $registrationStatus->setBookId($bookId);
         $registrationStatus->setStatus(0);
         $registrationStatus->setPropertyType('lease');
         $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->setBookId($bookId);
         $addLessor->setType('LR');
         $addLessor->setEmail($email);
         $em->persist($addLessor);
         $em->flush();
         if ($firstNameLs || $firstNameLs2 != "") {
             $addLessor1 = new Company();
             $addLessor1->setCompanyName($companyLs);
             $addLessor1->setFirstName($firstNameLs);
             $addLessor1->setMiddleName($middleNameLs);
             $addLessor1->setLastName($lastNameLs);
             $addLessor1->setNin($ninLs);
             $addLessor1->setTelephone1($telephone1Ls);
             $addLessor1->setTelephone2($telephone2Ls);
             $addLessor1->setDob($dobLs);
             $addLessor1->setAddress($addressLs);
             $addLessor1->setType('LR');
             $addLessor1->setEmail($emailLs);
             $addLessor1->setBookId($bookId);
             $em->persist($addLessor1);
             $em->flush();
             $addLessor2 = new Company();
             $addLessor2->setCompanyName($companyLs2);
             $addLessor2->setFirstName($firstNameLs2);
             $addLessor2->setMiddleName($middleNameLs2);
             $addLessor2->setLastName($lastNameLs2);
             $addLessor2->setNin($ninLs2);
             $addLessor2->setTelephone1($telephone1Ls2);
             $addLessor2->setTelephone2($telephone2Ls2);
             $addLessor2->setDob($dobLs2);
             $addLessor2->setAddress($addressLs2);
             $addLessor2->setType('LR');
             $addLessor2->setEmail($emailLs2);
             $addLessor2->setBookId($bookId);
             $em->persist($addLessor2);
             $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('LE');
         $em->persist($addNewLease);
         $em->flush();
         if ($firstNameLe1 || $firstNameLe2 != "") {
             $addNewLease1 = new Company();
             $addNewLease1->setCompanyName($companyLe1);
             $addNewLease1->setFirstName($firstNameLe1);
             $addNewLease1->setMiddleName($middleNameLe1);
             $addNewLease1->setLastName($lastNameLe1);
             $addNewLease1->setNin($ninLe1);
             $addNewLease1->setTelephone1($telephone1Le1);
             $addNewLease1->setTelephone2($telephone2Le1);
             $addNewLease1->setDob($dobLe1);
             $addNewLease1->setAddress($addressLe1);
             $addNewLease1->setEmail($emailLe1);
             $addNewLease1->setBookId($bookId);
             $addNewLease1->setType('LE');
             $em->persist($addNewLease1);
             $em->flush();
             $addNewLease2 = new Company();
             $addNewLease2->setCompanyName($companyLe2);
             $addNewLease2->setFirstName($firstNameLe2);
             $addNewLease2->setMiddleName($middleNameLe2);
             $addNewLease2->setLastName($lastNameLe2);
             $addNewLease2->setNin($ninLe2);
             $addNewLease2->setTelephone1($telephone1Le2);
             $addNewLease2->setTelephone2($telephone2Le2);
             $addNewLease2->setDob($dobLe2);
             $addNewLease2->setAddress($addressLe2);
             $addNewLease2->setEmail($emailLe2);
             $addNewLease2->setBookId($bookId);
             $addNewLease2->setType('LE');
             $em->persist($addNewLease2);
             $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->setType('PR');
         $addPartyRegistring->setBookId($bookId);
         $em->persist($addPartyRegistring);
         $em->flush();
         $addRecipient = new Company();
         $addRecipient->setFirstName($firstNameRP);
         $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_LEASE');
         $params['description'] = $this->getLogEventDescriptionAction('ADD_LEASE');
         $params['userId'] = $session->get('userId');
         $params['ipAddress'] = $ipAddress;
         $params['creatorId'] = $session->get('userId');
         $this->setLogAction($params);
         return $this->redirect($this->generateUrl('registrarAdmin_showLease', array('code' => $code, 'number' => $number)));
     }
     return $this->render('DRPRegistrarAdminBundle:Pages:addLease.html.twig', array('registrationType' => $registrationType, 'getType' => $getType));
 }