MilenkovicPetar Posted June 10, 2014 Share Posted June 10, 2014 Hello friends, I have a one problem... Im buy a countdown module, and modify module and now, im show a timer on product inside NEW ARIVALS item in home page.... First check sorting of products.... I need a code to Sort it by time expires....Is this possible? Thanks in advice .. P.S Module i'm buyed is Countdown special (he has a option for sorting but i dont like a design of this module, so im modify it) Sory for my bad English.... I hope you understand me... Greetings from Serbia Milenkovic Petar Link to comment Share on other sites More sharing options...
MilenkovicPetar Posted June 10, 2014 Author Share Posted June 10, 2014 <?php if (class_exists('CountdownSpecials') != true) { class CountdownSpecials extends Module { private $_html = ''; private $_postErrors = array(); function __construct() { $this->name = 'countdownspecials'; if (_PS_VERSION_ > "1.4.0.0") { $this->tab = 'pricing_promotion'; $this->author = 'RSI'; $this->need_instance = 1; } else { $this->tab = 'Home'; } $this->version = '3.0'; $this->module_key = "c5470490142d139dd24e87c0cb52051b"; parent::__construct(); $this->displayName = $this->l('Countdown Specials'); $this->description = $this->l('Displays specials Products in your site with timer'); } function install() { if (_PS_VERSION_ < "1.6.0.0") { if (!Configuration::updateValue('COUNTDOWNSPECIALS_NBR', 8) OR !parent::install() OR !$this->registerHook('home') OR !$this->registerHook('leftcolumn') OR !$this->registerHook('header') OR !$this->registerHook('extraright') OR !$this->registerHook('top') OR !$this->registerHook('footer')) return false; } else { if (!Configuration::updateValue('COUNTDOWNSPECIALS_NBR', 8) OR !parent::install() OR !$this->registerHook('home') OR !$this->registerHook('rightcolumn') OR !$this->registerHook('header') OR !$this->registerHook('extraright') OR !$this->registerHook('top') OR !$this->registerHook('footer')) return false; } if (!Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH', '180')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH2', '970')) return false; if (_PS_VERSION_ < "1.6.0.0") { if (!Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH3', '540')) return false; } else { if (!Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH3', '980')) return false; } if (!Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH3H', '379')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_HEIGHT', '340')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_HP', 'yes')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_PADDING', '3')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_STYLETIME', '1')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_BUT', '1')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_NBR2', '5')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_NBR3', '2')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_COLOR', 'ffffff')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_COLORBG', 'ffffff')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_COLOR2', 'yes')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_MARGIN', '2')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_SORT', 'ASC')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_ALIGN', '1px solid #000')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_FS', '14')) return false; if (_PS_VERSION_ < "1.5.0.0") { if (!Configuration::updateValue('COUNTDOWNSPECIALS_WIDTHT', '980')) return false; } else { if (!Configuration::updateValue('COUNTDOWNSPECIALS_WIDTHT', '1169')) return false; } if (_PS_VERSION_ < "1.5.0.0") { if (!Configuration::updateValue('COUNTDOWNSPECIALS_HEIGHTT', '250')) return false; } else { if (!Configuration::updateValue('COUNTDOWNSPECIALS_HEIGHTT', '298')) return false; } if (!Configuration::updateValue('COUNTDOWNSPECIALS_DELAYCS', 5000)) return false; if (_PS_VERSION_ < "1.5.0.0") { if (!Configuration::updateValue('COUNTDOWNSPECIALS_IMAGECS', 'home')) return false; } else { if (!Configuration::updateValue('COUNTDOWNSPECIALS_IMAGECS', 'home_default')) return false; } if (!Configuration::updateValue('COUNTDOWNSPECIALS_SLIDERCS', 'hometop')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_COLORTOP', 'ffffff')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_NBRTOP', '5')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_NBRPAGE', '20')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_ENABLEDP', 0)) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_DISABLEDP', 0)) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATION', "yes")) return false; if (_PS_VERSION_ < "1.6.0.0") { if (!Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATIONN', "3")) return false; } else { if (!Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATIONN', "5")) return false; } if (!Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATION2', "yes")) return false; if (_PS_VERSION_ < "1.6.0.0") { if (!Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATIONN2', "3")) return false; } else { if (!Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATIONN2', "4")) return false; } if (!Configuration::updateValue('COUNTDOWNSPECIALS_GRID', "no")) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_RAD', "0")) return false; if (_PS_VERSION_ < "1.6.0.0") { if (!Configuration::updateValue('COUNTDOWNSPECIALS_LISTW', "175")) return false; } else { if (!Configuration::updateValue('COUNTDOWNSPECIALS_LISTW', "200")) return false; } if (!Configuration::updateValue('COUNTDOWNSPECIALS_IMAGESIZEH', "128")) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_IMAGESIZEC', "128")) return false; if (_PS_VERSION_ < "1.5.0.0") { if (!Configuration::updateValue('COUNTDOWNSPECIALS_IMAGEH', "home")) return false; } else { if (!Configuration::updateValue('COUNTDOWNSPECIALS_IMAGEH', "home_default")) return false; } if (_PS_VERSION_ < "1.5.0.0") { if (!Configuration::updateValue('COUNTDOWNSPECIALS_IMAGEC', "home")) return false; } else { if (!Configuration::updateValue('COUNTDOWNSPECIALS_IMAGEC', "home_default")) return false; } if (!Configuration::updateValue('COUNTDOWNSPECIALS_COLORP', '000000')) return false; if (!Configuration::updateValue('COUNTDOWNSPECIALS_FSP', 14)) return false; @chmod("../modules/countdownspecials/" . ((_PS_VERSION_ > "1.5.0.0") ? $this->context->shop->id : '') . "jquery.countdown.css", 0777); return true; } public function uninstall() { if (parent::uninstall() == false) return false; if (!Configuration::deleteByName('COUNTDOWNSPECIALS_NBR') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_NBR2') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_MARGIN') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_PADDING') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_STYLETIME') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_NBR3') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_COLOR') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_COLOR2') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_BUT') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_WIDTH') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_WIDTH2') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_WIDTH3') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_HEIGHT') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_ALIGN') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_NUMBER') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_SORT') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_FS') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_ALIGN') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_WIDTH3H') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_WIDTHT') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_HEIGHTT') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_DELAYCS') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_IMAGECS') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_COLORTOP') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_NBRTOP') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_NBRPAGE') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_ENABLEDP') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_DISABLEDP') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_PAGINATION') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_PAGINATIONN') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_PAGINATION2') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_PAGINATIONN2') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_GRID') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_RAD') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_LISTW') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_COLORBG') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_COLORP') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_FSP') OR !Configuration::deleteByName('COUNTDOWNSPECIALS_SLIDERCS') OR !parent::uninstall()) return false; return true; } public function getContent() { $output = '<h2>' . $this->displayName . '</h2> <script type="text/javascript" src="' . $this->_path . 'countdownspecials.js"></script>'; if (Tools::isSubmit('submitDelete')) { if (_PS_VERSION_ < "1.4.0.0") { Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'product SET ' . _DB_PREFIX_ . 'product.`reduction_from` = \'2011-07-05 09:27:24\', `reduction_to` = \'2011-07-05 09:27:24\' WHERE `id_product`=' . intval($_POST['id_product'])); $output .= $this->displayConfirmation($this->l('Price Promotion Deleted')); } if (_PS_VERSION_ > "1.4.0.0" && _PS_VERSION_ < "1.5.0.0") { Db::getInstance()->Execute('DELETE FROM ' . _DB_PREFIX_ . 'specific_price WHERE ' . _DB_PREFIX_ . 'specific_price.`id_specific_price`=' . intval($_POST['id_discount'])); $output .= $this->displayConfirmation($this->l('Price Promotion Deleted' . $_POST['id_discount'])); } if (_PS_VERSION_ > "1.5.0.0") { Db::getInstance()->Execute('DELETE FROM ' . _DB_PREFIX_ . 'specific_price WHERE ' . _DB_PREFIX_ . 'specific_price.`id_specific_price`=' . intval($_POST['id_discount']) . ' AND ' . _DB_PREFIX_ . 'specific_price.`id_product`=' . intval($_POST['id_product'])); $output .= $this->displayConfirmation($this->l('Price Promotion Deleted')); } } if (Tools::isSubmit('submitCountdownSpecials')) { $nbr = Tools::getValue('nbr'); $hp = Tools::getValue('hp'); $pagination = Tools::getValue('pagination'); $paginationn = Tools::getValue('paginationn'); $pagination2 = Tools::getValue('pagination2'); $paginationn2 = Tools::getValue('paginationn2'); $skipcat = Tools::getValue('skipcat'); $nbr2 = Tools::getValue('nbr2'); $styletime = Tools::getValue('styletime'); $nbr3 = Tools::getValue('nbr3'); $color = Tools::getValue('color'); $colorbg = Tools::getValue('colorbg'); $color2 = Tools::getValue('color2'); $padding = Tools::getValue('padding'); $widtht = Tools::getValue('widtht'); $heightt = Tools::getValue('heightt'); $delaycs = Tools::getValue('delaycs'); $imagecs = Tools::getValue('imagecs'); $colortop = Tools::getValue('colortop'); $grid = Tools::getValue('grid'); $nbrtop = Tools::getValue('nbrtop'); $nbrpage = Tools::getValue('nbrpage'); $rad = Tools::getValue('rad'); $listw = Tools::getValue('listw'); $slidercs = Tools::getValue('slidercs'); $number = Tools::getValue('number'); $widthlo = Tools::getValue('width'); $width3h = Tools::getValue('width3h'); $widthlo3 = Tools::getValue('width3'); $heightlo = Tools::getValue('height'); $widthlo2 = Tools::getValue('widthlo2'); $align = Tools::getValue('align'); $margin = Tools::getValue('margin'); $sort = Tools::getValue('sort'); $fs = Tools::getValue('fs'); $but = Tools::getValue('but'); $enabledp = Tools::getValue('enabledp'); $disabledp = Tools::getValue('disabledp'); $imagesizec = Tools::getValue('imagesizec'); $imagesizeh = Tools::getValue('imagesizeh'); $imagec = Tools::getValue('imagec'); $imageh = Tools::getValue('imageh'); $colorp = Tools::getValue('colorp'); $fsp = Tools::getValue('fsp'); Configuration::updateValue('COUNTDOWNSPECIALS_COLORP', $colorp); Configuration::updateValue('COUNTDOWNSPECIALS_FSP', $fsp); Configuration::updateValue('COUNTDOWNSPECIALS_NBR', $nbr); Configuration::updateValue('COUNTDOWNSPECIALS_IMAGESIZEC', $imagesizec); Configuration::updateValue('COUNTDOWNSPECIALS_IMAGESIZEH', $imagesizeh); Configuration::updateValue('COUNTDOWNSPECIALS_IMAGEC', $imagec); Configuration::updateValue('COUNTDOWNSPECIALS_IMAGEH', $imageh); Configuration::updateValue('COUNTDOWNSPECIALS_LISTW', $listw); Configuration::updateValue('COUNTDOWNSPECIALS_RAD', $rad); Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATION', $pagination); Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATIONN', $paginationn); Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATION2', $pagination2); Configuration::updateValue('COUNTDOWNSPECIALS_SLIDERCS', $slidercs); Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATIONN2', $paginationn2); Configuration::updateValue('COUNTDOWNSPECIALS_NBRPAGE', $nbrpage); Configuration::updateValue('COUNTDOWNSPECIALS_NBRTOP', $nbrtop); Configuration::updateValue('COUNTDOWNSPECIALS_COLORTOP', $colortop); Configuration::updateValue('COUNTDOWNSPECIALS_COLORBG', $colorbg); Configuration::updateValue('COUNTDOWNSPECIALS_WIDTHT', $widtht); Configuration::updateValue('COUNTDOWNSPECIALS_HEIGHTT', $heightt); Configuration::updateValue('COUNTDOWNSPECIALS_DELAYCS', $delaycs); Configuration::updateValue('COUNTDOWNSPECIALS_NBR2', $nbr2); Configuration::updateValue('COUNTDOWNSPECIALS_HP', $hp); Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH3H', $width3h); Configuration::updateValue('COUNTDOWNSPECIALS_NBR3', $nbr3); Configuration::updateValue('COUNTDOWNSPECIALS_BUT', $but); Configuration::updateValue('COUNTDOWNSPECIALS_MARGIN', $margin); Configuration::updateValue('COUNTDOWNSPECIALS_STYLETIME', $styletime); Configuration::updateValue('COUNTDOWNSPECIALS_PADDING', $padding); Configuration::updateValue('COUNTDOWNSPECIALS_COLOR', $color); Configuration::updateValue('COUNTDOWNSPECIALS_COLOR2', $color2); Configuration::updateValue('COUNTDOWNSPECIALS_IMAGECS', $imagecs); Configuration::updateValue('COUNTDOWNSPECIALS_ALIGN', $align); Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH', $widthlo); Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH3', $widthlo3); Configuration::updateValue('COUNTDOWNSPECIALS_FS', $fs); Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH2', $widthlo2); Configuration::updateValue('COUNTDOWNSPECIALS_HEIGHT', $heightlo); Configuration::updateValue('COUNTDOWNSPECIALS_NUMBER', $number); Configuration::updateValue('COUNTDOWNSPECIALS_SORT', $sort); Configuration::updateValue('COUNTDOWNSPECIALS_ENABLEDP', $enabledp); Configuration::updateValue('COUNTDOWNSPECIALS_DISABLEDP', $disabledp); Configuration::updateValue('COUNTDOWNSPECIALS_GRID', $grid); $xml2 = fopen("../modules/countdownspecials/" . ((_PS_VERSION_ > "1.5.0.0") ? $this->context->shop->id : '') . "jquery.countdown.css", "w"); fwrite($xml2, ' #ajslider { margin: 10px 0 10px 0; border:1px solid #000; position:relative; float:left } #ajslider .s { background:url(back.png) repeat-x #' . $colortop . '; padding:10px; text-align: center; } #ajslider .s h1 { background-image:none; font-size:18px} #ajslider .s .pricescs { font-size:25px; color:#fff; font-weight:bolder; background:url(images/fire.png) no-repeat center; width:100%; height:27px; padding-top:39px; text-align:center; height:87px} .hasCountdown { position:relative; margin:0 auto; color:#' . $color . ' ; font-weight:bold; background:url(Countdown' . $but . '.png) no-repeat; padding-left:39px; padding-top:' . $padding . 'px; height:36px; clear:both; font-family:Arial; font-size:12px; width: 169px; } .price_container{ text-align:center } .exclusive ajax_add_to_cart_button {text-align:center; margin:0 auto} .center_column h2, .center_column h3, .center_column h4 { padding: 12px 0 0 40px; } .countdown_rtl { direction: rtl; } .countdown_holding span { background-color: #ccc; } .countdown_row { clear: both; width: 100%; padding: 0px 2px; text-align: center; line-height:14px } .countdown_show1 .countdown_section { width: 33px; color:#' . $color . ' ; } .countdown_show2 .countdown_section { width: 33px; color:#' . $color . ' ; } .countdown_show3 .countdown_section { width: 33px; color:#' . $color . ' ; } .countdown_show4 .countdown_section { width: 29px; color:#' . $color . ' ; } .countdown_show5 .countdown_section { width: 19.5%; color:#' . $color . ' ; } .countdown_show6 .countdown_section { width: 16.25%; color:#' . $color . ' ; } .countdown_show7 .countdown_section { width: 14%; color:#' . $color . ' ; } .countdown_section { display: block; float: left; font-size: 75%; text-align: center; } .countdown_amount { font-size:' . $fs . 'px; line-height:14px } .countdown_descr { display: block; width: 100%; } #marqueecontainercs{ position: relative; width: ' . $widthlo . 'px; /*marquee width */ height: ' . $heightlo . 'px; /*marquee height */ overflow: hidden; /*border: 3px solid orange;*/ } /* Container DIV - automatically generated */ .simply-scroll-container { position: relative; } /* Clip DIV - automatically generated */ .simply-scroll-clip { position: relative; overflow: hidden; z-index: 2; } /* UL/OL/DIV - the element that simplyScroll is inited on Class name automatically added to element */ .simply-scroll-list { position: absolute; top: 0; left: 0; z-index: 1; overflow: hidden; margin: 0; padding: 0; list-style: none; } .simply-scroll-list li { padding: 0; margin: 0; list-style: none; } .simply-scroll-list li img { border: none; } /* Custom class modifications - adds to / overrides above .simply-scroll is default base class */ /* Container DIV */ .simply-scroll { width: ' . $widthlo2 . 'px; height:40px; margin: 10px; clear:both; position:relative; float:left } /* Clip DIV */ .simply-scroll .simply-scroll-clip { width: auto; height: 40px; } /* Explicitly set height/width of each list item */ .simply-scroll .simply-scroll-list li { float: left; /* Horizontal scroll only */ width: auto; height: 40px; } .titletime{ line-height:27px; background:url(title.png) no-repeat left center; height:27px; padding-left:40px; padding-top:5px; padding-bottom:opx} .dash { float: left; position: relative; } .dash .digit { font-weight: bold; float: left; text-align: center; position: relative; } .dash_title { position: absolute; display: block; bottom: 0px; right: 6px; font-size: 9pt; color: #555; text-transform: uppercase; letter-spacing: 2px; } .dev_comment { font-size: 14pt; color: #777; text-align: center; font-style: italic; margin: 40px 10px; } #subscribe_form { position: relative; } #email_field { font-size: 16pt; padding: 6px 10px; width: 300px; } .copyright { font-size: 9pt; color: #333; margin: 40px 0px; } .faded { color: #999; } .form_message { width: 400px; padding: 10px; margin: 15px auto; display: none; } #error_message { background-color: #ffe; border-left: 5px solid #bb3; border-right: 5px solid #bb3; color: #770; } #info_message { background-color: #f0f9ff; border: 1px solid #eef; } #loading { text-align: center; margin: 10px; display: none; position: absolute; width: 100%; top: 60px; } #short_description_blockcd{ background: #E5E6E7; position: relative; clear:both; border: solid 1px #D0D3D8; margin-bottom: 1.5em; padding: 0.7em; margin-top: 1.5em; text-align:center; height:85px } #cd{ background-image:url(icon.png); background-repeat:no-repeat; width:64px; height:37px; text-align:center; padding-top:27px;margin:0 auto; color:#000 } #cd span{ color:#fff } #sli1{position; relative:; float:left; width:60%} #sli2{position; relative:; float:left; width:39%} #featured-products_block_centercs{width:' . $widthlo3 . 'px} csf2{width:27%} .ajax_block_productcs{width:'.$listw.'px} @media (max-width: 1024px) and (min-width: 992px){ #featured-products_block_centercs{width:100%} #ajslider{width:100%} .ajax_block_productcs{width:49%} } @media (max-width: 991px) and (min-width: 200px) { #featured-products_block_centercs{width:100%} #ajslider{display:none} #marqueecontainercs{ position: relative; width: 100%; /*marquee width */ } } @media (max-width: 600px) and (min-width: 200px) { #ajslider{display:none} .ajax_block_productcs{width:100%} .csf{display:none} csf2{width:40%} } '); fwrite($xml2, ""); if (!empty($skipcat)) Configuration::updateValue('COUNTDOWNSPECIALS_SKIP_CAT', implode(',', $skipcat)); if (isset($errors) AND sizeof($errors)) $output .= $this->displayError(implode('<br />', $errors)); else $output .= $this->displayConfirmation($this->l('Settings updated')); } return $output . $this->displayForm(); } function paginate_one($reload, $page, $tpages) { $firstlabel = $this->l('First'); $prevlabel = $this->l('Prev'); $nextlabel = $this->l('Next'); $lastlabel = $this->l('Last'); $out = "<div class=\"pagin\">\n"; $reload2 = preg_replace("/\&page=[0-9]/", "", $reload); // first if ($page > 1) { $out .= "<a href=\"" . $reload2 . "\">" . $firstlabel . "</a>\n"; } else { $out .= "<span>" . $firstlabel . "</span>\n"; } // previous if ($page == 1) { $out .= "<span>" . $prevlabel . "</span>\n"; } elseif ($page == 2) { $out .= "<a href=\"" . $reload2 . "\">" . $prevlabel . "</a>\n"; } else { $out .= "<a href=\"" . $reload2 . "&page=" . ($page - 1) . "\">" . $prevlabel . "</a>\n"; } // current $out .= "<span class=\"current\">" . $this->l('Page') . " " . $page . " of " . $tpages . "</span>\n"; // next if ($page < $tpages) { $out .= "<a href=\"" . $reload2 . "&page=" . ($page + 1) . "\">" . $nextlabel . "</a>\n"; } else { $out .= "<span>" . $nextlabel . "</span>\n"; } // last if ($page < $tpages) { $out .= "<a href=\"" . $reload2 . "&page=" . $tpages . "\">" . $lastlabel . "</a>\n"; } else { $out .= "<span>" . $lastlabel . "</span>\n"; } $out .= "</div>"; return $out; } public function displayForm() { global $beginning2, $ending2, $adminObj, $cookie, $page, $resultt, $output; $currentDate = date('Y-m-d H:M:S'); $orderBy = NULL; $orderWay = NULL; $beginning = true; $ending = false; $currentDate = date('Y-m-d H:i:s'); if (_PS_VERSION_ < "1.5.0.0") { $productToken = Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)); } else { $productToken = Tools::getAdminTokenLite('adminproducts'); } if (_PS_VERSION_ > "1.4.0.0") { $output = ' <script type="text/javascript" src="../modules/countdownspecials/accordion.ui.js"></script> <style type="text/css"> .nobootstrap label{clear:both} </style> <script type="text/javascript"> $(function() { $( "#accordion" ).accordion({ autoHeight: false }); }); </script>'; } $output .= ' <link rel="stylesheet" href="../modules/countdownspecials/css/colorpicker.css" type="text/css" /> <script type="text/javascript" src="../modules/countdownspecials/js/colorpicker.js"></script> <script type="text/javascript" src="../modules/countdownspecials/js/eye.js"></script> <script type="text/javascript" src="../modules/countdownspecials/js/utils.js"></script> <script type="text/javascript" src="../modules/countdownspecials/js/layout.js?ver=1.0.2"></script> <style type="text/css"> label { float: left; width: 300px; padding: 0.2em 0.5em 0 0; text-align: right; font-weight: bold; } </style> <form action="' . $_SERVER['REQUEST_URI'] . '" method="post"> <fieldset> <div id="accordion"> <h3 style="padding-left:40px"><img src="' . $this->_path . 'module.png" alt="" title="" />' . $this->l('General settings') . '</h3> <div> <label>' . $this->l('Text date color') . '</label> <div class="margin-form"> <div id="customWidget"> <input type="text" maxlength="6" name="color" size="6" id="colorpickerField1" value="' . Tools::getValue('color', Configuration::get('COUNTDOWNSPECIALS_COLOR')) . '" /> <p class="clear">' . $this->l('Color of the text (default ffffff)') . '</p> </div> </div> <label>' . $this->l('Disable products') . '</label> <div class="margin-form"> <select name="enabledp" id="enabledp"> <option value="1" ' . (Configuration::get('COUNTDOWNSPECIALS_ENABLEDP') == '1' ? 'selected' : '') . '>' . $this->l('Yes') . '</option> <option value="0" ' . (Configuration::get('COUNTDOWNSPECIALS_ENABLEDP') == '0' ? 'selected' : '') . '>' . $this->l('No') . '</option> </select> <p class="clear">' . $this->l('Disable products when countdown date finish') . '</p> </div> <label>' . $this->l('Enable products') . '</label> <div class="margin-form"> <select name="disabledp" id="disabledp"> <option value="1" ' . (Configuration::get('COUNTDOWNSPECIALS_DISABLEDP') == '1' ? 'selected' : '') . '>' . $this->l('Yes') . '</option> <option value="0" ' . (Configuration::get('COUNTDOWNSPECIALS_DISABLEDP') == '0' ? 'selected' : '') . '>' . $this->l('No') . '</option> </select> <p class="clear">' . $this->l('Enable products when countdown date start') . '</p> </div> <label>' . $this->l('Choice of sort') . '</label> <div class="margin-form"> <select name="sort" id="sort"> <option value="ASC" ' . (Configuration::get('COUNTDOWNSPECIALS_SORT') == 'ASC' ? 'selected' : '') . '>' . $this->l('Expiring first') . '</option> <option value="DESC" ' . (Configuration::get('COUNTDOWNSPECIALS_SORT') == 'DESC' ? 'selected' : '') . '>' . $this->l('Last expiring') . '</option> </select> </div> <label>' . $this->l('Style of time') . '</label> <div class="margin-form"> <select name="styletime" id="styletime"> <option value="1" ' . (Configuration::get('COUNTDOWNSPECIALS_STYLETIME') == '1' ? 'selected' : '') . '>' . $this->l('With words') . '</option> <option value="2" ' . (Configuration::get('COUNTDOWNSPECIALS_STYLETIME') == '2' ? 'selected' : '') . '>' . $this->l('With :') . '</option> </select> </div> <label>' . $this->l('Upper range for the counter') . '</label> <div class="margin-form"> <input type="text" size="5" name="padding" value="' . Tools::getValue('padding', Configuration::get('COUNTDOWNSPECIALS_PADDING')) . '" /> <p class="clear">' . $this->l('The space between the time and the top button (default 3)') . '</p> </div> <label>' . $this->l('Font size') . '</label> <div class="margin-form"> <input type="text" size="5" name="fs" value="' . Tools::getValue('fs', Configuration::get('COUNTDOWNSPECIALS_FS')) . '" /> </div> <label>' . $this->l('Price Font size') . '</label> <div class="margin-form"> <input type="text" size="5" name="fsp" value="' . Tools::getValue('fsp', Configuration::get('COUNTDOWNSPECIALS_FSP')) . '" /> </div> <label>' . $this->l('Price color') . '</label> <div class="margin-form"> <div id="customWidget"> <input type="text" maxlength="6" name="colorp" size="6" id="colorpickerField4" value="' . Tools::getValue('colorp', Configuration::get('COUNTDOWNSPECIALS_COLORP')) . '" /> <p class="clear">' . $this->l('Color of the text (default 000000)') . '</p> </div> </div> <label>' . $this->l('Type of button') . '</label> <div class="margin-form"> <table width="200" border="0"> <tr> <td><img src="../modules/countdownspecials/Countdown1.png" width="60"></td> <td><img src="../modules/countdownspecials/Countdown2.png" width="60"></td> <td><img src="../modules/countdownspecials/Countdown3.png" width="60"></td> <td><img src="../modules/countdownspecials/Countdown4.png" width="60"></td> <td><img src="../modules/countdownspecials/Countdown5.png" width="60"></td> <td><img src="../modules/countdownspecials/Countdown6.png" width="60"></td> <td><img src="../modules/countdownspecials/Countdown7.png" width="60"></td> <td><img src="../modules/countdownspecials/Countdown8.png" width="60"></td> <td><img src="../modules/countdownspecials/Countdown9.png" width="60"></td> </tr> <tr>'; if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == "1") { $output .= '<td>1<input type="radio" name="but" id="radio1" value="1" checked="checked" /></td>'; } else { $output .= ' <td>1<input type="radio" name="but" id="radio1" value="1" /></td>'; } if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == 2) { $output .= '<td>2<input type="radio" name="but" id="radio2" value="2" checked="checked" /></td>'; } else { $output .= ' <td>2<input type="radio" name="but" id="radio2" value="2" /></td>'; } if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == 3) { $output .= '<td>3<input type="radio" name="but" id="radio3" value="3" checked="checked" /></td>'; } else { $output .= '<td>3<input type="radio" name="but" id="radio3" value="3" /></td>'; } if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == 4) { $output .= '<td>4<input type="radio" name="but" id="radio4" value="4" checked="checked" /></td>'; } else { $output .= '<td>4<input type="radio" name="but" id="radio4" value="4" /></td>'; } if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == 5) { $output .= '<td>5<input type="radio" name="but" id="radio5" value="5" checked="checked" /></td>'; } else { $output .= '<td>5<input type="radio" name="but" id="radio5" value="5" /></td>'; } if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == "6") { $output .= '<td>6<input type="radio" name="but" id="radio6" value="6" checked="checked" /></td>'; } else { $output .= ' <td>6<input type="radio" name="but" id="radio6" value="6" /></td>'; } if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == "7") { $output .= '<td>7<input type="radio" name="but" id="radio7" value="7" checked="checked" /></td>'; } else { $output .= ' <td>7<input type="radio" name="but" id="radio7" value="7" /></td>'; } if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == "8") { $output .= '<td>8<input type="radio" name="but" id="radio8" value="8" checked="checked" /></td>'; } else { $output .= ' <td>8<input type="radio" name="but" id="radio8" value="8" /></td>'; } if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == "9") { $output .= '<td>9<input type="radio" name="but" id="radio9" value="9" checked="checked" /></td>'; } else { $output .= ' <td>9<input type="radio" name="but" id="radio9" value="9" /></td>'; } $output .= '</tr> </table></div>'; if (_PS_VERSION_ > "1.4.0.0") { $output .= ' <center><input type="submit" name="submitCountdownSpecials" value="' . $this->l('Save') . '" class="button" /></center><br/>'; } $output .= '</div> <h3 style="padding-left:40px"><img src="' . $this->_path . 'slide.png" alt="" title="" />' . $this->l('Slider settings') . '</h3> <div> <label>' . $this->l('Number of products') . '</label> <div class="margin-form"> <input type="text" size="5" name="nbrtop" value="' . Tools::getValue('nbrtop', Configuration::get('COUNTDOWNSPECIALS_NBRTOP')) . '" /> </div> <label>' . $this->l('Width of the slider') . '</label> <div class="margin-form"> <input type="text" size="5" name="widtht" value="' . Tools::getValue('widtht', Configuration::get('COUNTDOWNSPECIALS_WIDTHT')) . '" /> </div> <label>' . $this->l('Height of the slider') . '</label> <div class="margin-form"> <input type="text" size="5" name="heightt" value="' . Tools::getValue('heightt', Configuration::get('COUNTDOWNSPECIALS_HEIGHTT')) . '" /> </div> <label>' . $this->l('Delay ') . '</label> <div class="margin-form"> <input type="text" size="5" name="delaycs" value="' . Tools::getValue('delaycs', Configuration::get('COUNTDOWNSPECIALS_DELAYCS')) . '" /> </div> <label>' . $this->l('Type of image') . '</label> <div class="margin-form"> <select name="imagecs" id="imagecs"> <option value="small" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGECS') == 'small' ? 'selected' : '') . '>' . $this->l('small') . '</option> <option value="medium" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGECS') == 'medium' ? 'selected' : '') . '>' . $this->l('medium') . '</option> <option value="home" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGECS') == 'home' ? 'selected' : '') . '>' . $this->l('home') . '</option> <option value="large" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGECS') == 'large' ? 'selected' : '') . '>' . $this->l('large') . '</option> <option value="small_default" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGECS') == 'small_default' ? 'selected' : '') . '>' . $this->l('small PS 1.5') . '</option> <option value="medium_default" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGECS') == 'medium_default' ? 'selected' : '') . '>' . $this->l('medium PS 1.5') . '</option> <option value="home_default" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGECS') == 'home_default' ? 'selected' : '') . '>' . $this->l('home PS 1.5') . '</option> <option value="large_default" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGECS') == 'large_default' ? 'selected' : '') . '>' . $this->l('large PS 1.5') . '</option> </select> </div> <label>' . $this->l('Enable slider in:') . '</label> <div class="margin-form"> <select name="slidercs" id="slidercs"> <option value="hometop" ' . (Configuration::get('COUNTDOWNSPECIALS_SLIDERCS') == 'hometop' ? 'selected' : '') . '>' . $this->l('only in home, top of pages') . '</option> <option value="topcs" ' . (Configuration::get('COUNTDOWNSPECIALS_SLIDERCS') == 'topcs' ? 'selected' : '') . '>' . $this->l('all pages, in top of pages') . '</option> <option value="homecs" ' . (Configuration::get('COUNTDOWNSPECIALS_SLIDERCS') == 'homecs' ? 'selected' : '') . '>' . $this->l('homepage') . '</option> </select> </div> <label>' . $this->l('Background color') . '</label> <div class="margin-form"> <div id="customWidget"> <input type="text" maxlength="6" name="colortop" size="6" id="colorpickerField3" value="' . Tools::getValue('colortop', Configuration::get('COUNTDOWNSPECIALS_COLORTOP')) . '" /> <p class="clear">' . $this->l('Color of the text (default ffffff)') . '</p> </div> </div>'; if (_PS_VERSION_ > "1.4.0.0") { $output .= ' <center><input type="submit" name="submitCountdownSpecials" value="' . $this->l('Save') . '" class="button" /></center><br/>'; } $output .= '</div> <h3 style="padding-left:40px"><img src="' . $this->_path . 'column.png" alt="" title="" />' . $this->l('Column settings') . '</h3> <div> <label>' . $this->l('Image type') . '</label> <div class="margin-form"> <select name="imagec" id="imagec"> <option value="home" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGEC') == 'home' ? 'selected' : '') . '>' . $this->l('Home') . '</option> <option value="small" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGEC') == 'small' ? 'selected' : '') . '>' . $this->l('Small') . '</option> <option value="medium" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGEC') == 'medium' ? 'selected' : '') . '>' . $this->l('Medium') . '</option> <option value="home_default" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGEC') == 'home_default' ? 'selected' : '') . '>' . $this->l('Home PS 1.5') . '</option> <option value="small_default" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGEC') == 'small_default' ? 'selected' : '') . '>' . $this->l('Small PS 1.5') . '</option> <option value="medium_default" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGEC') == 'medium_default' ? 'selected' : '') . '>' . $this->l('Medium PS 1.5') . '</option> </select> <p class="clear">' . $this->l('The image type for the countdown') . '</p> </div> <label>' . $this->l('Image size') . '</label> <div class="margin-form"> <input type="text" size="5" name="imagesizec" value="' . Tools::getValue('imagesizec', Configuration::get('COUNTDOWNSPECIALS_IMAGESIZEC')) . '" /> <p class="clear">' . $this->l('The width for the image') . '</p> </div> <label>' . $this->l('Number of products') . '</label> <div class="margin-form"> <input type="text" size="5" name="nbr3" value="' . Tools::getValue('nbr3', Configuration::get('COUNTDOWNSPECIALS_NBR3')) . '" /> </div> <label>' . $this->l('Speed') . '</label> <div class="margin-form"> <input type="text" size="5" name="nbr2" value="' . Tools::getValue('nbr2', Configuration::get('COUNTDOWNSPECIALS_NBR2')) . '" /> <p class="clear">' . $this->l('Speed of the scroll (1 to 10)') . '</p> </div> <label>' . $this->l('Width') . '</label> <div class="margin-form"> <input type="text" size="5" name="width" value="' . Tools::getValue('width', Configuration::get('COUNTDOWNSPECIALS_WIDTH')) . '" /> <p class="clear">' . $this->l('Width of the block (default 180)') . '</p> </div> <label>' . $this->l('Height') . '</label> <div class="margin-form"> <input type="text" size="5" name="height" value="' . Tools::getValue('height', Configuration::get('COUNTDOWNSPECIALS_HEIGHT')) . '" /> <p class="clear">' . $this->l('Height of the module(default 240)') . '</p> </div>'; if (_PS_VERSION_ > "1.4.0.0") { $output .= ' <center><input type="submit" name="submitCountdownSpecials" value="' . $this->l('Save') . '" class="button" /></center><br/>'; } $output .= '</div> <h3 style="padding-left:40px"><img src="' . $this->_path . 'home.png" alt="" title="" />' . $this->l('Home and countdown page') . '</h3> <div> <label>' . $this->l('Enable on home page') . '</label> <div class="margin-form"> <select name="hp" id="hp"> <option value="yes" ' . (Configuration::get('COUNTDOWNSPECIALS_HP') == 'yes' ? 'selected' : '') . '>' . $this->l('yes') . '</option> <option value="no" ' . (Configuration::get('COUNTDOWNSPECIALS_HP') == 'no' ? 'selected' : '') . '>' . $this->l('no') . '</option> </select> <p class="clear">' . $this->l('Put no if you want to disable on home page. You can put this code on your homefeatured.tpl module to include in your home featured the countdown timer: </br>{include file="$tpl_dir./../../modules/countdownspecials/countdownspecials-list.tpl"}') . '</p> </div> <label>' . $this->l('Image type') . '</label> <div class="margin-form"> <select name="imageh" id="imageh"> <option value="home" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGEH') == 'home' ? 'selected' : '') . '>' . $this->l('Home') . '</option> <option value="small" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGEH') == 'small' ? 'selected' : '') . '>' . $this->l('Small') . '</option> <option value="medium" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGEH') == 'medium' ? 'selected' : '') . '>' . $this->l('Medium') . '</option> <option value="home_default" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGEH') == 'home_default' ? 'selected' : '') . '>' . $this->l('Home PS 1.5') . '</option> <option value="small_default" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGEH') == 'small_default' ? 'selected' : '') . '>' . $this->l('Small PS 1.5') . '</option> <option value="medium_default" ' . (Configuration::get('COUNTDOWNSPECIALS_IMAGEH') == 'medium_default' ? 'selected' : '') . '>' . $this->l('Medium PS 1.5') . '</option> </select> <p class="clear">' . $this->l('The image type for the countdown') . '</p> </div> <label>' . $this->l('Image size') . '</label> <div class="margin-form"> <input type="text" size="5" name="imagesizeh" value="' . Tools::getValue('imagesizeh', Configuration::get('COUNTDOWNSPECIALS_IMAGESIZEH')) . '" /> <p class="clear">' . $this->l('The width for the image') . '</p> </div> <label>' . $this->l('Number of products to display in homepage') . '</label> <div class="margin-form"> <input type="text" size="5" name="nbr" value="' . Tools::getValue('nbr', Configuration::get('COUNTDOWNSPECIALS_NBR')) . '" /> <p class="clear">' . $this->l('The number of orders to display (default: 10, put 0 to disable in homepage)') . '</p> </div> <label>' . $this->l('Number of products to display in Countdown page') . '</label> <div class="margin-form"> <input type="text" size="5" name="nbrpage" value="' . Tools::getValue('nbrpage', Configuration::get('COUNTDOWNSPECIALS_NBRPAGE')) . '" /> <p class="clear">' . $this->l('Total of products to show in countdown page') . '</p> </div> <label>' . $this->l('Enable pagination in homepage') . '</label> <div class="margin-form"> <select name="pagination" id="pagination"> <option value="yes" ' . (Configuration::get('COUNTDOWNSPECIALS_PAGINATION') == 'yes' ? 'selected' : '') . '>' . $this->l('yes') . '</option> <option value="no" ' . (Configuration::get('COUNTDOWNSPECIALS_PAGINATION') == 'no' ? 'selected' : '') . '>' . $this->l('no') . '</option> </select> </div> <label>' . $this->l('Enable pagination in countdown page') . '</label> <div class="margin-form"> <select name="pagination2" id="pagination2"> <option value="yes" ' . (Configuration::get('COUNTDOWNSPECIALS_PAGINATION2') == 'yes' ? 'selected' : '') . '>' . $this->l('yes') . '</option> <option value="no" ' . (Configuration::get('COUNTDOWNSPECIALS_PAGINATION2') == 'no' ? 'selected' : '') . '>' . $this->l('no') . '</option> </select> </div> <label style="padding:0">' . $this->l('Products in pagination (homepage)') . '</label> <div class="margin-form"> <input type="text" size="5" name="paginationn" value="' . Tools::getValue('paginationn', Configuration::get('COUNTDOWNSPECIALS_PAGINATIONN')) . '" /> </div> <label style="padding:0">' . $this->l('Products in pagination (countdown page)') . '</label> <div class="margin-form"> <input type="text" size="5" name="paginationn2" value="' . Tools::getValue('paginationn2', Configuration::get('COUNTDOWNSPECIALS_PAGINATIONN2')) . '" /> </div> <label style="padding:0">' . $this->l('Border style') . '</label> <div class="margin-form"> <input type="text" size="20" name="align" value="' . Tools::getValue('align', Configuration::get('COUNTDOWNSPECIALS_ALIGN')) . '" /> <p class="clear">' . $this->l('For example: 1px solid #000 ') . '</p> </div> <label>' . $this->l('Margin for each element') . '</label> <div class="margin-form"> <input type="text" size="5" name="margin" value="' . Tools::getValue('margin', Configuration::get('COUNTDOWNSPECIALS_MARGIN')) . '" /> </div> <label>' . $this->l('Show add to cart') . '</label> <div class="margin-form"> <select name="color2" id="color2"> <option value="yes" ' . (Configuration::get('COUNTDOWNSPECIALS_COLOR2') == 'yes' ? 'selected' : '') . '>' . $this->l('Yes') . '</option> <option value="no" ' . (Configuration::get('COUNTDOWNSPECIALS_COLOR2') == 'no' ? 'selected' : '') . '>' . $this->l('No') . '</option> </select> <p class="clear">' . $this->l('Show total price') . '</p> </div> <label>' . $this->l('Style of the module') . '</label> <div class="margin-form"> <select name="grid" id="grid"> <option value="no" ' . (Configuration::get('COUNTDOWNSPECIALS_GRID') == 'no' ? 'selected' : '') . '>' . $this->l('Grid') . '</option> <option value="yes" ' . (Configuration::get('COUNTDOWNSPECIALS_GRID') == 'yes' ? 'selected' : '') . '>' . $this->l('List') . '</option> </select> <p class="clear">' . $this->l('Show items as grid or list (homepage and module page)') . '</p> </div> <label>' . $this->l('Width of the module') . '</label> <div class="margin-form"> <input type="text" size="5" name="width3" value="' . Tools::getValue('width3', Configuration::get('COUNTDOWNSPECIALS_WIDTH3')) . '" /> <p class="clear">' . $this->l('Width of the block (default 540)') . '</p> </div> <label>' . $this->l('Height of each element') . '</label> <div class="margin-form"> <input type="text" size="5" name="width3h" value="' . Tools::getValue('width3h', Configuration::get('COUNTDOWNSPECIALS_WIDTH3H')) . '" /> <p class="clear">' . $this->l('The height for each element in homepage and page') . '</p> </div> <label>' . $this->l('Width of each element') . '</label> <div class="margin-form"> <input type="text" size="5" name="listw" value="' . Tools::getValue('listw', Configuration::get('COUNTDOWNSPECIALS_LISTW')) . '" /> <p class="clear">' . $this->l('The width for each element in homepage and page') . '</p> </div> <label>' . $this->l('Border radius') . '</label> <div class="margin-form"> <input type="text" size="5" name="rad" value="' . Tools::getValue('rad', Configuration::get('COUNTDOWNSPECIALS_RAD')) . '" /> <p class="clear">' . $this->l('Make the border of elements with a radius (max 20)') . '</p> </div> <label>' . $this->l('Background color') . '</label> <div class="margin-form"> <div id="customWidget"> <input type="text" maxlength="6" name="colorbg" size="6" id="colorpickerField2" value="' . Tools::getValue('colorbg', Configuration::get('COUNTDOWNSPECIALS_COLORBG')) . '" /> <p class="clear">' . $this->l('Color of the background (default ffffff)') . '</p> </div> </div> <center><input type="submit" name="submitCountdownSpecials" value="' . $this->l('Save') . '" class="button" /></center><br/> </div> <h3 style="padding-left:40px"><img src="' . $this->_path . 'pdf.png" alt="" title="" />' . $this->l('Documentation') . '</h3> <div> <p>' . $this->l('If you need to add countdown timer in product list, edit the product-list.tpl of your theme and put this code where you need the timer:') . '<br/>{include file="$tpl_dir./../../modules/countdownspecials/countdownspecials-list.tpl"}</p> <p>' . $this->l('If you use layered navigation module, edit in modules/blocklayered/blocklayered.php, and add at the beginning this code:') . '<br/>include(dirname(__FILE__).\'/../countdownspecials/countdownspecials.php\');</p> <p>' . $this->l('and search this line:') . '<br/>\'nb_products\' => $nb_products,</p> <p>' . $this->l('and put this code after it:') . '<br/>\'productlist\' => CountdownSpecials::productList(),</p> <center><a href="../modules/countdownspecials/countdown.pdf">README</a></center><br/> <center><a href="../modules/countdownspecials/termsandconditions.pdf">TERMS</a></center> </div> <h3 style="padding-left:40px"><img src="' . $this->_path . 'date.png" alt="" title="" />' . $this->l('Active and expired products') . '</h3> <div> '; $output .= '<h1>' . $this->l('Active prices drop list - Current time: ') . date('Y-m-d H:i:s') . '</h1> <form method="post" action="' . $_SERVER['REQUEST_URI'] . '" method="post" enctype="multipart/form-data" > <table class="table"> <tr> <th>' . $this->l('ID') . '</th> <th>' . $this->l('Reference') . '</th> <th>' . $this->l('Name') . '</th> <th>' . $this->l('From') . '</th> <th>' . $this->l('To') . '</th> <th>' . $this->l('Edit') . '</th> </tr>'; mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_) or die(mysql_error()); mysql_query("SET NAMES UTF8"); //this is needed for UTF 8 characters - multilanguage mysql_select_db(_DB_NAME_) or die(mysql_error()); if (_PS_VERSION_ > "1.4.0.0" && _PS_VERSION_ < "1.5.0.0") { $sql = ' SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, sp.from AS reduction_from, sp.to AS reduction_to,sp.`id_specific_price`,sp.`id_product` FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . $cookie->id_lang . ') LEFT JOIN `' . _DB_PREFIX_ . 'specific_price` sp ON (p.`id_product` = sp.`id_product`) WHERE sp.from <= sp.to AND sp.from <= \'' . pSQL($currentDate) . '\' AND sp.to >= \'' . pSQL($currentDate) . '\' '; } if (_PS_VERSION_ > "1.5.0.0") { global $context; if (!$context) $context = Context::getContext(); $currentDate = date('Y-m-d H:i:s'); $sql = ' SELECT p.*, ps.*,pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`, sp.`from` AS reduction_from, sp.`to` AS reduction_to, sp.`id_product`,sp.`id_specific_price` FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'product_shop` ps ON (p.`id_product` = ps.`id_product`) LEFT JOIN `' . _DB_PREFIX_ . 'specific_price` sp ON (p.`id_product` = sp.`id_product`) LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . $cookie->id_lang . ') WHERE sp.from <= sp.to AND sp.from <= \'' . pSQL($currentDate) . '\' AND sp.to >= \'' . pSQL($currentDate) . '\' AND ps.id_shop = ' . $this->context->shop->id . ' AND pl.id_shop = ' . $this->context->shop->id . ' '; } if (_PS_VERSION_ < "1.4.0.0") { $sql = ' SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name` FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . $cookie->id_lang . ') WHERE p.reduction_from < p.reduction_to AND p.reduction_from < \'' . pSQL($currentDate) . '\' AND p.reduction_to > \'' . pSQL($currentDate) . '\' GROUP BY p.`id_product`'; } $resultt = mysql_query($sql); $pricesDrop = Db::getInstance()->ExecuteS($sql); $prices_Drop = array(); /*paginate*/ $rpp = 10; // results per page $adjacents = 2; $page = intval(@$_GET["page"]); if ($page <= 0) $page = 1; $reload = $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']; // count total number of appropriate listings: @$tcount = mysql_num_rows(@$resultt); // count number of pages: $tpages = ($tcount) ? ceil($tcount / $rpp) : 1; // total pages, last page number $count = 0; $i = ($page - 1) * $rpp; while (($count < $rpp) && ($i < $tcount)) { mysql_data_seek($resultt, $i); $query = mysql_fetch_array($resultt); // output each row: $output .= ' <tr/><td>' . $query['id_product'] . '</td> <td>' . $query['reference'] . '</td> <td>' . $query['name'] . '</td> <td>' . $query['reduction_from'] . '</td> <td>' . $query['reduction_to'] . '</td>'; if (_PS_VERSION_ < "1.5.0.0") { $productToken2 = Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)); } else { $productToken2 = Tools::getAdminTokenLite('updateproduct' . $query['id_product']); } if (_PS_VERSION_ < "1.5.0.0") { $output .= '<td><a href="index.php?tab=AdminCatalog&id_product=' . $query['id_product'] . '&addproduct&token=' . $productToken2 . '" target="_blank">' . $this->l('Edit') . '</a> <input name="id_product" type="hidden" id="id_product" value="' . $query['id_product'] . '" />'; if (_PS_VERSION_ > "1.4.0.0") { $output .= ' <input name="id_discount" type="hidden" id="id_discount" value="' . $query['id_specific_price'] . '" />'; } $output .= '<input type="image" src="../img/admin/delete.gif" name="submitDelete" id="submitDelete" border="0" style="border:none;cursor: pointer;" /> '; } else { $output .= '<td><a href="index.php?controller=adminproducts&id_product=' . $query['id_product'] . '&updateproduct&token=' . $productToken2 . '" target="_blank">' . $this->l('Edit') . '</a> <input name="id_product" type="hidden" id="id_product" value="' . $query['id_product'] . '" /> <input name="id_discount" type="hidden" id="id_discount" value="' . $query['id_specific_price'] . '" /> <input type="image" src="../img/admin/delete.gif" name="submitDelete" id="submitDelete" border="0" style="border:none;cursor: pointer;" /> '; } $output .= '</td> </tr>'; $i++; $count++; } // call pagination function: /*endpaginate*/ /* foreach ($pricesDrop AS $priceDrop){ $output .= ' <tr/><td>'.$priceDrop['id_product'].'</td> <td>'.$priceDrop['reference'].'</td> <td>'.$priceDrop['name'].'</td> <td>'.$priceDrop['reduction_from'].'</td> <td>'.$priceDrop['reduction_to'].'</td> <td><a href="index.php?tab=AdminCatalog&id_product='.$priceDrop['id_product'].'&addproduct&token='.$productToken.'" target="_blank">'.$this->l('Edit').'</a> </td> </tr>'; }*/ $output .= '</table></form><br/>'; $output .= CountdownSpecials::paginate_one($reload, $page, $tpages, $adjacents); $output .= '<br/><h1>' . $this->l('Expired prices drop list') . '</h1> <form method="post" action="' . $_SERVER['REQUEST_URI'] . '" method="post" enctype="multipart/form-data" > <table class="table"> <tr> <th>' . $this->l('ID') . '</th> <th>' . $this->l('Reference') . '</th> <th>' . $this->l('Name') . '</th> <th>' . $this->l('From') . '</th> <th>' . $this->l('To') . '</th> <th>' . $this->l('Edit') . '</th> </tr>'; mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_) or die(mysql_error()); mysql_query("SET NAMES UTF8"); //this is needed for UTF 8 characters - multilanguage mysql_select_db(_DB_NAME_) or die(mysql_error()); if (_PS_VERSION_ > "1.4.0.0" && _PS_VERSION_ < "1.5.0.0") { $sql2 = ' SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, sp.from AS reduction_from, sp.to AS reduction_to, sp.id_specific_price FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . $cookie->id_lang . ') LEFT JOIN `' . _DB_PREFIX_ . 'specific_price` sp ON (p.`id_product` = sp.`id_product`) WHERE sp.from < sp.to AND sp.from <= \'' . pSQL($currentDate) . '\' AND sp.to < \'' . pSQL($currentDate) . '\' GROUP BY p.`id_product` '; } if (_PS_VERSION_ > "1.5.0.0") { global $context; if (!$context) $context = Context::getContext(); $currentDate = date('Y-m-d H:i:s'); $currentDate = date('Y-m-d H:i:s'); $sql2 = ' SELECT p.*,ps.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`, sp.`from` AS reduction_from, sp.`to` AS reduction_to, sp.`id_product` ,sp.`id_specific_price` FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'product_shop` ps ON (p.`id_product` = ps.`id_product`) LEFT JOIN `' . _DB_PREFIX_ . 'specific_price` sp ON (p.`id_product` = sp.`id_product`) LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . $cookie->id_lang . ') WHERE sp.from < sp.to AND sp.from <= \'' . pSQL($currentDate) . '\' AND sp.to < \'' . pSQL($currentDate) . '\' AND ps.id_shop = ' . $this->context->shop->id . ' AND pl.id_shop = ' . $this->context->shop->id . ' '; } if (_PS_VERSION_ < "1.4.0.0") { $sql2 = ' SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name` FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . $cookie->id_lang . ') WHERE p.reduction_from < p.reduction_to AND p.reduction_to < \'' . pSQL($currentDate) . '\' GROUP BY p.`id_product`'; } $pricesDrop2 = Db::getInstance()->ExecuteS($sql2); $resulttt = mysql_query($sql2); $prices_Drop2 = array(); @$tcount = mysql_num_rows(@$resulttt); // count number of pages: $tpages = ($tcount) ? ceil($tcount / $rpp) : 1; // total pages, last page number $count = 0; $i = ($page - 1) * $rpp; while (($count < $rpp) && ($i < $tcount)) { mysql_data_seek($resulttt, $i); $query = mysql_fetch_array($resulttt); // output each row: $output .= ' <tr/><td>' . $query['id_product'] . '</td> <td>' . $query['reference'] . '</td> <td>' . $query['name'] . '</td> <td>' . $query['reduction_from'] . '</td> <td>' . $query['reduction_to'] . '</td>'; if (_PS_VERSION_ < "1.5.0.0") { $productToken3 = Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)); } else { $productToken3 = Tools::getAdminTokenLite('AdminProducts' . $query['id_product']); } if (_PS_VERSION_ < "1.5.0.0") { $output .= '<td><a href="index.php?tab=AdminCatalog&id_product=' . $query['id_product'] . '&addproduct&token=' . $productToken3 . '" target="_blank">' . $this->l('Edit') . '</a> <input name="id_product" type="hidden" id="id_product" value="' . $query['id_product'] . '" />'; if (_PS_VERSION_ > "1.4.0.0") { $output .= ' <input name="id_discount" type="hidden" id="id_discount" value="' . $query['id_specific_price'] . '" />'; } $output .= '<input type="image" src="../img/admin/delete.gif" name="submitDelete" id="submitDelete" border="0" style="border:none;cursor: pointer;" />'; } else { $output .= '<td><a href="index.php?controller=adminproducts&id_product=' . $query['id_product'] . '&updateproduct&token=' . $productToken3 . '" target="_blank">' . $this->l('Edit') . '</a> <input name="id_product" type="hidden" id="id_product" value="' . $query['id_product'] . '" /> <input name="id_discount" type="hidden" id="id_discount" value="' . $query['id_specific_price'] . '" /> <input type="image" src="../img/admin/delete.gif" name="submitDelete" id="submitDelete" border="0" style="border:none;cursor: pointer;" />'; } $output .= ' </td> </tr>'; $i++; $count++; } // call pagination function: /*endpaginate*/ /* foreach ($pricesDrop AS $priceDrop){ $output .= ' <tr/><td>'.$priceDrop['id_product'].'</td> <td>'.$priceDrop['reference'].'</td> <td>'.$priceDrop['name'].'</td> <td>'.$priceDrop['reduction_from'].'</td> <td>'.$priceDrop['reduction_to'].'</td> <td><a href="index.php?tab=AdminCatalog&id_product='.$priceDrop['id_product'].'&addproduct&token='.$productToken.'" target="_blank">'.$this->l('Edit').'</a> </td> </tr>'; }*/ $output .= '</table></form><br/>'; $output .= CountdownSpecials::paginate_one($reload, $page, $tpages, $adjacents); /* foreach ($pricesDrop2 AS $priceDrop2){ $output .= ' <tr/><td>'.$priceDrop2['id_product'].'</td> <td>'.$priceDrop2['reference'].'</td> <td>'.$priceDrop2['name'].'</td> <td>'.$priceDrop2['reduction_from'].'</td> <td>'.$priceDrop2['reduction_to'].'</td> <td><a href="index.php?tab=AdminCatalog&id_product='.$priceDrop2['id_product'].'&addproduct&token='.$productToken.'" target="_blank">'.$this->l('Edit').'</a> </td> </tr>'; $output .= '</table>';*/ $output .= '</div> </fieldset> </form>'; return $output; } public function getPricesDropsh($id_lang, $pageNumber = 0, $nbProducts, $count = false, $orderBy = NULL, $orderWay = NULL, $beginning = true, $ending = false) { $sort = Configuration::get('COUNTDOWNSPECIALS_SORT'); $psversion = _PS_VERSION_; global $link, $cookie; if (!Validate::isBool($count)) die(Tools::displayError()); if ($pageNumber < 0) $pageNumber = 0; if ($nbProducts < 1) $nbProducts = 10; if (empty($orderBy) || $orderBy == 'position') $orderBy = 'myprice'; if (empty($orderWay)) $orderWay = 'DESC'; if ($orderBy == 'id_product' OR $orderBy == 'price' OR $orderBy == 'date_add') $orderByPrefix = 'p'; elseif ($orderBy == 'name') $orderByPrefix = 'pl'; if (!Validate::isOrderBy($orderBy) OR !Validate::isOrderWay($orderWay)) die(Tools::displayError()); if ($count) { $sql = ' SELECT COUNT(DISTINCT p.`id_product`) AS nb FROM `' . _DB_PREFIX_ . 'product` p WHERE p.`active` = 1 AND p.`id_product` IN ( SELECT cp.`id_product` FROM `' . _DB_PREFIX_ . 'category_group` cg LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` ' . (!$cookie->id_customer ? '= 1' : 'IN (SELECT id_group FROM ' . _DB_PREFIX_ . 'customer_group WHERE id_customer = ' . intval($cookie->id_customer) . ')') . ' )'; $result = Db::getInstance()->getRow($sql); return intval($result['nb']); } $currentDate = date('Y-m-d H:i:s'); $sql = ' SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, i.`id_image`, il.`legend`, t.`rate`, (p.`reduction_price` + (p.`reduction_percent` * p.`price`)) AS myprice, m.`name` AS manufacturer_name FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . intval($id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . intval($id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = p.`id_tax`) LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) WHERE (`reduction_price` >= 0 OR `reduction_percent` >= 0) ' . ((!$beginning AND !$ending) ? 'AND ((`reduction_from` <= \'' . pSQL($currentDate) . '\' AND `reduction_to` >= \'' . pSQL($currentDate) . '\'))' : ($beginning ? 'AND `reduction_from` <= \'' . pSQL($beginning) . '\'' : '') . ($ending ? 'AND `reduction_to` >= \'' . pSQL($ending) . '\'' : '')) . ' AND p.`active` = 1 AND p.`id_product` IN ( SELECT cp.`id_product` FROM `' . _DB_PREFIX_ . 'category_group` cg LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` ' . (!$cookie->id_customer ? '= 1' : 'IN (SELECT id_group FROM ' . _DB_PREFIX_ . 'customer_group WHERE id_customer = ' . intval($cookie->id_customer) . ')') . ' )'; if ($sort != "RAND()") { $sql .= ' GROUP BY p.`id_product` ORDER BY `reduction_to` ' . $sort . ' LIMIT ' . $nbProducts; } else { $sql .= ' GROUP BY p.`id_product` ORDER BY RAND() LIMIT ' . $nbProducts; } $result = Db::getInstance()->ExecuteS($sql); if ($orderBy == 'price') { Tools::orderbyPrice($result, $orderWay); } if (!$result) return false; return Product::getProductsProperties($id_lang, $result); } /**/ public function getPricesDropshea($id_lang, $pageNumber = 0, $nbProducts, $count = false, $orderBy = NULL, $orderWay = NULL, $beginning = true, $ending = false) { $sort = Configuration::get('COUNTDOWNSPECIALS_SORT'); $psversion = _PS_VERSION_; global $link, $cookie; if (!Validate::isBool($count)) die(Tools::displayError()); if ($pageNumber < 0) $pageNumber = 0; if ($nbProducts < 1) $nbProducts = 10; if (empty($orderBy) || $orderBy == 'position') $orderBy = 'myprice'; if (empty($orderWay)) $orderWay = 'DESC'; if ($orderBy == 'id_product' OR $orderBy == 'price' OR $orderBy == 'date_add') $orderByPrefix = 'p'; elseif ($orderBy == 'name') $orderByPrefix = 'pl'; if (!Validate::isOrderBy($orderBy) OR !Validate::isOrderWay($orderWay)) die(Tools::displayError()); if ($count) { $sql = ' SELECT COUNT(DISTINCT p.`id_product`) AS nb FROM `' . _DB_PREFIX_ . 'product` p WHERE p.`active` = 1 AND p.`id_product` IN ( SELECT cp.`id_product` FROM `' . _DB_PREFIX_ . 'category_group` cg LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` ' . (!$cookie->id_customer ? '= 1' : 'IN (SELECT id_group FROM ' . _DB_PREFIX_ . 'customer_group WHERE id_customer = ' . intval($cookie->id_customer) . ')') . ' )'; $result = Db::getInstance()->getRow($sql); return intval($result['nb']); } $currentDate = date('Y-m-d H:i:s'); $sql = ' SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, i.`id_image`, il.`legend`, t.`rate`, (p.`reduction_price` + (p.`reduction_percent` * p.`price`)) AS myprice, m.`name` AS manufacturer_name FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . intval($id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . intval($id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = p.`id_tax`) LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) WHERE (`reduction_price` >= 0 OR `reduction_percent` >= 0) ' . ((!$beginning AND !$ending) ? 'AND ((`reduction_from` <= \'' . pSQL($currentDate) . '\' AND `reduction_to` >= \'' . pSQL($currentDate) . '\'))' : ($beginning ? 'AND `reduction_from` <= \'' . pSQL($beginning) . '\'' : '') . ($ending ? 'AND `reduction_to` >= \'' . pSQL($ending) . '\'' : '')) . ' AND p.`active` = 1 AND p.`id_product` IN ( SELECT cp.`id_product` FROM `' . _DB_PREFIX_ . 'category_group` cg LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` ' . (!$cookie->id_customer ? '= 1' : 'IN (SELECT id_group FROM ' . _DB_PREFIX_ . 'customer_group WHERE id_customer = ' . intval($cookie->id_customer) . ')') . ' )'; if ($sort != "RAND()") { $sql .= ' GROUP BY p.`id_product` ORDER BY `reduction_to` ' . $sort . ' LIMIT ' . $nbProducts; } else { $sql .= ' GROUP BY p.`id_product` ORDER BY RAND() '; } $result = Db::getInstance()->ExecuteS($sql); if ($orderBy == 'price') { Tools::orderbyPrice($result, $orderWay); } if (!$result) return false; return Product::getProductsProperties($id_lang, $result); } /**/ public function getPricesDropT($id_lang, $pageNumber = 0, $nbProducts, $count = false, $orderBy = NULL, $orderWay = NULL, $beginning = true, $ending = false) { $sort = Configuration::get('COUNTDOWNSPECIALS_SORT'); $psversion = _PS_VERSION_; global $link, $cookie; if (!Validate::isBool($count)) die(Tools::displayError()); if ($pageNumber < 0) $pageNumber = 0; if ($nbProducts < 1) $nbProducts = 10; if (empty($orderBy) || $orderBy == 'position') $orderBy = 'myprice'; if (empty($orderWay)) $orderWay = 'DESC'; if ($orderBy == 'id_product' OR $orderBy == 'price' OR $orderBy == 'date_add') $orderByPrefix = 'p'; elseif ($orderBy == 'name') $orderByPrefix = 'pl'; if (!Validate::isOrderBy($orderBy) OR !Validate::isOrderWay($orderWay)) die(Tools::displayError()); if ($count) { $sql = ' SELECT COUNT(DISTINCT p.`id_product`) AS nb FROM `' . _DB_PREFIX_ . 'product` p WHERE p.`active` = 1 AND p.`id_product` IN ( SELECT cp.`id_product` FROM `' . _DB_PREFIX_ . 'category_group` cg LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` ' . (!$cookie->id_customer ? '= 1' : 'IN (SELECT id_group FROM ' . _DB_PREFIX_ . 'customer_group WHERE id_customer = ' . intval($cookie->id_customer) . ')') . ' )'; $result = Db::getInstance()->getRow($sql); return intval($result['nb']); } $currentDate = date('Y-m-d H:i:s'); $sql = ' SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, i.`id_image`, il.`legend`, t.`rate`, (p.`reduction_price` + (p.`reduction_percent` * p.`price`)) AS myprice, m.`name` AS manufacturer_name FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . intval($id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . intval($id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = p.`id_tax`) LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) WHERE (`reduction_price` >= 0 OR `reduction_percent` >= 0) ' . ((!$beginning AND !$ending) ? 'AND ((`reduction_from` <= \'' . pSQL($currentDate) . '\' AND `reduction_to` >= \'' . pSQL($currentDate) . '\'))' : ($beginning ? 'AND `reduction_from` <= \'' . pSQL($beginning) . '\'' : '') . ($ending ? 'AND `reduction_to` >= \'' . pSQL($ending) . '\'' : '')) . ' AND p.`active` = 1 AND p.`id_product` IN ( SELECT cp.`id_product` FROM `' . _DB_PREFIX_ . 'category_group` cg LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` ' . (!$cookie->id_customer ? '= 1' : 'IN (SELECT id_group FROM ' . _DB_PREFIX_ . 'customer_group WHERE id_customer = ' . intval($cookie->id_customer) . ')') . ' )'; if ($sort != "RAND()") { $sql .= ' GROUP BY p.`id_product` ORDER BY `reduction_to` ' . $sort . ' '; } else { $sql .= ' GROUP BY p.`id_product` ORDER BY RAND() '; } $result = Db::getInstance()->ExecuteS($sql); if ($orderBy == 'price') { Tools::orderbyPrice($result, $orderWay); } if (!$result) return false; return Product::getProductsProperties($id_lang, $result); } public static function getList($id_lang) { /*product list code*/ global $cookie; if (_PS_VERSION_ > "1.4.0.0") { $currentDate = date('Y-m-d H:i:s'); $sql = mysql_query(' SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name, sp.`from` AS reduction_from, sp.`to` AS reduction_to, sp.`id_product` FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'specific_price` sp ON (p.`id_product` = sp.`id_product`) LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . (int) ($cookie->id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) ($cookie->id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = ' . (int) Country::getDefaultCountryId() . ' AND tr.`id_state` = 0) LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = tr.`id_tax`) LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) WHERE 1 AND sp.`from` < sp.`to` AND p.`active` = 1 AND sp.`to` < "' . pSQL($currentDate) . '"'); } /*end product list*/ $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); if (!$result) return false; return CountdownSpecials::getProductsProperties((int) ($cookie->id_lang), $result); } public static function getPricesDrop2($id_lang, $pageNumber = 0, $nbProducts, $count = false, $orderBy = NULL, $orderWay = NULL, $beginning = false, $ending = false, Context $context = null) { global $context; if (_PS_VERSION_ > "1.5.0.0") { if (!$context) $context = Context::getContext(); } $front = true; $sort = Configuration::get('COUNTDOWNSPECIALS_SORT'); $psversion = _PS_VERSION_; if (!Validate::isBool($count)) die(Tools::displayError()); $currentDate = date('Y-m-d H:i:s'); $ids_product = self::_getProductIdByDate((!$beginning ? $currentDate : $beginning), (!$ending ? $currentDate : $ending)); $groups = FrontController::getCurrentCustomerGroups(); $sqlGroups = (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1'); if (_PS_VERSION_ > "1.4.0.0" && _PS_VERSION_ < "1.5.0.0") { $sql = ' SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name, sp.`from` AS reduction_from, sp.`to` AS reduction_to, sp.`id_product` FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'specific_price` sp ON (p.`id_product` = sp.`id_product`) LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . (int) ($id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) ($id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = ' . (int) Country::getDefaultCountryId() . ' AND tr.`id_state` = 0) LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = tr.`id_tax`) LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) WHERE 1 AND sp.`from` < sp.`to` AND sp.`to` >= "' . pSQL($currentDate) . '" AND p.`active` = 1 AND p.`show_price` = 1 AND p.`id_product` IN ( SELECT cp.`id_product` FROM `' . _DB_PREFIX_ . 'category_group` cg LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` ' . $sqlGroups . ' ) GROUP BY p.`id_product` ORDER BY sp.`to` ' . $sort . ' LIMIT ' . (int) ($pageNumber * $nbProducts) . ', ' . (int) ($nbProducts); } if (_PS_VERSION_ > "1.5.0.0") { global $context; if (!$context) $context = Context::getContext(); $sql = ' SELECT p.*, ps.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name, sp.`from` AS reduction_from, sp.`to` AS reduction_to, sp.`id_product` FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'specific_price` sp ON (p.`id_product` = sp.`id_product`) LEFT JOIN `' . _DB_PREFIX_ . 'product_shop` ps ON (p.`id_product` = ps.`id_product`) LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . (int) ($id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) ($id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = ' . (int) Context::getContext()->country->id . ' AND tr.`id_state` = 0) LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = tr.`id_tax`) LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) WHERE 1 AND sp.`from` < sp.`to` AND sp.`to` >= "' . pSQL($currentDate) . '" AND p.`active` = 1 AND p.`show_price` = 1 AND p.`id_product` IN ( SELECT cp.`id_product` FROM `' . _DB_PREFIX_ . 'category_group` cg LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` ' . $sqlGroups . ' ) AND ps.id_shop = ' . $context->shop->id . ' AND pl.id_shop = ' . $context->shop->id . ' GROUP BY p.`id_product` ORDER BY sp.`to` ' . $sort . ' LIMIT ' . (int) ($pageNumber * $nbProducts) . ', ' . (int) ($nbProducts); } $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); if ($orderBy == 'price') Tools::orderbyPrice($result, $orderWay); if (!$result) return false; return CountdownSpecials::getProductsProperties($id_lang, $result); } /*header*/ public static function getPricesDrop2header($id_lang, $pageNumber = 0, $nbProducts, $count = false, $orderBy = NULL, $orderWay = NULL, $beginning = false, $ending = false, Context $context = null) { global $context; if (_PS_VERSION_ > "1.5.0.0") { if (!$context) $context = Context::getContext(); } $front = true; $sort = Configuration::get('COUNTDOWNSPECIALS_SORT'); $psversion = _PS_VERSION_; if (!Validate::isBool($count)) die(Tools::displayError()); $currentDate = date('Y-m-d H:i:s'); $ids_product = self::_getProductIdByDate((!$beginning ? $currentDate : $beginning), (!$ending ? $currentDate : $ending)); $groups = FrontController::getCurrentCustomerGroups(); $sqlGroups = (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1'); if (_PS_VERSION_ > "1.4.0.0" && _PS_VERSION_ < "1.5.0.0") { $sql = ' SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name, sp.`from` AS reduction_from, sp.`to` AS reduction_to, sp.`id_product` FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'specific_price` sp ON (p.`id_product` = sp.`id_product`) LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . (int) ($id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) ($id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = ' . (int) Country::getDefaultCountryId() . ' AND tr.`id_state` = 0) LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = tr.`id_tax`) LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) WHERE 1 AND sp.`from` < sp.`to` AND sp.`to` >= "' . pSQL($currentDate) . '" AND p.`active` = 1 AND p.`show_price` = 1 ' . ((!$beginning AND !$ending) ? ' AND p.`id_product` IN (' . ((is_array($ids_product) AND sizeof($ids_product)) ? implode(', ', $ids_product) : 0) . ')' : '') . ' AND p.`id_product` IN ( SELECT cp.`id_product` FROM `' . _DB_PREFIX_ . 'category_group` cg LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` ' . $sqlGroups . ' ) GROUP BY p.`id_product` ORDER BY sp.`to` ' . $sort; } if (_PS_VERSION_ > "1.5.0.0") { global $context; if (!$context) $context = Context::getContext(); $sql = ' SELECT p.*, ps.*,pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name, sp.`from` AS reduction_from, sp.`to` AS reduction_to, sp.`id_product` FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'product_shop` ps ON (p.`id_product` = ps.`id_product`) LEFT JOIN `' . _DB_PREFIX_ . 'specific_price` sp ON (p.`id_product` = sp.`id_product`) LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . (int) ($id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) ($id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = ' . (int) Context::getContext()->country->id . ' AND tr.`id_state` = 0) LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = tr.`id_tax`) LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) WHERE 1 AND sp.`from` < sp.`to` AND sp.`to` >= "' . pSQL($currentDate) . '" AND p.`active` = 1 AND p.`show_price` = 1 ' . ((!$beginning AND !$ending) ? ' AND p.`id_product` IN (' . ((is_array($ids_product) AND sizeof($ids_product)) ? implode(', ', $ids_product) : 0) . ')' : '') . ' AND p.`id_product` IN ( SELECT cp.`id_product` FROM `' . _DB_PREFIX_ . 'category_group` cg LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` ' . $sqlGroups . ' ) AND ps.id_shop = ' . $context->shop->id . ' AND pl.id_shop = ' . $context->shop->id . ' GROUP BY p.`id_product` ORDER BY sp.`to` ' . $sort; } $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); if ($orderBy == 'price') Tools::orderbyPrice($result, $orderWay); if (!$result) return false; return CountdownSpecials::getProductsProperties($id_lang, $result); } /**/ public static function getPricesDrop2T($id_lang, $pageNumber = 0, $nbProducts, $count = false, $orderBy = NULL, $orderWay = NULL, $beginning = false, $ending = false) { $sort = Configuration::get('COUNTDOWNSPECIALS_SORT'); $psversion = _PS_VERSION_; if (!Validate::isBool($count)) die(Tools::displayError()); $currentDate = date('Y-m-d H:i:s'); $ids_product = self::_getProductIdByDate((!$beginning ? $currentDate : $beginning), (!$ending ? $currentDate : $ending)); $groups = FrontController::getCurrentCustomerGroups(); $sqlGroups = (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1'); $sql = ' SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name, sp.`from` AS reduction_from, sp.`to` AS reduction_to, sp.`id_product` FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'specific_price` sp ON (p.`id_product` = sp.`id_product`) LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . (int) ($id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) ($id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = ' . (int) Country::getDefaultCountryId() . ' AND tr.`id_state` = 0) LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = tr.`id_tax`) LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) WHERE 1 AND sp.`from` < sp.`to` AND sp.`to` >= "' . pSQL($currentDate) . '" AND p.`active` = 1 AND p.`show_price` = 1 ' . ((!$beginning AND !$ending) ? ' AND p.`id_product` IN (' . ((is_array($ids_product) AND sizeof($ids_product)) ? implode(', ', $ids_product) : 0) . ')' : '') . ' AND p.`id_product` IN ( SELECT cp.`id_product` FROM `' . _DB_PREFIX_ . 'category_group` cg LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` ' . $sqlGroups . ' ) GROUP BY p.`id_product` LIMIT 2 '; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); if ($orderBy == 'price') Tools::orderbyPrice($result, $orderWay); if (!$result) return false; return CountdownSpecials::getProductsProperties($id_lang, $result); } public static function getProductProperties($id_lang, $row) { if (!$row['id_product']) return false; // Product::getDefaultAttribute is only called if id_product_attribute is missing from the SQL query at the origin of it: consider adding it in order to avoid unnecessary queries $row['allow_oosp'] = Product::isAvailableWhenOutOfStock($row['out_of_stock']); if ((!isset($row['id_product_attribute']) OR !$row['id_product_attribute']) AND ((isset($row['cache_default_attribute']) AND ($ipa_default = $row['cache_default_attribute']) !== NULL) OR ($ipa_default = Product::getDefaultAttribute($row['id_product'], !$row['allow_oosp'])))) $row['id_product_attribute'] = $ipa_default; if (!isset($row['id_product_attribute'])) $row['id_product_attribute'] = 0; // Tax $usetax = Tax::excludeTaxeOption(); $cacheKey = $row['id_product'] . '-' . $row['id_product_attribute'] . '-' . $id_lang . '-' . (int) ($usetax); if (array_key_exists($cacheKey, self::$producPropertiesCache)) return self::$producPropertiesCache[$cacheKey]; // Datas $link = new Link(); $row['category'] = Category::getLinkRewrite((int) $row['id_category_default'], (int) ($id_lang)); $row['link'] = $link->getProductLink((int) $row['id_product'], $row['link_rewrite'], $row['category'], $row['ean13']); $row['attribute_price'] = (isset($row['id_product_attribute']) AND $row['id_product_attribute']) ? (float) (Product::getProductAttributePrice($row['id_product_attribute'])) : 0; $row['price_tax_exc'] = Product::getPriceStatic((int) $row['id_product'], false, ((isset($row['id_product_attribute']) AND !empty($row['id_product_attribute'])) ? (int) ($row['id_product_attribute']) : NULL), (self::$_taxCalculationMethod == PS_TAX_EXC ? 2 : 6)); if (self::$_taxCalculationMethod == PS_TAX_EXC) { $row['price_tax_exc'] = Tools::ps_round($row['price_tax_exc'], 2); $row['price'] = Product::getPriceStatic((int) $row['id_product'], true, ((isset($row['id_product_attribute']) AND !empty($row['id_product_attribute'])) ? (int) ($row['id_product_attribute']) : NULL), 6); } else $row['price'] = Tools::ps_round(Product::getPriceStatic((int) $row['id_product'], true, ((isset($row['id_product_attribute']) AND !empty($row['id_product_attribute'])) ? (int) ($row['id_product_attribute']) : NULL), 6), 2); $row['reduction'] = Product::getPriceStatic((int) ($row['id_product']), (bool) $usetax, (int) ($row['id_product_attribute']), 6, NULL, true, true, 1, true, NULL, NULL, NULL, $specific_prices); $row['specific_prices'] = $specific_prices; $row['price_without_reduction'] = Product::getPriceStatic((int) $row['id_product'], true, ((isset($row['id_product_attribute']) AND !empty($row['id_product_attribute'])) ? (int) ($row['id_product_attribute']) : NULL), 6, NULL, false, false); if ($row['id_product_attribute']) $row['quantity'] = Product::getQuantity((int) $row['id_product'], $row['id_product_attribute'], isset($row['cache_is_pack']) ? $row['cache_is_pack'] : NULL); $row['id_image'] = Product::defineProductImage($row, $id_lang); $row['features'] = Product::getFrontFeaturesStatic((int) $id_lang, $row['id_product']); $row['attachments'] = ((!isset($row['cache_has_attachments']) OR $row['cache_has_attachments']) ? Product::getAttachmentsStatic((int) ($id_lang), $row['id_product']) : array()); // Pack management $row['pack'] = (!isset($row['cache_is_pack']) ? Pack::isPack($row['id_product']) : (int) $row['cache_is_pack']); $row['packItems'] = $row['pack'] ? Pack::getItemTable($row['id_product'], $id_lang) : array(); $row['nopackprice'] = $row['pack'] ? Pack::noPackPrice($row['id_product']) : 0; if ($row['pack'] AND !Pack::isInStock($row['id_product'])) $row['quantity'] = 0; self::$producPropertiesCache[$cacheKey] = $row; return self::$producPropertiesCache[$cacheKey]; } public static function getProductsProperties($id_lang, $query_result) { $resultsArray = array(); foreach ($query_result AS $row) if ($row2 = CountdownSpecials::getProductProperties($id_lang, $row)) $resultsArray[] = $row2; return $resultsArray; } protected static $producPropertiesCache = array(); public static $_taxCalculationMethod = PS_TAX_EXC; public static function getTaxCalculationMethod($id_customer = NULL) { if ($id_customer) self::initPricesComputation((int) ($id_customer)); return (int) (self::$_taxCalculationMethod); } static private function _getProductIdByDate($beginning, $ending, Context $context = null) { global $cookie, $cart, $context; if (_PS_VERSION_ > "1.5.0.0") { if (!$context) $context = Context::getContext(); } $front = true; $currentDate = date('Y-m-d H:M:S'); $id_group = $cookie->id_customer ? (int) (Customer::getDefaultGroupId((int) ($cookie->id_customer))) : _PS_DEFAULT_CUSTOMER_GROUP_; $id_address = $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}; $ids = Address::getCountryAndState($id_address); $id_country = (int) ($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT')); if (_PS_VERSION_ < "1.5.0.0") { return SpecificPrice::getProductIdByDate((int) (Shop::getCurrentShop()), (int) ($cookie->id_currency), $id_country, $id_group, $currentDate, $currentDate); } else { return SpecificPrice::getProductIdByDate(Context::getContext()->shop->id, (int) ($cookie->id_currency), $id_country, $id_group, $currentDate, $currentDate); } } public function productpage() { $result = Db::getInstance()->ExecuteS(' SELECT *.p FROM `' . _DB_PREFIX_ . 'product` p WHERE p.active = 1 AND p.id_product = ' . $id_product); } public function hookTop($params) { global $cookie, $smarty, $width3, $width3h, $sort, $beginning2, $ending2, $nbr, $productsd, $productd, $color2, $psversion, $id_lang, $styletime, $margin, $reduction_to, $reduction_from, $productt, $productsd2; $styletime = Configuration::get('COUNTDOWNSPECIALS_STYLETIME'); $nbrtop = Configuration::get('COUNTDOWNSPECIALS_NBRTOP'); $widtht = Configuration::get('COUNTDOWNSPECIALS_WIDTHT'); $heightt = Configuration::get('COUNTDOWNSPECIALS_HEIGHTT'); $margin = Configuration::get('COUNTDOWNSPECIALS_MARGIN'); $widthlo3 = Configuration::get('COUNTDOWNSPECIALS_WIDTH3'); $color2 = Configuration::get('COUNTDOWNSPECIALS_COLOR2'); $align = Configuration::get('COUNTDOWNSPECIALS_ALIGN'); $imagecs = Configuration::get('COUNTDOWNSPECIALS_IMAGECS'); $styletime = Configuration::get('COUNTDOWNSPECIALS_STYLETIME'); $delaycs = Configuration::get('COUNTDOWNSPECIALS_DELAYCS'); $slidercs = Configuration::get('COUNTDOWNSPECIALS_SLIDERCS'); if ($sort == "ASC") { $sort = "DESC"; } else { $sort = "ASC"; } $psversion = _PS_VERSION_; if ($psversion < "1.4.0.0") { $pricesDrop = CountdownSpecials::getPricesDropsh(intval($params['cookie']->id_lang), $pageNumber = 0, $nbrtop, $count = false, $orderBy = $sort, $orderWay = NULL, $beginning = $beginning2, $ending = $ending2); } else { $pricesDrop = CountdownSpecials::getPricesDrop2(intval($params['cookie']->id_lang), $pageNumber = 0, $nbrtop, $count = false, $orderBy = $sort, $orderWay = NULL, $beginning = $beginning2, $ending = $ending2); } $prices_Drop = array(); if ($pricesDrop) foreach ($pricesDrop AS $priceDrop) $productsd2[] = $priceDrop; $smarty->assign(array( 'productsd2' => $productsd2, 'imagecs' => $imagecs, 'productlist' => CountdownSpecials::productList(), 'widtht' => $widtht, 'heightt' => $heightt, 'slidercs' => $slidercs, 'styletime' => $styletime, 'lang' => 'text_' . $cookie->id_lang )); return $this->display(__FILE__, 'countdownspecials-top.tpl'); } function hookHome($params) { global $smarty, $hpcp, $width3, $width3h, $sort, $beginning2, $ending2, $nbr, $productsd, $productd, $color2, $psversion, $id_lang, $styletime, $margin, $reduction_to, $reduction_from; $styletime = Configuration::get('COUNTDOWNSPECIALS_STYLETIME'); $nbr = Configuration::get('COUNTDOWNSPECIALS_NBR'); $width3 = Configuration::get('COUNTDOWNSPECIALS_WIDTH3'); $width3h = Configuration::get('COUNTDOWNSPECIALS_WIDTH3H'); $margin = Configuration::get('COUNTDOWNSPECIALS_MARGIN'); $widthlo3 = Configuration::get('COUNTDOWNSPECIALS_WIDTH3'); $hpcp = Configuration::get('COUNTDOWNSPECIALS_HP'); $color2 = Configuration::get('COUNTDOWNSPECIALS_COLOR2'); $colorbg = Configuration::get('COUNTDOWNSPECIALS_COLORBG'); $align = Configuration::get('COUNTDOWNSPECIALS_ALIGN'); $grid = Configuration::get('COUNTDOWNSPECIALS_GRID'); $delaycs = Configuration::get('COUNTDOWNSPECIALS_DELAYCS'); $rad = Configuration::get('COUNTDOWNSPECIALS_RAD'); $listw = Configuration::get('COUNTDOWNSPECIALS_LISTW'); $imagesizeh = Configuration::get('COUNTDOWNSPECIALS_IMAGESIZEH'); $imageh = Configuration::get('COUNTDOWNSPECIALS_IMAGEH'); $psversion = _PS_VERSION_; if ($psversion < "1.4.0.0") { $pricesDrop = CountdownSpecials::getPricesDropsh(intval($params['cookie']->id_lang), $pageNumber = 0, $nbr, $count = false, $orderBy = $sort, $orderWay = NULL, $beginning = $beginning2, $ending = $ending2); } else { $pricesDrop = CountdownSpecials::getPricesDrop2(intval($params['cookie']->id_lang), $pageNumber = 0, $nbr, $count = false, $orderBy = $sort, $orderWay = NULL, $beginning = $beginning2, $ending = $ending2); } $prices_Drop = array(); if ($pricesDrop) foreach ($pricesDrop AS $priceDrop) $productsd[] = $priceDrop; $smarty->assign(array( 'productsd' => $productsd, 'color2' => $color2, 'hpcp' => $hpcp, 'widthlo3' => $widthlo3, 'margin' => $margin, 'styletime' => $styletime, 'psversion' => $psversion, 'align' => $align, 'width3' => $width3, 'width3h' => $width3h, 'delaycs' => $delaycs, 'grid' => $grid, 'rad' => $rad, 'colorbg' => $colorbg, 'listw' => $listw, 'imageh' => $imageh, 'imagesizeh' => $imagesizeh, 'nbrcs' => $nbr )); return $this->display(__FILE__, 'countdownspecials.tpl'); } function hookLeftColumn($params) { global $smarty, $sort, $beginning2, $ending2, $nbr, $countdowns, $psversion, $id_lang, $reduction_from, $reduction_to, $styletime, $height; $styletime = Configuration::get('COUNTDOWNSPECIALS_STYLETIME'); $nbr3 = Configuration::get('COUNTDOWNSPECIALS_NBR3'); $height = Configuration::get('COUNTDOWNSPECIALS_HEIGHT'); $nbr2 = Configuration::get('COUNTDOWNSPECIALS_NBR2'); $imagesizec = Configuration::get('COUNTDOWNSPECIALS_IMAGESIZEC'); $imagec = Configuration::get('COUNTDOWNSPECIALS_IMAGEC'); $psversion = _PS_VERSION_; if ($psversion < "1.4.0.0") { $pricesDrop = CountdownSpecials::getPricesDropsh(intval($params['cookie']->id_lang), $pageNumber = 0, $nbr3, $count = false, $orderBy = $sort, $orderWay = NULL, $beginning = $beginning2, $ending = $ending2); } else { $pricesDrop = CountdownSpecials::getPricesDrop2(intval($params['cookie']->id_lang), $pageNumber = 0, $nbr3, $count = false, $orderBy = $sort, $orderWay = NULL, $beginning = $beginning2, $ending = $ending2); } $prices_Drop = array(); if ($pricesDrop) foreach ($pricesDrop AS $priceDrop) $countdowns[] = $priceDrop; $smarty->assign(array( 'countdowns' => $countdowns, 'height' => $height, 'nbr2' => $nbr2, 'styletime' => $styletime, 'psversion' => $psversion, 'imagesizec' => $imagesizec, 'imagec' => $imagec )); return $this->display(__FILE__, 'countdownspecials-column.tpl'); } function hookRightColumn($params) { return $this->hookLeftColumn($params); } public static function productList() { global $cookie, $smarty, $productsdd; if (_PS_VERSION_ > "1.5.0.0") { $context = Context::getContext(); } $styletime = Configuration::get('COUNTDOWNSPECIALS_STYLETIME'); $smarty->assign(array( 'styletime' => $styletime )); $front = true; $styletime = Configuration::get('COUNTDOWNSPECIALS_STYLETIME'); $pagination = Configuration::get('COUNTDOWNSPECIALS_PAGINATION'); $colorp = Configuration::get('COUNTDOWNSPECIALS_COLORP'); $fsp = Configuration::get('COUNTDOWNSPECIALS_FSP'); $paginationn = Configuration::get('COUNTDOWNSPECIALS_PAGINATIONN'); $pagination2 = Configuration::get('COUNTDOWNSPECIALS_PAGINATION2'); $paginationn2 = Configuration::get('COUNTDOWNSPECIALS_PAGINATIONN2'); $widthlo = Configuration::get('COUNTDOWNSPECIALS_WIDTH'); $slidercs = Configuration::get('COUNTDOWNSPECIALS_SLIDERCS'); $delaycs = Configuration::get('COUNTDOWNSPECIALS_DELAYCS'); $psversion = _PS_VERSION_; $enabledp = Configuration::get('COUNTDOWNSPECIALS_ENABLEDP'); $disabledp = Configuration::get('COUNTDOWNSPECIALS_DISABLEDP'); if ($psversion < "1.4.0.0") { $pricesDrop = CountdownSpecials::getPricesDropshea(intval($cookie->id_lang), $pageNumber = 0, 10, $count = false, $orderBy = NULL, $orderWay = NULL, $beginning = 1, $ending = 10); } else { $pricesDrop = CountdownSpecials::getPricesDrop2header(intval($cookie->id_lang), $pageNumber = 0, 10, $count = false, $orderBy = NULL, $orderWay = NULL, $beginning = 1, $ending = 10); } $prices_Drop = array(); if ($pricesDrop) foreach ($pricesDrop AS $priceDrop) $productsdd[] = $priceDrop; return $productsdd; } function hookHeader($params) { global $smarty, $cookie, $currentDate, $psversion, $productsd, $context, $productsdd, $slidercs, $productlist; mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_) or die(mysql_error()); mysql_query("SET NAMES UTF8"); //this is needed for UTF 8 characters - multilanguage mysql_select_db(_DB_NAME_) or die(mysql_error()); if (_PS_VERSION_ > "1.5.0.0") { if (!$context) $context = Context::getContext(); } $front = true; $styletime = Configuration::get('COUNTDOWNSPECIALS_STYLETIME'); $pagination = Configuration::get('COUNTDOWNSPECIALS_PAGINATION'); $colorp = Configuration::get('COUNTDOWNSPECIALS_COLORP'); $fsp = Configuration::get('COUNTDOWNSPECIALS_FSP'); $paginationn = Configuration::get('COUNTDOWNSPECIALS_PAGINATIONN'); $pagination2 = Configuration::get('COUNTDOWNSPECIALS_PAGINATION2'); $paginationn2 = Configuration::get('COUNTDOWNSPECIALS_PAGINATIONN2'); $widthlo = Configuration::get('COUNTDOWNSPECIALS_WIDTH'); $slidercs = Configuration::get('COUNTDOWNSPECIALS_SLIDERCS'); $delaycs = Configuration::get('COUNTDOWNSPECIALS_DELAYCS'); $psversion = _PS_VERSION_; $enabledp = Configuration::get('COUNTDOWNSPECIALS_ENABLEDP'); $disabledp = Configuration::get('COUNTDOWNSPECIALS_DISABLEDP'); if ($psversion < "1.4.0.0") { $pricesDrop = CountdownSpecials::getPricesDropshea(intval($params['cookie']->id_lang), $pageNumber = 0, 10, $count = false, $orderBy = NULL, $orderWay = NULL, $beginning = 1, $ending = 10); } else { $pricesDrop = CountdownSpecials::getPricesDrop2header(intval($params['cookie']->id_lang), $pageNumber = 0, 10, $count = false, $orderBy = NULL, $orderWay = NULL, $beginning = 1, $ending = 10); } $prices_Drop = array(); if ($pricesDrop) foreach ($pricesDrop AS $priceDrop) $productsdd[] = $priceDrop; /* $id_product = intval(Tools::getValue('id_product')); $product = new Product($id_product, true, intval($cookie->id_lang));*/ /*disable products*/ if ($enabledp == 1) { if ($psversion > "1.4.0.0" && $psversion < "1.5.0.0") { $currentDate = date('Y-m-d H:i:s'); $sorgudc = mysql_query(' SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name, sp.`from` AS reduction_from, sp.`to` AS reduction_to, sp.`id_product` FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'specific_price` sp ON (p.`id_product` = sp.`id_product`) LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . intval($params['cookie']->id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . intval($params['cookie']->id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = ' . (int) Country::getDefaultCountryId() . ' AND tr.`id_state` = 0) LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = tr.`id_tax`) LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) WHERE 1 AND sp.`from` < sp.`to` AND p.`active` = 1 AND sp.`to` < "' . pSQL($currentDate) . '"'); } if ($psversion > "1.5.0.0") { if (!$context) $context = Context::getContext(); $currentDate = date('Y-m-d H:i:s'); $sorgudc = mysql_query(' SELECT p.*,ps.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name, sp.`from` AS reduction_from, sp.`to` AS reduction_to, sp.`id_product` FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'product_shop` ps ON (p.`id_product` = ps.`id_product`) LEFT JOIN `' . _DB_PREFIX_ . 'specific_price` sp ON (p.`id_product` = sp.`id_product`) LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . intval($params['cookie']->id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . intval($params['cookie']->id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = ' . Context::getContext()->country->id . ' AND tr.`id_state` = 0) LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = tr.`id_tax`) LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) WHERE 1 AND sp.`from` < sp.`to` AND p.`active` = 1 AND ps.`id_shop` = ' . $context->shop->id . ' AND pl.`id_shop` = ' . $context->shop->id . ' AND sp.`to` < "' . pSQL($currentDate) . '"'); } if ($psversion < "1.4.0.0") { $currentDate = date('Y-m-d H:i:s'); $sorgudc = mysql_query('SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name` FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . intval($params['cookie']->id_lang) . ') WHERE p.reduction_from < p.reduction_to AND p.reduction_to < \'' . pSQL($currentDate) . '\' AND p.`active` = 1'); } $veridc = mysql_fetch_assoc($sorgudc); do { $num_rows = mysql_num_rows($sorgudc); if ($num_rows != NULL) { Db::getInstance()->Execute("UPDATE `" . _DB_PREFIX_ . "product` SET `active` = '0' WHERE `" . _DB_PREFIX_ . "product`.`id_product` = " . @$veridc['id_product'] . ";"); if (_PS_VERSION_ > "1.5.0.0") { Db::getInstance()->Execute("UPDATE `" . _DB_PREFIX_ . "product_shop` SET `active` = '0' WHERE `" . _DB_PREFIX_ . "product_shop`.`id_product` = " . @$veridc['id_product'] . " AND `" . _DB_PREFIX_ . "product_shop`.`id_shop` = " . $context->shop->id . ";"); } } } while (@$veridc = mysql_fetch_assoc($sorgudc)); } /*enable them*/ if ($disabledp == 1) { if ($psversion > "1.4.0.0" && $psversion < "1.5.0.0") { $currentDate = date('Y-m-d H:i:s'); $sorgudc = mysql_query(' SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name, sp.`from` AS reduction_from, sp.`to` AS reduction_to, sp.`id_product` FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'specific_price` sp ON (p.`id_product` = sp.`id_product`) LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . intval($params['cookie']->id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . intval($params['cookie']->id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = ' . (int) Country::getDefaultCountryId() . ' AND tr.`id_state` = 0) LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = tr.`id_tax`) LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) WHERE 1 AND sp.`from` < sp.`to` AND p.`active` = 0 AND sp.`from` < "' . pSQL($currentDate) . '"'); } if ($psversion > "1.5.0.0") { if (!$context) $context = Context::getContext(); $currentDate = date('Y-m-d H:i:s'); $sorgudc = mysql_query(' SELECT p.*, ps.*,pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name, sp.`from` AS reduction_from, sp.`to` AS reduction_to, sp.`id_product` FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'product_shop` ps ON (p.`id_product` = ps.`id_product`) LEFT JOIN `' . _DB_PREFIX_ . 'specific_price` sp ON (p.`id_product` = sp.`id_product`) LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . intval($params['cookie']->id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . intval($params['cookie']->id_lang) . ') LEFT JOIN `' . _DB_PREFIX_ . 'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = ' . Context::getContext()->country->id . ' AND tr.`id_state` = 0) LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = tr.`id_tax`) LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) WHERE 1 AND sp.`from` < sp.`to` AND p.`active` = 0 AND ps.`id_shop` = ' . $context->shop->id . ' AND pl.`id_shop` = ' . $context->shop->id . ' AND sp.`from` < "' . pSQL($currentDate) . '"'); } if ($psversion < "1.4.0.0") { $currentDate = date('Y-m-d H:i:s'); $sorgudc = mysql_query('SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name` FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . intval($params['cookie']->id_lang) . ') WHERE p.reduction_from < p.reduction_to AND p.reduction_from < \'' . pSQL($currentDate) . '\' AND p.`active` = 0'); } $veridc = mysql_fetch_assoc($sorgudc); do { $num_rows = mysql_num_rows($sorgudc); if ($num_rows != NULL) { Db::getInstance()->Execute("UPDATE `" . _DB_PREFIX_ . "product` SET `active` = 1 WHERE `" . _DB_PREFIX_ . "product`.`id_product` = " . @$veridc['id_product'] . ";"); if (_PS_VERSION_ > "1.5.0.0") { Db::getInstance()->Execute("UPDATE `" . _DB_PREFIX_ . "product_shop` SET `active` = 1 WHERE `" . _DB_PREFIX_ . "product_shop`.`id_product` = " . @$veridc['id_product'] . " AND `" . _DB_PREFIX_ . "product_shop`.`id_shop` = " . $context->shop->id . ";"); } } } while ($veridc = mysql_fetch_assoc($sorgudc)); } $special = Product::getRandomSpecial((int) ($params['cookie']->id_lang)) AND !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY'); $smarty->assign(array( 'pagination' => $pagination, 'paginationn' => $paginationn, 'pagination2' => $pagination2, 'styletime' => $styletime, 'paginationn2' => $paginationn2, 'psversion' => $psversion, 'colorpcs' => $colorp, 'fsp' => $fsp, 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2), 'special' => $special, 'widthlo' => $widthlo, 'slidercs' => $slidercs, 'delaycs' => $delaycs )); if (_PS_VERSION_ > "1.4.0.0" && _PS_VERSION_ < "1.5.0.0") { Tools::addJS(__PS_BASE_URI__ . 'modules/countdownspecials/js/ticker.js'); Tools::addJS(__PS_BASE_URI__ . 'modules/countdownspecials/jquery.countdown.js'); Tools::addCSS(__PS_BASE_URI__ . 'modules/countdownspecials/jquery.countdown.css', 'all'); Tools::addJS(__PS_BASE_URI__ . 'modules/countdownspecials/js/fadeSlideShow.js'); } if (_PS_VERSION_ > "1.5.0.0") { $this->context->controller->addJS(($this->_path) . 'js/ticker.js'); $this->context->controller->addJS(($this->_path) . 'jquery.countdown.js'); $this->context->controller->addCSS(($this->_path) . '' . ((_PS_VERSION_ > "1.5.0.0") ? $this->context->shop->id : '') . 'jquery.countdown.css', 'all'); $this->context->controller->addJS(($this->_path) . 'js/fadeSlideShow.js'); } if ($pagination == "yes" && _PS_VERSION_ > "1.4.0.0" && _PS_VERSION_ < "1.5.0.0") { Tools::addJS(__PS_BASE_URI__ . 'modules/countdownspecials/js/easypaginate.js'); Tools::addCSS(__PS_BASE_URI__ . 'modules/countdownspecials/style.css', 'all'); } if ($pagination == "yes" && _PS_VERSION_ > "1.5.0.0") { $this->context->controller->addJS(($this->_path) . 'js/easypaginate.js'); $this->context->controller->addCSS(($this->_path) . 'style.css', 'all'); } return $this->display(__FILE__, 'countdownspecials-header.tpl'); } function hookextraLeft($params) { return $this->hookextraRight($params); } function hookextraRight($params) { global $smarty, $cookie, $psversion, $styletime; $currentDate = date('Y-m-d H:i:s'); $styletime = Configuration::get('COUNTDOWNSPECIALS_STYLETIME'); $id_product = intval(Tools::getValue('id_product')); $psversion = _PS_VERSION_; if ($psversion < "1.4.0.0") { $results = Db::getInstance()->ExecuteS(' SELECT p.* FROM `' . _DB_PREFIX_ . 'product` p WHERE p.reduction_from < p.reduction_to AND p.reduction_from < \'' . pSQL($currentDate) . '\' AND p.reduction_to > \'' . pSQL($currentDate) . '\' AND p.id_product = ' . $id_product . ' LIMIT 1'); } else { $results = Db::getInstance()->ExecuteS(' SELECT p.*, sp.from AS reduction_from, sp.to AS reduction_to FROM `' . _DB_PREFIX_ . 'product` p LEFT JOIN `' . _DB_PREFIX_ . 'specific_price` sp ON (p.`id_product` = sp.`id_product`) WHERE sp.from <= sp.to AND sp.from <= \'' . pSQL($currentDate) . '\' AND sp.to >= \'' . pSQL($currentDate) . '\' AND p.id_product = ' . $id_product . ' LIMIT 1'); } $smarty->assign(array( 'results' => $results, 'id_product' => $id_product, 'styletime' => $styletime, 'psversion' => $psversion )); return $this->display(__FILE__, 'countdownspecials-product.tpl'); } public function displayFrontForm() { global $cookie, $smarty, $width3, $width3h, $sort, $beginning2, $ending2, $nbrpage, $productsd, $productd, $color2, $psversion, $id_lang, $styletime, $margin, $reduction_to, $reduction_from, $params; $styletime = Configuration::get('COUNTDOWNSPECIALS_STYLETIME'); $nbrpage = Configuration::get('COUNTDOWNSPECIALS_NBRPAGE'); $width3 = Configuration::get('COUNTDOWNSPECIALS_WIDTH3'); $width3h = Configuration::get('COUNTDOWNSPECIALS_WIDTH3H'); $margin = Configuration::get('COUNTDOWNSPECIALS_MARGIN'); $widthlo3 = Configuration::get('COUNTDOWNSPECIALS_WIDTH3'); $color2 = Configuration::get('COUNTDOWNSPECIALS_COLOR2'); $colorbg = Configuration::get('COUNTDOWNSPECIALS_COLORBG'); $align = Configuration::get('COUNTDOWNSPECIALS_ALIGN'); $grid = Configuration::get('COUNTDOWNSPECIALS_GRID'); $delaycs = Configuration::get('COUNTDOWNSPECIALS_DELAYCS'); $rad = Configuration::get('COUNTDOWNSPECIALS_RAD'); $listw = Configuration::get('COUNTDOWNSPECIALS_LISTW'); $imagesizeh = Configuration::get('COUNTDOWNSPECIALS_IMAGESIZEH'); $imageh = Configuration::get('COUNTDOWNSPECIALS_IMAGEH'); $psversion = _PS_VERSION_; if ($psversion < "1.4.0.0") { $pricesDrop = CountdownSpecials::getPricesDropsh((int) ($cookie->id_lang), $pageNumber = 0, $nbrpage, $count = false, $orderBy = $sort, $orderWay = NULL, $beginning = $beginning2, $ending = $ending2); } else { $pricesDrop = CountdownSpecials::getPricesDrop2((int) ($cookie->id_lang), $pageNumber = 0, $nbrpage, $count = false, $orderBy = $sort, $orderWay = NULL, $beginning = $beginning2, $ending = $ending2); } $prices_Drop = array(); if ($pricesDrop) foreach ($pricesDrop AS $priceDrop) $productsd[] = $priceDrop; $smarty->assign(array( 'productsd' => $productsd, 'color2' => $color2, 'widthlo3' => $widthlo3, 'margin' => $margin, 'styletime' => $styletime, 'psversion' => $psversion, 'align' => $align, 'width3' => $width3, 'width3h' => $width3h, 'delaycs' => $delaycs, 'grid' => $grid, 'colorbg' => $colorbg, 'rad' => $rad, 'listw' => $listw, 'imagesizeh' => $imagesizeh, 'imageh' => $imageh )); return $this->display(__FILE__, 'countdownspecials-page.tpl'); } public function hookFooter($params) { global $cookie, $smarty, $width3, $width3h, $sort, $beginning2, $ending2, $nbrpage, $productsd, $productd, $color2, $psversion, $id_lang, $styletime, $margin, $reduction_to, $reduction_from, $params; return $this->display(__FILE__, 'countdownspecials-footer.tpl'); } } } ?> Im found a code from module, and inside have a code for sorting... What part of this code i must use, and where to place? Modules/BlockNewProducts/ ? Thanks Link to comment Share on other sites More sharing options...
MilenkovicPetar Posted June 10, 2014 Author Share Posted June 10, 2014 Check lines #2715 and #2719 Link to comment Share on other sites More sharing options...
Recommended Posts