/** * Return day count orders * * @param $post_data : sent parameters * @return array with info data */ function getCountOrder(&$post_data) { $reponse = array(); $post_message = Tools::jsonDecode(NetReviewsModel::acDecodeBase64($post_data['message']), true); $sql_id_shop = ''; $sql_iso_lang = ''; $ids_lang = array(); if (!empty($post_message['id_shop'])) { if (Configuration::get('AV_MULTILINGUE', null, null, $post_message['id_shop']) == 'checked') { $sql_id_shop .= ' and id_shop = ' . (int) $post_message['id_shop']; $sql = 'SELECT name FROM ' . _DB_PREFIX_ . "configuration\n where value = '" . pSQL($post_message['idWebsite']) . "'\n and name like 'AV_IDWEBSITE_%'\n and id_shop = " . (int) $post_message['id_shop']; if ($row = Db::getInstance()->getRow($sql)) { $group_name = '_' . Tools::substr($row['name'], 13); } $av_group_conf = unserialize(Configuration::get('AV_GROUP_CONF' . $group_name, null, null, $post_message['id_shop'])); $o_lang = new Language(); foreach ($av_group_conf as $isolang) { $ids_lang[] = $o_lang->getIdByIso(Tools::strtolower($isolang)); } $sql_iso_lang .= ' and id_lang in ("' . implode('","', $ids_lang) . '")'; } else { $sql_id_shop .= ' and id_shop = ' . (int) $post_message['id_shop']; } } else { if (Configuration::get('AV_MULTILINGUE') == 'checked') { $sql = 'SELECT name FROM ' . _DB_PREFIX_ . "configuration\n where value = '" . pSQL($post_message['idWebsite']) . "'\n and name like 'AV_IDWEBSITE_%'\n and id_shop is null "; if ($row = Db::getInstance()->getRow($sql)) { $group_name = '_' . Tools::substr($row['name'], 13); } $av_group_conf = unserialize(Configuration::get('AV_GROUP_CONF' . $group_name)); $o_lang = new Language(); foreach ($av_group_conf as $isolang) { $ids_lang[] = $o_lang->getIdByIso(Tools::strtolower($isolang)); } $sql_iso_lang .= ' and id_lang in ("' . implode('","', $ids_lang) . '")'; } } $sql = 'SELECT COUNT( * ) FROM ' . _DB_PREFIX_ . 'orders WHERE ( date_add BETWEEN DATE_SUB( NOW( ) , INTERVAL 1 DAY ) AND NOW( ) )' . $sql_iso_lang . $sql_id_shop; $reponse['message']['count_orders_day'] = Db::getInstance()->getValue($sql); $reponse['return'] = 1; if (!empty($post_message['id_shop'])) { if (Configuration::get('AV_MULTILINGUE', null, null, $post_message['id_shop']) == 'checked') { $sql = 'SELECT name FROM ' . _DB_PREFIX_ . "configuration\n where value = '" . pSQL($post_message['idWebsite']) . "'\n and name like 'AV_IDWEBSITE_%'\n and id_shop = " . (int) $post_message['id_shop']; if ($row = Db::getInstance()->getRow($sql)) { $group_name = '_' . Tools::substr($row['name'], 13); } $reponse['sign'] = SHA1($post_message['query'] . Configuration::get('AV_IDWEBSITE' . $group_name, null, null, $post_message['id_shop']) . Configuration::get('AV_CLESECRETE' . $group_name, null, null, $post_message['id_shop'])); } else { $reponse['sign'] = SHA1($post_data['query'] . Configuration::get('AV_IDWEBSITE', null, null, $post_message['id_shop']) . Configuration::get('AV_CLESECRETE', null, null, $post_message['id_shop'])); } } else { if (Configuration::get('AV_MULTILINGUE') == 'checked') { $sql = 'SELECT name FROM ' . _DB_PREFIX_ . "configuration\n where value = '" . pSQL($post_message['idWebsite']) . "'\n and name like 'AV_IDWEBSITE_%'\n and id_shop is null "; if ($row = Db::getInstance()->getRow($sql)) { $group_name = '_' . Tools::substr($row['name'], 13); } $reponse['sign'] = SHA1($post_data['query'] . Configuration::get('AV_IDWEBSITE' . $group_name) . Configuration::get('AV_CLESECRETE' . $group_name)); } else { $reponse['sign'] = SHA1($post_data['query'] . Configuration::get('AV_IDWEBSITE') . Configuration::get('AV_CLESECRETE')); } } return $reponse; }
public function hookProductTabContent() { if (Configuration::get('AV_MULTILINGUE') == 'checked') { $this->id_lang = $this->context->language->id; $this->iso_lang = pSQL(Language::getIsoById($this->id_lang)); $this->this->group_name = $this->getIdConfigurationGroup($this->iso_lang); } if (version_compare(_PS_VERSION_, '1.5', '<')) { $display_prod_reviews = Configuration::get('AV_DISPLAYPRODREVIEWS' . $this->group_name); $url_certificat = Configuration::get('AV_URLCERTIFICAT' . $this->group_name); } else { $display_prod_reviews = configuration::get('AV_DISPLAYPRODREVIEWS' . $this->group_name, null, null, $this->context->shop->getContextShopID()); $url_certificat = Configuration::get('AV_URLCERTIFICAT' . $this->group_name, null, null, $this->context->shop->getContextShopID()); } $shop_name = Configuration::get('PS_SHOP_NAME'); $id_product = (int) Tools::getValue('id_product'); $o_av = new NetReviewsModel(); $stats_product = !isset($this->stats_product) || empty($this->stats_product) ? $o_av->getStatsProduct($id_product, $this->group_name, $this->context->shop->getContextShopID()) : $this->stats_product; if ($stats_product['nb_reviews'] < 1 || $display_prod_reviews != 'yes') { return ''; } /* if no reviews, return empty */ $reviews = $o_av->getProductReviews($id_product, $this->group_name, $this->context->shop->getContextShopID(), false, 0); $reviews_list = array(); //Create array with all reviews data $my_review = array(); //Create array with each reviews data foreach ($reviews as $review) { //Create variable for template engine $my_review['ref_produit'] = $review['ref_product']; $my_review['id_product_av'] = $review['id_product_av']; $my_review['rate'] = $review['rate']; $my_review['avis'] = urldecode($review['review']); $my_review['horodate'] = date('d/m/Y', $review['horodate']); $my_review['customer_name'] = urldecode($review['customer_name']); $my_review['discussion'] = ''; $unserialized_discussion = Tools::jsonDecode(NetReviewsModel::acDecodeBase64($review['discussion']), true); if ($unserialized_discussion) { foreach ($unserialized_discussion as $k_discussion => $each_discussion) { $my_review['discussion'][$k_discussion]['commentaire'] = $each_discussion['commentaire']; $my_review['discussion'][$k_discussion]['horodate'] = date('d/m/Y', time($each_discussion['horodate'])); if ($each_discussion['origine'] == 'ecommercant') { $my_review['discussion'][$k_discussion]['origine'] = $shop_name; } elseif ($each_discussion['origine'] == 'internaute') { $my_review['discussion'][$k_discussion]['origine'] = $my_review['customer_name']; } else { $my_review['discussion'][$k_discussion]['origine'] = $this->l('Moderator'); } } } array_push($reviews_list, $my_review); } if (version_compare(_PS_VERSION_, '1.5', '<')) { $controller = new FrontController(); $this->context->controller = $controller; } $this->context->controller->pagination((int) $stats_product['nb_reviews']); $this->context->smarty->assign(array('current_url' => $_SERVER['REQUEST_URI'], 'id_shop' => $this->context->shop->getContextShopID(), 'nom_group' => !empty($this->group_name) ? "'" . $this->group_name . "'" : null, 'reviews' => $reviews_list, 'count_reviews' => $stats_product['nb_reviews'], 'average_rate' => round($stats_product['rate'], 1), 'average_rate_percent' => $stats_product['rate'] * 20, 'is_https' => array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == 'on' ? 1 : 0, 'url_certificat' => $url_certificat)); if (version_compare(_PS_VERSION_, '1.5', '<')) { return $this->display(__FILE__, '/views/templates/hook/avisverifies-tab-content.tpl'); } else { return $this->display(__FILE__, 'avisverifies-tab-content.tpl'); } }