Ce module permet d'afficher un nombre de produits en ventes flash.

Ce nombre est défini à partir de la configuration du module et est initialisé dans blockventeflash.php ligne 33:
Configuration::updateValue('BLOCKVENTEFLASH_NB_CACHES', 3);

Le module seul affichera des ventes flash sur la page d'accueil uniquement. Pour l'étendre, il faut:
    * Pour voir les ventes flash dans la fiche produit:
        - surcharger controller/front/ProductController.php dans override/controllers/front/ProductController.php
        - modifier la vue themes/default-bootstrap/product.tpl
    * Pour voir les ventes flash dans une catégorie de produit: 
        - surcharger controller/front/CategoryController.php dans override/controllers/front/CategoryController.php
        - modifier la vue themes/default-bootstrap/product-list.tpl


-----------------------------------------------------------------------------------------------------------
ProductController.php:
<?php
/*
*  @author Comevents (Adrien)
*/
class ProductController extends ProductControllerCore
{  
  
  // On surcharge la fonction initContent pour pouvoir envoyer à la vue les produits similaires
  public function initContent(){
    // Ajout du temps restant au produit
    $today = new DateTime(); // Maintenant
    
    // print '<pre>'; print_r($this->product->specificPrice); print '</pre>';die(); // DEBUG
    
    $fin_flash  = new DateTime($this->product->specificPrice[to]); // Moment de la fin de la vente flash
    $tps_restant = $fin_flash->diff($today);

    // Stock séparemment le temps restant en jour, heure,minute,seconde pour les traiter dans le javascript de la vue
    $tab_tps_restant = array();
    $tab_tps_restant['jour'] = $tps_restant->format('%d');
    $tab_tps_restant['heure'] = $tps_restant->format('%h');
    $tab_tps_restant['minute'] = $tps_restant->format('%i');
    $tab_tps_restant['seconde'] = $tps_restant->format('%s');

    
    $this->context->smarty->assign(array(
        'tabtpsrestant'  =>  $tab_tps_restant,
    ));
    
    parent::initContent();
  }
  
}
-----------------------------------------------------------------------------------------------------------
product.tpl:
...
<!-- Vente flash -->
{if $product->vente_flash} 
<div class="vente_flash_txt">
    <p><strong>VENTE FLASH</strong> Plus que <strong id="defaultCountdown"></strong>
        <script type="text/javascript">
            {literal}
                $(function () {  
                    // Ajout du temps restant à maintenant pour le compte à rebours
                    var today = new Date();
                    var sale_end = new Date(today);
                    // Jour
                    j = "{/literal}{$tabtpsrestant['jour']}{literal}";
                    jour = parseInt(j);
                    sale_end.setDate(today.getDate()+ jour);
                    // Heure
                    h = "{/literal}{$tabtpsrestant['heure']}{literal}";
                    heure = parseInt(h);
                    sale_end.setHours(today.getHours()+ heure);
                    // Minute
                    m = "{/literal}{$tabtpsrestant['minute']}{literal}";
                    minute = parseInt(m);
                    sale_end.setMinutes(today.getMinutes()+ minute);
                    // Seconde
                    s = "{/literal}{$tabtpsrestant['seconde']}{literal}";
                    seconde = parseInt(s);
                    sale_end.setSeconds(today.getSeconds()+ seconde);
                    // Affichage du compte dans l'id defaultCountdown
                    $('#defaultCountdown').countdown({until: sale_end});
                });
            {/literal}
        </script> 
    </p>
</div>
{/if}
<!-- FIN Vente Flash -->
...

-----------------------------------------------------------------------------------------------------------
CategoryController.php:
<?php
/*
*  @author Comevents (Adrien)
*/

class CategoryController extends CategoryControllerCore
{
	public function initContent()
	{
    parent::initContent();
    
    $products = (isset($this->cat_products) && $this->cat_products) ? $this->cat_products : null;
    
		$i = 0;
    $tab_tps_restant = array();
    foreach($products as $product){
      // Ajout du temps restant au produit
      $today = new DateTime(); // Maintenant
      $fin_flash  = new DateTime($product[specific_prices][to]); // Moment de la fin de la vente flash
      $tps_restant = $fin_flash->diff($today);

      // Stock séparemment le temps restant en jour, heure,minute,seconde pour les traiter dans le javascript de la vue
      $tmp = array();
      $tmp['jour'] = $tps_restant->format('%d');
      $tmp['heure'] = $tps_restant->format('%h');
      $tmp['minute'] = $tps_restant->format('%i');
      $tmp['seconde'] = $tps_restant->format('%s');

      array_push($tab_tps_restant, $tmp);
      $i++;
    }
    
    //print '<pre>'; print_r($tab_tps_restant); print '</pre>';die();
    
    $this->context->smarty->assign(array(
        'tabtpsrestant'  =>  $tab_tps_restant,
    ));
    
    
	}
}


-----------------------------------------------------------------------------------------------------------
product-list.tpl:
... 
A METTRE AVANT LE FOREACH DES PRODUITS ({foreach from=$products item=product name=products})
{assign var="i" value=0}
...
<!-- Vente Flash -->
{if isset($product.vente_flash) && $product.vente_flash==1 && isset($product.reduction) && $product.reduction}
    <span class="flash_sale"></span>
    <!-- Compte à rebours -->
    <span class="decompte_list">
        Plus que <strong id="defaultCountdown{$i}"></strong>
        <script type="text/javascript">
            {literal}
                $(function () {  
                    // Ajout du temps restant à maintenant pour le compte à rebours
                    var today = new Date();
                    var sale_end = new Date(today);
                    // Jour
                    j = "{/literal}{$tabtpsrestant[$i]['jour']}{literal}";
                    jour = parseInt(j);
                    sale_end.setDate(today.getDate()+ jour);
                    // Heure
                    h = "{/literal}{$tabtpsrestant[$i]['heure']}{literal}";
                    heure = parseInt(h);
                    sale_end.setHours(today.getHours()+ heure);
                    // Minute
                    m = "{/literal}{$tabtpsrestant[$i]['minute']}{literal}";
                    minute = parseInt(m);
                    sale_end.setMinutes(today.getMinutes()+ minute);
                    // Seconde
                    s = "{/literal}{$tabtpsrestant[$i]['seconde']}{literal}";
                    seconde = parseInt(s);
                    sale_end.setSeconds(today.getSeconds()+ seconde);
                    // Affichage du compte à rebours à l'id defaultCountdown
                    $('#defaultCountdown{/literal}{$i}{literal}').countdown({until: sale_end});
                });
            {/literal}
        </script>
    </span>
    <!-- FIN Compte à rebours -->
{/if}
<!-- FIN Vente Flash -->
...
A METTRE AVANT LA FIN DU FOREACH
{assign var="i" value=$i+1}
{/foreach}
-----------------------------------------------------------------------------------------------------------

