/**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aExpedienteservicio !== null) {
             if ($this->aExpedienteservicio->isModified() || $this->aExpedienteservicio->isNew()) {
                 $affectedRows += $this->aExpedienteservicio->save($con);
             }
             $this->setExpedienteservicio($this->aExpedienteservicio);
         }
         if ($this->aServicioestado !== null) {
             if ($this->aServicioestado->isModified() || $this->aServicioestado->isNew()) {
                 $affectedRows += $this->aServicioestado->save($con);
             }
             $this->setServicioestado($this->aServicioestado);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Esempio n. 2
0
 public function nuevoservicioAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $post_data = $request->getPost();
         $entity = new \Expedienteservicio();
         foreach ($post_data as $key => $value) {
             if (\ExpedienteservicioPeer::getTableMap()->hasColumn($key) && !empty($value) && $key != 'expedienteservicio_fecha') {
                 $entity->setByName($key, $value, \BasePeer::TYPE_FIELDNAME);
             }
         }
         //LA FECHA
         $expedienteservicio_fecha = \DateTime::createFromFormat('d/m/Y', $post_data['expedienteservicio_fecha']);
         $entity->setExpedienteservicioFecha($expedienteservicio_fecha);
         $entity->save();
         $this->flashMessenger()->addSuccessMessage('Registro guardado exitosamente!');
         //REDIRECCIONAMOS A LA ENTIDAD QUE ACABAMOS DE CREAR
         return $this->redirect()->toUrl('/clientes/ver/' . $entity->getExpediente()->getIdcliente() . '/expedientes/ver/' . $entity->getIdexpediente());
     }
     $idexpediente = $this->params()->fromQuery('idexpediente');
     $expediente = \ExpedienteQuery::create()->findPk($idexpediente);
     $servicios_array = array();
     if ($expediente->getExpedienteTipo() == 'importacion') {
         $servicios = \ServicioQuery::create()->filterByServicioTipo('importacion')->find();
     } else {
         $servicios = \ServicioQuery::create()->filterByServicioTipo('exportacion')->find();
     }
     $servicio = new \Servicio();
     foreach ($servicios as $servicio) {
         $idservicio = $servicio->getIdservicio();
         $servicios_array[$idservicio] = $servicio->getServicioNombre();
     }
     //Instanciamos nuestro formulario
     $form = new \Admin\Clientes\Form\ServicioForm($idexpediente);
     //Enviamos a la vista
     $view_model = new ViewModel();
     $view_model->setTerminal(true)->setVariable('form', $form)->setVariable('entity', $expediente)->setTemplate('/clientes/expedientes/modal/nuevoservicio');
     return $view_model;
 }