function fecha_formato($formato = "%Y-%m-%d", $fecha) { if (!empty($fecha)) { $f = mdate($formato, normal_to_unix($fecha)); return $f; } else { return FALSE; } }
public function filters($offset = 0) { $this->load->helpers('date'); $string = '%' . $this->input->post('estudiante') . '%'; $usuario = $this->input->post('user_id'); $fecha_desde = $this->input->post('fecha_desde'); $fecha_hasta = $this->input->post('fecha_hasta'); $condiciones = 'anulado = ?'; $valores[] = 0; if ($string != '%%') { $condiciones .= " AND CONCAT(students.apellido,' ', students.nombre) LIKE ?"; $valores[] = $string; } if ($usuario > 0) { /*if($condiciones != ''){ $condiciones .= " AND "; }*/ $condiciones .= " AND user_id = ?"; $valores[] = $usuario; } if ($fecha_desde != '') { $fecha_desde = mdate('%Y-%m-%d', normal_to_unix($fecha_desde)); if ($fecha_hasta != '') { $fecha_hasta = mdate('%Y-%m-%d', normal_to_unix($fecha_hasta)); } else { $fecha_hasta = date('Y-m-d'); } /*if($condiciones != ''){ $condiciones .= " AND "; }*/ $condiciones .= " AND fecha BETWEEN ? AND ?"; $valores[] = $fecha_desde; $valores[] = $fecha_hasta; } $conditions = array_merge(array($condiciones), $valores); $config['base_url'] = site_url('pagos/index'); $config['total_rows'] = Payment::count(array('joins' => array('student'), 'conditions' => $conditions)); $config['per_page'] = '10'; $config['num_links'] = '10'; $config['first_link'] = '← primero'; $config['last_link'] = 'Ășltimo →'; $this->load->library('pagination', $config); $pagos = array(); $pagos = Payment::all(array('joins' => array('student'), 'conditions' => $conditions, 'limit' => $config['per_page'], 'offset' => $offset)); $this->table->set_heading('Fecha', 'Nro Comprobante', 'Estudiante', 'Importe', 'Usuario', 'Acciones'); foreach ($pagos as $pago) { $this->table->add_row($pago->fecha->format('d/m/Y'), $pago->nro_comprobante, $pago->student->apellido . ' ' . $pago->student->nombre, $pago->importe, $pago->user->apellido . ' ' . $pago->user->nombre, anchor('pagos/ver/' . $pago->id, img('static/img/icon/doc_lines.png'), 'class="tipwe" title="Ver detalles pago"') . ' ' . anchor('pagos/editar/' . $pago->id, img('static/img/icon/pencil.png'), 'class="tipwe" title="Editar pago"') . ' ' . anchor('pagos/eliminar/' . $pago->id, img('static/img/icon/trash.png'), 'class="tipwe eliminar" title="Eliminar pago"')); } echo $this->table->generate(); echo '<div class="pagination">'; echo $this->pagination->create_links(); echo '</div>'; }