/** * Retourne l'instance unique de la classe * * @return object */ public static function getInstance() { if (!self::$instance instanceof self) { self::$instance = new self(); } return self::$instance; }
function oledrion_com_update($product_id, $total_num) { include XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php'; global $h_oledrion_products; if (!is_object($h_oledrion_products)) { $handlers = oledrion_handler::getInstance(); $h_oledrion_products = $handlers->oledrion_products; } $h_oledrion_products->updateCommentsCount($product_id, $total_num); }
/** * Affichage des listes au hasard * * @param array $options [0] = Nombre maximum de listes à voir, [1] = Type de listes (0 = les 2, 1 = liste cadeaux, 2 = produits recommandés) * @return array */ function b_oledrion_random_lists_show($options) { require XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php'; oledrion_utils::loadLanguageFile('main.php'); $start = 0; $limit = intval($options[0]); $listType = intval($options[1]); $block = array(); $handlers = oledrion_handler::getInstance(); $items = array(); $items = $handlers->h_oledrion_lists->getRecentLists(new oledrion_parameters(array('start' => $start, 'limit' => $limit, 'sort' => 'RAND()', 'order' => 'DESC', 'idAsKey' => true, 'listType' => $listType))); if (count($items) > 0) { foreach ($items as $item) { $block['random_lists'][] = $item->toArray(); } } return $block; }
/** * Affichage des listes les plus vues * * @param array $options [0] = Nombre maximum de listes à voir, [1] = Type de listes (0 = les 2, 1 = liste cadeaux, 2 = produits recommandés) * @return array */ function b_oledrion_category_lists_show($options) { require XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php'; oledrion_utils::loadLanguageFile('main.php'); $limit = intval($options[0]); $listType = intval($options[1]); $block = array(); if (isset($GLOBALS['current_category']) && intval($GLOBALS['current_category']) > 0) { $handlers = oledrion_handler::getInstance(); $items = array(); $items = $handlers->h_oledrion_lists->listsFromCurrentCategory($GLOBALS['current_category'], $listType, $limit); if (count($items) > 0) { foreach ($items as $item) { $block['category_lists'][] = $item->toArray(); } } } return $block; }
/** * Affiche les listes de l'utilisateur * * @param array $options [0] = Nombre maximum de listes à voir * @return array */ function b_oledrion_my_lists_show($options) { require XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php'; oledrion_utils::loadLanguageFile('modinfo.php'); $start = 0; $limit = intval($options[0]); $uid = oledrion_utils::getCurrentUserID(); if ($uid == 0) { return null; } $listType = OLEDRION_LISTS_ALL; $block = array(); $handlers = oledrion_handler::getInstance(); $items = array(); $items = $handlers->h_oledrion_lists->getRecentLists(new oledrion_parameters(array('start' => $start, 'limit' => $limit, 'sort' => 'list_date', 'order' => 'DESC', 'idAsKey' => true, 'listType' => $listType, 'list_uid' => $uid))); if (count($items) > 0) { foreach ($items as $item) { $block['my_lists'][] = $item->toArray(); } } return $block; }
$op = isset($_POST['op']) ? $_POST['op'] : ''; if ($op == '') { $op = isset($_GET['op']) ? $_GET['op'] : ''; } $return = ''; $uid = oledrion_utils::getCurrentUserID(); $isAdmin = oledrion_utils::isAdmin(); switch ($op) { // **************************************************************************************************************** case 'updatePrice': // Mise à jour du prix du produit en fonction des attributs sélectionnés // **************************************************************************************************************** $product_id = isset($_POST['product_id']) ? intval($_POST['product_id']) : 0; if (isset($_POST['formcontent']) && $product_id > 0) { $data = $data = $attributesIds = $attributes = $templateProduct = array(); $handlers = oledrion_handler::getInstance(); $product = null; $product = $handlers->h_oledrion_products->get($product_id); if (!is_object($product)) { return _OLEDRION_NA; } if (!$product->isProductVisible()) { return _OLEDRION_NA; } $vat_id = $product->getVar('product_vat_id'); if (intval($product->getVar('product_discount_price', '')) != 0) { $productPrice = floatval($product->getVar('product_discount_price', 'e')); } else { $productPrice = floatval($product->getVar('product_price', 'e')); } parse_str(urldecode($_POST['formcontent']), $data);
/** * Retourne tous les produits d'un caddy * * @param array $carts Objets de type oledrion_caddy * @return array Tableau d'objets de type oledrion_products, Clé = Id produit * @since 2.31.2009.07.25 */ function getProductsFromCaddy($carts) { $ret = $productsIds = array(); foreach ($carts as $cart) { $productsIds[] = $cart->getVar('caddy_product_id'); } if (count($productsIds) > 0) { $handlers = oledrion_handler::getInstance(); $ret = $handlers->h_oledrion_products->getProductsFromIDs($productsIds, true); } return $ret; }
/** * Calcul le prix HT des options sélectionnées pour un produit * * @param array $choosenAttributes [clé] = attribute_id, [value] = array(valueId1, valueId2 ...) * @param integer $product_vat_id L'ID de TVA du produit * @param array $descriptions Tableau valorisé par la méthode [clé] = Id attribut [valeur] = array('attribute_title', array('attribute_names', 'attribute_prices')) * @return float * @since 2.3.2009.03.21 */ function getProductOptionsPrice($choosenAttributes, $product_vat_id, &$descriptions = null) { static $vats = array(); if (is_array($vats) && isset($vats[$product_vat_id])) { $vat_rate = $vats[$product_vat_id]; } else { $vat = null; $vat = oledrion_handler::getInstance()->h_oledrion_vat->get($product_vat_id); if (is_object($vat)) { $vats[$product_vat_id] = $vat_rate = $vat->getVar('vat_rate', 'n'); } } $ret = 0; $attributesIds = $attributes = array(); if (!is_array($choosenAttributes) || count($choosenAttributes) == 0) { return $ret; } $attributesIds = array_keys($choosenAttributes); $attributes = $this->getItemsFromIds($attributesIds); if (count($attributes) == 0) { return $ret; } $oledrion_Currency = oledrion_Currency::getInstance(); foreach ($choosenAttributes as $userAttributeId => $userAttributeValues) { if (isset($attributes[$userAttributeId])) { $attribute = $attributes[$userAttributeId]; $dataForDescriptions = array(); $optionDescription = ''; if (is_array($userAttributeValues) && count($userAttributeValues) > 0) { foreach ($userAttributeValues as $option) { $optionName = oledrion_utils::getName($option); $price = $attribute->getOptionPriceFromValue($optionName); $optionDescription = $attribute->getOptionNameFromValue($optionName); $vatAmount = oledrion_utils::getVAT($price, $vat_rate); $ttc = $price + $vatAmount; $vatAmountFormated = $oledrion_Currency->amountForDisplay($vatAmount); $htFormated = $oledrion_Currency->amountForDisplay($price); $ttcFormated = $oledrion_Currency->amountForDisplay($ttc); $dataForDescriptions[] = array('option_name' => $optionDescription, 'option_value' => $optionName, 'option_price' => $price, 'option_vat' => $vatAmount, 'option_ttc' => $ttc, 'option_price_ht_formated' => $htFormated, 'option_vat_formated' => $vatAmountFormated, 'option_ttc_formated' => $ttcFormated); $ret += $price; // Total de toutes les options } } else { $optionName = oledrion_utils::getName($userAttributeValues); $price = $attribute->getOptionPriceFromValue($optionName); $optionDescription = $attribute->getOptionNameFromValue($optionName); $vatAmount = oledrion_utils::getVAT($price, $vat_rate); $ttc = $price + $vatAmount; $vatAmountFormated = $oledrion_Currency->amountForDisplay($vatAmount); $htFormated = $oledrion_Currency->amountForDisplay($price); $ttcFormated = $oledrion_Currency->amountForDisplay($ttc); $dataForDescriptions[] = array('option_name' => $optionDescription, 'option_value' => $optionName, 'option_price' => $price, 'option_vat' => $vatAmount, 'option_ttc' => $ttc, 'option_price_ht_formated' => $htFormated, 'option_vat_formated' => $vatAmountFormated, 'option_ttc_formated' => $ttcFormated); $ret += $price; // Total de toutes les options } if (is_array($descriptions)) { $descriptions[$attribute->getVar('attribute_id')] = array('attribute_title' => $attribute->getVar('attribute_title'), 'attribute_options' => $dataForDescriptions); } } } return $ret; }
private function getHandlers() { $this->handlers = oledrion_handler::getInstance(); }
/** * Supprime une commande et tout ce qui s'y rattache * * @param oledrion_commands $order * @return boolean */ public function removeOrder(oledrion_commands $order) { $handlers = oledrion_handler::getInstance(); $cmd_id = $order->getVar('cmd_id'); $res = $this->delete($order); // Suppression des objets associés // 1) Ses propres caddies $handlers->h_oledrion_caddy->removeCartsFromOrderId($cmd_id); // 2) Les caddies des attributs $handlers->h_oledrion_caddy_attributes->removeCartsFromOrderId($cmd_id); return $res; }
/** * Retourne le montant HT initial des options * * @return float */ public function getInitialOptionsPrice() { return oledrion_handler::getInstance()->h_oledrion_attributes->getInitialOptionsPrice($this); }
/** * Retourne les produits d'une liste * * @param oledrion_lists $list * @return array Objets de type oledrion_products */ public function getListProducts(oledrion_lists $list) { $productsInList = $ret = $productsIds = array(); $handlers = oledrion_handler::getInstance(); $productsInList = $handlers->h_oledrion_products_list->getProductsFromList($list); if (count($productsInList) == 0) { return $ret; } foreach ($productsInList as $product) { $productsIds[] = $product->getVar('productlist_product_id'); } if (count($productsIds) > 0) { $ret = $handlers->h_oledrion_products->getProductsFromIDs($productsIds); } return $ret; }
/** * Retourne le montant TTC * * @param floatval $product_price Le montant du produit * @param integer $vat_id Le numéro de TVA * @return floatval Le montant TTC si on a trouvé sa TVA sinon */ function getAmountWithVat($product_price, $vat_id) { static $vats = array(); $vat_rate = null; if (is_array($vats) && in_array($vat_id, $vats)) { $vat_rate = $vats[$vat_id]; } else { $handlers = oledrion_handler::getInstance(); $vat = null; $vat = $handlers->h_oledrion_vat->get($vat_id); if (is_object($vat)) { $vat_rate = $vat->getVar('vat_rate', 'e'); $vats[$vat_id] = $vat_rate; } } if (!is_null($vat_rate)) { return floatval($product_price) * floatval($vat_rate) / 100 + floatval($product_price); } else { return $product_price; } }
/** * Retourne la liste formatée des attributs liés à un caddy * * @param integer $ca_caddy_id L'identifiant de caddy * @param object $product Le produit concerné par le caddy * @return array * @since 2.3.2009.03.23 */ function getFormatedAttributesForCaddy($ca_caddy_id, oledrion_products $product) { $handlers = oledrion_handler::getInstance(); $attributes = $ret = array(); $attributes = $this->getObjects(new Criteria('ca_caddy_id', $ca_caddy_id, '=')); if (count($attributes) == 0) { return $ret; } foreach ($attributes as $caddyAttribute) { $data = array(); $attribute = null; $attribute = $handlers->h_oledrion_attributes->get($caddyAttribute->getVar('ca_attribute_id')); if (is_object($attribute)) { $data = $attribute->toArray(); } $data['attribute_options'] = $caddyAttribute->renderForInvoice($product); $ret[] = $data; } return $ret; }
$ret['product_thumb_full_url'] = OLEDRION_PICTURES_URL . '/' . $myrow['product_thumb_url']; $ret['product_property1'] = $myrow['product_property1']; $ret['product_property2'] = $myrow['product_property2']; $ret['product_property3'] = $myrow['product_property3']; $ret['product_property4'] = $myrow['product_property4']; $ret['product_property5'] = $myrow['product_property5']; $ret['product_property6'] = $myrow['product_property6']; $ret['product_property7'] = $myrow['product_property7']; $ret['product_property8'] = $myrow['product_property8']; $ret['product_property9'] = $myrow['product_property9']; $ret['product_property10'] = $myrow['product_property10']; $ret['product_price'] = $myrow['product_price']; if ($myrow['product_price'] == 0) { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('attribute_product_id', $myrow['product_id'])); $attribute = oledrion_handler::getInstance()->h_oledrion_attributes->getObjects($criteria, false); foreach ($attribute as $root) { $ret['product_price'] = $root->getVar('attribute_default_value'); } } $ret['product_stock'] = $myrow['product_stock']; $ret['product_price_ttc'] = oledrion_utils::getTTC($ret['product_price'], ''); $ret['product_count'] = $count; $ret['product_summary'] = $myrow['product_summary']; $xoopsTpl->append('products', $ret); $count++; } unset($tempProduct); } else { $xoopsTpl->assign('search_results', false); $xoopsTpl->assign('global_advert', oledrion_utils::getModuleOption('advertisement'));