示例#1
0
 public function getProductListIntegration()
 {
     $sql = "SELECT\n\t\t\t\t\tP.idproduct,\n\t\t\t\t\tPT.name,\n\t\t\t\t\t(P.sellprice * (1 + (V.value / 100)) * CR.exchangerate) AS sellprice,\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\tPT.shortdescription,\n\t\t\t\t\tPhoto.photoid,\n\t\t\t\t\tPRT.name AS producername,\n\t\t\t\t\tPT.seo,\n\t\t\t\t\t(SELECT\n\t\t\t\t\t    GROUP_CONCAT(SUBSTRING(CT.name, 1) ORDER BY C.order DESC SEPARATOR ' / ')\n\t\t\t\t\tFROM categorytranslation CT\n\t\t\t\t\tLEFT JOIN categorypath C ON C.ancestorcategoryid = CT.categoryid\n\t\t\t\t\tWHERE C.categoryid = PC.categoryid AND CT.languageid = :languageid) AS kreocen\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\tLEFT JOIN categorypath CP ON CP.ancestorcategoryid = PC.categoryid\n\t\t\t\tLEFT JOIN categorytranslation CT ON CP.ancestorcategoryid = CT.categoryid AND CT.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 producertranslation PRT ON PRT.producerid = P.producerid AND PRT.languageid = :languageid\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->bindParam('languageid', Helper::getLanguageId());
     $stmt->bindParam('currencyto', Session::getActiveCurrencyId());
     $stmt->execute();
     $Data = array();
     while ($rs = $stmt->fetch()) {
         $Data[] = array('productid' => $rs['idproduct'], 'seo' => $rs['seo'], 'name' => $rs['name'], 'shortdescription' => $rs['shortdescription'], 'sellprice' => number_format(!is_null($rs['discountprice']) ? $rs['discountprice'] : $rs['sellprice'], 2), 'photoid' => $rs['photoid'], 'idproduct' => $rs['idproduct'], 'producername' => $rs['producername'], 'kreocen' => $rs['kreocen']);
     }
     foreach ($Data as $key => $Product) {
         $Image = App::getModel('gallery')->getOrginalImageById($Product['photoid']);
         $Data[$key]['photo'] = App::getModel('gallery')->getImagePath($Image, App::getURLAdress());
     }
     return $Data;
 }
示例#2
0
 public function getProductListIntegration()
 {
     $this->registry->template->assign('skapieccategories', $this->getCategories());
     $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\t(P.sellprice * (1 + (V.value / 100)) * CR.exchangerate) AS sellprice,\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\tPT.shortdescription,\n\t\t\t\t\tPhoto.photoid,\n\t\t\t\t\tPT.seo,\n\t\t\t\t\tPC.categoryid,\n\t\t\t\t\tPRT.name AS producername,\n\t\t\t\t\tP.weight\n\t\t\t\tFROM product P\n\t\t\t\tLEFT JOIN vat V ON P.vatid= V.idvat\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 currencyrates CR ON CR.currencyfrom = P.sellcurrencyid AND CR.currencyto = :currencyto\n\t\t\t\tLEFT JOIN categorypath CP ON CP.ancestorcategoryid = PC.categoryid\n\t\t\t\tLEFT JOIN categorytranslation CT ON CP.ancestorcategoryid = 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\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'], 'categoryid' => $rs['categoryid'], '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;
 }
