/**
  * Returns a new ServicioestadoQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param   ServicioestadoQuery|Criteria $criteria Optional Criteria to build the query from
  *
  * @return ServicioestadoQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof ServicioestadoQuery) {
         return $criteria;
     }
     $query = new ServicioestadoQuery(null, null, $modelAlias);
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
 /**
  * Get the associated Servicioestado object
  *
  * @param PropelPDO $con Optional Connection object.
  * @param $doQuery Executes a query to get the object if required
  * @return Servicioestado The associated Servicioestado object.
  * @throws PropelException
  */
 public function getServicioestado(PropelPDO $con = null, $doQuery = true)
 {
     if ($this->aServicioestado === null && $this->idestadoservicio !== null && $doQuery) {
         $this->aServicioestado = ServicioestadoQuery::create()->findPk($this->idestadoservicio, $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->aServicioestado->addExpedientehistorials($this);
            */
     }
     return $this->aServicioestado;
 }
示例#3
0
 /**
  * Returns the number of related Servicioestado objects.
  *
  * @param Criteria $criteria
  * @param boolean $distinct
  * @param PropelPDO $con
  * @return int             Count of related Servicioestado objects.
  * @throws PropelException
  */
 public function countServicioestados(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     $partial = $this->collServicioestadosPartial && !$this->isNew();
     if (null === $this->collServicioestados || null !== $criteria || $partial) {
         if ($this->isNew() && null === $this->collServicioestados) {
             return 0;
         }
         if ($partial && !$criteria) {
             return count($this->getServicioestados());
         }
         $query = ServicioestadoQuery::create(null, $criteria);
         if ($distinct) {
             $query->distinct();
         }
         return $query->filterByServicio($this)->count($con);
     }
     return count($this->collServicioestados);
 }
示例#4
0
 /**
  * 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(ServicioestadoPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = ServicioestadoQuery::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;
     }
 }
 public function editarhistorialAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $post_data = $request->getPost();
         $id = $post_data['idexpedientehistorial'];
         $entity = \ExpedientehistorialQuery::create()->findPk($id);
         foreach ($post_data as $key => $value) {
             if (\ExpedientehistorialPeer::getTableMap()->hasColumn($key) && !empty($value)) {
                 $entity->setByName($key, $value, \BasePeer::TYPE_FIELDNAME);
             }
         }
         $entity->save();
         //Validamos si se va enviar por correo al cliente
         if (isset($post_data['sendemail'])) {
             $cliente = $entity->getExpedienteservicio()->getExpediente()->getCliente();
             $new_status = $entity->getServicioestado()->getServicioestadoNombre();
             $folio = $entity->getExpedienteservicio()->getExpediente()->getExpedienteFolio();
             $mailer = new \Shared\GeneralFunction\Itrademailer();
             if ($mailer->changeStatusEmail($cliente, $folio, $new_status)) {
                 $this->flashMessenger()->addSuccessMessage('Correo electronico enviado exitosamente!');
             }
         }
         $this->flashMessenger()->addSuccessMessage('Registro guardado exitosamente!');
         //REDIRECCIONAMOS A LA ENTIDAD QUE ACABAMOS DE CREAR
         return $this->redirect()->toUrl('/clientes/ver/' . $entity->getExpedienteservicio()->getExpediente()->getIdcliente() . '/expedientes/ver/' . $entity->getExpedienteservicio()->getIdexpediente());
     }
     $id = $this->params()->fromQuery('id');
     $entity = \ExpedientehistorialQuery::create()->findPk($id);
     $expedienteservicio = $entity->getExpedienteservicio();
     $expediente = $expedienteservicio->getExpediente();
     //Obtenemos los estatus disponibles dependiendo del servicio seleccionado
     $servicio_estatus = array();
     $servicioestatus = \ServicioestadoQuery::create()->filterByIdservicio($expedienteservicio->getIdservicio())->find();
     $estatus = new \Servicioestado();
     foreach ($servicioestatus as $estatus) {
         $id = $estatus->getIdservicioestado();
         $servicio_estatus[$id] = $estatus->getServicioestadoNombre();
     }
     //Instanciamos nuestro formurmalario
     $form = new \Admin\Clientes\Form\HistorialForm($expedienteservicio->getIdexpedienteservicio(), $servicio_estatus);
     $form->setData($entity->toArray(\BasePeer::TYPE_FIELDNAME));
     //Enviamos a la vista
     $view_model = new ViewModel();
     $view_model->setTerminal(true)->setVariable('form', $form)->setVariable('entity', $expediente)->setTemplate('/clientes/expedientes/modal/editarhistorial');
     return $view_model;
     echo '<pre>';
     var_dump($entity->toArray());
     echo '</pre>';
     exit;
 }