/**
  * Declares an association between this object and a Servicioestado object.
  *
  * @param                  Servicioestado $v
  * @return Expedientehistorial The current object (for fluent API support)
  * @throws PropelException
  */
 public function setServicioestado(Servicioestado $v = null)
 {
     if ($v === null) {
         $this->setIdestadoservicio(NULL);
     } else {
         $this->setIdestadoservicio($v->getIdservicioestado());
     }
     $this->aServicioestado = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Servicioestado object, it will not be re-added.
     if ($v !== null) {
         $v->addExpedientehistorial($this);
     }
     return $this;
 }
 /**
  * Exclude object from result
  *
  * @param   Servicioestado $servicioestado Object to remove from the list of results
  *
  * @return ServicioestadoQuery The current query, for fluid interface
  */
 public function prune($servicioestado = null)
 {
     if ($servicioestado) {
         $this->addUsingAlias(ServicioestadoPeer::IDSERVICIOESTADO, $servicioestado->getIdservicioestado(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
 /**
  * Filter the query by a related Servicioestado object
  *
  * @param   Servicioestado|PropelObjectCollection $servicioestado The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 ExpedientehistorialQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByServicioestado($servicioestado, $comparison = null)
 {
     if ($servicioestado instanceof Servicioestado) {
         return $this->addUsingAlias(ExpedientehistorialPeer::IDESTADOSERVICIO, $servicioestado->getIdservicioestado(), $comparison);
     } elseif ($servicioestado instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(ExpedientehistorialPeer::IDESTADOSERVICIO, $servicioestado->toKeyValue('PrimaryKey', 'Idservicioestado'), $comparison);
     } else {
         throw new PropelException('filterByServicioestado() only accepts arguments of type Servicioestado or PropelCollection');
     }
 }
 /**
  * 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 Servicioestado $obj A Servicioestado object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getIdservicioestado();
         }
         // if key === null
         ServicioestadoPeer::$instances[$key] = $obj;
     }
 }
 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;
 }