protected function processItemForm(sfWebRequest $request, sfForm $itemForm)
 {
     if (!$this->getUser()->hasFlash('comprobante')) {
         $this->getUser()->setFlash('comprobante', new Comprobante());
     }
     $comprobante = $this->getUser()->getFlash('comprobante');
     $itemForm->bind($request->getParameter($itemForm->getName()));
     if ($itemForm->isValid()) {
         $comprobanteItem = $itemForm->updateObject();
         $itemForm = new ComprobanteItemForm();
         $comprobante->addComprobanteItem($comprobanteItem);
         $comprobante->calculateTotales();
     }
     $this->getUser()->setFlash('comprobante', $comprobante);
     return $itemForm;
 }
Beispiel #2
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $file = $form->getValue('path');
         if ($file != null) {
             $form->updateObject();
             $form->getObject()->setFilename($file->getOriginalName());
             $form->getObject()->save();
             $ei_subject_attachment = $form->getObject();
             //$ei_subject_attachment = $form->save();
             $this->getUser()->setFlash('alert_form', array('title' => 'Success', 'class' => 'alert-success', 'text' => 'Attachment has been add sucessfully ...'));
             //Suivant le type du fichier attaché , on éffectue la bonne redirection
         } else {
             $this->getUser()->setFlash('alert_form', array('title' => 'Error', 'class' => 'alert-danger', 'text' => 'Please select a file ...'));
         }
         $this->redirectWithinAttachmentType($form->getValue('type'));
     }
 }
	protected function processForm(sfWebRequest $request, sfForm $form)
	{
		//$form->bind($request->getParameter($form->getName()));
		$form->bind($request->getParameter($form->getName('ficheros')), $request->getFiles('ficheros'));
		 
		if ($form->isValid())
		{
			//Este metodo es para formularios doctrine
			//$form->saveFile ($field, $filename = null, $file = null);

			//Recoge archivo
			$file = $form->getValue('file');
			//Ruta de subida
			$directorio=sfConfig::get('sf_upload_dir').'/ficheros';

			//Si el directorio no existe le creo
			if (!is_dir($directorio))
			{
				mkdir ($directorio,0777);
			}

			$this-> existe_fichero = false;

			if (is_file($directorio.'/'.$file->getOriginalName()))
			{
				$this->logMessage("EXISTE UN FICHERO CON EL MISMO NOMBRE: " . $file->getOriginalName() ,"debug" );
				$this-> existe_fichero = true;
				$this->getUser()->setFlash('error', 'YA EXISTE UN FICHERO CON EL MISMO NOMBRE');
			}
			else{//si no existe el fichero lo guardamos
				//Guardo (subo) el fichero
				$file->save($directorio.'/'.$file->getOriginalName());
				//Actualizo el objeto del formulario
				$form->updateObject();
				//Añado los campos "propios"
				$form->getObject()->setFile($file->getOriginalName());
				//guardo el objeto
				$form->getObject()->save();
			}
			$this->redirect('ficheros/new');
		}
	}
Beispiel #4
0
 protected function processFormEncaminhamento(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter('encaminhamento'));
     if ($form->isValid()) {
         $form->updateObject();
         $duplicados = Doctrine_Core::getTable('Encaminhamento')->findByIdAndTipo($form->getObject()->getAssocId(), $form->getObject()->getTipo());
         if ($duplicados->count() > 0) {
             return 'erro';
         }
         $encaminhamento = $form->save();
         if ($encaminhamento->getTipo() == sfConfig::get('app_assoc_titular')) {
             $assoc = Doctrine_Core::getTable('Titular')->find($encaminhamento->getAssocId());
             $descricao = "Um encaminhamento dentário foi emitido para o titular " . $assoc->getNome() . " matricula " . $assoc->getMatricula() . ".";
             $titular_id = $encaminhamento->getAssocId();
         } elseif ($encaminhamento->getTipo() == sfConfig::get('app_assoc_dependente')) {
             $assoc = Doctrine_Core::getTable('Dependente')->find($encaminhamento->getAssocId());
             $descricao = "Um encaminhamento dentário foi impresso para o dependente " . $assoc->getNome() . " do titular " . $assoc->getTitular()->getNome() . ".";
             $titular_id = $assoc->getTitularId();
         }
         $tipo_atendimento = sfConfig::get('app_atend_tipo_imp_encaminha');
         $this->saveAtendimento($descricao, $tipo_atendimento, $titular_id, $encaminhamento->getId());
         $encaminhamento->gdata_insert_row();
         $this->redirect("@encaminhamento_ok?id=" . $encaminhamento->getId());
     }
 }