Exemplo n.º 1
0
 public function nuevoAction()
 {
     $request = $this->getRequest();
     //Intanciamos nuestro formulario
     $pacienteForm = new PacienteForm();
     if ($request->isPost()) {
         //Si hicieron POST
         //Instanciamos nuestro filtro
         $pacienteFilter = new PacienteFilter();
         //Le ponemos nuestro filtro a nuesto fromulario
         $pacienteForm->setInputFilter($pacienteFilter->getInputFilter());
         //Le ponemos los datos a nuestro formulario
         $pacienteForm->setData($request->getPost());
         //Validamos nuestro formulario
         if ($pacienteForm->isValid()) {
             //Instanciamos un nuevo objeto de nuestro objeto Paciente
             $paciente = new Paciente();
             //Recorremos nuestro formulario y seteamos los valores a nuestro objeto Paciente
             foreach ($pacienteForm->getData() as $pacienteKey => $pacienteValue) {
                 if ($pacienteKey != 'pacientefacturacion_rfc') {
                     $paciente->setByName($pacienteKey, $pacienteValue, \BasePeer::TYPE_FIELDNAME);
                 }
             }
             //Guardamos en nuestra base de datos
             $paciente->save();
             // Si nos mandan RFC
             if ($request->getPost()->pacientefacturacion_rfc != null) {
                 $pacientefacturacion = new \Pacientefacturacion();
                 $pacientefacturacion->setIdpaciente($paciente->getIdpaciente());
                 $pacientefacturacion->setPacientefacturacionCalle($paciente->getPacienteCalle());
                 $pacientefacturacion->setPacientefacturacionNoexterior($paciente->getPacienteNoexterior());
                 $pacientefacturacion->setPacientefacturacionNointerior($paciente->getPacienteNointerior());
                 $pacientefacturacion->setPacientefacturacionColonia($paciente->getPacienteColonia());
                 $pacientefacturacion->setPacientefacturacionCiudad($paciente->getPacienteCiudad());
                 $pacientefacturacion->setPacientefacturacionCodigopostal($paciente->getPacienteCodigopostal());
                 $pacientefacturacion->setPacientefacturacionEstado($paciente->getPacienteEstado());
                 $pacientefacturacion->setPacientefacturacionPais($paciente->getPacientePais());
                 $pacientefacturacion->setPacientefacturacionRfc($request->getPost()->pacientefacturacion_rfc);
                 $pacientefacturacion->save();
             }
             //Agregamos un mensaje
             $this->flashMessenger()->addMessage('Paciente guardado exitosamente!');
             $pacienteQuery = PacienteQuery::create()->filterByIdpaciente($paciente->getIdpaciente())->findOne();
             return new ViewModel(array('pacienteQuery' => $pacienteQuery, 'pacienteForm' => $pacienteForm, 'flashMessages' => $this->flashMessenger()->getMessages()));
             //Redireccionamos a nuestro list
             //return $this->redirect()->toRoute('pacientes');
         }
     }
     return new ViewModel(array('pacienteForm' => $pacienteForm));
 }
Exemplo n.º 2
0
 public function nuevodatosfacturacionAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $post_data = $request->getPost();
         $pacientefactuacion = new \Pacientefacturacion();
         foreach ($post_data as $key => $value) {
             $pacientefactuacion->setByName($key, $value, \BasePeer::TYPE_FIELDNAME);
         }
         $pacientefactuacion->save();
         return $this->getResponse()->setContent(\Zend\Json\Json::encode(array('response' => true, 'data' => $pacientefactuacion->toArray(\BasePeer::TYPE_FIELDNAME))));
     }
     $viewModel = new ViewModel();
     $viewModel->setTerminal(true);
     return $viewModel;
 }
Exemplo n.º 3
0
 /**
  * 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->aAdmision !== null) {
             if ($this->aAdmision->isModified() || $this->aAdmision->isNew()) {
                 $affectedRows += $this->aAdmision->save($con);
             }
             $this->setAdmision($this->aAdmision);
         }
         if ($this->aConsulta !== null) {
             if ($this->aConsulta->isModified() || $this->aConsulta->isNew()) {
                 $affectedRows += $this->aConsulta->save($con);
             }
             $this->setConsulta($this->aConsulta);
         }
         if ($this->aPacientefacturacion !== null) {
             if ($this->aPacientefacturacion->isModified() || $this->aPacientefacturacion->isNew()) {
                 $affectedRows += $this->aPacientefacturacion->save($con);
             }
             $this->setPacientefacturacion($this->aPacientefacturacion);
         }
         if ($this->aVenta !== null) {
             if ($this->aVenta->isModified() || $this->aVenta->isNew()) {
                 $affectedRows += $this->aVenta->save($con);
             }
             $this->setVenta($this->aVenta);
         }
         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;
 }