public function serversideAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         //EL MAPEO DE NUESTRA TABALA
         $table_map = array(0 => 'proveedorcliente_nombre', 1 => 'proveedorcliente_taxid', 2 => 'proveedorcliente_nombrecontacto', 3 => 'proveedorcliente_telefonocontacto');
         $post_data = $request->getPost();
         //NUESTRA QUERY
         $query = new \ProveedorclienteQuery();
         $query->filterByIdcliente($post_data['idcliente'])->filterByproveedorclienteTipo('cliente');
         //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('proveedorcliente.proveedorcliente_nombre', '%' . $search . '%', \Criteria::LIKE);
             $c2 = $c->getNewCriterion('proveedorcliente.proveedorcliente_taxid', '%' . $search . '%', \Criteria::LIKE);
             $c3 = $c->getNewCriterion('proveedorcliente.proveedorcliente_nombrecontacto', '%' . $search . '%', \Criteria::LIKE);
             $c4 = $c->getNewCriterion('proveedorcliente.proveedorcliente_telefonocontacto', '%' . $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 \Proveedorcliente();
         foreach ($query->find() as $value) {
             $tmp['DT_RowId'] = $value->getIdproveedorcliente();
             $tmp['proveedorcliente_nombre'] = $value->getProveedorclienteNombre();
             $tmp['proveedorcliente_taxid'] = $value->getProveedorclienteTaxid();
             $tmp['proveedorcliente_nombrecontacto'] = $value->getProveedorclienteNombrecontacto();
             $tmp['proveedorcliente_telefonocontacto'] = $value->getProveedorclienteTelefonocontacto();
             $tmp['proveedorcliente_options'] = '<a data-toggle="tooltip" data-placement="left" title="Editar" href="/clientes/ver/' . $value->getIdcliente() . '/clientes/editar/' . $value->getIdproveedorcliente() . '"><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));
     }
 }
Example #2
0
 /**
  * Filter the query by a related Proveedorcliente object
  *
  * @param   Proveedorcliente|PropelObjectCollection $proveedorcliente  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 ClienteQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByProveedorcliente($proveedorcliente, $comparison = null)
 {
     if ($proveedorcliente instanceof Proveedorcliente) {
         return $this->addUsingAlias(ClientePeer::IDCLIENTE, $proveedorcliente->getIdcliente(), $comparison);
     } elseif ($proveedorcliente instanceof PropelObjectCollection) {
         return $this->useProveedorclienteQuery()->filterByPrimaryKeys($proveedorcliente->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByProveedorcliente() only accepts arguments of type Proveedorcliente or PropelCollection');
     }
 }