public function view() { $sql = 'SELECT T.name, TD.translation FROM translation T LEFT JOIN translationdata TD ON T.idtranslation = TD.translationid AND TD.languageid = :languageid'; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('languageid', Helper::getLanguageId()); $stmt->execute(); $xml = new SimpleXMLElement('<rows></rows>'); while ($rs = $stmt->fetch()) { $node = $xml->addChild('row'); $name = $node->addChild('field', $rs['name']); $name->addAttribute('name', 'name'); $translation = $node->addChild('field', htmlspecialchars($rs['translation'])); $translation->addAttribute('name', 'translation'); } header('Content-type: text/xml; charset=utf-8'); header('Content-disposition: attachment; filename=pl_PL.xml'); header('Content-type: text/xml'); header('Cache-Control: max-age=0'); $doc = new DOMDocument('1.0', 'UTF-8'); $doc->formatOutput = true; $domnode = dom_import_simplexml($xml); $domnode = $doc->importNode($domnode, true); $domnode = $doc->appendChild($domnode); echo $doc->saveXML(); }
public function doAJAXRefreshSeoProducts() { @set_time_limit(0); Db::getInstance()->beginTransaction(); $sql = 'SELECT PT.productid AS id, PT.name AS name FROM producttranslation PT WHERE PT.languageid = :languageid '; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('languageid', Helper::getLanguageId()); $stmt->execute(); while ($rs = $stmt->fetch()) { $seo = $this->doAJAXCreateSeo(array('name' => $rs['name'])); $sql = 'UPDATE producttranslation SET seo = :seo WHERE languageid = :languageid AND productid = :id '; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('seo', $seo['seo']); $stmt->bindValue('languageid', Helper::getLanguageId()); $stmt->bindValue('id', $rs['id']); $stmt->execute(); } Db::getInstance()->commit(); }
public function delete($name) { if (strncmp('session_', $name, 8) === 0) { parent::delete($this->prefix . '_' . strtolower($name)); } foreach (\Gekosale\Helper::getViewIds() as $viewId) { $cacheid = $viewId . '_' . \Gekosale\Helper::getLanguageId(); parent::delete($this->prefix . '_' . strtolower($name) . '_' . $cacheid); } }
public function _populateFieldsContentTypeTextBox(&$populate, $ctValues = array()) { if (isset($ctValues['content']) and is_array($ctValues['content'])) { foreach ($ctValues['content'] as $languageId => $content) { $populate['ct_TextBox']['textbox_content_translation'][$languageId]['textbox_content'] = $content; } } else { $populate['ct_TextBox']['textbox_content_translation'][Helper::getLanguageId()]['textbox_content'] = ''; isset($ctValues['content']) and $populate['ct_TextBox']['textbox_content_translation'][Helper::getLanguageId()]['textbox_content'] = $ctValues['content']; } return $populate; }
public function __construct($registry) { parent::__construct($registry); $this->queryColumns = array(); $this->queryColumnsOptions = array(); $this->queryTable = ''; $this->queryFrom = ''; $this->queryWhere = ''; $this->queryAdditionalWhere = ''; $this->queryGroupBy = ''; $this->encryptionKey = Session::getActiveEncryptionKeyValue(); $this->languageId = Helper::getLanguageId(); $this->sqlParams = array(); $this->viewId = !is_null(Helper::getViewId()) ? Helper::getViewId() : 0; $this->viewIds = Helper::getViewIds(); }
public function getPaymentMethods() { $iddispatchmethod = Session::getActiveDispatchmethodChecked(); $sql = "SELECT \n\t\t\t\t\tPMT.name, \n\t\t\t\t\tPM.idpaymentmethod, \n\t\t\t\t\tPM.controller\n\t\t\t\tFROM paymentmethod PM\n\t\t\t\tLEFT JOIN paymentmethodtranslation PMT ON PMT.paymentmethodid = PM.idpaymentmethod AND PMT.languageid = :languageid\n\t\t\t\tLEFT JOIN paymentmethodview PV ON PV.paymentmethodid = idpaymentmethod\n\t\t\t\tLEFT JOIN dispatchmethodpaymentmethod DMPM ON PM.idpaymentmethod = DMPM.paymentmethodid\n\t\t\t\tLEFT JOIN dispatchmethod DM ON DM.iddispatchmethod = DMPM.dispatchmethodid\n\t\t\t\tWHERE DM.iddispatchmethod = :iddispatchmethod AND PM.active = 1 AND PV.viewid = :viewid\n\t\t\t\tORDER BY PM.hierarchy ASC"; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('viewid', Helper::getViewId()); $stmt->bindValue('languageid', Helper::getLanguageId()); $stmt->bindValue('iddispatchmethod', $iddispatchmethod['dispatchmethodid']); try { $stmt->execute(); $Data = array(); while ($rs = $stmt->fetch()) { $controller = $rs['controller']; $Data[] = array('name' => $rs['name'], 'idpaymentmethod' => $rs['idpaymentmethod']); } } catch (Exception $e) { throw new FrontendException('Error while doing sql query- getPaymentMethods- paymentModel.'); } return $Data; }
public function getLanguages() { if (($Data = $this->registry->cache->load('languages')) === FALSE) { $sql = 'SELECT idlanguage AS id, flag, translation, viewid FROM language L LEFT JOIN languageview LV ON LV.languageid = L.idlanguage'; $Data = array(); $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('viewid', Helper::getViewId()); $stmt->execute(); while ($rs = $stmt->fetch()) { $Data[$rs['id']] = array('id' => $rs['id'], 'flag' => $rs['flag'], 'weight' => $rs['id'], 'icon' => $rs['flag'], 'name' => _($rs['translation']), 'active' => 0); } $this->registry->cache->save('languages', $Data); } $Data[Helper::getLanguageId()]['active'] = 1; return $Data; }
public function edit() { $PopulateData = $this->model->getProductAndAttributesById((int) $this->id); $groupPrice = App::getModel('product')->getProductGroupPrice($this->id, false); $CurrentViewData = array('basic_pane' => array('language_data' => $PopulateData['language'], 'ean' => $PopulateData['ean'], 'enable' => $PopulateData['enable'], 'delivelercode' => $PopulateData['delivelercode'], 'producerid' => $PopulateData['producerid'], 'delivererid' => $PopulateData['delivererid']), 'meta_data' => array('language_data' => $PopulateData['language']), 'category_pane' => array('category' => $PopulateData['category']), 'price_pane' => array('vatid' => $PopulateData['vatid'], 'buyprice' => $PopulateData['buyprice'], 'buycurrencyid' => $PopulateData['buycurrencyid'], 'sellcurrencyid' => $PopulateData['sellcurrencyid'], 'standard_price' => array('sellprice' => $PopulateData['sellprice'], 'promotion' => $PopulateData['promotion'], 'discountprice' => $PopulateData['discountprice'], 'promotionstart' => $PopulateData['promotionstart'], 'promotionend' => $PopulateData['promotionend'])), 'weight_pane' => array('weight' => $PopulateData['weight'], 'width' => $PopulateData['width'], 'height' => $PopulateData['height'], 'deepth' => $PopulateData['deepth'], 'unit' => $PopulateData['unit'], 'packagesize' => $PopulateData['packagesize']), 'stock_pane' => array('stock' => $PopulateData['standardstock'], 'trackstock' => $PopulateData['trackstock'], 'availablityid' => isset($PopulateData['availablityid']) ? $PopulateData['availablityid'] : 0, 'disableatstockenabled' => $PopulateData['disableatstockenabled'], 'disableatstock' => $PopulateData['disableatstock']), 'description_pane' => array('language_data' => $PopulateData['language']), 'crosssell_products' => array('crosssell' => App::getModel('crosssell')->getProductsDataGrid((int) $this->id)), 'upsell_products' => array('upsell' => App::getModel('upsell')->getProductsDataGrid((int) $this->id)), 'similar_products' => array('similar' => App::getModel('similarproduct')->getProductsDataGrid((int) $this->id)), 'photos_pane' => array('photo' => $PopulateData['photo'], 'mainphotoid' => $PopulateData['mainphotoid']), 'files_pane' => array('file' => $PopulateData['file']), 'warranty_pane' => array('warranty' => $PopulateData['warranty']), 'statusproduct_pane' => array('productstatuses' => $PopulateData['productstatuses'], 'newactive' => $PopulateData['productnew']['newactive'], 'new_data' => array('startnew' => $PopulateData['productnew']['startnew'], 'endnew' => $PopulateData['productnew']['endnew'])), 'variants_pane' => array('variants' => $PopulateData['variants'])); foreach ($groupPrice as $key => $val) { $CurrentViewData['price_pane'][$key] = $val; } $this->formModel->setPopulateData($CurrentViewData); $form = $this->formModel->initForm(); if ($form->Validate(FormEngine\FE::SubmittedData())) { try { $this->model->productUpdateAll($form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT), $this->id); } catch (Exception $e) { $this->registry->template->assign('error', $e->getMessage()); } if (FormEngine\FE::IsAction('continue')) { App::redirect(__ADMINPANE__ . '/product/edit/' . $this->id); } else { App::redirect(__ADMINPANE__ . '/product'); } } $this->renderLayout(array('form' => $form->Render(), 'productName' => isset($PopulateData['language'][Helper::getLanguageId()]['name']) ? $PopulateData['language'][Helper::getLanguageId()]['name'] : $PopulateData['language'][1]['name'], 'productLink' => App::getURLAdress() . Seo::getSeo('productcart') . '/' . (isset($PopulateData['language'][Helper::getLanguageId()]['seo']) ? $PopulateData['language'][Helper::getLanguageId()]['seo'] : $PopulateData['language'][1]['seo']))); }
public function getPaymentToCondition($idpaymentmethod) { $paymentname = ''; $sql = "SELECT \n\t\t\t\t\tPMT.name as paymentname\n\t\t\t\tFROM paymentmethodtranslation PMT\n\t\t\t\tWHERE PMT.paymentmethodid = :idpaymentmethod AND PMT.languageid = :languageid"; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('idpaymentmethod', $idpaymentmethod); $stmt->bindValue('languageid', Helper::getLanguageId()); try { $stmt->execute(); $rs = $stmt->fetch(); if ($rs) { $paymentname = $rs['paymentname']; } } catch (Exception $e) { throw new FrontendException(_('ERR_PAYMENT_CHECK')); } return $paymentname; }
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 \tP.stock,\n\t\t\t\t \tP.weight,\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 \tNC.name as ceneooriginal,\n\t\t\t\t \tCN.categoryid,\n\t\t\t\t \tNC.idceneo,\n\t\t\t\t \tCN.ceneoid,\n\t\t\t\t \tPT.seo,\n\t\t\t\t\tPRT.name AS producername,\n\t\t\t\t\tP.ean,\n\t\t\t\t\tNC.path\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\tINNER JOIN productphoto Photo ON Photo.productid = P.idproduct AND Photo.mainphoto=1\n\t\t\t\tINNER JOIN categoryceneo CN ON CN.categoryid = PC.categoryid\n\t\t\t\tINNER JOIN ceneo NC ON NC.idorginal = CN.ceneoid\n\t\t\t\tLEFT JOIN producertranslation PRT ON PRT.producerid = P.producerid AND PRT.languageid = :languageid\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', $this->registry->session->getActiveCurrencyId()); $rs = $stmt->execute(); $Data = array(); while ($rs = $stmt->fetch()) { $Data[] = array('categoryid' => $rs['id'], 'producername' => $rs['producername'], 'ean' => $rs['ean'], 'productid' => $rs['idproduct'], 'stock' => $rs['stock'], 'avail' => $rs['stock'] > 0 ? 1 : 7, 'weight' => $rs['weight'], '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'], 'ceneo' => str_replace('|', '\\', $rs['path'])); } foreach ($Data as $key => $Product) { $Image = App::getModel('gallery')->getOrginalImageById($Product['photoid']); $Data[$key]['photo'] = App::getModel('gallery')->getImagePath($Image, App::getURLAdress()); } return $Data; }
public function getProductIdBySeo($seo) { $sql = "SELECT productid FROM producttranslation WHERE seo =:seo AND languageid = :languageid"; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('languageid', Helper::getLanguageId()); $stmt->bindValue('seo', $seo); try { $stmt->execute(); $rs = $stmt->fetch(); if ($rs) { return $rs['productid']; } } catch (Exception $e) { throw new FrontendException($e->getMessage()); } }
public function duplicate() { $tree = new FormEngine\Elements\Form(array('name' => 'category_tree', 'class' => 'category-select', 'action' => '', 'method' => 'post')); $categories = $this->model->getChildCategories(0, array($this->id)); $tree->AddChild(new FormEngine\Elements\Tree(array('name' => 'categories', 'label' => _('TXT_CATEGORIES'), 'add_item_prompt' => _('TXT_ENTER_NEW_CATEGORY_NAME'), 'sortable' => true, 'selectable' => false, 'clickable' => true, 'deletable' => true, 'addable' => true, 'prevent_duplicates' => true, 'items' => $categories, 'load_children' => array($this->model, 'getChildCategories'), 'onClick' => 'openCategoryEditor', 'onDuplicate' => 'openCategoryEditorDuplicate', 'onSaveOrder' => 'xajax_ChangeCategoryOrder', 'onAdd' => 'xajax_AddCategory', 'onAfterAdd' => 'openCategoryEditor', 'onDelete' => 'xajax_DeleteCategory', 'onAfterDelete' => 'openCategoryEditor', 'active' => $this->id))); $rawCategoryData = $this->model->getCategoryView($this->id); $populateData = array('required_data' => array('language_data' => $rawCategoryData['language'], 'categoryid' => $rawCategoryData['catid'], 'distinction' => $rawCategoryData['distinction'], 'enable' => $rawCategoryData['enable']), 'meta_data' => array('language_data' => $rawCategoryData['language']), 'description_pane' => array('language_data' => $rawCategoryData['language']), 'photos_pane' => array('photo' => $rawCategoryData['photoid']), 'category_products' => array('products' => App::getModel('category')->getProductsDataGrid((int) $this->id)), 'view_data' => array('view' => $rawCategoryData['view'])); $this->formModel->setPopulateData($populateData); $form = $this->formModel->initForm(); if ($form->Validate(FormEngine\FE::SubmittedData())) { try { $formData = $form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT); $this->model->duplicateCategory($formData); } catch (Exception $e) { $this->registry->template->assign('error', $e->getMessage()); } App::redirect(__ADMINPANE__ . '/category'); } $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript()); $this->registry->xajax->processRequest(); $this->registry->template->assign('id', $this->id); $this->registry->template->assign('tree', $tree->Render()); $this->registry->template->assign('form', $form->Render()); $this->registry->template->assign('total', count($categories)); $this->registry->template->assign('categoryName', $rawCategoryData['language'][Helper::getLanguageId()]['name']); $this->registry->template->display($this->loadTemplate('duplicate.tpl')); }
public function getDispatchmethodPriceForProduct($globalprice, $globalweight) { $Data = array(); $sql = "SELECT \n\t\t\t\t\tDP.dispatchmethodid,\n\t\t\t\t\tDP.`from`, \n\t\t\t\t\tDP.`to`, \n\t\t\t\t\tV.value, \n\t\t\t\t\tDP.iddispatchmethodprice,\n\t\t\t\t\tIF(DP.vat IS NOT NULL, ROUND(DP.dispatchmethodcost + (DP.dispatchmethodcost * (V.`value`/100)), 4), DP.dispatchmethodcost) * CR.exchangerate as dispatchmethodcost,\n\t\t\t\t\tCASE\n \t\t\t\t\t\tWHEN (`from` <> 0 AND `from` < :globalprice AND `to`= 0 AND DP.dispatchmethodcost = 0) THEN DMT.name\n \t\t\t\t\t \tWHEN (:globalprice BETWEEN `from` AND `to`) THEN DMT.name\n \t\t\t\t\t\tWHEN (`to` = 0 AND `from` < :globalprice AND DP.dispatchmethodcost <> 0) THEN DMT.name\n \t\t\t\t\t\tWHEN (`from` = 0 AND `to`=0 AND DP.dispatchmethodcost =0) THEN DMT.name\n\t\t\t\t\tEND as name\n\t\t\t\tFROM dispatchmethodprice DP\n\t\t\t\tLEFT JOIN dispatchmethod D ON D.iddispatchmethod = dispatchmethodid\n LEFT JOIN dispatchmethodtranslation DMT ON DMT.dispatchmethodid = D.iddispatchmethod AND DMT.languageid = :languageid\n\t\t\t\tLEFT JOIN vat V ON V.idvat = DP.vat\n\t\t\t\tLEFT JOIN dispatchmethodview DV ON DV.dispatchmethodid = D.iddispatchmethod\n\t\t\t\tLEFT JOIN currencyrates CR ON CR.currencyfrom = D.currencyid AND CR.currencyto = :currencyto\n\t\t\t\tWHERE DV.viewid= :viewid AND IF(D.maximumweight IS NOT NULL, D.maximumweight >= :globalweight, 1) AND D.type = 1\n\t\t\t\tORDER BY D.hierarchy ASC"; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('languageid', Helper::getLanguageId()); $stmt->bindValue('globalprice', $globalprice); $stmt->bindValue('globalweight', $globalweight); $stmt->bindValue('viewid', Helper::getViewId()); $stmt->bindValue('currencyto', Session::getActiveCurrencyId()); $stmt->execute(); while ($rs = $stmt->fetch()) { $dispatchmethodid = $rs['dispatchmethodid']; if ($rs['name'] != NULL) { $dispatchmethodcost = $rs['dispatchmethodcost']; $Data[] = array('dispatchmethodid' => $dispatchmethodid, 'name' => _($rs['name']), 'from' => $rs['from'], 'to' => $rs['to'], 'vatvalue' => $rs['value'], 'dispatchmethodcost' => $this->priceFormatParser($dispatchmethodcost)); } } $sql = "SELECT\n\t\t\t\t\tDW.dispatchmethodid, \n\t\t\t\t\tDW.`from`, \n\t\t\t\t\tDW.`to`, \n\t\t\t\t\tV.value, \n\t\t\t\t\tDW.iddispatchmethodweight,\n\t\t\t\t\tIF(DW.vat IS NOT NULL, ROUND(DW.cost+(DW.cost*(V.`value`/100)),4), DW.cost) * CR.exchangerate as dispatchmethodcost, \n\t\t\t\t\tD.freedelivery,\n\t\t\t\t\tCASE\n \t\t\t\t\t\tWHEN (`from`<>0 AND `from`<:globalweight AND `to`=0 AND DW.cost =0) THEN DMT.name\n \t\t\t\t\t \tWHEN (:globalweight BETWEEN `from` AND `to`) THEN DMT.name\n \t\t\t\t\t\tWHEN (`to` = 0 AND `from`<:globalweight AND DW.cost <> 0) THEN DMT.name\n \t\t\t\t\t\tWHEN (`from`=0 AND `to`=0 AND DW.cost = 0) THEN DMT.name\n\t\t\t\t\tEND as name\n\t\t\t\tFROM dispatchmethodweight DW\n\t\t\t\tLEFT JOIN vat V ON V.idvat = DW.vat\n\t\t\t\tLEFT JOIN dispatchmethod D ON D.iddispatchmethod = DW.dispatchmethodid\n LEFT JOIN dispatchmethodtranslation DMT ON DMT.dispatchmethodid = D.iddispatchmethod AND DMT.languageid = :languageid\n\t\t\t\tLEFT JOIN dispatchmethodview DV ON DV.dispatchmethodid = D.iddispatchmethod\n\t\t\t\tLEFT JOIN currencyrates CR ON CR.currencyfrom = D.currencyid AND CR.currencyto = :currencyto\n\t\t\t\tWHERE DV.viewid= :viewid AND D.type = 2\n\t\t\t\tORDER BY D.hierarchy ASC"; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('languageid', Helper::getLanguageId()); $stmt->bindValue('globalprice', $globalprice); $stmt->bindValue('globalweight', $globalweight); $stmt->bindValue('viewid', Helper::getViewId()); $stmt->bindValue('currencyto', Session::getActiveCurrencyId()); $stmt->execute(); while ($rs = $stmt->fetch()) { $dispatchmethodid = $rs['dispatchmethodid']; if ($rs['name'] != NULL) { if ($rs['freedelivery'] > 0 && $rs['freedelivery'] <= $globalprice) { $dispatchmethodcost = 0.0; } else { $dispatchmethodcost = $rs['dispatchmethodcost']; } $Data[] = array('dispatchmethodid' => $dispatchmethodid, 'name' => _($rs['name']), 'from' => $rs['from'], 'to' => $rs['to'], 'vatvalue' => $rs['value'], 'dispatchmethodcost' => $this->priceFormatParser($dispatchmethodcost)); } } return $Data; }
public function view() { $name = App::getModel('product')->getProductTranslation((int) $this->registry->core->getParam()); $this->renderLayout(array('id' => $this->id, 'name' => isset($name[Helper::getLanguageId()]['name']) ? $name[Helper::getLanguageId()]['name'] : '')); }
public function getAllCartRules() { $rules = array(); $sql = "SELECT \n\t\t\t\t\tRC.idrulescart,\n\t\t\t\t\tRCT.name,\n\t\t\t\t\tRCT.description\n\t\t\t\tFROM rulescart RC\n\t\t\t\tLEFT JOIN rulescarttranslation RCT ON RCT.rulescartid = RC.idrulescart AND RCT.languageid = :languageid\n\t\t\t\tLEFT JOIN rulescartview RCV ON RCV.rulescartid = RC.idrulescart\n\t\t\t\tWHERE RCV.viewid= :viewid\n\t\t\t\tAND IF(RC.datefrom IS NOT NULL, (CAST(RC.datefrom AS DATE) <= curdate()), 1)\n\t\t\t\tAND IF(RC.dateto IS NOT NULL, (CAST(RC.dateto AS DATE) >= curdate()),1)"; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('languageid', Helper::getLanguageId()); $stmt->bindValue('viewid', Helper::getViewId()); try { $stmt->execute(); while ($rs = $stmt->fetch()) { $rules[] = array('idrulescart' => $rs['idrulescart'], 'name' => $rs['name'], 'description' => $rs['description']); } } catch (Exception $e) { throw new FrontendException(_('ERR_RULES_CART_SELECT')); } return $rules; }
public function getParentCategories($parentCategory = 0) { $sql = 'SELECT C.idcategory AS id, C.distinction, CT.name AS categoryname FROM category C LEFT JOIN categorytranslation CT ON CT.categoryid = C.idcategory AND CT.languageid = :languageid LEFT JOIN viewcategory VC ON VC.categoryid = C.idcategory WHERE C.categoryid IS NULL '; if (Helper::getViewId() > 0) { $sql .= ' AND VC.viewid IN (' . implode(',', Helper::getViewIds()) . ') '; } $sql .= 'GROUP BY C.idcategory ORDER BY C.distinction ASC'; $Data = array(); $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('languageid', Helper::getLanguageId()); $stmt->execute(); $Data = array(); while ($rs = $stmt->fetch()) { $Data[$rs['id']] = array('id' => $rs['id'], 'name' => $rs['categoryname'], 'hasChildren' => false, 'parent' => null, 'weight' => $rs['distinction']); } return $Data; }
public function addEmptyUnitMeasure($request) { $sql = 'SELECT unitmeasureid FROM unitmeasuretranslation WHERE name = :name AND languageid = :languageid'; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('name', $request['name']); $stmt->bindValue('languageid', Helper::getLanguageId()); $stmt->execute(); $rs = $stmt->fetch(); if ($rs) { $id = $rs['producerid']; } else { $sql = 'INSERT INTO unitmeasure (adddate) VALUES (NOW())'; $stmt = Db::getInstance()->prepare($sql); try { $stmt->execute(); } catch (Exception $e) { throw new CoreException(_('ERR_UNIT_MEASURE_ADD'), 11, $e->getMessage()); } $id = Db::getInstance()->lastInsertId(); $sql = 'INSERT INTO unitmeasuretranslation (unitmeasureid, name, languageid) VALUES (:unitmeasureid, :name, :languageid)'; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('unitmeasureid', $id); $stmt->bindValue('name', $request['name']); $stmt->bindValue('languageid', Helper::getLanguageId()); try { $stmt->execute(); } catch (Exception $e) { throw new CoreException(_('ERR_UNIT_MEASURE_ADD'), 11, $e->getMessage()); } } return array('id' => $id, 'options' => $this->getUnitMeasureAsExchangeOptions()); }
public function saveBoxes($Data, $id) { $this->boxMapping = array(); foreach ($Data as $oldBoxId => $boxData) { $sql = 'INSERT INTO layoutbox (name, pageschemeid, controller) VALUES (:name, :pageschemeid,:controller)'; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('name', $boxData['name']); $stmt->bindValue('controller', $boxData['controller']); $stmt->bindValue('pageschemeid', $id); $stmt->execute(); $layoutboxid = Db::getInstance()->lastInsertId(); $this->boxMapping[$oldBoxId] = $layoutboxid; $sql = 'INSERT INTO layoutboxtranslation (layoutboxid, languageid, title) VALUES (:layoutboxid, :languageid, :title)'; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('layoutboxid', $layoutboxid); $stmt->bindValue('languageid', Helper::getLanguageId()); $stmt->bindValue('title', $boxData['title'] == NULL ? $boxData['name'] : $boxData['title']); $stmt->execute(); foreach ($boxData['params'] as $variable => $values) { $sql = 'INSERT INTO layoutboxcontentspecificvalue (layoutboxid, variable, value, languageid) VALUES (:id,:variable,:value, :languageid)'; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('id', $layoutboxid); $stmt->bindValue('variable', $variable); if ((int) $values['languageid'] > 0) { $stmt->bindValue('languageid', (int) $values['languageid']); } else { $stmt->bindValue('languageid', NULL); } $stmt->bindValue('value', $values['value']); $stmt->execute(); } foreach ($boxData['behaviour'] as $variable => $value) { $sql = 'INSERT INTO layoutboxjsvalue (layoutboxid, variable, value) VALUES (:layoutboxid, :variable, :value)'; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('layoutboxid', $layoutboxid); $stmt->bindValue('variable', $variable); $stmt->bindValue('value', $value); $stmt->execute(); } } }
public function getChildCategories($parentCategory = 0) { $Data = array(); $sql = 'SELECT C.idcategory AS id, C.distinction, C.categoryid AS parent, CT.name AS categoryname, (SELECT COUNT( idcategory ) FROM category WHERE categoryid = C.idcategory ) AS haschildren FROM category C LEFT JOIN categorytranslation CT ON CT.categoryid = C.idcategory AND CT.languageid = :languageid WHERE C.categoryid ' . ((int) $parentCategory == 0 ? 'IS NULL' : ' = ' . $parentCategory) . ' GROUP BY C.idcategory ORDER BY C.distinction ASC '; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('languageid', Helper::getLanguageId()); $stmt->execute(); $Data = array(); while ($rs = $stmt->fetch()) { $Data[$rs['id']] = array('id' => $rs['id'], 'name' => $rs['categoryname'], 'hasChildren' => $rs['haschildren'] > 0 ? true : false, 'parent' => $rs['parent'] == 0 ? NULL : $rs['parent'], 'weight' => $rs['distinction']); } return $Data; }
public function getCacheFileName($name) { $cacheid = \Gekosale\Helper::getViewId() . '_' . \Gekosale\Helper::getLanguageId(); return $this->path . strtolower($name) . '_' . $cacheid . $this->suffix; }