/** * 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; }
// Get product $product = $h_oledrion_products->get($product_id); $product_price = $product->getVar('product_price'); if ($h_oledrion_attributes->getProductAttributesCount($product->getVar('product_id')) > 0) { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('attribute_product_id', $product->getVar('product_id'))); $attribute = $h_oledrion_attributes->getObjects($criteria, false); foreach ($attribute as $root) { $product_price = $root->getVar('attribute_default_value'); } } if ($product->getVar('product_online') && $product->getVar('product_stock') > 0) { // Set parameter $password = md5(xoops_makepass()); $passwordCancel = md5(xoops_makepass()); $uid = oledrion_utils::getCurrentUserID(); $cmd_total = $product_price; $cmd_shipping = 0; // Save command $commande = $h_oledrion_commands->create(true); $commande->setVar('cmd_uid', $uid); $commande->setVar('cmd_date', date("Y-m-d")); $commande->setVar('cmd_create', time()); $commande->setVar('cmd_state', OLEDRION_STATE_NOINFORMATION); $commande->setVar('cmd_ip', oledrion_utils::IP()); $commande->setVar('cmd_lastname', $cmd_lastname); $commande->setVar('cmd_firstname', $cmd_firstname); $commande->setVar('cmd_adress', $cmd_adress); $commande->setVar('cmd_zip', $cmd_zip); $commande->setVar('cmd_town', $cmd_town); $commande->setVar('cmd_country', $cmd_country);
/** * Indique si un produit a déajà été acheté par un utilisateur * * @param integer $uid Identifiant de l'utilisateur * @param integer $productId Identifiant du produit * @return boolean Indique si c'est le cas ou pas */ public function productAlreadyBought($uid = 0, $productId = 0) { if ($uid == 0) { $uid = oledrion_utils::getCurrentUserID(); } $sql = 'SELECT Count(*) as cpt FROM ' . $this->db->prefix('oledrion_caddy') . ' c, ' . $this->db->prefix('oledrion_commands') . ' f WHERE c.caddy_product_id = ' . intval($productId) . ' AND c.caddy_cmd_id = f.cmd_id AND f.cmd_uid = ' . intval($uid); $result = $this->db->query($sql); if (!$result) { return 0; } list($count) = $this->db->fetchRow($result); if ($count > 0) { return true; } else { return false; } }
/** * Retourne les produits d'un utilisateur * * @param integer $persistent_uid L'ID de l'utilisateur * @return array Tableaux d'objets de type oledrion_persistent_cart */ public function getUserProducts($persistent_uid = 0) { if (oledrion_utils::getModuleOption('persistent_cart') == 0) { return false; } $persistent_uid = $persistent_uid == 0 ? oledrion_utils::getCurrentUserID() : $persistent_uid; $criteria = new Criteria('persistent_uid', $persistent_uid, '='); return $this->getObjects($criteria); }
/** * Indique si un produit est dans une liste d'un utilisateur * * @param integer $productlist_product_id * @param integer $list_uid * @return boolean */ public function isProductInUserList($productlist_product_id, $list_uid = 0) { //require_once 'lite.php'; if ($list_uid == 0) { $list_uid = oledrion_utils::getCurrentUserID(); } if ($list_uid == 0) { return true; } $ret = false; $start = $limit = 0; $list_uid = intval($list_uid); $productlist_product_id = intval($productlist_product_id); $sql = 'SELECT Count(*) FROM ' . $this->table . ' l, ' . $this->db->prefix('oledrion_products_list') . ' p WHERE (p.productlist_list_id = l.list_id) AND (l.list_uid = ' . $list_uid . ') AND (p.productlist_product_id =' . $productlist_product_id . ')'; //$Cache_Lite = new oledrion_Cache_Lite($this->cacheOptions); $id = $this->_getIdForCache($sql, $start, $limit); //$cacheData = $Cache_Lite->get($id); //if ($cacheData === false) { $result = $this->db->query($sql, $limit, $start); if ($result) { list($count) = $this->db->fetchRow($result); if ($count > 0) { $ret = true; } } //$Cache_Lite->save($ret); return $ret; //} else { //return $cacheData; //} }
/** * Recalcul du prix HT du produit en appliquant les réductions, s'il y a lieu * * @param integer $productId Identifiant du produit * @param float $prixHT Prix HT du produit * @param array $discountsDescription Descriptions des réductions appliquées * @param integer $productQty Quantité commandée du produit */ public function applyDiscountOnEachProduct($productId, &$prixHT, &$discountsDescription, $productQty) { global $h_oledrion_commands; $rules = array(); $rules = $this->getRulesOnEachProduct(); // Renvoie des objets Discounts if (count($rules) > 0) { $uid = oledrion_utils::getCurrentUserID(); foreach ($rules as $rule) { switch ($rule->getVar('disc_when')) { case OLEDRION_DISCOUNT_WHEN1: // Dans tous les cas if ($rule->getVar('disc_percent_monney') == OLEDRION_DISCOUNT_TYPE1) { // Réduction de x pourcent $prixHT = $this->getDiscountedPrice($prixHT, $rule->getVar('disc_amount')); if ($prixHT < 0) { $prixHT = 0; } } else { // Réduction de x euros $prixHT -= $rule->getVar('disc_amount'); if ($prixHT < 0) { $prixHT = 0; } } $discountsDescription[] = $rule->getVar('disc_description'); break; case OLEDRION_DISCOUNT_WHEN2: // Si c'est le premier achat de l'utilisateur sur le site if ($h_oledrion_commands->isFirstCommand($uid)) { if ($rule->getVar('disc_percent_monney') == OLEDRION_DISCOUNT_TYPE1) { // Réduction de x pourcent $prixHT = $this->getDiscountedPrice($prixHT, $rule->getVar('disc_amount')); if ($prixHT < 0) { $prixHT = 0; } } else { // Réduction de x euros $prixHT -= $rule->getVar('disc_amount'); if ($prixHT < 0) { $prixHT = 0; } } $discountsDescription[] = $rule->getVar('disc_description'); } break; case OLEDRION_DISCOUNT_WHEN3: // Si le produit n'a jamais été acheté if (!$h_oledrion_commands->productAlreadyBought($uid, $productId)) { if ($rule->getVar('disc_percent_monney') == OLEDRION_DISCOUNT_TYPE1) { // Réduction de x pourcent $prixHT = $this->getDiscountedPrice($prixHT, $rule->getVar('disc_amount')); if ($prixHT < 0) { $prixHT = 0; } } else { // Réduction de x euros $prixHT -= $rule->getVar('disc_amount'); if ($prixHT < 0) { $prixHT = 0; } } $discountsDescription[] = $rule->getVar('disc_description'); } break; case OLEDRION_DISCOUNT_WHEN4: // Si la quantité est =, >, >=, <, <= à ... $qtyDiscount = false; switch ($rule->getVar('disc_qty_criteria')) { case 0: // = if ($productQty == $rule->getVar('disc_qty_value')) { $qtyDiscount = true; } break; case 1: // > if ($productQty > $rule->getVar('disc_qty_value')) { $qtyDiscount = true; } break; case 2: // >= if ($productQty >= $rule->getVar('disc_qty_value')) { $qtyDiscount = true; } break; case 3: // < if ($productQty < $rule->getVar('disc_qty_value')) { $qtyDiscount = true; } break; case 4: // <= if ($productQty <= $rule->getVar('disc_qty_value')) { $qtyDiscount = true; } break; } if ($qtyDiscount) { if ($rule->getVar('disc_percent_monney') == OLEDRION_DISCOUNT_TYPE1) { // Réduction de x pourcent $prixHT = $this->getDiscountedPrice($prixHT, $rule->getVar('disc_amount')); if ($prixHT < 0) { $prixHT = 0; } } else { // Réduction de x euros $prixHT -= $rule->getVar('disc_amount'); if ($prixHT < 0) { $prixHT = 0; } } $discountsDescription[] = $rule->getVar('disc_description'); } break; } } } }
$xoopsTpl->assign('columnsCount', oledrion_utils::getModuleOption('catagory_colums')); $xoopsTpl->assign('list', $list->toArray()); // TVA $vatArray = array(); $vatArray = $h_oledrion_vat->getAllVats(new oledrion_parameters()); // Recherche des produits de la liste $products = $handlers->h_oledrion_lists->getListProducts($list); if (count($products) > 0) { foreach ($products as $product) { $xoopsTpl->append('products', $product->toArray()); } } // Mise à jour du compte de vues $handlers->h_oledrion_lists->incrementListViews($list); // Recherce des autres listes de cet utilisateur if ($handlers->h_oledrion_lists->getRecentListsCount(OLEDRION_LISTS_ALL_PUBLIC, oledrion_utils::getCurrentUserID()) > 1) { $otherUserLists = $handlers->h_oledrion_lists->getRecentLists(new oledrion_parameters(array('start' => 0, 'limit' => 0, 'sort' => 'list_date', 'order' => 'DESC', 'idAsKey' => true, 'listType' => OLEDRION_LISTS_ALL_PUBLIC, 'list_uid' => oledrion_utils::getCurrentUserID()))); if (count($otherUserLists) > 0) { foreach ($otherUserLists as $oneOtherList) { $xoopsTpl->append('otherUserLists', $oneOtherList->toArray()); } } } oledrion_utils::setCSS(); oledrion_utils::setLocalCSS($xoopsConfig['language']); oledrion_utils::loadLanguageFile('modinfo.php'); $breadcrumb = array(OLEDRION_URL . 'all-lists.php' => _MI_OLEDRION_SMNAME11, OLEDRION_URL . basename(__FILE__) => $list->getVar('list_title')); $xoopsTpl->assign('breadcrumb', oledrion_utils::breadcrumb($breadcrumb)); $title = $list->getVar('list_title') . ' - ' . oledrion_utils::getModuleName(); oledrion_utils::setMetas($title, $title, oledrion_utils::createMetaKeywords($list->getVar('list_description', 'n') . ' ' . $list->getVar('list_title', 'n'))); require_once XOOPS_ROOT_PATH . '/footer.php';
oledrion_utils::redirect(_OLEDRION_ERROR2, 'index.php', 5); } // Le produit est il publié ? if (oledrion_utils::getModuleOption('show_unpublished') == 0 && $product->getVar('product_submitted') > time()) { oledrion_utils::redirect(_OLEDRION_ERROR3, 'index.php', 5); } // Faut il afficher les produits même lorsqu'ils ne sont plus en stock ? if (oledrion_utils::getModuleOption('nostock_display') == 0 && $product->getVar('product_stock') == 0) { if (xoops_trim(oledrion_utils::getModuleOption('nostock_display')) != '') { oledrion_utils::redirect(oledrion_utils::getModuleOption('nostock_display'), 'index.php', 5); } } // Fin des tests, si on est encore là c'est que tout est bon ************************************** if (!empty($_POST['btnsubmit'])) { $GLOBALS['current_category'] = -1; $ratinguser = oledrion_utils::getCurrentUserID(); $canRate = true; if ($ratinguser != 0) { if ($h_oledrion_votedata->hasUserAlreadyVoted($ratinguser, $product->getVar('product_id'))) { $canRate = false; } } else { if ($h_oledrion_votedata->hasAnonymousAlreadyVoted('', $product->getVar('product_id'))) { $canRate = false; } } if ($canRate) { if ($_POST['rating'] == '--') { oledrion_utils::redirect(_OLEDRION_NORATING, OLEDRION_URL . 'product.php?product_id=' . $product->getVar('product_id'), 4); } $rating = intval($_POST['rating']);
/** * Indique si un utilisateur a déjà voté pour un produit * * @param integer $vote_uid L'identifiant de l'utilisateur * @param integer $vote_product_id Le numéro du produit * @return boolean True s'il a déjà voté sinon False */ function hasUserAlreadyVoted($vote_uid, $vote_product_id) { if ($vote_uid == 0) { $vote_uid = oledrion_utils::getCurrentUserID(); } $criteria = new CriteriaCompo(); $criteria->add(new Criteria('vote_product_id', $vote_product_id, '=')); $criteria->add(new Criteria('vote_uid', $vote_uid, '=')); $count = $this->getCount($criteria); if ($count > 0) { return true; } else { return false; } }