Portail PHP

Forum de discussion et d'aide au php

Vous n'êtes pas identifié.

Annonce

Regles d'utilisation des forums : pensez à toujours les respecter si vous désirez obtenir des réponses rapides.
FAQ : pensez à toujours chercher dedans si la réponse à votre question est dedans.
Proposez vos news : si vous avez un evenement à annoncer
le chat : venez discuter de php.
 

#1 25-02-2008 05:56:08

badibad
Membre
Date d'inscription: 25-02-2008
Messages: 2

Je suis desesperer impossible de fair macher ce compte à rebours

AUTO RESOLUE



Bonjour je vous contact car je suis desesperer j'ai un site oscommerce creload et j'ai installer une contrib pour fair des vente flash tous fonctionne bien mais voilla. 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/

Code:

// ##################### 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,$jbeginnin­g_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


Code:

<?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

Code:

$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 ++;
    }
  }

Je ne sais plus comment fait au lieu d'avoir un compte à rebours du genre 5 jour 3 heure 5 min 55s j'ai 1 janvier 1970 qui s'affiche. De plus je suis super nul en php.


voici le fichier en entier

Code:

<?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 //-->

Merci de l'aide.

Dernière modification par badibad (28-02-2008 06:52:13)

Hors ligne

 

#2 27-02-2008 09:19:08

badibad
Membre
Date d'inscription: 25-02-2008
Messages: 2

Re: Je suis desesperer impossible de fair macher ce compte à rebours

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

Hors ligne