コード例 #1
0
ファイル: mkc_paginate.php プロジェクト: slrondon/WispCenter
 /**
  * Método para paginar resultados utilizando el método find_all_by_sql de los modelos <br>
  *
  * Retorna un PageObject que tiene los siguientes atributos: <br>
  * next: numero de pagina siguiente, si no hay pagina siguiente entonces es false <br>
  * prev: numero de pagina anterior, si no hay pagina anterior entonces es false <br>
  * current: numero de pagina actual <br>
  * total: total de paginas que se pueden mostrar <br>
  * items: array de items de la pagina <br>
  * counter: Número que lleva el conteo de la página <br>
  * size: Total de registros <br>
  * per_page: cantidad de elementos por pagina <br>
  *
  *
  * @param string $model modelo
  * @param string $sql consulta sql
  * @return stdClass
  */
 public static function paginate_by_sql($model, $sql)
 {
     $params = Util::getParams(func_get_args());
     $page_number = isset($params['page']) ? Filter::get($params['page'], 'numeric') : 1;
     //Numero de la página
     $per_page = isset($params['per_page']) ? Filter::get($params['per_page'], 'numeric') : DATAGRID;
     //Datos por página
     $counter = $page_number > 1 ? $page_number * $per_page - ($per_page - 1) : 1;
     //Determino el contador para utilizarlo en la vista
     $start = $per_page * ($page_number - 1);
     //Determino el offset
     $page = new stdClass();
     //Instancia del objeto contenedor de pagina
     $total_items = $model->count_by_sql("SELECT COUNT(*) FROM ({$sql}) AS t");
     //Se cuentan los registros
     $page->items = $model->find_all_by_sql($model->limit($sql, "offset: {$start}", "limit: {$per_page}"));
     //Se efectua la búsqueda
     //Se efectuan los cálculos para las paginas
     $page->next = $start + $per_page < $total_items ? $page_number + 1 : false;
     $page->prev = $page_number > 1 ? $page_number - 1 : false;
     $page->current = $page_number;
     $page->total_page = ceil($total_items / $per_page);
     if ($page->total_page < $page_number && $total_items > 0) {
         $page->prev = false;
         $url = Router::get('route');
         $url = explode('pag', $url);
         $url = trim($url[0], '/');
         MkcMessage::error('La página solicitada no se encuentra en el paginador.  <br />' . MkcHtml::link($url, 'Regresar a la página 1'));
     }
     $page->counter = $total_items >= $counter ? $counter : 1;
     $page->size = $total_items;
     $page->per_page = $per_page;
     return $page;
 }
コード例 #2
0
ファイル: mkc_menu.php プロジェクト: slrondon/WispCenter
 /**
  * Método para listar los items en el backend
  */
 public static function getItems()
 {
     $route = trim(Router::get('route'), '/');
     $html = '';
     foreach (self::$_items as $menu => $items) {
         $html .= '<div id="sub-menu-' . MkcUtils::getSlug($menu) . '" class="subnav hidden">' . PHP_EOL;
         $html .= '<ul class="treview-menu nav nav-pills">' . PHP_EOL;
         if (array_key_exists($menu, self::$_items)) {
             foreach (self::$_items[$menu] as $item) {
                 if (!APP_OFFICE && $item->id == Menu::SUCURSAL) {
                     continue;
                 }
                 $active = ($item->url == $route or $item->url == 'principal') ? 'active' : null;
                 $submenu = $item->getListadoSubmenuPorPerfil(self::$_entorno, self::$_perfil, $item->id);
                 if ($submenu) {
                     $html .= '<li class="' . $active . 'treview dropdown">';
                     $html .= MkcHtml::link($item->url, ' <i class="fa fa-' . $main->icono . '"></i>' . $item->menu, array('class' => 'dropdown-toggle', 'role' => "button", "data-toggle" => "dropdown"), $item->icono);
                     $html .= '<ul class="treview-menu dropdown-menu" role="menu">';
                     foreach ($submenu as $tmp) {
                         $html .= '<li>' . MkcHtml::link($tmp->url, $tmp->menu, null, $tmp->icono) . '</li>' . PHP_EOL;
                     }
                     $html .= '</ul>' . PHP_EOL;
                     $html .= '</li>' . PHP_EOL;
                 } else {
                     $html .= '<li class="' . $active . '">' . MkcHtml::link($item->url, $item->menu, null, $item->icono) . '</li>' . PHP_EOL;
                 }
             }
         }
         $html .= '</ul>' . PHP_EOL;
         $html .= '</div>' . PHP_EOL;
     }
     return $html;
 }
