Example #1
0
    public function setDefaultView($result)
    {
        $sql = 'SELECT globaluser FROM user WHERE iduser = :userid';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('userid', $result);
        $stmt->execute();
        $rs = $stmt->fetch();
        if ($rs) {
            $globaluser = $rs['globaluser'];
        }
        if ($globaluser == 0) {
            $sql = 'SELECT
						UGV.viewid,
						V.storeid,
						V.name as viewname,
						UGV.groupid,
						S.idstore as storeid,
						S.shortcompanyname as storename
						FROM usergroupview UGV 
						lEFT JOIN view V ON UGV.viewid = V.idview
						lEFT JOIN store S ON V.storeid = S.idstore
						WHERE UGV.userid = :userid
						LIMIT 1';
            $stmt = Db::getInstance()->prepare($sql);
            $stmt->bindValue('userid', Session::getActiveUserid());
            $stmt->execute();
            $rs = $stmt->fetch();
            if ($rs) {
                App::getRegistry()->session->setActiveStoreId($rs['storeid']);
                App::getRegistry()->session->setActiveViewId($rs['viewid']);
                return true;
            }
        } else {
            $sql = 'SELECT
						idview,
						storeid
					FROM view
					LIMIT 1';
            $stmt = Db::getInstance()->prepare($sql);
            $stmt->execute();
            $rs = $stmt->fetch();
            if ($rs) {
                App::getRegistry()->session->setActiveStoreId($rs['storeid']);
                App::getRegistry()->session->setActiveViewId($rs['idview']);
            }
        }
    }
Example #2
0
    public function getViewForHelperAll()
    {
        $globaluser = Session::getActiveUserIsGlobal();
        $Data = Session::getActiveViewIds();
        if ($Data == NULL) {
            if ($globaluser == 1) {
                $sql = 'SELECT 
							V.idview AS id
						FROM view V
						GROUP BY V.idview
					';
                $stmt = Db::getInstance()->prepare($sql);
                $stmt->execute();
                while ($rs = $stmt->fetch()) {
                    $Data[] = $rs['id'];
                }
            } else {
                $sql = 'SELECT
							UGV.viewid
						FROM usergroupview UGV 
						lEFT JOIN view V ON UGV.viewid = V.idview
						lEFT JOIN store S ON V.storeid = S.idstore
						WHERE UGV.userid = :userid
						GROUP BY UGV.viewid';
                $stmt = Db::getInstance()->prepare($sql);
                $stmt->bindValue('userid', Session::getActiveUserid());
                $stmt->execute();
                while ($rs = $stmt->fetch()) {
                    $Data[] = $rs['viewid'];
                }
            }
            Session::setActiveViewIds($Data);
        }
        return $Data;
    }
Example #3
0
    public function getUserStoresDataByGroupId($groupid)
    {
        $globalUser = Session::getActiveUserIsGlobal();
        if ($globalUser == 0) {
            $sql = 'SELECT DISTINCT storeid
						FROM `view` V
						LEFT JOIN usergroupview UGV ON UGV.viewid = V.idview
						WHERE UGV.userid = :userid';
            $stmt = Db::getInstance()->prepare($sql);
            $stmt->bindValue('userid', Session::getActiveUserid());
            $stmt->execute();
            $Data = array();
            while ($rs = $stmt->fetch()) {
                if ($rs['storeid'] == NULL) {
                    $Data['global'] = 1;
                } else {
                    $Data['stores'] = array($rs['storeid'] => $this->getUserViewDataByStoreId($rs['storeid']));
                }
            }
        } else {
        }
        return $Data;
    }