Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.20 KB | None | 0 0
  1. public function updateViewed($product_id) {
  2. $this->db->query("UPDATE " . DB_PREFIX . "product SET viewed = (viewed + 1) WHERE product_id = '" . (int)$product_id . "'");
  3. }
  4.  
  5. public function getProduct($product_id) {
  6. if ($this->customer->isLogged()) {
  7. $customer_group_id = $this->customer->getCustomerGroupId();
  8. } else {
  9. $customer_group_id = $this->config->get('config_customer_group_id');
  10. }
  11.  
  12. $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$customer_group_id . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$customer_group_id . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT points FROM " . DB_PREFIX . "product_reward pr WHERE pr.product_id = p.product_id AND customer_group_id = '" . (int)$customer_group_id . "') AS reward, (SELECT ss.name FROM " . DB_PREFIX . "stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "') AS stock_status, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
  13.  
  14. if ($query->num_rows) {
  15. $query->row['price'] = ($query->row['discount'] ? $query->row['discount'] : $query->row['price']);
  16. $query->row['rating'] = (int)$query->row['rating'];
  17.  
  18. return $query->row;
  19. } else {
  20. return false;
  21. }
  22. }
  23.  
  24. public function getProduct($product_id) {
  25. if ($this->customer->isLogged()) {
  26. $customer_group_id = $this->customer->getCustomerGroupId();
  27. } else {
  28. $customer_group_id = $this->config->get('config_customer_group_id');
  29. }
  30.  
  31. $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$customer_group_id . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$customer_group_id . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT points FROM " . DB_PREFIX . "product_reward pr WHERE pr.product_id = p.product_id AND customer_group_id = '" . (int)$customer_group_id . "') AS reward, (SELECT ss.name FROM " . DB_PREFIX . "stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "') AS stock_status, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.sort_order, p.date_expires >= NOW(), p.date_expires <= NOW() DESC");
  32.  
  33. public function getProduct($product_id) {
  34. if ($this->customer->isLogged()) {
  35. $customer_group_id = $this->customer->getCustomerGroupId();
  36. } else {
  37. $customer_group_id = $this->config->get('config_customer_group_id');
  38. }
  39.  
  40. $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$customer_group_id . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$customer_group_id . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT date_start FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$customer_group_id . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS date_start, (SELECT date_end FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$customer_group_id . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS date_ends, (SELECT points FROM " . DB_PREFIX . "product_reward pr WHERE pr.product_id = p.product_id AND customer_group_id = '" . (int)$customer_group_id . "') AS reward, (SELECT ss.name FROM " . DB_PREFIX . "stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "') AS stock_status, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.sort_order, p.date_expires >= NOW(), p.date_expires <= NOW() DESC");
  41.  
  42. $this->data['products'][] = array(
  43. 'product_id' => $result['product_id'],
  44. 'thumb' => $image,
  45. 'name' => $result['name'],
  46. 'price' => $price,
  47. 'special' => $special,
  48. 'rating' => $rating,
  49. 'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
  50. 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']),
  51. );
  52.  
  53. $this->data['products'][] = array(
  54. 'product_id' => $result['product_id'],
  55. 'thumb' => $image,
  56. 'name' => $result['name'],
  57. 'price' => $price,
  58. 'special' => $special,
  59. 'rating' => $rating,
  60. 'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
  61. 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']),
  62. 'date_start' => $result['date_start'],
  63. 'date_end' => $result['date_end'],
  64. );
  65.  
  66. <?php if ($products) { ?>
  67. <script type="text/javascript">
  68. jQuery.fn.countdown = function (date, options, dateparse) {
  69. options = jQuery.extend({
  70. lang:{
  71. years: [' year, ', ' years, '],
  72. months: [' month, ', ' months, '],
  73. days: [' day, ', ' days, '],
  74. hours: [':', ':'],
  75. minutes: [':', ':'],
  76. seconds: ['', ''],
  77. plurar: function(n) {
  78. return (n == 1 ? 0 : 1);
  79. }
  80. },
  81. prefix: "end: ",
  82. finish: "End!",
  83. redirect: '',
  84. dateparse: "2050-01-01 00:00:00"
  85. }, options);
  86.  
  87. var timestamp = Date.parse(options.dateparse);
  88.  
  89. var timeDifference = function(begin, end) {
  90. if(end < begin){
  91. return false;
  92. }
  93. var diff = {
  94. seconds: [end.getSeconds() - begin.getSeconds(), 60],
  95. minutes: [end.getMinutes() - begin.getMinutes(), 60],
  96. hours: [end.getHours() - begin.getHours(), 24],
  97. days: [end.getDate() - begin.getDate(), new Date(begin.getYear(), begin.getMonth(), 0).getDate()],
  98. months: [end.getMonth() - begin.getMonth()-1, 12],
  99. years: [end.getYear() - begin.getYear(), 0]
  100. };
  101.  
  102. var result = new Array();
  103. var flag = false;
  104. for(i in diff){
  105. if((i=='seconds' || i=='minutes') && diff[i][0]==0){
  106. result.push('00' + options.lang[i][options.lang.plurar(diff[i][0])]);
  107. }else{
  108. if(flag){
  109. diff[i][0]--;
  110. flag = false;
  111. }
  112. if(diff[i][0] < 0){
  113. flag = true;
  114. diff[i][0] += diff[i][1];
  115. }
  116. if(!diff[i][0]) continue;
  117. if(i=='days' && diff[i][0]<0){
  118. diff['days'][0]=Math.abs(1+diff['days'][0]);
  119. diff['months'][0]++;
  120. }
  121. if(i=='years' && diff[i][0]<0)
  122. return '';
  123. if((i=='seconds' || i=='minutes') && diff[i][0]<10)
  124. diff[i][0] = '0' + diff[i][0];
  125.  
  126. if(diff[i][0]!=0)
  127. result.push(diff[i][0] + '' + options.lang[i][options.lang.plurar(diff[i][0])]);
  128. }
  129. }
  130. return result.reverse().join('');
  131. };
  132.  
  133. var timeCurrent = function(date){
  134. var hou = date.getHours().toString();
  135. var min = date.getMinutes().toString();
  136. var sec = date.getSeconds().toString();
  137. hou = (hou<10)?0+hou:hou;
  138. min = (min<10)?0+min:min;
  139. sec = (sec<10)?0+sec:sec;
  140. return hou+':'+min+':'+sec;
  141. };
  142.  
  143. var elem = $(this);
  144. var timeUpdate = function(){
  145. dateJS = new Date();
  146.  
  147. timestamp = parseInt(timestamp) + 1000;
  148. dateJS.setTime(timestamp);
  149.  
  150. /*if(elem.parents('.timedependent-form-content').find('#currentTime').length)
  151. elem.parents('.timedependent-form-content').find('#currentTime').html(timeCurrent(dateJS));*/
  152. var s = timeDifference(dateJS, date);
  153. if(s.length){
  154. elem.html(options.prefix + s);
  155. }else{
  156. clearInterval(timer);
  157. elem.html(options.finish);
  158. if(options.redirect != '')
  159. window.location.href = options.redirect;
  160. }
  161. };
  162. timeUpdate();
  163. var timer = setInterval(timeUpdate, 1000);
  164. };
  165.  
  166.  
  167. </script>
  168. <?php } ?>
  169.  
  170. <?php foreach ($products as $product) { ?>
  171.  
  172. <?php $now = time();
  173. $count = 0;
  174. foreach ($products as $product) {
  175. $count++; ?>
  176.  
  177. <?php $time_remaining = $result['date_end'];
  178. $countdown = strtotime("$time_remaining"); ?>
  179.  
  180. <div class="timerbar">
  181. <h2 id="product<?php echo $count; ?>"></h2>
  182. </div><br/>
  183. <script>
  184. jQuery("#product<?php echo $count; ?>").countdown(new Date(<?php echo date('Y, m, d, H, i, s',$countdown); ?>), {
  185. prefix:"",
  186. finish:"Expired",
  187. redirect:"",
  188. dateparse:"<?php echo date('d F Y H:i:s',$now); ?>",
  189. lang:{
  190. years: [' year, ', ' years, '],
  191. months: [' month, ', ' months, '],
  192. days: [' day, ', ' days, '],
  193. hours: [':', ':'],
  194. minutes: [':', ':'],
  195. seconds: ['', ''],
  196. plurar: function(n) {
  197. return (n == 1 ? 0 : 1);
  198. }
  199. }});
  200. </script>
  201.  
  202. public function getProduct($product_id) {
  203. if ($this->customer->isLogged()) {
  204. $customer_group_id = $this->customer->getCustomerGroupId();
  205. } else {
  206. $customer_group_id = $this->config->get('config_customer_group_id');
  207. }
  208.  
  209. $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$customer_group_id . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$customer_group_id . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT points FROM " . DB_PREFIX . "product_reward pr WHERE pr.product_id = p.product_id AND customer_group_id = '" . (int)$customer_group_id . "') AS reward, (SELECT ss.name FROM " . DB_PREFIX . "stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "') AS stock_status, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.sort_order, p.date_expires >= NOW(), p.date_expires <= NOW() DESC");
  210.  
  211. public function getProduct($product_id) {
  212. if ($this->customer->isLogged()) {
  213. $customer_group_id = $this->customer->getCustomerGroupId();
  214. } else {
  215. $customer_group_id = $this->config->get('config_customer_group_id');
  216. }
  217.  
  218. $query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$customer_group_id . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$customer_group_id . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT date_start FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$customer_group_id . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS date_start, (SELECT date_end FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$customer_group_id . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS date_ends, (SELECT points FROM " . DB_PREFIX . "product_reward pr WHERE pr.product_id = p.product_id AND customer_group_id = '" . (int)$customer_group_id . "') AS reward, (SELECT ss.name FROM " . DB_PREFIX . "stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "') AS stock_status, (SELECT wcd.unit FROM " . DB_PREFIX . "weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS weight_class, (SELECT lcd.unit FROM " . DB_PREFIX . "length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS length_class, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.sort_order FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.sort_order, p.date_expires >= NOW(), p.date_expires <= NOW() DESC");
  219.  
  220. 'special' => $query->row['special'],
  221.  
  222. 'date_ends' => $query->row['date_ends'],
  223. 'date_start' => $query->row['date_start'],
  224.  
  225. $this->data['products'][] = array(
  226. 'product_id' => $result['product_id'],
  227. 'thumb' => $image,
  228. 'name' => $result['name'],
  229. 'price' => $price,
  230. 'special' => $special,
  231. 'rating' => $rating,
  232. 'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
  233. 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']),
  234. );
  235.  
  236. $this->data['products'][] = array(
  237. 'product_id' => $result['product_id'],
  238. 'thumb' => $image,
  239. 'name' => $result['name'],
  240. 'price' => $price,
  241. 'special' => $special,
  242. 'rating' => $rating,
  243. 'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
  244. 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']),
  245. 'date_start' => $result['date_start'],
  246. 'date_ends' => $result['date_ends'],
  247.  
  248. );
  249.  
  250. <?php if ($products) { ?>
  251. <script type="text/javascript">
  252. jQuery.fn.countdown = function (date, options, dateparse) {
  253. options = jQuery.extend({
  254. lang:{
  255. years: [' year, ', ' years, '],
  256. months: [' month, ', ' months, '],
  257. days: [' day, ', ' days, '],
  258. hours: [':', ':'],
  259. minutes: [':', ':'],
  260. seconds: ['', ''],
  261. plurar: function(n) {
  262. return (n == 1 ? 0 : 1);
  263. }
  264. },
  265. prefix: "end: ",
  266. finish: "End!",
  267. redirect: '',
  268. dateparse: "2050-01-01 00:00:00"
  269. }, options);
  270.  
  271. var timestamp = Date.parse(options.dateparse);
  272.  
  273. var timeDifference = function(begin, end) {
  274. if(end < begin){
  275. return false;
  276. }
  277. var diff = {
  278. seconds: [end.getSeconds() - begin.getSeconds(), 60],
  279. minutes: [end.getMinutes() - begin.getMinutes(), 60],
  280. hours: [end.getHours() - begin.getHours(), 24],
  281. days: [end.getDate() - begin.getDate(), new Date(begin.getYear(), begin.getMonth(), 0).getDate()],
  282. months: [end.getMonth() - begin.getMonth()-1, 12],
  283. years: [end.getYear() - begin.getYear(), 0]
  284. };
  285.  
  286. var result = new Array();
  287. var flag = false;
  288. for(i in diff){
  289. if((i=='seconds' || i=='minutes') && diff[i][0]==0){
  290. result.push('00' + options.lang[i][options.lang.plurar(diff[i][0])]);
  291. }else{
  292. if(flag){
  293. diff[i][0]--;
  294. flag = false;
  295. }
  296. if(diff[i][0] < 0){
  297. flag = true;
  298. diff[i][0] += diff[i][1];
  299. }
  300. if(!diff[i][0]) continue;
  301. if(i=='days' && diff[i][0]<0){
  302. diff['days'][0]=Math.abs(1+diff['days'][0]);
  303. diff['months'][0]++;
  304. }
  305. if(i=='years' && diff[i][0]<0)
  306. return '';
  307. if((i=='seconds' || i=='minutes') && diff[i][0]<10)
  308. diff[i][0] = '0' + diff[i][0];
  309.  
  310. if(diff[i][0]!=0)
  311. result.push(diff[i][0] + '' + options.lang[i][options.lang.plurar(diff[i][0])]);
  312. }
  313. }
  314. return result.reverse().join('');
  315. };
  316. var timeCurrent = function(date){
  317. var hou = date.getHours().toString();
  318. var min = date.getMinutes().toString();
  319. var sec = date.getSeconds().toString();
  320. hou = (hou<10)?0+hou:hou;
  321. min = (min<10)?0+min:min;
  322. sec = (sec<10)?0+sec:sec;
  323. return hou+':'+min+':'+sec;
  324. };
  325.  
  326. var elem = $(this);
  327. var timeUpdate = function(){
  328. dateJS = new Date();
  329.  
  330. timestamp = parseInt(timestamp) + 1000;
  331. dateJS.setTime(timestamp);
  332.  
  333. /*if(elem.parents('.timedependent-form-content').find('#currentTime').length)
  334. elem.parents('.timedependent-form-content').find('#currentTime').html(timeCurrent(dateJS));*/
  335. var s = timeDifference(dateJS, date);
  336. if(s.length){
  337. elem.html(options.prefix + s);
  338. }else{
  339. clearInterval(timer);
  340. elem.html(options.finish);
  341. if(options.redirect != '')
  342. window.location.href = options.redirect;
  343. }
  344. };
  345. timeUpdate();
  346. var timer = setInterval(timeUpdate, 1000);
  347. };
  348. </script>
  349. <?php } ?>
  350.  
  351. <?php foreach ($products as $product) { ?>
  352.  
  353. <?php $now = time();
  354. $count = 0;
  355. foreach ($products as $product) {
  356. $count++; ?>
  357.  
  358. <?php $time_remaining = $product['date_ends'];
  359. $countdown = strtotime("$time_remaining"); ?>
  360. <div class="timerbar">
  361. <h2 id="product<?php echo $count; ?>"></h2>
  362. </div><br/>
  363. <script>
  364. jQuery("#product<?php echo $count; ?>").countdown(new Date(<?php echo date('Y, m, d, H, i, s',$countdown); ?>), {
  365. prefix:"",
  366. finish:"Expired",
  367. redirect:"",
  368. dateparse:"<?php echo date('d F Y H:i:s',$now); ?>",
  369. lang:{
  370. years: [' year, ', ' years, '],
  371. months: [' month, ', ' months, '],
  372. days: [' day, ', ' days, '],
  373. hours: [':', ':'],
  374. minutes: [':', ':'],
  375. seconds: ['', ''],
  376. plurar: function(n) {
  377. return (n == 1 ? 0 : 1);
  378. }
  379. }});
  380. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement