示例#1
0
    function getUndefinedDealers()
    {
        $data = array();
        //	INNER JOIN {{dealers_status}} ON {{dealers}}.status = {{dealers_status}}.id
        $sql = '
			SELECT {{dealers}}.* , {{dealers_status}}.shortname as statusname, {{dealers}}.id as dealer_id, (
				SELECT COUNT(*)
				FROM {{dealers_orders}}
				LEFT JOIN {{dealers_orders_status}} ON {{dealers_orders}}.status = {{dealers_orders_status}}.id
				WHERE {{dealers_orders}}.`dealer` = dealer_id AND {{dealers_orders_status}}.path = \'new\'
			) as new_orders
			FROM {{dealers}}
			LEFT JOIN {{dealers_status}} ON {{dealers}}.status = {{dealers_status}}.id
			WHERE {{dealers}}.active=1
			ORDER BY new_orders DESC
		';
        //getPagi не cпособен переварить запрос с подзапросами
        //вместо
        //$list=DB::getPagi($sql);
        //приходится делать так
        $dealers_count = DB::getOne('SELECT COUNT(*) FROM {{dealers}}');
        if (Funcs::$OneSSA) {
            $perpage = $_SESSION['user']['perpage'];
        } else {
            if ($_SESSION['perpage'][end(Funcs::$uri)]) {
                $perpage = $_SESSION['perpage'][end(Funcs::$uri)];
            } else {
                $perpage = 10;
            }
        }
        $page = intval($_GET['p']) > 0 ? $_GET['p'] : '1';
        if (class_exists(PaginationWidget)) {
            PaginationWidget::$count = $dealers_count;
        }
        $sql .= ' LIMIT ' . ($page - 1) * $perpage . ',' . $perpage;
        $list = DB::getAll($sql);
        foreach ($list as $item) {
            $item['stores_cnt'] = DealersStores::getCount($item['id']);
            $item['consignee_cnt'] = DealersConsignee::getCount($item['id']);
            $item['balance'] = self::getBalance($item['id']);
            $item['files'] = DealersFiles::getCountFiles($item['id']);
            $item['orders'] = DealersOrders::getOrdersCountByStatus($item['id'], 'new') . '/' . DealersOrders::getOrdersCountByStatus($item['id']);
            $data[] = $item;
        }
        return $data;
    }
示例#2
0
    function getUndefinedDealers()
    {
        $data = array();
        //$sql='SELECT * FROM {{dealers}} ORDER BY cdate';
        $sql = '
			SELECT {{dealers}}.* ,{{dealers_status}}.shortname as statusname FROM {{dealers}} 
			INNER JOIN {{dealers_status}} ON {{dealers}}.status = {{dealers_status}}.id
			ORDER by cdate
		';
        $list = DB::getPagi($sql);
        foreach ($list as $item) {
            $item['stores_cnt'] = DealersStores::getCount($item['id']);
            $item['consignee_cnt'] = DealersConsignee::getCount($item['id']);
            $item['balance'] = self::getBalance($item['id']);
            $item['files'] = DealersFiles::getCountFiles($item['id']);
            $item['orders'] = DealersOrders::getOrdersCountByStatus($item['id']);
            $data[] = $item;
        }
        return $data;
    }
示例#3
0
 public function actdelcons()
 {
     DealersConsignee::delCons();
     $this->redirect('/dealers/listcons/?id=' . $_GET['dealer']);
 }
示例#4
0
 public static function getNewOrderProp($dealer)
 {
     $ret = array();
     DB::escapeGet();
     $ret['dealer'] = Dealers::getOne($dealer);
     $ret['cons'] = DealersConsignee::getConsList($dealer, true);
     $ret['statuses'] = DealersOrders::getStatusesList();
     $ret['delivery'] = Delivery::$deliveries;
     $ret['catalog'] = self::getCatalog();
     $ret['goods'] = array();
     return $ret;
 }