Ejemplo n.º 1
0
        $filter['limit'] = $this->users_count;
        if ($this->request->get('group_id')) {
            $filter['group_id'] = intval($this->request->get('group_id'));
        }
        $filter['sort'] = $this->request->get('sort');
        $filter['keyword'] = $this->request->get('keyword');
        // Выбираем пользователей
        $users = array();
        foreach ($this->users->get_users($filter) as $u) {
            $str = array();
            foreach ($this->columns_names as $n => $c) {
                $str[] = $u->{$n};
            }
            fputcsv($f, $str, $this->column_delimiter);
        }
        $total_users = $this->users->count_users();
        if ($this->users_count * $page < $total_users) {
            return array('end' => false, 'page' => $page, 'totalpages' => $total_users / $this->users_count);
        } else {
            return array('end' => true, 'page' => $page, 'totalpages' => $total_users / $this->users_count);
        }
        fclose($f);
    }
}
$export_ajax = new ExportAjax();
$json = json_encode($export_ajax->fetch());
header("Content-type: application/json; charset=utf-8");
header("Cache-Control: must-revalidate");
header("Pragma: no-cache");
header("Expires: -1");
print $json;
Ejemplo n.º 2
0
                    }
                    foreach ($this->columns_names as $internal_name => $column_name) {
                        if (isset($result[$internal_name])) {
                            $res[$internal_name] = $result[$internal_name];
                        } else {
                            $res[$internal_name] = '';
                        }
                    }
                    fputcsv($f, $res, $this->column_delimiter);
                }
            }
        }
        $total_products = $this->products->count_products($filter);
        fclose($f);
        if ($this->products_count * $page < $total_products) {
            return array('end' => false, 'page' => $page, 'totalpages' => $total_products / $this->products_count);
        } else {
            return array('end' => true, 'page' => $page, 'totalpages' => $total_products / $this->products_count);
        }
    }
}
$export_ajax = new ExportAjax();
$data = $export_ajax->fetch();
if ($data) {
    header("Content-type: application/json; charset=utf-8");
    header("Cache-Control: must-revalidate");
    header("Pragma: no-cache");
    header("Expires: -1");
    $json = json_encode($data);
    print $json;
}