Exemple #1
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();
    }
Exemple #2
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();
    }