public function serversideAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         //EL MAPEO DE NUESTRA TABALA
         $table_map = array(0 => 'servicio_nombre', 1 => 'servicio_tipo', 2 => 'servicio_medio');
         $post_data = $request->getPost();
         //NUESTRA QUERY
         $query = new \ServicioQuery();
         //ORDER
         if (isset($post_data['order'])) {
             $order = $table_map[$post_data['order'][0]['column']];
             $dir = $post_data['order'][0]['dir'];
             $query->orderBy($order, $dir);
         } else {
             $query->orderByIdservicio(\Criteria::DESC);
         }
         if (!empty($post_data['search']['value'])) {
             $search = $post_data['search']['value'];
             $c = new \Criteria();
             $c1 = $c->getNewCriterion('servicio.servicio_tipo', '%' . $search . '%', \Criteria::LIKE);
             $c2 = $c->getNewCriterion('servicio.servicio_medio', '%' . $search . '%', \Criteria::LIKE);
             $c3 = $c->getNewCriterion('servicio.servicio_nombre', '%' . $search . '%', \Criteria::LIKE);
             $c4 = $c->getNewCriterion('servicio.servicio_descripcion', '%' . $search . '%', \Criteria::LIKE);
             $c1->addOr($c2)->addOr($c3)->addOr($c4);
             $query->addAnd($c1);
         }
         //EL TOTAL DE LA BUSQUEDA
         $recordsFiltered = $query->count();
         //LIMIT
         $query->setOffset((int) $post_data['start']);
         $query->setLimit((int) $post_data['length']);
         //DAMOS EL FORMATO CORRECTO
         $data = array();
         $value = new \Servicio();
         foreach ($query->find() as $value) {
             $tmp['DT_RowId'] = $value->getIdservicio();
             $tmp['servicio_nombre'] = $value->getServicioNombre();
             $tmp['servicio_tipo'] = $value->getServicioTipo();
             $tmp['servicio_medio'] = $value->getServicioMedio();
             $tmp['servicio_descripcion'] = $value->getServicioDescripcion();
             $tmp['servicio_options'] = '<a data-toggle="tooltip" data-placement="left" title="Editar" href="/catalogo/servicios/editar/' . $value->getIdservicio() . '"><i class="fa fa-pencil"></i></a>';
             $data[] = $tmp;
         }
         //El arreglo que regresamos
         $json_data = array("draw" => (int) $post_data['draw'], "recordsFiltered" => $recordsFiltered, "data" => $data, "page" => $post_data['url_params']['page']);
         return $this->getResponse()->setContent(json_encode($json_data));
     }
 }
 /**
  * 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 Servicio $obj A Servicio 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->getIdservicio();
         }
         // if key === null
         ServicioPeer::$instances[$key] = $obj;
     }
 }
Exemple #3
0
 /**
  * Declares an association between this object and a Servicio object.
  *
  * @param                  Servicio $v
  * @return Cargoadmision The current object (for fluent API support)
  * @throws PropelException
  */
 public function setServicio(Servicio $v = null)
 {
     if ($v === null) {
         $this->setIdservicio(NULL);
     } else {
         $this->setIdservicio($v->getIdservicio());
     }
     $this->aServicio = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Servicio object, it will not be re-added.
     if ($v !== null) {
         $v->addCargoadmision($this);
     }
     return $this;
 }
Exemple #4
0
 /**
  * Exclude object from result
  *
  * @param   Servicio $servicio Object to remove from the list of results
  *
  * @return ServicioQuery The current query, for fluid interface
  */
 public function prune($servicio = null)
 {
     if ($servicio) {
         $this->addUsingAlias(ServicioPeer::IDSERVICIO, $servicio->getIdservicio(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
 /**
  * Filter the query by a related Servicio object
  *
  * @param   Servicio|PropelObjectCollection $servicio The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 ExpedienteservicioQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByServicio($servicio, $comparison = null)
 {
     if ($servicio instanceof Servicio) {
         return $this->addUsingAlias(ExpedienteservicioPeer::IDSERVICIO, $servicio->getIdservicio(), $comparison);
     } elseif ($servicio instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(ExpedienteservicioPeer::IDSERVICIO, $servicio->toKeyValue('PrimaryKey', 'Idservicio'), $comparison);
     } else {
         throw new PropelException('filterByServicio() only accepts arguments of type Servicio or PropelCollection');
     }
 }
 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;
 }