Esempio n. 1
0
 public function setFirstLastFloor(Estate $estate)
 {
     $floor = $estate->getFloor();
     if ($floor['floor'] == 1 || $floor['floor'] == $floor['count_floor']) {
         $estate->setFirstLastFloor(true);
     } else {
         $estate->setFirstLastFloor(false);
     }
 }
Esempio n. 2
0
 public function testSubmitValidData()
 {
     $formData = array('floor' => null, 'count_floor' => null);
     $form = $this->factory->create(FloorType::class);
     $object = new Estate();
     $object->setFloor(array('floor' => null, 'count_floor' => null));
     $form->submit($formData);
     $this->assertTrue($form->isSynchronized());
     $this->assertEquals($object->getFloor(), $form->getData());
     $view = $form->createView();
     $children = $view->children;
     foreach (array_keys($formData) as $key) {
         $this->assertArrayHasKey($key, $children);
     }
 }
Esempio n. 3
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $propertyTypeChoices = [];
     $propertyTypes = $this->_entityManager->getRepository("AppBundle:EstateType")->findSpecificType(1);
     foreach ($propertyTypes as $propertyType) {
         $propertyTypeChoices[$propertyType['stringId']] = $propertyType['title'];
     }
     foreach (Estate::getTradeTypes() as $tradeType) {
         $propertyTradeTypeChoices[$tradeType] = mb_convert_case($this->_translator->trans('state.catalog.trade_type_' . $tradeType), MB_CASE_TITLE, "UTF-8");
     }
     $builder->add("name", 'text', ['label' => "proposal.common.name.label", 'attr' => ['placeholder' => "proposal.common.name.placeholder"]])->add("phone", 'text', ['label' => "proposal.common.phone.label", 'attr' => ['placeholder' => "proposal.common.phone.placeholder"]])->add("email", 'email', ['label' => "proposal.common.email.label", 'attr' => ['placeholder' => "proposal.common.email.placeholder"]])->add("type", 'choice', ['label' => "proposal.common.type.label", 'attr' => ['placeholder' => "proposal.common.type.placeholder"], 'choices' => $propertyTypeChoices, 'expanded' => TRUE, 'multiple' => FALSE, 'invalid_message' => "proposal.common.type.valid"])->add("tradeType", 'choice', ['label' => "proposal.common.trade_type.label", 'attr' => ['placeholder' => "proposal.common.trade_type.placeholder"], 'choices' => $propertyTradeTypeChoices, 'expanded' => TRUE, 'multiple' => FALSE, 'invalid_message' => "proposal.common.trade_type.valid"])->add("priceCurrency", 'choice', ['label' => "proposal.common.price_currency.label", 'attr' => ['placeholder' => "proposal.common.price_currency.placeholder"], 'choices' => ['UAH' => "UAH", 'USD' => "USD"], 'expanded' => TRUE, 'multiple' => FALSE, 'invalid_message' => "proposal.common.price_currency.valid"])->add("priceRentValue", 'number', ['required' => FALSE, 'label' => "proposal.residential.price_rent_value.label", 'attr' => ['placeholder' => "proposal.residential.price_rent_value.placeholder"], 'precision' => 2])->add("priceSaleValue", 'number', ['required' => FALSE, 'label' => "proposal.common.price_sale_value.label", 'attr' => ['placeholder' => "proposal.common.price_sale_value.placeholder"], 'precision' => 2])->add("street", "text", ['label' => "proposal.common.street.label", 'attr' => ['placeholder' => "proposal.common.street.placeholder"]])->add("house", "text", ['label' => "proposal.common.house.label", 'attr' => ['placeholder' => "proposal.common.house.placeholder"]])->add("space", "text", ['label' => "proposal.common.space.label", 'attr' => ['placeholder' => "proposal.common.space.placeholder"]])->add("spacePlot", "text", ['required' => FALSE, 'label' => "proposal.residential.space_plot.label", 'attr' => ['placeholder' => "proposal.residential.space_plot.placeholder"]])->add("roomsNumber", "number", ['label' => "proposal.residential.rooms_number.label", 'attr' => ['placeholder' => "proposal.residential.rooms_number.placeholder"]])->add("bathroomsNumber", "number", ['label' => "proposal.residential.bathrooms_number.label", 'attr' => ['placeholder' => "proposal.residential.bathrooms_number.placeholder"]])->add("bedroomsNumber", "number", ['required' => FALSE, 'label' => "proposal.residential.bedrooms_number.label", 'attr' => ['placeholder' => "proposal.residential.bedrooms_number.placeholder"]])->add("floor", "number", ['required' => FALSE, 'label' => "proposal.residential.floor.label", 'attr' => ['placeholder' => "proposal.residential.floor.placeholder"]])->add("floorsNumber", "number", ['required' => FALSE, 'label' => "proposal.residential.floors_number.label", 'attr' => ['placeholder' => "proposal.residential.floors_number.placeholder"]])->add("isCashless", "checkbox", ['required' => FALSE, 'label' => "proposal.residential.is_cashless.label"])->add("isNewBuilding", "checkbox", ['required' => FALSE, 'label' => "proposal.residential.is_new_building.label"])->add("hasElevator", "checkbox", ['required' => FALSE, 'label' => "proposal.residential.has_elevator.label"])->add("hasParking", "checkbox", ['required' => FALSE, 'label' => "proposal.residential.has_parking.label"])->add("hasFurniture", "checkbox", ['required' => FALSE, 'label' => "proposal.residential.has_furniture.label"])->add("hasRegistration", "checkbox", ['required' => FALSE, 'label' => "proposal.residential.has_registration.label"])->add("description", "textarea", ['required' => FALSE, 'label' => "proposal.common.description.label"])->add("wasted", "checkbox", ['label' => "proposal.common.wasted.label"])->add("send", 'submit', ['label' => "proposal.common.submit.label"]);
 }
