Advertisement
Guest User

Untitled

a guest
May 24th, 2017
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 21.21 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Helpers
  4.  * PHP version 5
  5.  * LICENSE
  6.  *
  7.  * This source file is subject to the GNU/GPL that is bundled
  8.  * with this package in the file docs/LICENSE.txt.
  9.  * It is also available through the world-wide-web at this URL:
  10.  * If you did not receive a copy of the license and are unable to
  11.  * obtain it through the world-wide-web, please send an email
  12.  * to fidel.oyarzo@gmail.com so we can send you a copy immediately.
  13.  *
  14.  * @author Fidel Oyarzo <fidel.oyarzo@gmail.com>
  15.  */
  16. require  '../libs/datagrid/arrays.php';
  17. /**
  18.  * Libreria para dimensionar imagenes
  19.  */
  20. require  '../libs/datagrid/images.php';
  21.  
  22. class dataGrid{
  23.     /**
  24.      * Almacena la versión actual del dataGrid
  25.      *
  26.      */
  27.     const DATAGRID_VERSION = '0.1 rc8';
  28.     /**
  29.     * cambia la hoja de estilo.
  30.     *
  31.     * @var string
  32.     */
  33.     public $style = 'default';
  34.  
  35.     public $contador    =   array();
  36.     /**
  37.      * titulo del datagrid
  38.     * @var string
  39.     */
  40.    public $title_caption        =   '';
  41.    /**
  42.     * Si desea que poder obtener un order by por campo
  43.     * para esto debe recibir el field y el order
  44.     * default = false
  45.     * @var bool
  46.     */
  47.    public $order_fields =   false;
  48.    /**
  49.     * Array de datos q se obtienen de un find
  50.     * @var array
  51.     */
  52.    public $data_source  =   array();
  53.    /**
  54.     * url: url para la accion que efectua la paginacion,
  55.     * por defecto "module/controller/page/" y se envia por parametro el numero de pagina.
  56.     * por defecto busca en el mismo controller y action
  57.     * @var string
  58.     */
  59.    public $url      =   '';
  60.    /**
  61.     * show: número de paginas que se mostraran en el paginador, por defecto 10.
  62.     * @var integer
  63.     */
  64.    public $show     =   10;
  65.    /**
  66.     * Paginator a utilizar. por defecto usa el classic
  67.     *   Classic -   Digg -   Extended -   Punbb -   Simple
  68.     * @var unknown_type
  69.     */
  70.    public $paginator_name = 'default';
  71.    /**
  72.     *URL donde se guardaran registros
  73.   */
  74.    public $save =   '';
  75.    /**
  76.     * Si existe un formulario para editar
  77.     * el registro debe indicar el controller_name y action_name
  78.     * por defecto envia el id
  79.     * @var string
  80.     */
  81.    public $edit         =   '';
  82.    /**
  83.     * Si existe un metodo para eliminar
  84.     * el registro debe indicar el controller_name y action_name
  85.     * por defecto envia el id
  86.     * @var string
  87.     */
  88.    public $delete           =   '';
  89.    /**
  90.     *crea una imagen con el link para ir al formulario create
  91.   */
  92.    public $create           =   '';
  93.    /**
  94.     * NO FUNCIONAL
  95.     * @param $name
  96.     public $auto_delete     =   false;
  97.    
  98.     /**
  99.     * Crear un autofiltro
  100.     *
  101.     */
  102.    public $auto_filter  =   false;
  103.    
  104.    public $btn_save =   'Guardar';
  105.    
  106.    public $btn_caption  =   'Buscar';
  107.     /**
  108.      * Mensaje personalizado antes de elminar
  109.      * alert javascript.
  110.      * elimar el {campo}
  111.      */
  112.     public $delete_confirm  =   '';
  113.     /**
  114.      *
  115.      * Tipos de mimes para las opciones
  116.      * img: action
  117.      */
  118.     public  $array_mimes    =   array();
  119.    
  120.      
  121.     public $get_fields_and_headers  =   array();
  122.     /**
  123.      * Modelo actual
  124.      * @var string
  125.      */
  126.     public $model       =   '';
  127.    
  128.     /**
  129.      * campos que se van a mostrar de la base de datos
  130.      * @var array
  131.      */
  132.     public $fields      =   array();
  133.     /**
  134.      * titulos o cabezeras que se mostra en la table <th></th>
  135.      * @var array
  136.      */
  137.     public $headers     =   array();
  138.     /**
  139.      * usa paginador true or false
  140.      * @var bool
  141.      */
  142.     public $use_paginator   =   false;
  143.     /**
  144.      * campo relacionado a mostrar para los campos _id
  145.      *
  146.      * @var unknown_type
  147.      */
  148.     public $values          =   array();
  149.     /**
  150.      * Tipos de datos para los campos
  151.      * array($id => $type);
  152.      * @var unknown_type
  153.      */
  154.     public $type            =   array();
  155.     public $params          =   array();
  156.     /**
  157.      * Array de campos para su valor a mostrar
  158.     */
  159.     public $array_alias     =   array();
  160.     /**
  161.      *Array para asignar clases a cada campo de la grilla
  162.    */
  163.     public $array_class     =   array();
  164.     /**
  165.      * Array para mostrar una imagen segun el valor del campo
  166.    */
  167.     public $array_image     =   array();
  168.     /**
  169.      *Array para generar los select del auto filtro
  170.      **/
  171.     public $array_select        =   array("0" => "Seleccione ...");
  172.     /**
  173.      *Se crea un chek al principio, esta experimental
  174.    */
  175.     public $set_check       =   FALSE;
  176.     /**
  177.      *Contador para nombrar nuevas columnas
  178.    */
  179.     public $cont_cols       =   0;
  180.  
  181.     public function __construct($model, $model_alias=TRUE) {
  182.     $this->data_source = $model;
  183.     $this->url = Router::get('controller') . '/' . Router::get('action');
  184.     if($this->existData()){
  185.         if(array_key_exists('per_page', $this->data_source)){
  186.         $this->use_paginator = true;
  187.         $this->fields   = array_combine($this->data_source->items[0]->fields, $this->data_source->items[0]->fields);
  188.         if($model_alias){
  189.             $this->headers  = array_combine($this->data_source->items[0]->fields, $this->data_source->items[0]->alias);
  190.         }else{
  191.             $this->headers  = array_combine($this->data_source->items[0]->fields, array_change_value_case($this->data_source->items[0]->fields));
  192.         }
  193.         $this->model    = $this->data_source->items[0]->get_source();
  194.         }else{
  195.         $this->fields   = array_combine($this->data_source[0]->fields, $this->data_source[0]->fields);
  196.         if($model_alias){
  197.             $this->headers  = array_combine($this->data_source[0]->fields, array_change_value_case($this->data_source[0]->fields));
  198.         }else{
  199.             $this->headers  = array_combine($this->data_source[0]->fields, $this->data_source[0]->alias);
  200.         }
  201.         $this->model    = $this->data_source[0]->get_source();
  202.         }
  203.     }
  204.     }
  205.     public function existData(){
  206.     static $i = 0;
  207.     if(count($this->data_source)==1){
  208.         if(array_key_exists('count', $this->data_source)){
  209.         if($this->data_source->count > 0){
  210.             return true;
  211.         }else{
  212.             if($i==0){
  213.             Flash::error('No existen registros');
  214.             $i++;
  215.             }
  216.             return false;
  217.         }
  218.         }else{
  219.         return true;
  220.         }
  221.     }if(count($this->data_source)>0){
  222.         return true;
  223.     }
  224.     if($i==0){
  225.         Flash::error('No existen registros');
  226.         $i++;
  227.     }
  228.     return false;
  229.     }
  230.     /**
  231.      * No visualiza un campo en la Tabla
  232.      * @param $field
  233.      * @return unknown_type
  234.      */
  235.     public function ignore($field){
  236.     if(!$this->existData()) return false;
  237.         if(array_key_exists($field, $this->fields)){
  238.         unset($this->fields[$field]);
  239.         unset($this->headers[$field]);
  240.         } else {
  241.             throw new KumbiaException("No se pudo ignorar, porque el campo: \"$field\" no existe.");
  242.         }      
  243.     }      
  244.     /**
  245.      *Cambia el valor a mostrar según la $field del array $data.
  246.      */
  247.     public function setAlias($field, $data=array()){
  248.     if(!$this->existData()) return false;
  249.         if(array_key_exists($field, $this->fields)){
  250.             array_push_associative($this->array_alias, array($field => $data));
  251.         } else {
  252.             throw new KumbiaException("No se pudo asignar el Alias, porque el campo: \"$field\" no existe.");
  253.     }
  254.     }
  255.     /**
  256.      *Cambia el titulo a mostrar según la key del array $data.
  257.      */    
  258.     public function setCaption($field, $caption){
  259.         if(!$this->existData()) return false;
  260.     if(array_key_exists($field, $this->headers)){
  261.         $replace = array($field => $caption);
  262.         $this->headers = array_replace($this->headers, $replace);
  263.         } else {
  264.             throw new KumbiaException("No se pudo cambiar el nombre de la cabecera, porque el campo: \"$field\" no existe.");
  265.     }
  266.     }
  267.     /**
  268.      * asigna un campo a mostrar de la tabla _id
  269.      * @param $campo_id
  270.      * @param $campo
  271.      */
  272.     public function setValue($field_id, $field){
  273.     if(!$this->existData()) return false;
  274.         if(array_key_exists($field_id, $this->fields)){
  275.             array_push_associative($this->values, array($field_id => $field));
  276.         } else {
  277.             throw new KumbiaException("No se pudo mostrar la asosiación, porque el campo: \"$field_id\" no existe.");
  278.     }
  279.     }
  280.     /**
  281.      * Campo de tipo imagen
  282.      * @param $field
  283.      * @return unknown_type
  284.      */
  285.     public function setTypeImage($field){
  286.     if(!$this->existData()) return false;
  287.         if(array_key_exists($field, $this->fields)){
  288.         unset($this->type[$field]);
  289.         array_push_associative($this->type, array($field => 'dtg_image'));
  290.         } else {
  291.             throw new KumbiaException("No se pudo mostrar la imagen, porque el campo: \"$field\" no existe.");
  292.         }
  293.     }  
  294.     /**
  295.      * Campo de tipo numerico
  296.      * @param $field
  297.      * @return unknown_type
  298.      */
  299.     public function setTypeNumeric($field){
  300.     if(!$this->existData()) return false;
  301.         if(array_key_exists($field, $this->fields)){
  302.         unset($this->type[$field]);
  303.         array_push_associative($this->type, array($field => 'dtg_numeric'));
  304.         } else {
  305.             throw new KumbiaException("No se pudo dar formato, porque el campo: \"$field\" no existe.");
  306.         }
  307.     }
  308.     public function setTypeMoney($field){
  309.     if(!$this->existData()) return false;
  310.         if(array_key_exists($field, $this->fields)){
  311.         unset($this->type[$field]);
  312.         array_push_associative($this->type, array($field => 'dtg_money'));
  313.         } else {
  314.             throw new KumbiaException("No se pudo dar formato, porque el campo: \"$field\" no existe.");
  315.         }  
  316.     }
  317.     public function setTypePercent($field){
  318.     if(!$this->existData()) return false;
  319.         if(array_key_exists($field, $this->fields)){
  320.         unset($this->type[$field]);
  321.         array_push_associative($this->type, array($field => 'dtg_percent'));
  322.         } else {
  323.             throw new KumbiaException("No se pudo dar formato, porque el campo: \"$field\" no existe.");
  324.         }  
  325.     }
  326.     public function setTypeDate($field){
  327.     if(!$this->existData()) return false;
  328.         if(array_key_exists($field, $this->fields)){
  329.         unset($this->type[$field]);
  330.         array_push_associative($this->type, array($field => 'dtg_date'));
  331.         } else {
  332.             throw new KumbiaException("No se pudo dar formato, porque el campo: \"$field\" no existe.");
  333.         }
  334.     }
  335.     public function setTextUpper($field){
  336.     if(!$this->existData()) return false;
  337.         if(array_key_exists($field, $this->fields)){
  338.         unset($this->type[$field]);
  339.         array_push_associative($this->type, array($field => 'strtoupper'));
  340.         } else {
  341.             throw new KumbiaException("No se pudo dar formato, porque el campo: \"$field\" no existe.");
  342.         }
  343.     }
  344.     public function setTextLower($field){
  345.     if(!$this->existData()) return false;
  346.         if(array_key_exists($field, $this->fields)){
  347.         unset($this->type[$field]);
  348.         array_push_associative($this->type, array($field => 'strtolower'));
  349.         } else {
  350.             throw new KumbiaException("No se pudo dar formato, porque el campo: \"$field\" no existe.");
  351.         }
  352.     }
  353.     public function setTextUpperFirst($field){
  354.     if(!$this->existData()) return false;
  355.         if(array_key_exists($field, $this->fields)){
  356.         unset($this->type[$field]);
  357.         array_push_associative($this->type, array($field => 'ucfirst'));
  358.         } else {
  359.             throw new KumbiaException("No se pudo dar formato, porque el campo: \"$field\" no existe.");
  360.     }
  361.     }  
  362.     public function setTextUpperWords($field){
  363.     if(!$this->existData()) return false;
  364.         if(array_key_exists($field, $this->fields)){
  365.         unset($this->type[$field]);
  366.         array_push_associative($this->type, array($field => 'ucwords'));
  367.         } else {
  368.             throw new KumbiaException("No se pudo dar formato, porque el campo: \"$field\" no existe.");
  369.     }
  370.     }
  371.     /**
  372.      *Coloca una class a toda la columna o segun su valor a mostrar
  373.      */
  374.     public function setClass($field, $data=array()){
  375.     if(!$this->existData()) return false;
  376.         if(array_key_exists($field, $this->fields)){
  377.         array_push_associative($this->array_class, array($field => $data));
  378.         } else {
  379.             throw new KumbiaException("No se pudo asignar clase, porque el campo: \"$field\" no existe.");
  380.     }  
  381.     }
  382.     /**
  383.      *Lo mismo que el setAlias, pero con imagenes
  384.      */
  385.     public function setImage($field, $data=array()){
  386.     if(!$this->existData()) return false;
  387.         if(array_key_exists($field, $this->fields)){
  388.         array_push_associative($this->array_image, array($field => $data));
  389.         } else {
  390.             throw new KumbiaException("No se pudo asignar una imagen, porque el campo: \"$field\" no existe.");
  391.     }  
  392.     }
  393.     /**
  394.      *Coloca imagenes para cada fila, ej: PDF; XLS, DOC ...
  395.      */
  396.     public function setMimes($name){
  397.     $params = is_array($name) ? $name : Util::getParams(func_get_args());
  398.     $this->array_mimes  =   $params;
  399.     }    
  400.    
  401.    
  402.    
  403.    
  404.    
  405.    
  406.    
  407.    
  408.    
  409.     public function getValue($field_id){
  410.     if(array_key_exists($field_id, $this->values)){
  411.         $model  =   substr($field_id, 0, -3);
  412.         return array($model, $this->values[$field_id]);
  413.     }else{
  414.         return array();
  415.     }
  416.     }
  417.  
  418.  
  419.     /**
  420.     * Campo de tipo texto
  421.     */
  422.     public function setTextField($params){
  423.     $params = is_array($params) ? $params : Util::getParams(func_get_args());  
  424.     unset($this->type[$params[0]]);
  425.     unset($this->params[$params[0]]);
  426.     array_push_associative($this->params, array($params[0] => $params));
  427.     array_push_associative($this->type, array($params[0] => 'text_field_tag'));
  428.     $this->contador[$params[0]][]=-1;  
  429.     }
  430.     public function setDateField($params){
  431.     $params = is_array($params) ? $params : Util::getParams(func_get_args());
  432.     unset($this->type[$params[0]]);
  433.     unset($this->params[$params[0]]);
  434.     array_push_associative($this->params, array($params[0] => $params));
  435.     array_push_associative($this->type, array($params[0] => 'date_field_tag'));
  436.     $this->contador[$params[0]][]=-1;
  437.     }
  438.     public function setComboBySql($params, $sql){
  439.     $params = is_array($params) ? $params : Util::getParams(func_get_args());
  440.     unset($this->type[$params[0]]);
  441.     unset($this->params[$params[0]]);
  442.     array_push_associative($this->params, array($params[0] => $params));
  443.     array_push_associative($this->type, array($params[0] => 'select_tag'));
  444.     $this->contador[$params[0]][]=-1;  
  445.     $db = DbBase::raw_connect();
  446.     $db->query($sql, true);
  447.     while($item = $db->fetch_array()){
  448.         array_push_associative($this->array_select, array(
  449.         $item[$db->field_name(0)]   =>  $item[$db->field_name(1)]));
  450.     }
  451.     $db->close();
  452.     }
  453.  
  454.        public function getFieldsAndHeaders(){
  455.         if($this->fields){
  456.            return   $this->get_fields_and_headers   =   array_combine($this->fields, $this->headers);
  457.         }else{
  458.         return array();
  459.         }
  460.        }
  461.        public function countOptions(){
  462.         $i=0;
  463.         if($this->edit!='') $i++;
  464.         if($this->delete!='') $i++;
  465.         return count($this->array_mimes) + $i;
  466.        }
  467.  
  468.        public function getUrl(){
  469.            if($this->url==''){
  470.                $this->url   =   Router::get('controller') . '/' . Router::get('action');
  471.            }
  472.            return $this->url;
  473.        }
  474.        public function getUrlOrder(){
  475.            if($this->url==''){
  476.                $this->url   =   Router::get('controller') . '/' . Router::get('action');
  477.            }
  478.            if($this->use_paginator){
  479.                if(Router::get('id')==''){
  480.                    $id  =   1;
  481.                }else{
  482.                    $id  =   Router::get('id');
  483.                }
  484.                return $this->url . '/' . $id . '/';
  485.            }else{
  486.                return $this->url . '/';
  487.            }
  488.        }
  489.     public function getFormat($field, $value){
  490.     if($value=='') return '&nbsp';
  491.     if(array_key_exists($field, $this->type)){
  492.         $format     =   $this->type[$field];
  493.         if(strstr($format,'tag')){
  494.         $format_aux =   $format;
  495.         $format     =   'tag';
  496.         }
  497.     }else{
  498.             return $value;
  499.     }
  500.     $ini            =   Config::read('datagrid');
  501.     switch ($format) {
  502.         case 'dtg_image':
  503.         //$array_img    =   explode(',', $ini['img']['size']);
  504.         //$image        =   new SimpleImage();
  505.         //$image->load('img/' . $value);
  506.         //if(count($array_img)==2){
  507.         //    $image->resize($array_img[0], $array_img[1]);
  508.         //}else{
  509.         //    $image->scale($array_img[0]);
  510.         //}
  511.         //$image->save($ini['img']['thumbs'] . $value, $ini['img']['image_type']);
  512.         //$value        =   'thumbs/' . $value;
  513.         //if(file_exists('img/' . $ini['img']['thumbs'] . $value))
  514.         $value      =   Html::img($ini['img']['thumbs'] . $value, null, 'class=type_image');
  515.         break;
  516.     case 'dtg_money':
  517.             $simbolo    =   $ini['money']['simbolo'];
  518.             $miles      =   $ini['money']['miles'];
  519.             $decimales  =   $ini['money']['decimales'];
  520.             $num_decimales  =   $ini['money']['num_decimales'];
  521.             $value      =   $format($value, $simbolo, $miles, $decimales, $num_decimales); 
  522.         break; 
  523.     case 'dtg_numeric':
  524.         $miles      =   $ini['number']['miles'];
  525.         $decimales      =   $ini['number']['decimales'];
  526.         $num_decimales  =   $ini['number']['num_decimales'];
  527.         $value      =   $format($value, $miles, $decimales, $num_decimales);
  528.         break;
  529.     case 'dtg_percent':
  530.         $decimales  =   $ini['percent']['decimales'];
  531.         $num_decimales  =   $ini['percent']['num_decimales'];
  532.         $value      =   $format($value, $decimales, $num_decimales);                       
  533.         break;
  534.     case 'tag':
  535.         $i      =   count($this->contador[$field]);
  536.         $this->contador[$field][]   =   $i;
  537.         if($format_aux=='select_tag'){
  538.             //array_push_associative($this->params[$field], array("datagrid[$field][$i]"));
  539.             $value      =   $format_aux("datagrid[$field][$i]", $this->array_select);
  540.         }else{
  541.             if(array_key_exists("value", $this->params[$field])){
  542.             array_push_associative($this->params[$field], array("datagrid[$field][$i]"));
  543.             }else{
  544.             array_push_associative($this->params[$field], array("datagrid[$field][$i]", "value" => $value));
  545.             }
  546.             $value      =   $format_aux($this->params[$field]);                    
  547.         }
  548.         break; 
  549.     default:
  550.         if(isset($format)){
  551.             $value      =   $format($value);
  552.         }
  553.         break;
  554.     }
  555.     return  $value;
  556.     }
  557.  
  558.  
  559.     /**
  560.      *Recupera el o los valores ingresados por el setAlias
  561.   */
  562.     public function getAlias($field, $value){
  563.     if(array_key_exists($field, $this->array_alias)){
  564.         $alias  =   $this->array_alias[$field];
  565.         if(array_key_exists($value, $alias)){
  566.         return $alias[$value];
  567.         }
  568.     }
  569.     return $value;
  570.     }
  571.     /**
  572.      *Recupera el o los valores ingresador por el setClass
  573.   */
  574.     public function getClass($field, $value){
  575.     if(array_key_exists($field, $this->array_class)){
  576.         $class  =   $this->array_class[$field];
  577.         if(array_key_exists($value, $class)){
  578.         return $class[$value];
  579.         }
  580.     }
  581.     return '';
  582.     }    
  583.     /**
  584.      *Recupera el o los valores ingresador por el setImage
  585.   */
  586.     public function getImage($field, $value){
  587.     if(array_key_exists($field, $this->array_image)){
  588.         $imagen =   $this->array_image[$field];
  589.         if(array_key_exists($value, $imagen)){
  590.         return $imagen[$value];
  591.         }
  592.     }
  593.     return $value;
  594.     }
  595.     /**
  596.      *Adiciona una columna la cabezera y a los fields
  597.    */
  598.     public function createCol($header, $html){
  599.     array_push_associative($this->fields,  array('new_col_' . $this->cont_cols => $html));
  600.     array_push_associative($this->headers, array('new_col_' . $this->cont_cols => $header));
  601.     $this->cont_cols++;
  602.     }
  603.     /**
  604.      *Obtiene las nuevas columnas si existe la key
  605.    */
  606.     public function getNewCol($key, $rows){
  607.     $str        =   preg_match_all('/{[\s\w\/<>=\\\"]*}/', $key, $items);
  608.     $values     =   '';
  609.     $msg        =   $key;
  610.     foreach ($items[0] as $item){
  611.         $value  =   str_replace(array('{','}'), '', $item);
  612.         $msg    =   str_replace($item, $rows->$value, $msg);
  613.     }
  614.     return $msg;
  615.     }
  616.     public function printSelect($field, $sel_dtg=null){
  617.     $campo      =   $this->getRelation($field);
  618.     $code       =   "<select name='sel_dtg[$field]' id='sel_dtg[$field]'>";
  619.     $code       .=  "<option value='0'>Seleccione ...</option>";
  620.     foreach(Load::model($this->model)->find_all_by_sql('SELECT DISTINCT ' . $field . ' FROM ' . $this->model . ' ORDER BY ' . $field) as $item):
  621.         $selected   =   '';
  622.         if(count($sel_dtg)>0){
  623.         if($sel_dtg[$field]==$item->$field){
  624.             $selected = 'SELECTED';
  625.         }
  626.         }
  627.         $code   .=  "<option value=\"". $item->$field ."\"  $selected>";
  628.         $array_field        =   $this->getValue($field);
  629.         if(strstr($field,'_') and count($array_field) == 2){
  630.         $code   .=  $this->getFormat($field, $item->$campo()->$array_field[1]);
  631.         }else{
  632.         $code   .=  $this->getFormat($field,$item->$field);
  633.         }
  634.         $code   .=  "</option>";
  635.     endforeach;
  636.     $code       .=  "</select>";
  637.     return $code;
  638.     }
  639.     public function getRelation($field=''){
  640.     if(strstr($field,'_')){
  641.         $array_field    =   explode('_', $field);
  642.         return  'get' . ucfirst($array_field[0]);
  643.     }
  644.     return $field;
  645.     }    
  646.     public function AutoFilter($items){
  647.         $fields='';
  648.         $conditions='';
  649.         foreach($items as $val => $key):
  650.         $fields         .=   $val .', ';
  651.         if($key!=0){
  652.         $conditions .=  "$val = '$key' AND ";
  653.         }
  654.     endforeach;
  655.     $fields     =   substr($fields, 0, strlen($fields)-2);
  656.     $this->use_paginator    =   false;
  657.         if($conditions!=''){
  658.         $conditions =   substr($conditions, 0, strlen($conditions)-5);
  659.         Load::model($this->model)->find($conditions);
  660.         $this->data_source  =   Load::model($this->model)->find($conditions);
  661.         //$sql      =   "SELECT $fields FROM $this->model WHERE $conditions";
  662.         if($this->existData()){
  663.             if(array_key_exists('per_page', $this->data_source)){
  664.             $this->use_paginator    =   true;
  665.             }
  666.         }else{
  667.             Flash::warning("No existen datos para mostrar");
  668.         }
  669.     }
  670.     }
  671. }
  672. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement