public function getContent() { $out = ''; $me = $this->doorGets->user; // get Content for edit / delete $params = $this->doorGets->Params(); if (array_key_exists('id', $params['GET'])) { $id = $params['GET']['id']; $isContent = $this->doorGets->dbQS($id, '_promotion'); if (!empty($isContent)) { $isContent['categories'] = @unserialize($isContent['categories']); // $isCheckedDefault = ($isContent['is_default'] === '1') ? 'checked': ''; } } $storeMenuFile = 'user/user_store_menu'; $tplStoreMenu = Template::getView($storeMenuFile); ob_start(); if (is_file($tplStoreMenu)) { include $tplStoreMenu; } $storeMenuHtml = ob_get_clean(); $aActivation = $this->doorGets->getArrayForms('yn'); $currencyCode = $this->doorGets->configWeb['currency']; $currencyIcon = Constant::$currencyIcon[$currencyCode]; $aPriority = range(0, 10); $aPercent = range(0, 100); $aStockmin = range(0, 100); $aType = array('percent' => $this->doorGets->__("Pourcentage") . ' %', 'amount' => $this->doorGets->__("Montant") . ' ' . $currencyIcon); switch ($this->Action) { case 'index': $PromotionQuery = new PromotionQuery($this->doorGets); $PromotionQuery->orderByPriority(); $PromotionQuery->find(); $Promotions = $PromotionQuery->_getEntities('array'); break; case 'add': $shopModules = $this->doorGets->loadModules(true, true, 'shop'); $categories = array(); if (!empty($shopModules)) { foreach ($shopModules as $module) { $this->doorGets->loadCategories($module['uri']); $categories[$module['id']] = $this->doorGets->categorieSimple__; unset($categories[$module['id']][0]); } } break; case 'edit': $shopModules = $this->doorGets->loadModules(true, true, 'shop'); $categories = array(); if (!empty($shopModules)) { foreach ($shopModules as $module) { $this->doorGets->loadCategories($module['uri']); $categories[$module['id']] = $this->doorGets->categorieSimple__; unset($categories[$module['id']][0]); } } break; case 'delete': break; } $ActionFile = 'user/promotion/user_promotion_' . $this->Action; $tpl = Template::getView($ActionFile); ob_start(); if (is_file($tpl)) { include $tpl; } $out .= ob_get_clean(); return $out; }
public function getAllActivePromotions() { $out = array(); $PromotionQuery = new PromotionQuery($this->doorGets); $PromotionQuery->filterByActive(1); $PromotionQuery->orderByPriority(); $PromotionQuery->find(); $Promotions = $PromotionQuery->_getEntities('array'); $now = time(); if (!empty($Promotions)) { foreach ($Promotions as $promotion) { if ((!empty($promotion['date_from_time']) && $now > (int) $promotion['date_from_time'] || empty($promotion['date_from_time'])) && (empty($promotion['date_to_time']) || $now < (int) $promotion['date_to_time'])) { $out[$promotion['id']] = $promotion; } } } return $out; }