Esempio n. 4
0
 protected function configureFormFields(FormMapper $formMapper)
 {
     $translator = $this->getConfigurationPool()->getContainer()->get("translator");
     $lTranslator = function ($input, $transDomain) use($translator) {
         $output = [];
         foreach ($input as $key => $value) {
             $output[$key] = $translator->trans($value, [], $transDomain);
         }
         return $output;
     };
     $tradeTypes = $lTranslator(Estate::getTradeTypes(), "trade_types");
     $districts = $lTranslator(Estate::getDistricts(), "districts");
     $estateTypeQuery = $this->modelManager->getEntityManager('AppBundle\\Entity\\EstateType')->createQueryBuilder()->select("estateType")->from('AppBundle\\Entity\\EstateType', 'estateType')->where("estateType.parent IS NOT NULL");
     $formMapper->with("Нерухомість - Локалізований контент")->add("translations", "a2lix_translations_gedmo", ["locales" => ['ua', 'en'], "label" => FALSE, "translatable_class" => 'AppBundle\\Entity\\Estate', "required" => TRUE, "fields" => ["title" => ["locale_options" => ["ua" => ["required" => FALSE, "label" => "Назва об'єкту"], "en" => ["required" => FALSE, "label" => "Estate title"]]], "address" => ["locale_options" => ["ua" => ["label" => "Точна адреса об'єкту"], "en" => ["required" => FALSE, "label" => "Exact property address"]]], "description" => ["locale_options" => ['ua' => ['label' => 'Опис', 'field_type' => 'ckeditor', 'config_name' => 'base_config'], 'en' => ["required" => FALSE, 'label' => 'Description', 'field_type' => 'ckeditor', 'config_name' => 'base_config']]], 'slug' => ['display' => FALSE]]])->end()->with("Нерухомість - Ручне введення координат")->add("coordinatesManualLat", "text", ['required' => FALSE, 'label' => "Широта"])->add("coordinatesManualLng", "text", ['required' => FALSE, 'label' => "Довгота"])->end()->with("Нерухомість - Загальні дані")->add("code", "text", ["label" => "ID"])->add("tradeType", "choice", ["label" => "Тип транзакції", "placeholder" => "Оберіть тип транзакції...", "choices" => $tradeTypes])->add("estateType", NULL, ["label" => "Тип нерухомості", "required" => TRUE, "placeholder" => "Оберіть тип нерухомості...", "class" => 'AppBundle\\Entity\\EstateType', "query_builder" => $estateTypeQuery], ['edit' => 'standard'])->add("district", "choice", ["label" => "Район", "placeholder" => "Оберіть район...", "choices" => $districts])->add("space", "number", ["label" => "Площа", "precision" => 2])->add("spacePlot", "number", ["required" => FALSE, "label" => "Площа ділянки", "precision" => 2])->add("priceUAH", "number", ["required" => FALSE, "label" => "Ціна (UAH)", "precision" => 2, "constraints" => [new Assert\Range(["min" => 0])]])->add("priceUSD", "number", ["label" => "Ціна (USD)", "precision" => 2, "constraints" => [new Assert\Range(["min" => 0])]])->add("pricePerSquareUAH", "number", ["required" => FALSE, "label" => "Ціна за м2 (UAH)", "precision" => 2, "constraints" => [new Assert\Range(["min" => 0])]])->add("pricePerSquareUSD", "number", ["required" => FALSE, "label" => "Ціна за м2 (USD)", "precision" => 2, "constraints" => [new Assert\Range(["min" => 0])]])->add('isActive', 'checkbox', ["required" => FALSE, "label" => "Відображається"])->end()->with("Нерухомість - Особливості")->add('estateFeatures', 'sonata_type_admin', ['label' => FALSE, 'delete' => FALSE])->end()->with("Нерухомість - Характеристики")->add('estateAttribute', 'sonata_type_collection', ['label' => FALSE, 'by_reference' => FALSE, 'btn_add' => "Додати характеристику"], ['edit' => 'inline', 'inline' => 'table'])->end()->with("Нерухомість - Фотографії")->add('estatePhoto', 'sonata_type_collection', ['required' => TRUE, 'label' => "Керування зображеннями", 'by_reference' => FALSE, 'btn_add' => "Додати зображення"], ['edit' => 'inline', 'inline' => 'table', 'sortable' => 'position'])->end();
 }
