PageRenderTime 24ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/manager/plugins/coupon.php

https://github.com/GansukhB/phtstr
PHP | 306 lines | 280 code | 19 blank | 7 comment | 43 complexity | 078c7b7a67ff62190b684d2ee32a02f9 MD5 | raw file
  1. <?php
  2. /*
  3. Manager Settings Plus 4.7.04
  4. 1 manager user login version
  5. This version includes metatags and other information
  6. */
  7. // OPTIONS
  8. $image_upload = 20; // number of images that can be uploaded per news item / 0 for no files
  9. $image_path = "../uploaded_images/";
  10. $image_caption = 1; // 1 on | 0 off / Allow captions on images
  11. $image_area_name = "";
  12. $file_upload = 20; // number of files that can be uploaded per news item / 0 for no files
  13. $file_path = "../uploaded_files/";
  14. $file_area_name = "";
  15. $file_active = 1; // allow files to be set active/inactive
  16. $copy_link_option = 1; // 1 on | 0 off / Allow image links to be copied
  17. $homepage_option = 1; // 1 on | 0 off
  18. $editor = 1; // 1 on | 0 off
  19. $reference = "coupon"; // used when saving and pulling images or files from/to the database
  20. $actions_page = "actions_coupon.php";
  21. if($execute_nav == 1){
  22. $nav_order = 22; // order of the nav, cant be 0!
  23. $nav_visible = 1; // 1 if you want to see the nav, 0 if its hidden
  24. $nav_name = "Coupons"; // name of the nav that will appear on the page
  25. }
  26. else{
  27. $settings_result = mysql_query("SELECT * FROM settings where id = '1'", $db);
  28. $setting = mysql_fetch_object($settings_result);
  29. $currency_result = mysql_query("SELECT * FROM currency where active = '1'", $db);
  30. $currency = mysql_fetch_object($currency_result);
  31. $mgr_result = mysql_query("SELECT * FROM mgr_users where id = '1'", $db);
  32. $mgr_users = mysql_fetch_object($mgr_result);
  33. ?>
  34. <table width="700" cellpadding="0" cellspacing="0" bgcolor="#577EC4" style="border: 1px solid #5B8BD8;">
  35. <script language="javascript">
  36. var i_status;
  37. var c_status;
  38. var o_status;
  39. function save_coupon_creation() {
  40. var agree=confirm("Are you sure you want to save these settings?");
  41. if (agree) {
  42. <?php
  43. $agent = $_SERVER['HTTP_USER_AGENT'];
  44. if(!eregi("mac", $agent) or $setting->force_mac == 1){
  45. ?>
  46. //document.forms.data_form.onsubmit();
  47. document.getElementById("article").value=oEdit1.getHTMLBody();
  48. <?php } ?>
  49. document.forms.coupon_creation.submit();
  50. }
  51. else {
  52. false
  53. }
  54. }
  55. function delete_data() {
  56. var agree=confirm("Are you sure you would like to delete the selected items?");
  57. if (agree) {
  58. document.coupon.action = "actions_coupon.php?pmode=delete";
  59. document.coupon.submit();
  60. }
  61. else {
  62. false
  63. }
  64. }
  65. function selectAll(formObj, isInverse) {
  66. if(c_status != 1){
  67. for (var i=0;i < formObj.length;i++){
  68. fldObj = formObj.elements[i];
  69. if (fldObj.type == 'checkbox')
  70. {
  71. fldObj.checked = true;
  72. }
  73. }
  74. c_status = 1;
  75. }
  76. else {
  77. for (var i=0;i < formObj.length;i++){
  78. fldObj = formObj.elements[i];
  79. if (fldObj.type == 'checkbox')
  80. {
  81. fldObj.checked = false;
  82. }
  83. }
  84. c_status = 0;
  85. }
  86. }
  87. </script>
  88. <form name="coupon_creation" action="<?PHP echo $actions_page; ?>?pmode=save_coupon_settings" method="post" ENCTYPE="multipart/form-data">
  89. <input type="hidden" value="mgr.php?nav=<? echo $_GET['nav']; ?>&message=saved" name="return">
  90. <tr>
  91. <td bgcolor="#3C6ABB" align="center" style="padding: 4px; border-bottom: 1px solid #355894;">
  92. <table cellpadding="0" cellspacing="0" width="95%">
  93. <tr>
  94. <td width="100%" nowrap><font face="arial" color="#ffffff" style="font-size: 11;"><b>COUPON | SAVINGS CODE</b></font>
  95. <? if($_GET['message'] == "deleted"){ ?>
  96. <td align="right" valign="bottom">
  97. <img src="images/mgr_check2_loop_3.gif" valign="absmiddle">
  98. </td>
  99. <td align="right" valign="middle" nowrap>
  100. <font color="#FFE400" style="font-size: 10;">&nbsp;The selected coupons have been deleted.
  101. </td>
  102. <? } ?>
  103. <? if($_GET['message'] == "saved"){ ?>
  104. <td align="right" valign="bottom">
  105. <img src="images/mgr_check2_loop_3.gif" valign="absmiddle">
  106. </td>
  107. <td align="right" valign="middle" nowrap>
  108. <font color="#FFE400" style="font-size: 10;">&nbsp;The coupon has been created.
  109. </td>
  110. <? } ?>
  111. </tr>
  112. </table>
  113. </td>
  114. </tr>
  115. <tr>
  116. <td bgcolor="#577EC4" align="center" style="padding-top: 10px; padding-bottom: 10px;" background="images/mgr_bg_texture.gif">
  117. <table width="95%" cellpadding="0" cellspacing="0">
  118. <tr>
  119. <td>
  120. <table cellpadding="0" cellspacing="0" width="100%">
  121. <tr>
  122. <td align="left"><img src="images/mgr_section_header_l.gif"></td>
  123. <td width="100%" background="images/mgr_section_header_bg.gif" align="center" valign="middle"><b>ADD NEW COUPON | SAVINGS CODE</b></td>
  124. <td align="right"><img src="images/mgr_section_header_r.gif"></td>
  125. </tr>
  126. </table>
  127. </td>
  128. </tr>
  129. <tr>
  130. <td bgcolor="#5E85CA" class="data_box"><font color="#ffffff" style="font-size: 11;"><b>Coupon | Savings Code types:</b><br>(Check one type and enter the data for that type. Do not check more than one type! Create one at a time.)<br><hr width="90%">
  131. <b>1. Select a type of coupon you would like to create</b><br>
  132. <font color="#ffffff" style="font-size: 11;"><input name="type" type="radio" value="2"> <b>Percentage Off</b><br>(Percentage off on total of the cart.)<br>
  133. <font color="#ffffff" style="font-size: 11;"><input name="type" type="radio" value="3"> <b>Dollar Amount Off</b><br>(Dollar amount off on total of the cart.)<br>
  134. <font color="#ffffff" style="font-size: 11;"><input name="type" type="radio" value="5"> <b>Tax Exempt</b><br>(Remove tax from overall total in cart.<b> Skip section 2</b>)<br>
  135. <font color="#ffffff" style="font-size: 11;"><input name="type" type="radio" value="1"> <b>Free Shipping</b><br>(Give free shipping to anyone that types this code in during checkout.<b> Skip section 2</b>)<br>
  136. <hr width="90%">
  137. <b>2. Enter Data</b> (depending on type of coupon you selected)<br>
  138. <input type="text" name="percent" style="font-size: 10; font-weight: bold; width: 100; border: 1px solid #000000;" maxlength="300">% <b>Percent Amount</b><br>(Example: 10 | This is for the percentage off coupon)<br>
  139. <b>--OR--</b><br>
  140. <input type="text" name="amount" style="font-size: 10; font-weight: bold; width: 100; border: 1px solid #000000;" maxlength="300">$ <b>Dollar Amount</b><br>(Example: 10 | This is for the dollar amount off coupon)<br>
  141. <hr width="90%">
  142. <b>3. Enter Expire Data</b> (Can be either a date or amount of times it is used)<br>
  143. <input type="text" name="expire" style="font-size: 10; font-weight: bold; width: 100; border: 1px solid #000000;" maxlength="300"> <b>Expire Date</b><br>(Example: mm/dd/yyyy | On what day will this coupon expire <b>OR</b> you can enter a quantity below)<br>
  144. <b>--OR--</b><br>
  145. <input type="text" name="quantity" style="font-size: 10; font-weight: bold; width: 100; border: 1px solid #000000;" maxlength="300"> <b>Quantity</b><br>(Example: 100 | How many do you want to issue <b>OR</b> you can enter a date it will expire above)<br>
  146. <hr width="90%">
  147. <b>4. Enter Code</b> (This is the code the customer will use to validate a coupon during checkout)<br>(You CAN NOT use these characters in the promo code: /"\|][;:)(*^%$#@<>)<br>
  148. <input type="text" name="code" style="font-size: 10; font-weight: bold; width: 100; border: 1px solid #000000;" maxlength="300"> <b>Code</b><br>(Example: 01ag8xe | This is the code used by the customer to activate the coupon)<br><hr width="90%">
  149. </tr>
  150. <tr>
  151. <td bgcolor="#5E85CA" class="data_box">
  152. <input type="checkbox" name="display" value="1"><font face="arial" color="#ffffff" style="font-size: 11;"><b>Display this coupon on the cart page:</b> (If you check this, the data in the content field below will show on the cart page, try to keep it short and simple.)<br>
  153. </td>
  154. </tr>
  155. <? if($setting->editor == 1 and $editor == 1){ ?>
  156. <tr>
  157. <td bgcolor="#5E85CA" class="data_box"><b>Content:</b><br><? $sContent = $ca->article; ?>
  158. <?php
  159. $agent = $_SERVER['HTTP_USER_AGENT'];
  160. if(eregi("mac", $agent) && $setting->force_mac == 0){
  161. ?>
  162. <textarea name="article" id="article" rows=8 cols=30 style="width: 100%"><?php echo $sContent; ?></textarea>
  163. <?php
  164. } else {
  165. ?>
  166. <script language=JavaScript src='./scripts/innovaeditor.js'></script>
  167. <textarea name="article" id="article" rows=4 cols=30>
  168. <?
  169. function encodeHTML($sHTML)
  170. {
  171. $sHTML=ereg_replace("&","&amp;",$sHTML);
  172. $sHTML=ereg_replace("<","&lt;",$sHTML);
  173. $sHTML=ereg_replace(">","&gt;",$sHTML);
  174. return $sHTML;
  175. }
  176. if(isset($sContent)) echo encodeHTML($sContent);
  177. ?>
  178. </textarea>
  179. <script>
  180. var oEdit1 = new InnovaEditor("oEdit1");
  181. oEdit1.initialRefresh=true;
  182. oEdit1.REPLACE("article");
  183. </script>
  184. <?php
  185. }
  186. ?>
  187. </td>
  188. </tr>
  189. <? } else { ?>
  190. <tr>
  191. <td bgcolor="#5E85CA" class="data_box">
  192. <b>Copy</b><br>
  193. <textarea name="article" id="text_box" style="width:100%; height:200; border: 1px solid #000000;" rows="1" cols="20"><? echo $ca->article; ?></textarea>
  194. <p align="right"><a href="#" onclick="window.open('<? echo $setting->help_tips_link; ?>help_tips.php?pmode=html_tags', 'tips_win', ['HEIGHT=500', 'WIDTH=600', 'scrollbars=yes', 'dependent']);" class="edit_links">HTML Tips</a>
  195. </td>
  196. </tr>
  197. <? } ?>
  198. <tr>
  199. <td align="right"><? echo "<a href=\"javascript:save_coupon_creation();\">"; ?><img src="images/mgr_button_save.gif" border="0"></a></td>
  200. </tr>
  201. </form>
  202. <tr><td height="10">&nbsp;</td></tr>
  203. <tr>
  204. <td>
  205. <table cellpadding="0" cellspacing="0" width="100%">
  206. <tr>
  207. <td align="left"><img src="images/mgr_section_header_l.gif"></td>
  208. <td width="100%" background="images/mgr_section_header_bg.gif" align="center" valign="middle"><b>STATISTICS</b></td>
  209. <td align="right"><img src="images/mgr_section_header_r.gif"></td>
  210. </tr>
  211. </table>
  212. </td>
  213. </tr>
  214. <?
  215. $coupon_result = mysql_query("SELECT * FROM coupon order by id desc", $db);
  216. $coupon_num_row = mysql_num_rows($coupon_result);
  217. ?>
  218. <tr>
  219. <td bgcolor="#5E85CA" class="data_box"><font color="#ffffff" style="font-size: 11;"><b>Coupons:</b> <? echo $download_num_rows; ?></td>
  220. </tr>
  221. <table width="95%" border="1" bordercolordark="#89A6DB" bordercolorlight="#5078BF">
  222. <tr>
  223. <form name="coupon" method="post">
  224. <input type="hidden" value="mgr.php?nav=<? echo $_GET['nav']; ?>&message=deleted&order_by=<? echo $_GET['order_by']; ?>&order_type=<? echo $_GET['order_type']; ?>&search=<? echo $_GET['search']; ?>" name="return">
  225. <td align="Center" bgcolor="#89A6DB"><b>ID</b></td>
  226. <td align="center" bgcolor="#89A6DB"><b>Code</b></td>
  227. <td align="center" bgcolor="#89A6DB"><b>Type</b></td>
  228. <td align="center" bgcolor="#89A6DB"><b>Amount</b></td>
  229. <td align="center" bgcolor="#89A6DB"><b>Percentage</b></td>
  230. <td align="center" bgcolor="#89A6DB"><b>Expire</b></td>
  231. <td align="center" bgcolor="#89A6DB"><b>Quantity</b></td>
  232. <td align="center" bgcolor="#89A6DB"><b>Used</b></td>
  233. <td align="center" bgcolor="#89A6DB"><b>Delete</b></td>
  234. </tr>
  235. <?
  236. while($coupon = mysql_fetch_object($coupon_result)){
  237. ?>
  238. <tr>
  239. <td align="Center" bgcolor="#89A6DB"><b><? echo $coupon->id; ?></b></td>
  240. <td align="center" bgcolor="#89A6DB"><b><? echo $coupon->code; ?></b></td>
  241. <?
  242. if($coupon->type == "1"){
  243. $type_is = "Free Shipping";
  244. }
  245. if($coupon->type == "2"){
  246. $type_is = "Percent Off";
  247. }
  248. if($coupon->type == "3"){
  249. $type_is = "Dollar Off";
  250. }
  251. if($coupon->type == "4"){
  252. $type_is = "Free Items";
  253. }
  254. if($coupon->type == "5"){
  255. $type_is = "Tax Exempt";
  256. }
  257. ?>
  258. <td align="center" bgcolor="#89A6DB"><b><? echo $type_is; ?></b></td>
  259. <td align="center" bgcolor="#89A6DB"><b><? echo $currency->sign; ?><? echo dollar($coupon->amount); ?></b></td>
  260. <td align="center" bgcolor="#89A6DB"><b><? echo $coupon->percent; ?>%</b></td>
  261. <td align="center" bgcolor="#89A6DB"><b><? if($coupon->expire != ""){ ?><? echo $coupon->expire; ?><? } else { echo "-----"; } ?></b></td>
  262. <td align="center" bgcolor="#89A6DB"><b><? echo $coupon->quantity; ?></b></td>
  263. <td align="center" bgcolor="#89A6DB"><b><? if($coupon->used != ""){ ?><? echo $coupon->used; ?><? } else { echo "0"; } ?></b></td>
  264. <td align="center" bgcolor="#89A6DB"><input name="<? echo $coupon->id; ?>" type="checkbox" value="1"></td>
  265. </tr>
  266. <? } ?>
  267. </table>
  268. <table width="95%">
  269. <tr>
  270. <td align="right"><a href="javascript:selectAll(document.coupon,0);"><img src="images/mgr_button_select_all.gif" border="0"></a>&nbsp;<? if($access_type == "demo"){ echo "<a href=\"javascript:demo_mode();\">"; } else { echo "<a href=\"javascript:delete_data();\">"; } ?><img src="images/mgr_button_delete_sel.gif" border="0"></a></td>
  271. </form>
  272. </tr>
  273. </table>
  274. </td>
  275. </tr>
  276. <!--
  277. <tr>
  278. <td bgcolor="#5E85CA" style="border-top: 1px solid #6F97DE;border-bottom: 1px solid #476DB0;"><br><br><br><br><br></td>
  279. </tr>
  280. <tr>
  281. <td bgcolor="#577EC4" style="border-bottom: 1px solid #476DB0;border-top: 1px solid #6F97DE;"><br><br><br><br><br></td>
  282. </tr>
  283. -->
  284. </table>
  285. <?
  286. }
  287. ?>