public function setAdjunto(Adjunto $v = null) { if ($v === null) { $this->setFkAdjuntoId(NULL); } else { $this->setFkAdjuntoId($v->getId()); } $this->aAdjunto = $v; if ($v !== null) { $v->addInforme($this); } return $this; }
public function executeEdit() { $this->informe = $this->getInformeOrCreate(); if ($this->getRequest()->getMethod() == sfRequest::POST) { $this->updateInformeFromRequest(); if ($this->getRequest()->getFileName('file')) { /*if (!$this->informe->isNew()) { $adjunto_anterior = $this->informe->getAdjunto(); @unlink(sfConfig::get('sf_informe_dir') . DIRECTORY_SEPARATOR . $adjunto_anterior->getRuta()); $adjunto_anterior->delete(); } */ $mimetype = $this->getRequest()->getFileType('file'); $ext = substr($this->getRequest()->getFileName('file'), strrpos($this->getRequest()->getFileName('file'), '.')); $realFileName = $this->getRequest()->getFileName('file'); $this->getRequest()->moveFile('file', sfConfig::get('sf_informe_dir') . DIRECTORY_SEPARATOR . $realFileName); $adjunto = new Adjunto(); $adjunto->setFecha(date('Y-m-d')); $adjunto->setNombreArchivo($realFileName); $adjunto->setTipoArchivo($mimetype); $adjunto->setRuta($realFileName); $adjunto->save(); $this->informe->setFkAdjuntoId($adjunto->getId()); $this->saveInforme($this->informe); $this->getUser()->setFlash('notice', 'Your modifications have been saved'); if ($this->getRequestParameter('save_and_add')) { return $this->redirect('informes/create'); } else { if ($this->getRequestParameter('save_and_list')) { return $this->redirect('informes/list'); } else { return $this->redirect('informes/edit?id=' . $this->informe->getId()); } } } else { //no se adjunto archivo if ($this->informe->isNew()) { $this->getRequest()->setError('file', 'Debe adjuntar un archivo'); } else { $this->saveInforme($this->informe); $this->getUser()->setFlash('notice', 'Your modifications have been saved'); if ($this->getRequestParameter('save_and_add')) { return $this->redirect('informes/create'); } else { if ($this->getRequestParameter('save_and_list')) { return $this->redirect('informes/list'); } else { return $this->redirect('informes/edit?id=' . $this->informe->getId()); } } } } } $this->labels = $this->getLabels(); }
public static function addInstanceToPool(Adjunto $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } self::$instances[$key] = $obj; } }