[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/admin/ -> coupon_admin.php (source)

   1  <?php
   2  /*

   3  $Id: coupon_admin.php 3 2006-05-27 04:59:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7    Copyright 2006 osCMax

   8  

   9    Released under the GNU General Public License

  10  */
  11  
  12    require ('includes/application_top.php');
  13    require (DIR_WS_CLASSES . 'currencies.php');
  14    require (DIR_FCKEDITOR . 'fckeditor.php');
  15  
  16    $currencies = new currencies();
  17  
  18    if ($HTTP_GET_VARS['selected_box']) {
  19      $HTTP_GET_VARS['action']='';
  20      $HTTP_GET_VARS['old_action']='';
  21    }
  22    
  23    if (($HTTP_GET_VARS['action'] == 'send_email_to_user') && ($HTTP_POST_VARS['customers_email_address']) && (!$HTTP_POST_VARS['back_x'])) {
  24      switch ($HTTP_POST_VARS['customers_email_address']) {
  25      case '***':
  26        $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS);
  27        $mail_sent_to = TEXT_ALL_CUSTOMERS;
  28        break;
  29      case '**D':
  30        $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
  31        $mail_sent_to = TEXT_NEWSLETTER_CUSTOMERS;
  32        break;
  33      default:
  34        $customers_email_address = tep_db_prepare_input($HTTP_POST_VARS['customers_email_address']);
  35        $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($customers_email_address) . "'");
  36        $mail_sent_to = $HTTP_POST_VARS['customers_email_address'];
  37        break;
  38      }
  39      $coupon_query = tep_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_id = '" . $HTTP_GET_VARS['cid'] . "'");
  40      $coupon_result = tep_db_fetch_array($coupon_query);
  41      $coupon_name_query = tep_db_query("select coupon_name from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id = '" . $HTTP_GET_VARS['cid'] . "' and language_id = '" . $languages_id . "'");
  42      $coupon_name = tep_db_fetch_array($coupon_name_query);
  43  
  44      $from = tep_db_prepare_input($HTTP_POST_VARS['from']);
  45      $subject = tep_db_prepare_input($HTTP_POST_VARS['subject']);
  46      while ($mail = tep_db_fetch_array($mail_query)) {
  47        $message = tep_db_prepare_input($HTTP_POST_VARS['message']);
  48        $message .= "\n\n" . TEXT_TO_REDEEM . "\n\n";
  49        $message .= TEXT_VOUCHER_IS . $coupon_result['coupon_code'] . "\n\n";
  50        $message .= TEXT_REMEMBER . "\n\n";
  51        $message .= TEXT_VISIT . "\n\n";
  52       
  53        //Let's build a message object using the email class

  54        $mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));
  55        // add the message to the object

  56  // MaxiDVD Added Line For WYSIWYG HTML Area: BOF (Send TEXT Email when WYSIWYG Disabled)

  57      if (HTML_AREA_WYSIWYG_DISABLE_EMAIL == 'Disable') {
  58      $mimemessage->add_text($message);
  59      } else {
  60      $mimemessage->add_html($message);
  61      }
  62  // MaxiDVD Added Line For WYSIWYG HTML Area: EOF (Send HTML Email when WYSIWYG Enabled)

  63        $mimemessage->build_message();
  64        $mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', $from, $subject);
  65      }
  66  
  67      tep_redirect(tep_href_link(FILENAME_COUPON_ADMIN, 'mail_sent_to=' . urlencode($mail_sent_to)));
  68    }
  69   
  70    if ( ($HTTP_GET_VARS['action'] == 'preview_email') && (!$HTTP_POST_VARS['customers_email_address']) ) {
  71      $HTTP_GET_VARS['action'] = 'email';
  72      $messageStack->add(ERROR_NO_CUSTOMER_SELECTED, 'error');
  73    }
  74  
  75    if ($HTTP_GET_VARS['mail_sent_to']) {
  76      $messageStack->add(sprintf(NOTICE_EMAIL_SENT_TO, $HTTP_GET_VARS['mail_sent_to']), 'notice');
  77    }
  78  
  79    switch ($HTTP_GET_VARS['action']) {
  80      case 'confirmdelete':
  81        $delete_query=tep_db_query("update " . TABLE_COUPONS . " set coupon_active = 'N' where coupon_id='".$HTTP_GET_VARS['cid']."'");
  82        break;
  83      case 'update':
  84        // get all HTTP_POST_VARS and validate

  85        $HTTP_POST_VARS['coupon_code'] = trim($HTTP_POST_VARS['coupon_code']);
  86          $languages = tep_get_languages();
  87          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  88            $language_id = $languages[$i]['id'];
  89            $HTTP_POST_VARS['coupon_name'][$language_id] = trim($HTTP_POST_VARS['coupon_name'][$language_id]);
  90            $HTTP_POST_VARS['coupon_desc'][$language_id] = trim($HTTP_POST_VARS['coupon_desc'][$language_id]);
  91          }
  92        $HTTP_POST_VARS['coupon_amount'] = trim($HTTP_POST_VARS['coupon_amount']);
  93        $update_errors = 0;
  94        if (!$HTTP_POST_VARS['coupon_name']) {
  95          $update_errors = 1;
  96          $messageStack->add(ERROR_NO_COUPON_NAME, 'error');
  97        }
  98        if ((!$HTTP_POST_VARS['coupon_amount']) && (!$HTTP_POST_VARS['coupon_free_ship'])) {
  99          $update_errors = 1;
 100          $messageStack->add(ERROR_NO_COUPON_AMOUNT, 'error');
 101        }
 102        if (!$HTTP_POST_VARS['coupon_code']) {
 103          $coupon_code = create_coupon_code();
 104        }
 105        if ($HTTP_POST_VARS['coupon_code']) $coupon_code = $HTTP_POST_VARS['coupon_code'];
 106        $query1 = tep_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_code = '" . tep_db_prepare_input($coupon_code) . "'");
 107        if (tep_db_num_rows($query1) && $HTTP_POST_VARS['coupon_code'] && $HTTP_GET_VARS['oldaction'] != 'voucheredit')  {
 108          $update_errors = 1;
 109          $messageStack->add(ERROR_COUPON_EXISTS, 'error');
 110        }
 111        if ($update_errors != 0) {
 112          $HTTP_GET_VARS['action'] = 'new';
 113        } else {
 114          $HTTP_GET_VARS['action'] = 'update_preview';
 115        }
 116        break;
 117      case 'update_confirm':
 118        if ( ($HTTP_POST_VARS['back_x']) || ($HTTP_POST_VARS['back_y']) ) {
 119          $HTTP_GET_VARS['action'] = 'new';
 120        } else {
 121          $coupon_type = "F";
 122          if (substr($HTTP_POST_VARS['coupon_amount'], -1) == '%') $coupon_type='P';
 123          if ($HTTP_POST_VARS['coupon_free_ship']) $coupon_type = 'S';
 124          $sql_data_array = array('coupon_code' => tep_db_prepare_input($HTTP_POST_VARS['coupon_code']),
 125                                  'coupon_amount' => tep_db_prepare_input($HTTP_POST_VARS['coupon_amount']),
 126                                  'coupon_type' => tep_db_prepare_input($coupon_type),
 127                                  'uses_per_coupon' => tep_db_prepare_input($HTTP_POST_VARS['coupon_uses_coupon']),
 128                                  'uses_per_user' => tep_db_prepare_input($HTTP_POST_VARS['coupon_uses_user']),
 129                                  'coupon_minimum_order' => tep_db_prepare_input($HTTP_POST_VARS['coupon_min_order']),
 130                                  'restrict_to_products' => tep_db_prepare_input($HTTP_POST_VARS['coupon_products']),
 131                                  'restrict_to_categories' => tep_db_prepare_input($HTTP_POST_VARS['coupon_categories']),
 132                                  'coupon_start_date' => $HTTP_POST_VARS['coupon_startdate'],
 133                                  'coupon_expire_date' => $HTTP_POST_VARS['coupon_finishdate'],
 134                                  'date_created' => 'now()',
 135                                  'date_modified' => 'now()');
 136          $languages = tep_get_languages();
 137          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 138            $language_id = $languages[$i]['id'];
 139            $sql_data_marray[$i] = array('coupon_name' => tep_db_prepare_input($HTTP_POST_VARS['coupon_name'][$language_id]),
 140                                   'coupon_description' => tep_db_prepare_input($HTTP_POST_VARS['coupon_desc'][$language_id])
 141                                   );
 142          }
 143  //        $query = tep_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_code = '" . tep_db_prepare_input($HTTP_POST_VARS['coupon_code']) . "'");

 144  //        if (!tep_db_num_rows($query)) {

 145          if ($HTTP_GET_VARS['oldaction']=='voucheredit') {
 146            tep_db_perform(TABLE_COUPONS, $sql_data_array, 'update', "coupon_id='" . $HTTP_GET_VARS['cid']."'");
 147            for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 148            $language_id = $languages[$i]['id'];
 149              $update = tep_db_query("update " . TABLE_COUPONS_DESCRIPTION . " set coupon_name = '" . tep_db_prepare_input($HTTP_POST_VARS['coupon_name'][$language_id]) . "', coupon_description = '" . tep_db_prepare_input($HTTP_POST_VARS['coupon_desc'][$language_id]) . "' where coupon_id = '" . $HTTP_GET_VARS['cid'] . "' and language_id = '" . $language_id . "'");
 150  //            tep_db_perform(TABLE_COUPONS_DESCRIPTION, $sql_data_marray[$i], 'update', "coupon_id='" . $HTTP_GET_VARS['cid']."'");

 151            }
 152          } else {
 153            $query = tep_db_perform(TABLE_COUPONS, $sql_data_array);
 154            $insert_id = tep_db_insert_id($query);
 155  
 156            for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 157              $language_id = $languages[$i]['id'];
 158              $sql_data_marray[$i]['coupon_id'] = $insert_id;
 159              $sql_data_marray[$i]['language_id'] = $language_id;
 160              tep_db_perform(TABLE_COUPONS_DESCRIPTION, $sql_data_marray[$i]);
 161            }
 162  //        }

 163        }
 164      }
 165    }
 166  ?>
 167  <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
 168  <html <?php echo HTML_PARAMS; ?>>
 169  <head>
 170  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
 171  <title><?php echo TITLE; ?></title>
 172  <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
 173  <script language="javascript" src="includes/general.js"></script>
 174  <link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
 175  <script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
 176  <script language="javascript">
 177    var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?php echo $pInfo->products_date_available; ?>",scBTNMODE_CUSTOMBLUE);
 178  </script>
 179  </head>
 180  <body OnLoad="init()" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
 181  
 182  <div id="spiffycalendar" class="text"></div>
 183  <!-- header //-->
 184  <?php require (DIR_WS_INCLUDES . 'header.php'); ?>
 185  <!-- header_eof //-->
 186  
 187  <!-- body //-->
 188  <table border="0" width="100%" cellspacing="2" cellpadding="2">
 189    <tr>
 190      <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
 191  <!-- left_navigation //-->
 192  <?php require (DIR_WS_INCLUDES . 'column_left.php'); ?>
 193  <!-- left_navigation_eof //-->
 194      </table></td>
 195  <!-- body_text //-->
 196  <?php
 197    switch ($HTTP_GET_VARS['action']) {
 198    case 'voucherreport':
 199  ?>
 200        <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
 201        <tr>
 202          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 203            <tr>
 204              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 205              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 206            </tr>
 207          </table></td>
 208        </tr>
 209        <tr>
 210          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 211            <tr>
 212              <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 213                <tr class="dataTableHeadingRow">
 214                  <td class="dataTableHeadingContent"><?php echo CUSTOMER_ID; ?></td>
 215                  <td class="dataTableHeadingContent" align="center"><?php echo CUSTOMER_NAME; ?></td>
 216                  <td class="dataTableHeadingContent" align="center"><?php echo IP_ADDRESS; ?></td>
 217                  <td class="dataTableHeadingContent" align="center"><?php echo REDEEM_DATE; ?></td>
 218                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
 219                </tr>
 220  <?php
 221      $cc_query_raw = "select * from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $HTTP_GET_VARS['cid'] . "'";
 222      $cc_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $cc_query_raw, $cc_query_numrows);
 223      $cc_query = tep_db_query($cc_query_raw);
 224      while ($cc_list = tep_db_fetch_array($cc_query)) {
 225        $rows++;
 226        if (strlen($rows) < 2) {
 227          $rows = '0' . $rows;
 228        }
 229        if (((!$HTTP_GET_VARS['uid']) || (@$HTTP_GET_VARS['uid'] == $cc_list['unique_id'])) && (!$cInfo)) {
 230          $cInfo = new objectInfo($cc_list);
 231        }
 232        if ( (is_object($cInfo)) && ($cc_list['unique_id'] == $cInfo->unique_id) ) {
 233          echo '          <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . tep_href_link('coupon_admin.php', tep_get_all_get_params(array('cid', 'action', 'uid')) . 'cid=' . $cInfo->coupon_id . '&action=voucherreport&uid=' . $cinfo->unique_id) . '\'">' . "\n";
 234        } else {
 235          echo '          <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . tep_href_link('coupon_admin.php', tep_get_all_get_params(array('cid', 'action', 'uid')) . 'cid=' . $cc_list['coupon_id'] . '&action=voucherreport&uid=' . $cc_list['unique_id']) . '\'">' . "\n";
 236        }
 237  $customer_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . $cc_list['customer_id'] . "'");
 238  $customer = tep_db_fetch_array($customer_query);
 239  
 240  ?>
 241                  <td class="dataTableContent"><?php echo $cc_list['customer_id']; ?></td>
 242                  <td class="dataTableContent" align="center"><?php echo $customer['customers_firstname'] . ' ' . $customer['customers_lastname']; ?></td>
 243                  <td class="dataTableContent" align="center"><?php echo $cc_list['redeem_ip']; ?></td>
 244                  <td class="dataTableContent" align="center"><?php echo tep_date_short($cc_list['redeem_date']); ?></td>
 245                  <td class="dataTableContent" align="right"><?php if ( (is_object($cInfo)) && ($cc_list['unique_id'] == $cInfo->unique_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . tep_href_link(FILENAME_COUPON_ADMIN, 'page=' . $HTTP_GET_VARS['page'] . '&cid=' . $cc_list['coupon_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
 246                </tr>
 247  <?php
 248      }
 249  ?>
 250  
 251               </table></td>
 252  <?php
 253      $heading = array();
 254      $contents = array();
 255        $coupon_description_query = tep_db_query("select coupon_name from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id = '" . $HTTP_GET_VARS['cid'] . "' and language_id = '" . $languages_id . "'");
 256        $coupon_desc = tep_db_fetch_array($coupon_description_query);
 257        $count_customers = tep_db_query("select * from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $HTTP_GET_VARS['cid'] . "' and customer_id = '" . $cInfo->customer_id . "'");
 258  
 259        $heading[] = array('text' => '<b>[' . $HTTP_GET_VARS['cid'] . ']' . COUPON_NAME . ' ' . $coupon_desc['coupon_name'] . '</b>');
 260        $contents[] = array('text' => '<b>' . TEXT_REDEMPTIONS . '</b>');
 261        $contents[] = array('text' => TEXT_REDEMPTIONS_TOTAL . '=' . tep_db_num_rows($cc_query));
 262        $contents[] = array('text' => TEXT_REDEMPTIONS_CUSTOMER . '=' . tep_db_num_rows($count_customers));
 263        $contents[] = array('text' => '');
 264  ?>
 265      <td width="25%" valign="top">
 266  <?php
 267        $box = new box;
 268        echo $box->infoBox($heading, $contents);
 269        echo '            </td>' . "\n";
 270  ?>
 271  <?php
 272      break;
 273    case 'preview_email':
 274      $coupon_query = tep_db_query("select coupon_code from " .TABLE_COUPONS . " where coupon_id = '" . $HTTP_GET_VARS['cid'] . "'");
 275      $coupon_result = tep_db_fetch_array($coupon_query);
 276      $coupon_name_query = tep_db_query("select coupon_name from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id = '" . $HTTP_GET_VARS['cid'] . "' and language_id = '" . $languages_id . "'");
 277      $coupon_name = tep_db_fetch_array($coupon_name_query);
 278      switch ($HTTP_POST_VARS['customers_email_address']) {
 279      case '***':
 280        $mail_sent_to = TEXT_ALL_CUSTOMERS;
 281        break;
 282      case '**D':
 283        $mail_sent_to = TEXT_NEWSLETTER_CUSTOMERS;
 284        break;
 285      default:
 286        $mail_sent_to = $HTTP_POST_VARS['customers_email_address'];
 287        break;
 288      }
 289  ?>
 290        <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 291        <tr>
 292          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 293            <tr>
 294              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 295              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 296            </tr>
 297          </table></td>
 298        </tr>
 299        <tr>
 300            <tr><?php echo tep_draw_form('mail', FILENAME_COUPON_ADMIN, 'action=send_email_to_user&cid=' . $HTTP_GET_VARS['cid']); ?>
 301              <td><table border="0" width="100%" cellpadding="0" cellspacing="2">
 302                <tr>
 303                  <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 304                </tr>
 305                <tr>
 306                  <td class="smallText"><b><?php echo TEXT_CUSTOMER; ?></b><br><?php echo $mail_sent_to; ?></td>
 307                </tr>
 308                <tr>
 309                  <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 310                </tr>
 311                <tr>
 312                  <td class="smallText"><b><?php echo TEXT_COUPON; ?></b><br><?php echo $coupon_name['coupon_name']; ?></td>
 313                </tr>
 314                <tr>
 315                  <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 316                </tr>
 317                <tr>
 318                  <td class="smallText"><b><?php echo TEXT_FROM; ?></b><br><?php echo htmlspecialchars(stripslashes($HTTP_POST_VARS['from'])); ?></td>
 319                </tr>
 320                <tr>
 321                  <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 322                </tr>
 323                <tr>
 324                  <td class="smallText"><b><?php echo TEXT_SUBJECT; ?></b><br><?php echo htmlspecialchars(stripslashes($HTTP_POST_VARS['subject'])); ?></td>
 325                </tr>
 326                <tr>
 327                  <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 328                </tr>
 329                <tr>
 330                  <td class="smallText"><b><?php if (HTML_AREA_WYSIWYG_DISABLE_EMAIL == 'Enable') { echo (stripslashes($HTTP_POST_VARS['message'])); } else { echo htmlspecialchars(stripslashes($HTTP_POST_VARS['message'])); } ?></td>
 331                </tr>
 332                <tr>
 333                  <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 334                </tr>
 335                <tr>
 336                  <td>
 337  <?php
 338  /* Re-Post all POST'ed variables */

 339      reset($HTTP_POST_VARS);
 340      while (list($key, $value) = each($HTTP_POST_VARS)) {
 341        if (!is_array($HTTP_POST_VARS[$key])) {
 342          echo tep_draw_hidden_field($key, htmlspecialchars(stripslashes($value)));
 343        }
 344      }
 345  ?>
 346                  <table border="0" width="100%" cellpadding="0" cellspacing="2">
 347                    <tr>
 348                      <td><?php ?>&nbsp;</td>
 349                       <tr>
 350                      <td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_MAIL) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a> ' . tep_image_submit('button_send_mail.gif', IMAGE_SEND_EMAIL); ?></td>
 351                      </tr>
 352                      <td class="smallText">
 353                  <?php if (HTML_AREA_WYSIWYG_DISABLE_EMAIL == 'Disable'){echo tep_image_submit('button_back.gif', IMAGE_BACK, 'name="back"');
 354                  } ?><?php if (HTML_AREA_WYSIWYG_DISABLE_EMAIL == 'Disable') {echo(TEXT_EMAIL_BUTTON_HTML);
 355                   } else { echo(TEXT_EMAIL_BUTTON_TEXT); } ?>
 356                      </td>
 357                    </tr>
 358                  </table></td>
 359                </tr>
 360              </table></td>
 361            </form></tr>
 362  <?php
 363      break;
 364    case 'email':
 365      $coupon_query = tep_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_id = '" . $HTTP_GET_VARS['cid'] . "'");
 366      $coupon_result = tep_db_fetch_array($coupon_query);
 367      $coupon_name_query = tep_db_query("select coupon_name from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id = '" . $HTTP_GET_VARS['cid'] . "' and language_id = '" . $languages_id . "'");
 368      $coupon_name = tep_db_fetch_array($coupon_name_query);
 369  ?>
 370        <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 371        <tr>
 372          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 373            <tr>
 374              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 375              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 376            </tr>
 377          </table></td>
 378        </tr>
 379        <tr>
 380  
 381            <tr><?php echo tep_draw_form('mail', FILENAME_COUPON_ADMIN, 'action=preview_email&cid='. $HTTP_GET_VARS['cid']); ?>
 382              <td><table border="0" cellpadding="0" cellspacing="2">
 383                <tr>
 384                  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 385                </tr>
 386  <?php
 387      $customers = array();
 388      $customers[] = array('id' => '', 'text' => TEXT_SELECT_CUSTOMER);
 389      $customers[] = array('id' => '***', 'text' => TEXT_ALL_CUSTOMERS);
 390      $customers[] = array('id' => '**D', 'text' => TEXT_NEWSLETTER_CUSTOMERS);
 391      $mail_query = tep_db_query("select customers_email_address, customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " order by customers_lastname");
 392      while($customers_values = tep_db_fetch_array($mail_query)) {
 393        $customers[] = array('id' => $customers_values['customers_email_address'],
 394                             'text' => $customers_values['customers_lastname'] . ', ' . $customers_values['customers_firstname'] . ' (' . $customers_values['customers_email_address'] . ')');
 395      }
 396  ?>
 397                <tr>
 398                  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 399                </tr>
 400                <tr>
 401                  <td class="main"><?php echo TEXT_COUPON; ?>&nbsp;&nbsp;</td>
 402                  <td><?php echo $coupon_name['coupon_name']; ?></td>
 403                </tr>
 404                <tr>
 405                  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 406                </tr>
 407                <tr>
 408                  <td class="main"><?php echo TEXT_CUSTOMER; ?>&nbsp;&nbsp;</td>
 409                  <td><?php echo tep_draw_pull_down_menu('customers_email_address', $customers, $HTTP_GET_VARS['customer']);?></td>
 410                </tr>
 411                <tr>
 412                  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 413                </tr>
 414                <tr>
 415                  <td class="main"><?php echo TEXT_FROM; ?>&nbsp;&nbsp;</td>
 416                  <td><?php echo tep_draw_input_field('from', EMAIL_FROM); ?></td>
 417                </tr>
 418                <tr>
 419                  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 420                </tr>
 421  <?php
 422  /*

 423                <tr>

 424                  <td class="main"><?php echo TEXT_RESTRICT; ?>&nbsp;&nbsp;</td>

 425                  <td><?php echo tep_draw_checkbox_field('customers_restrict', $customers_restrict);?></td>

 426                </tr>

 427                <tr>

 428                  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

 429                </tr>

 430  */
 431  ?>
 432                <tr>
 433                  <td class="main"><?php echo TEXT_SUBJECT; ?>&nbsp;&nbsp;</td>
 434                  <td><?php echo tep_draw_input_field('subject'); ?></td>
 435                </tr>
 436                <tr>
 437                  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 438                </tr>
 439                <tr>
 440                  <td valign="top" class="main"><?php echo TEXT_MESSAGE; ?></td>
 441                  <td><?php if (HTML_AREA_WYSIWYG_DISABLE_EMAIL == 'Enable') {
 442  // Line Changed - MOD: Ajustable Editor Window

 443                      echo tep_draw_fckeditor('message', HTML_AREA_WYSIWYG_EDITOR_WIDTH, HTML_AREA_WYSIWYG_EDITOR_HEIGHT, ' ') .'</td>';
 444                  } else { echo tep_draw_textarea_field('message', 'soft', '60', '15') .'</td>';
 445                  }
 446                  ?>
 447                </tr>
 448                <tr>
 449                  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 450                </tr>
 451                <tr>
 452                   <td colspan="2" align="right">
 453                   <?php if (HTML_AREA_WYSIWYG_DISABLE_EMAIL == 'Enable'){ echo tep_image_submit('button_send_mail.gif', IMAGE_SEND_EMAIL, 'onClick="validate();return returnVal;"');
 454                     } else {
 455                  echo tep_image_submit('button_send_mail.gif', IMAGE_SEND_EMAIL); }?>
 456                  </td>
 457                </tr>
 458              </table></td>
 459            </form></tr>
 460  
 461        </tr>
 462        </td>
 463  <?php
 464      break;
 465    case 'update_preview':
 466  ?>
 467        <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 468        <tr>
 469          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 470            <tr>
 471              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 472              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 473            </tr>
 474          </table></td>
 475        </tr>
 476        <tr>
 477        <td>
 478  <?php echo tep_draw_form('coupon', 'coupon_admin.php', 'action=update_confirm&oldaction=' . $HTTP_GET_VARS['oldaction'] . '&cid=' . $HTTP_GET_VARS['cid']); ?>
 479        <table border="0" width="100%" cellspacing="0" cellpadding="6">
 480  <?php
 481          $languages = tep_get_languages();
 482          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 483              $language_id = $languages[$i]['id'];
 484  ?>
 485        <tr>
 486          <td align="left"><?php echo COUPON_NAME; ?></td>
 487          <td align="left"><?php echo $HTTP_POST_VARS['coupon_name'][$language_id]; ?></td>
 488        </tr>
 489  <?php
 490  }
 491  ?>
 492  <?php
 493          $languages = tep_get_languages();
 494          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 495              $language_id = $languages[$i]['id'];
 496  ?>
 497        <tr>
 498          <td align="left"><?php echo COUPON_DESC; ?></td>
 499          <td align="left"><?php echo $HTTP_POST_VARS['coupon_desc'][$language_id]; ?></td>
 500        </tr>
 501  <?php
 502  }
 503  ?>
 504        <tr>
 505          <td align="left"><?php echo COUPON_AMOUNT; ?></td>
 506          <td align="left"><?php echo $HTTP_POST_VARS['coupon_amount']; ?></td>
 507        </tr>
 508  
 509        <tr>
 510          <td align="left"><?php echo COUPON_MIN_ORDER; ?></td>
 511          <td align="left"><?php echo $HTTP_POST_VARS['coupon_min_order']; ?></td>
 512        </tr>
 513  
 514        <tr>
 515          <td align="left"><?php echo COUPON_FREE_SHIP; ?></td>
 516  <?php
 517      if ($HTTP_POST_VARS['coupon_free_ship']) {
 518  ?>
 519          <td align="left"><?php echo TEXT_FREE_SHIPPING; ?></td>
 520  <?php
 521      } else {
 522  ?>
 523          <td align="left"><?php echo TEXT_NO_FREE_SHIPPING; ?></td>
 524  <?php
 525      }
 526  ?>
 527        </tr>
 528        <tr>
 529          <td align="left"><?php echo COUPON_CODE; ?></td>
 530  <?php
 531      if ($HTTP_POST_VARS['coupon_code']) {
 532        $c_code = $HTTP_POST_VARS['coupon_code'];
 533      } else {
 534        $c_code = $coupon_code;
 535      }
 536  ?>
 537          <td align="left"><?php echo $coupon_code; ?></td>
 538        </tr>
 539  
 540        <tr>
 541          <td align="left"><?php echo COUPON_USES_COUPON; ?></td>
 542          <td align="left"><?php echo $HTTP_POST_VARS['coupon_uses_coupon']; ?></td>
 543        </tr>
 544  
 545        <tr>
 546          <td align="left"><?php echo COUPON_USES_USER; ?></td>
 547          <td align="left"><?php echo $HTTP_POST_VARS['coupon_uses_user']; ?></td>
 548        </tr>
 549  
 550         <tr>
 551          <td align="left"><?php echo COUPON_PRODUCTS; ?></td>
 552          <td align="left"><?php echo $HTTP_POST_VARS['coupon_products']; ?></td>
 553        </tr>
 554  
 555  
 556        <tr>
 557          <td align="left"><?php echo COUPON_CATEGORIES; ?></td>
 558          <td align="left"><?php echo $HTTP_POST_VARS['coupon_categories']; ?></td>
 559        </tr>
 560        <tr>
 561          <td align="left"><?php echo COUPON_STARTDATE; ?></td>
 562  <?php
 563      $start_date = date(DATE_FORMAT, mktime(0, 0, 0, $HTTP_POST_VARS['coupon_startdate_month'],$HTTP_POST_VARS['coupon_startdate_day'] ,$HTTP_POST_VARS['coupon_startdate_year'] ));
 564  ?>
 565          <td align="left"><?php echo $start_date; ?></td>
 566        </tr>
 567  
 568        <tr>
 569          <td align="left"><?php echo COUPON_FINISHDATE; ?></td>
 570  <?php
 571      $finish_date = date(DATE_FORMAT, mktime(0, 0, 0, $HTTP_POST_VARS['coupon_finishdate_month'],$HTTP_POST_VARS['coupon_finishdate_day'] ,$HTTP_POST_VARS['coupon_finishdate_year'] ));
 572      echo date('Y-m-d', mktime(0, 0, 0, $HTTP_POST_VARS['coupon_startdate_month'],$HTTP_POST_VARS['coupon_startdate_day'] ,$HTTP_POST_VARS['coupon_startdate_year'] ));
 573  ?>
 574          <td align="left"><?php echo $finish_date; ?></td>
 575        </tr>
 576  <?php
 577          $languages = tep_get_languages();
 578          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 579            $language_id = $languages[$i]['id'];
 580            echo tep_draw_hidden_field('coupon_name[' . $languages[$i]['id'] . ']', $HTTP_POST_VARS['coupon_name'][$language_id]);
 581            echo tep_draw_hidden_field('coupon_desc[' . $languages[$i]['id'] . ']', $HTTP_POST_VARS['coupon_desc'][$language_id]);
 582         }
 583      echo tep_draw_hidden_field('coupon_amount', $HTTP_POST_VARS['coupon_amount']);
 584      echo tep_draw_hidden_field('coupon_min_order', $HTTP_POST_VARS['coupon_min_order']);
 585      echo tep_draw_hidden_field('coupon_free_ship', $HTTP_POST_VARS['coupon_free_ship']);
 586      echo tep_draw_hidden_field('coupon_code', $c_code);
 587      echo tep_draw_hidden_field('coupon_uses_coupon', $HTTP_POST_VARS['coupon_uses_coupon']);
 588      echo tep_draw_hidden_field('coupon_uses_user', $HTTP_POST_VARS['coupon_uses_user']);
 589      echo tep_draw_hidden_field('coupon_products', $HTTP_POST_VARS['coupon_products']);
 590      echo tep_draw_hidden_field('coupon_categories', $HTTP_POST_VARS['coupon_categories']);
 591      echo tep_draw_hidden_field('coupon_startdate', date('Y-m-d', mktime(0, 0, 0, $HTTP_POST_VARS['coupon_startdate_month'],$HTTP_POST_VARS['coupon_startdate_day'] ,$HTTP_POST_VARS['coupon_startdate_year'] )));
 592      echo tep_draw_hidden_field('coupon_finishdate', date('Y-m-d', mktime(0, 0, 0, $HTTP_POST_VARS['coupon_finishdate_month'],$HTTP_POST_VARS['coupon_finishdate_day'] ,$HTTP_POST_VARS['coupon_finishdate_year'] )));
 593  ?>
 594       <tr>
 595          <td align="left"><?php echo tep_image_submit('button_confirm.gif',COUPON_BUTTON_CONFIRM); ?></td>
 596          <td align="left"><?php echo tep_image_submit('button_back.gif',COUPON_BUTTON_BACK, 'name=back'); ?></td>
 597        </td>
 598        </tr>
 599  
 600        </td></table></form>
 601        </tr>
 602  
 603        </table></td>
 604  <?php
 605  
 606      break;
 607    case 'voucheredit':
 608      $languages = tep_get_languages();
 609      for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 610        $language_id = $languages[$i]['id'];
 611        $coupon_query = tep_db_query("select coupon_name,coupon_description from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id = '" .  $HTTP_GET_VARS['cid'] . "' and language_id = '" . $language_id . "'");
 612        $coupon = tep_db_fetch_array($coupon_query);
 613        $coupon_name[$language_id] = $coupon['coupon_name'];
 614        $coupon_desc[$language_id] = $coupon['coupon_description'];
 615      }
 616      $coupon_query=tep_db_query("select coupon_code, coupon_amount, coupon_type, coupon_minimum_order, coupon_start_date, coupon_expire_date, uses_per_coupon, uses_per_user, restrict_to_products, restrict_to_categories from " . TABLE_COUPONS . " where coupon_id = '" . $HTTP_GET_VARS['cid'] . "'");
 617      $coupon=tep_db_fetch_array($coupon_query);
 618      $coupon_amount = $coupon['coupon_amount'];
 619      if ($coupon['coupon_type']=='P') {
 620        $coupon_amount .= '%';
 621      }
 622      if ($coupon['coupon_type']=='S') {
 623        $coupon_free_ship .= true;
 624      }
 625      $coupon_min_order = $coupon['coupon_minimum_order'];
 626      $coupon_code = $coupon['coupon_code'];
 627      $coupon_uses_coupon = $coupon['uses_per_coupon'];
 628      $coupon_uses_user = $coupon['uses_per_user'];
 629      $coupon_products = $coupon['restrict_to_products'];
 630      $coupon_categories = $coupon['restrict_to_categories'];
 631    case 'new':
 632  // set some defaults

 633      if (!$coupon_uses_user) $coupon_uses_user=1;
 634  ?>
 635        <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 636        <tr>
 637          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 638            <tr>
 639              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 640              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 641            </tr>
 642          </table></td>
 643        </tr>
 644        <tr>
 645        <td>
 646  <?php
 647      echo tep_draw_form('coupon', 'coupon_admin.php', 'action=update&oldaction='.$HTTP_GET_VARS['action'] . '&cid=' . $HTTP_GET_VARS['cid']);
 648  ?>
 649        <table border="0" width="100%" cellspacing="0" cellpadding="6">
 650  <?php
 651          $languages = tep_get_languages();
 652          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 653          $language_id = $languages[$i]['id'];
 654  ?>
 655        <tr>
 656          <td align="left" class="main"><?php if ($i==0) echo COUPON_NAME; ?></td>
 657          <td align="left"><?php echo tep_draw_input_field('coupon_name[' . $languages[$i]['id'] . ']', $coupon_name[$language_id]) . '&nbsp;' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?></td>
 658          <td align="left" class="main" width="40%"><?php if ($i==0) echo COUPON_NAME_HELP; ?></td>
 659        </tr>
 660  <?php
 661  }
 662  ?>
 663  <?php
 664          $languages = tep_get_languages();
 665          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 666          $language_id = $languages[$i]['id'];
 667  ?>
 668  
 669        <tr>
 670          <td align="left" valign="top" class="main"><?php if ($i==0) echo COUPON_DESC; ?></td>
 671          <td align="left" valign="top"><?php echo tep_draw_textarea_field('coupon_desc[' . $languages[$i]['id'] . ']','physical','24','3', $coupon_desc[$language_id]) . '&nbsp;' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?></td>
 672          <td align="left" valign="top" class="main"><?php if ($i==0) echo COUPON_DESC_HELP; ?></td>
 673        </tr>
 674  <?php
 675  }
 676  ?>
 677        <tr>
 678          <td align="left" class="main"><?php echo COUPON_AMOUNT; ?></td>
 679          <td align="left"><?php echo tep_draw_input_field('coupon_amount', $coupon_amount); ?></td>
 680          <td align="left" class="main"><?php echo COUPON_AMOUNT_HELP; ?></td>
 681        </tr>
 682        <tr>
 683          <td align="left" class="main"><?php echo COUPON_MIN_ORDER; ?></td>
 684          <td align="left"><?php echo tep_draw_input_field('coupon_min_order', $coupon_min_order); ?></td>
 685          <td align="left" class="main"><?php echo COUPON_MIN_ORDER_HELP; ?></td>
 686        </tr>
 687        <tr>
 688          <td align="left" class="main"><?php echo COUPON_FREE_SHIP; ?></td>
 689          <td align="left"><?php echo tep_draw_checkbox_field('coupon_free_ship', $coupon_free_ship); ?></td>
 690          <td align="left" class="main"><?php echo COUPON_FREE_SHIP_HELP; ?></td>
 691        </tr>
 692        <tr>
 693          <td align="left" class="main"><?php echo COUPON_CODE; ?></td>
 694          <td align="left"><?php echo tep_draw_input_field('coupon_code', $coupon_code); ?></td>
 695          <td align="left" class="main"><?php echo COUPON_CODE_HELP; ?></td>
 696        </tr>
 697        <tr>
 698          <td align="left" class="main"><?php echo COUPON_USES_COUPON; ?></td>
 699          <td align="left"><?php echo tep_draw_input_field('coupon_uses_coupon', $coupon_uses_coupon); ?></td>
 700          <td align="left" class="main"><?php echo COUPON_USES_COUPON_HELP; ?></td>
 701        </tr>
 702        <tr>
 703          <td align="left" class="main"><?php echo COUPON_USES_USER; ?></td>
 704          <td align="left"><?php echo tep_draw_input_field('coupon_uses_user', $coupon_uses_user); ?></td>
 705          <td align="left" class="main"><?php echo COUPON_USES_USER_HELP; ?></td>
 706        </tr>
 707         <tr>
 708          <td align="left" class="main"><?php echo COUPON_PRODUCTS; ?></td>
 709          <td align="left"><?php echo tep_draw_input_field('coupon_products', $coupon_products); ?> <A HREF="validproducts.php" TARGET="_blank" ONCLICK="window.open('validproducts.php', 'Valid_Products', 'scrollbars=yes,resizable=yes,menubar=yes,width=600,height=600'); return false">View</A></td>
 710          <td align="left" class="main"><?php echo COUPON_PRODUCTS_HELP; ?></td>
 711        </tr>
 712        <tr>
 713          <td align="left" class="main"><?php echo COUPON_CATEGORIES; ?></td>
 714          <td align="left"><?php echo tep_draw_input_field('coupon_categories', $coupon_categories); ?> <A HREF="validcategories.php" TARGET="_blank" ONCLICK="window.open('validcategories.php', 'Valid_Categories', 'scrollbars=yes,resizable=yes,menubar=yes,width=600,height=600'); return false">View</A></td>
 715          <td align="left" class="main"><?php echo COUPON_CATEGORIES_HELP; ?></td>
 716        </tr>
 717        <tr>
 718  <?php
 719      if (!$HTTP_POST_VARS['coupon_startdate']) {
 720        $coupon_startdate = split("[-]", date('Y-m-d'));
 721      } else {
 722        $coupon_startdate = split("[-]", $HTTP_POST_VARS['coupon_startdate']);
 723      }
 724      if (!$HTTP_POST_VARS['coupon_finishdate']) {
 725        $coupon_finishdate = split("[-]", date('Y-m-d'));
 726        $coupon_finishdate[0] = $coupon_finishdate[0] + 1;
 727      } else {
 728        $coupon_finishdate = split("[-]", $HTTP_POST_VARS['coupon_finishdate']);
 729      }
 730  ?>
 731          <td align="left" class="main"><?php echo COUPON_STARTDATE; ?></td>
 732          <td align="left"><?php echo tep_draw_date_selector('coupon_startdate', mktime(0,0,0, $coupon_startdate[1], $coupon_startdate[2], $coupon_startdate[0], 0)); ?></td>
 733          <td align="left" class="main"><?php echo COUPON_STARTDATE_HELP; ?></td>
 734        </tr>
 735        <tr>
 736          <td align="left" class="main"><?php echo COUPON_FINISHDATE; ?></td>
 737          <td align="left"><?php echo tep_draw_date_selector('coupon_finishdate', mktime(0,0,0, $coupon_finishdate[1], $coupon_finishdate[2], $coupon_finishdate[0], 0)); ?></td>
 738          <td align="left" class="main"><?php echo COUPON_FINISHDATE_HELP; ?></td>
 739        </tr>
 740        <tr>
 741          <td align="left"><?php echo tep_image_submit('button_preview.gif',COUPON_BUTTON_PREVIEW); ?></td>
 742          <td align="left"><?php echo '&nbsp;&nbsp;<a href="' . tep_href_link('coupon_admin.php', ''); ?>"><?php echo tep_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a>
 743        </td>
 744        </tr>
 745        </td></table></form>
 746        </tr>
 747  
 748        </table></td>
 749  <?php
 750      break;
 751    default:
 752  ?>
 753      <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 754        <tr>
 755          <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
 756            <tr>
 757              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 758              <td class="main"><?php echo tep_draw_form('status', FILENAME_COUPON_ADMIN, '', 'get'); ?>
 759  <?php
 760      $status_array[] = array('id' => 'Y', 'text' => TEXT_COUPON_ACTIVE);
 761      $status_array[] = array('id' => 'N', 'text' => TEXT_COUPON_INACTIVE);
 762      $status_array[] = array('id' => '*', 'text' => TEXT_COUPON_ALL);
 763  
 764      if ($HTTP_GET_VARS['status']) {
 765        $status = tep_db_prepare_input($HTTP_GET_VARS['status']);
 766      } else {
 767        $status = 'Y';
 768      }
 769      echo HEADING_TITLE_STATUS . ' ' . tep_draw_pull_down_menu('status', $status_array, $status, 'onChange="this.form.submit();"');
 770  ?>
 771                </form>
 772             </td>
 773            </tr>
 774          </table></td>
 775        </tr>
 776        <tr>
 777          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 778            <tr>
 779              <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 780                <tr class="dataTableHeadingRow">
 781                  <td class="dataTableHeadingContent"><?php echo COUPON_NAME; ?></td>
 782                  <td class="dataTableHeadingContent" align="center"><?php echo COUPON_AMOUNT; ?></td>
 783                  <td class="dataTableHeadingContent" align="center"><?php echo COUPON_CODE; ?></td>
 784                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
 785                </tr>
 786  <?php
 787      if ($HTTP_GET_VARS['page'] > 1) $rows = $HTTP_GET_VARS['page'] * 20 - 20;
 788      if ($status != '*') {
 789        $cc_query_raw = "select coupon_id, coupon_code, coupon_amount, coupon_type, coupon_start_date,coupon_expire_date,uses_per_user,uses_per_coupon,restrict_to_products, restrict_to_categories, date_created,date_modified from " . TABLE_COUPONS ." where coupon_active='" . tep_db_input($status) . "' and coupon_type != 'G'";
 790      } else {
 791        $cc_query_raw = "select coupon_id, coupon_code, coupon_amount, coupon_type, coupon_start_date,coupon_expire_date,uses_per_user,uses_per_coupon,restrict_to_products, restrict_to_categories, date_created,date_modified from " . TABLE_COUPONS . " where coupon_type != 'G'";
 792      }
 793      $cc_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $cc_query_raw, $cc_query_numrows);
 794      $cc_query = tep_db_query($cc_query_raw);
 795      while ($cc_list = tep_db_fetch_array($cc_query)) {
 796        $rows++;
 797        if (strlen($rows) < 2) {
 798          $rows = '0' . $rows;
 799        }
 800        if (((!$HTTP_GET_VARS['cid']) || (@$HTTP_GET_VARS['cid'] == $cc_list['coupon_id'])) && (!$cInfo)) {
 801          $cInfo = new objectInfo($cc_list);
 802        }
 803        if ( (is_object($cInfo)) && ($cc_list['coupon_id'] == $cInfo->coupon_id) ) {
 804          echo '          <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . tep_href_link('coupon_admin.php', tep_get_all_get_params(array('cid', 'action')) . 'cid=' . $cInfo->coupon_id . '&action=edit') . '\'">' . "\n";
 805        } else {
 806          echo '          <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . tep_href_link('coupon_admin.php', tep_get_all_get_params(array('cid', 'action')) . 'cid=' . $cc_list['coupon_id']) . '\'">' . "\n";
 807        }
 808        $coupon_description_query = tep_db_query("select coupon_name from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id = '" . $cc_list['coupon_id'] . "' and language_id = '" . $languages_id . "'");
 809        $coupon_desc = tep_db_fetch_array($coupon_description_query);
 810  ?>
 811                  <td class="dataTableContent"><?php echo $coupon_desc['coupon_name']; ?></td>
 812                  <td class="dataTableContent" align="center">
 813  <?php
 814        if ($cc_list['coupon_type'] == 'P') {
 815          echo $cc_list['coupon_amount'] . '%';
 816        } elseif ($cc_list['coupon_type'] == 'S') {
 817          echo TEXT_FREE_SHIPPING;
 818        } else {
 819          echo $currencies->format($cc_list['coupon_amount']);
 820        }
 821  ?>
 822              &nbsp;</td>
 823                  <td class="dataTableContent" align="center"><?php echo $cc_list['coupon_code']; ?></td>
 824                  <td class="dataTableContent" align="right"><?php if ( (is_object($cInfo)) && ($cc_list['coupon_id'] == $cInfo->coupon_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . tep_href_link(FILENAME_COUPON_ADMIN, 'page=' . $HTTP_GET_VARS['page'] . '&cid=' . $cc_list['coupon_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
 825                </tr>
 826  <?php
 827      }
 828  ?>
 829            <tr>
 830              <td colspan="5"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 831                <tr>
 832                  <td class="smallText">&nbsp;<?php echo $cc_split->display_count($cc_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_COUPONS); ?>&nbsp;</td>
 833                  <td align="right" class="smallText">&nbsp;<?php echo $cc_split->display_links($cc_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?>&nbsp;</td>
 834                </tr>
 835  
 836                <tr>
 837                  <td align="right" colspan="2" class="smallText"><?php echo '<a href="' . tep_href_link('coupon_admin.php', 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->coupon_id . '&action=new') . '">' . tep_image_button('button_insert.gif', IMAGE_INSERT) . '</a>'; ?></td>
 838                </tr>
 839              </table></td>
 840            </tr>
 841          </table></td>
 842  
 843  <?php
 844  
 845      $heading = array();
 846      $contents = array();
 847  
 848      switch ($HTTP_GET_VARS['action']) {
 849      case 'release':
 850        break;
 851      case 'voucherreport':
 852        $heading[] = array('text' => '<b>' . TEXT_HEADING_COUPON_REPORT . '</b>');
 853        $contents[] = array('text' => TEXT_NEW_INTRO);
 854        break;
 855      case 'neww':
 856        $heading[] = array('text' => '<b>' . TEXT_HEADING_NEW_COUPON . '</b>');
 857        $contents[] = array('text' => TEXT_NEW_INTRO);
 858        $contents[] = array('text' => '<br>' . COUPON_NAME . '<br>' . tep_draw_input_field('name'));
 859        $contents[] = array('text' => '<br>' . COUPON_AMOUNT . '<br>' . tep_draw_input_field('voucher_amount'));
 860        $contents[] = array('text' => '<br>' . COUPON_CODE . '<br>' . tep_draw_input_field('voucher_code'));
 861        $contents[] = array('text' => '<br>' . COUPON_USES_COUPON . '<br>' . tep_draw_input_field('voucher_number_of'));
 862        break;
 863      default:
 864        $heading[] = array('text'=>'['.$cInfo->coupon_id.']  '.$cInfo->coupon_code);
 865        $amount = $cInfo->coupon_amount;
 866        if ($cInfo->coupon_type == 'P') {
 867          $amount .= '%';
 868        } else {
 869          $amount = $currencies->format($amount);
 870        }
 871        if ($HTTP_GET_VARS['action'] == 'voucherdelete') {
 872          $contents[] = array('text'=> TEXT_CONFIRM_DELETE . '</br></br>' .
 873                  '<a href="'.tep_href_link('coupon_admin.php','action=confirmdelete&cid='.$HTTP_GET_VARS['cid'],'NONSSL').'">'.tep_image_button('button_confirm.gif','Confirm Delete Voucher').'</a>' .
 874                  '<a href="'.tep_href_link('coupon_admin.php','cid='.$cInfo->coupon_id,'NONSSL').'">'.tep_image_button('button_cancel.gif','Cancel').'</a>'
 875                  );
 876        } else {
 877          $prod_details = NONE;
 878          if ($cInfo->restrict_to_products) {
 879            $prod_details = '<A HREF="listproducts.php?cid=' . $cInfo->coupon_id . '" TARGET="_blank" ONCLICK="window.open(\'listproducts.php?cid=' . $cInfo->coupon_id . '\', \'Valid_Categories\', \'scrollbars=yes,resizable=yes,menubar=yes,width=600,height=600\'); return false">View</A>';
 880          }
 881          $cat_details = NONE;
 882          if ($cInfo->restrict_to_categories) {
 883            $cat_details = '<A HREF="listcategories.php?cid=' . $cInfo->coupon_id . '" TARGET="_blank" ONCLICK="window.open(\'listcategories.php?cid=' . $cInfo->coupon_id . '\', \'Valid_Categories\', \'scrollbars=yes,resizable=yes,menubar=yes,width=600,height=600\'); return false">View</A>';
 884          }
 885          $coupon_name_query = tep_db_query("select coupon_name from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id = '" . $cInfo->coupon_id . "' and language_id = '" . $languages_id . "'");
 886          $coupon_name = tep_db_fetch_array($coupon_name_query);
 887          $contents[] = array('text'=>COUPON_NAME . '&nbsp;::&nbsp; ' . $coupon_name['coupon_name'] . '<br>' .
 888                       COUPON_AMOUNT . '&nbsp;::&nbsp; ' . $amount . '<br>' .
 889                       COUPON_STARTDATE . '&nbsp;::&nbsp; ' . tep_date_short($cInfo->coupon_start_date) . '<br>' .
 890                       COUPON_FINISHDATE . '&nbsp;::&nbsp; ' . tep_date_short($cInfo->coupon_expire_date) . '<br>' .
 891                       COUPON_USES_COUPON . '&nbsp;::&nbsp; ' . $cInfo->uses_per_coupon . '<br>' .
 892                       COUPON_USES_USER . '&nbsp;::&nbsp; ' . $cInfo->uses_per_user . '<br>' .
 893                       COUPON_PRODUCTS . '&nbsp;::&nbsp; ' . $prod_details . '<br>' .
 894                       COUPON_CATEGORIES . '&nbsp;::&nbsp; ' . $cat_details . '<br>' .
 895                       DATE_CREATED . '&nbsp;::&nbsp; ' . tep_date_short($cInfo->date_created) . '<br>' .
 896                       DATE_MODIFIED . '&nbsp;::&nbsp; ' . tep_date_short($cInfo->date_modified) . '<br><br>' .
 897                       '<center><a href="'.tep_href_link('coupon_admin.php','action=email&cid='.$cInfo->coupon_id,'NONSSL').'">'.tep_image_button('button_email.gif','Email Voucher').'</a>' .
 898                       '<a href="'.tep_href_link('coupon_admin.php','action=voucheredit&cid='.$cInfo->coupon_id,'NONSSL').'">'.tep_image_button('button_edit.gif','Edit Voucher').'</a>' .
 899                       '<a href="'.tep_href_link('coupon_admin.php','action=voucherdelete&cid='.$cInfo->coupon_id,'NONSSL').'">'.tep_image_button('button_delete.gif','Delete Voucher').'</a>' .
 900                       '<br><a href="'.tep_href_link('coupon_admin.php','action=voucherreport&cid='.$cInfo->coupon_id,'NONSSL').'">'.tep_image_button('button_report.gif','Voucher Report').'</a></center>'
 901                       );
 902          }
 903          break;
 904        }
 905  ?>
 906      <td width="25%" valign="top">
 907  <?php
 908        $box = new box;
 909        echo $box->infoBox($heading, $contents);
 910      echo '            </td>' . "\n";
 911      }
 912  ?>
 913        </tr>
 914      </table></td>
 915  <!-- body_text_eof //-->
 916    </tr>
 917  </table>
 918  <!-- body_eof //-->
 919  <!-- footer //-->
 920  <?php require (DIR_WS_INCLUDES . 'footer.php'); ?>
 921  <!-- footer_eof //-->
 922  </body>
 923  </html>
 924  <?php require (DIR_WS_INCLUDES . 'application_bottom.php'); ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7