Exemplo n.º 1
0
    }
    // функция получения определённой страницы отсортированных данных
    // cортировка указывается третьим параметром (true=ASC,false=DESC)
    public static function get_page($pagesize, $page, $asc = true)
    {
        return array_slice($asc ? self::$mydata : array_reverse(self::$mydata), ($page - 1) * $pagesize, $pagesize);
    }
    // так же допустим есть функция удаления строки
    public static function delete($num)
    {
        unset(self::$mydata[$num]);
    }
}
// Инициализируем буфер и менеджер сущностей
$ajaxbuffer = new ajax_buffer("ajax_buffer");
$ajaxbuffer->show_progress(true);
$emanager = new ajax_entities_manager('entities_manager', $ajaxbuffer);
// Если нужно выполнить какие-то действия над данными по постбэку
if ($ajaxbuffer->is_post_back() && $emanager->isAnyAction()) {
    switch ($emanager->getAction()) {
        // необходимо удалить строку
        case $emanager->action->DEL:
            mydata::delete($emanager->getItem());
            break;
    }
    // сбрасываем действие (в противном случае оно будет активно при каждом ajax запросе)
    $emanager->eraseAction();
}
// Форматтер для отображения данных грида
class my_grid_formatter extends grid_formatter
{
<?php

if ((!check_auth() || $CURRENT_USER['level'] < 7) && $BILLEVEL != 2) {
    die("Access denied!");
}
require_once dirname(__FILE__) . "/SMPHPToolkit/SMAjax.php";
require_once dirname(__FILE__) . "/CADBiS/PacketsTodayLimits.php";
CADBiSNew::instance()->script_src('js/ajax/buffer.js');
$ajaxbuf = new ajax_buffer("update_buffer");
$ajaxbuf->show_progress(true);
$ajaxbuf->set_postback_url($_SERVER['REQUEST_URI']);
$BILL = new CBilling($GV["dbhost"], $GV["dbname"], $GV["dblogin"], $GV["dbpassword"]);
require_once dirname(__FILE__) . "/CADBiS/cadbis_statistic_backend.php";
$packets = $BILL->GetTarifs();
$config = $BILL->GetCADBiSConfig();
$packets_confs = array();
foreach ($packets as &$packet) {
    $accts = $BILL->GetTarifTodayAccts($packet['gid']);
    $packet['accts']['traffic'] = $accts['traffic'];
    $packet['accts']['time'] = $accts['time'];
    $packets_confs[$packet['gid']]['rang'] = new ajax_var('rng' . $packet['gid'], $packet['rang']);
    $packets_confs[$packet['gid']]['exceed_times'] = new ajax_var('et' . $packet['gid'], $packet['exceed_times']);
    $ajaxbuf->register_vars($packets_confs[$packet['gid']]);
}
$max_month_traffic = new ajax_var('max_month_traffic', $config['max_month_traffic'] / 1024 / 1024);
$ajaxbuf->register_var($max_month_traffic);
if ($ajaxbuf->is_post_back()) {
    foreach ($packets as &$packet) {
        $packet['rang'] = $packets_confs[$packet['gid']]['rang']->get_value();
        $packet['exceed_times'] = $packets_confs[$packet['gid']]['exceed_times']->get_value();
        $BILL->UpdateTarif($packet['gid'], $packet);
Exemplo n.º 3
0
 /**
  * Sets the show progress variable (true/false) for internal ajax buffer
  * If set to true, the window showing ajax progress will be shown
  * on each ajax request
  * @param bool $value
  */
 public function show_progress($value)
 {
     $this->buffer->show_progress($value);
 }
Exemplo n.º 4
0
<?php

if (!check_auth() || $CURRENT_USER['level'] < 7) {
    die("Access denied!");
}
require_once dirname(__FILE__) . "/SMPHPToolkit/SMAjax.php";
CADBiSNew::instance()->script_src('js/ajax/buffer.js');
CADBiSNew::instance()->script_src('js/ajax/manager.js');
CADBiSNew::instance()->link_href('skins/smadbis/css/grid.css');
$BILL = new CBilling($GV["dbhost"], $GV["dbname"], $GV["dblogin"], $GV["dbpassword"]);
if (isset($_REQUEST['renderkwdsfor'])) {
    $cid = $_REQUEST['renderkwdsfor'];
    die(implode(", ", $BILL->GetUrlCategoryKeywordsWithWeights($cid)));
}
$ajaxbuf_cats = new ajax_buffer("update_buffer_cats");
$ajaxbuf_cats->show_progress(true);
$emanager = new ajax_entities_manager('entities_manager', $ajaxbuf_cats);
class cats_formatter extends grid_formatter
{
    protected $_field = '';
    /**
     * Entities manager
     * @var ajax_entities_manager
     */
    protected $_entities_manager = null;
    /**
     * @param string $field
     * @param ajax_entities_manager $entities_manager
     */
    public function __construct($field, $entities_manager)
    {