Esempio n. 5
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $propertyTypeChoices = [];
     $propertyTypes = $this->_entityManager->getRepository("AppBundle:EstateType")->findSpecificType(2);
     foreach ($propertyTypes as $propertyType) {
         $propertyTypeChoices[$propertyType['stringId']] = $propertyType['title'];
     }
     foreach (Estate::getTradeTypes() as $tradeType) {
         $propertyTradeTypeChoices[$tradeType] = mb_convert_case($this->_translator->trans('state.catalog.trade_type_' . $tradeType), MB_CASE_TITLE, "UTF-8");
     }
     foreach (Estate::getFitOutTypes() as $fitOutType) {
         $propertyFitOutTypeChoices[$fitOutType] = mb_convert_case($this->_translator->trans('state.catalog.fit_out_type_' . $fitOutType), MB_CASE_TITLE, "UTF-8");
     }
     foreach (Estate::getLayoutTypes() as $layoutType) {
         $propertyLayoutTypeChoices[$layoutType] = mb_convert_case($this->_translator->trans('state.catalog.layout_type_' . $layoutType), MB_CASE_TITLE, "UTF-8");
     }
     $builder->add("name", 'text', ['label' => "proposal.common.name.label", 'attr' => ['placeholder' => "proposal.common.name.placeholder"]])->add("phone", 'text', ['label' => "proposal.common.phone.label", 'attr' => ['placeholder' => "proposal.common.phone.placeholder"]])->add("email", 'email', ['label' => "proposal.common.email.label", 'attr' => ['placeholder' => "proposal.common.email.placeholder"]])->add("type", 'choice', ['label' => "proposal.common.type.label", 'attr' => ['placeholder' => "proposal.common.type.placeholder"], 'choices' => $propertyTypeChoices, 'expanded' => TRUE, 'multiple' => FALSE, 'invalid_message' => "proposal.common.type.valid"])->add("tradeType", 'choice', ['label' => "proposal.common.trade_type.label", 'attr' => ['placeholder' => "proposal.common.trade_type.placeholder"], 'choices' => $propertyTradeTypeChoices, 'expanded' => TRUE, 'multiple' => FALSE, 'invalid_message' => "proposal.common.trade_type.valid"])->add("city", "text", ['label' => "proposal.common.city.label", 'attr' => ['placeholder' => "proposal.common.city.placeholder"]])->add("street", "text", ['label' => "proposal.common.street.label", 'attr' => ['placeholder' => "proposal.common.street.placeholder"]])->add("house", "text", ['label' => "proposal.common.house.label", 'attr' => ['placeholder' => "proposal.common.house.placeholder"]])->add("space", "text", ['label' => "proposal.common.space.label", 'attr' => ['placeholder' => "proposal.common.space.placeholder"]])->add("fitOutType", 'choice', ['label' => "proposal.commercial.fit_out_type.label", 'attr' => ['placeholder' => "proposal.commercial.fit_out_type.placeholder"], 'choices' => $propertyFitOutTypeChoices, 'expanded' => TRUE, 'multiple' => FALSE, 'invalid_message' => "proposal.commercial.fit_out_type.valid"])->add("layoutType", 'choice', ['label' => "proposal.commercial.layout_type.label", 'attr' => ['placeholder' => "proposal.commercial.layout_type.placeholder"], 'choices' => $propertyLayoutTypeChoices, 'expanded' => TRUE, 'multiple' => FALSE, 'invalid_message' => "proposal.commercial.layout_type.valid"])->add("priceCurrency", 'choice', ['label' => "proposal.common.price_currency.label", 'attr' => ['placeholder' => "proposal.common.price_currency.placeholder"], 'choices' => ['UAH' => "UAH", 'USD' => "USD"], 'expanded' => TRUE, 'multiple' => FALSE, 'invalid_message' => "proposal.common.price_currency.valid"])->add("priceRentValue", 'number', ['required' => FALSE, 'label' => "proposal.commercial.price_rent_value.label", 'attr' => ['placeholder' => "proposal.commercial.price_rent_value.placeholder"], 'precision' => 2])->add("priceSaleValue", 'number', ['required' => FALSE, 'label' => "proposal.common.price_sale_value.label", 'attr' => ['placeholder' => "proposal.common.price_sale_value.placeholder"], 'precision' => 2])->add("operatingExpenseValue", 'number', ['required' => FALSE, 'label' => "proposal.commercial.operating_expense_value.label", 'attr' => ['placeholder' => "proposal.commercial.operating_expense_value.placeholder"], 'precision' => 2])->add("parkingBayNumber", "number", ['required' => FALSE, 'label' => "proposal.commercial.parking_bay_number.label", 'attr' => ['placeholder' => "proposal.commercial.parking_bay_number.placeholder"]])->add("parkingBayPriceValue", 'number', ['required' => FALSE, 'label' => "proposal.commercial.parking_bay_price_value.label", 'attr' => ['placeholder' => "proposal.commercial.parking_bay_price_value.placeholder"], 'precision' => 2])->add("description", "textarea", ['required' => FALSE, 'label' => "proposal.common.description.label"])->add("wasted", "checkbox", ['label' => "proposal.common.wasted.label"])->add("send", 'submit', ['label' => "proposal.common.submit.label"]);
 }
 private function createDeleteForm(Estate $estate)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('admin_estate_delete', array('slug' => $estate->getSlug())))->setMethod('DELETE')->getForm();
 }
