コード例 #1
0
 protected function saveDocumento($documento)
 {
     //Ana: 03-11-09 Por defecto se añaden al documento los usuarios que pertenecen al proyecto que tiene asignado el documento.
     if ($documento->isNew()) {
         $nuevo = 1;
     }
     $documento->save();
     if (isset($_FILES["resume_degraded"]) && is_uploaded_file($_FILES["resume_degraded"]["tmp_name"]) && $_FILES["resume_degraded"]["error"] == 0) {
         $fileName = $_FILES["resume_degraded"]["name"];
         $used_degraded = true;
     }
     if (isset($_REQUEST["hidFileID"]) && $_REQUEST["hidFileID"] != "") {
         $fileName = $_REQUEST["hidFileID"];
     }
     if ($used_degraded) {
         $fileSize = $this->getRequest()->getFileSize($fileName);
         $fileType = $this->getRequest()->getFileType($fileName);
     } else {
         $filePath = sfConfig::get('sf_web_dir') . "/temp/" . $fileName;
         $fileSize = filesize($filePath);
         $fileType = mime_content_type($filePath);
     }
     //if ($_FILES['fichero']['error'] == 0)
     //{
     $usuario = Usuario::getUsuarioActual();
     $historico = new HistoricoDocumento();
     $historico->setIdEmpresa(sfContext::getInstance()->getUser()->getAttribute('idempresa'));
     $historico->setIdDocumento($documento->getIdDocumento());
     $historico->setVersion(HistoricoDocumentoPeer::getUltimaVersion($this->documento->getPrimaryKey()));
     $historico->setFecha(date('Y-m-d H:i:s'));
     $historico->setTamano($fileSize);
     $historico->setNombreFich($fileName);
     $historico->setMime($fileType);
     $historico->setIdUsuario($usuario ? $usuario->getPrimaryKey() : null);
     //Rober 28-dic-2009
     $nombre_base_nuevo = $this->renombrarDocumento($historico, $documento->getIdProyecto(), $documento->getIdFase());
     $historico->setNombreFich($nombre_base_nuevo);
     $historico->save();
     $cookie_cliente = sfContext::getInstance()->getUser()->getAttribute('empresa', '', 'usuarios');
     if ($cookie_cliente != 0 && $cookie_cliente != '') {
         $cliente = ClientePeer::retrieveByPk($cookie_cliente);
         //if ($cliente->getEmail() != '' && $cliente->getQuieremail())
         //{
         // Rober 23-oct-2009: la funcion de envío no está definida...
         //DocumentoPeer::mandarEmail($historico, $cliente->getEmail(), $cliente->getNombre());
         //}
     }
     //}
     if ($nuevo) {
         // Ana: 03-11-09 Por defecto se añaden al documento los usuarios que
         // pertenecen al proyecto que tiene asignado el documento.
         // Rober 26-abr-2010: código comentado.
         $fase = $documento->getFase();
         $trabajadores = $fase instanceof Fase ? $fase->getListaTrabajadores() : array();
         if (sizeof($trabajadores) == 0) {
             $c = new Criteria();
             $c->add(RelProyectoTrabajadorPeer::ID_PROYECTO, $documento->getIdProyecto());
             $trabajadores = RelProyectoTrabajadorPeer::doSelect($c);
         }
         //Rober 26-abr-2010
         foreach ($trabajadores as $trabajador) {
             $c = new Criteria();
             $new_rpt = new RelDocumentoTrabajador();
             $new_rpt->setIdTrabajador($trabajador->getIdTrabajador());
             $documento->addRelDocumentoTrabajador($new_rpt);
         }
         $documento->save();
     }
     //BORRAMOS EL FICHERO TEMPORAL SI EXISTE
     if (isset($filePath) && file_exists($filePath)) {
         @unlink($filePath);
     }
 }
コード例 #2
0
 protected function getHistoricoDocumentoOrCreate($iddocumento = 'id_documento', $version = 'version')
 {
     if (!$this->getRequestParameter($iddocumento) || !$this->getRequestParameter($version)) {
         $historico_documento = new HistoricoDocumento();
         $historico_documento->setIdEmpresa(sfContext::getInstance()->getUser()->getAttribute('idempresa'));
     } else {
         $c = new Criteria();
         $c->add(HistoricoDocumentoPeer::ID_DOCUMENTO, $this->getRequestParameter('id_documento'));
         $c->add(HistoricoDocumentoPeer::VERSION, $this->getRequestParameter('version'), Criteria::LIKE);
         $historico_documento = HistoricoDocumentoPeer::doSelectOne($c);
         $this->forward404Unless($historico_documento);
     }
     return $historico_documento;
 }
コード例 #3
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      HistoricoDocumento $value A HistoricoDocumento object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(HistoricoDocumento $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = serialize(array((string) $obj->getIdDocumento(), (string) $obj->getVersion()));
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
コード例 #4
0
 public function cancelarTramitacaoAction()
 {
     $this->_helper->layout->disableLayout();
     // desabilita o Zend_Layout
     $idHistorico = $_POST['idHistorico'];
     $HistoricoDocumento = new HistoricoDocumento();
     $rs = $HistoricoDocumento->buscar(array('idHistorico = ?' => $idHistorico))->current();
     $conclusao = false;
     switch ($rs->Acao) {
         case 1:
             $rs->stEstado = 0;
             $rs->save();
             $conclusao = true;
             break;
         case 2:
             $rs->stEstado = 0;
             $rs->save();
             $conclusao = true;
             break;
         default:
             break;
     }
     if ($conclusao) {
         echo json_encode(array('resposta' => true));
     } else {
         echo json_encode(array('resposta' => false));
     }
     die;
 }