public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('intCreditAmount', 'hidden', array('data' => $this->getCredit()->getCreditAmount())); $builder->add('intRepaymentTime', 'hidden', array('data' => $this->getCredit()->getReplaymentTime())); $builder->add('intRepaymentMethod', 'choice', array('choices' => \App\FrontendBundle\Utils\Session\CreditCreator::GetReplaymentMethodsToDropDown(), 'placeholder' => 'Sposób spłaty pożyczki', 'data' => $this->getCredit()->getReplaymentMethod())); $builder->add('strPurpose', 'text', array('attr' => array('placeholder' => 'Cel pożyczki'), 'data' => $this->getCredit()->getPurpose())); $builder->add('strTypeOfSecurity', 'text', array('attr' => array('placeholder' => 'Rodzaj zabezpieczenia'), 'data' => $this->getCredit()->getTypeOfSecurity())); $builder->add('strTypeOfSecurityDescription', 'textarea', array('attr' => array('placeholder' => 'Szczegółowy opis zabezpieczenia pożyczki'), 'data' => $this->getCredit()->getTypeOfSecurityDescription())); }
/** * * @param \App\FrontendBundle\Utils\Session\CreditCreator $objCreator * @return \App\GuardBundle\Entity\GuardUser */ public function getUserForCredit(CreditCreator $objCreator) { /** * Zwraca zalogowanego usera */ if ($this->getUser() instanceof \App\GuardBundle\Entity\GuardUser) { if ($this->getUser()->hasRole(\App\GuardBundle\Entity\GuardUser::ROLE_LENDER)) { $objCreator->addError('Osoba zalogowania jako pożyczkodawca nie może wziąć pożyczki'); return null; } return $this->getUser(); } $m = $this->getDoctrine()->getManager(); /** * Sprawdza czy istnieje user o podanym emailu i username */ /* @var $activeUser \App\GuardBundle\Entity\GuardUser */ $activeUser = $m->getRepository('AppGuardBundle:GuardUser')->findOneBy(array('username' => $objCreator->getUsername(), 'email' => $objCreator->getEmail())); if ($activeUser instanceof \App\GuardBundle\Entity\GuardUser) { $encoder_service = $this->get('security.encoder_factory'); $encoder = $encoder_service->getEncoder($activeUser); $encoded_pass = $encoder->encodePassword($objCreator->getPassword(), $activeUser->getSalt()); if ($activeUser->getPassword() !== $encoded_pass) { $objCreator->addError('Hasło jest niepoprawne'); return null; } if ($activeUser->hasRole(\App\GuardBundle\Entity\GuardUser::ROLE_LENDER)) { $objCreator->addError('Nie można użyć tych danych do wzięcia pożyczki. Użytkownik jest pożyczkodawcą'); return null; } if (!$activeUser->hasRole(\App\GuardBundle\Entity\GuardUser::ROLE_BORROWER)) { $objCreator->addError('Nie można użyć tych danych do wzięcia pożyczki.'); return null; } return $activeUser; } $activeUser = $m->getRepository('AppGuardBundle:GuardUser')->findOneBy(array('username' => $objCreator->getUsername())); if ($activeUser instanceof \App\GuardBundle\Entity\GuardUser) { $objCreator->addError('Adres email lub nick jest niepoprawny'); return null; } $activeUser = $m->getRepository('AppGuardBundle:GuardUser')->findOneBy(array('email' => $objCreator->getEmail())); if ($activeUser instanceof \App\GuardBundle\Entity\GuardUser) { $objCreator->addError('Adres email lub nick jest niepoprawny'); return null; } $caller = $this->get('api_caller'); $arrParams = array('username' => $objCreator->getUsername(), 'password' => $objCreator->getPassword(), 'email' => $objCreator->getEmail(), 'roles' => array(\App\GuardBundle\Entity\GuardUser::ROLE_BORROWER, \App\GuardBundle\Entity\GuardUser::ROLE_DEFAULT)); $url = $this->generateUrl("post_user", $arrParams, true); $objHttp = new \Lsw\ApiCallerBundle\Call\HttpPostJson($url, array()); $data = $caller->call($objHttp); $objCreator->setIsNew(TRUE); return $m->getRepository('AppGuardBundle:GuardUser')->findOneByUsername($objCreator->getUsername()); }
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('amount', 'hidden', array('data' => $this->getCredit()->getCreditAmount())); $builder->add('replaymentTime', 'hidden', array('data' => $this->getCredit()->getReplaymentTime())); $builder->add('interest', 'text', array('attr' => array('placeholder' => 'Oprocentowanie', 'regex' => '\\d+'))); $builder->add('typeOfSecurity', 'text', array('attr' => array('placeholder' => 'Rodzaj zabezpieczenia', 'regex' => '.{1,255}'), 'data' => $this->getCredit()->getTypeOfSecurity())); $builder->add('replaymentMethod', 'choice', array('choices' => \App\FrontendBundle\Utils\Session\CreditCreator::GetReplaymentMethodsToDropDown(), 'placeholder' => 'Sposób spłaty pożyczki', 'data' => $this->getCredit()->getReplaymentMethod())); $builder->add('description', 'textarea', array('attr' => array('placeholder' => 'Uwagi', 'regex' => '.+'))); $builder->add('expiredAt', 'text', array('attr' => array('placeholder' => 'Ważność oferty', 'regex' => '\\d\\d\\.\\d\\d\\.\\d\\d\\d\\d'))); }
/** * Pobranie z sesji obiektu CreditCreator * @return \App\FrontendBundle\Utils\Session\CreditCreator */ public function getCreditCreator() { $strSerialized = $this->get('session')->get('CreditCreator'); if ($strSerialized === null && $this->getUser() instanceof \App\GuardBundle\Entity\GuardUser) { $objCreditCreator = new \App\FrontendBundle\Utils\Session\CreditCreator(); $objCreditCreator->setUserData($this->getUser()); $this->saveCreditCreator(serialize($objCreditCreator)); return $objCreditCreator; } return \App\FrontendBundle\Utils\Session\CreditCreator::unserialized($strSerialized); }
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('strPurpose', 'text', array('attr' => array('placeholder' => 'Cel pożyczki', 'pattern' => '^.{1,255}$'))); $builder->add('strPurposeDescription', 'textarea', array('attr' => array('placeholder' => 'Szczegółowy opis celu pożyczki', 'pattern' => '^.+$'))); $builder->add('intRepaymentMethod', 'choice', array('choices' => CreditCreator::GetReplaymentMethodsToDropDown(), 'placeholder' => 'Sposób spłaty pożyczki')); $builder->add('intSourceOfIncome', 'choice', array('choices' => CreditCreator::GetSourceOfIncomesToDropDown(), 'placeholder' => 'Źródło przychodów')); $builder->add('intSalary', 'text', array('attr' => array('placeholder' => 'Dochody miesięczne', 'pattern' => '^\\d{1,8}$'))); $builder->add('intMaritalStatus', 'choice', array('choices' => CreditCreator::GetMaritalStatusesToDropDown(), 'placeholder' => 'Stan cywilny')); $builder->add('intNumberOfChildren', 'choice', array('choices' => CreditCreator::GetNumbersOfChildrenToDropDown(), 'placeholder' => 'Ilość dzieci')); $builder->add('strTypeOfSecurity', 'text', array('attr' => array('placeholder' => 'Rodzaj zabezpieczenia', 'pattern' => '^.{1,255}$'))); $builder->add('strTypeOfSecurityDescription', 'textarea', array('attr' => array('placeholder' => 'Szczegółowy opis zabezpieczenia pożyczki', 'pattern' => '^.+$'))); $builder->add('filesName', 'text', array('required' => false, 'attr' => array('readonly' => true, 'placeholder' => 'Dokumenty, zdjęcia', 'class' => 'selectedFiles'))); $builder->add('files', 'file', array('attr' => array('class' => 'selectFiles', 'style' => 'display: none;'), 'required' => false, 'multiple' => true)); $this->setDefault($builder); }
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('intTypeOfPerson', 'choice', array('choices' => CreditCreator::GetTypesOfPersonToDropDown(), 'expanded' => true, 'multiple' => false)); /** * LEWA STRONA */ $builder->add('strFirstName', 'text', array('required' => false, 'attr' => array('placeholder' => 'Imię', 'data-required' => 'true', 'pattern' => '^.{1,255}$'))); $builder->add('strSecondName', 'text', array('required' => false, 'attr' => array('placeholder' => 'Drugie imię', 'data-required' => 'false', 'pattern' => '^.{1,255}$'))); $builder->add('strLastName', 'text', array('required' => false, 'attr' => array('placeholder' => 'Nazwisko', 'data-required' => 'true', 'pattern' => '^.{1,255}$'))); $builder->add('strPesel', 'text', array('required' => false, 'attr' => array('placeholder' => 'PESEL', 'data-required' => 'true', 'pattern' => '^[0-9]{11}$'))); $builder->add('strEdg', 'text', array('required' => false, 'attr' => array('placeholder' => 'EDG dla działalności gosp.', 'data-required' => 'false', 'pattern' => '^.{0,255}$'))); $builder->add('strIdNumber', 'text', array('required' => false, 'attr' => array('placeholder' => 'Nr dowodu osobistego', 'data-required' => 'true', 'pattern' => '^.{3}[0-9]{6}$'))); $builder->add('strAddress', 'text', array('required' => false, 'attr' => array('placeholder' => 'Adres zamieszkania', 'data-required' => 'true', 'pattern' => '^.{1,255}$'))); $builder->add('strPostCode', 'text', array('required' => false, 'attr' => array('placeholder' => 'Kod pocztowy', 'data-required' => 'true', 'pattern' => '^(\\d\\d\\d\\d\\d|\\d\\d-\\d\\d\\d)$'))); $builder->add('strCity', 'text', array('required' => false, 'attr' => array('placeholder' => 'Miescowość', 'data-required' => 'true', 'pattern' => '^.{1,255}$'))); $builder->add('strPhone', 'text', array('required' => false, 'attr' => array('placeholder' => 'Telefon', 'data-required' => 'true', 'pattern' => '^(\\+)?[0-9\\s\\-]{9,15}$'))); $builder->add('strFacebookAddress', 'text', array('required' => false, 'attr' => array('placeholder' => 'Adres profilu na Facebook', 'data-required' => 'true', 'pattern' => '^.{1,255}$'))); /** * PRAWA STRONA */ $builder->add('strFirstName2', 'text', array('required' => false, 'attr' => array('placeholder' => 'Imię', 'data-required' => 'true', 'pattern' => '^.{1,255}$'))); $builder->add('strSecondName2', 'text', array('required' => false, 'attr' => array('placeholder' => 'Drugie imię', 'data-required' => 'false', 'pattern' => '^.{1,255}$'))); $builder->add('strLastName2', 'text', array('required' => false, 'attr' => array('placeholder' => 'Nazwisko', 'data-required' => 'true', 'pattern' => '^.{1,255}$'))); $builder->add('strPesel2', 'text', array('required' => false, 'attr' => array('placeholder' => 'PESEL', 'data-required' => 'true', 'pattern' => '^[0-9]{11}$'))); $builder->add('strEdg2', 'text', array('required' => false, 'attr' => array('placeholder' => 'EDG dla działalności gosp.', 'data-required' => 'false', 'pattern' => '^.{0,255}$'))); $builder->add('strIdNumber2', 'text', array('required' => false, 'attr' => array('placeholder' => 'Nr dowodu osobistego', 'data-required' => 'true', 'pattern' => '^.{3}[0-9]{6}$'))); $builder->add('strAddress2', 'text', array('required' => false, 'attr' => array('placeholder' => 'Adres zamieszkania', 'data-required' => 'true', 'pattern' => '^.{1,255}$'))); $builder->add('strPostCode2', 'text', array('required' => false, 'attr' => array('placeholder' => 'Kod pocztowy', 'data-required' => 'true', 'pattern' => '^(\\d\\d\\d\\d\\d|\\d\\d-\\d\\d\\d)$'))); $builder->add('strCity2', 'text', array('required' => false, 'attr' => array('placeholder' => 'Miescowość', 'data-required' => 'true', 'pattern' => '^.{1,255}$'))); $builder->add('strPhone2', 'text', array('required' => false, 'attr' => array('placeholder' => 'Telefon', 'data-required' => 'true', 'pattern' => '^(\\+)?[0-9\\s\\-]{9,15}$'))); $builder->add('strFacebookAddress2', 'text', array('required' => false, 'attr' => array('placeholder' => 'Adres profilu na Facebook', 'data-required' => 'true', 'pattern' => '^.{1,255}$'))); if (!$this->getUser() instanceof GuardUser) { $builder->add('username', 'text', array('attr' => array('placeholder' => 'Nick', 'data-required' => 'true', 'pattern' => '^.{1,255}$'))); $patternEmail = '^(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){255,})(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){65,}@)(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22))(?:\\.(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-z0-9]+(?:-+[a-z0-9]+)*\\.){1,126}){1,}(?:(?:[a-z][a-z0-9]*)|(?:(?:xn--)[a-z0-9]+))(?:-+[a-z0-9]+)*)|(?:\\[(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9][:\\]]){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\\]))$'; $builder->add('email', 'text', array('attr' => array('placeholder' => 'e-mail', 'data-required' => 'true', 'pattern' => $patternEmail))); $builder->add('password', 'password', array('attr' => array('placeholder' => 'hasło', 'data-required' => 'true', 'pattern' => '^.{1,255}$'))); } $this->setDefault($builder); }
/** * Get numberOfChildren * * @return string */ public function getNumberOfChildrenLabel() { return \App\FrontendBundle\Utils\Session\CreditCreator::GetNumbersOfChildrenLabel($this->numberOfChildren); }