Esempio n. 7
0
 public function load(ObjectManager $manager)
 {
     $faker = Factory::create();
     for ($i = 0; $i <= 200; $i++) {
         $estate = new Estate();
         $estate->setTitle($faker->sentence);
         $estate->setDescription($faker->sentence);
         $estate->setPrice($faker->numberBetween(10000, 500000));
         $estate->setCreatedBy('user_manager' . rand(0, 2));
         $estate->setDistrict($this->getReference('district' . rand(1, 10)));
         $exclusive = rand(1, 10);
         if ($exclusive == 10) {
             $estate->setExclusive(true);
         }
         for ($k = 1; $k <= 5; $k++) {
             $file = new File();
             $file->setEstate($estate);
             $estate->addFile($file);
             $file->setMimeType('image/jpeg');
             $file->setName(md5(uniqid('sdfadf')) . '.jpg');
             $file->setSize('100000');
             $file->setPath("images/estates/foto" . rand(1, 9) . ".jpg");
             $manager->persist($file);
         }
         for ($j = 1; $j <= 5; $j++) {
             $comment = new Comment();
             $comment->setEstate($estate);
             $estate->addComment($comment);
             $comment->setContent($faker->sentence);
             $enable = rand(1, 2);
             if ($enable === 1) {
                 $comment->setEnabled(false);
             } else {
                 $comment->setEnabled(true);
             }
             $comment->setCreatedBy('user_user1');
             $manager->persist($comment);
         }
         // flats - 40%
         // set category
         // for rent - 20%
         $quart = rand(0, 9);
         if ($quart <= 3) {
             $cat = rand(1, 5);
             $estate->setCategory($this->getReference('category' . $cat));
             $countFloors = rand(4, 16);
             $estate->setFloor(array('floor' => rand(1, $countFloors), 'count_floor' => $countFloors));
             $floor = $estate->getFloor();
             if ($floor['floor'] == 1 || $floor['floor'] == $floor['count_floor']) {
                 $estate->setFirstLastFloor(true);
             } else {
                 $estate->setFirstLastFloor(false);
             }
         } elseif ($quart == 4 || $quart == 5) {
             $cat = rand(13, 14);
             $estate->setCategory($this->getReference('category' . $cat));
         } else {
             $cat = rand(6, 12);
             $estate->setCategory($this->getReference('category' . $cat));
         }
         $manager->persist($estate);
     }
     $manager->flush();
 }
 public function validate($value, Constraint $constraint)
 {
     if (!in_array($value, Estate::getLayoutTypes())) {
         $this->context->buildViolation($constraint->message)->addViolation();
     }
 }
 public function availableDistricts(array $estates)
 {
     $availableDistricts = [];
     $existingDistricts = Estate::getDistricts();
     foreach ($estates as $estate) {
         if ($estate instanceof Estate) {
             if (!in_array($estate->getDistrict(), $availableDistricts, TRUE) && !empty($existingDistricts[$estate->getDistrict()])) {
                 $availableDistricts[$estate->getDistrict()] = $existingDistricts[$estate->getDistrict()];
             }
         }
     }
     return $availableDistricts;
 }
Esempio n. 10
0
 protected function validateDistricts(array $districts)
 {
     $existingDistricts = array_keys(Estate::getDistricts());
     foreach ($districts as $district) {
         if (!in_array($district, $existingDistricts, TRUE)) {
             return FALSE;
         }
     }
     return TRUE;
 }
Esempio n. 11
0
 public function hasEstate(Estate $estate)
 {
     $estates = $this->getEstates();
     $has = false;
     foreach ($estates as $item) {
         if ($item->getId() === $estate->getId()) {
             $has = true;
         }
     }
     return $has;
 }