public function nuevoAction() { $request = $this->getRequest(); if ($request->isPost()) { $post_data = $request->getPost(); $cita_hora = date("H:i", strtotime($post_data['cita_hora'])); $cita = new \Cita(); $cita->setIdpaciente($post_data['idpaciente'])->setCitaFecha($post_data['cita_fecha_submit'])->setCitaHora($cita_hora)->setCitaDescripcion($post_data['cita_descripcion']); if (!empty($post_data['idmedico'])) { $cita->setIdmedico($post_data['idmedico']); $citasCollection = \CitaQuery::create()->filterByIdmedico($post_data['idmedico'])->filterByCitaFecha($post_data['cita_fecha_submit'])->find(); $disponibilidad = true; foreach ($citasCollection as $citaEntity) { $time = strtotime($citaEntity->getCitaHora()); $endTime = date("H:i", strtotime('+10 minutes', $time)); if (strtotime($cita_hora) >= $time && strtotime($cita_hora) <= strtotime('+10 minutes', $time)) { $disponibilidad = false; } } if (!$disponibilidad) { //Agregamos un mensaje $medico = \MedicoQuery::create()->findPk($post_data['idmedico']); $this->flashMessenger()->addMessage('Los sentimos, pero el medico ' . $medico->getMedicoNombre() . ' ' . $medico->getMedicoApellidopaterno() . ' ' . $medico->getMedicoApellidomaterno() . ' no tiene disponibilidad para la fecha y hora seleccionada'); return $this->redirect()->toUrl('/pacientes/agendarcita/nuevo/' . $post_data['idpaciente']); } else { $cita->save(); //Agregamos un mensaje $this->flashMessenger()->addMessage('Cita Agendada exitosamente!'); //Redireccionamos a nuestro list return $this->redirect()->toRoute('citas'); } } else { $cita->save(); //Agregamos un mensaje $this->flashMessenger()->addMessage('Cita Agendada exitosamente!'); //Redireccionamos a nuestro list return $this->redirect()->toRoute('citas'); } } //Cachamos el valor desde nuestro params $id = (int) $this->params()->fromRoute('id'); $paciente = \PacienteQuery::create()->findPk($id)->toArray(\BasePeer::TYPE_FIELDNAME); $medicos = \MedicoQuery::create()->find(); $medicos_array = array(); if (!empty($medicos)) { foreach ($medicos as $medico) { $idmedico = $medico->getIdmedico(); $medicos_array[$idmedico] = $medico->getMedicoNombre() . ' ' . $medico->getMedicoApellidopaterno() . ' ' . $medico->getMedicoApellidomaterno(); } } //Instanciamos nuestro fomrulario $form = new CitasForm($medicos_array); $form->get('idpaciente')->setValue($id); $collection = \PacienteQuery::create()->find()->toArray(null, false, \BasePeer::TYPE_FIELDNAME); return new ViewModel(array('paciente' => $paciente, 'form' => $form, 'flashMessages' => $this->flashMessenger()->getMessages())); }
public function nuevoAction() { $medicos = \MedicoQuery::create()->find(); $medicos_array = array(); if (!empty($medicos)) { foreach ($medicos as $medico) { $idmedico = $medico->getIdmedico(); $tmp[$idmedico] = $medico->getMedicoNombre() . ' ' . $medico->getMedicoApellidopaterno() . ' ' . $medico->getMedicoApellidomaterno(); $medicos_array[] = $tmp; } } //Instanciamos nuestro fomrulario $form = new CitasForm($medicos_array); $collection = \PacienteQuery::create()->find()->toArray(null, false, \BasePeer::TYPE_FIELDNAME); return new ViewModel(array('form' => $form)); }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @throws Exception * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(PacientePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = PacienteQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
/** * Get the associated Paciente object * * @param PropelPDO $con Optional Connection object. * @param $doQuery Executes a query to get the object if required * @return Paciente The associated Paciente object. * @throws PropelException */ public function getPaciente(PropelPDO $con = null, $doQuery = true) { if ($this->aPaciente === null && $this->idpaciente !== null && $doQuery) { $this->aPaciente = PacienteQuery::create()->findPk($this->idpaciente, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aPaciente->addConsultas($this); */ } return $this->aPaciente; }
public function getpacientesAction() { $collection = \PacienteQuery::create()->find()->toArray(null, false, \BasePeer::TYPE_FIELDNAME); $autcomplete = array(); foreach ($collection as $entity) { $tmp['value'] = $entity["idpaciente"]; $tmp['label'] = $entity["paciente_nombre"] . ' ' . $entity['paciente_ap'] . ' ' . $entity['paciente_am']; $conceptos_autcomplete[] = $tmp; } return $this->getResponse()->setContent(\Zend\Json\Json::encode($conceptos_autcomplete)); }