public function serversideAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         //EL MAPEO DE NUESTRA TABALA
         $table_map = array(0 => 'cliente_razonsocial', 1 => 'cliente_nombrecontacto', 2 => 'cliente_email', 3 => 'cliente_celular', 4 => 'cliente_ciudad', 5 => 'cliente_pais');
         $post_data = $request->getPost();
         //NUESTRA QUERY
         $query = new \ClienteQuery();
         //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->orderByIdcliente(\Criteria::DESC);
         }
         if (!empty($post_data['search']['value'])) {
             $search = $post_data['search']['value'];
             $c = new \Criteria();
             $c1 = $c->getNewCriterion('cliente.cliente_razonsocial', '%' . $search . '%', \Criteria::LIKE);
             $c2 = $c->getNewCriterion('cliente.cliente_nombrecontacto', '%' . $search . '%', \Criteria::LIKE);
             $c3 = $c->getNewCriterion('cliente.cliente_celular', '%' . $search . '%', \Criteria::LIKE);
             $c4 = $c->getNewCriterion('cliente.cliente_ciudad', '%' . $search . '%', \Criteria::LIKE);
             $c5 = $c->getNewCriterion('cliente.cliente_estado', '%' . $search . '%', \Criteria::LIKE);
             $c6 = $c->getNewCriterion('cliente.cliente_pais', '%' . $search . '%', \Criteria::LIKE);
             $c1->addOr($c2)->addOr($c3)->addOr($c4)->addOr($c5)->addOr($c6);
             $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 \Cliente();
         foreach ($query->find() as $value) {
             $tmp['DT_RowId'] = $value->getIdcliente();
             $tmp['cliente_razonsocial'] = $value->getClienteRazonsocial();
             $tmp['cliente_nombrecontacto'] = $value->getClienteNombrecontacto();
             $tmp['cliente_email'] = $value->getClienteEmail();
             $tmp['cliente_telefono'] = $value->getClienteTelefono();
             $tmp['cliente_ciudad'] = $value->getClienteCiudad();
             if (!is_null($value->getClienteEstado())) {
                 $tmp['cliente_ciudad'] .= ', ' . $value->getClienteEstado();
             }
             $tmp['cliente_pais'] = $value->getClientePais();
             $tmp['cliente_options'] = '<a data-toggle="tooltip" data-placement="left" title="Editar" href="/clientes/ver/' . $value->getIdcliente() . '"><i class="fa fa-pencil"></i></a><a class="delete" data-toggle="tooltip" data-placement="left" title="Eliminar" href="javascript:void(0)"><i class="fa fa-trash-o"></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));
     }
 }
 /**
  * Filter the query by a related Cliente object
  *
  * @param   Cliente|PropelObjectCollection $cliente The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 ExpedienteQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByCliente($cliente, $comparison = null)
 {
     if ($cliente instanceof Cliente) {
         return $this->addUsingAlias(ExpedientePeer::IDCLIENTE, $cliente->getIdcliente(), $comparison);
     } elseif ($cliente instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(ExpedientePeer::IDCLIENTE, $cliente->toKeyValue('PrimaryKey', 'Idcliente'), $comparison);
     } else {
         throw new PropelException('filterByCliente() only accepts arguments of type Cliente or PropelCollection');
     }
 }
 /**
  * Declares an association between this object and a Cliente object.
  *
  * @param                  Cliente $v
  * @return Clientearchivo The current object (for fluent API support)
  * @throws PropelException
  */
 public function setCliente(Cliente $v = null)
 {
     if ($v === null) {
         $this->setIdcliente(NULL);
     } else {
         $this->setIdcliente($v->getIdcliente());
     }
     $this->aCliente = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Cliente object, it will not be re-added.
     if ($v !== null) {
         $v->addClientearchivo($this);
     }
     return $this;
 }
 /**
  * Exclude object from result
  *
  * @param   Cliente $cliente Object to remove from the list of results
  *
  * @return ClienteQuery The current query, for fluid interface
  */
 public function prune($cliente = null)
 {
     if ($cliente) {
         $this->addUsingAlias(ClientePeer::IDCLIENTE, $cliente->getIdcliente(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Exemple #5
0
 /**
  * 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 Cliente $obj A Cliente 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->getIdcliente();
         }
         // if key === null
         ClientePeer::$instances[$key] = $obj;
     }
 }