[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.38 KiB
MD5: 84b754f10de758044c7cb265bbcf34e2

coupon_admin.php - 关闭高亮
  1. <?php
  2. /**
  3.  * @package admin
  4.  * @copyright Copyright 2003-2012 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 GIT: $Id: Author: Ian Wilson  Tue Aug 7 15:17:58 2012 +0100 Modified in v1.5.1 $
  8.  */
  9.   require('includes/application_top.php');
  10.   require(DIR_WS_CLASSES . 'currencies.php');
  11.   $currencies = new currencies();
  12.   if ($_GET['selected_box']) {
  13.     $_GET['action']='';
  14.     $_GET['old_action']='';
  15.   }
  16.  
  17.   if (isset($_GET['cid'])) $_GET['cid'] = (int)$_GET['cid'];
  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 = '" . (int)$_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:";
  124.       $sql = $db->bindVars($sql, ':coupon_copy:', $coupon_copy_to, 'string');
  125.       $check_new_coupon = $db->Execute($sql);
  126.       if ($check_new_coupon->RecordCount() > 0) {
  127.         $messageStack->add_session(ERROR_DISCOUNT_COUPON_DUPLICATE . $coupon_copy_to, 'caution');
  128.         zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
  129.       }
  130.  
  131.       $sql = "SELECT * from " . TABLE_COUPONS . " where coupon_id='" . $_GET['cid'] . "'";
  132.       $check_new_coupon = $db->Execute($sql);
  133.  
  134.       // create duplicate coupon
  135.         $sql_data_array = array('coupon_code' => zen_db_prepare_input($coupon_copy_to),
  136.                                 'coupon_amount' => zen_db_prepare_input($check_new_coupon->fields['coupon_amount']),
  137.                                 'coupon_type' => zen_db_prepare_input($check_new_coupon->fields['coupon_type']),
  138.                                 'uses_per_coupon' => zen_db_prepare_input((int)$check_new_coupon->fields['uses_per_coupon']),
  139.                                 'uses_per_user' => zen_db_prepare_input((int)$check_new_coupon->fields['uses_per_user']),
  140.                                 'coupon_minimum_order' => zen_db_prepare_input((float)$check_new_coupon->fields['coupon_minimum_order']),
  141.                                 'restrict_to_products' => zen_db_prepare_input($check_new_coupon->fields['restrict_to_products']),
  142.                                 'restrict_to_categories' => zen_db_prepare_input($check_new_coupon->fields['restrict_to_categories']),
  143.                                 'coupon_start_date' => $check_new_coupon->fields['coupon_start_date'],
  144.                                 'coupon_expire_date' => $check_new_coupon->fields['coupon_expire_date'],
  145.                                 'date_created' => 'now()',
  146.                                 'date_modified' => 'now()',
  147.                                 'coupon_zone_restriction' => $check_new_coupon->fields['coupon_zone_restriction']);
  148.  
  149.           zen_db_perform(TABLE_COUPONS, $sql_data_array);
  150.           $insert_id = $db->Insert_ID();
  151.           $cid = $insert_id;
  152. //          $_GET['cid'] = $cid;
  153.  
  154.           // create duplicate coupon description
  155.           $sql = "SELECT * from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id='" . $_GET['cid'] . "'";
  156.           $new_coupon_descriptions = $db->Execute($sql);
  157.  
  158.           while (!$new_coupon_descriptions->EOF) {
  159.             $sql_mdata_array = array('coupon_id' => zen_db_prepare_input($cid),
  160.                                     'language_id' => zen_db_prepare_input($new_coupon_descriptions->fields['language_id']),
  161.                                     'coupon_name' => zen_db_prepare_input('COPY: ' . $new_coupon_descriptions->fields['coupon_name']),
  162.                                     'coupon_description' => zen_db_prepare_input($new_coupon_descriptions->fields['coupon_description'])
  163.                                     );
  164.             zen_db_perform(TABLE_COUPONS_DESCRIPTION, $sql_mdata_array);
  165.             $new_coupon_descriptions->MoveNext();
  166.           }
  167.  
  168.       // copy restrictions
  169.       $sql = "SELECT * from " . TABLE_COUPON_RESTRICT . " where coupon_id='" . $_GET['cid'] . "'";
  170.       $copy_coupon_restrictions = $db->Execute($sql);
  171.  
  172.       while (!$copy_coupon_restrictions->EOF) {
  173.         $sql_rdata_array = array('coupon_id' => zen_db_prepare_input($cid),
  174.                                  'product_id' => zen_db_prepare_input($copy_coupon_restrictions->fields['product_id']),
  175.                                  'category_id' => zen_db_prepare_input($copy_coupon_restrictions->fields['category_id']),
  176.                                  'coupon_restrict' => zen_db_prepare_input($copy_coupon_restrictions->fields['coupon_restrict'])
  177.                                  );
  178.         zen_db_perform(TABLE_COUPON_RESTRICT, $sql_rdata_array);
  179.         $copy_coupon_restrictions->MoveNext();
  180.       }
  181.  
  182.       $_GET['cid'] = $cid;
  183.       $messageStack->add_session(SUCCESS_COUPON_DUPLICATE . $coupon_copy_to, 'success');
  184.       zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'action=voucheredit' . '&cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '')));
  185. //        zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN));
  186.       break;
  187.     case 'update':
  188.       $update_errors = 0;
  189.       // get all HTTP_POST_VARS and validate
  190.       $_POST['coupon_code'] = trim($_POST['coupon_code']);
  191.         $languages = zen_get_languages();
  192.         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  193.           $language_id = $languages[$i]['id'];
  194.           $_POST['coupon_name'][$language_id] = trim($_POST['coupon_name'][$language_id]);
  195.           if (!$_POST['coupon_name'][$language_id]) {
  196.             $update_errors = 1;
  197.             $messageStack->add(ERROR_NO_COUPON_NAME . $languages[$i]['name'], 'error');
  198.           }
  199.           $_POST['coupon_desc'][$language_id] = trim($_POST['coupon_desc'][$language_id]);
  200.         }
  201.       $_POST['coupon_amount'] = trim($_POST['coupon_amount']);
  202.       $_POST['coupon_amount'] = preg_replace('/[^0-9.%]/', '', $_POST['coupon_amount']);
  203.       if (!$_POST['coupon_name']) {
  204.         $update_errors = 1;
  205.         $messageStack->add(ERROR_NO_COUPON_NAME, 'error');
  206.       }
  207.       if ((!$_POST['coupon_amount']) && (!$_POST['coupon_free_ship'])) {
  208.         $update_errors = 1;
  209.         $messageStack->add(ERROR_NO_COUPON_AMOUNT, 'error');
  210.       }
  211.       if (!$_POST['coupon_code']) {
  212.         $coupon_code = create_coupon_code();
  213.       }
  214.       if ($_POST['coupon_code']) $coupon_code = $_POST['coupon_code'];
  215.       $sql = "select coupon_code
  216.                              from " . TABLE_COUPONS . "
  217.                              where coupon_code = :couponCode:";
  218.       $sql = $db->bindVars($sql, ':couponCode:', $coupon_code, 'string');
  219.       $query1 = $db->Execute($sql);
  220.       if ($query1->RecordCount()>0 && $_POST['coupon_code'] && $_GET['oldaction'] != 'voucheredit')  {
  221.         $update_errors = 1;
  222.         $messageStack->add(ERROR_COUPON_EXISTS, 'error');
  223.       }
  224.       if ($update_errors != 0) {
  225.         $_GET['action'] = 'new';
  226.       } else {
  227.         $_GET['action'] = 'update_preview';
  228.       }
  229.       break;
  230.     case 'update_confirm':
  231.       if ( ($_POST['back_x']) || ($_POST['back_y']) ) {
  232.         $_GET['action'] = 'new';
  233.       } else {
  234.         $coupon_type = 'F'; // amount off
  235.         if ($_POST['coupon_free_ship']) $coupon_type = 'S'; // free shipping
  236.         if (substr($_POST['coupon_amount'], -1) == '%') $coupon_type = 'P'; // percentage off
  237.         if ($_POST['coupon_amount'] > 0 && $_POST['coupon_free_ship']) $coupon_type = 'O';  // amount off and free shipping
  238.         if (substr($_POST['coupon_amount'], -1) == '%' && $_POST['coupon_free_ship']) $coupon_type = 'E'; // percentage off and free shipping
  239.         $_POST['coupon_amount'] = preg_replace('/[^0-9.]/', '', $_POST['coupon_amount']);
  240.         $sql_data_array = array('coupon_code' => zen_db_prepare_input($_POST['coupon_code']),
  241.                                 'coupon_amount' => zen_db_prepare_input($_POST['coupon_amount']),
  242.                                 'coupon_type' => zen_db_prepare_input($coupon_type),
  243.                                 'uses_per_coupon' => zen_db_prepare_input((int)$_POST['coupon_uses_coupon']),
  244.                                 'uses_per_user' => zen_db_prepare_input((int)$_POST['coupon_uses_user']),
  245.                                 'coupon_minimum_order' => zen_db_prepare_input((float)$_POST['coupon_min_order']),
  246.                                 'restrict_to_products' => zen_db_prepare_input($_POST['coupon_products']),
  247.                                 'restrict_to_categories' => zen_db_prepare_input($_POST['coupon_categories']),
  248.                                 'coupon_start_date' => $_POST['coupon_startdate'],
  249.                                 'coupon_expire_date' => $_POST['coupon_finishdate'],
  250.                                 'date_created' => 'now()',
  251.                                 'date_modified' => 'now()',
  252.                                 'coupon_zone_restriction' => $_POST['coupon_zone_restriction']);
  253.         $languages = zen_get_languages();
  254.         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  255.           $language_id = $languages[$i]['id'];
  256.           $sql_data_marray[$i] = array('coupon_name' => zen_db_prepare_input($_POST['coupon_name'][$language_id]),
  257.                                        'coupon_description' => zen_db_prepare_input($_POST['coupon_desc'][$language_id])
  258.                                        );
  259.         }
  260.         if ($_GET['oldaction']=='voucheredit') {
  261.           zen_db_perform(TABLE_COUPONS, $sql_data_array, 'update', "coupon_id='" . $_GET['cid']."'");
  262.           for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  263.             $language_id = $languages[$i]['id'];
  264.             $sql_data_desc_array = array('coupon_name' => zen_db_prepare_input($_POST['coupon_name'][$language_id]),
  265.                                          'coupon_description' => zen_db_prepare_input($_POST['coupon_desc'][$language_id])
  266.                                          );
  267.             zen_db_perform(TABLE_COUPONS_DESCRIPTION, $sql_data_desc_array, 'update', "coupon_id = '" . $_GET['cid'] . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
  268.           }
  269.         } else {
  270.           zen_db_perform(TABLE_COUPONS, $sql_data_array);
  271.           $insert_id = $db->Insert_ID();
  272.           $cid = $insert_id;
  273.           $_GET['cid'] = $cid;
  274.  
  275.           for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  276.             $language_id = $languages[$i]['id'];
  277.             $sql_data_marray[$i]['coupon_id'] = (int)$insert_id;
  278.             $sql_data_marray[$i]['language_id'] = (int)$language_id;
  279.             zen_db_perform(TABLE_COUPONS_DESCRIPTION, $sql_data_marray[$i]);
  280.           }
  281.         }
  282.       }
  283.       zen_redirect(zen_href_link(FILENAME_COUPON_ADMIN, 'cid=' . $_GET['cid'] . (isset($_GET['status']) ? '&status=' . $_GET['status'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
  284.   }
  285. ?>
  286. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  287. <html <?php echo HTML_PARAMS; ?>>
  288. <head>
  289. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  290. <title><?php echo TITLE; ?></title>
  291. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  292. <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
  293. <script language="javascript" src="includes/menu.js"></script>
  294. <script language="javascript" src="includes/general.js"></script>
  295. <link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
  296. <script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
  297. <script language="javascript">
  298.   var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?php echo $pInfo->products_date_available; ?>",scBTNMODE_CUSTOMBLUE);
  299. </script>
  300. <script type="text/javascript">
  301.   <!--
  302.   function init()
  303.   {
  304.     cssjsmenu('navbar');
  305.     if (document.getElementById)
  306.     {
  307.       var kill = document.getElementById('hoverJS');
  308.       kill.disabled = true;
  309.     }
  310. <?php if ($_GET['action'] == 'new' || $_GET['action'] == 'voucheredit') { ?>
  311.     if (typeof _editor_url == "string") HTMLArea.replaceAll();
  312. <?php } else { ?>
  313.     if (typeof _editor_url == "string") HTMLArea.replace('message_html');
  314. <?php } ?>
  315.   }
  316.   // -->
  317. </script>
  318. <script language="javascript" type="text/javascript"><!--
  319. var form = "";
  320. var submitted = false;
  321. var error = false;
  322. var error_message = "";
  323.  
  324. function check_select(field_name, field_default, message) {
  325.   if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
  326.     var field_value = form.elements[field_name].value;
  327.  
  328.     if (field_value == field_default) {
  329.       error_message = error_message + "* " + message + "\n";
  330.       error = true;
  331.     }
  332.   }
  333. }
  334. function check_message(msg) {
  335.   if (form.elements['message'] && form.elements['message_html']) {
  336.     var field_value1 = form.elements['message'].value;
  337.     var field_value2 = form.elements['message_html'].value;
  338.  
  339.     if ((field_value1 == '' || field_value1.length < 3) && (field_value2 == '' || field_value2.length < 3)) {
  340.       error_message = error_message + "* " + msg + "\n";
  341.       error = true;
  342.     }
  343.   }
  344. }
  345. function check_input(field_name, field_size, message) {
  346.   if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
  347.     var field_value = form.elements[field_name].value;
  348.  
  349.     if (field_value == '' || field_value.length < field_size) {
  350.       error_message = error_message + "* " + message + "\n";
  351.       error = true;
  352.     }
  353.   }
  354. }
  355.  
  356. function check_form(form_name) {
  357.   if (submitted == true) {
  358.     alert("<?php echo JS_ERROR_SUBMITTED; ?>");
  359.     return false;
  360.   }
  361.   error = false;
  362.   form = form_name;
  363.   error_message = "<?php echo JS_ERROR; ?>";
  364.  
  365.   check_select('customers_email_address', '', "<?php echo ERROR_NO_CUSTOMER_SELECTED; ?>");
  366.   check_message("<?php echo ENTRY_NOTHING_TO_SEND; ?>");
  367.   check_input('subject','',"<?php echo ERROR_NO_SUBJECT; ?>");
  368.  
  369.   if (error == true) {
  370.     alert(error_message);
  371.     return false;
  372.   } else {
  373.     submitted = true;
  374.     return true;
  375.   }
  376. }
  377. //--></script>
  378. <?php if ($editor_handler != '') include ($editor_handler); ?>
  379. </head>
  380. <body onLoad="init()">
  381. <div id="spiffycalendar" class="text"></div>
  382. <!-- header //-->
  383. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  384. <!-- header_eof //-->
  385.  
  386. <!-- body //-->
  387. <table border="0" width="100%" cellspacing="2" cellpadding="2">
  388.   <tr>
  389. <!-- body_text //-->
  390. <?php
  391.   switch ($_GET['action']) {
  392.   case 'voucherreport':
  393. ?>
  394.       <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  395.       <tr>
  396.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  397.           <tr>
  398.             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  399.             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  400.           </tr>
  401.         </table></td>
  402.       </tr>
  403.       <tr>
  404.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  405.           <tr>
  406.             <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  407.               <tr class="dataTableHeadingRow">
  408.                 <td class="dataTableHeadingContent"><?php echo CUSTOMER_ID; ?></td>
  409.                 <td class="dataTableHeadingContent" align="center"><?php echo CUSTOMER_NAME; ?></td>
  410.                 <td class="dataTableHeadingContent" align="center"><?php echo IP_ADDRESS; ?></td>
  411.                 <td class="dataTableHeadingContent" align="center"><?php echo REDEEM_DATE; ?></td>
  412.                 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
  413.               </tr>
  414. <?php
  415.     $cc_query_raw = "select * from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $_GET['cid'] . "'";
  416.     $cc_split = new splitPageResults($_GET['reports_page'], MAX_DISPLAY_SEARCH_RESULTS_DISCOUNT_COUPONS_REPORTS, $cc_query_raw, $cc_query_numrows);
  417.     $cc_list = $db->Execute($cc_query_raw);
  418.     while (!$cc_list->EOF) {
  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 = '" . (int)$_SESSION['languages_id'] . "'");
  462.       $count_customers = $db->Execute("select * from " . TABLE_COUPON_REDEEM_TRACK . "
  463.                                       where coupon_id = '" . $_GET['cid'] . "'
  464.                                       and customer_id = '" . (int)$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 = '" . (int)$_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']), ENT_COMPAT, CHARSET, TRUE); ?></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']), ENT_COMPAT, CHARSET, TRUE); ?></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']), ENT_COMPAT, CHARSET, TRUE)); ?></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), ENT_COMPAT, CHARSET, TRUE));
  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 = '" . (int)$_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. <?php   if (EMAIL_USE_HTML == 'true') { ?>
  634.               <tr>
  635.                 <td valign="top" class="main"><?php echo TEXT_RICH_TEXT_MESSAGE; ?></td>
  636.                 <td><?php echo zen_draw_textarea_field('message_html', 'soft', '100%', '25', htmlspecialchars(($_POST['message_html']=='') ? TEXT_COUPON_ANNOUNCE : stripslashes($_POST['message_html']), ENT_COMPAT, CHARSET, TRUE), 'id="message_html"'); ?></td>
  637.               </tr>
  638. <?php } ?>
  639.               <tr>
  640.                 <td valign="top" class="main"><?php echo TEXT_MESSAGE; ?>&nbsp;&nbsp;</td>
  641.                 <td><?php echo zen_draw_textarea_field('message', 'soft', '60', '15', htmlspecialchars(strip_tags(($_POST['message_html']=='') ? TEXT_COUPON_ANNOUNCE : stripslashes($_POST['message_html'])), ENT_COMPAT, CHARSET, TRUE)); ?></td>
  642.               </tr>
  643.               <tr>
  644.                 <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  645.               </tr>
  646.               <tr>
  647.                 <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>
  648.               </tr>
  649.             </table></td>
  650.           </form></tr>
  651.   </table></td>
  652. <?php
  653.     break;
  654.   case 'update_preview':
  655. ?>
  656.       <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  657.       <tr>
  658.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  659.           <tr>
  660.             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  661.             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  662.           </tr>
  663.         </table></td>
  664.       </tr>
  665.       <tr>
  666.       <td>
  667. <?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'] : '')); ?>
  668.       <table border="0" width="100%" cellspacing="0" cellpadding="6">
  669.         <tr>
  670.           <td align="left" class="main"><?php echo COUPON_ZONE_RESTRICTION; ?></td>
  671.           <td align="left" class="main"><?php echo zen_get_geo_zone_name($_POST['coupon_zone_restriction']); ?>
  672.         </tr>
  673. <?php
  674.         $languages = zen_get_languages();
  675.         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  676.             $language_id = $languages[$i]['id'];
  677. ?>
  678.       <tr>
  679.         <td align="left"><?php echo COUPON_NAME; ?></td>
  680.         <td align="left"><?php echo zen_db_prepare_input($_POST['coupon_name'][$language_id]); ?></td>
  681.       </tr>
  682. <?php
  683. }
  684. ?>
  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_DESC; ?></td>
  692.         <td align="left"><?php echo zen_db_prepare_input($_POST['coupon_desc'][$language_id]); ?></td>
  693.       </tr>
  694. <?php
  695. }
  696. ?>
  697.       <tr>
  698.         <td align="left"><?php echo COUPON_AMOUNT; ?></td>
  699.         <td align="left"><?php echo zen_db_prepare_input($_POST['coupon_amount']); ?></td>
  700.       </tr>
  701.  
  702.       <tr>
  703.         <td align="left"><?php echo COUPON_MIN_ORDER; ?></td>
  704.         <td align="left"><?php echo zen_db_prepare_input($_POST['coupon_min_order']); ?></td>
  705.       </tr>
  706.  
  707.       <tr>
  708.         <td align="left"><?php echo COUPON_FREE_SHIP; ?></td>
  709. <?php
  710.     if ($_POST['coupon_free_ship']) {
  711. ?>
  712.         <td align="left"><?php echo TEXT_FREE_SHIPPING; ?></td>
  713. <?php
  714.     } else {
  715. ?>
  716.         <td align="left"><?php echo TEXT_NO_FREE_SHIPPING; ?></td>
  717. <?php
  718.     }
  719. ?>
  720.       </tr>
  721.       <tr>
  722.         <td align="left"><?php echo COUPON_CODE; ?></td>
  723. <?php
  724.     if ($_POST['coupon_code']) {
  725.       $c_code = $_POST['coupon_code'];
  726.     } else {
  727.       $c_code = $coupon_code;
  728.     }
  729. ?>
  730.         <td align="left"><?php echo $coupon_code; ?></td>
  731.       </tr>
  732.  
  733.       <tr>
  734.         <td align="left"><?php echo COUPON_USES_COUPON; ?></td>
  735.         <td align="left"><?php echo $_POST['coupon_uses_coupon']; ?></td>
  736.       </tr>
  737.  
  738.       <tr>
  739.         <td align="left"><?php echo COUPON_USES_USER; ?></td>
  740.         <td align="left"><?php echo $_POST['coupon_uses_user']; ?></td>
  741.       </tr>
  742.  
  743.       <tr>
  744.         <td align="left"><?php echo COUPON_STARTDATE; ?></td>
  745. <?php
  746.     $start_date = date(DATE_FORMAT, mktime(0, 0, 0, $_POST['coupon_startdate_month'],$_POST['coupon_startdate_day'] ,$_POST['coupon_startdate_year'] ));
  747. ?>
  748.         <td align="left"><?php echo $start_date; ?></td>
  749.       </tr>
  750.  
  751.       <tr>
  752.         <td align="left"><?php echo COUPON_FINISHDATE; ?></td>
  753. <?php
  754.     $finish_date = date(DATE_FORMAT, mktime(0, 0, 0, $_POST['coupon_finishdate_month'],$_POST['coupon_finishdate_day'] ,$_POST['coupon_finishdate_year'] ));
  755. ?>
  756.         <td align="left"><?php echo $finish_date; ?></td>
  757.       </tr>
  758. <?php
  759.         $languages = zen_get_languages();
  760.         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  761.           $language_id = $languages[$i]['id'];
  762.           echo zen_draw_hidden_field('coupon_name[' . $languages[$i]['id'] . ']', stripslashes($_POST['coupon_name'][$language_id]));
  763.           echo zen_draw_hidden_field('coupon_desc[' . $languages[$i]['id'] . ']', stripslashes($_POST['coupon_desc'][$language_id]));
  764.        }
  765.     echo zen_draw_hidden_field('coupon_amount', $_POST['coupon_amount']);
  766.     echo zen_draw_hidden_field('coupon_min_order', $_POST['coupon_min_order']);
  767.     echo zen_draw_hidden_field('coupon_free_ship', $_POST['coupon_free_ship']);
  768.     echo zen_draw_hidden_field('coupon_code', stripslashes($c_code));
  769.     echo zen_draw_hidden_field('coupon_uses_coupon', $_POST['coupon_uses_coupon']);
  770.     echo zen_draw_hidden_field('coupon_uses_user', $_POST['coupon_uses_user']);
  771.     echo zen_draw_hidden_field('coupon_products', $_POST['coupon_products']);
  772.     echo zen_draw_hidden_field('coupon_categories', $_POST['coupon_categories']);
  773.     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'] )));
  774.     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'] )));
  775.     echo zen_draw_hidden_field('coupon_zone_restriction', $_POST['coupon_zone_restriction']);
  776. ?>
  777.      <tr>
  778.         <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>
  779.         <td align="left"><?php echo zen_image_submit('button_cancel.gif',COUPON_BUTTON_CANCEL, 'name=back'); ?></td>
  780.       </td>
  781.       </tr>
  782.  
  783.       </td></table></form>
  784.       </tr>
  785.  
  786.       </table></td>
  787. <?php
  788.  
  789.     break;
  790.   case 'voucheredit':
  791.     $languages = zen_get_languages();
  792.     for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  793.       $language_id = $languages[$i]['id'];
  794.       $coupon = $db->Execute("select coupon_name,coupon_description
  795.                              from " . TABLE_COUPONS_DESCRIPTION . "
  796.                              where coupon_id = '" .  $_GET['cid'] . "'
  797.                              and language_id = '" . (int)$language_id . "'");
  798.  
  799.       $_POST['coupon_name'][$language_id] = $coupon->fields['coupon_name'];
  800.       $_POST['coupon_desc'][$language_id] = $coupon->fields['coupon_description'];
  801.     }
  802.  
  803.     $coupon = $db->Execute("select coupon_code, coupon_amount, coupon_type, coupon_minimum_order,
  804.                                   coupon_start_date, coupon_expire_date, uses_per_coupon,
  805.                                   uses_per_user, restrict_to_products, restrict_to_categories, coupon_zone_restriction
  806.                            from " . TABLE_COUPONS . "
  807.                            where coupon_id = '" . $_GET['cid'] . "'");
  808.  
  809.     $_POST['coupon_amount'] = $coupon->fields['coupon_amount'];
  810.     if ($coupon->fields['coupon_type'] == 'P' || $coupon->fields['coupon_type'] == 'E') {
  811.       $_POST['coupon_amount'] .= '%';
  812.     }
  813.     // free shipping on free shipping only 'S' or percentage off and free shipping 'E' or amount off and free shipping 'O'
  814.     if ($coupon->fields['coupon_type'] == 'S' || $coupon->fields['coupon_type'] == 'O' || $coupon->fields['coupon_type'] == 'E') {
  815.       $_POST['coupon_free_ship'] = true;
  816.     } else {
  817.       $_POST['coupon_free_ship'] = false;
  818.     }
  819.     $_POST['coupon_min_order'] = $coupon->fields['coupon_minimum_order'];
  820.     $_POST['coupon_code'] = $coupon->fields['coupon_code'];
  821.     $_POST['coupon_uses_coupon'] = $coupon->fields['uses_per_coupon'];
  822.     $_POST['coupon_uses_user'] = $coupon->fields['uses_per_user'];
  823.     $_POST['coupon_startdate'] = $coupon->fields['coupon_start_date'];
  824.     $_POST['coupon_finishdate'] = $coupon->fields['coupon_expire_date'];
  825.     $_POST['coupon_zone_restriction'] = $coupon->fields['coupon_zone_restriction'];
  826.  
  827.   case 'new':
  828. // set some defaults
  829.     if ($_GET['action'] != 'voucheredit' and $_POST['coupon_uses_user'] == '') $_POST['coupon_uses_user'] = 1;
  830. ?>
  831.       <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  832.       <tr>
  833.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  834.           <tr>
  835.             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  836.             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  837.           </tr>
  838.         </table></td>
  839.       </tr>
  840.       <tr>
  841.       <td>
  842. <?php
  843.     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'] : ''));
  844. ?>
  845.       <table border="0" width="100%" cellspacing="0" cellpadding="6">
  846. <?php
  847.         $languages = zen_get_languages();
  848.         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  849.         $language_id = $languages[$i]['id'];
  850. ?>
  851.       <tr>
  852.         <td align="left" class="main"><?php if ($i==0) echo COUPON_NAME; ?></td>
  853.         <td align="left"><?php echo zen_draw_input_field('coupon_name[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($_POST['coupon_name'][$language_id]), ENT_COMPAT, CHARSET, TRUE)) . '&nbsp;' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?></td>
  854.         <td align="left" class="main" width="40%"><?php if ($i==0) echo COUPON_NAME_HELP; ?></td>
  855.       </tr>
  856. <?php
  857. }
  858. ?>
  859. <?php
  860.         $languages = zen_get_languages();
  861.         for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  862.         $language_id = $languages[$i]['id'];
  863. ?>
  864.  
  865.       <tr>
  866.         <td align="left" valign="top" class="main"><?php if ($i==0) echo COUPON_DESC; ?></td>
  867.         <td align="left" valign="top"><?php echo zen_draw_textarea_field('coupon_desc[' . $languages[$i]['id'] . ']','physical','24','8', htmlspecialchars(stripslashes($_POST['coupon_desc'][$language_id]), ENT_COMPAT, CHARSET, TRUE)); ?>
  868.             <?php echo '&nbsp;' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?></td>
  869.         <td align="left" valign="top" class="main"><?php if ($i==0) echo COUPON_DESC_HELP; ?></td>
  870.       </tr>
  871. <?php
  872. }
  873. ?>
  874.       <tr>
  875.         <td align="left" class="main"><?php echo COUPON_AMOUNT; ?></td>
  876.         <td align="left"><?php echo zen_draw_input_field('coupon_amount', $_POST['coupon_amount']); ?></td>
  877.         <td align="left" class="main"><?php echo COUPON_AMOUNT_HELP; ?></td>
  878.       </tr>
  879.       <tr>
  880.         <td align="left" class="main"><?php echo COUPON_MIN_ORDER; ?></td>
  881.         <td align="left"><?php echo zen_draw_input_field('coupon_min_order', $_POST['coupon_min_order']); ?></td>
  882.         <td align="left" class="main"><?php echo COUPON_MIN_ORDER_HELP; ?></td>
  883.       </tr>
  884.       <tr>
  885.         <td align="left" class="main"><?php echo COUPON_FREE_SHIP; ?></td>
  886.         <td align="left"><input type="checkbox" name="coupon_free_ship" <?php if ($_POST['coupon_free_ship']) echo 'CHECKED'; ?>></td>
  887.         <td align="left" class="main"><?php echo COUPON_FREE_SHIP_HELP; ?></td>
  888.       </tr>
  889.       <tr>
  890.         <td align="left" class="main"><?php echo COUPON_CODE; ?></td>
  891.         <td align="left"><?php echo zen_draw_input_field('coupon_code', htmlspecialchars($_POST['coupon_code'], ENT_COMPAT, CHARSET, TRUE)); ?></td>
  892.         <td align="left" class="main"><?php echo COUPON_CODE_HELP; ?></td>
  893.       </tr>
  894.       <tr>
  895.         <td align="left" class="main"><?php echo COUPON_USES_COUPON; ?></td>
  896.         <td align="left"><?php echo zen_draw_input_field('coupon_uses_coupon', ($_POST['coupon_uses_coupon'] >= 1 ? $_POST['coupon_uses_coupon'] : '')); ?></td>
  897.         <td align="left" class="main"><?php echo COUPON_USES_COUPON_HELP; ?></td>
  898.       </tr>
  899.       <tr>
  900.         <td align="left" class="main"><?php echo COUPON_USES_USER; ?></td>
  901.         <td align="left"><?php echo zen_draw_input_field('coupon_uses_user', ($_POST['coupon_uses_user'] >= 1 ? $_POST['coupon_uses_user'] : '')); ?></td>
  902.         <td align="left" class="main"><?php echo COUPON_USES_USER_HELP; ?></td>
  903.       </tr>
  904.       <tr>
  905. <?php
  906.     if (!$_POST['coupon_startdate']) {
  907.       $coupon_startdate = preg_split("/[-]/", date('Y-m-d'));
  908.     } else {
  909.       $coupon_startdate = preg_split("/[-]/", $_POST['coupon_startdate']);
  910.     }
  911.     if (!$_POST['coupon_finishdate']) {
  912.       $coupon_finishdate = preg_split("/[-]/", date('Y-m-d'));
  913.       $coupon_finishdate[0] = $coupon_finishdate[0] + 1;
  914.     } else {
  915.       $coupon_finishdate = preg_split("/[-]/", $_POST['coupon_finishdate']);
  916.     }
  917. ?>
  918.         <td align="left" class="main"><?php echo COUPON_STARTDATE; ?></td>
  919.         <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>
  920.         <td align="left" class="main"><?php echo COUPON_STARTDATE_HELP; ?></td>
  921.       </tr>
  922.       <tr>
  923.         <td align="left" class="main"><?php echo COUPON_FINISHDATE; ?></td>
  924.         <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>
  925.         <td align="left" class="main"><?php echo COUPON_FINISHDATE_HELP; ?></td>
  926.       </tr>
  927.       <tr>
  928.         <td align="left" class="main"><?php echo COUPON_ZONE_RESTRICTION; ?></td>
  929.         <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']); ?>
  930.         <td align="left" class="main"><?php echo TEXT_COUPON_ZONE_RESTRICTION; ?></td>
  931.       </tr>
  932.       <tr>
  933.         <td align="left"><?php echo zen_image_submit('button_preview.gif',COUPON_BUTTON_PREVIEW); ?></td>
  934.         <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>
  935.       </td>
  936.       </tr>
  937.       </td></table></form>
  938.       </tr>
  939.  
  940.       </table></td>
  941. <?php
  942.     break;
  943.   default:
  944. ?>
  945.     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  946.       <tr>
  947.         <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  948.           <tr>
  949.             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  950.             <td class="main"><?php echo zen_draw_form('status', FILENAME_COUPON_ADMIN, '', 'get'); ?>
  951. <?php
  952.     $status_array[] = array('id' => 'Y', 'text' => TEXT_COUPON_ACTIVE);
  953.     $status_array[] = array('id' => 'N', 'text' => TEXT_COUPON_INACTIVE);
  954.     $status_array[] = array('id' => '*', 'text' => TEXT_COUPON_ALL);
  955.  
  956.     if (isset($_GET['status'])) {
  957.       $status = zen_db_prepare_input($_GET['status']);
  958.     } else {
  959.       $status = 'Y';
  960.     }
  961.     echo zen_hide_session_id();
  962.     $status = $status[0];
  963.     echo HEADING_TITLE_STATUS . ' ' . zen_draw_pull_down_menu('status', $status_array, $status, 'onChange="this.form.submit();"') .
  964.     zen_draw_hidden_field('page', $_GET['page']);
  965. ?>
  966.               </form>
  967.            </td>
  968.             <td class="main">
  969. <?php
  970. // toggle switch for editor
  971.         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();"') .
  972.         zen_hide_session_id() .
  973.         zen_draw_hidden_field('action', 'set_editor') .
  974.         '</form>';
  975. ?>
  976. </td>
  977.           </tr>
  978.         </table></td>
  979.       </tr>
  980.       <tr>
  981.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  982.           <tr>
  983.             <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  984.               <tr class="dataTableHeadingRow">
  985.                 <td class="dataTableHeadingContent"><?php echo COUPON_NAME; ?></td>
  986.                 <td class="dataTableHeadingContent" align="center"><?php echo COUPON_AMOUNT; ?></td>
  987.                 <td class="dataTableHeadingContent" align="center"><?php echo COUPON_CODE; ?></td>
  988.                 <td class="dataTableHeadingContent" align="center"><?php echo COUPON_ACTIVE; ?></td>
  989.                 <td class="dataTableHeadingContent" align="center"><?php echo COUPON_START_DATE; ?></td>
  990.                 <td class="dataTableHeadingContent" align="center"><?php echo COUPON_EXPIRE_DATE; ?></td>
  991.                 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
  992.               </tr>
  993. <?php
  994.     if ($status != '*') {
  995.       $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'";
  996.     } else {
  997.       $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'";
  998.     }
  999.     $maxDisplaySearchResults = (defined('MAX_DISPLAY_SEARCH_RESULTS_DISCOUNT_COUPONS') && (int)MAX_DISPLAY_SEARCH_RESULTS_DISCOUNT_COUPONS > 0) ? (int)MAX_DISPLAY_SEARCH_RESULTS_DISCOUNT_COUPONS : 20;
  1000.     // reset page when page is unknown
  1001. if (($_GET['page'] == '' or $_GET['page'] == '1') and $_GET['cid'] != '') {
  1002.   $check_page = $db->Execute($cc_query_raw);
  1003.   $check_count=1;
  1004.   if ($check_page->RecordCount() > $maxDisplaySearchResults) {
  1005.     while (!$check_page->EOF) {
  1006.       if ($check_page->fields['coupon_id'] == $_GET['cid']) {
  1007.         break;
  1008.       }
  1009.       $check_count++;
  1010.       $check_page->MoveNext();
  1011.     }
  1012.     $_GET['page'] = round((($check_count/$maxDisplaySearchResults)+(fmod_round($check_count,$maxDisplaySearchResults) !=0 ? .5 : 0)),0);
  1013.   } else {
  1014.     $_GET['page'] = 1;
  1015.   }
  1016. }
  1017.  
  1018.     $cc_split = new splitPageResults($_GET['page'], $maxDisplaySearchResults, $cc_query_raw, $cc_query_numrows);
  1019.     $cc_list = $db->Execute($cc_query_raw);
  1020.     while (!$cc_list->EOF) {
  1021.       if (((!$_GET['cid']) || (@$_GET['cid'] == $cc_list->fields['coupon_id'])) && (!$cInfo)) {
  1022.         $cInfo = new objectInfo($cc_list->fields);
  1023.       }
  1024.       if ( (is_object($cInfo)) && ($cc_list->fields['coupon_id'] == $cInfo->coupon_id) ) {
  1025.         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";
  1026.       } else {
  1027.         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";
  1028.       }
  1029.       $coupon_desc = $db->Execute("select coupon_name
  1030.                                   from " . TABLE_COUPONS_DESCRIPTION . "
  1031.                                   where coupon_id = '" . (int)$cc_list->fields['coupon_id'] . "'
  1032.                                   and language_id = '" . (int)$_SESSION['languages_id'] . "'");
  1033. ?>
  1034.                 <td class="dataTableContent"><?php echo $coupon_desc->fields['coupon_name']; ?></td>
  1035.                 <td class="dataTableContent" align="center">
  1036. <?php
  1037.       switch ($cc_list->fields['coupon_type']) {
  1038.         case ('S'): // free shipping
  1039.           echo TEXT_FREE_SHIPPING;
  1040.           break;
  1041.         case ('P'): // percentage off
  1042.           echo $cc_list->fields['coupon_amount'] . '%';
  1043.           break;
  1044.         case ('F'): // amount off
  1045.           echo $currencies->format($cc_list->fields['coupon_amount']);
  1046.           break;
  1047.         case ('E'): // percentage off and free shipping
  1048.           echo $cc_list->fields['coupon_amount'] . '%' . '<br />' . TEXT_FREE_SHIPPING;
  1049.           break;
  1050.         case ('O'): // amount off and free shipping
  1051.           echo $currencies->format($cc_list->fields['coupon_amount']) . '<br />' . TEXT_FREE_SHIPPING;
  1052.           break;
  1053.         default:
  1054.           echo '***';
  1055.           break;
  1056.       }
  1057. ?>
  1058.             &nbsp;</td>
  1059.                 <td class="dataTableContent" align="center"><?php echo $cc_list->fields['coupon_code']; ?></td>
  1060.                 <td class="dataTableContent" align="center"><?php echo $cc_list->fields['coupon_active']; ?></td>
  1061.                 <td class="dataTableContent" align="center"><?php echo zen_date_short($cc_list->fields['coupon_start_date']); ?></td>
  1062.                 <td class="dataTableContent" align="center"><?php echo zen_date_short($cc_list->fields['coupon_expire_date']); ?></td>
  1063.                 <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>
  1064.               </tr>
  1065. <?php
  1066.       $cc_list->MoveNext();
  1067.     }
  1068. ?>
  1069.           <tr>
  1070.             <td colspan="7"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  1071.               <tr>
  1072.                 <td class="smallText">&nbsp;<?php echo $cc_split->display_count($cc_query_numrows, $maxDisplaySearchResults, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_COUPONS); ?>&nbsp;</td>
  1073.                 <td align="right" class="smallText">&nbsp;<?php echo $cc_split->display_links($cc_query_numrows, $maxDisplaySearchResults, MAX_DISPLAY_PAGE_LINKS, $_GET['page'], (isset($_GET['status']) ? '&status=' . $_GET['status'] : '')); ?>&nbsp;</td>
  1074.               </tr>
  1075.  
  1076.               <tr>
  1077.                 <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>
  1078.               </tr>
  1079.             </table></td>
  1080.           </tr>
  1081.         </table></td>
  1082.  
  1083. <?php
  1084.  
  1085.     $heading = array();
  1086.     $contents = array();
  1087.  
  1088.     switch ($_GET['action']) {
  1089.     case 'release':
  1090.       break;
  1091.     case 'voucherreport':
  1092.       $heading[] = array('text' => '<b>' . TEXT_HEADING_COUPON_REPORT . '</b>');
  1093.       $contents[] = array('text' => TEXT_NEW_INTRO);
  1094.       break;
  1095.     case 'new':
  1096.       $heading[] = array('text' => '<b>' . TEXT_HEADING_NEW_COUPON . '</b>');
  1097.       $contents[] = array('text' => TEXT_NEW_INTRO);
  1098.       $contents[] = array('text' => '<br />' . COUPON_NAME . '<br />' . zen_draw_input_field('name'));
  1099.       $contents[] = array('text' => '<br />' . COUPON_AMOUNT . '<br />' . zen_draw_input_field('voucher_amount'));
  1100.       $contents[] = array('text' => '<br />' . COUPON_CODE . '<br />' . zen_draw_input_field('voucher_code'));
  1101.       $contents[] = array('text' => '<br />' . COUPON_USES_COUPON . '<br />' . zen_draw_input_field('voucher_number_of'));
  1102.       break;
  1103.     default:
  1104.       $heading[] = array('text'=>'['.$cInfo->coupon_id.']  '.$cInfo->coupon_code);
  1105.       $amount = $cInfo->coupon_amount;
  1106.       if ($cInfo->coupon_type == 'P' || $cInfo->coupon_type == 'E') {
  1107.         $amount .= '%';
  1108.       } else {
  1109.         $amount = $currencies->format($amount);
  1110.       }
  1111.       if ($cInfo->coupon_type == 'S'|| $cInfo->coupon_type == 'E' || $cInfo->coupon_type == 'O' ) {
  1112.         $amount .= ' ' . TEXT_FREE_SHIPPING;
  1113.       }
  1114.       if ($_GET['action'] == 'voucherdelete' or $_GET['action'] == 'vouchercopy') {
  1115.         if ($_GET['action'] == 'voucherdelete') {
  1116.           $contents[] = array('text'=> TEXT_CONFIRM_DELETE . '</br></br>' .
  1117.                   '<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>' .
  1118.                   '<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>'
  1119.                   );
  1120.         }
  1121.         if ($_GET['action'] == 'vouchercopy') {
  1122.           $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"'));
  1123.  
  1124.           $contents[] = array('text' => '<br>' . TEXT_COUPON_NEW . '&nbsp;' . zen_draw_input_field('coupon_copy_to', '', 6, 6));
  1125.  
  1126.           $contents[] = array('text'=> TEXT_CONFIRM_COPY . '</br>');
  1127.           $contents[] = array('text'=> zen_image_submit('button_save.gif', IMAGE_SAVE));
  1128.           $contents[] = array('text'=>
  1129.                   '<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>'
  1130.                   );
  1131.         }
  1132.       } else {
  1133.         $prod_details = TEXT_NONE;
  1134. //bof 12-6ke
  1135. $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;
  1136. //eof 12-6ke
  1137.         $cat_details = TEXT_NONE;
  1138. //bof 12-6ke
  1139. $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;
  1140. //eof 12-6ke
  1141.         $coupon_name = $db->Execute("select coupon_name
  1142.                                     from " . TABLE_COUPONS_DESCRIPTION . "
  1143.                                     where coupon_id = '" . $cInfo->coupon_id . "'
  1144.                                     and language_id = '" . (int)$_SESSION['languages_id'] . "'");
  1145.         $uses_coupon = $cInfo->uses_per_coupon;
  1146.         $uses_user = $cInfo->uses_per_user;
  1147.         if ($uses_coupon == 0 || $uses_coupon == '') $uses_coupon = TEXT_UNLIMITED;
  1148.         if ($uses_user == 0 || $uses_user == '') $uses_user = TEXT_UNLIMITED;
  1149.         $contents[] = array('text'=>COUPON_NAME . '&nbsp;::&nbsp; ' . $coupon_name->fields['coupon_name'] . '<br />' .
  1150.                      COUPON_AMOUNT . '&nbsp;::&nbsp; ' . $amount . '<br />' .
  1151.                      COUPON_STARTDATE . '&nbsp;::&nbsp; ' . zen_date_short($cInfo->coupon_start_date) . '<br />' .
  1152.                      COUPON_FINISHDATE . '&nbsp;::&nbsp; ' . zen_date_short($cInfo->coupon_expire_date) . '<br />' .
  1153.                      COUPON_USES_COUPON . '&nbsp;::&nbsp; ' . $uses_coupon . '<br />' .
  1154.                      COUPON_USES_USER . '&nbsp;::&nbsp; ' . $uses_user . '<br />' .
  1155.                      COUPON_PRODUCTS . '&nbsp;::&nbsp; ' . $prod_details . '<br />' .
  1156.                      COUPON_CATEGORIES . '&nbsp;::&nbsp; ' . $cat_details . '<br />' .
  1157.                      DATE_CREATED . '&nbsp;::&nbsp; ' . zen_date_short($cInfo->date_created) . '<br />' .
  1158.                      DATE_MODIFIED . '&nbsp;::&nbsp; ' . zen_date_short($cInfo->date_modified) . '<br /><br />' .
  1159.                      COUPON_ZONE_RESTRICTION . '&nbsp;::&nbsp; ' . zen_get_geo_zone_name($cInfo->coupon_zone_restriction) . '<br /><br />' .
  1160.                      ($cInfo->coupon_id != '' ?
  1161.                      '<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>' .
  1162.                      '<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>' .
  1163.                      '<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>' .
  1164.                      '<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').
  1165.                      '<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>'
  1166.                      : ' who ' . $cInfo->coupon_id . ' - ' . $_GET['cid'])
  1167.                      );
  1168.         }
  1169.         break;
  1170.       }
  1171. ?>
  1172.     <td width="25%" valign="top">
  1173. <?php
  1174.       $box = new box;
  1175.       echo $box->infoBox($heading, $contents);
  1176.     echo '            </td>' . "\n";
  1177.     }
  1178. ?>
  1179.       </tr>
  1180.     </table></td>
  1181. <!-- body_text_eof //-->
  1182.   </tr>
  1183. </table>
  1184. <!-- body_eof //-->
  1185. <!-- footer //-->
  1186. <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  1187. <!-- footer_eof //-->
  1188. </body>
  1189. </html>
  1190. <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
  1191.  


cron