<?php
/**
  @licence GPL 2005-2011  The osCSS developers - osCSS Open Source E-commerce
  @portion code Copyright (c) 2002 osCommerce
  @package osCSS-2 <www http://www.oscss.org>
  @version 2.1.0
  @date  23/01/11, 16:28
  @author oscim <mail aurelien@oscim.fr> <www http://www.oscim.fr>
  @encode UTF-8
*/
?>
<div id="checkoutPayment" class="orderProcess">
  <?php $boxe =$page->oscss_boxes->_return('checkout_progressbar'); ?>
  <?php echo unhtmlentities($boxe->content) ?>

  <?php echo $payment_modules->javascript_validation(); ?>

  <h2 class="content title <?php echo $language ;?>"><?php echo HEADING_TITLE; ?></h2>

  <?php echo tep_draw_form('checkout_payment', tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'), 'post', 'onsubmit="return check_form();"'); ?>

  <?php /** Retour des erreurs */
    if (isset($_GET['payment_error']) && is_object(${$_GET['payment_error']}) && ($error = ${$_GET['payment_error']}->get_error())) { ?>
    <div class="alert">
      <p class="infoText"><?php echo tep_output_string_protected($error['title']); ?></p>
      <p class="infoText"><?php echo tep_output_string_protected($error['error']); ?></p>
    </div>
  <?php  } ?>


  <div class="contentBox billingAddress">

    <h3><?php echo TABLE_HEADING_BILLING_ADDRESS; ?></h3>
      <p><?php echo TEXT_SELECTED_BILLING_DESTINATION; ?></p>

    <h4><?php echo TITLE_BILLING_ADDRESS; ?></h4>
      <p class="currentAdress"><?php echo tep_address_label($customer_id, $billto, true, ' ', '<br />'); ?></p>
      <p><?php echo '<a class="navBtMini" href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, '', 'SSL') . '">' . IMAGE_BUTTON_CHANGE_ADDRESS . '</a>'; ?></p>

  </div>


  <div class="contentBox paymentMethod">

    <h3><?php echo TABLE_HEADING_PAYMENT_METHOD; ?></h3>

    <?php if (sizeof($selection) > 1): ?>
      <p class="textInfo"><?php echo TEXT_SELECT_PAYMENT_METHOD; ?></p>
    <?php else: ?>
      <p class="textInfo"><?php echo TEXT_ENTER_PAYMENT_INFORMATION; ?></p>
    <?php endif; ?>


    <ul class="listSelect listModules">
      <?php for ($i=0, $n=sizeof($selection); $i<$n; $i++): ?>
	<li class="methodSelect nameModule" onmouseover="this.id='mouseOver';" onmouseout="this.id='mouseOutpost';">
	  <label for="payment<?php echo $i; ?>">
	    <span class="methodName"><?php echo $selection[$i]['module']; ?></span>
	    <span class="methodIcon"><?php if (isset($selection[$i]['icon']) && tep_not_null($selection[$i]['icon'])) { echo $selection[$i]['icon']; } ?></span>
	  </label>

	  <?php if (sizeof($selection) > 1)  echo '<span class="radioBt">'.tep_draw_radio_field('payment','payment'.$i, $selection[$i]['id']) .'</span>'. "\n";
	      else  echo tep_draw_hidden_field('payment', $selection[$i]['id']). "<br />\n"; ?>

	  <?php /** Erreur module */  if (isset($selection[$i]['error'])) : ?>

	    <p class="paymentError"><?php echo $selection[$i]['error']; ?></p>

	  <?php elseif (isset($selection[$i]['fields']) && is_array($selection[$i]['fields'])) :
	      for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) {  ?>

	    <p class="paymentFields" >
	      <label><?php echo $selection[$i]['fields'][$j]['title']; ?></label>
	      <?php echo $selection[$i]['fields'][$j]['field'] . "\n"; ?>
	    </p>
	  <?php } endif; $radio_buttons++; ?>
	</li>
      <?php endfor; // for ($i=0, $n=sizeof($selection); $i<$n; $i++)  ?>
    </ul>
  </div>

      <p class="checkoutComment">
        <label for="comment"><?php echo TABLE_HEADING_COMMENTS; ?></label>
        <?php echo tep_draw_textarea_field('comments', 'comment', '48', '5'); ?>
      </p>

      <?php if( _cst_bool('MODULE_ORDER_TOTAL_DISCOUNT_COUPON_STATUS')) { ?>
        <p class="checkoutcoupon">
        <label for="coupon"><?php echo ENTRY_DISCOUNT_COUPON; ?></label>
        <?php
            /**
              Propose une liste de coupon possibe secifique pour le client
            */
              $check_user_query = tep_db_query( $sql = 'SELECT dc.coupons_discount_amount, dc2u.coupons_id  FROM '.TABLE_DISCOUNT_COUPONS.' dc, '.TABLE_DISCOUNT_COUPONS_TO_CUSTOMERS.' dc2u WHERE dc.coupons_id=dc2u.coupons_id and  dc2u.customers_id='.(int)$customer_id.' AND in_out=\'I\' ' );
            if( tep_db_num_rows( $check_user_query ) > 0 ) {
              echo "<ul>";
                while($v = tep_db_fetch_array( $check_user_query ) ):  ?>
                  <li><?php echo ''.tep_draw_radio_field('coupon','coupon', $v['coupons_id']) .'<span>'. $v['coupons_id'].'</span> <span>'.$v['coupons_discount_amount'].'</span>'; ?></li>
                <?php endwhile;
              echo "</ul>";
            } else echo tep_draw_input_field('coupon','coupon', '', 'size="32"');
	    ?>
        </p>
	<p id="checkoutcouponerror" class="warning"><?php if(isset($_GET['error_message'])) echo $_GET['error_message'] ?></p>
      <?php } ?>

      <fieldset>
        <legend><?php echo CHECKOUT_CGV ;?></legend>

        <label for="conditions"><?php echo TEXT_CONDITIONS ;?></label>
        <input name="conditions" id="conditions" type="checkbox" <?php echo isset($_GET['consult_conditions']) ? 'checked="checked"' : '' ;?> />
      </fieldset>

    <p class="formBt ieExtractFieldset">
      <?php echo TITLE_CONTINUE_CHECKOUT_PROCEDURE ;?>
       <input type="submit" class="submitBt" value="<?php echo IMAGE_BUTTON_CONTINUE; ?>"  />
      </p>

  </form>

</div>