Exemplo n.º 1
0
 public function getProductReviews($productid)
 {
     $sql = "SELECT\n\t\t\t\t\treview,\n\t\t\t\t\tnick,\n\t\t\t\t\tadddate,\n\t\t\t\t\tidproductreview\n\t\t\t\tFROM productreview\n\t\t\t\tWHERE productid = :productid AND viewid = :viewid AND enable = 1\n\t\t\t\tGROUP BY idproductreview\n\t\t\t\tORDER BY adddate ASC\n\t\t";
     $stmt = Db::getInstance()->prepare($sql);
     $stmt->bindValue('productid', $productid);
     $stmt->bindValue('viewid', Helper::getViewId());
     $Data = array();
     try {
         $stmt->execute();
         while ($rs = $stmt->fetch()) {
             $sql2 = "SELECT \n\t\t\t\t\t\t\tPR.rangetypeid,\n\t\t\t\t\t\t\tPR.value,\n\t\t\t\t\t\t\tRTT.name\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\tproductrange PR\n\t\t\t\t\t\t\tLEFT JOIN rangetypetranslation RTT ON RTT.rangetypeid = PR.rangetypeid AND RTT.languageid = :languageid\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tPR.productreviewid = :reviewid";
             $stmt2 = Db::getInstance()->prepare($sql2);
             $stmt2->bindValue('reviewid', $rs['idproductreview']);
             $stmt2->bindValue('languageid', Helper::getLanguageId());
             $rangesRes = $stmt2->execute();
             $ranges = array();
             while ($rangesRes = $stmt2->fetch()) {
                 $ranges[] = array('rangetypeid' => $rangesRes['rangetypeid'], 'value' => $rangesRes['value'], 'name' => $rangesRes['name']);
             }
             $Data[] = array('nick' => $rs['nick'], 'review' => $rs['review'], 'adddate' => $rs['adddate'], 'ranges' => $ranges);
         }
     } catch (Exception $e) {
         throw new FrontendException('Error while doing sql query- getProductReviews (productreview)');
     }
     return $Data;
 }
Exemplo n.º 2
0
    public function getCategories($params)
    {
        $sql = 'SELECT
					PC.categoryid AS id,
					CT.name AS caption,
					CT.seo
				FROM productcategory PC
				LEFT JOIN product P ON PC.productid = P.idproduct
				LEFT JOIN categorytranslation CT ON PC.categoryid = CT.categoryid AND CT.languageid = :languageid
				LEFT JOIN viewcategory VC ON PC.categoryid = VC.categoryid
				LEFT JOIN productstatuses PS ON PC.productid = PS.productid
				WHERE VC.viewid = :viewid AND PS.productstatusid = :statusid AND P.enable = 1
				GROUP BY PC.categoryid';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('languageid', Helper::getLanguageId());
        $stmt->bindValue('viewid', Helper::getViewId());
        $stmt->bindValue('statusid', $params['statusId']);
        $stmt->execute();
        $Data = array();
        $Data[] = array('id' => 0, 'caption' => _('TXT_ALL'));
        while ($rs = $stmt->fetch()) {
            $Data[] = array('id' => $rs['id'], 'caption' => $rs['caption'], 'link' => $this->registry->router->generate('frontend.categorylist', true, array('param' => $rs['seo'])));
        }
        return $Data;
    }
Exemplo n.º 3
0
    public function getProducerAll()
    {
        $sql = 'SELECT 
					P.idproducer AS id,
					PT.name,
					PT.seo, 
					P.photoid, 
					COUNT(PROD.idproduct) AS totalproducts
				FROM producer P
				LEFT JOIN producertranslation PT ON PT.producerid = P.idproducer AND PT.languageid = :language
				LEFT JOIN producerview PV ON P.idproducer = PV.producerid
				LEFT JOIN product PROD ON PROD.producerid = P.idproducer AND PROD.enable = 1
				WHERE PV.viewid = :viewid
				GROUP BY P.idproducer
				HAVING totalproducts > 0
				ORDER BY PT.name ASC';
        $Data = array();
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('language', Helper::getLanguageId());
        $stmt->bindValue('viewid', Helper::getViewId());
        $stmt->execute();
        while ($rs = $stmt->fetch()) {
            $Data[] = array('id' => $rs['id'], 'name' => $rs['name'], 'seo' => $rs['seo'], 'link' => $this->registry->router->generate('frontend.producerlist', true, array('param' => $rs['seo'])), 'active' => $this->getParam() == $rs['seo'] ? true : false, 'photo' => App::getModel('categorylist')->getImagePath($rs['photoid']));
        }
        return $Data;
    }
Exemplo n.º 4
0
    protected function getCategories()
    {
        $sql = '
				SELECT
					C.idcategory AS id,
					CT.name AS label
				FROM
					category C
					INNER JOIN viewcategory CV ON CV.categoryid = idcategory
					LEFT JOIN categorytranslation CT ON C.idcategory = CT.categoryid AND CT.languageid = :languageid
				WHERE
					CV.viewid = :viewid AND C.enable = 1
				GROUP BY
					C.idcategory
				ORDER BY
					C.distinction ASC
			';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->BindParam('languageid', Helper::getLanguageId());
        $stmt->BindParam('viewid', Helper::getViewId());
        $stmt->execute();
        $Data = array();
        while ($rs = $stmt->fetch()) {
            $Data[] = array('catid' => $rs['id'], 'catname' => $rs['label']);
        }
        return $Data;
    }
Exemplo n.º 5
0
 public function getActiveLayer()
 {
     $storeid = !is_null(Helper::getStoreId()) ? Helper::getStoreId() : 0;
     $viewid = !is_null(Helper::getViewId()) ? Helper::getViewId() : 0;
     if ($viewid > 0) {
         return $storeid . '_' . $viewid;
     } else {
         return $storeid;
     }
 }
