/**
	 * 
	 */private function setClickBanner($id) {
		$banner=$this->getDoctrine()
		->getRepository("BannerBundle:Banner")
		->find($id);
		
		$formData=new Formdata();
		$banner->setClicks($banner->getClicks()+1);
		$formData->updateData($this);
	}
Пример #2
0
 private function setRatedAds($idAds,$rated){
 	$formData=new Formdata();
 	$ad=$this->getDoctrine()
 	->getRepository("AdsmanagerBundle:AdsmanagerAds")
 	->find($idAds);
 	
 	$ad->setRated($rated);
 	$formData->updateData($this);
 	
 }
    public function editAdsProductAction($id,Request $request)
    {
    	if(!$this->container->get('security.context')->isGranted('IS_AUTHENTICATED_FULLY') ){
    		return $this->redirectToRoute('fos_user_security_login');
    	}
    	
    	$adProduct=$this->getDoctrine()
    	->getRepository("AdsmanagerBundle:AdsmanagerProduct")
    	->find($id);
    	 
    	if(!$adProduct){
    		return $this->redirectToRoute('my_ads');
    	}
    	
    	$ad=$this->getDoctrine()
    	->getRepository("AdsmanagerBundle:AdsmanagerAds")
    	->find($adProduct->getIdAd());
    	
    	if(!$this->isAnUserOwner ( $ad->getUserId() )){
    		return $this->redirectToRoute('my_ads');
    	}

    	$formData=new Formdata();
    	$message=new Message();
    	
    	 
    	$form=$this->createForm(new AdsmanagerProductType(),$adProduct);
    	if(!$formData->isSetFormat($request))
    	{
    		return $this->render('AdsmanagerBundle:Product:editProductAds.html.twig',array("form"=>$form->createView(),"id"=>$adProduct->getIdAd(),"image"=>$adProduct->getImages(),"price"=>$adProduct->getPrice()));
    	}
    	 
    	if(!$formData->isValidFormat($request,$form,$message))
    	{
    		$message->show($this);
    		return $this->render('AdsmanagerBundle:Product:editProductAds.html.twig',array("form"=>$form->createView(),"id"=>$adProduct->getIdAd(),"image"=>$adProduct->getImages(),"price"=>$adProduct->getPrice()));
    		 
    	}
    	 
    	$image = $request->files->get('imagen');
    	 
    	if(!$formData->isValidImageUpdate($image,$form,$adProduct,$message,'name')){
    		$message->show($this);
    		return $this->render('AdsmanagerBundle:Product:editProductAds.html.twig',array("form"=>$form->createView(),"id"=>$adProduct->getIdAd(),"image"=>$adProduct->getImages(),"price"=>$adProduct->getPrice()));
    		 
    	}
    	$ad->setPublished(0);
    	$date = new DateTime();
    	$ad->setDateModified($date);
    	$formData->updateData($this);
    	
    	$price=$request->request->get('price');
    	$adProduct->setPrice(str_replace('.', '', $price));
    	$formData->updateData($this);
    	$message->setSuccessMessages("El Producto o servicio ha sido Modificado Exitosamente.")->show($this);
    	
    	if($image){
    		$formData->uploadImages($image,'images/ids/'.$adProduct->getIdAd(),$adProduct);
    		$this->resizeImages($adProduct->getIdAd(),$adProduct->getImages());
    	}

    	return $this->redirectToRoute('my_ads');
    }