示例#3
0
    public function getSummaryStats()
    {
        $Data = array();
        $period = date("Ym");
        $sql = 'SELECT ROUND(SUM(globalprice * CR.exchangerate),2) as total, COUNT(idorder) as orders
					FROM `order` O
          LEFT JOIN currencyrates CR ON CR.currencyfrom = O.currencyid AND CR.currencyto = :currencyto
					WHERE viewid IN (' . Helper::getViewIdsAsString() . ') AND DATE_FORMAT(adddate,\'%Y%m\') = :period';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('period', $period);
        $stmt->bindValue('currencyto', Session::getActiveCurrencyId());
        $stmt->execute();
        while ($rs = $stmt->fetch()) {
            $Data['summarysales'] = array('total' => sprintf('%.2f', $rs['total']), 'orders' => $rs['orders']);
        }
        // Daily sales
        $sql = 'SELECT ROUND(SUM(globalprice * CR.exchangerate),2) as total, COUNT(idorder) as orders
					FROM `order` O
          LEFT JOIN currencyrates CR ON CR.currencyfrom = O.currencyid AND CR.currencyto = :currencyto
					WHERE viewid IN (' . Helper::getViewIdsAsString() . ') AND DATE_FORMAT(adddate,\'%Y-%m-%d\') = CURDATE()';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('currencyto', Session::getActiveCurrencyId());
        $stmt->execute();
        while ($rs = $stmt->fetch()) {
            $Data['todaysales'] = array('total' => sprintf('%.2f', $rs['total']), 'orders' => $rs['orders']);
        }
        // Total clients
        $sql = 'SELECT COUNT(idclient) as totalclients
					FROM `client`
					WHERE viewid IN (' . Helper::getViewIdsAsString() . ') AND DATE_FORMAT(adddate,\'%Y%m\') = :period';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('period', $period);
        $stmt->execute();
        while ($rs = $stmt->fetch()) {
            $Data['summaryclients'] = array('totalclients' => (int) $rs['totalclients']);
        }
        // Daily clients
        $sql = 'SELECT COUNT(idclient) as clients
					FROM `client`
					WHERE viewid IN (' . Helper::getViewIdsAsString() . ') AND DATE_FORMAT(adddate,\'%Y-%m-%d\') = CURDATE()';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->execute();
        while ($rs = $stmt->fetch()) {
            $Data['todayclients'] = array('totalclients' => (int) $rs['clients']);
        }
        return $Data;
    }
示例#4
0
    protected function addOrder($Data, $clientId = 0, $orginalOrderId = NULL)
    {
        $selectedOption = Session::getActiveDispatchmethodOption();
        $globalPrice = 0;
        $globalNetto = 0;
        $price = 0;
        $sql = 'INSERT INTO `order` (
					price, 
					dispatchmethodprice, 
					globalprice, 
					dispatchmethodname, 
					paymentmethodname, 
					orderstatusid,
					dispatchmethodid, 
					paymentmethodid, 
					clientid, 
					globalpricenetto, 
					viewid, 
					pricebeforepromotion, 
					currencyid, 
					currencysymbol, 
					currencyrate,
					rulescartid,
					sessionid,
					customeropinion
				)
				VALUES (
					:price, 
					:dispatchmethodprice, 
					:globalprice, 
					:dispatchmethodname, 
					:paymentmethodname,
					(SELECT idorderstatus FROM orderstatus WHERE `default` = 1), 
					:dispatchmethodid, 
					:paymentmethodid, 
					:clientid, 
					:globalpricenetto, 
					:viewid, 
					:pricebeforepromotion, 
					:currencyid, 
					:currencysymbol, 
					:currencyrate,
					:rulescartid,
					:sessionid,
					:customeropinion
				)';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('dispatchmethodprice', $Data['dispatchmethod']['dispatchmethodcost']);
        $stmt->bindValue('dispatchmethodname', $Data['dispatchmethod']['dispatchmethodname']);
        $stmt->bindValue('dispatchmethodid', $Data['dispatchmethod']['dispatchmethodid']);
        $stmt->bindValue('paymentmethodname', $Data['payment']['paymentmethodname']);
        $stmt->bindValue('paymentmethodid', $Data['payment']['idpaymentmethod']);
        $stmt->bindValue('clientid', $clientId);
        $stmt->bindValue('sessionid', session_id());
        $stmt->bindValue('customeropinion', $Data['customeropinion']);
        $shopCurrency = Session::getActiveShopCurrencyId();
        $clientCurrency = Session::getActiveCurrencyId();
        if ($shopCurrency !== $clientCurrency) {
            $stmt->bindValue('currencyid', $clientCurrency);
            $stmt->bindValue('currencysymbol', Session::getActiveCurrencySymbol());
            $stmt->bindValue('currencyrate', Session::getActiveCurrencyRate());
        } else {
            $stmt->bindValue('currencyid', $shopCurrency);
            $stmt->bindValue('currencysymbol', $this->layer['currencysymbol']);
            $stmt->bindValue('currencyrate', Session::getActiveCurrencyRate());
        }
        if (isset($Data['priceWithDispatchMethodPromo']) && $Data['priceWithDispatchMethodPromo'] > 0) {
            $stmt->bindValue('pricebeforepromotion', $Data['priceWithDispatchMethod']);
            if ($globalPrice == 0) {
                $globalPrice = $Data['priceWithDispatchMethodPromo'];
                $globalNetto = $Data['priceWithDispatchMethodNettoPromo'];
                $price = $Data['globalPricePromo'];
            }
        } else {
            $stmt->bindValue('pricebeforepromotion', 0);
        }
        if ($globalPrice == 0 || $globalNetto == 0) {
            $globalPrice = $Data['priceWithDispatchMethod'];
            $globalNetto = $Data['globalPriceWithoutVat'];
            $price = $Data['globalPrice'];
        }
        if (isset($Data['rulescartid']) && !empty($Data['rulescartid'])) {
            $stmt->bindValue('rulescartid', $Data['rulescartid']);
        } else {
            $stmt->bindValue('rulescartid', NULL);
        }
        $stmt->bindValue('globalprice', $globalPrice);
        $stmt->bindValue('globalpricenetto', $globalNetto);
        $stmt->bindValue('price', $price);
        $stmt->bindValue('viewid', Helper::getViewId());
        try {
            $stmt->execute();
        } catch (Exception $e) {
            throw new Exception($e->getMessage());
        }
        return Db::getInstance()->lastInsertId();
    }
示例#5
0
    public function getAttributeCombinationsForProduct($productId, $clientGroupId = 0, $currencyid = 0)
    {
        if ($currencyid == 0) {
            $currencyid = Session::getActiveCurrencyId();
        }
        $Data = array();
        if ($clientGroupId > 0) {
            $sql = '
				SELECT
					A.idproductattributeset AS id,
					A.`value`,
					A.stock AS qty,
					A.symbol,
					A.status,
					A.weight,
					A.availablityid,
					A.photoid,
					A.suffixtypeid AS prefix_id,
					GROUP_CONCAT(SUBSTRING(CONCAT(\' \', C.name), 1)) AS name,
					IF(PGP.promotion = 1 AND IF(PGP.promotionstart IS NOT NULL, PGP.promotionstart <= CURDATE(), 1) AND IF(PGP.promotionend IS NOT NULL, PGP.promotionend >= CURDATE(), 1),
						CASE A.suffixtypeid
                           	WHEN 1 THEN PGP.discountprice * (A.value / 100)
                            WHEN 2 THEN PGP.discountprice + A.value
                            WHEN 3 THEN PGP.discountprice - A.value
                          	WHEN 4 THEN A.`value`
                        END,
						IF(PGP.groupprice IS NULL AND D.promotion = 1 AND IF(D.promotionstart IS NOT NULL, D.promotionstart <= CURDATE(), 1) AND IF(D.promotionend IS NOT NULL, D.promotionend >= CURDATE(), 1),
							A.discountprice,
							IF(PGP.sellprice IS NOT NULL,
								CASE A.suffixtypeid
		                           	WHEN 1 THEN PGP.sellprice * (A.value / 100)
		                            WHEN 2 THEN PGP.sellprice + A.value
		                            WHEN 3 THEN PGP.sellprice - A.value
		                          	WHEN 4 THEN A.`value`
	                           	END,
								A.attributeprice
							)
						)
					) * CR.exchangerate AS price,
					(
						SELECT (
							ROUND(price + (price * V.`value` / 100), 2)
						)
					) AS price_gross
				FROM
					productattributeset A
					LEFT JOIN productattributevalueset B ON A.idproductattributeset = B.productattributesetid
					LEFT JOIN attributeproductvalue C ON B.attributeproductvalueid = C.idattributeproductvalue
					LEFT JOIN product D ON A.productid = D.idproduct
					LEFT JOIN productgroupprice PGP ON PGP.productid = D.idproduct AND PGP.clientgroupid = :clientgroupid
					LEFT JOIN currencyrates CR ON CR.currencyfrom = D.sellcurrencyid AND CR.currencyto = :currencyto
					LEFT JOIN suffixtype E ON A.suffixtypeid = E.idsuffixtype
					LEFT JOIN vat V ON V.idvat = D.vatid
				WHERE
					A.productid = :productid
				GROUP BY
					A.idproductattributeset
			';
        } else {
            $sql = '
				SELECT
					A.idproductattributeset AS id,
					A.`value`,
					A.stock AS qty,
					A.symbol,
					A.status,
					A.weight,
					A.availablityid,
					A.photoid,
					A.suffixtypeid AS prefix_id,
					GROUP_CONCAT(SUBSTRING(CONCAT(\' \', C.name), 1)) AS name,
					IF(D.promotion = 1 AND IF(D.promotionstart IS NOT NULL, D.promotionstart <= CURDATE(), 1) AND IF(D.promotionend IS NOT NULL, D.promotionend >= CURDATE(), 1), A.discountprice, A.attributeprice) * CR.exchangerate AS price,
					(
						SELECT (
							ROUND(price + (price * V.`value` / 100), 2)
						)
					) AS price_gross
				FROM
					productattributeset A
					LEFT JOIN productattributevalueset B ON A.idproductattributeset = B.productattributesetid
					LEFT JOIN attributeproductvalue C ON B.attributeproductvalueid = C.idattributeproductvalue
					LEFT JOIN product D ON A.productid = D.idproduct
					LEFT JOIN productgroupprice PGP ON PGP.productid = D.idproduct AND PGP.clientgroupid = :clientgroupid
					LEFT JOIN currencyrates CR ON CR.currencyfrom = D.sellcurrencyid AND CR.currencyto = :currencyto
					LEFT JOIN suffixtype E ON A.suffixtypeid = E.idsuffixtype
					LEFT JOIN vat V ON V.idvat = D.vatid
				WHERE
					A.productid = :productid
				GROUP BY
					A.idproductattributeset
			';
        }
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('productid', $productId);
        $stmt->bindValue('clientgroupid', $clientGroupId);
        $stmt->bindValue('currencyto', $currencyid);
        $stmt->execute();
        $Data = $stmt->fetchAll();
        foreach ($Data as $key => $value) {
            $sql = '
					SELECT
						B.attributeproductid AS attribute,
						A.attributeproductvalueid AS value,
						B.name AS name
					FROM
						productattributevalueset A
						LEFT JOIN attributeproductvalue B ON A.attributeproductvalueid = B.idattributeproductvalue
					WHERE
						A.productattributesetid = :productattributesetid
				';
            $stmt = Db::getInstance()->prepare($sql);
            $stmt->bindValue('productattributesetid', $value['id']);
            $stmt->execute();
            $Data[$key]['attributes'] = array();
            while ($rs = $stmt->fetch()) {
                $Data[$key]['attributes'][] = array('id' => $rs['attribute'], 'value_id' => $rs['value'], 'name' => $rs['name']);
            }
        }
        return $Data;
    }
示例#6
0
    public function loadView()
    {
        $sql = 'SELECT
					V.idview,
					V.name as shopname,
					V.namespace,
					C.idcurrency, 
					C.currencysymbol,
					C.decimalseparator,
					C.decimalcount,
					C.thousandseparator,
					C.positivepreffix,
					C.positivesuffix,
					C.negativepreffix,
					C.negativesuffix,
					S.countryid,
					V.taxes,
					V.showtax,
					V.offline,
					cartredirect,
          terms,
					photoid,
					favicon,
					forcelogin,
					apikey,
					watermark,
					confirmregistration,
					enableregistration,
					invoicenumerationkind,
					V.pageschemeid,
					V.contactid,
					PS.templatefolder
				FROM view V
				LEFT JOIN viewcategory VC ON VC.viewid = V.idview
				LEFT JOIN store S ON V.storeid = S.idstore
				LEFT JOIN pagescheme PS ON PS.idpagescheme = V.pageschemeid
				LEFT JOIN currency C ON C.idcurrency = IF(:currencyid > 0, :currencyid, V.currencyid)
				WHERE V.idview = :viewid';
        $stmt = Db::getInstance()->prepare($sql);
        $stmt->bindValue('viewid', $this->determineViewId());
        $stmt->bindValue('currencyid', Session::getActiveCurrencyId());
        $stmt->execute();
        $rs = $stmt->fetch();
        if ($rs) {
            $this->layer = array('terms' => $rs['terms'], 'idview' => $rs['idview'], 'namespace' => $rs['namespace'], 'cartredirect' => $rs['cartredirect'], 'offline' => $rs['offline'], 'taxes' => $rs['taxes'], 'showtax' => $rs['showtax'], 'shopname' => $rs['shopname'], 'photoid' => $rs['photoid'], 'favicon' => $rs['favicon'], 'watermark' => $rs['watermark'], 'idcurrency' => $rs['idcurrency'], 'currencysymbol' => $rs['currencysymbol'], 'decimalseparator' => $rs['decimalseparator'], 'decimalcount' => $rs['decimalcount'], 'thousandseparator' => $rs['thousandseparator'], 'positivepreffix' => $rs['positivepreffix'], 'positivesuffix' => $rs['positivesuffix'], 'negativepreffix' => $rs['negativepreffix'], 'negativesuffix' => $rs['negativesuffix'], 'countryid' => $rs['countryid'], 'forcelogin' => $rs['forcelogin'], 'confirmregistration' => $rs['confirmregistration'], 'enableregistration' => $rs['enableregistration'], 'apikey' => $rs['apikey'], 'invoicenumerationkind' => $rs['invoicenumerationkind'], 'pageschemeid' => $rs['pageschemeid'], 'theme' => $rs['templatefolder'], 'pageschemeid' => $rs['pageschemeid'], 'contactid' => $rs['contactid']);
            Session::setActiveShopName($this->layer['shopname']);
            if (is_null($this->layer['photoid'])) {
                $this->layer['photoid'] = 'logo.png';
            }
            if (is_null($this->layer['favicon'])) {
                $this->layer['favicon'] = 'favicon.ico';
            }
            Session::setActiveShopCurrencyId($this->layer['idcurrency']);
            Session::setActiveForceLogin($this->layer['forcelogin']);
            if (Session::getActiveBrowserData() == NULL) {
                $browser = new Browser();
                $Data = array('browser' => $browser->getBrowser(), 'platform' => $browser->getPlatform(), 'ismobile' => $browser->isMobile(), 'isbot' => $browser->isRobot());
                Session::setActiveBrowserData($Data);
            }
        }
    }
示例#7
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();
    }
示例#8
0
 public function getData()
 {
     $this->queryLimit = $this->pagination;
     $this->queryOffset = $this->currentPage * $this->pagination - $this->pagination;
     $bFilteredOrderBy = false;
     foreach ($this->queryColumns as $column => $options) {
         if ($this->queryOrderBy == $column || $this->queryOrderBy == 'random' || $this->queryOrderBy == 'default' || $this->queryOrderBy == 'related') {
             $bFilteredOrderBy = true;
         }
         if (isset($options['encrypted']) && $options['encrypted'] && $this->encryptionKey != '') {
             $columns[] = "AES_DECRYPT({$options['source']}, :encryptionkey) AS {$column}";
         } else {
             $columns[] = "{$options['source']} AS {$column}";
         }
     }
     if ($bFilteredOrderBy == false) {
         throw new \Exception('Column not found: ' . $this->queryOrderBy);
     }
     $columns[0] = 'SQL_CALC_FOUND_ROWS ' . $columns[0];
     $sqlColumns = implode(",\n", $columns);
     $sqlFrom = $this->queryFrom;
     $sqlGroupBy = $this->queryGroupBy;
     $selectString = "SELECT {$sqlColumns}";
     $fromString = " FROM {$sqlFrom}";
     $whereString = "";
     $havingString = "";
     if ($this->queryAdditionalWhere != '') {
         $whereString = ' WHERE ' . $this->queryAdditionalWhere;
     }
     $groupString = " GROUP BY {$sqlGroupBy}";
     $orderString = ' ';
     if ($this->queryHaving != '') {
         $havingString = ' HAVING ' . $this->queryHaving;
     }
     $limitString = ' ';
     if ($this->queryOrderBy == 'random') {
         $orderString .= 'ORDER BY RAND()';
         $limitString .= 'LIMIT ' . $this->pagination;
     } elseif ($this->queryOrderBy == 'default') {
         $orderString .= 'ORDER BY hierarchy DESC, discountprice DESC, new DESC';
         $limitString .= 'LIMIT ' . $this->queryOffset . ',' . $this->pagination;
     } elseif ($this->queryOrderBy == 'related') {
         $orderString .= 'ORDER BY hierarchy ' . $this->queryOrderDir;
         $limitString .= 'LIMIT ' . $this->queryOffset . ',' . $this->pagination;
     } else {
         $orderString .= 'ORDER BY ' . $this->queryOrderBy . ' ' . $this->queryOrderDir;
         if ($this->pagination > 0) {
             $limitString .= 'LIMIT ' . $this->queryOffset . ',' . $this->pagination;
         }
     }
     $sql = $selectString . $fromString . $whereString . $groupString . $havingString . $orderString . $limitString;
     $stmt = Db::getInstance()->prepare($sql);
     if (preg_match('/:languageid/', $sql)) {
         $stmt->bindValue('languageid', $this->languageId);
     }
     if (preg_match('/:encryptionkey/', $sql)) {
         $stmt->bindValue('encryptionkey', $this->encryptionKey);
     }
     foreach ($this->sqlParams as $key => $val) {
         if (is_array($val)) {
             if (isset($val[0]) && is_numeric($val[0])) {
                 $stmt->bindValue($key, implode(',', $val));
             } elseif (isset($val[0]) && is_string($val[0])) {
                 $stmt->bindValue($key, implode(',', $val));
             } else {
                 $stmt->bindValue($key, 0);
             }
         } else {
             if (is_int($val)) {
                 $stmt->bindValue($key, $val);
             } elseif (is_null($val)) {
                 $stmt->bindValue($key, NULL);
             } elseif (is_float($val)) {
                 $stmt->bindValue($key, $val);
             } elseif (is_string($val)) {
                 $stmt->bindValue($key, $val);
             } else {
                 $stmt->bindValue($key, $val);
             }
         }
     }
     if (preg_match('/:viewid/', $sql)) {
         $stmt->bindValue('viewid', $this->viewId);
     }
     if (preg_match('/:clientgroupid/', $sql)) {
         $stmt->bindValue('clientgroupid', Session::getActiveClientGroupid());
     }
     if (preg_match('/:today/', $sql)) {
         $stmt->bindValue('today', date("Y-m-d"));
     }
     if (preg_match('/:currencyto/', $sql)) {
         $stmt->bindValue('currencyto', Session::getActiveCurrencyId());
     }
     try {
         $stmt->execute();
         $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     } catch (Exception $e) {
         throw new FrontendException('ERR_DATASET_GET_DATA', 12, $e->getMessage());
     }
     $this->getTotalRecords();
     $this->processRows($rows);
     if ($this->pagination > 0) {
         $pages = ceil($this->DataSet['total'] / $this->pagination);
         if ($pages == 0) {
             $this->DataSet['totalPages'] = range(1, 1, 1);
             $this->DataSet['activePage'] = 1;
             $this->DataSet['lastPage'] = 1;
             $this->DataSet['previousPage'] = 1;
             $this->DataSet['nextPage'] = 1;
         } else {
             $this->DataSet['totalPages'] = range(1, $pages, 1);
             $this->DataSet['activePage'] = $this->currentPage;
             $this->DataSet['lastPage'] = $pages;
             $this->DataSet['previousPage'] = $this->currentPage - 1;
             $this->DataSet['nextPage'] = $this->currentPage + 1;
         }
     } else {
         $this->DataSet['totalPages'] = range(1, 1, 1);
         $this->DataSet['activePage'] = 1;
         $this->DataSet['lastPage'] = 1;
         $this->DataSet['previousPage'] = 1;
         $this->DataSet['nextPage'] = 1;
     }
 }