Esempio n. 1
0
 public function index($id = 0, $params = array())
 {
     $status = Response::STATUS_BAD_REQUEST;
     if (!empty($this->auth['company_id'])) {
         $params['company_id'] = $this->auth['company_id'];
     }
     $lang_code = $this->safeGet($params, 'lang_code', DEFAULT_LANGUAGE);
     if (!empty($id)) {
         if (!empty($this->auth['company_id']) && $this->auth['company_id'] != $id) {
             $status = Response::STATUS_FORBIDDEN;
             $data = array();
         } else {
             $params = array('company_id' => $id);
             list($data) = fn_get_companies($params, $this->auth, 0, $lang_code);
             if (empty($data)) {
                 $status = Response::STATUS_NOT_FOUND;
             } else {
                 $status = Response::STATUS_OK;
             }
             $data = reset($data);
             Registry::set('runtime.company_id', $id);
         }
     } else {
         $items_per_page = $this->safeGet($params, 'items_per_page', Registry::get('settings.Appearance.admin_elements_per_page'));
         list($data, ) = fn_get_companies($params, $this->auth, $items_per_page, $lang_code);
         $pathes = explode('\\', get_class($this));
         $key = strtolower(array_pop($pathes));
         $data = array($key => $data, 'params' => $params);
         $status = Response::STATUS_OK;
     }
     return array('status' => $status, 'data' => $data);
 }
Esempio n. 2
0
        return array(CONTROLLER_STATUS_NO_PAGE);
    }
    fn_add_breadcrumb(__('all_vendors'), 'companies.catalog');
    fn_add_breadcrumb($company_data['company']);
    $company_data['total_products'] = count(db_get_fields(fn_get_products(array('get_query' => true, 'company_id' => $_REQUEST['company_id']))));
    $company_data['logos'] = fn_get_logos($company_data['company_id']);
    Registry::set('navigation.tabs', array('description' => array('title' => __('description'), 'js' => true)));
    $params = array('company_id' => $_REQUEST['company_id']);
    Tygh::$app['view']->assign('company_data', $company_data);
} elseif ($mode == 'catalog') {
    fn_add_breadcrumb(__('all_vendors'));
    $params = $_REQUEST;
    $params['status'] = 'A';
    $params['get_description'] = 'Y';
    $vendors_per_page = Registry::get('settings.Vendors.vendors_per_page');
    list($companies, $search) = fn_get_companies($params, $auth, $vendors_per_page);
    foreach ($companies as &$company) {
        $company['logos'] = fn_get_logos($company['company_id']);
    }
    Tygh::$app['view']->assign('companies', $companies);
    Tygh::$app['view']->assign('search', $search);
} elseif ($mode == 'apply_for_vendor') {
    if (Registry::get('settings.Vendors.apply_for_vendor') != 'Y') {
        return array(CONTROLLER_STATUS_NO_PAGE);
    }
    $restored_company_data = fn_restore_post_data('company_data');
    if ($restored_company_data) {
        Tygh::$app['view']->assign('company_data', $restored_company_data);
    }
    $restored_user_data = fn_restore_post_data('user_data');
    if ($restored_user_data) {
Esempio n. 3
0
if (fn_allowed_for('MULTIVENDOR')) {
    if ($mode == 'merge') {
        if (!isset(Tygh::$app['session']['auth']['is_root']) || Tygh::$app['session']['auth']['is_root'] != 'Y' || Registry::get('runtime.company_id')) {
            return array(CONTROLLER_STATUS_DENIED);
        }
        if (empty($_REQUEST['company_id'])) {
            return array(CONTROLLER_STATUS_NO_PAGE);
        }
        $company_id = $_REQUEST['company_id'];
        unset($_REQUEST['company_id']);
        $company_data = !empty($company_id) ? fn_get_company_data($company_id) : array();
        if (empty($company_data)) {
            return array(CONTROLLER_STATUS_NO_PAGE);
        }
        $_REQUEST['exclude_company_id'] = $company_id;
        list($companies, $search) = fn_get_companies($_REQUEST, $auth, Registry::get('settings.Appearance.admin_elements_per_page'));
        Tygh::$app['view']->assign('company_id', $company_id);
        Tygh::$app['view']->assign('company_name', $company_data['company']);
        Tygh::$app['view']->assign('companies', $companies);
        Tygh::$app['view']->assign('search', $search);
        Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE));
        Tygh::$app['view']->assign('states', fn_get_all_states());
    } elseif ($mode == 'balance') {
        list($payouts, $search, $total) = fn_companies_get_payouts($_REQUEST, Registry::get('settings.Appearance.admin_elements_per_page'));
        Tygh::$app['view']->assign('payouts', $payouts);
        Tygh::$app['view']->assign('search', $search);
        Tygh::$app['view']->assign('total', $total);
    }
}
if (fn_allowed_for('ULTIMATE')) {
    if ($mode == 'get_object_share') {
Esempio n. 4
0
/**
 * Add vendors list to products search result
 * @param array $response
 * @param array $params
 * @param string $lang_code
 */
function fn_twg_add_response_vendors(&$response, $params)
{
    if (empty($params['q'])) {
        return;
    }
    $params['q'] = trim(preg_replace('/\\s+/', ' ', $params['q']));
    $all_comapnies = fn_get_companies(array('status' => 'A'), $_SESSION['auth']);
    $all_comapnies = $all_comapnies[0];
    if (empty($all_comapnies)) {
        return;
    }
    $companies = array();
    foreach ($all_comapnies as $company) {
        if (preg_match('/\\b' . preg_quote($company['company'], '/') . '\\b/iU', $params['q'])) {
            $logo = unserialize($company['logos']);
            if (empty($logo['Customer_logo'])) {
                $url = '';
            } else {
                $url = (defined('HTTPS') ? 'https://' . Registry::get('config.https_host') : 'http://' . Registry::get('config.http_host')) . Registry::get('config.images_path') . $logo['Customer_logo']['filename'];
            }
            $companies[] = array('company_id' => $company['company_id'], 'title' => $company['company'], 'q' => trim(preg_replace('/\\b' . $company['company'] . '\\b/iU', '', $params['q'])), 'icon' => array('url' => $url));
        }
    }
    $response->setMeta($companies, 'companies');
    if (empty($response->data) and $companies) {
        $response->setMeta(1, 'current_page');
    }
}