[ Index ]
 

Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/admin/ -> coupon_admin.php (source)

   1  <?php
   2  /**

   3   * @package admin

   4   * @copyright Copyright 2003-2006 Zen Cart Development Team

   5   * @copyright Portions Copyright 2003 osCommerce

   6   * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

   7   * @version $Id: coupon_admin.php 4976 2006-11-20 22:33:34Z wilt $

   8   */
   9  
  10    require ('includes/application_top.php');
  11    require (DIR_WS_CLASSES . 'currencies.php');
  12    $currencies = new currencies();
  13  
  14    if ($_GET['selected_box']) {
  15      $_GET['action']='';
  16      $_GET['old_action']='';
  17    }
  18  
  19    if (($_GET['action'] == 'send_email_to_user') && ($_POST['customers_email_address']) && (!$_POST['back_x'])) {
  20      $audience_select = get_audience_sql_query($_POST['customers_email_address'], 'email');
  21          $mail = $db->Execute($audience_select['query_string']);
  22          $mail_sent_to = $audience_select['query_name'];
  23        if ($_POST['email_to']) {
  24          $mail_sent_to = $_POST['email_to'];
  25          }
  26  
  27      $coupon_result = $db->Execute("select coupon_code
  28                                     from " . TABLE_COUPONS . "
  29                                     where coupon_id = '" . $_GET['cid'] . "'");
  30  
  31      $coupon_name = $db->Execute("select coupon_name, coupon_description
  32                                   from " . TABLE_COUPONS_DESCRIPTION . "
  33                                   where coupon_id = '" . $_GET['cid'] . "'
  34                                   and language_id = '" . $_SESSION['languages_id'] . "'");
  35  
  36      // demo active test

  37      if (zen_admin_demo()) {
  38        $_GET['action']= '';
  39        $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
  40        zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'mail_sent_to=' . urlencode($mail_sent_to)));
  41      }
  42      $from = zen_db_prepare_input($_POST['from']);
  43      $subject = zen_db_prepare_input($_POST['subject']);
  44      $recip_count=0;
  45      while (!$mail->EOF) {
  46        $message = zen_db_prepare_input($_POST['message']);
  47        $message .= "\n\n" . TEXT_TO_REDEEM . "\n\n";
  48        $message .= TEXT_VOUCHER_IS . $coupon_result->fields['coupon_code'] . "\n\n";
  49        $message .= TEXT_REMEMBER . "\n\n";
  50        $message .= sprintf(TEXT_VISIT ,HTTP_CATALOG_SERVER . DIR_WS_CATALOG);
  51  
  52        // disclaimer

  53        $message .= "\n-----\n" . sprintf(EMAIL_DISCLAIMER, STORE_OWNER_EMAIL_ADDRESS) . "\n\n";
  54  
  55        $html_msg['EMAIL_FIRST_NAME'] = $mail->fields['customers_firstname'];
  56        $html_msg['EMAIL_LAST_NAME']  = $mail->fields['customers_lastname'];
  57        $html_msg['EMAIL_MESSAGE_HTML'] = zen_db_prepare_input($_POST['message_html']);
  58        $html_msg['COUPON_TEXT_TO_REDEEM'] = TEXT_TO_REDEEM;
  59        $html_msg['COUPON_TEXT_VOUCHER_IS'] = TEXT_VOUCHER_IS;
  60        $html_msg['COUPON_CODE'] = $coupon_result->fields['coupon_code'];
  61        $html_msg['COUPON_DESCRIPTION'] =(!empty($coupon_name->fields['coupon_description']) ? $coupon_name->fields['coupon_description'] : '');
  62        $html_msg['COUPON_TEXT_REMEMBER']  = TEXT_REMEMBER;
  63        $html_msg['COUPON_REDEEM_STORENAME_URL'] = sprintf(TEXT_VISIT ,'<a href="'.HTTP_CATALOG_SERVER . DIR_WS_CATALOG.'">'.STORE_NAME.'</a>');
  64  
  65  //Send the emails

  66        zen_mail($mail->fields['customers_firstname'] . ' ' . $mail->fields['customers_lastname'], $mail->fields['customers_email_address'], $subject , $message, '',$from, $html_msg, 'coupon');
  67  
  68        $recip_count++;
  69        $mail->MoveNext();
  70      }
  71      // send one to Admin if enabled

  72      if (SEND_EXTRA_DISCOUNT_COUPON_ADMIN_EMAILS_TO_STATUS== '1' and SEND_EXTRA_DISCOUNT_COUPON_ADMIN_EMAILS_TO != '') {
  73        zen_mail('', SEND_EXTRA_DISCOUNT_COUPON_ADMIN_EMAILS_TO, SEND_EXTRA_DISCOUNT_COUPON_ADMIN_EMAILS_TO_SUBJECT . ' ' . $subject , $message, '',$from, $html_msg, 'coupon_extra');
  74      }
  75      zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'mail_sent_to=' . urlencode($mail_sent_to) . '&recip_count='. $recip_count ));
  76    }
  77  
  78    if ( ($_GET['action'] == 'preview_email') && (!$_POST['customers_email_address']) ) {
  79      $_GET['action'] = 'email';
  80      $messageStack->add(ERROR_NO_CUSTOMER_SELECTED, 'error');
  81    }
  82  
  83    if ($_GET['mail_sent_to']) {
  84      $messageStack->add(sprintf(NOTICE_EMAIL_SENT_TO, $_GET['mail_sent_to']. '(' . $_GET['recip_count'] . ')'), 'success');
  85      $_GET['mail_sent_to'] = '';
  86    }
  87  
  88    switch ($_GET['action']) {
  89        case 'set_editor':
  90          // Reset will be done by init_html_editor.php. Now we simply redirect to refresh page properly.

  91          $action='';
  92          zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN));
  93          break;
  94      case 'confirmdelete':
  95        // demo active test

  96        if (zen_admin_demo()) {
  97          $_GET['action']= '';
  98          $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
  99          zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN));
 100        }
 101  
 102  // do not allow change if set to welcome coupon

 103        if ($_GET['cid'] == NEW_SIGNUP_DISCOUNT_COUPON) {
 104          $messageStack->add_session(ERROR_DISCOUNT_COUPON_WELCOME, 'caution');
 105          zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
 106        }
 107  
 108        $db->Execute("update " . TABLE_COUPONS . "
 109                      set coupon_active = 'N'
 110                      where coupon_id='".$_GET['cid']."'");
 111        $messageStack->add_session(SUCCESS_COUPON_DISABLED, 'success');
 112        zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN));
 113        break;
 114      case 'confirmcopy':
 115        $coupon_copy_to = trim($_POST['coupon_copy_to']);
 116  
 117        // check if new coupon code exists

 118        $sql = "SELECT * from " . TABLE_COUPONS . " where coupon_code='" . $coupon_copy_to . "'";
 119        $check_new_coupon = $db->Execute($sql);
 120        if ($check_new_coupon->RecordCount() > 0) {
 121          $messageStack->add_session(ERROR_DISCOUNT_COUPON_DUPLICATE . $coupon_copy_to, 'caution');
 122          zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
 123        }
 124  
 125        $sql = "SELECT * from " . TABLE_COUPONS . " where coupon_id='" . $_GET['cid'] . "'";
 126        $check_new_coupon = $db->Execute($sql);
 127  
 128        // create duplicate coupon

 129          $sql_data_array = array('coupon_code' => zen_db_prepare_input($coupon_copy_to),
 130                                  'coupon_amount' => zen_db_prepare_input($check_new_coupon->fields['coupon_amount']),
 131                                  'coupon_type' => zen_db_prepare_input($check_new_coupon->fields['coupon_type']),
 132                                  'uses_per_coupon' => zen_db_prepare_input((int)$check_new_coupon->fields['uses_per_coupon']),
 133                                  'uses_per_user' => zen_db_prepare_input((int)$check_new_coupon->fields['uses_per_user']),
 134                                  'coupon_minimum_order' => zen_db_prepare_input((float)$check_new_coupon->fields['coupon_minimum_order']),
 135                                  'restrict_to_products' => zen_db_prepare_input($check_new_coupon->fields['restrict_to_products']),
 136                                  'restrict_to_categories' => zen_db_prepare_input($check_new_coupon->fields['restrict_to_categories']),
 137                                  'coupon_start_date' => $check_new_coupon->fields['coupon_start_date'],
 138                                  'coupon_expire_date' => $check_new_coupon->fields['coupon_expire_date'],
 139                                  'date_created' => 'now()',
 140                                  'date_modified' => 'now()',
 141                                  'coupon_zone_restriction' => $check_new_coupon->fields['coupon_zone_restriction']);
 142  
 143            zen_db_perform(TABLE_COUPONS, $sql_data_array);
 144            $insert_id = $db->Insert_ID();
 145            $cid = $insert_id;
 146  //          $_GET['cid'] = $cid;

 147  
 148            // create duplicate coupon description

 149            $sql = "SELECT * from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id='" . $_GET['cid'] . "'";
 150            $new_coupon_descriptions = $db->Execute($sql);
 151  
 152            while (!$new_coupon_descriptions->EOF) {
 153              $sql_mdata_array = array('coupon_id' => zen_db_prepare_input($cid),
 154                                      'language_id' => zen_db_prepare_input($new_coupon_descriptions->fields['language_id']),
 155                                      'coupon_name' => zen_db_prepare_input('COPY: ' . $new_coupon_descriptions->fields['coupon_name']),
 156                                      'coupon_description' => zen_db_prepare_input($new_coupon_descriptions->fields['coupon_description'])
 157                                      );
 158              zen_db_perform(TABLE_COUPONS_DESCRIPTION, $sql_mdata_array);
 159              $new_coupon_descriptions->MoveNext();
 160            }
 161  
 162        // copy restrictions

 163        $sql = "SELECT * from " . TABLE_COUPON_RESTRICT . " where coupon_id='" . $_GET['cid'] . "'";
 164        $copy_coupon_restrictions = $db->Execute($sql);
 165  
 166        while (!$copy_coupon_restrictions->EOF) {
 167          $sql_rdata_array = array('coupon_id' => zen_db_prepare_input($cid),
 168                                   'product_id' => zen_db_prepare_input($copy_coupon_restrictions->fields['product_id']),
 169                                   'category_id' => zen_db_prepare_input($copy_coupon_restrictions->fields['category_id']),
 170                                   'coupon_restrict' => zen_db_prepare_input($copy_coupon_restrictions->fields['coupon_restrict'])
 171                                   );
 172          zen_db_perform(TABLE_COUPON_RESTRICT, $sql_rdata_array);
 173          $copy_coupon_restrictions->MoveNext();
 174        }
 175  
 176        $_GET['cid'] = $cid;
 177        $messageStack->add_session(SUCCESS_COUPON_DUPLICATE . $coupon_copy_to, 'success');
 178        zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'action=voucheredit' . '&cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '')));
 179  //        zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN));

 180        break;
 181      case 'update':
 182        $update_errors = 0;
 183        // get all HTTP_POST_VARS and validate

 184        $_POST['coupon_code'] = trim($_POST['coupon_code']);
 185          $languages = zen_get_languages();
 186          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 187            $language_id = $languages[$i]['id'];
 188            $_POST['coupon_name'][$language_id] = trim($_POST['coupon_name'][$language_id]);
 189            if (!$_POST['coupon_name'][$language_id]) {
 190              $update_errors = 1;
 191              $messageStack->add(ERROR_NO_COUPON_NAME . $languages[$i]['name'], 'error');
 192            }
 193            $_POST['coupon_desc'][$language_id] = trim($_POST['coupon_desc'][$language_id]);
 194          }
 195        $_POST['coupon_amount'] = trim($_POST['coupon_amount']);
 196        $_POST['coupon_amount'] = preg_replace('/[^0-9.%]/', '', $_POST['coupon_amount']);
 197        if (!$_POST['coupon_name']) {
 198          $update_errors = 1;
 199          $messageStack->add(ERROR_NO_COUPON_NAME, 'error');
 200        }
 201        if ((!$_POST['coupon_amount']) && (!$_POST['coupon_free_ship'])) {
 202          $update_errors = 1;
 203          $messageStack->add(ERROR_NO_COUPON_AMOUNT, 'error');
 204        }
 205        if (!$_POST['coupon_code']) {
 206          $coupon_code = create_coupon_code();
 207        }
 208        if ($_POST['coupon_code']) $coupon_code = $_POST['coupon_code'];
 209        $query1 = $db->Execute("select coupon_code
 210                                from " . TABLE_COUPONS . "
 211                                where coupon_code = '" . zen_db_prepare_input($coupon_code) . "'");
 212  
 213        if ($query1->RecordCount()>0 && $_POST['coupon_code'] && $_GET['oldaction'] != 'voucheredit')  {
 214          $update_errors = 1;
 215          $messageStack->add(ERROR_COUPON_EXISTS, 'error');
 216        }
 217        if ($update_errors != 0) {
 218          $_GET['action'] = 'new';
 219        } else {
 220          $_GET['action'] = 'update_preview';
 221        }
 222        break;
 223      case 'update_confirm':
 224        if ( ($_POST['back_x']) || ($_POST['back_y']) ) {
 225          $_GET['action'] = 'new';
 226        } else {
 227          $coupon_type = "F";
 228          if (substr($_POST['coupon_amount'], -1) == '%') $coupon_type='P';
 229          $_POST['coupon_amount'] = preg_replace('/[^0-9.]/', '', $_POST['coupon_amount']);
 230          if ($_POST['coupon_free_ship']) $coupon_type = 'S';
 231          $sql_data_array = array('coupon_code' => zen_db_prepare_input($_POST['coupon_code']),
 232                                  'coupon_amount' => zen_db_prepare_input($_POST['coupon_amount']),
 233                                  'coupon_type' => zen_db_prepare_input($coupon_type),
 234                                  'uses_per_coupon' => zen_db_prepare_input((int)$_POST['coupon_uses_coupon']),
 235                                  'uses_per_user' => zen_db_prepare_input((int)$_POST['coupon_uses_user']),
 236                                  'coupon_minimum_order' => zen_db_prepare_input((float)$_POST['coupon_min_order']),
 237                                  'restrict_to_products' => zen_db_prepare_input($_POST['coupon_products']),
 238                                  'restrict_to_categories' => zen_db_prepare_input($_POST['coupon_categories']),
 239                                  'coupon_start_date' => $_POST['coupon_startdate'],
 240                                  'coupon_expire_date' => $_POST['coupon_finishdate'],
 241                                  'date_created' => 'now()',
 242                                  'date_modified' => 'now()',
 243                                  'coupon_zone_restriction' => $_POST['coupon_zone_restriction']);
 244          $languages = zen_get_languages();
 245          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 246            $language_id = $languages[$i]['id'];
 247            $sql_data_marray[$i] = array('coupon_name' => zen_db_prepare_input($_POST['coupon_name'][$language_id]),
 248                                         'coupon_description' => zen_db_prepare_input($_POST['coupon_desc'][$language_id])
 249                                         );
 250          }
 251          if ($_GET['oldaction']=='voucheredit') {
 252            zen_db_perform(TABLE_COUPONS, $sql_data_array, 'update', "coupon_id='" . $_GET['cid']."'");
 253            for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 254              $language_id = $languages[$i]['id'];
 255              $sql_data_desc_array = array('coupon_name' => zen_db_prepare_input($_POST['coupon_name'][$language_id]),
 256                                           'coupon_description' => zen_db_prepare_input($_POST['coupon_desc'][$language_id])
 257                                           );
 258              zen_db_perform(TABLE_COUPONS_DESCRIPTION, $sql_data_desc_array, 'update', "coupon_id = '" . $_GET['cid'] . "' and language_id = '" . $languages[$i]['id'] . "'");
 259            }
 260          } else {
 261            zen_db_perform(TABLE_COUPONS, $sql_data_array);
 262            $insert_id = $db->Insert_ID();
 263            $cid = $insert_id;
 264            $_GET['cid'] = $cid;
 265  
 266            for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 267              $language_id = $languages[$i]['id'];
 268              $sql_data_marray[$i]['coupon_id'] = $insert_id;
 269              $sql_data_marray[$i]['language_id'] = $language_id;
 270              zen_db_perform(TABLE_COUPONS_DESCRIPTION, $sql_data_marray[$i]);
 271            }
 272          }
 273        }
 274        zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
 275    }
 276  ?>
 277  <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
 278  <html <?php echo HTML_PARAMS; ?>>
 279  <head>
 280  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
 281  <title><?php echo TITLE; ?></title>
 282  <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
 283  <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
 284  <script language="javascript" src="includes/menu.js"></script>
 285  <script language="javascript" src="includes/general.js"></script>
 286  <link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
 287  <script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
 288  <script language="javascript">
 289    var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?php echo $pInfo->products_date_available; ?>",scBTNMODE_CUSTOMBLUE);
 290  </script>
 291  <script type="text/javascript">
 292    <!--
 293    function init()
 294    {
 295      cssjsmenu('navbar');
 296      if (document.getElementById)
 297      {
 298        var kill = document.getElementById('hoverJS');
 299        kill.disabled = true;
 300      }
 301  <?php if ($_GET['action'] == 'new') { ?>
 302      if (typeof _editor_url == "string") HTMLArea.replaceAll();
 303  <?php } else { ?>
 304      if (typeof _editor_url == "string") HTMLArea.replace('message_html');
 305  <?php } ?>
 306    }
 307    // -->

 308  </script>
 309  <script language="javascript" type="text/javascript"><!--
 310  var form = "";
 311  var submitted = false;
 312  var error = false;
 313  var error_message = "";
 314  
 315  function check_select(field_name, field_default, message) {
 316    if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
 317      var field_value = form.elements[field_name].value;
 318  
 319      if (field_value == field_default) {
 320        error_message = error_message + "* " + message + "\n";
 321        error = true;
 322      }
 323    }
 324  }
 325  function check_message(msg) {
 326    if (form.elements['message'] && form.elements['message_html']) {
 327      var field_value1 = form.elements['message'].value;
 328      var field_value2 = form.elements['message_html'].value;
 329  
 330      if ((field_value1 == '' || field_value1.length < 3) && (field_value2 == '' || field_value2.length < 3)) {
 331        error_message = error_message + "* " + msg + "\n";
 332        error = true;
 333      }
 334    }
 335  }
 336  function check_input(field_name, field_size, message) {
 337    if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
 338      var field_value = form.elements[field_name].value;
 339  
 340      if (field_value == '' || field_value.length < field_size) {
 341        error_message = error_message + "* " + message + "\n";
 342        error = true;
 343      }
 344    }
 345  }
 346  
 347  function check_form(form_name) {
 348    if (submitted == true) {
 349      alert("<?php echo JS_ERROR_SUBMITTED; ?>");
 350      return false;
 351    }
 352    error = false;
 353    form = form_name;
 354    error_message = "<?php echo JS_ERROR; ?>";
 355  
 356    check_select('customers_email_address', '', "<?php echo ERROR_NO_CUSTOMER_SELECTED; ?>");
 357    check_message("<?php echo ENTRY_NOTHING_TO_SEND; ?>");
 358    check_input('subject','',"<?php echo ERROR_NO_SUBJECT; ?>");
 359  
 360    if (error == true) {
 361      alert(error_message);
 362      return false;
 363    } else {
 364      submitted = true;
 365      return true;
 366    }
 367  }
 368  //--></script>

 369  <?php if ($editor_handler != '') include ($editor_handler); ?>
 370  </head>
 371  <body onLoad="init()">
 372  <div id="spiffycalendar" class="text"></div>
 373  <!-- header //-->
 374  <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
 375  <!-- header_eof //-->
 376  
 377  <!-- body //-->
 378  <table border="0" width="100%" cellspacing="2" cellpadding="2">
 379    <tr>
 380  <!-- body_text //-->
 381  <?php
 382    switch ($_GET['action']) {
 383    case 'voucherreport':
 384  ?>
 385        <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
 386        <tr>
 387          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 388            <tr>
 389              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 390              <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 391            </tr>
 392          </table></td>
 393        </tr>
 394        <tr>
 395          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 396            <tr>
 397              <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 398                <tr class="dataTableHeadingRow">
 399                  <td class="dataTableHeadingContent"><?php echo CUSTOMER_ID; ?></td>
 400                  <td class="dataTableHeadingContent" align="center"><?php echo CUSTOMER_NAME; ?></td>
 401                  <td class="dataTableHeadingContent" align="center"><?php echo IP_ADDRESS; ?></td>
 402                  <td class="dataTableHeadingContent" align="center"><?php echo REDEEM_DATE; ?></td>
 403                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
 404                </tr>
 405  <?php
 406      $cc_query_raw = "select * from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $_GET['cid'] . "'";
 407      $cc_split = new splitPageResults($_GET['reports_page'], MAX_DISPLAY_SEARCH_RESULTS_DISCOUNT_COUPONS_REPORTS, $cc_query_raw, $cc_query_numrows);
 408      $cc_list = $db->Execute($cc_query_raw);
 409      while (!$cc_list->EOF) {
 410        $rows++;
 411        if (strlen($rows) < 2) {
 412          $rows = '0' . $rows;
 413        }
 414        if (((!$_GET['uid']) || (@$_GET['uid'] == $cc_list->fields['unique_id'])) && (!$cInfo)) {
 415          $cInfo = new objectInfo($cc_list->fields);
 416        }
 417        if ( (is_object($cInfo)) && ($cc_list->fields['unique_id'] == $cInfo->unique_id) ) {
 418          echo '          <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . zen_href_link(FILENAME_COUPON_ADMIN, zen_get_all_get_params(array('cid', 'action', 'uid')) . 'cid=' . $cInfo->coupon_id . '&action=voucherreport&uid=' . $cinfo->unique_id) . '\'">' . "\n";
 419        } else {
 420          echo '          <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . zen_href_link(FILENAME_COUPON_ADMIN, zen_get_all_get_params(array('cid', 'action', 'uid')) . 'cid=' . $cc_list->fields['coupon_id'] . '&action=voucherreport&uid=' . $cc_list->fields['unique_id']) . '\'">' . "\n";
 421        }
 422  $customer = $db->Execute("select customers_firstname, customers_lastname
 423                            from " . TABLE_CUSTOMERS . "
 424                            where customers_id = '" . $cc_list->fields['customer_id'] . "'");
 425  
 426  ?>
 427                  <td class="dataTableContent"><?php echo $cc_list->fields['customer_id']; ?></td>
 428                  <td class="dataTableContent" align="center"><?php echo $customer->fields['customers_firstname'] . ' ' . $customer->fields['customers_lastname']; ?></td>
 429                  <td class="dataTableContent" align="center"><?php echo $cc_list->fields['redeem_ip']; ?></td>
 430                  <td class="dataTableContent" align="center"><?php echo zen_date_short($cc_list->fields['redeem_date']); ?></td>
 431                  <td class="dataTableContent" align="right"><?php if ( (is_object($cInfo)) && ($cc_list->fields['unique_id'] == $cInfo->unique_id) ) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . zen_href_link(FILENAME_COUPON_ADMIN, 'reports_page=' . $_GET['reports_page'] . '&cid=' . $cc_list->fields['coupon_id']) . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
 432                </tr>
 433  <?php
 434        $cc_list->MoveNext();
 435      }
 436  ?>
 437            <tr>
 438              <td colspan="5"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 439                <tr>
 440                  <td class="smallText">&nbsp;<?php echo $cc_split->display_count($cc_query_numrows, MAX_DISPLAY_SEARCH_RESULTS_DISCOUNT_COUPONS_REPORTS, $_GET['reports_page'], TEXT_DISPLAY_NUMBER_OF_COUPONS); ?>&nbsp;</td>
 441                  <td align="right" class="smallText">&nbsp;<?php echo $cc_split->display_links($cc_query_numrows, MAX_DISPLAY_SEARCH_RESULTS_DISCOUNT_COUPONS_REPORTS, MAX_DISPLAY_PAGE_LINKS, $_GET['reports_page'], 'action=voucherreport&cid=' . $cInfo->coupon_id, 'reports_page'); ?>&nbsp;</td>
 442                </tr>
 443  
 444                <tr>
 445                  <td align="right" colspan="2" class="smallText"><?php echo '<a href="' . zen_href_link(FILENAME_COUPON_ADMIN, 'page=' . $_GET['page'] . '&cid=' . (!empty($cInfo->coupon_id) ? $cInfo->coupon_id : $_GET['cid']) . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '')) . '">' . zen_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
 446                </tr>
 447              </table></td>
 448            </tr>
 449               </table></td>
 450  <?php
 451      $heading = array();
 452      $contents = array();
 453        $coupon_desc = $db->Execute("select coupon_name
 454                                     from " . TABLE_COUPONS_DESCRIPTION . "
 455                                     where coupon_id = '" . $_GET['cid'] . "'
 456                                     and language_id = '" . $_SESSION['languages_id'] . "'");
 457        $count_customers = $db->Execute("select * from " . TABLE_COUPON_REDEEM_TRACK . "
 458                                         where coupon_id = '" . $_GET['cid'] . "'
 459                                         and customer_id = '" . $cInfo->customer_id . "'");
 460  
 461        $heading[] = array('text' => '<b>[' . $_GET['cid'] . ']' . COUPON_NAME . ' ' . $coupon_desc->fields['coupon_name'] . '</b>');
 462        $contents[] = array('text' => '<b>' . TEXT_REDEMPTIONS . '</b>');
 463  //      $contents[] = array('text' => TEXT_REDEMPTIONS_TOTAL . '=' . $cc_list->RecordCount());

 464        $contents[] = array('text' => TEXT_REDEMPTIONS_TOTAL . '=' . $cc_query_numrows);
 465        $contents[] = array('text' => TEXT_REDEMPTIONS_CUSTOMER . '=' . $count_customers->RecordCount());
 466        $contents[] = array('text' => '');
 467  ?>
 468      <td width="25%" valign="top">
 469  <?php
 470        $box = new box;
 471        echo $box->infoBox($heading, $contents);
 472        echo '            </td>' . "\n";
 473  ?>
 474  <?php
 475      break;
 476    case 'preview_email':
 477      $coupon_result = $db->Execute("select coupon_code
 478                                     from " .TABLE_COUPONS . "
 479                                     where coupon_id = '" . $_GET['cid'] . "'");
 480  
 481      $coupon_name = $db->Execute("select coupon_name
 482                                   from " . TABLE_COUPONS_DESCRIPTION . "
 483                                   where coupon_id = '" . $_GET['cid'] . "'
 484                                   and language_id = '" . $_SESSION['languages_id'] . "'");
 485  
 486      $audience_select = get_audience_sql_query($_POST['customers_email_address']);
 487      $mail_sent_to = $audience_select['query_name'];
 488  
 489  ?>
 490        <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
 491        <tr>
 492          <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
 493            <tr>
 494              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 495              <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 496            </tr>
 497          </table></td>
 498        </tr>
 499        <tr>
 500          <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
 501            <tr><?php echo zen_draw_form('mail', FILENAME_COUPON_ADMIN, 'action=send_email_to_user&cid=' . $_GET['cid']); ?>
 502              <td><table border="0" width="100%" cellpadding="0" cellspacing="2">
 503                <tr>
 504                  <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 505                </tr>
 506                <tr>
 507                  <td class="smallText"><b><?php echo TEXT_CUSTOMER; ?></b><br /><?php echo $mail_sent_to; ?></td>
 508                </tr>
 509                <tr>
 510                  <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 511                </tr>
 512                <tr>
 513                  <td class="smallText"><b><?php echo TEXT_COUPON; ?></b><br /><?php echo $coupon_name->fields['coupon_name']; ?></td>
 514                </tr>
 515                <tr>
 516                  <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 517                </tr>
 518                <tr>
 519                  <td class="smallText"><b><?php echo TEXT_FROM; ?></b><br /><?php echo htmlspecialchars(stripslashes($_POST['from'])); ?></td>
 520                </tr>
 521                <tr>
 522                  <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 523                </tr>
 524                <tr>
 525                  <td class="smallText"><b><?php echo TEXT_SUBJECT; ?></b><br /><?php echo htmlspecialchars(stripslashes($_POST['subject'])); ?></td>
 526                </tr>
 527                <tr>
 528                  <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 529                </tr>
 530                <tr>
 531                  <td><hr /><b><?php echo TEXT_RICH_TEXT_MESSAGE; ?></b><br /><?php echo stripslashes($_POST['message_html']); ?></td>
 532                </tr>
 533                <tr>
 534                  <td ><hr /><b><?php echo TEXT_MESSAGE; ?></b><br /><tt><?php echo nl2br(htmlspecialchars(stripslashes($_POST['message']))); ?></tt><hr /></td>
 535                </tr>
 536                <tr>
 537                  <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 538                </tr>
 539                <tr>
 540                  <td>
 541  <?php
 542  /* Re-Post all POST'ed variables */

 543      reset($_POST);
 544      while (list($key, $value) = each($_POST)) {
 545        if (!is_array($_POST[$key])) {
 546          echo zen_draw_hidden_field($key, htmlspecialchars(stripslashes($value)));
 547        }
 548      }
 549  ?>
 550                  <table border="0" width="100%" cellpadding="0" cellspacing="2">
 551                    <tr>
 552                      <td><?php ?>&nbsp;</td>
 553                      <td align="right"><?php echo '<a href="' . zen_href_link(FILENAME_COUPON_ADMIN,  'cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a> ' . zen_image_submit('button_send_mail.gif', IMAGE_SEND_EMAIL); ?></td>
 554                    </tr>
 555                  </table></td>
 556                </tr>
 557              </table></td>
 558            </form></tr>
 559  <?php
 560      break;
 561    case 'email':
 562      $coupon_result = $db->Execute("select coupon_code
 563                                     from " . TABLE_COUPONS . "
 564                                     where coupon_id = '" . $_GET['cid'] . "'");
 565      $coupon_name = $db->Execute("select coupon_name
 566                                   from " . TABLE_COUPONS_DESCRIPTION . "
 567                                   where coupon_id = '" . $_GET['cid'] . "'
 568                                   and language_id = '" . $_SESSION['languages_id'] . "'");
 569  ?>
 570        <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 571        <tr>
 572          <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
 573            <tr>
 574              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 575              <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 576            </tr>
 577          </table></td>
 578        </tr>
 579        <tr>
 580          <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
 581            <tr><?php echo zen_draw_form('mail', FILENAME_COUPON_ADMIN, 'action=preview_email&cid='. $_GET['cid'],'post', 'onsubmit="return check_form(mail);"'); ?>
 582              <td><table border="0" width="100%" cellpadding="0" cellspacing="2">
 583                <tr>
 584                  <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 585                </tr>
 586                <tr>
 587                  <td class="main"><?php echo TEXT_COUPON; ?>&nbsp;&nbsp;</td>
 588                  <td><?php echo $coupon_name->fields['coupon_name']; ?></td>
 589                </tr>
 590                <tr>
 591                  <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 592                </tr>
 593  <?php
 594      $customers = get_audiences_list('email');
 595  ?>
 596                <tr>
 597                  <td class="main"><?php echo TEXT_CUSTOMER; ?>&nbsp;&nbsp;</td>
 598                  <td><?php echo zen_draw_pull_down_menu('customers_email_address', $customers, $_GET['customer']);?></td>
 599                </tr>
 600                <tr>
 601                  <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 602                </tr>
 603                <tr>
 604                  <td class="main"><?php echo TEXT_FROM; ?>&nbsp;&nbsp;</td>
 605                  <td><?php echo zen_draw_input_field('from', EMAIL_FROM, 'size="50"'); ?></td>
 606                </tr>
 607                <tr>
 608                  <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 609                </tr>
 610  <?php
 611  /*

 612                <tr>

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

 614                  <td><?php echo zen_draw_checkbox_field('customers_restrict', $customers_restrict);?></td>

 615                </tr>

 616                <tr>

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

 618                </tr>

 619  */
 620  ?>
 621                <tr>
 622                  <td class="main"><?php echo TEXT_SUBJECT; ?>&nbsp;&nbsp;</td>
 623                  <td><?php echo zen_draw_input_field('subject', '', 'size="50"'); ?></td>
 624                </tr>
 625                <tr>
 626                  <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 627                </tr>
 628                <tr>
 629                  <td valign="top" class="main"><?php echo TEXT_RICH_TEXT_MESSAGE; ?></td>
 630                  <td>
 631  <?php  if (EMAIL_USE_HTML == 'true') {
 632                if ($_SESSION['html_editor_preference_status']=="FCKEDITOR") {
 633                  $oFCKeditor = new FCKeditor('message_html') ;
 634                  $oFCKeditor->Value = ($_POST['message_html']=='') ? TEXT_COUPON_ANNOUNCE : stripslashes($_POST['message_html']) ;
 635                  $oFCKeditor->Width  = '97%' ;
 636                  $oFCKeditor->Height = '250' ;
 637  //                $oFCKeditor->Config['ToolbarLocation'] = 'Out:xToolbar' ;

 638  //                $oFCKeditor->Create() ;

 639                  $output = $oFCKeditor->CreateHtml() ; echo $output;
 640                      } else { // using HTMLAREA or just raw "source"
 641                      echo zen_draw_textarea_field('message_html', 'soft', '100%', '25', ($_POST['message_html']=='') ? TEXT_COUPON_ANNOUNCE : stripslashes($_POST['message_html']), 'id="message_html"');
 642            }
 643  } ?>
 644                  </td>
 645                </tr>
 646                <tr>
 647                  <td valign="top" class="main"><?php echo TEXT_MESSAGE; ?>&nbsp;&nbsp;</td>
 648                  <td><?php echo zen_draw_textarea_field('message', 'soft', '60', '15', strip_tags(($_POST['message_html']=='') ? TEXT_COUPON_ANNOUNCE : stripslashes($_POST['message_html']))); ?></td>
 649                </tr>
 650                <tr>
 651                  <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 652                </tr>
 653                <tr>
 654                  <td colspan="2" align="right"><?php echo '<a href="' . zen_href_link(FILENAME_COUPON_ADMIN, 'cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a> ' .  zen_image_submit('button_send_mail.gif', IMAGE_SEND_EMAIL); ?></td>
 655                </tr>
 656              </table></td>
 657            </form></tr>
 658      </table></td>
 659  <?php
 660      break;
 661    case 'update_preview':
 662  ?>
 663        <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 664        <tr>
 665          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 666            <tr>
 667              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 668              <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 669            </tr>
 670          </table></td>
 671        </tr>
 672        <tr>
 673        <td>
 674  <?php echo zen_draw_form('coupon', FILENAME_COUPON_ADMIN, 'action=update_confirm&oldaction=' . $_GET['oldaction'] . '&cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')); ?>
 675        <table border="0" width="100%" cellspacing="0" cellpadding="6">
 676          <tr>
 677            <td align="left" class="main"><?php echo COUPON_ZONE_RESTRICTION; ?></td>
 678            <td align="left" class="main"><?php echo zen_get_geo_zone_name($_POST['coupon_zone_restriction']); ?>
 679          </tr>
 680  <?php
 681          $languages = zen_get_languages();
 682          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 683              $language_id = $languages[$i]['id'];
 684  ?>
 685        <tr>
 686          <td align="left"><?php echo COUPON_NAME; ?></td>
 687          <td align="left"><?php echo zen_db_prepare_input($_POST['coupon_name'][$language_id]); ?></td>
 688        </tr>
 689  <?php
 690  }
 691  ?>
 692  <?php
 693          $languages = zen_get_languages();
 694          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 695              $language_id = $languages[$i]['id'];
 696  ?>
 697        <tr>
 698          <td align="left"><?php echo COUPON_DESC; ?></td>
 699          <td align="left"><?php echo zen_db_prepare_input($_POST['coupon_desc'][$language_id]); ?></td>
 700        </tr>
 701  <?php
 702  }
 703  ?>
 704        <tr>
 705          <td align="left"><?php echo COUPON_AMOUNT; ?></td>
 706          <td align="left"><?php echo zen_db_prepare_input($_POST['coupon_amount']); ?></td>
 707        </tr>
 708  
 709        <tr>
 710          <td align="left"><?php echo COUPON_MIN_ORDER; ?></td>
 711          <td align="left"><?php echo zen_db_prepare_input($_POST['coupon_min_order']); ?></td>
 712        </tr>
 713  
 714        <tr>
 715          <td align="left"><?php echo COUPON_FREE_SHIP; ?></td>
 716  <?php
 717      if ($_POST['coupon_free_ship']) {
 718  ?>
 719          <td align="left"><?php echo TEXT_FREE_SHIPPING; ?></td>
 720  <?php
 721      } else {
 722  ?>
 723          <td align="left"><?php echo TEXT_NO_FREE_SHIPPING; ?></td>
 724  <?php
 725      }
 726  ?>
 727        </tr>
 728        <tr>
 729          <td align="left"><?php echo COUPON_CODE; ?></td>
 730  <?php
 731      if ($_POST['coupon_code']) {
 732        $c_code = $_POST['coupon_code'];
 733      } else {
 734        $c_code = $coupon_code;
 735      }
 736  ?>
 737          <td align="left"><?php echo $coupon_code; ?></td>
 738        </tr>
 739  
 740        <tr>
 741          <td align="left"><?php echo COUPON_USES_COUPON; ?></td>
 742          <td align="left"><?php echo $_POST['coupon_uses_coupon']; ?></td>
 743        </tr>
 744  
 745        <tr>
 746          <td align="left"><?php echo COUPON_USES_USER; ?></td>
 747          <td align="left"><?php echo $_POST['coupon_uses_user']; ?></td>
 748        </tr>
 749  
 750        <tr>
 751          <td align="left"><?php echo COUPON_STARTDATE; ?></td>
 752  <?php
 753      $start_date = date(DATE_FORMAT, mktime(0, 0, 0, $_POST['coupon_startdate_month'],$_POST['coupon_startdate_day'] ,$_POST['coupon_startdate_year'] ));
 754  ?>
 755          <td align="left"><?php echo $start_date; ?></td>
 756        </tr>
 757  
 758        <tr>
 759          <td align="left"><?php echo COUPON_FINISHDATE; ?></td>
 760  <?php
 761      $finish_date = date(DATE_FORMAT, mktime(0, 0, 0, $_POST['coupon_finishdate_month'],$_POST['coupon_finishdate_day'] ,$_POST['coupon_finishdate_year'] ));
 762  ?>
 763          <td align="left"><?php echo $finish_date; ?></td>
 764        </tr>
 765  <?php
 766          $languages = zen_get_languages();
 767          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 768            $language_id = $languages[$i]['id'];
 769            echo zen_draw_hidden_field('coupon_name[' . $languages[$i]['id'] . ']', stripslashes($_POST['coupon_name'][$language_id]));
 770            echo zen_draw_hidden_field('coupon_desc[' . $languages[$i]['id'] . ']', stripslashes($_POST['coupon_desc'][$language_id]));
 771         }
 772      echo zen_draw_hidden_field('coupon_amount', $_POST['coupon_amount']);
 773      echo zen_draw_hidden_field('coupon_min_order', $_POST['coupon_min_order']);
 774      echo zen_draw_hidden_field('coupon_free_ship', $_POST['coupon_free_ship']);
 775      echo zen_draw_hidden_field('coupon_code', stripslashes($c_code));
 776      echo zen_draw_hidden_field('coupon_uses_coupon', $_POST['coupon_uses_coupon']);
 777      echo zen_draw_hidden_field('coupon_uses_user', $_POST['coupon_uses_user']);
 778      echo zen_draw_hidden_field('coupon_products', $_POST['coupon_products']);
 779      echo zen_draw_hidden_field('coupon_categories', $_POST['coupon_categories']);
 780      echo zen_draw_hidden_field('coupon_startdate', date('Y-m-d', mktime(0, 0, 0, $_POST['coupon_startdate_month'],$_POST['coupon_startdate_day'] ,$_POST['coupon_startdate_year'] )));
 781      echo zen_draw_hidden_field('coupon_finishdate', date('Y-m-d', mktime(0, 0, 0, $_POST['coupon_finishdate_month'],$_POST['coupon_finishdate_day'] ,$_POST['coupon_finishdate_year'] )));
 782      echo zen_draw_hidden_field('coupon_zone_restriction', $_POST['coupon_zone_restriction']);
 783  ?>
 784       <tr>
 785          <td align="left"><?php echo zen_image_submit('button_confirm.gif',COUPON_BUTTON_CONFIRM, (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')); ?></td>
 786          <td align="left"><?php echo zen_image_submit('button_cancel.gif',COUPON_BUTTON_CANCEL, 'name=back'); ?></td>
 787        </td>
 788        </tr>
 789  
 790        </td></table></form>
 791        </tr>
 792  
 793        </table></td>
 794  <?php
 795  
 796      break;
 797    case 'voucheredit':
 798      $languages = zen_get_languages();
 799      for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 800        $language_id = $languages[$i]['id'];
 801        $coupon = $db->Execute("select coupon_name,coupon_description
 802                                from " . TABLE_COUPONS_DESCRIPTION . "
 803                                where coupon_id = '" .  $_GET['cid'] . "'
 804                                and language_id = '" . $language_id . "'");
 805  
 806        $_POST['coupon_name'][$language_id] = $coupon->fields['coupon_name'];
 807        $_POST['coupon_desc'][$language_id] = $coupon->fields['coupon_description'];
 808      }
 809  
 810      $coupon = $db->Execute("select coupon_code, coupon_amount, coupon_type, coupon_minimum_order,
 811                                     coupon_start_date, coupon_expire_date, uses_per_coupon,
 812                                     uses_per_user, restrict_to_products, restrict_to_categories, coupon_zone_restriction
 813                              from " . TABLE_COUPONS . "
 814                              where coupon_id = '" . $_GET['cid'] . "'");
 815  
 816      $_POST['coupon_amount'] = $coupon->fields['coupon_amount'];
 817      if ($coupon->fields['coupon_type']=='P') {
 818        $_POST['coupon_amount'] .= '%';
 819      }
 820      if ($coupon->fields['coupon_type']=='S') {
 821        $_POST['coupon_free_ship'] = true;
 822      } else {
 823        $_POST['coupon_free_ship'] = false;
 824      }
 825      $_POST['coupon_min_order'] = $coupon->fields['coupon_minimum_order'];
 826      $_POST['coupon_code'] = $coupon->fields['coupon_code'];
 827      $_POST['coupon_uses_coupon'] = $coupon->fields['uses_per_coupon'];
 828      $_POST['coupon_uses_user'] = $coupon->fields['uses_per_user'];
 829      $_POST['coupon_startdate'] = $coupon->fields['coupon_start_date'];
 830      $_POST['coupon_finishdate'] = $coupon->fields['coupon_expire_date'];
 831      $_POST['coupon_zone_restriction'] = $coupon->fields['coupon_zone_restriction'];
 832  
 833    case 'new':
 834  // set some defaults

 835      if ($_GET['action'] != 'voucheredit' and $_POST['coupon_uses_user'] == '') $_POST['coupon_uses_user'] = 1;
 836  ?>
 837        <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 838        <tr>
 839          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 840            <tr>
 841              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 842              <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 843            </tr>
 844          </table></td>
 845        </tr>
 846        <tr>
 847        <td>
 848  <?php
 849      echo zen_draw_form('coupon', FILENAME_COUPON_ADMIN, 'action=update&oldaction=' . $_GET['action'] . '&cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''));
 850  ?>
 851        <table border="0" width="100%" cellspacing="0" cellpadding="6">
 852  <?php
 853          $languages = zen_get_languages();
 854          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 855          $language_id = $languages[$i]['id'];
 856  ?>
 857        <tr>
 858          <td align="left" class="main"><?php if ($i==0) echo COUPON_NAME; ?></td>
 859          <td align="left"><?php echo zen_draw_input_field('coupon_name[' . $languages[$i]['id'] . ']', stripslashes($_POST['coupon_name'][$language_id])) . '&nbsp;' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?></td>
 860          <td align="left" class="main" width="40%"><?php if ($i==0) echo COUPON_NAME_HELP; ?></td>
 861        </tr>
 862  <?php
 863  }
 864  ?>
 865  <?php
 866          $languages = zen_get_languages();
 867          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
 868          $language_id = $languages[$i]['id'];
 869  ?>
 870  
 871        <tr>
 872          <td align="left" valign="top" class="main"><?php if ($i==0) echo COUPON_DESC; ?></td>
 873          <td align="left" valign="top"><?php
 874              if ($_SESSION['html_editor_preference_status']=="FCKEDITOR") {
 875                  $oFCKeditor = new FCKeditor('coupon_desc[' . $languages[$i]['id'] . ']') ;
 876                  $oFCKeditor->Value = (stripslashes($_POST['coupon_desc'][$language_id]) != '') ? stripslashes($_POST['coupon_desc'][$language_id]) : '';
 877                  $oFCKeditor->Width  = '97%' ;
 878                  $oFCKeditor->Height = '200' ;
 879  //                $oFCKeditor->Config['ToolbarLocation'] = 'Out:xToolbar' ;

 880  //                $oFCKeditor->Create() ;

 881                  $output = $oFCKeditor->CreateHtml() ; echo $output;
 882                      } else { // using HTMLAREA or just raw "source"
 883                        echo zen_draw_textarea_field('coupon_desc[' . $languages[$i]['id'] . ']','physical','24','8', stripslashes($_POST['coupon_desc'][$language_id]));
 884            }
 885                      echo '&nbsp;' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?></td>
 886          <td align="left" valign="top" class="main"><?php if ($i==0) echo COUPON_DESC_HELP; ?></td>
 887        </tr>
 888  <?php
 889  }
 890  ?>
 891        <tr>
 892          <td align="left" class="main"><?php echo COUPON_AMOUNT; ?></td>
 893          <td align="left"><?php echo zen_draw_input_field('coupon_amount', $_POST['coupon_amount']); ?></td>
 894          <td align="left" class="main"><?php echo COUPON_AMOUNT_HELP; ?></td>
 895        </tr>
 896        <tr>
 897          <td align="left" class="main"><?php echo COUPON_MIN_ORDER; ?></td>
 898          <td align="left"><?php echo zen_draw_input_field('coupon_min_order', $_POST['coupon_min_order']); ?></td>
 899          <td align="left" class="main"><?php echo COUPON_MIN_ORDER_HELP; ?></td>
 900        </tr>
 901        <tr>
 902          <td align="left" class="main"><?php echo COUPON_FREE_SHIP; ?></td>
 903          <td align="left"><input type="checkbox" name="coupon_free_ship" <?php if ($_POST['coupon_free_ship']) echo 'CHECKED'; ?>></td>
 904          <td align="left" class="main"><?php echo COUPON_FREE_SHIP_HELP; ?></td>
 905        </tr>
 906        <tr>
 907          <td align="left" class="main"><?php echo COUPON_CODE; ?></td>
 908          <td align="left"><?php echo zen_draw_input_field('coupon_code', $_POST['coupon_code']); ?></td>
 909          <td align="left" class="main"><?php echo COUPON_CODE_HELP; ?></td>
 910        </tr>
 911        <tr>
 912          <td align="left" class="main"><?php echo COUPON_USES_COUPON; ?></td>
 913          <td align="left"><?php echo zen_draw_input_field('coupon_uses_coupon', ($_POST['coupon_uses_coupon'] >= 1 ? $_POST['coupon_uses_coupon'] : '')); ?></td>
 914          <td align="left" class="main"><?php echo COUPON_USES_COUPON_HELP; ?></td>
 915        </tr>
 916        <tr>
 917          <td align="left" class="main"><?php echo COUPON_USES_USER; ?></td>
 918          <td align="left"><?php echo zen_draw_input_field('coupon_uses_user', ($_POST['coupon_uses_user'] >= 1 ? $_POST['coupon_uses_user'] : '')); ?></td>
 919          <td align="left" class="main"><?php echo COUPON_USES_USER_HELP; ?></td>
 920        </tr>
 921        <tr>
 922  <?php
 923      if (!$_POST['coupon_startdate']) {
 924        $coupon_startdate = split("[-]", date('Y-m-d'));
 925      } else {
 926        $coupon_startdate = split("[-]", $_POST['coupon_startdate']);
 927      }
 928      if (!$_POST['coupon_finishdate']) {
 929        $coupon_finishdate = split("[-]", date('Y-m-d'));
 930        $coupon_finishdate[0] = $coupon_finishdate[0] + 1;
 931      } else {
 932        $coupon_finishdate = split("[-]", $_POST['coupon_finishdate']);
 933      }
 934  ?>
 935          <td align="left" class="main"><?php echo COUPON_STARTDATE; ?></td>
 936          <td align="left"><?php echo zen_draw_date_selector('coupon_startdate', mktime(0,0,0, $coupon_startdate[1], $coupon_startdate[2], $coupon_startdate[0], 0)); ?></td>
 937          <td align="left" class="main"><?php echo COUPON_STARTDATE_HELP; ?></td>
 938        </tr>
 939        <tr>
 940          <td align="left" class="main"><?php echo COUPON_FINISHDATE; ?></td>
 941          <td align="left"><?php echo zen_draw_date_selector('coupon_finishdate', mktime(0,0,0, $coupon_finishdate[1], $coupon_finishdate[2], $coupon_finishdate[0], 0)); ?></td>
 942          <td align="left" class="main"><?php echo COUPON_FINISHDATE_HELP; ?></td>
 943        </tr>
 944        <tr>
 945          <td align="left" class="main"><?php echo COUPON_ZONE_RESTRICTION; ?></td>
 946          <td align="left" class="main"><?php echo zen_geo_zones_pull_down_coupon('name="coupon_zone_restriction" style="font-size:10px"', $_POST['coupon_zone_restriction']); ?>
 947          <td align="left" class="main"><?php echo TEXT_COUPON_ZONE_RESTRICTION; ?></td>
 948        </tr>
 949        <tr>
 950          <td align="left"><?php echo zen_image_submit('button_preview.gif',COUPON_BUTTON_PREVIEW); ?></td>
 951          <td align="left"><?php echo '&nbsp;&nbsp;<a href="' . zen_href_link(FILENAME_COUPON_ADMIN, 'cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')); ?>"><?php echo zen_image_button('button_cancel.gif', IMAGE_CANCEL); ?></a>
 952        </td>
 953        </tr>
 954        </td></table></form>
 955        </tr>
 956  
 957        </table></td>
 958  <?php
 959      break;
 960    default:
 961  ?>
 962      <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 963        <tr>
 964          <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
 965            <tr>
 966              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 967              <td class="main"><?php echo zen_draw_form('status', FILENAME_COUPON_ADMIN, '', 'get'); ?>
 968  <?php
 969      $status_array[] = array('id' => 'Y', 'text' => TEXT_COUPON_ACTIVE);
 970      $status_array[] = array('id' => 'N', 'text' => TEXT_COUPON_INACTIVE);
 971      $status_array[] = array('id' => '*', 'text' => TEXT_COUPON_ALL);
 972  
 973      if ($_GET['status']) {
 974        $status = zen_db_prepare_input($_GET['status']);
 975      } else {
 976        $status = 'Y';
 977      }
 978  
 979      echo zen_hide_session_id();
 980      echo HEADING_TITLE_STATUS . ' ' . zen_draw_pull_down_menu('status', $status_array, $status, 'onChange="this.form.submit();"') .
 981      zen_draw_hidden_field('page', $_GET['page']);
 982  ?>
 983                </form>
 984             </td>
 985              <td class="main">
 986  <?php
 987  // toggle switch for editor

 988          echo TEXT_EDITOR_INFO . zen_draw_form('set_editor_form', FILENAME_COUPON_ADMIN, '', 'get') . '&nbsp;&nbsp;' . zen_draw_pull_down_menu('reset_editor', $editors_pulldown, $current_editor_key, 'onChange="this.form.submit();"') .
 989          zen_hide_session_id() .
 990          zen_draw_hidden_field('action', 'set_editor') .
 991          '</form>';
 992  ?>
 993  </td>
 994            </tr>
 995          </table></td>
 996        </tr>
 997        <tr>
 998          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 999            <tr>
1000              <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
1001                <tr class="dataTableHeadingRow">
1002                  <td class="dataTableHeadingContent"><?php echo COUPON_NAME; ?></td>
1003                  <td class="dataTableHeadingContent" align="center"><?php echo COUPON_AMOUNT; ?></td>
1004                  <td class="dataTableHeadingContent" align="center"><?php echo COUPON_CODE; ?></td>
1005                  <td class="dataTableHeadingContent" align="center"><?php echo COUPON_ACTIVE; ?></td>
1006                  <td class="dataTableHeadingContent" align="center"><?php echo COUPON_START_DATE; ?></td>
1007                  <td class="dataTableHeadingContent" align="center"><?php echo COUPON_EXPIRE_DATE; ?></td>
1008                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
1009                </tr>
1010  <?php
1011      if ($_GET['page'] > 1) $rows = $_GET['page'] * 20 - 20;
1012      if ($status != '*') {
1013        $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, coupon_active, coupon_zone_restriction from " . TABLE_COUPONS ." where coupon_active='" . zen_db_input($status) . "' and coupon_type != 'G'";
1014      } else {
1015        $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, coupon_active, coupon_zone_restriction from " . TABLE_COUPONS . " where coupon_type != 'G'";
1016      }
1017      $cc_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS_DISCOUNT_COUPONS, $cc_query_raw, $cc_query_numrows);
1018      $cc_list = $db->Execute($cc_query_raw);
1019      while (!$cc_list->EOF) {
1020        $rows++;
1021        if (strlen($rows) < 2) {
1022          $rows = '0' . $rows;
1023        }
1024        if (((!$_GET['cid']) || (@$_GET['cid'] == $cc_list->fields['coupon_id'])) && (!$cInfo)) {
1025          $cInfo = new objectInfo($cc_list->fields);
1026        }
1027        if ( (is_object($cInfo)) && ($cc_list->fields['coupon_id'] == $cInfo->coupon_id) ) {
1028          echo '          <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . zen_href_link(FILENAME_COUPON_ADMIN, zen_get_all_get_params(array('cid', 'action')) . 'cid=' . $cInfo->coupon_id . '&action=voucheredit') . '\'">' . "\n";
1029        } else {
1030          echo '          <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . zen_href_link(FILENAME_COUPON_ADMIN, zen_get_all_get_params(array('cid', 'action')) . 'cid=' . $cc_list->fields['coupon_id']) . '\'">' . "\n";
1031        }
1032        $coupon_desc = $db->Execute("select coupon_name
1033                                     from " . TABLE_COUPONS_DESCRIPTION . "
1034                                     where coupon_id = '" . $cc_list->fields['coupon_id'] . "'
1035                                     and language_id = '" . $_SESSION['languages_id'] . "'");
1036  ?>
1037                  <td class="dataTableContent"><?php echo $coupon_desc->fields['coupon_name']; ?></td>
1038                  <td class="dataTableContent" align="center">
1039  <?php
1040        if ($cc_list->fields['coupon_type'] == 'P') {
1041          echo $cc_list->fields['coupon_amount'] . '%';
1042        } elseif ($cc_list->fields['coupon_type'] == 'S') {
1043          echo TEXT_FREE_SHIPPING;
1044        } else {
1045          echo $currencies->format($cc_list->fields['coupon_amount']);
1046        }
1047  ?>
1048              &nbsp;</td>
1049                  <td class="dataTableContent" align="center"><?php echo $cc_list->fields['coupon_code']; ?></td>
1050                  <td class="dataTableContent" align="center"><?php echo $cc_list->fields['coupon_active']; ?></td>
1051                  <td class="dataTableContent" align="center"><?php echo zen_date_short($cc_list->fields['coupon_start_date']); ?></td>
1052                  <td class="dataTableContent" align="center"><?php echo zen_date_short($cc_list->fields['coupon_expire_date']); ?></td>
1053                  <td class="dataTableContent" align="right"><?php if ( (is_object($cInfo)) && ($cc_list->fields['coupon_id'] == $cInfo->coupon_id) ) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . zen_href_link(FILENAME_COUPON_ADMIN, 'page=' . $_GET['page'] . '&cid=' . $cc_list->fields['coupon_id']) . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
1054                </tr>
1055  <?php
1056        $cc_list->MoveNext();
1057      }
1058  ?>
1059            <tr>
1060              <td colspan="7"><table border="0" width="100%" cellspacing="0" cellpadding="2">
1061                <tr>
1062                  <td class="smallText">&nbsp;<?php echo $cc_split->display_count($cc_query_numrows, MAX_DISPLAY_SEARCH_RESULTS_DISCOUNT_COUPONS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_COUPONS); ?>&nbsp;</td>
1063                  <td align="right" class="smallText">&nbsp;<?php echo $cc_split->display_links($cc_query_numrows, MAX_DISPLAY_SEARCH_RESULTS_DISCOUNT_COUPONS, MAX_DISPLAY_PAGE_LINKS, $_GET['page'], (isset($_GET['status']) ? '&status=' . $_GET['status'] : '')); ?>&nbsp;</td>
1064                </tr>
1065  
1066                <tr>
1067                  <td align="right" colspan="2" class="smallText"><?php echo '<a href="' . zen_href_link(FILENAME_COUPON_ADMIN, 'page=' . $_GET['page'] . '&cid=' . $cInfo->coupon_id . '&action=new') . '">' . zen_image_button('button_insert.gif', IMAGE_INSERT) . '</a>'; ?></td>
1068                </tr>
1069              </table></td>
1070            </tr>
1071          </table></td>
1072  
1073  <?php
1074  
1075      $heading = array();
1076      $contents = array();
1077  
1078      switch ($_GET['action']) {
1079      case 'release':
1080        break;
1081      case 'voucherreport':
1082        $heading[] = array('text' => '<b>' . TEXT_HEADING_COUPON_REPORT . '</b>');
1083        $contents[] = array('text' => TEXT_NEW_INTRO);
1084        break;
1085      case 'new':
1086        $heading[] = array('text' => '<b>' . TEXT_HEADING_NEW_COUPON . '</b>');
1087        $contents[] = array('text' => TEXT_NEW_INTRO);
1088        $contents[] = array('text' => '<br />' . COUPON_NAME . '<br />' . zen_draw_input_field('name'));
1089        $contents[] = array('text' => '<br />' . COUPON_AMOUNT . '<br />' . zen_draw_input_field('voucher_amount'));
1090        $contents[] = array('text' => '<br />' . COUPON_CODE . '<br />' . zen_draw_input_field('voucher_code'));
1091        $contents[] = array('text' => '<br />' . COUPON_USES_COUPON . '<br />' . zen_draw_input_field('voucher_number_of'));
1092        break;
1093      default:
1094        $heading[] = array('text'=>'['.$cInfo->coupon_id.']  '.$cInfo->coupon_code);
1095        $amount = $cInfo->coupon_amount;
1096        if ($cInfo->coupon_type == 'P') {
1097          $amount .= '%';
1098        } else {
1099          $amount = $currencies->format($amount);
1100        }
1101        if ($_GET['action'] == 'voucherdelete' or $_GET['action'] == 'vouchercopy') {
1102          if ($_GET['action'] == 'voucherdelete') {
1103            $contents[] = array('text'=> TEXT_CONFIRM_DELETE . '</br></br>' .
1104                    '<a href="'.zen_href_link(FILENAME_COUPON_ADMIN,'action=confirmdelete&cid='.$_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''),'NONSSL').'">'.zen_image_button('button_confirm.gif','Confirm Delete ' . TEXT_DISCOUNT_COUPON).'</a>' .
1105                    '<a href="'.zen_href_link(FILENAME_COUPON_ADMIN,'cid='.$cInfo->coupon_id . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''),'NONSSL').'">'.zen_image_button('button_cancel.gif','Cancel').'</a>'
1106                    );
1107          }
1108          if ($_GET['action'] == 'vouchercopy') {
1109            $contents = array('form' => zen_draw_form('new_coupon', FILENAME_COUPON_ADMIN, 'action=confirmcopy' . '&cid='.$_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''), 'post', 'enctype="multipart/form-data"'));
1110  
1111            $contents[] = array('text' => '<br>' . TEXT_COUPON_NEW . '&nbsp;' . zen_draw_input_field('coupon_copy_to', '', 6, 6));
1112  
1113            $contents[] = array('text'=> TEXT_CONFIRM_COPY . '</br>');
1114            $contents[] = array('text'=> zen_image_submit('button_save.gif', IMAGE_SAVE));
1115            $contents[] = array('text'=>
1116                    '<a href="'.zen_href_link(FILENAME_COUPON_ADMIN,'cid='.$cInfo->coupon_id . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''),'NONSSL').'">'.zen_image_button('button_cancel.gif','Cancel').'</a>'
1117                    );
1118  /*

1119            $contents[] = array('text'=>

1120                    '<a href="'.zen_href_link(FILENAME_COUPON_ADMIN,'action=confirmcopy&cid='.$_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . '&coupon_copy_to=' . $_GET['coupon_copy_to'] . '-' . $_POST['coupon_copy_to'] . '-' . $coupon_copy_to,'NONSSL').'">'.zen_image_button('button_confirm.gif','Confirm Copy ' . TEXT_DISCOUNT_COUPON).'</a>' .

1121  

1122  

1123                    '<a href="'.zen_href_link(FILENAME_COUPON_ADMIN,'cid='.$cInfo->coupon_id . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''),'NONSSL').'">'.zen_image_button('button_cancel.gif','Cancel').'</a>'

1124                    );

1125  */
1126  
1127  
1128          }
1129        } else {
1130          $prod_details = NONE;
1131  //bof 12-6ke

1132  $product_query = $db->Execute("select * from " . TABLE_COUPON_RESTRICT . " where coupon_id = '" . $cInfo->coupon_id . "' and product_id != '0'");        if ($product_query->RecordCount() > 0) $prod_details = TEXT_SEE_RESTRICT;
1133  //eof 12-6ke

1134          $cat_details = NONE;
1135  //bof 12-6ke

1136  $category_query = $db->Execute("select * from " . TABLE_COUPON_RESTRICT . " where coupon_id = '" . $cInfo->coupon_id . "' and category_id != '0'");        if ($category_query->RecordCount() > 0) $cat_details = TEXT_SEE_RESTRICT;
1137  //eof 12-6ke

1138          $coupon_name = $db->Execute("select coupon_name
1139                                       from " . TABLE_COUPONS_DESCRIPTION . "
1140                                       where coupon_id = '" . $cInfo->coupon_id . "'
1141                                       and language_id = '" . $_SESSION['languages_id'] . "'");
1142          $uses_coupon = $cInfo->uses_per_coupon;
1143          $uses_user = $cInfo->uses_per_user;
1144          if ($uses_coupon == 0 || $uses_coupon == '') $uses_coupon = TEXT_UNLIMITED;
1145          if ($uses_user == 0 || $uses_user == '') $uses_user = TEXT_UNLIMITED;
1146          $contents[] = array('text'=>COUPON_NAME . '&nbsp;::&nbsp; ' . $coupon_name->fields['coupon_name'] . '<br />' .
1147                       COUPON_AMOUNT . '&nbsp;::&nbsp; ' . $amount . '<br />' .
1148                       COUPON_STARTDATE . '&nbsp;::&nbsp; ' . zen_date_short($cInfo->coupon_start_date) . '<br />' .
1149                       COUPON_FINISHDATE . '&nbsp;::&nbsp; ' . zen_date_short($cInfo->coupon_expire_date) . '<br />' .
1150                       COUPON_USES_COUPON . '&nbsp;::&nbsp; ' . $uses_coupon . '<br />' .
1151                       COUPON_USES_USER . '&nbsp;::&nbsp; ' . $uses_user . '<br />' .
1152                       COUPON_PRODUCTS . '&nbsp;::&nbsp; ' . $prod_details . '<br />' .
1153                       COUPON_CATEGORIES . '&nbsp;::&nbsp; ' . $cat_details . '<br />' .
1154                       DATE_CREATED . '&nbsp;::&nbsp; ' . zen_date_short($cInfo->date_created) . '<br />' .
1155                       DATE_MODIFIED . '&nbsp;::&nbsp; ' . zen_date_short($cInfo->date_modified) . '<br /><br />' .
1156                       COUPON_ZONE_RESTRICTION . '&nbsp;::&nbsp; ' . zen_get_geo_zone_name($cInfo->coupon_zone_restriction) . '<br /><br />' .
1157                       ($cInfo->coupon_id != '' ?
1158                       '<center><a href="'.zen_href_link(FILENAME_COUPON_ADMIN,'action=email&cid='.$cInfo->coupon_id,'NONSSL').'">'.zen_image_button('button_email.gif','Email ' . TEXT_DISCOUNT_COUPON).'</a>' .
1159                       '<a href="'.zen_href_link(FILENAME_COUPON_ADMIN,'action=voucheredit&cid='.$cInfo->coupon_id . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''),'NONSSL').'">'.zen_image_button('button_edit.gif','Edit ' . TEXT_DISCOUNT_COUPON) .'</a>' .
1160                       '<a href="'.zen_href_link(FILENAME_COUPON_ADMIN,'action=voucherdelete&cid='.$cInfo->coupon_id . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''),'NONSSL').'">'.zen_image_button('button_delete.gif','Delete ' . TEXT_DISCOUNT_COUPON).'</a>' .
1161                       '<br /><a href="'.zen_href_link('coupon_restrict.php','cid='.$cInfo->coupon_id  . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''),'NONSSL').'">'.zen_image_button('button_restrict.gif','Restrict').'</a><a href="'.zen_href_link(FILENAME_COUPON_ADMIN,'action=voucherreport&cid='.$cInfo->coupon_id . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''),'NONSSL').'">'.zen_image_button('button_report.gif',TEXT_DISCOUNT_COUPON . ' Report').
1162                       '<a href="'.zen_href_link(FILENAME_COUPON_ADMIN,'action=vouchercopy&cid='.$cInfo->coupon_id . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''),'NONSSL').'">'.zen_image_button('button_copy.gif','Copy ' . TEXT_DISCOUNT_COUPON) . '</a></center>'
1163                       : ' who ' . $cInfo->coupon_id . ' - ' . $_GET['cid'])
1164                       );
1165          }
1166          break;
1167        }
1168  ?>
1169      <td width="25%" valign="top">
1170  <?php
1171        $box = new box;
1172        echo $box->infoBox($heading, $contents);
1173      echo '            </td>' . "\n";
1174      }
1175  ?>
1176        </tr>
1177      </table></td>
1178  <!-- body_text_eof //-->
1179    </tr>
1180  </table>
1181  <!-- body_eof //-->
1182  <!-- footer //-->
1183  <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
1184  <!-- footer_eof //-->
1185  </body>
1186  </html>
1187  <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>


Généré le : Mon Nov 26 16:45:43 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics