public function __construct($table)
 {
     $_SESSION['rows_per_page'] = req::_('rows_per_page', 10, '_SESSION');
     $this->table = $table;
     $this->order = req::_('order', dbfn::_getprimary($table));
     $this->order_dir = req::_('dir', 'ASC');
     $this->page = req::_('page', '1');
     $this->rows_per_page = $_SESSION['rows_per_page'] = req::_('rows_per_page', $_SESSION['rows_per_page']);
     $this->filter_field = req::_('filter_field');
     $this->filter_group = req::_('filter_group', -1);
     $this->filter_group = is_array($this->filter_group) ? implode(',', $this->filter_group) : $this->filter_group;
     $this->first_record = req::_chk('page') ? (req::_('page') - 1) * $this->rows_per_page + 1 : 1;
     $this->last_record = $this->first_record + $this->rows_per_page - 1;
     $this->limit = $this->first_record - 1 . "," . $this->rows_per_page;
     $this->q = req::_('q') == 'Search Records...' ? '' : req::_('q');
     $this->where = $this->q != '' ? dbfn::_buildwhere($table, $this->q) : 1;
     $this->where .= $this->filter_group != -1 ? " AND `{$this->filter_field}` IN ({$this->filter_group})" : '';
 }
Exemple #2
0
    } else {
        echo "<pre>" . $s . "</pre>";
    }
}
function preh($s)
{
    echo pre(htmlentities($s));
}
function consoleLog($s)
{
    if (is_array($s) || is_object($s)) {
        $return = "console.log(\"{\\n\"";
        foreach ($s as $key => $value) {
            $return .= " + \"\t[" . addslashes($key) . "] => " . addslashes($s->{$key}) . " \\n \"";
        }
        $return .= "+\"}\" );";
    } else {
        $return = "console.log(\"" . addslashes($s) . "\");";
    }
    return $return;
}
// RESET USER PASSWORD
if (req::_chk('reset') > 0) {
    $id = req::_('reset');
    $_REQUEST['use_id'] = $id;
    $query = "UPDATE `aimusers` SET `use_password` = md5(concat(`use_firstname`,`use_lastname`)) WHERE `use_id` = {$id} LIMIT 1";
    $oResult = new db($query);
    foreach ($oResult->ret as $key => $value) {
        ${$key} = $value;
    }
}
 function __construct($table, $joins = false)
 {
     global $option;
     global $view;
     $this->table = $table;
     $this->friendlytable = ucfirst(str_replace(TABLEPREFIX, '', $table));
     $this->option = $option;
     $this->view = $view;
     $this->frm_name = "{$table}_filter_form";
     $this->joins = $joins;
     // Are we actively performing a filter
     $this->apply = req::_('frm_name') == $this->frm_name ? true : false;
     if ($this->apply) {
         // actively applying this filter to the current table
         // Filter Params
         $filter = req::_('filter', -1);
         $this->filter = is_array($filter) ? implode(',', $filter) : $filter;
         // Build Pagination params
         $_SESSION['rows_per_page'] = req::_('rows_per_page', ROWS_PER_PAGE, '_SESSION');
         $rows_per_page = $_SESSION['rows_per_page'] = req::_('rows_per_page', $_SESSION['rows_per_page']);
         $first_record = req::_chk('page') ? (req::_('page') - 1) * $rows_per_page + 1 : 1;
         $last_record = $first_record + $rows_per_page - 1;
         // Build where statement
         $search_criteria = req::_('search_criteria', '');
         if (!empty($search_criteria)) {
             $search_criteria = urldecode($search_criteria);
             $pairs = explode('&', $search_criteria);
             $this->search_criteria = array();
             foreach ($pairs as $pair) {
                 $p = explode('=', $pair);
                 $this->search_criteria[$p[0]] = $p[1];
             }
         }
         $this->where = !empty($this->search_criteria) ? dbfn::_buildwhere2($this->search_criteria) : 1;
         // Build order criteria
         $this->order = req::_('order', dbfn::_getPrimary($table));
         $this->dir = req::_('dir', 'ASC');
     } else {
         // not actively applying any filters to this table
         $this->filter = -1;
         $rows_per_page = $_SESSION['rows_per_page'];
         $first_record = 1;
         $last_record = $first_record + $rows_per_page - 1;
         $this->where = 1;
         $this->order = dbfn::_getPrimary($table);
         $this->dir = 'ASC';
     }
     $this->limit = $first_record - 1 . "," . $rows_per_page;
     $this->page = req::_('page', 1);
     $this->rows_per_page = $rows_per_page;
     // Find total records
     $select2 = "SELECT count(*) AS `c` FROM `{$table}` {$joins} WHERE {$this->where}";
     $oTemp = new db($select2);
     $this->total_rows = $oTemp->_getResult();
     $this->first_record = $this->rows_per_page < $this->total_rows ? $first_record : 1;
     $this->last_record = $this->total_rows <= $last_record ? $this->total_rows : $last_record;
     $this->total_pages = ceil($this->total_rows / $this->rows_per_page);
     // Update limit and page number if necessary
     $this->limit = $this->first_record - 1 . "," . $rows_per_page;
     $this->page = $this->rows_per_page < $this->total_rows ? $this->page : 1;
     // Row message: Displaying x - y of z records...
     $this->row_message = $this->total_rows > 0 ? "Showing " . $this->first_record . " - " . $this->last_record . " of " . $this->total_rows . " rows." : "<font style='color:red'>No records found.</font>";
     $this->row_message_class = $this->total_rows > 0 ? "ui-state-success" : "ui-state-error";
 }