PageRenderTime 36ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/popup_coupon_help.php

https://bitbucket.org/flth/xtcm
PHP | 89 lines | 62 code | 11 blank | 16 comment | 11 complexity | 7cadb0ab132023400e06deeecbd307a6 MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. /* -----------------------------------------------------------------------------------------
  3. $Id: popup_coupon_help.php 1313 2005-10-18 15:49:15Z mz $
  4. XT-Commerce - community made shopping
  5. http://www.xt-commerce.com
  6. Copyright (c) 2003 XT-Commerce
  7. -----------------------------------------------------------------------------------------
  8. based on:
  9. (c) 2000-2001 The Exchange Project (earlier name of osCommerce)
  10. (c) 2002-2003 osCommerce(popup_coupon_help.php,v 1.1.2.5 2003/05/02); www.oscommerce.com
  11. Released under the GNU General Public License
  12. ---------------------------------------------------------------------------------------*/
  13. require ('includes/application_top.php');
  14. require_once (DIR_FS_INC.'xtc_date_short.inc.php');
  15. $smarty = new Smarty;
  16. include ('includes/header.php');
  17. $coupon_query = xtc_db_query("select * from ".TABLE_COUPONS." where coupon_id = '".(int)$_GET['cID']."'");
  18. $coupon = xtc_db_fetch_array($coupon_query);
  19. $coupon_desc_query = xtc_db_query("select * from ".TABLE_COUPONS_DESCRIPTION." where coupon_id = '".(int)$_GET['cID']."' and language_id = '".$_SESSION['languages_id']."'");
  20. $coupon_desc = xtc_db_fetch_array($coupon_desc_query);
  21. $text_coupon_help = TEXT_COUPON_HELP_HEADER;
  22. $text_coupon_help .= sprintf(TEXT_COUPON_HELP_NAME, $coupon_desc['coupon_name']);
  23. if (xtc_not_null($coupon_desc['coupon_description']))
  24. $text_coupon_help .= sprintf(TEXT_COUPON_HELP_DESC, $coupon_desc['coupon_description']);
  25. $coupon_amount = $coupon['coupon_amount'];
  26. switch ($coupon['coupon_type']) {
  27. case 'F' :
  28. $text_coupon_help .= sprintf(TEXT_COUPON_HELP_FIXED, $xtPrice->xtcFormat($coupon['coupon_amount'], true));
  29. break;
  30. case 'P' :
  31. $text_coupon_help .= sprintf(TEXT_COUPON_HELP_FIXED, number_format($coupon['coupon_amount'], 2).'%');
  32. break;
  33. case 'S' :
  34. $text_coupon_help .= TEXT_COUPON_HELP_FREESHIP;
  35. break;
  36. default :
  37. }
  38. if ($coupon['coupon_minimum_order'] > 0)
  39. $text_coupon_help .= sprintf(TEXT_COUPON_HELP_MINORDER, $xtPrice->xtcFormat($coupon['coupon_minimum_order'], true));
  40. $text_coupon_help .= sprintf(TEXT_COUPON_HELP_DATE, xtc_date_short($coupon['coupon_start_date']), xtc_date_short($coupon['coupon_expire_date']));
  41. $text_coupon_help .= '<strong>'.TEXT_COUPON_HELP_RESTRICT.'</strong>';
  42. $text_coupon_help .= '<br /><br />'.TEXT_COUPON_HELP_CATEGORIES;
  43. $coupon_get = xtc_db_query("select restrict_to_categories from ".TABLE_COUPONS." where coupon_id='".(int)$_GET['cID']."'");
  44. $get_result = xtc_db_fetch_array($coupon_get);
  45. $cat_ids = explode(",", $get_result['restrict_to_categories']); // Hetfield - 2009-08-18 - replaced deprecated function split with explode to be ready for PHP >= 5.3
  46. for ($i = 0; $i < count($cat_ids); $i ++) {
  47. $result = xtc_db_query("SELECT * FROM ".TABLE_CATEGORIES." c, ".TABLE_CATEGORIES_DESCRIPTION." cd WHERE c.categories_id = cd.categories_id and cd.language_id = '".$_SESSION['languages_id']."' and c.categories_id='".$cat_ids[$i]."'");
  48. if ($row = xtc_db_fetch_array($result)) {
  49. $cats .= '<br />'.$row["categories_name"];
  50. }
  51. }
  52. if ($cats == '')
  53. $cats = '<br />NONE';
  54. $text_coupon_help .= $cats;
  55. $text_coupon_help .= '<br /><br />'.TEXT_COUPON_HELP_PRODUCTS;
  56. $coupon_get = xtc_db_query("select restrict_to_products from ".TABLE_COUPONS." where coupon_id='".(int)$_GET['cID']."'");
  57. $get_result = xtc_db_fetch_array($coupon_get);
  58. $pr_ids = explode(",", $get_result['restrict_to_products']); // Hetfield - 2009-08-18 - replaced deprecated function split with explode to be ready for PHP >= 5.3
  59. for ($i = 0; $i < count($pr_ids); $i ++) {
  60. $result = xtc_db_query("SELECT * FROM ".TABLE_PRODUCTS." p, ".TABLE_PRODUCTS_DESCRIPTION." pd WHERE p.products_id = pd.products_id and pd.language_id = '".$_SESSION['languages_id']."'and p.products_id = '".$pr_ids[$i]."'");
  61. if ($row = xtc_db_fetch_array($result)) {
  62. $prods .= '<br />'.$row["products_name"];
  63. }
  64. }
  65. if ($prods == '')
  66. $prods = '<br />NONE';
  67. $text_coupon_help .= $prods;
  68. $smarty->assign('TEXT_HELP', $text_coupon_help);
  69. $smarty->assign('link_close', 'javascript:window.close()');
  70. $smarty->assign('language', $_SESSION['language']);
  71. $smarty->caching = 0;
  72. $smarty->display(CURRENT_TEMPLATE.'/module/popup_coupon_help.html');
  73. //include ('includes/application_bottom.php');
  74. ?>