[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 coupon_admin.php

Zen Cart 源代码 coupon_admin.php




下载文件

文件名: coupon_admin.php
文件类型: PHP文件
文件大小: 65.01 KiB
MD5: ea60766e18d628e47409bf8834a60d15

coupon_admin.php - 关闭高亮
  1. <?php
  2. /**
  3.  * @package admin
  4.  * @copyright Copyright 2003-2009 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 14139 2009-08-10 13:46:02Z 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, coupon_start_date, coupon_expire_date
  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.     $text_coupon_help = sprintf(TEXT_COUPON_HELP_DATE, zen_date_short($coupon_result->fields['coupon_start_date']), zen_date_short($coupon_result->fields['coupon_expire_date']));
  46.     $html_coupon_help = sprintf(HTML_COUPON_HELP_DATE, zen_date_short($coupon_result->fields['coupon_start_date']), zen_date_short($coupon_result->fields['coupon_expire_date']));
  47.  
  48.     while (!$mail->EOF) {
  49.       $message = zen_db_prepare_input($_POST['message']);
  50.       $message .= "\n\n" . TEXT_TO_REDEEM . "\n\n";
  51.       $message .= TEXT_VOUCHER_IS . $coupon_result->fields['coupon_code'] . "\n\n";
  52.       $message .= $text_coupon_help . "\n\n";
  53.       $message .= TEXT_REMEMBER . "\n\n";
  54.       $message .=(!empty($coupon_name->fields['coupon_description']) ? $coupon_name->fields['coupon_description'] . "\n\n" : '');
  55.       $message .= sprintf(TEXT_VISIT ,HTTP_CATALOG_SERVER . DIR_WS_CATALOG);
  56.  
  57.       // disclaimer
  58.       $message .= "\n-----\n" . sprintf(EMAIL_DISCLAIMER, STORE_OWNER_EMAIL_ADDRESS) . "\n\n";
  59.  
  60.       $html_msg['EMAIL_FIRST_NAME'] = $mail->fields['customers_firstname'];
  61.       $html_msg['EMAIL_LAST_NAME']  = $mail->fields['customers_lastname'];
  62.       $html_msg['EMAIL_MESSAGE_HTML'] = zen_db_prepare_input($_POST['message_html']);
  63.       $html_msg['COUPON_TEXT_TO_REDEEM'] = TEXT_TO_REDEEM;
  64.       $html_msg['COUPON_TEXT_VOUCHER_IS'] = TEXT_VOUCHER_IS;
  65.       $html_msg['COUPON_CODE'] = $coupon_result->fields['coupon_code'] . $html_coupon_help;
  66.       $html_msg['COUPON_DESCRIPTION'] =(!empty($coupon_name->fields['coupon_description']) ? $coupon_name->fields['coupon_description'] : '');
  67.       $html_msg['COUPON_TEXT_REMEMBER']  = TEXT_REMEMBER;
  68.       $html_msg['COUPON_REDEEM_STORENAME_URL'] = sprintf(TEXT_VISIT ,'<a href="'.HTTP_CATALOG_SERVER . DIR_WS_CATALOG.'">'.STORE_NAME.'</a>');
  69.  
  70. //Send the emails
  71.       zen_mail($mail->fields['customers_firstname'] . ' ' . $mail->fields['customers_lastname'], $mail->fields['customers_email_address'], $subject , $message, '',$from, $html_msg, 'coupon');
  72.  
  73.       $recip_count++;
  74.       // send copy to Admin if enabled
  75.       if (SEND_EXTRA_DISCOUNT_COUPON_ADMIN_EMAILS_TO_STATUS== '1' and SEND_EXTRA_DISCOUNT_COUPON_ADMIN_EMAILS_TO != '') {
  76.         zen_mail('', SEND_EXTRA_DISCOUNT_COUPON_ADMIN_EMAILS_TO, SEND_EXTRA_DISCOUNT_COUPON_ADMIN_EMAILS_TO_SUBJECT . ' ' . $subject , $message, '',$from, $html_msg, 'coupon_extra');
  77.       }
  78.       $mail->MoveNext();
  79.     }
  80.     zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'mail_sent_to=' . urlencode($mail_sent_to) . '&recip_count='. $recip_count ));
  81.   }
  82.  
  83.   if ( ($_GET['action'] == 'preview_email') && (!$_POST['customers_email_address']) ) {
  84.     $_GET['action'] = 'email';
  85.     $messageStack->add(ERROR_NO_CUSTOMER_SELECTED, 'error');
  86.   }
  87.  
  88.   if ($_GET['mail_sent_to']) {
  89.     $messageStack->add(sprintf(NOTICE_EMAIL_SENT_TO, $_GET['mail_sent_to']. '(' . $_GET['recip_count'] . ')'), 'success');
  90.     $_GET['mail_sent_to'] = '';
  91.   }
  92.  
  93.   switch ($_GET['action']) {
  94.       case 'set_editor':
  95.         // Reset will be done by init_html_editor.php. Now we simply redirect to refresh page properly.
  96.         $action='';
  97.         zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN));
  98.         break;
  99.     case 'confirmdelete':
  100.       // demo active test
  101.       if (zen_admin_demo()) {
  102.         $_GET['action']= '';
  103.         $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
  104.         zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN));
  105.       }
  106.  
  107. // do not allow change if set to welcome coupon
  108.       if ($_GET['cid'] == NEW_SIGNUP_DISCOUNT_COUPON) {
  109.         $messageStack->add_session(ERROR_DISCOUNT_COUPON_WELCOME, 'caution');
  110.         zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
  111.       }
  112.  
  113.       $db->Execute("update " . TABLE_COUPONS . "
  114.                    set coupon_active = 'N'
  115.                    where coupon_id='".$_GET['cid']."'");
  116.       $messageStack->add_session(SUCCESS_COUPON_DISABLED, 'success');
  117.       zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN));
  118.       break;
  119.     case 'confirmcopy':
  120.       $coupon_copy_to = trim($_POST['coupon_copy_to']);
  121.  
  122.       // check if new coupon code exists
  123.       $sql = "SELECT * from " . TABLE_COUPONS . " where coupon_code='" . $coupon_copy_to . "'";
  124.       $check_new_coupon = $db->Execute($sql);
  125.       if ($check_new_coupon->RecordCount() > 0) {
  126.         $messageStack->add_session(ERROR_DISCOUNT_COUPON_DUPLICATE . $coupon_copy_to, 'caution');
  127.         zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
  128.       }
  129.  
  130.       $sql = "SELECT * from " . TABLE_COUPONS . " where coupon_id='" . $_GET['cid'] . "'";
  131.       $check_new_coupon = $db->Execute($sql);
  132.  
  133.       // create duplicate coupon
  134.         $sql_data_array = array('coupon_code' => zen_db_prepare_input($coupon_copy_to),
  135.                                 'coupon_amount' => zen_db_prepare_input($check_new_coupon->fields['coupon_amount']),
  136.                                 'coupon_type' => zen_db_prepare_input($check_new_coupon->fields['coupon_type']),
  137.                                 'uses_per_coupon' => zen_db_prepare_input((int)$check_new_coupon->fields['uses_per_coupon']),
  138.                                 'uses_per_user' => zen_db_prepare_input((int)$check_new_coupon->fields['uses_per_user']),
  139.                                 'coupon_minimum_order' => zen_db_prepare_input((float)$check_new_coupon->fields['coupon_minimum_order']),
  140.                                 'restrict_to_products' => zen_db_prepare_input($check_new_coupon->fields['restrict_to_products']),
  141.                                 'restrict_to_categories' => zen_db_prepare_input($check_new_coupon->fields['restrict_to_categories']),
  142.                                 'coupon_start_date' => $check_new_coupon->fields['coupon_start_date'],
  143.                                 'coupon_expire_date' => $check_new_coupon->fields['coupon_expire_date'],
  144.                                 'date_created' => 'now()',
  145.                                 'date_modified' => 'now()',
  146.                                 'coupon_zone_restriction' => $check_new_coupon->fields['coupon_zone_restriction']);
  147.  
  148.           zen_db_perform(TABLE_COUPONS, $sql_data_array);
  149.           $insert_id = $db->Insert_ID();
  150.           $cid = $insert_id;
  151. //          $_GET['cid'] = $cid;
  152.  
  153.           // create duplicate coupon description
  154.           $sql = "SELECT * from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id='" . $_GET['cid'] . "'";
  155.           $new_coupon_descriptions = $db->Execute($sql);
  156.  
  157.           while (!$new_coupon_descriptions->EOF) {
  158.             $sql_mdata_array = array('coupon_id' => zen_db_prepare_input($cid),
  159.                                     'language_id' => zen_db_prepare_input($new_coupon_descriptions->fields['language_id']),
  160.                                     'coupon_name' => zen_db_prepare_input('COPY: ' . $new_coupon_descriptions->fields['coupon_name']),
  161.                                     'coupon_description' => zen_db_prepare_input($new_coupon_descriptions->fields['coupon_description'])
  162.                                     );
  163.             zen_db_perform(TABLE_COUPONS_DESCRIPTION, $sql_mdata_array);
  164.             $new_coupon_descriptions->MoveNext();
  165.           }
  166.  
  167.       // copy restrictions
  168.       $sql = "SELECT * from " . TABLE_COUPON_RESTRICT . " where coupon_id='" . $_GET['cid'] . "'";
  169.       $copy_coupon_restrictions = $db->Execute($sql);
  170.  
  171.       while (!$copy_coupon_restrictions->EOF) {
  172.         $sql_rdata_array = array('coupon_id' => zen_db_prepare_input($cid),
  173.                                  'product_id' => zen_db_prepare_input($copy_coupon_restrictions->fields['product_id']),
  174.                                  'category_id' => zen_db_prepare_input($copy_coupon_restrictions->fields['category_id']),
  175.                                  'coupon_restrict' => zen_db_prepare_input($copy_coupon_restrictions->fields['coupon_restrict'])
  176.                                  );
  177.         zen_db_perform(TABLE_COUPON_RESTRICT, $sql_rdata_array);
  178.         $copy_coupon_restrictions->MoveNext();
  179.       }
  180.  
  181.       $_GET['cid'] = $cid;
  182.       $messageStack->add_session(SUCCESS_COUPON_DUPLICATE . $coupon_copy_to, 'success');
  183.       zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'action=voucheredit' . '&cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '')));
  184. //        zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN));
  185.       break;
  186.     case 'update':
  187.       $update_errors = 0;
  188.       // get all HTTP_POST_VARS and validate
  189.       $_POST['coupon_code'] = trim($_POST['coupon_code']);
  190.         $languages = zen_get_languages();
  191.         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  192.           $language_id = $languages[$i]['id'];
  193.           $_POST['coupon_name'][$language_id] = trim($_POST['coupon_name'][$language_id]);
  194.           if (!$_POST['coupon_name'][$language_id]) {
  195.             $update_errors = 1;
  196.             $messageStack->add(ERROR_NO_COUPON_NAME . $languages[$i]['name'], 'error');
  197.           }
  198.           $_POST['coupon_desc'][$language_id] = trim($_POST['coupon_desc'][$language_id]);
  199.         }
  200.       $_POST['coupon_amount'] = trim($_POST['coupon_amount']);
  201.       $_POST['coupon_amount'] = preg_replace('/[^0-9.%]/', '', $_POST['coupon_amount']);
  202.       if (!$_POST['coupon_name']) {
  203.         $update_errors = 1;
  204.         $messageStack->add(ERROR_NO_COUPON_NAME, 'error');
  205.       }
  206.       if ((!$_POST['coupon_amount']) && (!$_POST['coupon_free_ship'])) {
  207.         $update_errors = 1;
  208.         $messageStack->add(ERROR_NO_COUPON_AMOUNT, 'error');
  209.       }
  210.       if (!$_POST['coupon_code']) {
  211.         $coupon_code = create_coupon_code();
  212.       }
  213.       if ($_POST['coupon_code']) $coupon_code = $_POST['coupon_code'];
  214.       $query1 = $db->Execute("select coupon_code
  215.                              from " . TABLE_COUPONS . "
  216.                              where coupon_code = '" . zen_db_prepare_input($coupon_code) . "'");
  217.  
  218.       if ($query1->RecordCount()>0 && $_POST['coupon_code'] && $_GET['oldaction'] != 'voucheredit')  {
  219.         $update_errors = 1;
  220.         $messageStack->add(ERROR_COUPON_EXISTS, 'error');
  221.       }
  222.       if ($update_errors != 0) {
  223.         $_GET['action'] = 'new';
  224.       } else {
  225.         $_GET['action'] = 'update_preview';
  226.       }
  227.       break;
  228.     case 'update_confirm':
  229.       if ( ($_POST['back_x']) || ($_POST['back_y']) ) {
  230.         $_GET['action'] = 'new';
  231.       } else {
  232.         $coupon_type = "F";
  233.         if (substr($_POST['coupon_amount'], -1) == '%') $coupon_type='P';
  234.         $_POST['coupon_amount'] = preg_replace('/[^0-9.]/', '', $_POST['coupon_amount']);
  235.         if ($_POST['coupon_free_ship']) $coupon_type = 'S';
  236.         $sql_data_array = array('coupon_code' => zen_db_prepare_input($_POST['coupon_code']),
  237.                                 'coupon_amount' => zen_db_prepare_input($_POST['coupon_amount']),
  238.                                 'coupon_type' => zen_db_prepare_input($coupon_type),
  239.                                 'uses_per_coupon' => zen_db_prepare_input((int)$_POST['coupon_uses_coupon']),
  240.                                 'uses_per_user' => zen_db_prepare_input((int)$_POST['coupon_uses_user']),
  241.                                 'coupon_minimum_order' => zen_db_prepare_input((float)$_POST['coupon_min_order']),
  242.                                 'restrict_to_products' => zen_db_prepare_input($_POST['coupon_products']),
  243.                                 'restrict_to_categories' => zen_db_prepare_input($_POST['coupon_categories']),
  244.                                 'coupon_start_date' => $_POST['coupon_startdate'],
  245.                                 'coupon_expire_date' => $_POST['coupon_finishdate'],
  246.                                 'date_created' => 'now()',
  247.                                 'date_modified' => 'now()',
  248.                                 'coupon_zone_restriction' => $_POST['coupon_zone_restriction']);
  249.         $languages = zen_get_languages();
  250.         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  251.           $language_id = $languages[$i]['id'];
  252.           $sql_data_marray[$i] = array('coupon_name' => zen_db_prepare_input($_POST['coupon_name'][$language_id]),
  253.                                        'coupon_description' => zen_db_prepare_input($_POST['coupon_desc'][$language_id])
  254.                                        );
  255.         }
  256.         if ($_GET['oldaction']=='voucheredit') {
  257.           zen_db_perform(TABLE_COUPONS, $sql_data_array, 'update', "coupon_id='" . $_GET['cid']."'");
  258.           for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  259.             $language_id = $languages[$i]['id'];
  260.             $sql_data_desc_array = array('coupon_name' => zen_db_prepare_input($_POST['coupon_name'][$language_id]),
  261.                                          'coupon_description' => zen_db_prepare_input($_POST['coupon_desc'][$language_id])
  262.                                          );
  263.             zen_db_perform(TABLE_COUPONS_DESCRIPTION, $sql_data_desc_array, 'update', "coupon_id = '" . $_GET['cid'] . "' and language_id = '" . $languages[$i]['id'] . "'");
  264.           }
  265.         } else {
  266.           zen_db_perform(TABLE_COUPONS, $sql_data_array);
  267.           $insert_id = $db->Insert_ID();
  268.           $cid = $insert_id;
  269.           $_GET['cid'] = $cid;
  270.  
  271.           for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  272.             $language_id = $languages[$i]['id'];
  273.             $sql_data_marray[$i]['coupon_id'] = $insert_id;
  274.             $sql_data_marray[$i]['language_id'] = $language_id;
  275.             zen_db_perform(TABLE_COUPONS_DESCRIPTION, $sql_data_marray[$i]);
  276.           }
  277.         }
  278.       }
  279.       zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
  280.   }
  281. ?>
  282. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  283. <html <?php echo HTML_PARAMS; ?>>
  284. <head>
  285. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  286. <title><?php echo TITLE; ?></title>
  287. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  288. <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
  289. <script language="javascript" src="includes/menu.js"></script>
  290. <script language="javascript" src="includes/general.js"></script>
  291. <link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
  292. <script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
  293. <script language="javascript">
  294.   var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?php echo $pInfo->products_date_available; ?>",scBTNMODE_CUSTOMBLUE);
  295. </script>
  296. <script type="text/javascript">
  297.   <!--
  298.   function init()
  299.   {
  300.     cssjsmenu('navbar');
  301.     if (document.getElementById)
  302.     {
  303.       var kill = document.getElementById('hoverJS');
  304.       kill.disabled = true;
  305.     }
  306. <?php if ($_GET['action'] == 'new') { ?>
  307.     if (typeof _editor_url == "string") HTMLArea.replaceAll();
  308. <?php } else { ?>
  309.     if (typeof _editor_url == "string") HTMLArea.replace('message_html');
  310. <?php } ?>
  311.   }
  312.   // -->
  313. </script>
  314. <script language="javascript" type="text/javascript"><!--
  315. var form = "";
  316. var submitted = false;
  317. var error = false;
  318. var error_message = "";
  319.  
  320. function check_select(field_name, field_default, message) {
  321.   if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
  322.     var field_value = form.elements[field_name].value;
  323.  
  324.     if (field_value == field_default) {
  325.       error_message = error_message + "* " + message + "\n";
  326.       error = true;
  327.     }
  328.   }
  329. }
  330. function check_message(msg) {
  331.   if (form.elements['message'] && form.elements['message_html']) {
  332.     var field_value1 = form.elements['message'].value;
  333.     var field_value2 = form.elements['message_html'].value;
  334.  
  335.     if ((field_value1 == '' || field_value1.length < 3) && (field_value2 == '' || field_value2.length < 3)) {
  336.       error_message = error_message + "* " + msg + "\n";
  337.       error = true;
  338.     }
  339.   }
  340. }
  341. function check_input(field_name, field_size, message) {
  342.   if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
  343.     var field_value = form.elements[field_name].value;
  344.  
  345.     if (field_value == '' || field_value.length < field_size) {
  346.       error_message = error_message + "* " + message + "\n";
  347.       error = true;
  348.     }
  349.   }
  350. }
  351.  
  352. function check_form(form_name) {
  353.   if (submitted == true) {
  354.     alert("<?php echo JS_ERROR_SUBMITTED; ?>");
  355.     return false;
  356.   }
  357.   error = false;
  358.   form = form_name;
  359.   error_message = "<?php echo JS_ERROR; ?>";
  360.  
  361.   check_select('customers_email_address', '', "<?php echo ERROR_NO_CUSTOMER_SELECTED; ?>");
  362.   check_message("<?php echo ENTRY_NOTHING_TO_SEND; ?>");
  363.   check_input('subject','',"<?php echo ERROR_NO_SUBJECT; ?>");
  364.  
  365.   if (error == true) {
  366.     alert(error_message);
  367.     return false;
  368.   } else {
  369.     submitted = true;
  370.     return true;
  371.   }
  372. }
  373. //--></script>
  374. <?php if ($editor_handler != '') include ($editor_handler); ?>
  375. </head>
  376. <body onLoad="init()">
  377. <div id="spiffycalendar" class="text"></div>
  378. <!-- header //-->
  379. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  380. <!-- header_eof //-->
  381.  
  382. <!-- body //-->
  383. <table border="0" width="100%" cellspacing="2" cellpadding="2">
  384.   <tr>
  385. <!-- body_text //-->
  386. <?php
  387.   switch ($_GET['action']) {
  388.   case 'voucherreport':
  389. ?>
  390.       <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  391.       <tr>
  392.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  393.           <tr>
  394.             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  395.             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  396.           </tr>
  397.         </table></td>
  398.       </tr>
  399.       <tr>
  400.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  401.           <tr>
  402.             <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  403.               <tr class="dataTableHeadingRow">
  404.                 <td class="dataTableHeadingContent"><?php echo CUSTOMER_ID; ?></td>
  405.                 <td class="dataTableHeadingContent" align="center"><?php echo CUSTOMER_NAME; ?></td>
  406.                 <td class="dataTableHeadingContent" align="center"><?php echo IP_ADDRESS; ?></td>
  407.                 <td class="dataTableHeadingContent" align="center"><?php echo REDEEM_DATE; ?></td>
  408.                 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
  409.               </tr>
  410. <?php
  411.     $cc_query_raw = "select * from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $_GET['cid'] . "'";
  412.     $cc_split = new splitPageResults($_GET['reports_page'], MAX_DISPLAY_SEARCH_RESULTS_DISCOUNT_COUPONS_REPORTS, $cc_query_raw, $cc_query_numrows);
  413.     $cc_list = $db->Execute($cc_query_raw);
  414.     while (!$cc_list->EOF) {
  415.       $rows++;
  416.       if (strlen($rows) < 2) {
  417.         $rows = '0' . $rows;
  418.       }
  419.       if (((!$_GET['uid']) || (@$_GET['uid'] == $cc_list->fields['unique_id'])) && (!$cInfo)) {
  420.         $cInfo = new objectInfo($cc_list->fields);
  421.       }
  422.       if ( (is_object($cInfo)) && ($cc_list->fields['unique_id'] == $cInfo->unique_id) ) {
  423.         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";
  424.       } else {
  425.         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";
  426.       }
  427. $customer = $db->Execute("select customers_firstname, customers_lastname
  428.                          from " . TABLE_CUSTOMERS . "
  429.                          where customers_id = '" . $cc_list->fields['customer_id'] . "'");
  430.  
  431. ?>
  432.                 <td class="dataTableContent"><?php echo $cc_list->fields['customer_id']; ?></td>
  433.                 <td class="dataTableContent" align="center"><?php echo $customer->fields['customers_firstname'] . ' ' . $customer->fields['customers_lastname']; ?></td>
  434.                 <td class="dataTableContent" align="center"><?php echo $cc_list->fields['redeem_ip']; ?></td>
  435.                 <td class="dataTableContent" align="center"><?php echo zen_date_short($cc_list->fields['redeem_date']); ?></td>
  436.                 <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>
  437.               </tr>
  438. <?php
  439.       $cc_list->MoveNext();
  440.     }
  441. ?>
  442.           <tr>
  443.             <td colspan="5"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  444.               <tr>
  445.                 <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>
  446.                 <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>
  447.               </tr>
  448.  
  449.               <tr>
  450.                 <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>
  451.               </tr>
  452.             </table></td>
  453.           </tr>
  454.              </table></td>
  455. <?php
  456.     $heading = array();
  457.     $contents = array();
  458.       $coupon_desc = $db->Execute("select coupon_name
  459.                                   from " . TABLE_COUPONS_DESCRIPTION . "
  460.                                   where coupon_id = '" . $_GET['cid'] . "'
  461.                                   and language_id = '" . $_SESSION['languages_id'] . "'");
  462.       $count_customers = $db->Execute("select * from " . TABLE_COUPON_REDEEM_TRACK . "
  463.                                       where coupon_id = '" . $_GET['cid'] . "'
  464.                                       and customer_id = '" . $cInfo->customer_id . "'");
  465.  
  466.       $heading[] = array('text' => '<b>[' . $_GET['cid'] . ']' . COUPON_NAME . ' ' . $coupon_desc->fields['coupon_name'] . '</b>');
  467.       $contents[] = array('text' => '<b>' . TEXT_REDEMPTIONS . '</b>');
  468. //      $contents[] = array('text' => TEXT_REDEMPTIONS_TOTAL . '=' . $cc_list->RecordCount());
  469.       $contents[] = array('text' => TEXT_REDEMPTIONS_TOTAL . '=' . $cc_query_numrows);
  470.       $contents[] = array('text' => TEXT_REDEMPTIONS_CUSTOMER . '=' . $count_customers->RecordCount());
  471.       $contents[] = array('text' => '');
  472. ?>
  473.     <td width="25%" valign="top">
  474. <?php
  475.       $box = new box;
  476.       echo $box->infoBox($heading, $contents);
  477.       echo '            </td>' . "\n";
  478. ?>
  479. <?php
  480.     break;
  481.   case 'preview_email':
  482.     $coupon_result = $db->Execute("select coupon_code
  483.                                   from " .TABLE_COUPONS . "
  484.                                   where coupon_id = '" . $_GET['cid'] . "'");
  485.  
  486.     $coupon_name = $db->Execute("select coupon_name
  487.                                 from " . TABLE_COUPONS_DESCRIPTION . "
  488.                                 where coupon_id = '" . $_GET['cid'] . "'
  489.                                 and language_id = '" . $_SESSION['languages_id'] . "'");
  490.  
  491.     $audience_select = get_audience_sql_query($_POST['customers_email_address']);
  492.     $mail_sent_to = $audience_select['query_name'];
  493.  
  494. ?>
  495.       <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  496.       <tr>
  497.         <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  498.           <tr>
  499.             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  500.             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  501.           </tr>
  502.         </table></td>
  503.       </tr>
  504.       <tr>
  505.         <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  506.           <tr><?php echo zen_draw_form('mail', FILENAME_COUPON_ADMIN, 'action=send_email_to_user&cid=' . $_GET['cid']); ?>
  507.             <td><table border="0" width="100%" cellpadding="0" cellspacing="2">
  508.               <tr>
  509.                 <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  510.               </tr>
  511.               <tr>
  512.                 <td class="smallText"><b><?php echo TEXT_CUSTOMER; ?></b><br /><?php echo $mail_sent_to; ?></td>
  513.               </tr>
  514.               <tr>
  515.                 <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  516.               </tr>
  517.               <tr>
  518.                 <td class="smallText"><b><?php echo TEXT_COUPON; ?></b><br /><?php echo $coupon_name->fields['coupon_name']; ?></td>
  519.               </tr>
  520.               <tr>
  521.                 <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  522.               </tr>
  523.               <tr>
  524.                 <td class="smallText"><b><?php echo TEXT_FROM; ?></b><br /><?php echo htmlspecialchars(stripslashes($_POST['from'])); ?></td>
  525.               </tr>
  526.               <tr>
  527.                 <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  528.               </tr>
  529.               <tr>
  530.                 <td class="smallText"><b><?php echo TEXT_SUBJECT; ?></b><br /><?php echo htmlspecialchars(stripslashes($_POST['subject'])); ?></td>
  531.               </tr>
  532.               <tr>
  533.                 <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  534.               </tr>
  535.               <tr>
  536.                 <td><hr /><b><?php echo TEXT_RICH_TEXT_MESSAGE; ?></b><br /><?php echo stripslashes($_POST['message_html']); ?></td>
  537.               </tr>
  538.               <tr>
  539.                 <td ><hr /><b><?php echo TEXT_MESSAGE; ?></b><br /><tt><?php echo nl2br(htmlspecialchars(stripslashes($_POST['message']))); ?></tt><hr /></td>
  540.               </tr>
  541.               <tr>
  542.                 <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  543.               </tr>
  544.               <tr>
  545.                 <td>
  546. <?php
  547. /* Re-Post all POST'ed variables */
  548.     reset($_POST);
  549.     while (list($key, $value) = each($_POST)) {
  550.       if (!is_array($_POST[$key])) {
  551.         echo zen_draw_hidden_field($key, htmlspecialchars(stripslashes($value)));
  552.       }
  553.     }
  554. ?>
  555.                 <table border="0" width="100%" cellpadding="0" cellspacing="2">
  556.                   <tr>
  557.                     <td><?php ?>&nbsp;</td>
  558.                     <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>
  559.                   </tr>
  560.                 </table></td>
  561.               </tr>
  562.             </table></td>
  563.           </form></tr>
  564. <?php
  565.     break;
  566.   case 'email':
  567.     $coupon_result = $db->Execute("select coupon_code
  568.                                   from " . TABLE_COUPONS . "
  569.                                   where coupon_id = '" . $_GET['cid'] . "'");
  570.     $coupon_name = $db->Execute("select coupon_name
  571.                                 from " . TABLE_COUPONS_DESCRIPTION . "
  572.                                 where coupon_id = '" . $_GET['cid'] . "'
  573.                                 and language_id = '" . $_SESSION['languages_id'] . "'");
  574. ?>
  575.       <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  576.       <tr>
  577.         <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  578.           <tr>
  579.             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  580.             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  581.           </tr>
  582.         </table></td>
  583.       </tr>
  584.       <tr>
  585.         <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
  586.           <tr><?php echo zen_draw_form('mail', FILENAME_COUPON_ADMIN, 'action=preview_email&cid='. $_GET['cid'],'post', 'onsubmit="return check_form(mail);"'); ?>
  587.             <td><table border="0" width="100%" cellpadding="0" cellspacing="2">
  588.               <tr>
  589.                 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  590.               </tr>
  591.               <tr>
  592.                 <td class="main"><?php echo TEXT_COUPON; ?>&nbsp;&nbsp;</td>
  593.                 <td><?php echo $coupon_name->fields['coupon_name']; ?></td>
  594.               </tr>
  595.               <tr>
  596.                 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  597.               </tr>
  598. <?php
  599.     $customers = get_audiences_list('email');
  600. ?>
  601.               <tr>
  602.                 <td class="main"><?php echo TEXT_CUSTOMER; ?>&nbsp;&nbsp;</td>
  603.                 <td><?php echo zen_draw_pull_down_menu('customers_email_address', $customers, $_GET['customer']);?></td>
  604.               </tr>
  605.               <tr>
  606.                 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  607.               </tr>
  608.               <tr>
  609.                 <td class="main"><?php echo TEXT_FROM; ?>&nbsp;&nbsp;</td>
  610.                 <td><?php echo zen_draw_input_field('from', EMAIL_FROM, 'size="50"'); ?></td>
  611.               </tr>
  612.               <tr>
  613.                 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  614.               </tr>
  615. <?php
  616. /*
  617.               <tr>
  618.                 <td class="main"><?php echo TEXT_RESTRICT; ?>&nbsp;&nbsp;</td>
  619.                 <td><?php echo zen_draw_checkbox_field('customers_restrict', $customers_restrict);?></td>
  620.               </tr>
  621.               <tr>
  622.                 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  623.               </tr>
  624. */
  625. ?>
  626.               <tr>
  627.                 <td class="main"><?php echo TEXT_SUBJECT; ?>&nbsp;&nbsp;</td>
  628.                 <td><?php echo zen_draw_input_field('subject', '', 'size="50"'); ?></td>
  629.               </tr>
  630.               <tr>
  631.                 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  632.               </tr>
  633.               <tr>
  634.                 <td valign="top" class="main"><?php echo TEXT_RICH_TEXT_MESSAGE; ?></td>
  635.                 <td>
  636. <?php   if (EMAIL_USE_HTML == 'true') {
  637.               if ($_SESSION['html_editor_preference_status']=="FCKEDITOR") {
  638.                 $oFCKeditor = new FCKeditor('message_html') ;
  639.                 $oFCKeditor->Value = ($_POST['message_html']=='') ? TEXT_COUPON_ANNOUNCE : stripslashes($_POST['message_html']) ;
  640.                 $oFCKeditor->Width  = '97%' ;
  641.                 $oFCKeditor->Height = '250' ;
  642. //                $oFCKeditor->Config['ToolbarLocation'] = 'Out:xToolbar' ;
  643. //                $oFCKeditor->Create() ;
  644.                 $output = $oFCKeditor->CreateHtml() ; echo $output;
  645.         } else { // using HTMLAREA or just raw "source"
  646.           echo zen_draw_textarea_field('message_html', 'soft', '100%', '25', ($_POST['message_html']=='') ? TEXT_COUPON_ANNOUNCE : stripslashes($_POST['message_html']), 'id="message_html"');
  647.         }
  648. } ?>
  649.                 </td>
  650.               </tr>
  651.               <tr>
  652.                 <td valign="top" class="main"><?php echo TEXT_MESSAGE; ?>&nbsp;&nbsp;</td>
  653.                 <td><?php echo zen_draw_textarea_field('message', 'soft', '60', '15', strip_tags(($_POST['message_html']=='') ? TEXT_COUPON_ANNOUNCE : stripslashes($_POST['message_html']))); ?></td>
  654.               </tr>
  655.               <tr>
  656.                 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  657.               </tr>
  658.               <tr>
  659.                 <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>
  660.               </tr>
  661.             </table></td>
  662.           </form></tr>
  663.   </table></td>
  664. <?php
  665.     break;
  666.   case 'update_preview':
  667. ?>
  668.       <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  669.       <tr>
  670.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  671.           <tr>
  672.             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  673.             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  674.           </tr>
  675.         </table></td>
  676.       </tr>
  677.       <tr>
  678.       <td>
  679. <?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'] : '')); ?>
  680.       <table border="0" width="100%" cellspacing="0" cellpadding="6">
  681.         <tr>
  682.           <td align="left" class="main"><?php echo COUPON_ZONE_RESTRICTION; ?></td>
  683.           <td align="left" class="main"><?php echo zen_get_geo_zone_name($_POST['coupon_zone_restriction']); ?>
  684.         </tr>
  685. <?php
  686.         $languages = zen_get_languages();
  687.         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  688.             $language_id = $languages[$i]['id'];
  689. ?>
  690.       <tr>
  691.         <td align="left"><?php echo COUPON_NAME; ?></td>
  692.         <td align="left"><?php echo zen_db_prepare_input($_POST['coupon_name'][$language_id]); ?></td>
  693.       </tr>
  694. <?php
  695. }
  696. ?>
  697. <?php
  698.         $languages = zen_get_languages();
  699.         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  700.             $language_id = $languages[$i]['id'];
  701. ?>
  702.       <tr>
  703.         <td align="left"><?php echo COUPON_DESC; ?></td>
  704.         <td align="left"><?php echo zen_db_prepare_input($_POST['coupon_desc'][$language_id]); ?></td>
  705.       </tr>
  706. <?php
  707. }
  708. ?>
  709.       <tr>
  710.         <td align="left"><?php echo COUPON_AMOUNT; ?></td>
  711.         <td align="left"><?php echo zen_db_prepare_input($_POST['coupon_amount']); ?></td>
  712.       </tr>
  713.  
  714.       <tr>
  715.         <td align="left"><?php echo COUPON_MIN_ORDER; ?></td>
  716.         <td align="left"><?php echo zen_db_prepare_input($_POST['coupon_min_order']); ?></td>
  717.       </tr>
  718.  
  719.       <tr>
  720.         <td align="left"><?php echo COUPON_FREE_SHIP; ?></td>
  721. <?php
  722.     if ($_POST['coupon_free_ship']) {
  723. ?>
  724.         <td align="left"><?php echo TEXT_FREE_SHIPPING; ?></td>
  725. <?php
  726.     } else {
  727. ?>
  728.         <td align="left"><?php echo TEXT_NO_FREE_SHIPPING; ?></td>
  729. <?php
  730.     }
  731. ?>
  732.       </tr>
  733.       <tr>
  734.         <td align="left"><?php echo COUPON_CODE; ?></td>
  735. <?php
  736.     if ($_POST['coupon_code']) {
  737.       $c_code = $_POST['coupon_code'];
  738.     } else {
  739.       $c_code = $coupon_code;
  740.     }
  741. ?>
  742.         <td align="left"><?php echo $coupon_code; ?></td>
  743.       </tr>
  744.  
  745.       <tr>
  746.         <td align="left"><?php echo COUPON_USES_COUPON; ?></td>
  747.         <td align="left"><?php echo $_POST['coupon_uses_coupon']; ?></td>
  748.       </tr>
  749.  
  750.       <tr>
  751.         <td align="left"><?php echo COUPON_USES_USER; ?></td>
  752.         <td align="left"><?php echo $_POST['coupon_uses_user']; ?></td>
  753.       </tr>
  754.  
  755.       <tr>
  756.         <td align="left"><?php echo COUPON_STARTDATE; ?></td>
  757. <?php
  758.     $start_date = date(DATE_FORMAT, mktime(0, 0, 0, $_POST['coupon_startdate_month'],$_POST['coupon_startdate_day'] ,$_POST['coupon_startdate_year'] ));
  759. ?>
  760.         <td align="left"><?php echo $start_date; ?></td>
  761.       </tr>
  762.  
  763.       <tr>
  764.         <td align="left"><?php echo COUPON_FINISHDATE; ?></td>
  765. <?php
  766.     $finish_date = date(DATE_FORMAT, mktime(0, 0, 0, $_POST['coupon_finishdate_month'],$_POST['coupon_finishdate_day'] ,$_POST['coupon_finishdate_year'] ));
  767. ?>
  768.         <td align="left"><?php echo $finish_date; ?></td>
  769.       </tr>
  770. <?php
  771.         $languages = zen_get_languages();
  772.         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  773.           $language_id = $languages[$i]['id'];
  774.           echo zen_draw_hidden_field('coupon_name[' . $languages[$i]['id'] . ']', stripslashes($_POST['coupon_name'][$language_id]));
  775.           echo zen_draw_hidden_field('coupon_desc[' . $languages[$i]['id'] . ']', stripslashes($_POST['coupon_desc'][$language_id]));
  776.        }
  777.     echo zen_draw_hidden_field('coupon_amount', $_POST['coupon_amount']);
  778.     echo zen_draw_hidden_field('coupon_min_order', $_POST['coupon_min_order']);
  779.     echo zen_draw_hidden_field('coupon_free_ship', $_POST['coupon_free_ship']);
  780.     echo zen_draw_hidden_field('coupon_code', stripslashes($c_code));
  781.     echo zen_draw_hidden_field('coupon_uses_coupon', $_POST['coupon_uses_coupon']);
  782.     echo zen_draw_hidden_field('coupon_uses_user', $_POST['coupon_uses_user']);
  783.     echo zen_draw_hidden_field('coupon_products', $_POST['coupon_products']);
  784.     echo zen_draw_hidden_field('coupon_categories', $_POST['coupon_categories']);
  785.     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'] )));
  786.     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'] )));
  787.     echo zen_draw_hidden_field('coupon_zone_restriction', $_POST['coupon_zone_restriction']);
  788. ?>
  789.      <tr>
  790.         <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>
  791.         <td align="left"><?php echo zen_image_submit('button_cancel.gif',COUPON_BUTTON_CANCEL, 'name=back'); ?></td>
  792.       </td>
  793.       </tr>
  794.  
  795.       </td></table></form>
  796.       </tr>
  797.  
  798.       </table></td>
  799. <?php
  800.  
  801.     break;
  802.   case 'voucheredit':
  803.     $languages = zen_get_languages();
  804.     for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  805.       $language_id = $languages[$i]['id'];
  806.       $coupon = $db->Execute("select coupon_name,coupon_description
  807.                              from " . TABLE_COUPONS_DESCRIPTION . "
  808.                              where coupon_id = '" .  $_GET['cid'] . "'
  809.                              and language_id = '" . $language_id . "'");
  810.  
  811.       $_POST['coupon_name'][$language_id] = $coupon->fields['coupon_name'];
  812.       $_POST['coupon_desc'][$language_id] = $coupon->fields['coupon_description'];
  813.     }
  814.  
  815.     $coupon = $db->Execute("select coupon_code, coupon_amount, coupon_type, coupon_minimum_order,
  816.                                   coupon_start_date, coupon_expire_date, uses_per_coupon,
  817.                                   uses_per_user, restrict_to_products, restrict_to_categories, coupon_zone_restriction
  818.                            from " . TABLE_COUPONS . "
  819.                            where coupon_id = '" . $_GET['cid'] . "'");
  820.  
  821.     $_POST['coupon_amount'] = $coupon->fields['coupon_amount'];
  822.     if ($coupon->fields['coupon_type']=='P') {
  823.       $_POST['coupon_amount'] .= '%';
  824.     }
  825.     if ($coupon->fields['coupon_type']=='S') {
  826.       $_POST['coupon_free_ship'] = true;
  827.     } else {
  828.       $_POST['coupon_free_ship'] = false;
  829.     }
  830.     $_POST['coupon_min_order'] = $coupon->fields['coupon_minimum_order'];
  831.     $_POST['coupon_code'] = $coupon->fields['coupon_code'];
  832.     $_POST['coupon_uses_coupon'] = $coupon->fields['uses_per_coupon'];
  833.     $_POST['coupon_uses_user'] = $coupon->fields['uses_per_user'];
  834.     $_POST['coupon_startdate'] = $coupon->fields['coupon_start_date'];
  835.     $_POST['coupon_finishdate'] = $coupon->fields['coupon_expire_date'];
  836.     $_POST['coupon_zone_restriction'] = $coupon->fields['coupon_zone_restriction'];
  837.  
  838.   case 'new':
  839. // set some defaults
  840.     if ($_GET['action'] != 'voucheredit' and $_POST['coupon_uses_user'] == '') $_POST['coupon_uses_user'] = 1;
  841. ?>
  842.       <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  843.       <tr>
  844.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  845.           <tr>
  846.             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  847.             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  848.           </tr>
  849.         </table></td>
  850.       </tr>
  851.       <tr>
  852.       <td>
  853. <?php
  854.     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'] : ''));
  855. ?>
  856.       <table border="0" width="100%" cellspacing="0" cellpadding="6">
  857. <?php
  858.         $languages = zen_get_languages();
  859.         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  860.         $language_id = $languages[$i]['id'];
  861. ?>
  862.       <tr>
  863.         <td align="left" class="main"><?php if ($i==0) echo COUPON_NAME; ?></td>
  864.         <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>
  865.         <td align="left" class="main" width="40%"><?php if ($i==0) echo COUPON_NAME_HELP; ?></td>
  866.       </tr>
  867. <?php
  868. }
  869. ?>
  870. <?php
  871.         $languages = zen_get_languages();
  872.         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  873.         $language_id = $languages[$i]['id'];
  874. ?>
  875.  
  876.       <tr>
  877.         <td align="left" valign="top" class="main"><?php if ($i==0) echo COUPON_DESC; ?></td>
  878.         <td align="left" valign="top"><?php
  879.             if ($_SESSION['html_editor_preference_status']=="FCKEDITOR") {
  880.                 $oFCKeditor = new FCKeditor('coupon_desc[' . $languages[$i]['id'] . ']') ;
  881.                 $oFCKeditor->Value = (stripslashes($_POST['coupon_desc'][$language_id]) != '') ? stripslashes($_POST['coupon_desc'][$language_id]) : '';
  882.                 $oFCKeditor->Width  = '97%' ;
  883.                 $oFCKeditor->Height = '200' ;
  884. //                $oFCKeditor->Config['ToolbarLocation'] = 'Out:xToolbar' ;
  885.                 $output = $oFCKeditor->CreateHtml() ; echo $output;
  886.             } else { // using HTMLAREA or just raw "source"
  887.               echo zen_draw_textarea_field('coupon_desc[' . $languages[$i]['id'] . ']','physical','24','8', stripslashes($_POST['coupon_desc'][$language_id]));
  888.             }
  889.             echo '&nbsp;' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?></td>
  890.         <td align="left" valign="top" class="main"><?php if ($i==0) echo COUPON_DESC_HELP; ?></td>
  891.       </tr>
  892. <?php
  893. }
  894. ?>
  895.       <tr>
  896.         <td align="left" class="main"><?php echo COUPON_AMOUNT; ?></td>
  897.         <td align="left"><?php echo zen_draw_input_field('coupon_amount', $_POST['coupon_amount']); ?></td>
  898.         <td align="left" class="main"><?php echo COUPON_AMOUNT_HELP; ?></td>
  899.       </tr>
  900.       <tr>
  901.         <td align="left" class="main"><?php echo COUPON_MIN_ORDER; ?></td>
  902.         <td align="left"><?php echo zen_draw_input_field('coupon_min_order', $_POST['coupon_min_order']); ?></td>
  903.         <td align="left" class="main"><?php echo COUPON_MIN_ORDER_HELP; ?></td>
  904.       </tr>
  905.       <tr>
  906.         <td align="left" class="main"><?php echo COUPON_FREE_SHIP; ?></td>
  907.         <td align="left"><input type="checkbox" name="coupon_free_ship" <?php if ($_POST['coupon_free_ship']) echo 'CHECKED'; ?>></td>
  908.         <td align="left" class="main"><?php echo COUPON_FREE_SHIP_HELP; ?></td>
  909.       </tr>
  910.       <tr>
  911.         <td align="left" class="main"><?php echo COUPON_CODE; ?></td>
  912.         <td align="left"><?php echo zen_draw_input_field('coupon_code', $_POST['coupon_code']); ?></td>
  913.         <td align="left" class="main"><?php echo COUPON_CODE_HELP; ?></td>
  914.       </tr>
  915.       <tr>
  916.         <td align="left" class="main"><?php echo COUPON_USES_COUPON; ?></td>
  917.         <td align="left"><?php echo zen_draw_input_field('coupon_uses_coupon', ($_POST['coupon_uses_coupon'] >= 1 ? $_POST['coupon_uses_coupon'] : '')); ?></td>
  918.         <td align="left" class="main"><?php echo COUPON_USES_COUPON_HELP; ?></td>
  919.       </tr>
  920.       <tr>
  921.         <td align="left" class="main"><?php echo COUPON_USES_USER; ?></td>
  922.         <td align="left"><?php echo zen_draw_input_field('coupon_uses_user', ($_POST['coupon_uses_user'] >= 1 ? $_POST['coupon_uses_user'] : '')); ?></td>
  923.         <td align="left" class="main"><?php echo COUPON_USES_USER_HELP; ?></td>
  924.       </tr>
  925.       <tr>
  926. <?php
  927.     if (!$_POST['coupon_startdate']) {
  928.       $coupon_startdate = preg_split("/[-]/", date('Y-m-d'));
  929.     } else {
  930.       $coupon_startdate = preg_split("/[-]/", $_POST['coupon_startdate']);
  931.     }
  932.     if (!$_POST['coupon_finishdate']) {
  933.       $coupon_finishdate = preg_split("/[-]/", date('Y-m-d'));
  934.       $coupon_finishdate[0] = $coupon_finishdate[0] + 1;
  935.     } else {
  936.       $coupon_finishdate = preg_split("/[-]/", $_POST['coupon_finishdate']);
  937.     }
  938. ?>
  939.         <td align="left" class="main"><?php echo COUPON_STARTDATE; ?></td>
  940.         <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>
  941.         <td align="left" class="main"><?php echo COUPON_STARTDATE_HELP; ?></td>
  942.       </tr>
  943.       <tr>
  944.         <td align="left" class="main"><?php echo COUPON_FINISHDATE; ?></td>
  945.         <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>
  946.         <td align="left" class="main"><?php echo COUPON_FINISHDATE_HELP; ?></td>
  947.       </tr>
  948.       <tr>
  949.         <td align="left" class="main"><?php echo COUPON_ZONE_RESTRICTION; ?></td>
  950.         <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']); ?>
  951.         <td align="left" class="main"><?php echo TEXT_COUPON_ZONE_RESTRICTION; ?></td>
  952.       </tr>
  953.       <tr>
  954.         <td align="left"><?php echo zen_image_submit('button_preview.gif',COUPON_BUTTON_PREVIEW); ?></td>
  955.         <td align="left">&nbsp;&nbsp;<a href="<?php echo 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>
  956.       </td>
  957.       </tr>
  958.       </td></table></form>
  959.       </tr>
  960.  
  961.       </table></td>
  962. <?php
  963.     break;
  964.   default:
  965. ?>
  966.     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  967.       <tr>
  968.         <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  969.           <tr>
  970.             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  971.             <td class="main"><?php echo zen_draw_form('status', FILENAME_COUPON_ADMIN, '', 'get'); ?>
  972. <?php
  973.     $status_array[] = array('id' => 'Y', 'text' => TEXT_COUPON_ACTIVE);
  974.     $status_array[] = array('id' => 'N', 'text' => TEXT_COUPON_INACTIVE);
  975.     $status_array[] = array('id' => '*', 'text' => TEXT_COUPON_ALL);
  976.  
  977.     if ($_GET['status']) {
  978.       $status = zen_db_prepare_input($_GET['status']);
  979.     } else {
  980.       $status = 'Y';
  981.     }
  982.  
  983.     echo zen_hide_session_id();
  984.     echo HEADING_TITLE_STATUS . ' ' . zen_draw_pull_down_menu('status', $status_array, $status, 'onChange="this.form.submit();"') .
  985.     zen_draw_hidden_field('page', $_GET['page']);
  986. ?>
  987.               </form>
  988.            </td>
  989.             <td class="main">
  990. <?php
  991. // toggle switch for editor
  992.         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();"') .
  993.         zen_hide_session_id() .
  994.         zen_draw_hidden_field('action', 'set_editor') .
  995.         '</form>';
  996. ?>
  997. </td>
  998.           </tr>
  999.         </table></td>
  1000.       </tr>
  1001.       <tr>
  1002.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  1003.           <tr>
  1004.             <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  1005.               <tr class="dataTableHeadingRow">
  1006.                 <td class="dataTableHeadingContent"><?php echo COUPON_NAME; ?></td>
  1007.                 <td class="dataTableHeadingContent" align="center"><?php echo COUPON_AMOUNT; ?></td>
  1008.                 <td class="dataTableHeadingContent" align="center"><?php echo COUPON_CODE; ?></td>
  1009.                 <td class="dataTableHeadingContent" align="center"><?php echo COUPON_ACTIVE; ?></td>
  1010.                 <td class="dataTableHeadingContent" align="center"><?php echo COUPON_START_DATE; ?></td>
  1011.                 <td class="dataTableHeadingContent" align="center"><?php echo COUPON_EXPIRE_DATE; ?></td>
  1012.                 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
  1013.               </tr>
  1014. <?php
  1015.     if ($_GET['page'] > 1) $rows = $_GET['page'] * 20 - 20;
  1016.     if ($status != '*') {
  1017.       $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'";
  1018.     } else {
  1019.       $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'";
  1020.     }
  1021.     $cc_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS_DISCOUNT_COUPONS, $cc_query_raw, $cc_query_numrows);
  1022.     $cc_list = $db->Execute($cc_query_raw);
  1023.     while (!$cc_list->EOF) {
  1024.       $rows++;
  1025.       if (strlen($rows) < 2) {
  1026.         $rows = '0' . $rows;
  1027.       }
  1028.       if (((!$_GET['cid']) || (@$_GET['cid'] == $cc_list->fields['coupon_id'])) && (!$cInfo)) {
  1029.         $cInfo = new objectInfo($cc_list->fields);
  1030.       }
  1031.       if ( (is_object($cInfo)) && ($cc_list->fields['coupon_id'] == $cInfo->coupon_id) ) {
  1032.         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";
  1033.       } else {
  1034.         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";
  1035.       }
  1036.       $coupon_desc = $db->Execute("select coupon_name
  1037.                                   from " . TABLE_COUPONS_DESCRIPTION . "
  1038.                                   where coupon_id = '" . $cc_list->fields['coupon_id'] . "'
  1039.                                   and language_id = '" . $_SESSION['languages_id'] . "'");
  1040. ?>
  1041.                 <td class="dataTableContent"><?php echo $coupon_desc->fields['coupon_name']; ?></td>
  1042.                 <td class="dataTableContent" align="center">
  1043. <?php
  1044.       if ($cc_list->fields['coupon_type'] == 'P') {
  1045.         echo $cc_list->fields['coupon_amount'] . '%';
  1046.       } elseif ($cc_list->fields['coupon_type'] == 'S') {
  1047.         echo TEXT_FREE_SHIPPING;
  1048.       } else {
  1049.         echo $currencies->format($cc_list->fields['coupon_amount']);
  1050.       }
  1051. ?>
  1052.             &nbsp;</td>
  1053.                 <td class="dataTableContent" align="center"><?php echo $cc_list->fields['coupon_code']; ?></td>
  1054.                 <td class="dataTableContent" align="center"><?php echo $cc_list->fields['coupon_active']; ?></td>
  1055.                 <td class="dataTableContent" align="center"><?php echo zen_date_short($cc_list->fields['coupon_start_date']); ?></td>
  1056.                 <td class="dataTableContent" align="center"><?php echo zen_date_short($cc_list->fields['coupon_expire_date']); ?></td>
  1057.                 <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'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
  1058.               </tr>
  1059. <?php
  1060.       $cc_list->MoveNext();
  1061.     }
  1062. ?>
  1063.           <tr>
  1064.             <td colspan="7"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  1065.               <tr>
  1066.                 <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>
  1067.                 <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>
  1068.               </tr>
  1069.  
  1070.               <tr>
  1071.                 <td align="right" colspan="2" class="smallText"><?php echo '<a name="couponInsert" 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>
  1072.               </tr>
  1073.             </table></td>
  1074.           </tr>
  1075.         </table></td>
  1076.  
  1077. <?php
  1078.  
  1079.     $heading = array();
  1080.     $contents = array();
  1081.  
  1082.     switch ($_GET['action']) {
  1083.     case 'release':
  1084.       break;
  1085.     case 'voucherreport':
  1086.       $heading[] = array('text' => '<b>' . TEXT_HEADING_COUPON_REPORT . '</b>');
  1087.       $contents[] = array('text' => TEXT_NEW_INTRO);
  1088.       break;
  1089.     case 'new':
  1090.       $heading[] = array('text' => '<b>' . TEXT_HEADING_NEW_COUPON . '</b>');
  1091.       $contents[] = array('text' => TEXT_NEW_INTRO);
  1092.       $contents[] = array('text' => '<br />' . COUPON_NAME . '<br />' . zen_draw_input_field('name'));
  1093.       $contents[] = array('text' => '<br />' . COUPON_AMOUNT . '<br />' . zen_draw_input_field('voucher_amount'));
  1094.       $contents[] = array('text' => '<br />' . COUPON_CODE . '<br />' . zen_draw_input_field('voucher_code'));
  1095.       $contents[] = array('text' => '<br />' . COUPON_USES_COUPON . '<br />' . zen_draw_input_field('voucher_number_of'));
  1096.       break;
  1097.     default:
  1098.       $heading[] = array('text'=>'['.$cInfo->coupon_id.']  '.$cInfo->coupon_code);
  1099.       $amount = $cInfo->coupon_amount;
  1100.       if ($cInfo->coupon_type == 'P') {
  1101.         $amount .= '%';
  1102.       } else {
  1103.         $amount = $currencies->format($amount);
  1104.       }
  1105.       if ($_GET['action'] == 'voucherdelete' or $_GET['action'] == 'vouchercopy') {
  1106.         if ($_GET['action'] == 'voucherdelete') {
  1107.           $contents[] = array('text'=> TEXT_CONFIRM_DELETE . '</br></br>' .
  1108.                   '<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>' .
  1109.                   '<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>'
  1110.                   );
  1111.         }
  1112.         if ($_GET['action'] == 'vouchercopy') {
  1113.           $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"'));
  1114.  
  1115.           $contents[] = array('text' => '<br>' . TEXT_COUPON_NEW . '&nbsp;' . zen_draw_input_field('coupon_copy_to', '', 6, 6));
  1116.  
  1117.           $contents[] = array('text'=> TEXT_CONFIRM_COPY . '</br>');
  1118.           $contents[] = array('text'=> zen_image_submit('button_save.gif', IMAGE_SAVE));
  1119.           $contents[] = array('text'=>
  1120.                   '<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>'
  1121.                   );
  1122. /*
  1123.           $contents[] = array('text'=>
  1124.                   '<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>' .
  1125.  
  1126.  
  1127.                   '<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>'
  1128.                   );
  1129. */
  1130.  
  1131.  
  1132.         }
  1133.       } else {
  1134.         $prod_details = TEXT_NONE;
  1135. //bof 12-6ke
  1136. $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;
  1137. //eof 12-6ke
  1138.         $cat_details = TEXT_NONE;
  1139. //bof 12-6ke
  1140. $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;
  1141. //eof 12-6ke
  1142.         $coupon_name = $db->Execute("select coupon_name
  1143.                                     from " . TABLE_COUPONS_DESCRIPTION . "
  1144.                                     where coupon_id = '" . $cInfo->coupon_id . "'
  1145.                                     and language_id = '" . $_SESSION['languages_id'] . "'");
  1146.         $uses_coupon = $cInfo->uses_per_coupon;
  1147.         $uses_user = $cInfo->uses_per_user;
  1148.         if ($uses_coupon == 0 || $uses_coupon == '') $uses_coupon = TEXT_UNLIMITED;
  1149.         if ($uses_user == 0 || $uses_user == '') $uses_user = TEXT_UNLIMITED;
  1150.         $contents[] = array('text'=>COUPON_NAME . '&nbsp;::&nbsp; ' . $coupon_name->fields['coupon_name'] . '<br />' .
  1151.                      COUPON_AMOUNT . '&nbsp;::&nbsp; ' . $amount . '<br />' .
  1152.                      COUPON_STARTDATE . '&nbsp;::&nbsp; ' . zen_date_short($cInfo->coupon_start_date) . '<br />' .
  1153.                      COUPON_FINISHDATE . '&nbsp;::&nbsp; ' . zen_date_short($cInfo->coupon_expire_date) . '<br />' .
  1154.                      COUPON_USES_COUPON . '&nbsp;::&nbsp; ' . $uses_coupon . '<br />' .
  1155.                      COUPON_USES_USER . '&nbsp;::&nbsp; ' . $uses_user . '<br />' .
  1156.                      COUPON_PRODUCTS . '&nbsp;::&nbsp; ' . $prod_details . '<br />' .
  1157.                      COUPON_CATEGORIES . '&nbsp;::&nbsp; ' . $cat_details . '<br />' .
  1158.                      DATE_CREATED . '&nbsp;::&nbsp; ' . zen_date_short($cInfo->date_created) . '<br />' .
  1159.                      DATE_MODIFIED . '&nbsp;::&nbsp; ' . zen_date_short($cInfo->date_modified) . '<br /><br />' .
  1160.                      COUPON_ZONE_RESTRICTION . '&nbsp;::&nbsp; ' . zen_get_geo_zone_name($cInfo->coupon_zone_restriction) . '<br /><br />' .
  1161.                      ($cInfo->coupon_id != '' ?
  1162.                      '<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>' .
  1163.                      '<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>' .
  1164.                      '<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>' .
  1165.                      '<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').
  1166.                      '<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>'
  1167.                      : ' who ' . $cInfo->coupon_id . ' - ' . $_GET['cid'])
  1168.                      );
  1169.         }
  1170.         break;
  1171.       }
  1172. ?>
  1173.     <td width="25%" valign="top">
  1174. <?php
  1175.       $box = new box;
  1176.       echo $box->infoBox($heading, $contents);
  1177.     echo '            </td>' . "\n";
  1178.     }
  1179. ?>
  1180.       </tr>
  1181.     </table></td>
  1182. <!-- body_text_eof //-->
  1183.   </tr>
  1184. </table>
  1185. <!-- body_eof //-->
  1186. <!-- footer //-->
  1187. <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  1188. <!-- footer_eof //-->
  1189. </body>
  1190. </html>
  1191. <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
  1192.  


cron