Probleme de compte à rebours

[Fermé]
Signaler
-
 badibad -
Bonjour,
Je suis en oscommerce creload et j'ai installer flash disciunt 2.9. Je voulai mettre un compte à rebours dans le boxe flash selling de la page principale alors j'ai créer ce fichier dans includes/modules/mainpage_modules/



  
<?php
/*
  $Id: default_specials.php,v 2.0 2003/06/13

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/


// ##################### Added Flash Selling ##################

$new_price = tep_get_products_special_price($product_info['products_id']);
$status_flash_selling = tep_get_products_special_status_flash_selling($product_info['products_id']);
$status_special = tep_get_products_special_status_flash($product_info['products_id']);
$special_flash_selling_end_date = tep_get_products_special_flash_selling_end_date($product_info['products_id']);
$special_flash_selling_end_date1 = tep_get_products_special_flash_selling_end_date($product_info['products_id']);

$jend_days = substr($special_flash_selling_end_date1,8,2); // le jour
$jend_month = substr($special_flash_selling_end_date1,5,2); // puis le mois 
$jend_year = substr($special_flash_selling_end_date1,0,4); // et l\'annee 
$jend_hour = substr($special_flash_selling_end_date1,11,2); // et l\'heure
$jend_minute = substr($special_flash_selling_end_date1,14,2); // et la minute 
$jend_second = substr($special_flash_selling_end_date1,17,2); // et la seconde

$timestamp_end_flash_selling_date = mktime($jend_hour,$jend_minute,$jend_second,$jend_month,$jend_days,$jend_year); 

// Flash discount start Date
$special_flash_selling_beginning_date = tep_get_products_special_flash_selling_beginning_date($product_info['products_id']);
$special_flash_selling_beginning_date1 = tep_get_products_special_flash_selling_beginning_date($product_info['products_id']);

$jbeginning_days = substr($special_flash_selling_beginning_date1,8,2); // le jour
$jbeginning_month = substr($special_flash_selling_beginning_date1,5,2); // puis le mois 
$jbeginning_year = substr($special_flash_selling_beginning_date1,0,4); // et l\'annee 
$jbeginning_hour = substr($special_flash_selling_beginning_date1,11,2); // et l\'heure
$jbeginning_minute = substr($special_flash_selling_beginning_date1,14,2); // et la minute 
$jbeginning_second = substr($special_flash_selling_beginning_date1,17,2); // et la seconde

$timestamp_beginning_flash_selling_date = mktime($jbeginning_hour,$jbeginning_minute,$jbeginning_second,$jbeginning_month,$jbeginning_days,$jbeginning_year); 

// Now
$today =time();


if ($status_flash_selling =='1'){
$new_price_flash_selling = tep_get_products_special_price_flash_selling($product_info['products_id']);
} else {
$new_price_flash_selling = 0;
}

if (($status_special =='0') && ($status_flash_selling =='0')) {
$products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
} elseif (($status_special =='0') && ($status_flash_selling =='1') && ($timestamp_end_flash_selling_date > $today) && ($timestamp_beginning_flash_selling_date < $today)) {
$products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s><br> <span class="productSpecialPrice">' . $currencies->display_price($new_price_flash_selling, tep_get_tax_rate($product_info['products_tax_class_id'])) . '<br> -'. round((($product_info['products_price'] - $new_price_flash_selling) / $product_info['products_price']) * 100, 0) . '% </span>';
} elseif (($status_special =='1') && ($status_flash_selling =='0')) {
$products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s><br> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '<br> -'. round((($product_info['products_price'] - $new_price) / $product_info['products_price']) * 100, 0) . '% </span>';
} elseif(($status_special =='1') && ($status_flash_selling =='1') && ($new_price > $new_price_flash_selling) && ($timestamp_end_flash_selling_date > $today) && ($timestamp_beginning_flash_selling_date < $today)) {
$products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s><br> <span class="productSpecialPrice">' . $currencies->display_price($new_price_flash_selling, tep_get_tax_rate($product_info['products_tax_class_id'])) . '<br> -'. round((($product_info['products_price'] - $new_price_flash_selling) / $product_info['products_price']) * 100, 0) . '% </span>';
} elseif(($status_special =='1') && ($status_flash_selling =='1') && ($timestamp_end_flash_selling_date < $today)) {
$products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s><br> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '<br> -'. round((($product_info['products_price'] - $new_price) / $product_info['products_price']) * 100, 0) . '% </span>';
} else {
$products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
} 
// ################# end Added Flash Selling ##################
?>
<!-- default_specials //-->

  <tr>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr>
         <?php // ############## Added Flash selling #############

$status_flash_selling = tep_get_products_flash_selling($product_info['products_id']);
if ($status_flash_selling == '1') {
?>
<tr>
<td class="" align="left" valign="top" colspan="2">



<?php


//Time to stp
$ecart_secondes = ($timestamp_end_flash_selling_date - $today);
$ecart_days = floor($ecart_secondes / (60*60*24)); 
$ecart_hour = floor($ecart_secondes / (60*60));
$ecart_minutes = floor($ecart_secondes / (60));

//Time to beginning
$ecart_secondes_beginning = ($timestamp_end_flash_start_date - $today);
$ecart_days_beginning = floor($ecart_secondes / (60*60*24)); 
$ecart_hour_beginning = floor($ecart_secondes / (60*60));
$ecart_minutes_beginning = floor($ecart_secondes / (60));
?>
<br/>
<?php 
if (($today > $timestamp_beginning_flash_selling_date) && ($today < $timestamp_end_flash_selling_date)) {
if (($special_flash_selling_end_date != '') && ($special_flash_selling_end_date != '0000-00-00 00:00:00') && ($timestamp_end_flash_selling_date > $today)) {
?>
<script>
function decompteur(jour,mois,annee,heure,minute,seconde) {
Resultat = "";
now = new Date();
goal = new Date(annee,mois-1,jour,heure,minute,seconde);

ts = Math.abs((now.getTime()/1000)-(goal.getTime()/1000));

if((goal.getTime()/1000) < (now.getTime()/1000)){
location.reload();
}

fjour = Math.floor(ts/(3600*24));
if(fjour<=1) {
Resultat = fjour + " jour ";
} else {
Resultat = fjour + " jours ";
}

ts = ts - (fjour*24*3600);
fheure = Math.floor((ts/3600));
if(fheure<10) {
Resultat += " 0" + fheure + "h ";
} else {
Resultat += " " + fheure + "h ";
}

ts = ts - (fheure*3600);
minutes = Math.floor((ts/60));
if(minutes<10) {
Resultat += "0" + minutes + "m ";
} else {
Resultat += minutes + "m ";
}

ts = ts - (minutes*60);
fseconde = Math.floor(ts);
if(fseconde<10) {
Resultat += "0" + fseconde + "s"
} else {
Resultat += fseconde + "s"
}
return Resultat
}

function startX() {
document.getElementById("countdown").innerHTML=decompteur(<?php echo $jend_days.','.$jend_month.','.$jend_year.','.$jend_hour.','.$jend_minute.','.$jend_second; ?>);
setTimeout("startX()",1000);
} 
window.onload = startX;
</script>

<?php 

echo tep_image_button('button_flash_selling.gif', IMAGE_BUTTON_FLASH_SELLING);
?>
&nbsp;
<span id= "countdown" type="text" disabled="disabled" class="boldText"></span>
<?php 

} 
}
?>
</td>
</tr>
<?php
} else {
if ($status_flash_selling == '0')
?>
<tr>
<td class="smallText" align="right" valign="top" colspan="2">
<?php
$special_flash_selling_end_date = tep_get_products_special_flash_selling_end_date($product_info['products_id']);
if (($special_flash_selling_end_date != '') && ($special_flash_selling_end_date != '0000-00-00 00:00:00')) {
echo '<span class="inputRequirement">' . TEXT_DATE_EXPIRE;
echo tep_date_long($special_flash_selling_end_date) . ' </span>';
}
?>
</td>
</tr>
<?php
}
?>

<?php // ############## End Added Flash selling ############# ?>

<?php
$info_box_contents = array();
  $info_box_contents[] = array('align' => 'left', 'text' => sprintf(TABLE_HEADING_DEFAULT_SPECIALS, strftime('%B')));
         

  new contentBoxHeading($info_box_contents, false, false, tep_href_link(FILENAME_FLASH_SELLING));

$new = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and s.status = '1' order by s.specials_date_added DESC limit " . MAX_DISPLAY_FLASH_SELLING_PRODUCT);
    
    

        
    
$info_box_contents = array();
  $row = 0;
  $col = 0;
  
  while ($default_specials = tep_db_fetch_array($new)) {
    $default_specials['products_name'] = tep_get_products_name($default_specials['products_id']);
    $info_box_contents[$row][$col] = array('align' => 'center',
                                           'params' => 'class="smallText" width="33%" valign="top"',
                                           'text' => BOX_FLASH_SELLING . '<br>' . tep_image(DIR_WS_IMAGES.'Horloge.gif') . '&nbsp;'.  $special_flash_selling_end_date =  tep_get_products_special_flash_selling_end_date($product_info['products_id']) .tep_date_long($special_flash_selling_end_date) .'<br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $default_specials["products_id"]) . '">' . tep_image(DIR_WS_IMAGES . $default_specials['products_image'], $default_specials['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $default_specials['products_id']) . '">' . $default_specials['products_name'] . '</a><br><s>' . $currencies->display_price($default_specials['products_price'], tep_get_tax_rate($default_specials['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($default_specials['specials_new_products_price'], tep_get_tax_rate($default_specials['products_tax_class_id'])) . '</span>');
    $col ++;
    if ($col > 2) {
      $col = 0;
      $row ++;
    }
  }
  new contentBox($info_box_contents);

if (MAIN_TABLE_BORDER == 'yes'){
$info_box_contents = array();
  $info_box_contents[] = array('align' => 'left',
                                'text'  => tep_draw_separator('pixel_trans.gif', '100%', '1')
                              );
  new infoboxFooter($info_box_contents, true, true);
}
?><!-- default_specials_eof //-->



Le probleme c'est qu'au lieu d'avoir (la vente ce termine dans 5 jours 5 h 5 min 5 s) j'ai la vente ce termine dans jeudi 01 janvier, 1970


j'espere que vous pourais m'aide car je ne sais plus comment fair et ca fait 1 semaine que je suis dessus.
merci

1 réponse

Messages postés
496
Date d'inscription
lundi 17 septembre 2007
Statut
Membre
Dernière intervention
22 juin 2010
123
Bonjour,

Yahou... y a du volume et... ce n'est pas tellement mon domaine. Je précise juste en passant que le 1er Janvier 1970 est la référence pour pas mal de fonctions de date. En C par exemple, time() revoit le nombre de secondes écoulées depuis le 1er Janvier 70. Tu affiches donc très certainement une date qui vaut 0, soit exactement le 1er Janvier 70. Après il est possible qu'elle ne soit pas initialisée ou alors tu oublies de mettre un intervalle de temps avant de soustraire deux dates.


M.
1
Merci

Quelques mots de remerciements seront grandement appréciés. Ajouter un commentaire

CCM 41989 internautes nous ont dit merci ce mois-ci

merci de ton aide

mais je ne comprend par car pourtant j'appel bien la fonction $special_flash_selling_end_date qui appel la date de fin de vente flash

bon je vais recommencer du debut j'ai rajoute ce code pour le calcule

// ##################### Added Flash Selling ##################

$new_price = tep_get_products_special_price($product_info['products_id']);
$status_flash_selling = tep_get_products_special_status_flash_selling($product_info['products_id']);
$status_special = tep_get_products_special_status_flash($product_info['products_id']);
$special_flash_selling_end_date = tep_get_products_special_flash_selling_end_date($product_info['products_id']);
$special_flash_selling_end_date1 = tep_get_products_special_flash_selling_end_date($product_info['products_id']);

$jend_days = substr($special_flash_selling_end_date1,8,2); // le jour
$jend_month = substr($special_flash_selling_end_date1,5,2); // puis le mois 
$jend_year = substr($special_flash_selling_end_date1,0,4); // et l\'annee 
$jend_hour = substr($special_flash_selling_end_date1,11,2); // et l\'heure
$jend_minute = substr($special_flash_selling_end_date1,14,2); // et la minute 
$jend_second = substr($special_flash_selling_end_date1,17,2); // et la seconde

$timestamp_end_flash_selling_date = mktime($jend_hour,$jend_minute,$jend_second,$jend_month,$jend_days,$jend_year); 

// Flash discount start Date
$special_flash_selling_beginning_date = tep_get_products_special_flash_selling_beginning_date($product_info['products_id']);
$special_flash_selling_beginning_date1 = tep_get_products_special_flash_selling_beginning_date($product_info['products_id']);

$jbeginning_days = substr($special_flash_selling_beginning_date1,8,2); // le jour
$jbeginning_month = substr($special_flash_selling_beginning_date1,5,2); // puis le mois 
$jbeginning_year = substr($special_flash_selling_beginning_date1,0,4); // et l\'annee 
$jbeginning_hour = substr($special_flash_selling_beginning_date1,11,2); // et l\'heure
$jbeginning_minute = substr($special_flash_selling_beginning_date1,14,2); // et la minute 
$jbeginning_second = substr($special_flash_selling_beginning_date1,17,2); // et la seconde

$timestamp_beginning_flash_selling_date = mktime($jbeginning_hour,$jbeginning_minute,$jbeginning_second,$jbeginning_month,$jbeginning_days,$jbeginning_year); 

// Now
$today =time();


if ($status_flash_selling =='1'){
$new_price_flash_selling = tep_get_products_special_price_flash_selling($product_info['products_id']);
} else {
$new_price_flash_selling = 0;
}

if (($status_special =='0') && ($status_flash_selling =='0')) {
$products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
} elseif (($status_special =='0') && ($status_flash_selling =='1') && ($timestamp_end_flash_selling_date > $today) && ($timestamp_beginning_flash_selling_date < $today)) {
$products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s><br> <span class="productSpecialPrice">' . $currencies->display_price($new_price_flash_selling, tep_get_tax_rate($product_info['products_tax_class_id'])) . '<br> -'. round((($product_info['products_price'] - $new_price_flash_selling) / $product_info['products_price']) * 100, 0) . '% </span>';
} elseif (($status_special =='1') && ($status_flash_selling =='0')) {
$products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s><br> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '<br> -'. round((($product_info['products_price'] - $new_price) / $product_info['products_price']) * 100, 0) . '% </span>';
} elseif(($status_special =='1') && ($status_flash_selling =='1') && ($new_price > $new_price_flash_selling) && ($timestamp_end_flash_selling_date > $today) && ($timestamp_beginning_flash_selling_date < $today)) {
$products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s><br> <span class="productSpecialPrice">' . $currencies->display_price($new_price_flash_selling, tep_get_tax_rate($product_info['products_tax_class_id'])) . '<br> -'. round((($product_info['products_price'] - $new_price_flash_selling) / $product_info['products_price']) * 100, 0) . '% </span>';
} elseif(($status_special =='1') && ($status_flash_selling =='1') && ($timestamp_end_flash_selling_date < $today)) {
$products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s><br> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '<br> -'. round((($product_info['products_price'] - $new_price) / $product_info['products_price']) * 100, 0) . '% </span>';
} else {
$products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
} 
// ################# end Added Flash Selling ##################



puis celui si pour compte à rebours

  <?php // ############## Added Flash selling #############

$status_flash_selling = tep_get_products_flash_selling($product_info['products_id']);
if ($status_flash_selling == '1') {
?>
<tr>
<td class="" align="left" valign="top" colspan="2">



<?php


//Time to stp
$ecart_secondes = ($timestamp_end_flash_selling_date - $today);
$ecart_days = floor($ecart_secondes / (60*60*24)); 
$ecart_hour = floor($ecart_secondes / (60*60));
$ecart_minutes = floor($ecart_secondes / (60));

//Time to beginning
$ecart_secondes_beginning = ($timestamp_end_flash_start_date - $today);
$ecart_days_beginning = floor($ecart_secondes / (60*60*24)); 
$ecart_hour_beginning = floor($ecart_secondes / (60*60));
$ecart_minutes_beginning = floor($ecart_secondes / (60));
?>
<br/>
<?php 
if (($today > $timestamp_beginning_flash_selling_date) && ($today < $timestamp_end_flash_selling_date)) {
if (($special_flash_selling_end_date != '') && ($special_flash_selling_end_date != '0000-00-00 00:00:00') && ($timestamp_end_flash_selling_date > $today)) {
?>
<script>
function decompteur(jour,mois,annee,heure,minute,seconde) {
Resultat = "";
now = new Date();
goal = new Date(annee,mois-1,jour,heure,minute,seconde);

ts = Math.abs((now.getTime()/1000)-(goal.getTime()/1000));

if((goal.getTime()/1000) < (now.getTime()/1000)){
location.reload();
}

fjour = Math.floor(ts/(3600*24));
if(fjour<=1) {
Resultat = fjour + " jour ";
} else {
Resultat = fjour + " jours ";
}

ts = ts - (fjour*24*3600);
fheure = Math.floor((ts/3600));
if(fheure<10) {
Resultat += " 0" + fheure + "h ";
} else {
Resultat += " " + fheure + "h ";
}

ts = ts - (fheure*3600);
minutes = Math.floor((ts/60));
if(minutes<10) {
Resultat += "0" + minutes + "m ";
} else {
Resultat += minutes + "m ";
}

ts = ts - (minutes*60);
fseconde = Math.floor(ts);
if(fseconde<10) {
Resultat += "0" + fseconde + "s"
} else {
Resultat += fseconde + "s"
}
return Resultat
}

function startX() {
document.getElementById("countdown").innerHTML=decompteur(<?php echo $jend_days.','.$jend_month.','.$jend_year.','.$jend_hour.','.$jend_minute.','.$jend_second; ?>);
setTimeout("startX()",1000);
} 
window.onload = startX;
</script>

<?php 

echo tep_image_button('button_flash_selling.gif', IMAGE_BUTTON_FLASH_SELLING) ;
?>
&nbsp;
<span id= "countdown" type="text" disabled="disabled" class="boldText"></span>
<?php 

} 
}
?>
</td>
</tr>
<?php
} else {
if ($status_flash_selling == '0')
?>
<tr>
<td class="smallText" align="right" valign="top" colspan="2">
<?php
$special_flash_selling_end_date = tep_get_products_special_flash_selling_end_date($product_info['products_id']);
if (($special_flash_selling_end_date != '') && ($special_flash_selling_end_date != '0000-00-00 00:00:00')) {
echo '<span class="inputRequirement">' . TEXT_DATE_EXPIRE ;
echo tep_date_long($special_flash_selling_end_date) . ' </span>';
}
?>
</td>
</tr>
<?php
}
?>

<?php // ############## End Added Flash selling ############# ?>




Puis j'ai modifier cette ligne est je suis sur que le probleme vient de la
  

'text' => BOX_FLASH_SELLING . '<br>' . tep_image(DIR_WS_IMAGES.'Horloge.gif') . '&nbsp;'.  $special_flash_selling_end_date =  tep_get_products_special_flash_selling_end_date($product_info['products_id']) .tep_date_long($special_flash_selling_end_date) .'<br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $default_specials["products_id"]) . '">' . tep_image(DIR_WS_IMAGES . $default_specials['products_image'], $default_specials['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $default_specials['products_id']) . '">' . $default_specials['products_name'] . '</a><br><s>' . $currencies->display_price($default_specials['products_price'], tep_get_tax_rate($default_specials['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($default_specials['specials_new_products_price'], tep_get_tax_rate($default_specials['products_tax_class_id'])) . '</span>');
    $col ++;






merci de votre aide
> badibad
bon j'y est passer, je ne sais pas combien de nuit blanche et j'ai beau tourner le probleme dans tout les sens je ni arrive pas. J'en appel à une bonne ame génereuse pour m'aider car je sais plus quoi fair.

merci