Commits

pickupman committed 26378e6

Inital commit

Comments (0)

Files changed (5)

.hgignore

Empty file added.

cron_gv_delay_send.php

+<?php
+/** 
+ * Cron job file for sending emails for Gift Voucher/Certificate at a specific time
+ * 
+ * @author Joe McFrederick
+ * @date   2012-02-28
+ * 
+ * @package ZenCart
+ * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
+ */
+//Load zencart
+require('includes/application_top.php');
+
+//Load gv_send language files
+$current_page_base = 'gv_send';
+$language_page_directory = DIR_WS_LANGUAGES .'english/';
+require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
+
+
+//Get GV that have not yet been sent
+$gifts_result = $db->Execute("SELECT cpe.*, c.coupon_amount, c.coupon_code FROM " . TABLE_COUPON_EMAIL_TRACK . " cpe, " . TABLE_COUPONS . " c WHERE cpe.coupon_id=c.coupon_id AND cpe.send_future = '1'");
+
+if ($gifts_result->RecordCount() > 0) {
+
+    //Loop through each voucher to send
+    while ( ! $gifts_result->EOF) {
+        
+        // build email content:
+          $gv_email = STORE_NAME . "\n" .
+          EMAIL_SEPARATOR . "\n" .
+          sprintf(EMAIL_GV_TEXT_HEADER, $currencies->format($gifts_result->fields['coupon_amount'], false)) . "\n" .
+          EMAIL_SEPARATOR . "\n\n" .
+          sprintf(EMAIL_GV_FROM, $send_name) . "\n";
+    
+          $html_msg['EMAIL_GV_TEXT_HEADER'] =  sprintf(EMAIL_GV_TEXT_HEADER, '');
+          $html_msg['EMAIL_GV_AMOUNT'] =  $currencies->format($gifts_result->fields['coupon_amount'], false);
+          $html_msg['EMAIL_GV_FROM'] =  sprintf(EMAIL_GV_FROM, $gifts_result->fields['sent_firstname']. ' ' .$gifts_result->fields['sent_lastname']) ;
+    
+          if (isset($gifts_result->fields['message'])) {
+            $gv_email .= EMAIL_GV_MESSAGE . "\n\n";
+            $html_msg['EMAIL_GV_MESSAGE'] = EMAIL_GV_MESSAGE . '<br />';
+
+            if (isset($gifts_result->fields['to_name'])) {
+              $gv_email .= sprintf(EMAIL_GV_SEND_TO, $gifts_result->fields['to_name']) . "\n\n";
+              $html_msg['EMAIL_GV_SEND_TO'] = '<tt>'.sprintf(EMAIL_GV_SEND_TO, $gifts_result->fields['to_name']). '</tt><br />';
+            }
+            $gv_email .= stripslashes($gifts_result->fields['message']) . "\n\n";
+            $gv_email .= EMAIL_SEPARATOR . "\n\n";
+            $html_msg['EMAIL_MESSAGE_HTML'] = stripslashes($gifts_result->fields['message']);
+          }
+    
+          $html_msg['GV_REDEEM_HOW'] = sprintf(EMAIL_GV_REDEEM, '<strong>' . $gifts_result->fields['coupon_code'] . '</strong>');
+          $html_msg['GV_REDEEM_URL'] = '<a href="'.zen_href_link(FILENAME_GV_REDEEM, 'gv_no=' . $gifts_result->fields['coupon_code'], 'NONSSL', false).'">'.EMAIL_GV_LINK.'</a>';
+          $html_msg['GV_REDEEM_CODE'] = $gifts_result->fields['coupon_code'];
+    
+          $gv_email .= sprintf(EMAIL_GV_REDEEM, $gifts_result->fields['coupon_code']) . "\n\n";
+          $gv_email .= EMAIL_GV_LINK . ' ' . zen_href_link(FILENAME_GV_REDEEM, 'gv_no=' . $gifts_result->fields['coupon_code'], 'NONSSL', false);
+          $gv_email .= "\n\n";
+          $gv_email .= EMAIL_GV_FIXED_FOOTER . "\n\n";
+          $gv_email .= EMAIL_GV_SHOP_FOOTER;
+    
+          $gv_email_subject = sprintf(EMAIL_GV_TEXT_SUBJECT, $gifts_result->fields['sent_firstname'] . ' ' .$gifts_result->fields['sent_lastname']);
+    
+          // include disclaimer
+          $gv_email .= "\n\n" . EMAIL_ADVISORY . "\n\n";
+    
+          $html_msg['EMAIL_GV_FIXED_FOOTER'] = str_replace(array("\r\n", "\n", "\r", "-----"), '', EMAIL_GV_FIXED_FOOTER);
+          $html_msg['EMAIL_GV_SHOP_FOOTER'] =	EMAIL_GV_SHOP_FOOTER;
+          
+          // send the email
+          zen_mail($gifts_result->fields['to_name'], $gifts_result->fields['emailed_to'], $gv_email_subject, nl2br($gv_email), STORE_NAME, EMAIL_FROM, $html_msg, 'gv_send');
+          
+          // Mark as send_future to 0
+          zen_db_perform(TABLE_COUPON_EMAIL_TRACK, array('send_future' => '0'), 'update', "unique_id='" . $gifts_result->fields['unique_id']. "'");
+
+        
+        $gifts_result->MoveNext();
+    }
+}
+
+//Tidy up before ending
+require('includes/application_bottom.php');

includes/modules/pages/gv_send/header_php.php

+<?php
+/**
+ * GV Send
+ *
+ * Used to allow customer to send GV to their friends/family by way of email.
+ * They can send up to the amount of GV accumlated in their account by way of purchased GV's or GV's sent to them.
+ *
+ * @package page
+ * @copyright Copyright 2003-2011 Zen Cart Development Team
+ * @copyright Portions Copyright 2003 osCommerce
+ * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
+ * @version $Id: header_php.php 18695 2011-05-04 05:24:19Z drbyte $
+ */
+
+// This should be first line of the script:
+$zco_notifier->notify('NOTIFY_HEADER_START_GV_SEND');
+if (isset($_POST['message'])) $_POST['message'] = zen_output_string_protected($_POST['message']);
+
+require_once('includes/classes/http_client.php');
+
+// verify no timeout has occurred on the send or process
+if (!$_SESSION['customer_id'] and ($_GET['action'] == 'send' or $_GET['action'] == 'process')) {
+  zen_redirect(zen_href_link(FILENAME_TIME_OUT));
+}
+
+// if the customer is not logged on, redirect them to the login page
+if (!$_SESSION['customer_id']) {
+  $_SESSION['navigation']->set_snapshot();
+  zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
+}
+
+require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
+
+if (isset($_POST['edit_x']) || isset($_POST['edit_y'])) {
+  $_GET['action'] = 'send';
+}
+
+// extract sender's name+email from database, since logged-in customer is the one who is sending this GV email
+  $account_query = "SELECT customers_firstname, customers_lastname, customers_email_address
+                    FROM " . TABLE_CUSTOMERS . "
+                    WHERE customers_id = :customersID";
+  $account_query = $db->bindVars($account_query, ':customersID', $_SESSION['customer_id'], 'integer');
+  $account = $db->Execute($account_query);
+  $send_name = $account->fields['customers_firstname'] . ' ' . $account->fields['customers_lastname'];
+  $send_firstname = $account->fields['customers_firstname'];
+
+$gv_query = "SELECT amount
+             FROM " . TABLE_COUPON_GV_CUSTOMER . "
+             WHERE customer_id = :customersID";
+
+$gv_query = $db->bindVars($gv_query, ':customersID', $_SESSION['customer_id'], 'integer');
+$gv_result = $db->Execute($gv_query);
+
+// Sanity Check
+// Some stuff for debugging
+// First let's get the local and base for how much the customer has in his GV account
+// The customer_gv account is always stored in the store's base currency
+//   $local_customer_gv = $currencies->value($gv_result->fields['amount']);
+//   $base_customer_gv = $gv_result->fields['amount'];
+// Now let's get the amount that the customer wants to send.
+//   $local_customer_send = $_POST['amount'];
+//   $base_customer_send = $currencies->value($_POST['amount'], true, DEFAULT_CURRENCY);
+
+
+if ($_GET['action'] == 'send') {
+  $_SESSION['complete'] = '';
+  $error = false;
+
+  if (isset($_POST['edit_x']) || isset($_POST['edit_y'])) {
+    $error = true;
+  }
+  if (!isset($_POST['to_name']) || trim($_POST['to_name']=='')) {
+    $error = true;
+    $messageStack->add('gv_send', ERROR_ENTRY_TO_NAME_CHECK, 'error');
+  }
+  if (!zen_validate_email(trim($_POST['email']))) {
+    $error = true;
+    $messageStack->add('gv_send', ERROR_ENTRY_EMAIL_ADDRESS_CHECK, 'error');
+  }
+  
+  // GV Delay Send BOF
+  if (isset($_POST['set_date_time']) AND ( ! isset($_POST['date']) OR ! isset($_POST['time']) OR date("Y-m-d H:i:s", strtotime($_POST['date'] . ' ' . $_POST['time'])) < date("Y-m-d H:i:s") )) {
+    $error = true;
+    $messageStack->add('gv_send', ERROR_ENTRY_DATE_TIME, 'error');
+  }
+  // GV Delay Send EOF
+
+  $customer_amount = $gv_result->fields['amount'];
+
+  $_POST['amount'] = str_replace('$', '', $_POST['amount']);
+
+  $gv_amount = trim($_POST['amount']);
+  if (preg_match('/[^0-9\.]/', $gv_amount)) {
+    $error = true;
+    $messageStack->add('gv_send', ERROR_ENTRY_AMOUNT_CHECK, 'error');
+  }
+  if ( $currencies->value($gv_amount, true,DEFAULT_CURRENCY) > $customer_amount || $gv_amount == 0) {
+    //echo $currencies->value($customer_amount, true,DEFAULT_CURRENCY);
+    $error = true;
+    $messageStack->add('gv_send', ERROR_ENTRY_AMOUNT_CHECK, 'error');
+  }
+}
+
+if ($_GET['action'] == 'process') {
+  if (!isset($_POST['back'])) { // customer didn't click the back button
+    $id1 = zen_create_coupon_code($mail['customers_email_address']);
+    // sanitize and remove non-numeric characters
+    $_POST['amount'] = preg_replace('/[^0-9.%]/', '', $_POST['amount']);
+
+    $new_amount = $gv_result->fields['amount'] - $currencies->value($_POST['amount'], true, DEFAULT_CURRENCY);
+    //die($currencies->value($_POST['amount'], true, $_SESSION['currency']));
+    $new_db_amount = $gv_result->fields['amount'] - $currencies->value($_POST['amount'], true, DEFAULT_CURRENCY);
+    if ($new_amount < 0) {
+      $error= true;
+      $messageStack->add('gv_send', ERROR_ENTRY_AMOUNT_CHECK, 'error');
+      $_GET['action'] = 'send';
+    } else {
+      $_GET['action'] = 'complete';
+      $gv_query="UPDATE " . TABLE_COUPON_GV_CUSTOMER . "
+                 SET amount = '" .  $new_amount . "'
+                 WHERE customer_id = :customersID";
+
+      $gv_query = $db->bindVars($gv_query, ':customersID', $_SESSION['customer_id'], 'integer');
+      $db->Execute($gv_query);
+
+      $gv_query="INSERT INTO " . TABLE_COUPONS . " (coupon_type, coupon_code, date_created, coupon_amount)
+                 VALUES ('G', :couponCode, NOW(), :amount)";
+
+      $gv_query = $db->bindVars($gv_query, ':couponCode', $id1, 'string');
+      $gv_query = $db->bindVars($gv_query, ':amount', $currencies->value($_POST['amount'], true, DEFAULT_CURRENCY), 'currency');
+      $gv = $db->Execute($gv_query);
+
+      $insert_id = $db->Insert_ID();
+      
+      // GV Delay Send BOF
+      if (isset($_POST['set_date_time']) AND isset($_POST['date']) AND isset($_POST['time'])) {
+        $date_sent = date("Y-m-d H:i:s", strtotime($_POST['date'] . ' ' . $_POST['time']));
+        $send_future = 1;
+      }
+      else
+      {
+        $date_sent = date("Y-m-d H:i:s");
+        $send_future = 0;
+      }
+      // GV Delay Send EOF
+
+      $gv_query="INSERT INTO " . TABLE_COUPON_EMAIL_TRACK . "(coupon_id, customer_id_sent, sent_firstname, sent_lastname, emailed_to, date_sent, send_future, message, to_name)
+                 VALUES (:insertID, :customersID, :firstname, :lastname, :email, '" . $date_sent ."', " . $send_future .", '" . zen_db_prepare_input($_POST['message']) . "', '" . zen_db_prepare_input($_POST['to_name']) . "')";
+
+      $gv_query = $db->bindVars($gv_query, ':insertID', $insert_id, 'integer');
+      $gv_query = $db->bindVars($gv_query, ':customersID', $_SESSION['customer_id'], 'integer');
+      $gv_query = $db->bindVars($gv_query, ':firstname', $account->fields['customers_firstname'], 'string');
+      $gv_query = $db->bindVars($gv_query, ':lastname', $account->fields['customers_lastname'], 'string');
+      $gv_query = $db->bindVars($gv_query, ':email', $_POST['email'], 'string');
+      $db->Execute($gv_query);
+
+      // build email content:
+      $gv_email = STORE_NAME . "\n" .
+      EMAIL_SEPARATOR . "\n" .
+      sprintf(EMAIL_GV_TEXT_HEADER, $currencies->format($_POST['amount'], false)) . "\n" .
+      EMAIL_SEPARATOR . "\n\n" .
+      sprintf(EMAIL_GV_FROM, $send_name) . "\n";
+
+      $html_msg['EMAIL_GV_TEXT_HEADER'] =  sprintf(EMAIL_GV_TEXT_HEADER, '');
+      $html_msg['EMAIL_GV_AMOUNT'] =  $currencies->format($_POST['amount'], false);
+      $html_msg['EMAIL_GV_FROM'] =  sprintf(EMAIL_GV_FROM, $send_name) ;
+
+      if (isset($_POST['message'])) {
+        $gv_email .= EMAIL_GV_MESSAGE . "\n\n";
+        $html_msg['EMAIL_GV_MESSAGE'] = EMAIL_GV_MESSAGE . '<br />';
+
+        if (isset($_POST['to_name'])) {
+          $gv_email .= sprintf(EMAIL_GV_SEND_TO, $_POST['to_name']) . "\n\n";
+          $html_msg['EMAIL_GV_SEND_TO'] = '<tt>'.sprintf(EMAIL_GV_SEND_TO, $_POST['to_name']). '</tt><br />';
+        }
+        $gv_email .= stripslashes($_POST['message']) . "\n\n";
+        $gv_email .= EMAIL_SEPARATOR . "\n\n";
+        $html_msg['EMAIL_MESSAGE_HTML'] = stripslashes($_POST['message']);
+      }
+
+      $html_msg['GV_REDEEM_HOW'] = sprintf(EMAIL_GV_REDEEM, '<strong>' . $id1 . '</strong>');
+      $html_msg['GV_REDEEM_URL'] = '<a href="'.zen_href_link(FILENAME_GV_REDEEM, 'gv_no=' . $id1, 'NONSSL', false).'">'.EMAIL_GV_LINK.'</a>';
+      $html_msg['GV_REDEEM_CODE'] = $id1;
+
+      $gv_email .= sprintf(EMAIL_GV_REDEEM, $id1) . "\n\n";
+      $gv_email .= EMAIL_GV_LINK . ' ' . zen_href_link(FILENAME_GV_REDEEM, 'gv_no=' . $id1, 'NONSSL', false);
+      $gv_email .= "\n\n";
+      $gv_email .= EMAIL_GV_FIXED_FOOTER . "\n\n";
+      $gv_email .= EMAIL_GV_SHOP_FOOTER;
+
+      $gv_email_subject = sprintf(EMAIL_GV_TEXT_SUBJECT, $send_name);
+
+      // include disclaimer
+      $gv_email .= "\n\n" . EMAIL_ADVISORY . "\n\n";
+
+      $html_msg['EMAIL_GV_FIXED_FOOTER'] = str_replace(array("\r\n", "\n", "\r", "-----"), '', EMAIL_GV_FIXED_FOOTER);
+      $html_msg['EMAIL_GV_SHOP_FOOTER'] =	EMAIL_GV_SHOP_FOOTER;
+      
+      // GV Delay Send BOF
+      if ($send_future === 0) :
+      // GV Delay Send EOF
+      
+      // send the email
+      zen_mail($_POST['to_name'], $_POST['email'], $gv_email_subject, nl2br($gv_email), STORE_NAME, EMAIL_FROM, $html_msg, 'gv_send');
+
+      // GV Delay Send BOF
+      endif;
+      // GV Delay Send EOF
+
+      // send additional emails
+      if (SEND_EXTRA_GV_CUSTOMER_EMAILS_TO_STATUS == '1' and SEND_EXTRA_GV_CUSTOMER_EMAILS_TO !='') {
+        $extra_info = email_collect_extra_info(ENTRY_NAME . $_POST['to_name'], ENTRY_EMAIL . $_POST['email'], $send_name , $account->fields['customers_email_address']);
+        $html_msg['EXTRA_INFO'] = $extra_info['HTML'];
+        zen_mail('', SEND_EXTRA_GV_CUSTOMER_EMAILS_TO, SEND_EXTRA_GV_CUSTOMER_EMAILS_TO_SUBJECT . ' ' . $gv_email_subject,
+        $gv_email . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $html_msg,'gv_send_extra');
+      }
+
+      // do a fresh calculation after sending an email
+      $gv_query = "SELECT amount
+                   FROM " . TABLE_COUPON_GV_CUSTOMER . "
+                   WHERE customer_id = :customersID";
+
+      $gv_query = $db->bindVars($gv_query, ':customersID', $_SESSION['customer_id'], 'integer');
+      $gv_result = $db->Execute($gv_query);
+    }
+  } else { // customer DID click the back button
+    $_GET['action'] = '';
+  }
+}
+
+$gv_current_balance = $currencies->format($gv_result->fields['amount']);
+
+if ($_GET['action'] == 'complete') zen_redirect(zen_href_link(FILENAME_GV_SEND, 'action=doneprocess'));
+
+$breadcrumb->add(NAVBAR_TITLE);
+
+// validate entries
+$gv_amount = (float)$gv_amount;
+
+// This should be last line of the script:
+$zco_notifier->notify('NOTIFY_HEADER_END_GV_SEND');

includes/modules/pages/gv_send/jscript_main.php

+<script type="text/javascript" src="https://www.google.com/jsapi"></script>
+<link type="text/css" rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/smoothness/jquery-ui.css" media="screen" />
+<script type="text/javascript">
+    google.load("jquery", "1.7.1");
+    google.load("jqueryui", "1.8.16");
+    
+    function OnLoad()
+    {
+        jQuery(document).ready(function($){
+            $(".dateselect, .timeselect").hide();
+            $("input[name='set_date_time']").click(function(event){
+                $(".dateselect, .timeselect").slideToggle();
+            });
+            $(".datepicker").datepicker({minDate: new Date()});   
+            $("select[name='time']").change(function(event){
+                var time = $(this).val();
+                var date = $("input[name='date']").val();
+                var now = new Date();
+                if(isNaN(date))
+                {
+                    if(now > Date.parse(date + ' ' + time))
+                    {
+                        alert('You need to use a time in the future');
+                    }
+                }
+            }); 
+        });
+    }
+    google.setOnLoadCallback(OnLoad);
+
+</script>

includes/templates/CUSTOM/templates/tpl_gv_send_default.php

+<?php
+/**
+ * Page Template
+ *
+ * Template used to collect/display details of sending a GV to a friend from own GV balance. <br />
+ *
+ * @package templateSystem
+ * @copyright Copyright 2003-2011 Zen Cart Development Team
+ * @copyright Portions Copyright 2003 osCommerce
+ * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
+ * @version $Id: tpl_gv_send_default.php 18695 2011-05-04 05:24:19Z drbyte $
+ */
+?>
+<div class="centerColumn" id="gvSendDefault">
+
+<div id="sendSpendWrapper"class="forward">
+<h2><?php echo TEXT_AVAILABLE_BALANCE;?></h2>
+<p id="gvSendDefaultBalance"><?php echo TEXT_BALANCE_IS . $gv_current_balance; ?></p>
+<?php
+  if ($gv_result->fields['amount'] > 0 && $_GET['action'] == 'doneprocess') {
+?>
+<p><?php echo TEXT_SEND_ANOTHER; ?></p>
+<div class="buttonRow forward"><a href="<?php echo zen_href_link(FILENAME_GV_SEND, '', 'SSL', false); ?>"><?php echo zen_image_button(BUTTON_IMAGE_SEND_ANOTHER, BUTTON_SEND_ANOTHER_ALT); ?></a></div>
+<?php
+    }
+?>
+</div>
+<?php
+  if ($_GET['action'] == 'doneprocess') {
+?>
+<!--BOF GV sent success-->
+
+<h1 id="gvSendDefaultHeadingDone"><?php echo HEADING_TITLE_COMPLETED; ?></h1>
+
+<div id="gvSendDefaultContentSuccess" class="content"><?php echo TEXT_SUCCESS; ?></div>
+
+<div class="buttonRow forward"><a href="<?php echo zen_href_link(FILENAME_DEFAULT, '', 'SSL', false); ?>"><?php echo zen_image_button(BUTTON_IMAGE_CONTINUE, BUTTON_CONTINUE_ALT); ?></a></div>
+<!--EOF GV sent success -->
+<?php
+  }
+  if ($_GET['action'] == 'send' && !$error) {
+?>
+<!--BOF GV send confirm -->
+
+<h1 id="gvSendDefaultHeadingConfirm"><?php echo HEADING_TITLE_CONFIRM_SEND; ?></h1>
+
+<?php echo zen_draw_form('gv_send_process', zen_href_link(FILENAME_GV_SEND, 'action=process', 'SSL', false)); ?>
+<div id="gvSendDefaultMainMessage" class="content"><?php echo sprintf(MAIN_MESSAGE, $currencies->format($_POST['amount'], false), $_POST['to_name'], $_POST['email']); ?></div>
+
+<?php
+// GV Delay Send BOF
+if(isset($_POST['set_date_time'])):
+echo zen_draw_hidden_field('set_date_time', 'set_date_time') . zen_draw_hidden_field('date', zen_db_prepare_input($_POST['date'])) . zen_draw_hidden_field('time', zen_db_prepare_input($_POST['time']));
+?> 
+
+<div id="gvSendDefaultDateTime" class="content">The email will be  sent on <?php echo $_POST['date'];?> at <?php echo $_POST['time'];?></div><br/>
+<?php
+endif;
+// GV Delay Send EOF
+?>
+
+<div id="gvSendDefaultMessageSecondary" class="content"><?php echo sprintf(SECONDARY_MESSAGE, $_POST['to_name'], $currencies->format($_POST['amount'], false), $send_name); ?></div>
+<?php
+    if ($_POST['message']) {
+?>
+
+<div id="gvSendDefaultMessagePersonal" class="content"><?php echo sprintf(PERSONAL_MESSAGE, $send_firstname); ?></div>
+
+<div id="gvSendDefaultMessage" class="content"><?php echo stripslashes($_POST['message']); ?></div>
+<?php
+    }
+
+    echo zen_draw_hidden_field('to_name', stripslashes($_POST['to_name'])) . zen_draw_hidden_field('email', $_POST['email']) . zen_draw_hidden_field('amount', $gv_amount) . zen_draw_hidden_field('message', stripslashes($_POST['message']));
+?>
+
+<div class="buttonRow forward"><?php echo zen_image_submit(BUTTON_IMAGE_CONFIRM_SEND, BUTTON_CONFIRM_SEND_ALT); ?></div>
+<div class="buttonRow back"><?php echo zen_image_submit(BUTTON_IMAGE_EDIT_SMALL, BUTTON_EDIT_SMALL_ALT, 'name="edit" value="edit"'); ?></div>
+
+</form>
+<br class="clearBoth" />
+
+<div class="advisory"><?php echo EMAIL_ADVISORY_INCLUDED_WARNING . str_replace('-----', '', EMAIL_ADVISORY); ?></div>
+<!--EOF GV send confirm -->
+<?php
+  } elseif ($_GET['action']=='' || $error) {
+?>
+<!--BOF GV send-->
+<h1 id="gvSendDefaultHeadingSend"><?php echo HEADING_TITLE; ?></h1>
+
+<div id="gvSendDefaultMainContent" class="content"><?php echo HEADING_TEXT; ?></div>
+<br class="clearBoth" />
+<?php if ($messageStack->size('gv_send') > 0) echo $messageStack->output('gv_send'); ?>
+
+<?php echo zen_draw_form('gv_send_send', zen_href_link(FILENAME_GV_SEND, 'action=send', 'SSL', false)); ?>
+
+<fieldset>
+<legend><?php echo HEADING_TITLE; ?></legend>
+
+<p><input type="checkbox" value="set_date_time" name="set_date_time"/> Check here, if you would like to have the gift certificate emailed at a specific date and time, enter the time you would like it sent.</p>
+<p class="dateselect">
+    <label for="date">Enter Date:</label>
+    <?php echo zen_draw_input_field('date', date("m/d/Y"), 'class="datepicker" placeholder="Date mm/dd/YYYY"');?>
+</p>
+
+<p class="timeselect">
+    <label for="time">Enter Time:</label>
+    <select name="time">
+        <?php
+        $start = strtotime('12:00am');
+        $end = strtotime('11:59pm');
+        
+        for ($i = $start; $i <= $end; $i += 1800): ?>        
+        <option value="<?php echo date('g:i a', $i);?>"><?php echo date('g:i a', $i);?></option>        
+        <?php endfor;?>
+        
+    </select> (<?php echo date("T");?>)
+</p>
+
+<label class="inputLabel" for="to-name"><?php echo ENTRY_NAME; ?></label>
+<?php echo zen_draw_input_field('to_name', $_POST['to_name'], 'size="40" id="to-name"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>';?>
+<br class="clearBoth" />
+
+<label class="inputLabel" for="email-address"><?php echo ENTRY_EMAIL; ?></label>
+<?php echo zen_draw_input_field('email', $_POST['email'], 'size="40" id="email-address"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; if ($error) echo $error_email; ?>
+<br class="clearBoth" />
+
+<label class="inputLabel" for="amount"><?php echo ENTRY_AMOUNT; ?></label>
+<?php echo zen_draw_input_field('amount', $_POST['amount'], 'id="amount"', 'text', false) . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; if ($error) echo $error_amount; ?>
+<br class="clearBoth" />
+
+<label for="message-area"><?php echo ENTRY_MESSAGE; ?></label>
+<?php echo zen_draw_textarea_field('message', 50, 10, stripslashes($_POST['message']), 'id="message-area"'); ?>
+</fieldset>
+
+<div class="buttonRow forward"><?php echo zen_image_submit(BUTTON_IMAGE_SEND, BUTTON_SEND_ALT); ?></div>
+<div class="buttonRow back"><?php echo zen_back_link() . zen_image_button(BUTTON_IMAGE_BACK, BUTTON_BACK_ALT) . '</a>'; ?></div>
+<br class="clearBoth" />
+</form>
+
+<div class="advisory"><?php echo EMAIL_ADVISORY_INCLUDED_WARNING . str_replace('-----', '', EMAIL_ADVISORY); ?></div>
+<?php
+  }
+?>
+<!--EOF GV send-->
+</div>