public function serversideAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         //EL MAPEO DE NUESTRA TABALA
         $table_map = array(0 => 'categoriagasto_nombre', 1 => 'categoriagasto_descripcion');
         $post_data = $request->getPost();
         //NUESTRA QUERY
         $query = new \CategoriagastoQuery();
         //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->orderByIdcategoriagasto(\Criteria::DESC);
         }
         if (!empty($post_data['search']['value'])) {
             $search = $post_data['search']['value'];
             $c = new \Criteria();
             $c1 = $c->getNewCriterion('categoriagasto.categoriagasto_nombre', '%' . $search . '%', \Criteria::LIKE);
             $c2 = $c->getNewCriterion('categoriagasto.categoriagasto_descripcion', '%' . $search . '%', \Criteria::LIKE);
             $c1->addOr($c2);
             $query->addAnd($c1);
         }
         //EL TOTAL DE LA BUSQUEDA
         $recordsFiltered = $query->count();
         //SUSTITUIMOS VARIABLES SI NOS LAS ENVIAN POR LA URL
         if (isset($post_data['url_params']['limit']) && isset($post_data['url_params']['page'])) {
             $post_data['length'] = (int) $post_data['url_params']['limit'];
             $post_data['start'] = 0;
             if ((int) $post_data['url_params']['page'] > 1) {
                 $post_data['start'] = $post_data['url_params']['limit'] * ((int) $post_data['url_params']['page'] - 1);
             }
         }
         //LIMIT
         $query->setOffset((int) $post_data['start']);
         $query->setLimit((int) $post_data['length']);
         //DAMOS EL FORMATO CORRECTO
         $data = array();
         $value = new \Categoriagasto();
         foreach ($query->find() as $value) {
             $tmp['DT_RowId'] = $value->getIdcategoriagasto();
             $tmp['categoriagasto_nombre'] = $value->getCategoriagastoNombre();
             $tmp['categoriagasto_descripcion'] = $value->getCategoriagastoDescripcion();
             $tmp['gastofacturacion_options'] = '<a data-toggle="tooltip" data-placement="left" title="Editar" href="/catalogo/categorias-gastos/editar/' . $value->getIdcategoriagasto() . '"><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));
     }
 }