Exemplo n.º 6
0
 public function getMainCategories()
 {
     $sql = "SELECT \n\t\t\t\t\tC.idcategory, \n\t\t\t\t\tCT.name,\n\t\t\t\t\tCT.seo,\n\t\t\t\t\tC.photoid,\n\t\t\t\t\tCT.shortdescription,\n\t\t\t\t\tCT.description,\n     \t\t\t\tCOUNT(PC.productid) AS totalproducts,\n     \t\t\t\tMIN(P.sellprice) AS minsellprice\n\t\t\t\tFROM category C\n\t\t\t\tLEFT JOIN viewcategory VC ON VC.categoryid = C.idcategory\n\t\t\t\tLEFT JOIN categorypath CP ON CP.ancestorcategoryid = C.idcategory\n\t\t\t\tLEFT JOIN productcategory PC ON CP.categoryid = PC.categoryid\n\t\t\t\tLEFT JOIN product P ON PC.productid = P.idproduct\n\t\t\t\tLEFT JOIN categorytranslation CT ON CT.categoryid = idcategory AND CT.languageid = :languageid\n\t\t\t\tWHERE C.categoryid IS NULL AND VC.viewid=:viewid AND C.enable = 1\n\t\t\t\tGROUP BY C.idcategory";
     $stmt = Db::getInstance()->prepare($sql);
     $stmt->bindValue('viewid', Helper::getViewId());
     $stmt->bindValue('languageid', Helper::getLanguageId());
     $stmt->execute();
     $Data = array();
     while ($rs = $stmt->fetch()) {
         $Data[] = array('name' => $rs['name'], 'idcategory' => $rs['idcategory'], 'qry' => $rs['totalproducts'], 'seo' => $rs['seo'], 'minsellprice' => $this->registry->core->processPrice($rs['minsellprice']), 'shortdescription' => $rs['shortdescription'], 'description' => $rs['description'], 'photo' => $this->getImagePath($rs['photoid']));
     }
     return $Data;
 }
Exemplo n.º 7
0
 public function getAllMostSearched()
 {
     $top_count = $this->getTopSearched(Helper::getViewId());
     $sql = "SELECT \n\t\t\t\t\tidmostsearch,\n\t\t\t\t\tname, \n\t\t\t\t\ttextcount\n\t\t\t\tFROM mostsearch\n\t\t\t\tWHERE viewid = :viewid";
     $stmt = Db::getInstance()->prepare($sql);
     $stmt->bindValue('viewid', Helper::getViewId());
     $stmt->execute();
     $Data = array();
     while ($rs = $stmt->fetch()) {
         $Data[] = array('idmostsearch' => $rs['idmostsearch'], 'name' => $rs['name'], 'phrase' => $rs['name'], 'textcount' => $rs['textcount'], 'percentage' => ceil($rs['textcount'] / $top_count['textcount'] * 100));
     }
     return $Data;
 }
Exemplo n.º 8
0
 public function getContactList()
 {
     $sql = "SELECT\n\t\t\t\t\tC.idcontact,\n\t\t\t\t\tCT.name, \n\t\t\t\t\tCT.email, \n\t\t\t\t\tCT.phone, \n\t\t\t\t\tCT.fax, \n\t\t\t\t\tCT.street, \n\t\t\t\t\tCT.streetno, \n\t\t\t\t\tCT.placeno, \n\t\t\t\t\tCT.placename, \n\t\t\t\t\tCT.postcode,\n\t\t\t\t\tCT.businesshours\n\t\t\t\tFROM contact C\n\t\t\t\tLEFT JOIN contacttranslation CT ON CT.contactid = C.idcontact AND CT.languageid = :languageid\n\t\t\t\tLEFT JOIN contactview CV ON CV.contactid = C.idcontact\n\t\t\t\tWHERE C.publish = 1 AND CV.viewid = :viewid\n\t\t\t\tORDER BY C.idcontact";
     $stmt = Db::getInstance()->prepare($sql);
     $stmt->bindValue('viewid', Helper::getViewId());
     $stmt->bindValue('languageid', Helper::getLanguageId());
     $Data = array();
     try {
         $stmt->execute();
         while ($rs = $stmt->fetch()) {
             $Data[$rs['idcontact']] = array('idcontact' => $rs['idcontact'], 'name' => $rs['name'], 'phone' => $rs['phone'], 'fax' => $rs['fax'], 'email' => $rs['email'], 'street' => $rs['street'], 'streetno' => $rs['streetno'], 'placeno' => $rs['placeno'], 'placename' => $rs['placename'], 'postcode' => $rs['postcode'], 'businesshours' => $rs['businesshours']);
         }
     } catch (Exception $e) {
         throw new FrontendException($fe->getMessage('ERR_QUERY_WISHLIST'));
     }
     return $Data;
 }
