<?php
// RCI code start
echo $cre_RCI->get('global', 'top');
echo $cre_RCI->get('gvsend', 'top');
// RCI code eof
?>      
<h1 class="no-margin-top"><?php echo HEADING_TITLE; ?></h1>
<table border="0" width="100%" cellspacing="0" cellpadding="<?php echo CELLPADDING_SUB; ?>">
<?php
  if ($_GET['action'] == 'process') {
?>
      <tr>
        <td class="main"><?php echo TEXT_SUCCESS; ?><br><br><?php echo 'gv '.$id1; ?></td>
      </tr>
      <tr>
        <td align="right"><br><a href="<?php echo tep_href_link(FILENAME_DEFAULT, '', 'NONSSL'); ?>"><button class="pull-left btn btn-lg btn-default" type="button"><?php echo IMAGE_BUTTON_CONTINUE; ?></button></a></td>
      </tr>
<?php
  }  
  if ($_GET['action'] == 'send' && !$error) {
    // validate entries
      $gv_amount = (double) $gv_amount;
      $gv_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . $_SESSION['customer_id'] . "'");
      $gv_result = tep_db_fetch_array($gv_query);
      $send_name = $gv_result['customers_firstname'] . ' ' . $gv_result['customers_lastname'];
?>
      <tr>
        <td><form action="<?php echo tep_href_link(FILENAME_GV_SEND, 'action=process', 'NONSSL'); ?>" method="post"><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr>
            <td class="main"><?php echo sprintf(MAIN_MESSAGE, $currencies->format($_POST['amount']), $_POST['to_name'], $_POST['email'], $_POST['to_name'], $currencies->format($_POST['amount']), $send_name); ?></td>
          </tr>
<?php
      if ($_POST['message']) {
?>
           <tr>
            <td class="main"><?php echo sprintf(PERSONAL_MESSAGE, $gv_result['customers_firstname']); ?></td>
          </tr>
          <tr>
            <td class="main"><?php echo stripslashes($_POST['message']); ?></td>
          </tr>
<?php
      }

      // RCI code start
      echo $cre_RCI->get('gvsend', 'menu');
      // RCI code eof
      echo tep_draw_hidden_field('send_name', $send_name) . tep_draw_hidden_field('to_name', stripslashes($_POST['to_name'])) . tep_draw_hidden_field('email', $_POST['email']) . tep_draw_hidden_field('amount', $gv_amount) . tep_draw_hidden_field('message', stripslashes($_POST['message']));
?>
          <tr>
            <td class="main"></td>
            <td align="right"><button class="pull-right btn btn-lg btn-primary" type="submit"><?php echo IMAGE_BUTTON_CONTINUE; ?></button></td>
          </tr>
        </table></form></td>
      </tr>
<?php
  } elseif ($_GET['action']=='' || $error) {
?>
      <tr>
        <td class="main"><?php echo HEADING_TEXT; ?></td>
      </tr>
      <tr>
        <td><form action="<?php echo tep_href_link(FILENAME_GV_SEND, 'action=send', 'NONSSL'); ?>" method="post">
        <table border="0" width="100%" cellspacing="0" cellpadding="2" class="table-condensed">
          <tr>
            <td class="main"><?php echo ENTRY_NAME; ?><br><?php echo tep_draw_input_field('to_name', stripslashes($_POST['to_name']), 'class="form-control"');?></td>
          </tr>
          <tr>
            <td class="main"><?php echo ENTRY_EMAIL; ?><br><?php echo tep_draw_input_field('email', $_POST['email'], 'class="form-control"'); if ($error) echo $error_email; ?></td>
          </tr>
          <tr>
            <td class="main"><?php echo ENTRY_AMOUNT; ?><br><?php echo tep_draw_input_field('amount', $_POST['amount'], 'class="form-control"', '', false); if ($error) echo $error_amount; ?></td>
          </tr>
          <tr>
            <td class="main"><?php echo ENTRY_MESSAGE; ?><br><?php echo tep_draw_textarea_field('message', 'soft', 50, 15, stripslashes($_POST['message']), 'class="form-control"'); ?></td>
          </tr>
        </table>
        <table border="0" width="100%" cellspacing="0" cellpadding="2" style="padding-top:10px;">
          <?php
          // RCI code start
          echo $cre_RCI->get('gvsend', 'menu');
          // RCI code eof
          $back = sizeof($navigation->path)-2;
          ?>
          <tr>
            <td class="main"><?php echo '<a href="' . tep_href_link($navigation->path[$back]['page'], tep_array_to_string($navigation->path[$back]['get'], array('action')), $navigation->path[$back]['mode']) . '"><button class="pull-left btn btn-lg btn-default" type="button">'. IMAGE_BUTTON_BACK .'</button></a>'; ?></td>
            <td class="main" align="right"><button class="pull-right btn btn-lg btn-primary" type="submit"><?php echo IMAGE_BUTTON_CONTINUE; ?></button></td>
          </tr>
        </table></form></td>
      </tr>
<?php
  }
?>
    </table></td>
<?php
// RCI code start
echo $cre_RCI->get('gvsend', 'bottom');
echo $cre_RCI->get('global', 'bottom');
// RCI code eof
?>
