PageRenderTime 48ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/coupon_admin.php

https://bitbucket.org/flth/xtcm
PHP | 1061 lines | 956 code | 35 blank | 70 comment | 144 complexity | 9a8d93048f36b9d048f2a1905c39cf3a MD5 | raw file
Possible License(s): AGPL-1.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /* --------------------------------------------------------------
  3. $Id: coupon_admin.php 1084 2005-07-23 18:36:08Z matthias $
  4. xtcModified - community made shopping
  5. http://www.xtc-modified.org
  6. Copyright (c) 2010 xtcModified
  7. -----------------------------------------------------------------------------------------
  8. based on:
  9. (c) 2000-2001 The Exchange Project (earlier name of osCommerce)
  10. (c) 2002-2003 osCommerce(coupon_admin.php); www.oscommerce.com
  11. (c) 2006 XT-Commerce (coupon_admin.php 1084 2005-07-23)
  12. Released under the GNU General Public License
  13. -----------------------------------------------------------------------------------------
  14. Third Party contribution:
  15. Credit Class/Gift Vouchers/Discount Coupons (Version 5.10)
  16. http://www.oscommerce.com/community/contributions,282
  17. Copyright (c) Strider | Strider@oscworks.com
  18. Copyright (c Nick Stanko of UkiDev.com, nick@ukidev.com
  19. Copyright (c) Andre ambidex@gmx.net
  20. Copyright (c) 2001,2002 Ian C Wilson http://www.phesis.org
  21. Fix html email and error handling (c) 2011-07-07 by web28 - www.rpa-com.de
  22. Released under the GNU General Public License
  23. ---------------------------------------------------------------------------------------*/
  24. require('includes/application_top.php');
  25. require_once(DIR_FS_INC . 'xtc_wysiwyg.inc.php'); //web28- 2011-07-07 - Fix html email
  26. require(DIR_WS_CLASSES . 'currencies.php');
  27. $currencies = new currencies();
  28. require_once(DIR_FS_CATALOG.DIR_WS_CLASSES.'class.phpmailer.php');
  29. require_once(DIR_FS_INC . 'xtc_php_mail.inc.php');
  30. // initiate template engine for mail
  31. $smarty = new Smarty;
  32. if ($_GET['selected_box']) {
  33. $_GET['action']='';
  34. $_GET['old_action']='';
  35. }
  36. if (($_GET['action'] == 'send_email_to_user') && ($_POST['customers_email_address']) && (!$_POST['back_x'])) {
  37. switch ($_POST['customers_email_address']) {
  38. case '***':
  39. $mail_query = xtc_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS);
  40. $mail_sent_to = TEXT_ALL_CUSTOMERS;
  41. break;
  42. case '**D':
  43. $mail_query = xtc_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
  44. $mail_sent_to = TEXT_NEWSLETTER_CUSTOMERS;
  45. break;
  46. default:
  47. $customers_email_address = xtc_db_prepare_input($_POST['customers_email_address']);
  48. $mail_query = xtc_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_email_address = '" . xtc_db_input($customers_email_address) . "'");
  49. $mail_sent_to = $_POST['customers_email_address'];
  50. break;
  51. }
  52. //BOF - web28 - 2011-04-13 - ADD Coupon message infos
  53. //$coupon_query = xtc_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_id = '" . $_GET['cid'] . "'");
  54. $coupon_query = xtc_db_query("select * from " . TABLE_COUPONS . " where coupon_id = '" . (int)$_GET['cid'] . "'");
  55. //EOF - web28 - 2011-04-13 - ADD Coupon message infos
  56. $coupon_result = xtc_db_fetch_array($coupon_query);
  57. $coupon_name_query = xtc_db_query("select coupon_name from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id = '" . (int)$_GET['cid'] . "' and language_id = '" . (int)$_SESSION['languages_id'] . "'");
  58. $coupon_name = xtc_db_fetch_array($coupon_name_query);
  59. //BOF - web28 - 2011-04-13 - ADD Coupon message infos
  60. require(DIR_FS_CATALOG . DIR_WS_CLASSES . 'xtcPrice.php');
  61. $xtPrice = new xtcPrice(DEFAULT_CURRENCY,1);
  62. $coupon_amount = '';
  63. if ($coupon_result['coupon_type']=='S') {
  64. $coupon_amount = COUPON_INFO . COUPON_FREE_SHIPPING;
  65. } else {
  66. $coupon_amount = COUPON_INFO . $xtPrice->xtcFormat($coupon_result['coupon_amount'], true) . ' ';
  67. }
  68. if ($coupon_result['coupon_type']=='P') $coupon_amount = COUPON_INFO . number_format($coupon_result['coupon_amount'], 2) . '% ';
  69. if ($coupon_result['coupon_minimum_order']>0) $coupon_amount .= COUPON_MINORDER_INFO . $xtPrice->xtcFormat($coupon_result['coupon_minimum_order'], true) . ' ';
  70. if (trim($coupon_result['restrict_to_products'])!='' || trim($coupon_result['restrict_to_categories'])!='') $coupon_amount .= COUPON_RESTRICT_INFO;
  71. //TODO - Anzeige der gültigen Artikel/Kategorien
  72. //EOF - web28 - 2011-04-13 - ADD Coupon message infos
  73. $from = xtc_db_prepare_input($_POST['from']);
  74. $subject = xtc_db_prepare_input($_POST['subject']);
  75. while ($mail = xtc_db_fetch_array($mail_query)) {
  76. // assign language to template for caching
  77. $smarty->assign('language', $_SESSION['language']);
  78. $smarty->caching = false;
  79. // set dirs manual
  80. $smarty->template_dir=DIR_FS_CATALOG.'templates';
  81. $smarty->compile_dir=DIR_FS_CATALOG.'templates_c';
  82. $smarty->config_dir=DIR_FS_CATALOG.'lang';
  83. $smarty->assign('tpl_path','templates/'.CURRENT_TEMPLATE.'/');
  84. $smarty->assign('logo_path',HTTP_SERVER . DIR_WS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/img/');
  85. $smarty->assign('MESSAGE', stripslashes($_POST['message'])); //web28 2011-07-07 - Fix html email
  86. $smarty->assign('COUPON_ID', $coupon_result['coupon_code']);
  87. $smarty->assign('COUPON_AMOUNT', $coupon_amount); // web28 - 2011-04-13 - ADD Coupon message infos
  88. $smarty->assign('WEBSITE', HTTP_SERVER . DIR_WS_CATALOG);
  89. $html_mail=$smarty->fetch(CURRENT_TEMPLATE . '/admin/mail/'.$_SESSION['language'].'/send_coupon.html');
  90. $txt_mail=$smarty->fetch(CURRENT_TEMPLATE . '/admin/mail/'.$_SESSION['language'].'/send_coupon.txt');
  91. xtc_php_mail(EMAIL_BILLING_ADDRESS,EMAIL_BILLING_NAME, $mail['customers_email_address'] , $mail['customers_firstname'] . ' ' . $mail['customers_lastname'] , '', EMAIL_BILLING_REPLY_ADDRESS, EMAIL_BILLING_REPLY_ADDRESS_NAME, '', '', $subject, $html_mail , $txt_mail);
  92. }
  93. xtc_redirect(xtc_href_link(FILENAME_COUPON_ADMIN, 'mail_sent_to=' . urlencode($mail_sent_to)));
  94. }
  95. if ( ($_GET['action'] == 'preview_email') && (!$_POST['customers_email_address']) ) {
  96. $_GET['action'] = 'email';
  97. $messageStack->add(ERROR_NO_CUSTOMER_SELECTED, 'error');
  98. }
  99. if ($_GET['mail_sent_to']) {
  100. $messageStack->add(sprintf(NOTICE_EMAIL_SENT_TO, $_GET['mail_sent_to']), 'success');
  101. $_GET['mail_sent_to'] = '';
  102. }
  103. switch ($_GET['action']) {
  104. case 'confirmdelete':
  105. $delete_query=xtc_db_query("update " . TABLE_COUPONS . " set coupon_active = 'N' where coupon_id='".(int)$_GET['cid']."'");
  106. break;
  107. //BOF - web28 - 2010-07-23 - new coupon actions
  108. case 'noconfirmdelete':
  109. // delete coupon from DB
  110. $delete_query = xtc_db_query("delete from ".TABLE_COUPONS." where coupon_id = '".(int)$_GET['cID']."'");
  111. $delete_query = xtc_db_query("delete from ".TABLE_COUPONS_DESCRIPTION." where coupon_id = '".(int)$_GET['cID']."'");
  112. break;
  113. //EOF - web28 - 2010-07-23 - new coupon actions
  114. case 'update':
  115. $update_errors = 0;
  116. // get all _POST and validate
  117. $_POST['coupon_code'] = trim($_POST['coupon_code']);
  118. $languages = xtc_get_languages();
  119. for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  120. $language_id = $languages[$i]['id'];
  121. $_POST['coupon_name'][$language_id] = trim($_POST['coupon_name'][$language_id]);
  122. if (!$_POST['coupon_name'][$language_id]) {
  123. $update_errors = 1;
  124. $messageStack->add(ERROR_NO_COUPON_NAME . $languages[$i]['name'], 'error');
  125. }
  126. $_POST['coupon_desc'][$language_id] = trim($_POST['coupon_desc'][$language_id]);
  127. }
  128. $_POST['coupon_amount'] = trim($_POST['coupon_amount']);
  129. $_POST['coupon_amount'] = preg_replace('/[^0-9.%]/', '', $_POST['coupon_amount']); //DokuMan - 2010-11-13 - allow numbers only
  130. if (!$_POST['coupon_name']) {
  131. $update_errors = 1;
  132. $messageStack->add(ERROR_NO_COUPON_NAME, 'error');
  133. }
  134. if ((!$_POST['coupon_amount']) && (!$_POST['coupon_free_ship'])) {
  135. $update_errors = 1;
  136. $messageStack->add(ERROR_NO_COUPON_AMOUNT, 'error');
  137. }
  138. if (!$_POST['coupon_code']) {
  139. $coupon_code = create_coupon_code();
  140. }
  141. if ($_POST['coupon_code']) $coupon_code = $_POST['coupon_code'];
  142. $query1 = xtc_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_code = '" . xtc_db_prepare_input($coupon_code) . "'");
  143. if (xtc_db_num_rows($query1) && $_POST['coupon_code'] && $_GET['oldaction'] != 'voucheredit') {
  144. $update_errors = 1;
  145. $messageStack->add(ERROR_COUPON_EXISTS, 'error');
  146. }
  147. if ($update_errors != 0) {
  148. $_GET['action'] = 'new';
  149. } else {
  150. $_GET['action'] = 'update_preview';
  151. }
  152. break;
  153. case 'update_confirm':
  154. if ( ($_POST['back_x']) || ($_POST['back_y']) ) {
  155. $_GET['action'] = 'new';
  156. } else {
  157. $coupon_type = "F";
  158. if (substr($_POST['coupon_amount'], -1) == '%') $coupon_type='P';
  159. if ($_POST['coupon_free_ship']) $coupon_type = 'S';
  160. $_POST['coupon_amount'] = preg_replace('/[^0-9.]/', '', $_POST['coupon_amount']); //DokuMan - 2010-11-13 - allow numbers only
  161. $sql_data_array = array('coupon_code' => xtc_db_prepare_input($_POST['coupon_code']),
  162. 'coupon_amount' => xtc_db_prepare_input($_POST['coupon_amount']),
  163. 'coupon_type' => xtc_db_prepare_input($coupon_type),
  164. 'uses_per_coupon' => xtc_db_prepare_input((int)$_POST['coupon_uses_coupon']),
  165. 'uses_per_user' => xtc_db_prepare_input((int)$_POST['coupon_uses_user']),
  166. 'coupon_minimum_order' => xtc_db_prepare_input($_POST['coupon_min_order']),
  167. 'restrict_to_products' => xtc_db_prepare_input($_POST['coupon_products']),
  168. 'restrict_to_categories' => xtc_db_prepare_input($_POST['coupon_categories']),
  169. 'coupon_start_date' => $_POST['coupon_startdate'],
  170. 'coupon_expire_date' => $_POST['coupon_finishdate'],
  171. 'date_created' => 'now()',
  172. 'date_modified' => 'now()');
  173. $languages = xtc_get_languages();
  174. for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  175. $language_id = $languages[$i]['id'];
  176. $sql_data_marray[$i] = array('coupon_name' => xtc_db_prepare_input($_POST['coupon_name'][$language_id]),
  177. 'coupon_description' => xtc_db_prepare_input($_POST['coupon_desc'][$language_id])
  178. );
  179. }
  180. if ($_GET['oldaction']=='voucheredit') {
  181. xtc_db_perform(TABLE_COUPONS, $sql_data_array, 'update', "coupon_id='" . (int)$_GET['cid']."'");
  182. for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  183. $language_id = $languages[$i]['id'];
  184. //BOF - web28 - 2011-04-07 - BUGFIX no entry stored for previous deactivated languages
  185. $coupon_query = xtc_db_query("select * from ".TABLE_COUPONS_DESCRIPTION." where language_id = '".(int)$language_id."' and coupon_id = '".(int)$_GET['cid']."'");
  186. if (xtc_db_num_rows($coupon_query) == 0) xtc_db_perform(TABLE_COUPONS_DESCRIPTION, array ('coupon_id' => (int)$_GET['cid'], 'language_id' => (int)$language_id));
  187. //EOF - web28 - 2011-04-07 - BUGFIX no entry stored for previous deactivated languages
  188. $update = xtc_db_query("update " . TABLE_COUPONS_DESCRIPTION . " set coupon_name = '" . xtc_db_prepare_input($_POST['coupon_name'][$language_id]) . "',
  189. coupon_description = '" . xtc_db_prepare_input($_POST['coupon_desc'][$language_id]) . "'
  190. where coupon_id = '" . (int)$_GET['cid'] . "' and language_id = '" . (int)$language_id . "'");
  191. }
  192. } else {
  193. $query = xtc_db_perform(TABLE_COUPONS, $sql_data_array);
  194. $insert_id = xtc_db_insert_id();
  195. for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  196. $language_id = $languages[$i]['id'];
  197. $sql_data_marray[$i]['coupon_id'] = $insert_id;
  198. $sql_data_marray[$i]['language_id'] = $language_id;
  199. xtc_db_perform(TABLE_COUPONS_DESCRIPTION, $sql_data_marray[$i]);
  200. }
  201. }
  202. }
  203. }
  204. ?>
  205. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  206. <html <?php echo HTML_PARAMS; ?>>
  207. <head>
  208. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $_SESSION['language_charset']; ?>">
  209. <title><?php echo TITLE; ?></title>
  210. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  211. <?php
  212. if (USE_WYSIWYG=='true' && $_GET['action'] == 'email') {
  213. $query=xtc_db_query("SELECT code FROM ". TABLE_LANGUAGES ." WHERE languages_id='".$_SESSION['languages_id']."'");
  214. $data=xtc_db_fetch_array($query);
  215. echo xtc_wysiwyg('gv_mail',$data['code']);
  216. }
  217. ?>
  218. <script type="text/javascript" src="includes/general.js"></script>
  219. <link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
  220. <script type="text/javascript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
  221. <script type="text/javascript">
  222. var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?php echo $pInfo->products_date_available; ?>",scBTNMODE_CUSTOMBLUE);
  223. </script>
  224. </head>
  225. <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
  226. <div id="spiffycalendar" class="text"></div>
  227. <!-- header //-->
  228. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  229. <!-- header_eof //-->
  230. <!-- body //-->
  231. <table border="0" width="100%" cellspacing="2" cellpadding="2">
  232. <tr>
  233. <td class="columnLeft2" width="<?php echo BOX_WIDTH; ?>" valign="top">
  234. <table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
  235. <!-- left_navigation //-->
  236. <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
  237. <!-- left_navigation_eof //-->
  238. </table>
  239. </td>
  240. <!-- body_text //-->
  241. <?php
  242. switch ($_GET['action']) {
  243. case 'voucherreport':
  244. ?>
  245. <td class="boxCenter" width="100%" valign="top">
  246. <table border="0" width="100%" cellspacing="0" cellpadding="0">
  247. <tr>
  248. <td>
  249. <table border="0" width="100%" cellspacing="0" cellpadding="0">
  250. <tr>
  251. <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  252. <td class="pageHeading" align="right"><?php echo xtc_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  253. </tr>
  254. </table>
  255. </td>
  256. </tr>
  257. <tr>
  258. <td>
  259. <table border="0" width="100%" cellspacing="0" cellpadding="0">
  260. <tr>
  261. <td valign="top">
  262. <table border="0" width="100%" cellspacing="0" cellpadding="2">
  263. <tr class="dataTableHeadingRow">
  264. <td class="dataTableHeadingContent" align="left"><?php echo COUPON_ID; ?></td>
  265. <?php // web28 - 2010-07-23 - new table design ?>
  266. <td class="dataTableHeadingContent" align="left"><?php echo CUSTOMER_ID; ?></td>
  267. <td class="dataTableHeadingContent" align="left"><?php echo CUSTOMER_NAME; ?></td>
  268. <td class="dataTableHeadingContent" align="left"><?php echo IP_ADDRESS; ?></td>
  269. <td class="dataTableHeadingContent" align="left"><?php echo REDEEM_DATE; ?></td>
  270. <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
  271. </tr>
  272. <?php
  273. $cc_query_raw = "select * from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . (int)$_GET['cid'] . "'";
  274. $cc_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $cc_query_raw, $cc_query_numrows);
  275. $cc_query = xtc_db_query($cc_query_raw);
  276. while ($cc_list = xtc_db_fetch_array($cc_query)) {
  277. $rows++;
  278. if (strlen($rows) < 2) {
  279. $rows = '0' . $rows;
  280. }
  281. if (((!$_GET['uid']) || (@$_GET['uid'] == $cc_list['unique_id'])) && (!$cInfo)) {
  282. $cInfo = new objectInfo($cc_list);
  283. }
  284. if ( (is_object($cInfo)) && ($cc_list['unique_id'] == $cInfo->unique_id) ) {
  285. echo ' <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'pointer\'" onclick="document.location.href=\'' . xtc_href_link('coupon_admin.php', xtc_get_all_get_params(array('cid', 'action', 'uid')) . 'cid=' . $cInfo->coupon_id . '&action=voucherreport&uid=' . $cinfo->unique_id) . '\'">' . "\n";
  286. } else {
  287. echo ' <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'pointer\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . xtc_href_link('coupon_admin.php', xtc_get_all_get_params(array('cid', 'action', 'uid')) . 'cid=' . $cc_list['coupon_id'] . '&action=voucherreport&uid=' . $cc_list['unique_id']) . '\'">' . "\n";
  288. }
  289. $customer_query = xtc_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . $cc_list['customer_id'] . "'");
  290. $customer = xtc_db_fetch_array($customer_query);
  291. ?>
  292. <td class="dataTableContent" align="left">&nbsp;<?php echo $_GET['cid']; ?></td><?php // web28 - 2010-07-23 - new table design ?>
  293. <td class="dataTableContent" align="left">&nbsp;<?php echo $cc_list['customer_id']; ?></td>
  294. <td class="dataTableContent" align="left">&nbsp;<?php echo $customer['customers_firstname'] . ' ' . $customer['customers_lastname']; ?></td>
  295. <td class="dataTableContent" align="left">&nbsp;<?php echo $cc_list['redeem_ip']; ?></td>
  296. <td class="dataTableContent" align="left">&nbsp;<?php echo xtc_date_short($cc_list['redeem_date']); ?></td>
  297. <td class="dataTableContent" align="right"><?php if (isset($cInfo) && is_object($cInfo) && ($cc_list['unique_id'] == $cInfo->unique_id) ) { echo xtc_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ICON_ARROW_RIGHT); } else { echo '<a href="' . xtc_href_link(FILENAME_COUPON_ADMIN, 'page=' . $_GET['page'] . '&cid=' . $cc_list['coupon_id']) . '">' . xtc_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
  298. </tr>
  299. <?php
  300. }
  301. ?>
  302. </table>
  303. </td>
  304. <?php
  305. $heading = array();
  306. $contents = array();
  307. $coupon_description_query = xtc_db_query("select coupon_name from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id = '" . (int)$_GET['cid'] . "' and language_id = '" . (int)$_SESSION['languages_id'] . "'");
  308. $coupon_desc = xtc_db_fetch_array($coupon_description_query);
  309. $count_customers = xtc_db_query("select * from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . (int)$_GET['cid'] . "' and customer_id = '" . (int)$cInfo->customer_id . "'");
  310. $heading[] = array('text' => '<b>[' . $_GET['cid'] . ']' . COUPON_NAME . ' ' . $coupon_desc['coupon_name'] . '</b>');
  311. $contents[] = array('text' => '<b>' . TEXT_REDEMPTIONS . '</b>');
  312. $contents[] = array('text' => TEXT_REDEMPTIONS_TOTAL . '=' . xtc_db_num_rows($cc_query));
  313. $contents[] = array('text' => TEXT_REDEMPTIONS_CUSTOMER . '=' . xtc_db_num_rows($count_customers));
  314. //added missing back button
  315. $contents[] = array('text' => '<a class="button" onclick="this.blur();" href="' . xtc_href_link(FILENAME_COUPON_ADMIN) . '">' . BUTTON_BACK . '</a>');
  316. ?>
  317. <td width="25%" valign="top">
  318. <?php
  319. $box = new box;
  320. echo $box->infoBox($heading, $contents);
  321. echo ' </td>' . "\n";
  322. break;
  323. case 'preview_email':
  324. $coupon_query = xtc_db_query("select coupon_code from " .TABLE_COUPONS . " where coupon_id = '" . (int)$_GET['cid'] . "'");
  325. $coupon_result = xtc_db_fetch_array($coupon_query);
  326. $coupon_name_query = xtc_db_query("select coupon_name from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id = '" . (int)$_GET['cid'] . "' and language_id = '" . (int)$_SESSION['languages_id'] . "'");
  327. $coupon_name = xtc_db_fetch_array($coupon_name_query);
  328. switch ($_POST['customers_email_address']) {
  329. case '***':
  330. $mail_sent_to = TEXT_ALL_CUSTOMERS;
  331. break;
  332. case '**D':
  333. $mail_sent_to = TEXT_NEWSLETTER_CUSTOMERS;
  334. break;
  335. default:
  336. $mail_sent_to = $_POST['customers_email_address'];
  337. break;
  338. }
  339. ?>
  340. <td width="100%" valign="top">
  341. <table border="0" width="100%" cellspacing="0" cellpadding="2">
  342. <tr>
  343. <td>
  344. <table border="0" width="100%" cellspacing="0" cellpadding="0">
  345. <tr>
  346. <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  347. <td class="pageHeading" align="right"><?php echo xtc_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  348. </tr>
  349. </table>
  350. </td>
  351. </tr>
  352. <tr>
  353. <?php echo xtc_draw_form('mail', FILENAME_COUPON_ADMIN, 'action=send_email_to_user&cid=' . $_GET['cid']); ?>
  354. <td>
  355. <table border="0" width="100%" cellpadding="0" cellspacing="2">
  356. <tr>
  357. <td><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  358. </tr>
  359. <tr>
  360. <td class="smallText"><b><?php echo TEXT_CUSTOMER; ?></b><br /><?php echo $mail_sent_to; ?></td>
  361. </tr>
  362. <tr>
  363. <td><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  364. </tr>
  365. <tr>
  366. <td class="smallText"><b><?php echo TEXT_COUPON; ?></b><br /><?php echo $coupon_name['coupon_name']; ?></td>
  367. </tr>
  368. <tr>
  369. <td><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  370. </tr>
  371. <tr>
  372. <td class="smallText"><b><?php echo TEXT_FROM; ?></b><br /><?php echo htmlspecialchars(stripslashes($_POST['from'])); ?></td>
  373. </tr>
  374. <tr>
  375. <td><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  376. </tr>
  377. <tr>
  378. <td class="smallText"><b><?php echo TEXT_SUBJECT; ?></b><br /><?php echo htmlspecialchars(stripslashes($_POST['subject'])); ?></td>
  379. </tr>
  380. <tr>
  381. <td><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  382. </tr>
  383. <tr>
  384. <td class="smallText"><b><?php echo TEXT_MESSAGE; ?></b><br /><?php echo stripslashes($_POST['message']); ?></td>
  385. </tr>
  386. <tr>
  387. <td><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  388. </tr>
  389. <tr>
  390. <td>
  391. <?php
  392. /* Re-Post all POST'ed variables */
  393. reset($_POST);
  394. while (list($key, $value) = each($_POST)) {
  395. if (!is_array($_POST[$key])) {
  396. echo xtc_draw_hidden_field($key, htmlspecialchars(stripslashes($value)));
  397. }
  398. }
  399. ?>
  400. <table border="0" width="100%" cellpadding="0" cellspacing="2">
  401. <tr>
  402. <td><?php ?>&nbsp;</td>
  403. <td align="right"><?php echo '<a class="button" onclick="this.blur();" href="' . xtc_href_link(FILENAME_COUPON_ADMIN) . '">' . BUTTON_CANCEL . '</a> <input type="submit" class="button" onclick="this.blur();" value="' . BUTTON_SEND_EMAIL . '"/>'; ?></td>
  404. </tr>
  405. </table>
  406. </td>
  407. </tr>
  408. </table>
  409. </td>
  410. </form>
  411. </tr>
  412. <?php
  413. break;
  414. case 'email':
  415. $coupon_query = xtc_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_id = '" . (int)$_GET['cid'] . "'");
  416. $coupon_result = xtc_db_fetch_array($coupon_query);
  417. $coupon_name_query = xtc_db_query("select coupon_name from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id = '" . (int)$_GET['cid'] . "' and language_id = '" . (int)$_SESSION['languages_id'] . "'");
  418. $coupon_name = xtc_db_fetch_array($coupon_name_query);
  419. ?>
  420. <td class="boxCenter" width="100%" valign="top">
  421. <table border="0" width="100%" cellspacing="0" cellpadding="2">
  422. <tr>
  423. <td>
  424. <table border="0" width="100%" cellspacing="0" cellpadding="0">
  425. <tr>
  426. <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  427. <td class="pageHeading" align="right"><?php echo xtc_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  428. </tr>
  429. </table>
  430. </td>
  431. </tr>
  432. <tr>
  433. <?php echo xtc_draw_form('mail', FILENAME_COUPON_ADMIN, 'action=preview_email&cid='. (int)$_GET['cid']); ?>
  434. <td>
  435. <table class="main" border="0" cellpadding="0" cellspacing="2">
  436. <?php // web28 - 2010-07-23 - new table design ?>
  437. <tr>
  438. <td colspan="2"><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  439. </tr>
  440. <?php
  441. $customers = array();
  442. $customers[] = array('id' => '', 'text' => TEXT_SELECT_CUSTOMER);
  443. $customers[] = array('id' => '***', 'text' => TEXT_ALL_CUSTOMERS);
  444. $customers[] = array('id' => '**D', 'text' => TEXT_NEWSLETTER_CUSTOMERS);
  445. $mail_query = xtc_db_query("select customers_email_address, customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " order by customers_lastname");
  446. while($customers_values = xtc_db_fetch_array($mail_query)) {
  447. $customers[] = array('id' => $customers_values['customers_email_address'],
  448. 'text' => $customers_values['customers_lastname'] . ', ' . $customers_values['customers_firstname'] . ' (' . $customers_values['customers_email_address'] . ')');
  449. }
  450. ?>
  451. <tr>
  452. <td colspan="2"><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  453. </tr>
  454. <tr>
  455. <td class="main"><?php echo TEXT_COUPON; ?>&nbsp;&nbsp;</td>
  456. <td class="main"><?php echo $coupon_name['coupon_name']; ?></td>
  457. </tr>
  458. <tr>
  459. <td colspan="2"><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  460. </tr>
  461. <tr>
  462. <td class="main"><?php echo TEXT_CUSTOMER; ?>&nbsp;&nbsp;</td>
  463. <td><?php echo xtc_draw_pull_down_menu('customers_email_address', $customers, $_GET['customer']);?></td>
  464. </tr>
  465. <tr>
  466. <td colspan="2"><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  467. </tr>
  468. <tr>
  469. <td class="main"><?php echo TEXT_FROM; ?>&nbsp;&nbsp;</td>
  470. <td><?php echo xtc_draw_input_field('from', EMAIL_FROM); ?></td>
  471. </tr>
  472. <tr>
  473. <td colspan="2"><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  474. </tr>
  475. <?php
  476. /*
  477. <tr>
  478. <td class="main"><?php echo TEXT_RESTRICT; ?>&nbsp;&nbsp;</td>
  479. <td><?php echo xtc_draw_checkbox_field('customers_restrict', $customers_restrict);?></td>
  480. </tr>
  481. <tr>
  482. <td colspan="2"><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  483. </tr>
  484. */
  485. ?>
  486. <tr>
  487. <td class="main"><?php echo TEXT_SUBJECT; ?>&nbsp;&nbsp;</td>
  488. <td><?php echo xtc_draw_input_field('subject',$_POST['subject']); ?></td>
  489. </tr>
  490. <tr>
  491. <td colspan="2"><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  492. </tr>
  493. <tr>
  494. <td valign="top" class="main"><?php echo TEXT_MESSAGE; ?>&nbsp;&nbsp;</td>
  495. <td><?php echo xtc_draw_textarea_field('message', 'soft', '60', '15', $_POST['message']); ?></td>
  496. </tr>
  497. <tr>
  498. <td colspan="2"><?php echo xtc_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  499. </tr>
  500. <tr>
  501. <td colspan="2" align="right"><?php echo '<input type="submit" class="button" onclick="this.blur();" value="' . BUTTON_SEND_EMAIL . '"/>'; ?></td>
  502. </tr>
  503. </table>
  504. </td>
  505. </form>
  506. </tr>
  507. </td>
  508. <?php
  509. break;
  510. case 'update_preview':
  511. ?>
  512. <td class="boxCenter" width="100%" valign="top">
  513. <table border="0" width="100%" cellspacing="0" cellpadding="2">
  514. <tr>
  515. <td>
  516. <table border="0" width="100%" cellspacing="0" cellpadding="0">
  517. <tr>
  518. <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  519. <td class="pageHeading" align="right"><?php echo xtc_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  520. </tr>
  521. </table>
  522. </td>
  523. </tr>
  524. <tr>
  525. <td>
  526. <?php echo xtc_draw_form('coupon', 'coupon_admin.php', 'action=update_confirm&oldaction=' . $_GET['oldaction'] . '&cid=' . (int)$_GET['cid']); ?>
  527. <?php // BOF - web28 - 2011-03-11 - new table design ?>
  528. <table class="main borderall" border="0" cellspacing="0" cellpadding="5" style="border-collapse:collapse">
  529. <?php
  530. $languages = xtc_get_languages();
  531. for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  532. $language_id = $languages[$i]['id'];
  533. $lang_img = '<span style="float:right; padding-top:2px;">'. xtc_image(DIR_WS_LANGUAGES . $languages[$i]['directory'].'/admin/images/'.$languages[$i]['image'], $languages[$i]['name']) . '</span>';
  534. ?>
  535. <tr>
  536. <td align="left"><?php echo COUPON_NAME. $lang_img ; ?></td>
  537. <td align="left"><?php echo $_POST['coupon_name'][$language_id]; ?>&nbsp;</td>
  538. </tr>
  539. <?php
  540. }
  541. $languages = xtc_get_languages();
  542. for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  543. $language_id = $languages[$i]['id'];
  544. $lang_img = '<span style="float:right; padding-top:2px;">'. xtc_image(DIR_WS_LANGUAGES . $languages[$i]['directory'].'/admin/images/'.$languages[$i]['image'], $languages[$i]['name']) . '</span>';
  545. ?>
  546. <tr>
  547. <td align="left"><?php echo COUPON_DESC. $lang_img ; ?></td>
  548. <td align="left"><?php echo $_POST['coupon_desc'][$language_id]; ?>&nbsp;</td>
  549. </tr>
  550. <?php
  551. }
  552. ?>
  553. <tr>
  554. <td align="left"><?php echo COUPON_AMOUNT; ?></td>
  555. <td align="left"><?php echo $_POST['coupon_amount']; ?>&nbsp;</td>
  556. </tr>
  557. <tr>
  558. <td align="left"><?php echo COUPON_MIN_ORDER; ?></td>
  559. <td align="left"><?php echo $_POST['coupon_min_order']; ?>&nbsp;</td>
  560. </tr>
  561. <tr>
  562. <td align="left"><?php echo COUPON_FREE_SHIP; ?></td>
  563. <?php
  564. if ($_POST['coupon_free_ship']) {
  565. ?>
  566. <td align="left"><?php echo TEXT_FREE_SHIPPING; ?></td>
  567. <?php
  568. } else {
  569. ?>
  570. <td align="left"><?php echo TEXT_NO_FREE_SHIPPING; ?></td>
  571. <?php
  572. }
  573. ?>
  574. </tr>
  575. <tr>
  576. <td align="left"><?php echo COUPON_CODE; ?></td>
  577. <?php
  578. if ($_POST['coupon_code']) {
  579. $c_code = $_POST['coupon_code'];
  580. } else {
  581. $c_code = $coupon_code;
  582. }
  583. ?>
  584. <td align="left"><?php echo $coupon_code; ?>&nbsp;</td>
  585. </tr>
  586. <tr>
  587. <td align="left"><?php echo COUPON_USES_COUPON; ?></td>
  588. <td align="left"><?php echo $_POST['coupon_uses_coupon']; ?>&nbsp;</td>
  589. </tr>
  590. <tr>
  591. <td align="left"><?php echo COUPON_USES_USER; ?></td>
  592. <td align="left"><?php echo $_POST['coupon_uses_user']; ?>&nbsp;</td>
  593. </tr>
  594. <tr>
  595. <td align="left"><?php echo COUPON_PRODUCTS; ?></td>
  596. <td align="left"><?php echo $_POST['coupon_products']; ?>&nbsp;</td>
  597. </tr>
  598. <tr>
  599. <td align="left"><?php echo COUPON_CATEGORIES; ?></td>
  600. <td align="left"><?php echo $_POST['coupon_categories']; ?>&nbsp;</td>
  601. </tr>
  602. <tr>
  603. <td align="left"><?php echo COUPON_STARTDATE; ?></td>
  604. <?php
  605. $start_date = date(DATE_FORMAT, mktime(0, 0, 0, $_POST['coupon_startdate_month'],$_POST['coupon_startdate_day'] ,$_POST['coupon_startdate_year'] ));
  606. ?>
  607. <td align="left"><?php echo $start_date; ?>&nbsp;</td>
  608. </tr>
  609. <tr>
  610. <td align="left"><?php echo COUPON_FINISHDATE; ?></td>
  611. <?php
  612. $finish_date = date(DATE_FORMAT, mktime(0, 0, 0, $_POST['coupon_finishdate_month'],$_POST['coupon_finishdate_day'] ,$_POST['coupon_finishdate_year'] ));
  613. ?>
  614. <td align="left"><?php echo $finish_date; ?>&nbsp;</td>
  615. </tr>
  616. <?php
  617. $languages = xtc_get_languages();
  618. for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  619. $language_id = $languages[$i]['id'];
  620. echo xtc_draw_hidden_field('coupon_name[' . $languages[$i]['id'] . ']', stripslashes($_POST['coupon_name'][$language_id]));
  621. echo xtc_draw_hidden_field('coupon_desc[' . $languages[$i]['id'] . ']', stripslashes($_POST['coupon_desc'][$language_id]));
  622. }
  623. echo xtc_draw_hidden_field('coupon_amount', $_POST['coupon_amount']);
  624. echo xtc_draw_hidden_field('coupon_min_order', $_POST['coupon_min_order']);
  625. echo xtc_draw_hidden_field('coupon_free_ship', $_POST['coupon_free_ship']);
  626. echo xtc_draw_hidden_field('coupon_code', $c_code);
  627. echo xtc_draw_hidden_field('coupon_uses_coupon', $_POST['coupon_uses_coupon']);
  628. echo xtc_draw_hidden_field('coupon_uses_user', $_POST['coupon_uses_user']);
  629. echo xtc_draw_hidden_field('coupon_products', $_POST['coupon_products']);
  630. echo xtc_draw_hidden_field('coupon_categories', $_POST['coupon_categories']);
  631. echo xtc_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'] )));
  632. echo xtc_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'] )));
  633. ?>
  634. </table>
  635. <?php echo '<input type="submit" class="button" onclick="this.blur();" value="' . BUTTON_CONFIRM . '"/>'; ?>
  636. <?php echo '<input type="submit" name="back" class="button" onclick="this.blur();" value="' . BUTTON_BACK . '"/>'; ?>
  637. </form>
  638. </td>
  639. </tr>
  640. </table>
  641. </td>
  642. <?php
  643. break;
  644. case 'voucheredit':
  645. $languages = xtc_get_languages();
  646. for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  647. $language_id = $languages[$i]['id'];
  648. $coupon_query = xtc_db_query("select coupon_name,coupon_description from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id = '" . (int)$_GET['cid'] . "' and language_id = '" . (int)$language_id . "'");
  649. $coupon = xtc_db_fetch_array($coupon_query);
  650. $coupon_name[$language_id] = $coupon['coupon_name'];
  651. $coupon_desc[$language_id] = $coupon['coupon_description'];
  652. }
  653. $coupon_query = xtc_db_query("select coupon_code, coupon_amount, coupon_type, coupon_minimum_order, coupon_start_date, coupon_expire_date, uses_per_coupon, uses_per_user, restrict_to_products, restrict_to_categories from " . TABLE_COUPONS . " where coupon_id = '" . (int)$_GET['cid'] . "'");
  654. $coupon = xtc_db_fetch_array($coupon_query);
  655. $coupon_amount = $coupon['coupon_amount'];
  656. if ($coupon['coupon_type']=='P') {
  657. $coupon_amount .= '%';
  658. }
  659. if ($coupon['coupon_type']=='S') {
  660. $coupon_free_ship .= true;
  661. }
  662. $coupon_min_order = $coupon['coupon_minimum_order'];
  663. $coupon_code = $coupon['coupon_code'];
  664. $coupon_uses_coupon = $coupon['uses_per_coupon'];
  665. $coupon_uses_user = $coupon['uses_per_user'];
  666. $coupon_products = $coupon['restrict_to_products'];
  667. $coupon_categories = $coupon['restrict_to_categories'];
  668. //BOF web28 - 2010-03-11 FIX coupon_start_date, coupon_expire_date
  669. $coupon_start_date = $coupon['coupon_start_date'];
  670. $coupon_expire_date = $coupon['coupon_expire_date'];
  671. //EOF web28 - 2010-03-11 FIX coupon_start_date, coupon_expire_date
  672. case 'new':
  673. //BOF web28 - 2010-07-04 FIX error handling
  674. if (isset($_POST['coupon_amount'])) $coupon_amount = $_POST['coupon_amount'];
  675. if (isset($_POST['coupon_min_order'])) $coupon_min_order = $_POST['coupon_min_order'];
  676. if (isset($_POST['coupon_free_ship'])) $coupon_free_ship = $_POST['coupon_free_ship'];
  677. if (isset($_POST['coupon_code'])) $coupon_code = $_POST['coupon_code'];
  678. if (isset($_POST['coupon_uses_coupon'])) $coupon_uses_coupon = $_POST['coupon_uses_coupon'];
  679. if (isset($_POST['coupon_uses_user'])) $coupon_uses_user = $_POST['coupon_uses_user'];
  680. if (isset($_POST['coupon_products'])) $coupon_products = $_POST['coupon_products'];
  681. if (isset($_POST['coupon_categories'])) $coupon_categories = $_POST['coupon_categories'];
  682. if (isset($_POST['coupon_startdate_day'])) $coupon_start_date = date('Y-m-d', mktime(0, 0, 0, $_POST['coupon_startdate_month'],$_POST['coupon_startdate_day'] ,$_POST['coupon_startdate_year']));
  683. if (isset($_POST['coupon_finishdate_day'])) $coupon_expire_date = date('Y-m-d', mktime(0, 0, 0, $_POST['coupon_finishdate_month'],$_POST['coupon_finishdate_day'] ,$_POST['coupon_finishdate_year']));
  684. //EOF web28 - 2010-07-04 FIX error handling
  685. // set some defaults
  686. if (!$coupon_uses_user) $coupon_uses_user=1;
  687. ?>
  688. <td class="boxCenter" width="100%" valign="top">
  689. <table border="0" width="100%" cellspacing="0" cellpadding="2">
  690. <tr>
  691. <td>
  692. <table border="0" width="100%" cellspacing="0" cellpadding="0">
  693. <tr>
  694. <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  695. <td class="pageHeading" align="right"><?php echo xtc_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  696. </tr>
  697. </table>
  698. </td>
  699. </tr>
  700. <tr>
  701. <td>
  702. <?php
  703. // BOF - web28 - 2010-07-23 - new table design
  704. $input_name = '';
  705. $input_desc = '';
  706. $languages = xtc_get_languages();
  707. for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
  708. $language_id = $languages[$i]['id'];
  709. //BOF web28 - 2010-07-04 FIX error handling
  710. if (isset($_POST['coupon_name'][$language_id])) $coupon_name[$language_id] = $_POST['coupon_name'][$language_id];
  711. if (isset($_POST['coupon_desc'][$language_id])) $coupon_desc[$language_id] = $_POST['coupon_desc'][$language_id];
  712. //BOF web28 - 2010-07-04 FIX error handling
  713. $lang_img = '<span style="float:left; padding-top:2px;">'. xtc_image(DIR_WS_LANGUAGES . $languages[$i]['directory'].'/admin/images/'.$languages[$i]['image'], $languages[$i]['name']) . '</span>';
  714. $input_name .= $lang_img . '&nbsp;'. xtc_draw_input_field('coupon_name[' . $languages[$i]['id'] . ']', $coupon_name[$language_id]) . '&nbsp;<br />';
  715. $input_desc .= $lang_img . '&nbsp;'. xtc_draw_textarea_field('coupon_desc[' . $languages[$i]['id'] . ']','physical','24','3', $coupon_desc[$language_id]) . '&nbsp;<br />';
  716. }
  717. //EOF web28 - 2010-03-11 new table design
  718. //BOF web28 - 2010-03-11 FIX coupon_start_date, coupon_expire_date
  719. if (!$coupon_start_date) {
  720. $coupon_startdate = explode("-", date('Y-m-d')); // Hetfield - 2009-08-18 - replaced deprecated function split with explode to be ready for PHP >= 5.3
  721. } else {
  722. $coupon_startdate = explode("-", $coupon_start_date); // Hetfield - 2009-08-18 - replaced deprecated function split with explode to be ready for PHP >= 5.3
  723. }
  724. if (!$coupon_expire_date) {
  725. $coupon_finishdate = explode("-", date('Y-m-d')); // Hetfield - 2009-08-18 - replaced deprecated function split with explode to be ready for PHP >= 5.3
  726. $coupon_finishdate[0] = $coupon_finishdate[0] + 1;
  727. } else {
  728. $coupon_finishdate = explode("-", $coupon_expire_date); // Hetfield - 2009-08-18 - replaced deprecated function split with explode to be ready for PHP >= 5.3
  729. }
  730. //EOF web28 - 2010-03-11 FIX coupon_start_date, coupon_expire_date
  731. echo xtc_draw_form('coupon', 'coupon_admin.php', 'action=update&oldaction='.$_GET['action'] . '&cid=' . (int)$_GET['cid'],'post', 'enctype="multipart/form-data"');
  732. ?>
  733. <table class="main borderall" border="0" cellspacing="0" cellpadding="6">
  734. <tr>
  735. <td align="left"><?php echo COUPON_NAME; ?></td>
  736. <td align="left"><?php echo $input_name; ?></td>
  737. <td align="left"><?php echo COUPON_NAME_HELP; ?></td>
  738. </tr>
  739. <tr>
  740. <td align="left" valign="top"><?php echo COUPON_DESC; ?></td>
  741. <td align="left" valign="top"><?php echo $input_desc; ?></td>
  742. <td align="left" valign="top"><?php echo COUPON_DESC_HELP; ?></td>
  743. </tr>
  744. <tr>
  745. <td align="left"><?php echo COUPON_AMOUNT; ?></td>
  746. <td align="left"><?php echo xtc_draw_input_field('coupon_amount', $coupon_amount, 'style="width: 150px"'); ?></td>
  747. <td align="left"><?php echo COUPON_AMOUNT_HELP; ?></td>
  748. </tr>
  749. <tr>
  750. <td align="left"><?php echo COUPON_MIN_ORDER; ?></td>
  751. <td align="left"><?php echo xtc_draw_input_field('coupon_min_order', $coupon_min_order, 'style="width: 150px"'); ?></td>
  752. <td align="left"><?php echo COUPON_MIN_ORDER_HELP; ?></td>
  753. </tr>
  754. <tr>
  755. <td align="left"><?php echo COUPON_FREE_SHIP; ?></td>
  756. <td align="left"><?php echo xtc_draw_checkbox_field('coupon_free_ship', $coupon_free_ship); ?></td>
  757. <td align="left"><?php echo COUPON_FREE_SHIP_HELP; ?></td>
  758. </tr>
  759. <tr>
  760. <td align="left"><?php echo COUPON_CODE; ?></td>
  761. <td align="left"><?php echo xtc_draw_input_field('coupon_code', $coupon_code, 'style="width: 150px"'); ?></td>
  762. <td align="left"><?php echo COUPON_CODE_HELP; ?></td>
  763. </tr>
  764. <tr>
  765. <td align="left"><?php echo COUPON_USES_COUPON; ?></td>
  766. <td align="left"><?php echo xtc_draw_input_field('coupon_uses_coupon', $coupon_uses_coupon, 'style="width: 150px"'); ?></td>
  767. <td align="left"><?php echo COUPON_USES_COUPON_HELP; ?></td>
  768. </tr>
  769. <tr>
  770. <td align="left"><?php echo COUPON_USES_USER; ?></td>
  771. <td align="left"><?php echo xtc_draw_input_field('coupon_uses_user', $coupon_uses_user, 'style="width: 150px"'); ?></td>
  772. <td align="left"><?php echo COUPON_USES_USER_HELP; ?></td>
  773. </tr>
  774. <tr>
  775. <td align="left"><?php echo COUPON_PRODUCTS; ?></td>
  776. <?php // BOF - web28 - 2010-11-13 - FIX popup link ?>
  777. <!--td align="left"><?php //echo xtc_draw_input_field('coupon_products', $coupon_products, 'style="width: 150px"'); ?> <A HREF="validproducts.php" TARGET="_blank" ONCLICK="window.open('validproducts.php', 'Valid_Products', 'scrollbars=yes,resizable=yes,menubar=yes,width=600,height=600'); return false">View</A></td-->
  778. <td align="left"><?php echo xtc_draw_input_field('coupon_products', $coupon_products, 'style="width: 150px"'); ?> <a href="<?php echo xtc_href_link('validproducts.php', '' , 'NONSSL');?>" target="_blank" onclick="window.open('validproducts.php', 'Valid_Products', 'scrollbars=yes,resizable=yes,menubar=yes,width=600,height=600'); return false"><?php echo TEXT_VIEW_SHORT;?></a></td>
  779. <?php // EOF - web28 - 2010-11-13 - FIX popup link ?>
  780. <td align="left"><?php echo COUPON_PRODUCTS_HELP; ?></td>
  781. </tr>
  782. <tr>
  783. <td align="left"><?php echo COUPON_CATEGORIES; ?></td>
  784. <?php // BOF - web28 - 2010-11-13 - FIX popup link ?>
  785. <!--td align="left"><?php //echo xtc_draw_input_field('coupon_categories', $coupon_categories, 'style="width: 150px"'); ?> <A HREF="validcategories.php" TARGET="_blank" ONCLICK="window.open('validcategories.php', 'Valid_Categories', 'scrollbars=yes,resizable=yes,menubar=yes,width=600,height=600'); return false">View</A></td-->
  786. <td align="left"><?php echo xtc_draw_input_field('coupon_categories', $coupon_categories, 'style="width: 150px"'); ?> <a href="<?php echo xtc_href_link('validcategories.php', '' , 'NONSSL');?>" target="_blank" onclick="window.open('validcategories.php', 'Valid_Categories', 'scrollbars=yes,resizable=yes,menubar=yes,width=600,height=600'); return false"><?php echo TEXT_VIEW_SHORT;?></a></td>
  787. <?php //EOF - web28 - 2010-11-13 - FIX popup link ?>
  788. <td align="left"><?php echo COUPON_CATEGORIES_HELP; ?></td>
  789. </tr>
  790. <tr>
  791. <td align="left"><?php echo COUPON_STARTDATE; ?></td>
  792. <td align="left" style="white-space:nowrap"><?php echo xtc_draw_date_selector('coupon_startdate', mktime(0,0,0, $coupon_startdate[1], $coupon_startdate[2], $coupon_startdate[0])); ?></td>
  793. <td align="left"><?php echo COUPON_STARTDATE_HELP; ?></td>
  794. </tr>
  795. <tr>
  796. <td align="left"><?php echo COUPON_FINISHDATE; ?></td>
  797. <td align="left" style="white-space:nowrap"><?php echo xtc_draw_date_selector('coupon_finishdate', mktime(0,0,0, $coupon_finishdate[1], $coupon_finishdate[2], $coupon_finishdate[0])); ?></td>
  798. <td align="left"><?php echo COUPON_FINISHDATE_HELP; ?></td>
  799. </tr>
  800. </table>
  801. <?php echo '<input type="submit" class="button" onclick="this.blur();" value="' . BUTTON_PREVIEW . '"/>'; ?>
  802. <?php echo '&nbsp;&nbsp;<a class="button" onclick="this.blur();" href="' . xtc_href_link('coupon_admin.php', '') .'">'. BUTTON_CANCEL . '</a>'; ?>
  803. <?php // EOF - web28 - 2011-03-11 - new table design ?>
  804. </form>
  805. </tr>
  806. </table>
  807. </td>
  808. <?php
  809. break;
  810. default:
  811. ?>
  812. <td class="boxCenter" width="100%" valign="top">
  813. <table border="0" width="100%" cellspacing="0" cellpadding="2">
  814. <tr>
  815. <td width="100%">
  816. <table border="0" width="100%" cellspacing="0" cellpadding="0">
  817. <tr>
  818. <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  819. <td class="main">
  820. <?php echo xtc_draw_form('status', FILENAME_COUPON_ADMIN, '', 'get'); ?>
  821. <?php
  822. $status_array[] = array('id' => 'Y', 'text' => TEXT_COUPON_ACTIVE);
  823. $status_array[] = array('id' => 'N', 'text' => TEXT_COUPON_INACTIVE);
  824. $status_array[] = array('id' => '*', 'text' => TEXT_COUPON_ALL);
  825. if ($_GET['status']) {
  826. $status = xtc_db_prepare_input($_GET['status']);
  827. } else {
  828. $status = 'Y';
  829. }
  830. echo HEADING_TITLE_STATUS . ' ' . xtc_draw_pull_down_menu('status', $status_array, $status, 'onChange="this.form.submit();"');
  831. ?>
  832. </form>
  833. </td>
  834. </tr>
  835. </table>
  836. </td>
  837. </tr>
  838. <tr>
  839. <td>
  840. <a class="button" onclick="this.blur();" href="<?php echo xtc_href_link('coupon_admin.php', 'action=new'); ?>"><?php echo BUTTON_INSERT; ?></a>
  841. <table border="0" width="100%" cellspacing="0" cellpadding="0">
  842. <tr>
  843. <td valign="top">
  844. <?php // BOF - web28 - 2010-07-23 - new table design?>
  845. <table border="0" width="100%" cellspacing="0" cellpadding="2">
  846. <tr class="dataTableHeadingRow">
  847. <td class="dataTableHeadingContent" align="left" width="25"><?php echo COUPON_ID; ?></td>
  848. <td class="dataTableHeadingContent" align="left"><?php echo COUPON_NAME; ?></td>
  849. <td class="dataTableHeadingContent" align="left" width="110"><?php echo COUPON_AMOUNT; ?></td>
  850. <td class="dataTableHeadingContent" align="left" width="110"><?php echo TEXT_COUPON_MINORDER; ?></td>
  851. <td class="dataTableHeadingContent" align="left" width="80"><?php echo COUPON_CODE; ?></td>
  852. <td class="dataTableHeadingContent" align="center" width="70"><?php echo TEXT_COUPON_STATUS; ?></td>
  853. <td class="dataTableHeadingContent" align="center" width="70"><?php echo TEXT_COUPON_DELETE; ?></td>
  854. <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
  855. </tr>
  856. <?php
  857. if ($_GET['page'] > 1) {
  858. $rows = $_GET['page'] * 20 - 20;
  859. }
  860. if ($status != '*') {
  861. $cc_query_raw = "select coupon_id, coupon_code, coupon_amount, coupon_minimum_order, coupon_type, coupon_start_date,coupon_expire_date,uses_per_user,uses_per_coupon,restrict_to_products, restrict_to_categories, coupon_active, date_created,date_modified from " . TABLE_COUPONS ." where coupon_active='" . xtc_db_input($status) . "' and coupon_type != 'G' ORDER BY date_created DESC"; //DokuMan added 'ORDER BY date_created DESC'
  862. } else {
  863. $cc_query_raw = "select coupon_id, coupon_code, coupon_amount, coupon_minimum_order, coupon_type, coupon_start_date,coupon_expire_date,uses_per_user,uses_per_coupon,restrict_to_products, restrict_to_categories, coupon_active, date_created,date_modified from " . TABLE_COUPONS . " where coupon_type != 'G' ORDER BY date_created DESC"; //DokuMan added 'ORDER BY date_created DESC'
  864. }
  865. $cc_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $cc_query_raw, $cc_query_numrows);
  866. $cc_query = xtc_db_query($cc_query_raw);
  867. while ($cc_list = xtc_db_fetch_array($cc_query)) {
  868. $rows++;
  869. …

Large files files are truncated, but you can click here to view the full file