$url_cats_unmatched_ds = create_ds_header($emanager->client_id());
$url_cats_unmatched_grid = new ajax_grid('url_cats_grid_unmatched', $url_cats_unmatched_ds, $ajaxbuf_url_cats);
$url_cats_unmatched_grid_pager = new ajax_grid_pager('url_cats_grid_pager_unmatched', $BILL->GetCategoriesUrlUnMatchedCount($url_cats_unmatched_grid->get_filterfield(), $url_cats_unmatched_grid->get_filtering()), 10);
$url_cats_unmatched_grid->attach_pager($url_cats_unmatched_grid_pager);
$url_cats_matched_ds = create_ds_header($emanager->client_id());
$url_cats_matched_grid = new ajax_grid('url_cats_grid_matched', $url_cats_matched_ds, $ajaxbuf_url_matched_cats);
$url_cats_matched_grid_pager = new ajax_grid_pager('url_cats_grid_pager_matched', $BILL->GetCategoriesUrlMatchedCount($url_cats_matched_grid->get_filterfield(), $url_cats_matched_grid->get_filtering()), 10);
$url_cats_matched_grid->attach_pager($url_cats_matched_grid_pager);
/**
 * Check if we need to make some actions
 */
if ($emanager->isAnyAction()) {
    //special actions
    if ($emanager->getAction() == 'changeCatByName') {
        $item = json_decode($emanager->getItem());
        $BILL->UpdateUrlCategoryMatchByName($item->url, $item->name);
    } elseif ($emanager->getAction() == 'recognizeAll') {
        $url_cats = $BILL->GetUrlCategoriesMatch($url_cats_unmatched_grid_pager->get_curpage(), 10, $url_cats_unmatched_grid->get_sorting(), $url_cats_unmatched_grid->get_sort_direction(), array(0), array());
        require_once dirname(__FILE__) . '/CADBiS/recognize.php';
        foreach ($url_cats as $url) {
            $catname = Recognizer::recognizeByUrlCheck($url['url']);
            if (!empty($catname)) {
                $BILL->UpdateUrlCategoryMatchByName($url['url'], $catname);
            }
        }
    }
    switch ($emanager->getAction()) {
        case $emanager->action->UPD:
            $item = json_decode($emanager->getItem());
            $BILL->UpdateUrlCategoryMatch($item->u2cid, $item->url, $item->cid);
            break;