Exemplo n.º 9
0
    protected function initDatagrid($datagrid)
    {
        $datagrid->setTableData('dispatchmethod', array('iddispatchmethod' => array('source' => 'D.iddispatchmethod'), 'name' => array('source' => 'DMT.name', 'prepareForAutosuggest' => true, 'processLanguage' => true), 'countries' => array('source' => 'D.countryids', 'processFunction' => array($this, 'getCountriesForDispatchmethod')), 'hierarchy' => array('source' => 'D.hierarchy')));
        $datagrid->setFrom('
			dispatchmethod D
			LEFT JOIN dispatchmethodview DV ON DV.dispatchmethodid = D.iddispatchmethod
      LEFT JOIN dispatchmethodtranslation DMT ON DMT.dispatchmethodid = D.iddispatchmethod AND DMT.languageid = :languageid
		');
        $datagrid->setGroupBy('
			D.iddispatchmethod
		');
        if (Helper::getViewId() > 0) {
            $datagrid->setAdditionalWhere('
				DV.viewid IN (' . Helper::getViewIdsAsString() . ') 
			');
        }
    }
Exemplo n.º 10
0
    protected function initDatagrid($datagrid)
    {
        $datagrid->setTableData('producer', array('idproducer' => array('source' => 'P.idproducer'), 'name' => array('source' => 'PT.name', 'prepareForAutosuggest' => true), 'adddate' => array('source' => 'P.adddate')));
        $datagrid->setFrom('
			producer P
			LEFT JOIN producertranslation PT ON PT.producerid = P.idproducer AND PT.languageid = :languageid
			LEFT JOIN producerview PV ON PV.producerid = P.idproducer
		');
        if (Helper::getViewId() > 0) {
            $datagrid->setAdditionalWhere('
				PV.viewid IN (' . Helper::getViewIdsAsString() . ')
			');
        }
        $datagrid->setGroupBy('
			P.idproducer
		');
    }
Exemplo n.º 11
0
 public function getNewsById($id)
 {
     $sql = "SELECT \n\t\t\t\t\tN.idnews, \n\t\t\t\t\tNT.topic, \n\t\t\t\t\tNT.summary,\n\t\t\t\t\tNT.content,\n\t\t\t\t\tNT.seo,\n\t\t\t\t\tNT.keyword_title,\n\t\t\t\t\tNT.keyword,\n\t\t\t\t\tNT.keyword_description,\n\t\t\t\t\tN.adddate,\n\t\t\t\t\tN.featured\n\t\t\t\tFROM news N\n\t\t\t\tLEFT JOIN newsview NV ON NV.newsid = idnews\n\t\t\t\tLEFT JOIN newstranslation NT ON N.idnews = NT.newsid AND NT.languageid = :languageid\n\t\t\t\tWHERE\n\t\t\t\t\tidnews=:id\n\t\t\t\tAND\n\t\t\t\t\tpublish = 1\n\t\t\t\tAND\n\t\t\t\t\tIF((N.startdate IS NULL OR N.startdate = '0000-00-00 00:00:00' OR N.startdate <= CURDATE()) AND (N.enddate IS NULL OR N.enddate = '0000-00-00 00:00:00' OR N.enddate >= CURDATE()), 1, 0)\n\t\t\t\t\t\n\t\t\t\tAND\n\t\t\t\t\tNV.viewid = :viewid\n\t\t\t\tORDER BY N.`adddate` desc";
     $stmt = Db::getInstance()->prepare($sql);
     $stmt->bindValue('id', $id);
     $stmt->bindValue('languageid', Helper::getLanguageId());
     $stmt->bindValue('viewid', Helper::getViewId());
     $stmt->execute();
     $rs = $stmt->fetch();
     $Data = array();
     if ($rs) {
         $Data = array('featured' => $rs['featured'], 'topic' => $rs['topic'], 'adddate' => $rs['adddate'], 'summary' => $rs['summary'], 'content' => $rs['content'], 'seo' => $rs['seo'], 'link' => $this->generateUrl($rs['idnews'], $rs['seo']), 'keyword_title' => $rs['keyword_title'] == NULL || $rs['keyword_title'] == '' ? $rs['topic'] : $rs['keyword_title'], 'keyword' => $rs['keyword'], 'keyword_description' => $rs['keyword_description'], 'mainphoto' => $this->getPhotosByNewsId($id), 'otherphoto' => $this->getOtherPhotosByNewsId($id));
         return $Data;
     } else {
         App::redirectUrl($this->registry->router->generate('frontend.news', true));
     }
 }
Exemplo n.º 12
0
 public function getProductListIntegration()
 {
     $sql = "SELECT\n\t\t\t\t\tPC.categoryid AS id,\n\t\t\t\t\tP.idproduct,\n\t\t\t\t\tPT.name,\n\t\t\t\t\tIF(P.promotion = 1 AND IF(P.promotionstart IS NOT NULL, P.promotionstart <= CURDATE(), 1) AND IF(P.promotionend IS NOT NULL, P.promotionend >= CURDATE(), 1), P.discountprice * (1 + (V.value / 100)) * CR.exchangerate, NULL) AS discountprice,\n\t\t\t\t\t(P.sellprice * (1 + (V.value / 100)) * CR.exchangerate) AS sellprice,\n\t\t\t\t\tPT.shortdescription,\n\t\t\t\t\tPhoto.photoid,\n\t\t\t\t\tPT.seo,\n\t\t\t\t\tCT.name AS categoryname,\n\t\t\t\t\tPRT.name AS producername\n\t\t\t\tFROM product P\n\t\t\t\tLEFT JOIN producttranslation PT ON PT.productid = P.idproduct AND PT.languageid=:languageid\n\t\t\t\tLEFT JOIN productcategory PC ON PC.productid = P.idproduct\n\t\t\t\tINNER JOIN viewcategory VC ON VC.categoryid = PC.categoryid AND VC.viewid = :viewid\n\t\t\t\tLEFT JOIN categorytranslation CT ON PC.categoryid = CT.categoryid AND CT.languageid = :languageid\n\t\t\t\tLEFT JOIN producertranslation PRT ON PRT.producerid = P.producerid AND PRT.languageid = :languageid\n\t\t\t\tLEFT JOIN productphoto Photo ON Photo.productid = P.idproduct AND Photo.mainphoto = 1\n\t\t\t\tLEFT JOIN vat V ON P.vatid= V.idvat\n\t\t\t\tLEFT JOIN currencyrates CR ON CR.currencyfrom = P.sellcurrencyid AND CR.currencyto = :currencyto\n\t\t\t\tWHERE P.enable = 1\n\t            GROUP BY P.idproduct";
     $stmt = Db::getInstance()->prepare($sql);
     $stmt->bindValue('viewid', Helper::getViewId());
     $stmt->bindValue('languageid', Helper::getLanguageId());
     $stmt->bindValue('currencyto', Session::getActiveCurrencyId());
     $stmt->execute();
     $Data = array();
     while ($rs = $stmt->fetch()) {
         $Data[] = array('categoryid' => $rs['id'], 'seo' => $rs['seo'], 'categoryname' => $rs['categoryname'], 'producername' => $rs['producername'], 'productid' => $rs['idproduct'], 'name' => $rs['name'], 'shortdescription' => $rs['shortdescription'], 'sellprice' => number_format(!is_null($rs['discountprice']) ? $rs['discountprice'] : $rs['sellprice'], 2), 'photoid' => $rs['photoid'], 'idproduct' => $rs['idproduct']);
     }
     foreach ($Data as $key => $Product) {
         $Image = App::getModel('gallery')->getOrginalImageById($Product['photoid']);
         $Data[$key]['photo'] = App::getModel('gallery')->getImagePath($Image, App::getURLAdress());
     }
     return $Data;
 }
Exemplo n.º 13
0
 public function authProccess($login)
 {
     $hash = new \PasswordHash\PasswordHash();
     $sql = 'SELECT idclient, disable FROM client WHERE login = :login AND viewid = :viewid';
     $stmt = Db::getInstance()->prepare($sql);
     $stmt->bindValue('login', $hash->HashLogin($login));
     $stmt->bindValue('viewid', Helper::getViewId());
     $stmt->execute();
     $rs = $stmt->fetch();
     if ($rs) {
         if ($rs['disable'] == 0) {
             return $rs['idclient'];
         } else {
             return -1;
         }
     } else {
         return 0;
     }
 }
Exemplo n.º 14
0
 public function getCategoryById($id)
 {
     $sql = "SELECT\n\t\t\t\t\tCT.categoryid,\n\t\t\t\t\tCT.name,\n\t\t\t\t\tCT.seo,\n\t\t\t\t\tCT.shortdescription,\n\t\t\t\t\tCT.description,\n\t\t\t\t\tC.photoid,\n\t\t\t\t\tC.categoryid AS parent\n\t\t\t\tFROM categorytranslation CT\n\t\t\t\tLEFT JOIN category C ON CT.categoryid = C.idcategory\n\t\t\t\tLEFT JOIN viewcategory VC ON CT.categoryid = VC.categoryid \n\t\t\t\tWHERE C.idcategory =:id AND CT.languageid = :languageid AND VC.viewid = :viewid AND C.enable = 1";
     $stmt = Db::getInstance()->prepare($sql);
     $stmt->bindValue('languageid', Helper::getLanguageId());
     $stmt->bindValue('viewid', Helper::getViewId());
     $stmt->bindValue('id', $id);
     try {
         $stmt->execute();
         $rs = $stmt->fetch();
     } catch (Exception $e) {
         throw new FrontendException($e->getMessage());
     }
     $Data = array();
     if ($rs) {
         $Data = array('id' => $rs['categoryid'], 'name' => $rs['name'], 'seo' => $rs['seo'], 'shortdescription' => $rs['shortdescription'], 'description' => $rs['description'], 'photo' => $this->getImagePath($rs['photoid']));
     }
     return $Data;
 }
Exemplo n.º 15
0
 public function __construct($registry)
 {
     parent::__construct($registry);
     $this->queryColumns = array();
     $this->queryFrom = '';
     $this->queryGroupBy = '';
     $this->queryOrderBy = '';
     $this->queryHaving = '';
     $this->queryLimit = 100;
     $this->queryOffset = 0;
     $this->pagination = 100;
     $this->currentPage = 0;
     $this->sqlParams = array();
     $this->encryptionKey = Session::getActiveEncryptionKeyValue();
     $this->languageId = Helper::getLanguageId();
     $this->viewId = !is_null(Helper::getViewId()) ? Helper::getViewId() : 0;
     $this->queryAdditionalWhere = '';
     $this->DataSet = array();
     $this->cacheEnabled = array('enabled' => false, 'lifetime' => 3600, 'cacheid' => null);
     $this->layerData = $this->registry->loader->getCurrentLayer();
 }
Exemplo n.º 16
0
    protected function initDatagrid($datagrid)
    {
        $datagrid->setTableData('similarproduct', array('idsimilarproduct' => array('source' => 'SP.productid'), 'name' => array('source' => 'PT.name', 'prepareForAutosuggest' => true), 'productcount' => array('source' => 'count(distinct SP.relatedproductid)', 'filter' => 'having'), 'categoryname' => array('source' => 'CT.name'), 'categoryid' => array('source' => 'PC.categoryid', 'prepareForTree' => true, 'first_level' => App::getModel('product')->getCategories()), 'ancestorcategoryid' => array('source' => 'CP.ancestorcategoryid'), 'categoriesname' => array('source' => 'GROUP_CONCAT(DISTINCT SUBSTRING(CONCAT(\' \', CT.name), 1))', 'filter' => 'having')));
        $datagrid->setFrom('
			similarproduct SP
			LEFT JOIN producttranslation PT ON SP.productid = PT.productid AND PT.languageid = :languageid
			LEFT JOIN productcategory PC ON PC.productid = PT.productid
			LEFT JOIN viewcategory VC ON PC.categoryid = VC.categoryid
			LEFT JOIN category C ON C.idcategory = PC.categoryid
			LEFT JOIN categorypath CP ON C.idcategory = CP.categoryid
			LEFT JOIN categorytranslation CT ON C.idcategory = CT.categoryid AND CT.languageid = :languageid
		');
        $datagrid->setGroupBy('
				SP.productid
		');
        if (Helper::getViewId() > 0) {
            $datagrid->setAdditionalWhere('
				VC.viewid IN (' . Helper::getViewIdsAsString() . ')
			');
        }
    }
Exemplo n.º 17
0
    protected function _loadRawCategoriesFromDatabase()
    {
        $sql = '
				SELECT
					C.idcategory AS id,
					C.categoryid AS parent,
					C.photoid,
					CT.name AS label,
					CT.description,
					CT.shortdescription,
					CT.seo,
					(
						SELECT
							COUNT(DISTINCT T_PC.productid)
						FROM
							productcategory T_PC
						INNER JOIN
							product P ON P.idproduct = T_PC.productid
						WHERE
							P.enable = 1
						AND
							T_PC.categoryid = C.idcategory
					)AS totalproducts
				FROM
					category C
					LEFT JOIN viewcategory CV ON CV.categoryid = idcategory
					LEFT JOIN categorytranslation CT ON C.idcategory = CT.categoryid AND CT.languageid = :languageid
          			LEFT JOIN categorypath CP ON CP.ancestorcategoryid = C.idcategory
          			LEFT JOIN productcategory PC ON CP.categoryid = PC.categoryid
				WHERE
					CV.viewid = :viewid AND C.enable = 1
				GROUP BY id ORDER BY C.distinction ASC
			';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('languageid', Helper::getLanguageId());
        $stmt->bindValue('viewid', Helper::getViewId());
        $stmt->execute();
        $this->_rawData = $stmt->fetchAll();
    }
Exemplo n.º 18
0
 public function getMetadataForPage()
 {
     $controller = $this->registry->router->getCurrentController();
     $Data = array();
     $sql = "SELECT\n\t\t\t\t\tVT.keyword_title,\n\t\t\t\t\tC.description,\n\t\t\t\t\tVT.keyword,\n\t\t\t\t\tVT.keyword_description,\n\t\t\t\t\tVT.additionalmeta\n\t\t\t\tFROM controller C\n\t\t\t\tLEFT JOIN viewtranslation VT ON VT.viewid = :viewid AND VT.languageid = :languageid\n\t\t\t\tWHERE C.name = :controller AND C.mode = 0";
     $stmt = Db::getInstance()->prepare($sql);
     $stmt->bindValue('controller', $controller);
     $stmt->bindValue('viewid', Helper::getViewId());
     $stmt->bindValue('languageid', Helper::getLanguageId());
     $stmt->execute();
     $rs = $stmt->fetch();
     if ($rs) {
         if ($rs['keyword_title'] == NULL || $rs['keyword_title'] == '') {
             $keyword_title = $controller == 'mainside' ? Session::getActiveShopName() : _($rs['description']);
         } else {
             $keyword_title = $rs['keyword_title'];
         }
         $title = $controller == 'mainside' ? $keyword_title : _($rs['description']);
         $Data = array('keyword_title' => $title, 'keyword' => $rs['keyword'], 'keyword_description' => $rs['keyword_description'], 'additionalmeta' => $rs['additionalmeta']);
     }
     return $Data;
 }
Exemplo n.º 19
0
 protected function createMenu()
 {
     $this->xmlParser = new XmlParser();
     $namespace = $this->registry->loader->getCurrentNamespace();
     if (is_file(ROOTPATH . 'config' . DS . $namespace . DS . 'admin_menu.xml')) {
         $this->xmlParser->parseFast(ROOTPATH . 'config' . DS . $namespace . DS . 'admin_menu.xml');
     } else {
         $this->xmlParser->parseFast(ROOTPATH . 'config/admin_menu.xml');
     }
     $menuXML = $this->xmlParser->getValue('menu', false);
     $this->xmlParser->flush();
     $menu = array();
     foreach ($menuXML->block as $block) {
         if (is_object($block->element)) {
             foreach ($block->element as $element) {
                 if ($this->registry->right->checkMenuPermission((string) $element->controller, 'index', App::getModel('users')->getLayerIdByViewId(Helper::getViewId())) !== false) {
                     if (is_object($element->subelement) && !empty($element->subelement)) {
                         $sub = array();
                         $sort_subelement = array();
                         foreach ($element->subelement as $subelement) {
                             $sub[] = array('name' => _((string) $subelement->name), 'link' => (string) $subelement->link, 'sort_order' => (int) $subelement->sort_order, 'controller' => (string) $subelement->controller);
                             $sort_subelement[] = (int) $subelement->sort_order;
                         }
                     } else {
                         $sub = array();
                         $sort_subelement = array();
                     }
                     if (isset($element->subelement) && !empty($element->subelement)) {
                         $elem[] = array('name' => _((string) $element->name), 'link' => (string) $element->link, 'sort_order' => (int) $element->sort_order, 'controller' => (string) $element->controller, 'subelement' => $sub);
                         $sort_element[] = (int) $element->sort_order;
                     } else {
                         $elem[] = array('name' => _((string) $element->name), 'link' => (string) $element->link, 'sort_order' => (int) $element->sort_order, 'controller' => (string) $element->controller);
                         $sort_element[] = (int) $element->sort_order;
                     }
                 }
             }
             if (isset($elem)) {
                 if (isset($element->subelement) && !empty($element->subelement)) {
                     array_multisort($sort_subelement, SORT_ASC, $sub);
                     $menu[] = array('name' => _((string) $block->name), 'link' => (string) $block->link, 'icon' => (string) $block->icon, 'sort_order' => (int) $block->sort_order, 'elements' => $elem);
                 } else {
                     array_multisort($sort_element, SORT_ASC, $elem);
                     $menu[] = array('name' => _((string) $block->name), 'link' => (string) $block->link, 'icon' => (string) $block->icon, 'sort_order' => (int) $block->sort_order, 'elements' => $elem);
                 }
             } else {
                 $menu[] = array('name' => _((string) $block->name), 'link' => (string) $block->link, 'icon' => (string) $block->icon, 'sort_order' => (int) $block->sort_order);
             }
             $sort_block[] = (int) $block->sort_order;
             if (isset($elem)) {
                 unset($elem);
                 unset($sort_element);
                 unset($sub);
                 unset($subelement);
                 unset($sort_subelement);
             }
         }
     }
     array_multisort($sort_block, SORT_ASC, $menu);
     $Data = array();
     foreach ($menu as $key => $val) {
         $Data[] = $menu[$key];
     }
     Session::setActiveMenuData($Data);
 }
Exemplo n.º 20
0
 public function getOpinions()
 {
     $sql = 'SELECT idproductreview, nick, review FROM productreview WHERE enable != 1 AND viewid = :viewid ORDER BY adddate DESC limit 10';
     $stmt = Db::getInstance()->prepare($sql);
     $stmt->bindValue('viewid', Helper::getViewId());
     $stmt->execute();
     return $stmt->fetchAll();
 }
Exemplo n.º 21
0
    protected function addOrderClientData($Data, $clientId = 0, $orderId)
    {
        $sql = 'INSERT INTO orderclientdata SET
					firstname = AES_ENCRYPT(:firstname, :encryptionKey), 
					surname = AES_ENCRYPT(:surname, :encryptionKey), 
					street = AES_ENCRYPT(:street, :encryptionKey), 
					streetno = AES_ENCRYPT(:streetno, :encryptionKey), 
					placeno = AES_ENCRYPT(:placeno, :encryptionKey), 
					postcode = AES_ENCRYPT(:postcode, :encryptionKey), 
					place = AES_ENCRYPT(:place, :encryptionKey), 
					phone = AES_ENCRYPT(:phone, :encryptionKey),
					phone2 = AES_ENCRYPT(:phone2, :encryptionKey),
					email = AES_ENCRYPT(:email, :encryptionKey), 
					companyname = AES_ENCRYPT(:companyname, :encryptionKey), 
					nip = AES_ENCRYPT(:nip, :encryptionKey), 
					orderid = :orderid,
					clientid = :clientid,
					countryid = :country
		';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('firstname', $Data['firstname']);
        $stmt->bindValue('surname', $Data['surname']);
        $stmt->bindValue('street', $Data['street']);
        $stmt->bindValue('streetno', $Data['streetno']);
        $stmt->bindValue('placeno', $Data['placeno']);
        $stmt->bindValue('postcode', $Data['postcode']);
        $stmt->bindValue('place', $Data['placename']);
        $stmt->bindValue('phone', $Data['phone']);
        $stmt->bindValue('phone2', $Data['phone2']);
        $stmt->bindValue('email', $Data['email']);
        $stmt->bindValue('companyname', $Data['companyname']);
        $stmt->bindValue('nip', $Data['nip']);
        $stmt->bindValue('country', $Data['countryid']);
        $stmt->bindValue('orderid', $orderId);
        $stmt->bindValue('clientid', $clientId);
        $stmt->bindValue('viewid', Helper::getViewId());
        $stmt->bindValue('encryptionKey', Session::getActiveEncryptionKeyValue());
        try {
            $stmt->execute();
        } catch (Exception $e) {
            throw new Exception($e->getMessage());
        }
    }
Exemplo n.º 22
0
 public function getModuleSettingsForView()
 {
     if (($Data = $this->registry->cache->load('modulesettings')) === FALSE) {
         $sql = 'SELECT * FROM modulesettings WHERE viewid = :viewid';
         $stmt = Db::getInstance()->prepare($sql);
         $stmt->bindValue('viewid', Helper::getViewId());
         $stmt->execute();
         $Data = array();
         while ($rs = $stmt->fetch()) {
             $Data[$rs['module']] = array($rs['param'] => $rs['value']);
         }
         $this->registry->cache->save('modulesettings', $Data);
     }
     return $Data;
 }
Exemplo n.º 23
0
    public function productCategory($id)
    {
        if (Helper::getViewId() > 0) {
            $sql = 'SELECT
						VC.categoryid as id
					FROM viewcategory VC, productcategory PC
					WHERE VC.viewid = :viewid AND PC.productid = :id AND VC.categoryid = PC.categoryid
					GROUP BY VC.categoryid';
        } else {
            $sql = 'SELECT
						categoryid AS id
					FROM productcategory
					WHERE productid=:id
					GROUP BY categoryid';
        }
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('id', $id);
        if (Helper::getViewId() > 0) {
            $stmt->bindValue('viewid', Helper::getViewId());
        }
        $stmt->execute();
        return $stmt->fetchAll();
    }
Exemplo n.º 24
0
    protected function addUpdateCategory($Data)
    {
        $viewid = Helper::getViewId() > 0 ? Helper::getViewId() : $this->registry->loader->getParam('idview');
        $sql = 'SELECT idcategory FROM category WHERE migrationid = :migrationid';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('migrationid', $Data['id']);
        $stmt->execute();
        $rs = $stmt->fetch();
        if ($rs) {
            $idcategory = $rs['idcategory'];
            $sql = 'UPDATE category SET
						enable = :enable
					WHERE idcategory = :id';
            $stmt = Db::getInstance()->prepare($sql);
            $stmt->bindValue('id', $idcategory);
            $stmt->bindValue('enable', isset($Data['enable']) ? (int) $Data['enable'] : 0);
            try {
                $stmt->execute();
            } catch (Exception $e) {
                throw new CoreException(_('ERR_CATEGORY_ADD'), 3003, $e->getMessage());
            }
            $sql = 'UPDATE categorytranslation SET
					name = :name,
					shortdescription = :shortdescription,
					description = :description,
					keyword_title = :keyword_title,
					keyword = :keyword,
					keyword_description = :keyword_description,
					seo = :seo
				WHERE
					categoryid = :categoryid
			';
            $stmt = Db::getInstance()->prepare($sql);
            $stmt->bindValue('categoryid', $idcategory);
            $stmt->bindValue('name', $Data['name']);
            $stmt->bindValue('shortdescription', $Data['shortdescription']);
            $stmt->bindValue('description', $Data['description']);
            $stmt->bindValue('keyword_title', $Data['keyword_title']);
            $stmt->bindValue('keyword', $Data['keyword']);
            $stmt->bindValue('keyword_description', $Data['keyword_description']);
            $stmt->bindValue('seo', strtolower(Core::clearSeoUTF($Data['name'])));
            try {
                $stmt->execute();
            } catch (Exception $e) {
                throw new CoreException(_('ERR_CATEGORY_TRANSLATION_ADD'), 4, $e->getMessage());
            }
        } else {
            $sql = 'INSERT INTO category SET
						categoryid = :categoryid,
						photoid = :photoid,
						distinction = :distinction,
						enable = :enable,
						migrationid = :migrationid,
						migrationparentid = :migrationparentid';
            $stmt = Db::getInstance()->prepare($sql);
            $stmt->bindValue('categoryid', NULL);
            $stmt->bindValue('photoid', NULL);
            $stmt->bindValue('enable', isset($Data['enable']) ? (int) $Data['enable'] : 0);
            $stmt->bindValue('migrationid', $Data['id']);
            if ($Data['categoryid'] == 0) {
                $stmt->bindValue('migrationparentid', NULL);
            } else {
                $stmt->bindValue('migrationparentid', $Data['categoryid']);
            }
            $stmt->bindValue('distinction', $Data['distinction']);
            try {
                $stmt->execute();
            } catch (Exception $e) {
                throw new CoreException(_('ERR_CATEGORY_ADD'), 3003, $e->getMessage());
            }
            $idcategory = Db::getInstance()->lastInsertId();
            $sql = 'INSERT INTO categorytranslation (
						categoryid,
						name,
						shortdescription,
						description,
						keyword_title,
						keyword,
						keyword_description,
						seo,
						languageid
					)VALUES(
						:categoryid,
						:name,
						:shortdescription,
						:description,
						:keyword_title,
						:keyword,
						:keyword_description,
						:seo,
						:languageid
			)';
            $stmt = Db::getInstance()->prepare($sql);
            $stmt->bindValue('categoryid', $idcategory);
            $stmt->bindValue('name', $Data['name']);
            $stmt->bindValue('shortdescription', $Data['shortdescription']);
            $stmt->bindValue('description', $Data['description']);
            $stmt->bindValue('keyword_title', $Data['keyword_title']);
            $stmt->bindValue('keyword', $Data['keyword']);
            $stmt->bindValue('keyword_description', $Data['keyword_description']);
            $stmt->bindValue('seo', strtolower(Core::clearSeoUTF($Data['name'])));
            $stmt->bindValue('languageid', Helper::getLanguageId());
            try {
                $stmt->execute();
            } catch (Exception $e) {
                throw new CoreException(_('ERR_CATEGORY_TRANSLATION_ADD'), 4, $e->getMessage());
            }
            $sql = 'INSERT INTO viewcategory (categoryid,viewid) VALUES (:categoryid, :viewid)';
            $stmt = Db::getInstance()->prepare($sql);
            $stmt->bindValue('categoryid', $idcategory);
            $stmt->bindValue('viewid', $viewid);
            try {
                $stmt->execute();
            } catch (Exception $e) {
                throw new CoreException(_('ERR_NEWS_ADD'), 4, $e->getMessage());
            }
        }
    }
Exemplo n.º 25
0
    public function addOrder($Data)
    {
        $dispatchmethodId = $Data['additional_data']['payment_data']['delivery_method'];
        $sql = "SELECT\n\t\t\t\t\tDMT.name as dispatchmethodname,\n\t\t\t\t\tiddispatchmethod\n\t\t\t\tFROM dispatchmethod D\n        LEFT JOIN dispatchmethodtranslation DMT ON DMT.dispatchmethodid = D.iddispatchmethod AND DMT.languageid = :languageid\n\t\t\t\tWHERE iddispatchmethod=:dispatchmethodId";
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('languageid', Helper::getLanguageId());
        $stmt->bindValue('dispatchmethodId', $dispatchmethodId);
        $stmt->execute();
        $rs = $stmt->fetch();
        $dispatchData = array();
        if ($rs) {
            $dispatchmethodname = $rs['dispatchmethodname'];
        }
        $paymentmethodId = $Data['additional_data']['payment_data']['payment_method'];
        $sql = "SELECT\n\t\t\t\t\tPMT.name as paymentmethodname,\n\t\t\t\t\tidpaymentmethod\n\t\t\t\tFROM paymentmethod P\n        LEFT JOIN paymentmethodtranslation PMT ON PMT.paymentmethodid = P.idpaymentmethod AND PMT.languageid = :languageid\n\t\t\t\tWHERE idpaymentmethod=:paymentmethodId";
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('paymentmethodId', $paymentmethodId);
        $stmt->bindValue('languageid', Helper::getLanguageId());
        $stmt->execute();
        $rs = $stmt->fetch();
        $paymentData = array();
        if ($rs) {
            $paymentmethodname = $rs['paymentmethodname'];
        }
        $sql = 'INSERT INTO `order` SET
					clientid = :clientid,
					orderstatusid = (SELECT idorderstatus FROM orderstatus WHERE `default` = 1),
					price = :price,
					dispatchmethodprice = :dispatchmethodprice,
					globalprice = :globalprice,
					dispatchmethodid = :dispatchmethodid,
					dispatchmethodname = :dispatchmethodname,
					paymentmethodid = :paymentmethodid,
					paymentmethodname = :paymentmethodname,
					globalpricenetto = :globalpricenetto,
					viewid = :viewid,
					pricebeforepromotion = :pricebeforepromotion,
					rulescartid = :rulescartid,
					currencyid = :currencyid,
					currencysymbol = :currencysymbol,
					currencyrate = :currencyrate,
					sessionid = :sessionid';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('sessionid', session_id());
        if (isset($Data['client_data']['client']) && (int) $Data['client_data']['client'] > 0) {
            $stmt->bindValue('clientid', $Data['client_data']['client']);
        } else {
            $stmt->bindValue('clientid', NULL);
        }
        $stmt->bindValue('currencyid', Session::getActiveCurrencyId());
        $stmt->bindValue('currencysymbol', Session::getActiveCurrencySymbol());
        $stmt->bindValue('currencyrate', Session::getActiveCurrencyRate());
        $stmt->bindValue('price', $Data['pricebrutto']);
        $stmt->bindValue('globalprice', $Data['pricebrutto'] + $Data['dispatchmethodprice']);
        $stmt->bindValue('dispatchmethodprice', $Data['dispatchmethodprice']);
        $stmt->bindValue('globalpricenetto', $Data['pricenetto']);
        $stmt->bindValue('pricebeforepromotion', NULL);
        $stmt->bindValue('rulescartid', NULL);
        $stmt->bindValue('dispatchmethodname', $dispatchmethodname);
        $stmt->bindValue('dispatchmethodid', $dispatchmethodId);
        $stmt->bindValue('paymentmethodname', $paymentmethodname);
        $stmt->bindValue('paymentmethodid', $paymentmethodId);
        $stmt->bindValue('viewid', Helper::getViewId());
        try {
            $stmt->execute();
        } catch (Exception $e) {
            throw new CoreException(_('ERR_ORDER_ADD'), 112, $e->getMessage());
        }
        return Db::getInstance()->lastInsertId();
    }
Exemplo n.º 26
0
    protected function _loadRawContentCategoriesFromDatabase()
    {
        $sql = 'SELECT 
					C.idcontentcategory AS id, 
					CT.name AS name, 
					CCV.viewid, 
					C.contentcategoryid as parent,
					C.header,
					C.footer,
					C.redirect,
					C.redirect_route,
					C.redirect_url
				FROM contentcategory C
				LEFT JOIN contentcategoryview CCV ON CCV.contentcategoryid = C.idcontentcategory
				LEFT JOIN contentcategorytranslation CT ON CT.contentcategoryid = C.idcontentcategory AND CT.languageid = :languageid
				WHERE CCV.viewid = :viewid
				ORDER BY C.hierarchy ASC
		';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('languageid', Helper::getLanguageId());
        $stmt->bindValue('viewid', Helper::getViewId());
        $stmt->execute();
        $Data = array();
        while ($rs = $stmt->fetch()) {
            $Data[] = array('id' => $rs['id'], 'name' => $rs['name'], 'viewid' => $rs['viewid'], 'parent' => $rs['parent'], 'header' => $rs['header'], 'footer' => $rs['footer'], 'redirect' => $rs['redirect'], 'redirect_route' => $rs['redirect_route'], 'redirect_url' => $rs['redirect_url'], 'seo' => strtolower(Core::clearSeoUTF($rs['name'])));
        }
        $this->_rawData = $Data;
    }
Exemplo n.º 27
0
 public function __construct($registry, $modelFile)
 {
     parent::__construct($registry, $modelFile);
     $this->viewid = Helper::getViewId();
     $this->languageid = Helper::getLanguageId();
 }
Exemplo n.º 28
0
    public function getSummaryStats()
    {
        $Data = array();
        $period = date("Ym");
        $sql = 'SELECT COUNT(idclient) as clients
				FROM `client`
				WHERE IF(:viewid = 0, 1, viewid = :viewid) AND DATE_FORMAT(adddate,\'%Y-%m-%d\') = CURDATE()';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('viewid', Helper::getViewId());
        $stmt->execute();
        while ($rs = $stmt->fetch()) {
            $Data['day'] = array('dayclients' => (int) $rs['clients']);
        }
        $sql = 'SELECT COUNT(idclient) as clients
				FROM `client`
				WHERE IF(:viewid =0,1,viewid = :viewid) AND DATE_FORMAT(adddate,\'%Y%m\') = :period';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('period', $period);
        $stmt->bindValue('viewid', Helper::getViewId());
        $stmt->execute();
        while ($rs = $stmt->fetch()) {
            $Data['month'] = array('monthclients' => (int) $rs['clients']);
        }
        $sql = 'SELECT COUNT(idclient) as clients
					FROM `client`
					WHERE IF(:viewid =0,1,viewid = :viewid) AND year(adddate) = :period';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('period', date("Y"));
        $stmt->bindValue('viewid', Helper::getViewId());
        $stmt->execute();
        while ($rs = $stmt->fetch()) {
            $Data['year'] = array('yearclients' => (int) $rs['clients']);
        }
        $sql = 'SELECT COUNT(idclient) as totalclients FROM `client`';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->execute();
        while ($rs = $stmt->fetch()) {
            $Data['total'] = array('totalclients' => (int) $rs['totalclients']);
        }
        return $Data;
    }
Exemplo n.º 29
0
    public function addClientAboutNewsletter($email, $viewId = 0)
    {
        $sql = 'INSERT INTO clientnewsletter (email, viewid)
					VALUES (:email, :viewid)';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('email', $email);
        $stmt->bindValue('viewid', $viewId !== 0 ? $viewId : Helper::getViewId());
        try {
            $stmt->execute();
        } catch (Exception $e) {
            throw new FrontendException($e->getMessage());
        }
        return Db::getInstance()->lastInsertId();
    }
Exemplo n.º 30
0
    public function getSubpageTree()
    {
        $sql = 'SELECT
					idpagescheme AS id,
					name
				FROM pagescheme
				WHERE IF(:viewid > 0, idpagescheme = (SELECT pageschemeid FROM view WHERE idview = :viewid), 1)
				ORDER BY name ASC';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('viewid', (int) Helper::getViewId());
        $stmt->execute();
        $Data = array();
        $i = 0;
        while ($rs = $stmt->fetch()) {
            $Data[$rs['id']] = array('name' => $rs['name'], 'parent' => NULL, 'weight' => $i++);
            $sql2 = 'SELECT
						S.name,
						S.description,
						SL.idsubpagelayout 
					FROM subpagelayout SL
					LEFT JOIN subpage S ON SL.subpageid = S.idsubpage
					WHERE SL.pageschemeid = :pageschemeid
					GROUP BY SL.subpageid
					ORDER BY name ASC';
            $stmt2 = Db::getInstance()->prepare($sql2);
            $stmt2->bindValue('pageschemeid', $rs['id']);
            $stmt2->execute();
            $j = 0;
            while ($rs2 = $stmt2->fetch()) {
                $Data[$rs['id'] . ',' . $rs2['idsubpagelayout']] = array('name' => $rs2['description'] . ' <small>' . $rs2['name'] . '</small>', 'parent' => $rs['id'], 'weight' => $j++);
            }
        }
        return $Data;
    }