コード例 #3
0
ファイル: breadcrumb.php プロジェクト: slrondon/WispCenter
 /**
  * Breadcrumb::display()
  *
  * Genera el breadcrumb
  *
  * @return string
  */
 public function display()
 {
     $this->_jobs();
     do {
         $crumb = current($this->_path);
         if (next($this->_path) && !empty($crumb['title'])) {
             prev($this->_path);
             $html[] = "<li>" . MkcHtml::link($crumb['url'], $crumb['title']) . "</li>";
         } elseif (!empty($crumb['title'])) {
             $html[] = "<li><a href='javascript: void(0)'>{$crumb['title']}</a></li>";
         }
     } while (next($this->_path));
     self::reset();
     if (is_null($this->attrs['separator'])) {
         return "<ol class='{$this->attrs['class_ol']}'>" . implode('', $html) . '</ol>';
     } else {
         return "<ol class='{$this->attrs['class_ol']}'>" . implode("<li class='{$this->attrs['class_separator']}'><a href='javascript: void(0)'>{$this->attrs['separator']}</a></li>", $html) . '</ol>';
     }
 }
コード例 #4
0
ファイル: mkc_button.php プロジェクト: slrondon/WispCenter
 /**
  * Método para crear un botón para imprimir reportes
  * @param type $path Ruta del controlador del módulo de reporte
  * @param type $file Tipos de formato de reporte
  * @param type $title (opcional) Titulo del botón
  * @param type $text (opcional) Texto a mostrar en el botón
  * @return type
  */
 public static function report($path, $files = 'html', $title = '', $text = '')
 {
     $path = '/reporte/' . trim($path, '/') . '/';
     //Verifico los tipos de archivo para llevar un orden específico
     $types = array();
     //Verifico si tiene el formato de impresora fiscal
     if (preg_match("/\\bticket\\b/i", $files)) {
         $types[] = 'ticket';
     }
     //Verifico si tiene el formato html
     if (preg_match("/\\bhtml\\b/i", $files)) {
         $types[] = 'html';
     }
     //Verifico si tiene el formato pdf
     if (preg_match("/\\bpdf\\b/i", $files)) {
         $types[] = 'pdf';
     }
     //Verifico si tiene el formato xls
     if (preg_match("/\\bxls\\b/i", $files)) {
         $types[] = 'xls';
     }
     //Verifico si tiene el formato xlsx
     if (preg_match("/\\bxlsx\\b/i", $files)) {
         $types[] = 'xlsx';
     }
     //Verifico si tiene el formato doc
     if (preg_match("/\\bdoc\\b/i", $files)) {
         $types[] = 'doc';
     }
     //Verifico si tiene el formato docx
     if (preg_match("/\\bdocx\\b/i", $files)) {
         $types[] = 'docx';
     }
     //Verifico si tiene el formato xml
     if (preg_match("/\\bxml\\b/i", $files)) {
         $types[] = 'xml';
     }
     //Verifico si tiene el formato docx
     if (preg_match("/\\bcsv\\b/i", $files)) {
         $types[] = 'csv';
     }
     //Uno los tipos
     $files = join('|', $types);
     $attrs = array();
     $attrs['class'] = 'btn-info js-report no-load';
     $attrs['title'] = 'Imprimir reporte';
     $attrs['data-report-title'] = empty($title) ? 'Imprimir reporte' : $title;
     $attrs['data-report-format'] = $files;
     if (empty($text)) {
         return MkcHtml::button($path, '', $attrs, 'print');
     } else {
         return MkcHtml::button($path, strtoupper($text), $attrs, 'print');
     }
 }