Ejemplo n.º 1
0
 public function addpropertyAction(Request $request)
 {
     $realtors = $this->getRealtorsAction();
     //echo "<pre>";print_r($realtors);die;
     $states = $this->getStatesAction();
     if ($request->getMethod() == 'POST') {
         $name = $this->get('request')->request->get('name');
         $description = $this->get('request')->request->get('description');
         $phone = $this->get('request')->request->get('phone');
         $state = $this->get('request')->request->get('state');
         $address = $this->get('request')->request->get('address');
         $city = $this->get('request')->request->get('city');
         $additional = $this->get('request')->request->get('additional');
         $price = $this->get('request')->request->get('price');
         $videourl = $this->get('request')->request->get('videourl');
         $realtors = $this->get('request')->request->get('realtors');
         $zip = $this->get('request')->request->get('zip');
         $property = new Property();
         $property->setName($name);
         $property->setDescription($description);
         $property->setPhone($phone);
         $property->setState($state);
         $property->setAddress($address);
         $property->setAdditionalInformation($additional);
         $property->setCity($city);
         $property->setVideoUrl($videourl);
         $property->setprice($price);
         $property->setZip($zip);
         $property->setUserId($realtors);
         $em = $this->getDoctrine()->getEntityManager();
         $em->persist($property);
         $em->flush();
         return $this->redirect($this->generateUrl('RARAdminBundle_property'));
     }
     return $this->render('RARAdminBundle:Property:addProperty.html.twig', array('states' => $states, 'realtors' => $realtors));
 }
Ejemplo n.º 2
0
 public function addPropertyAction(Request $request)
 {
     $em = $this->getDoctrine()->getEntityManager();
     $session = $this->getRequest()->getSession();
     if (!$session->get('userId') || $session->get('userId') == '') {
         return $this->redirect($this->generateUrl('rar_web_login'));
     }
     $states = $this->getStatesAction();
     if ($request->getMethod() == 'POST') {
         $name = $this->get('request')->request->get('name');
         $description = $this->get('request')->request->get('description');
         $phone = $this->get('request')->request->get('phone');
         $state = $this->get('request')->request->get('state');
         $address = $this->get('request')->request->get('address');
         $city = $this->get('request')->request->get('city');
         $additional = $this->get('request')->request->get('additional');
         $price = $this->get('request')->request->get('price');
         $videourl = $this->get('request')->request->get('videourl');
         $a = @explode("watch?v=", $videourl);
         if (@$a[1] != "") {
             $b = "embed/";
             @($videourl = $a[0] . $b . $a[1]);
         }
         $zip = $this->get('request')->request->get('zip');
         $mainImageId = $this->get('request')->request->get('hidMainImageId');
         $property = new Property();
         $property->setName($name);
         $property->setUserId($session->get('userId'));
         $property->setDescription($description);
         $property->setPhone($phone);
         $property->setState($state);
         $property->setAddress($address);
         $property->setAdditionalInformation($additional);
         $property->setCity($city);
         $property->setVideoUrl($videourl);
         $property->setprice($price);
         $property->setZip($zip);
         $em = $this->getDoctrine()->getEntityManager();
         $em->persist($property);
         $em->flush();
         $propertyId = $property->getId();
         foreach ($_FILES as $file) {
         }
         for ($i = 0; $i < count($file['name']); $i++) {
             $main = 0;
             if ($i == $mainImageId || $i == 0) {
                 $main = 1;
             }
             if (isset($_POST['main' . $i + 1])) {
                 //echo $main = $_POST['main'.$i+1];
             }
             //echo $file["tmp_name"][$i]."---".$file["name"][$i];
             move_uploaded_file($file["tmp_name"][$i], "Property/" . $file["name"][$i]);
             $realtor = new PropertyImages();
             $realtor->setPropertyId($propertyId);
             $realtor->setImageUrl($file["name"][$i]);
             $realtor->setIsMain($main);
             $em = $this->getDoctrine()->getEntityManager();
             $em->persist($realtor);
             $em->flush();
             //echo'<pre>';print_r($_POST);die;
             //$mainNew[]=$_POST['main'.$i+1]$_POST['main'.$i+1];
             //echo "-----";
         }
         //die;
         // echo "<PRE>";print_r($mainNew);die;
         return $this->redirect($this->generateUrl('rar_web_property', array('name' => $session->get('userId'), 'id' => $session->get('realtorName'))));
     }
     return $this->render('RARWebBundle:Page:addProperty.html.twig', array('states' => $states));
 }