PageRenderTime 72ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 1ms

/application/views/pages/admin/discounts.php

https://bitbucket.org/chadsaun/ifrogz-panel
PHP | 1627 lines | 1506 code | 36 blank | 85 comment | 306 complexity | ea6f168c0ca5b268ebb1e86e894997b0 MD5 | raw file

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

  1. <?php
  2. //This code is copyright (c) Internet Business Solutions SL, all rights reserved.
  3. //The contents of this file are protect under law as the intellectual property of Internet
  4. //Business Solutions SL. Any use, reproduction, disclosure or copying of any kind
  5. //without the express and written permission of Internet Business Solutions SL is forbidden.
  6. //Author: Vince Reid, vince@virtualred.net
  7. if(@$storesessionvalue=="") $storesessionvalue="virtualstore".time();
  8. if($_SESSION["loggedon"] != $storesessionvalue || @$disallowlogin==TRUE) exit();
  9. $success=TRUE;
  10. $sSQL = "";
  11. $alreadygotadmin = getadminsettings();
  12. if (@$_POST["posted"]=="1") {
  13. if (@$_POST["act"]=="delete") {
  14. $sSQL = "DELETE FROM cpnassign WHERE cpaCpnID=" . @$_POST["id"];
  15. mysql_query($sSQL) or print(mysql_error());
  16. $sSQL = "DELETE FROM coupons WHERE cpnID=" . @$_POST["id"];
  17. mysql_query($sSQL) or print(mysql_error());
  18. print '<meta http-equiv="refresh" content="3; url=/admin/discounts.php">';
  19. }
  20. else if (@$_POST["act"]=="deleteGrp") {
  21. $sql = "DELETE FROM grpCpn WHERE grpCpnID = ". @$_POST["id"];
  22. mysql_query($sql) or print(mysql_error());
  23. $sql = "SELECT * FROM coupons WHERE cpnGrpCpnID = '".@$_POST["id"]."'";
  24. $res = mysql_query($sql) or print(mysql_error());
  25. $coupons = '';
  26. if(mysql_num_rows($res) > 0) {
  27. for($i=0; $row = mysql_fetch_assoc($res); $i++) {
  28. $coupons .= $row['cpnID'];
  29. if($i+1!=mysql_num_rows($res)) {
  30. $coupons .= ",";
  31. }
  32. }
  33. }
  34. $sql = "DELETE FROM coupons WHERE cpnGrpCpnID = '".@$_POST["id"]."'";
  35. mysql_query($sql) or print(mysql_error());
  36. $sql = "DELETE FROM cpnassign WHERE cpaCpnID IN($coupons)";
  37. mysql_query($sql) or print(mysql_error());
  38. print '<meta http-equiv="refresh" content="3; url=/admin/discounts.php">';
  39. }
  40. else if (@$_POST["act"]=="domodify") {
  41. // Creates lock
  42. $lSQL = 'LOCK TABLES coupons WRITE, fsadiscount WRITE;';
  43. mysql_query($lSQL) or print(mysql_error().'<br />'.$lSQL);
  44. // Updates coupon
  45. $sSQL = "UPDATE coupons SET cpnName='" . mysql_real_escape_string(unstripslashes(@$_POST["cpnName"])) . "'";
  46. for($index=2; $index <= $adminlanguages+1; $index++){
  47. if(($adminlangsettings & 1024)==1024) $sSQL .= ",cpnName" . $index . "='" . mysql_real_escape_string(unstripslashes(@$_POST["cpnName" . $index])) . "'";
  48. }
  49. if(trim(@$_POST["cpnWorkingName"]) != "")
  50. $sSQL .= ",cpnWorkingName='" . mysql_real_escape_string(unstripslashes(@$_POST["cpnWorkingName"])) . "'";
  51. else
  52. $sSQL .= ",cpnWorkingName='" . mysql_real_escape_string(unstripslashes(@$_POST["cpnName"])) . "'";
  53. if(@$_POST["cpnIsCoupon"]=="0")
  54. $sSQL .= ",cpnNumber='',";
  55. else
  56. $sSQL .= ",cpnNumber='" . mysql_real_escape_string(unstripslashes(@$_POST["cpnNumber"])) . "',";
  57. $sSQL .= "cpnType=" . @$_POST["cpnType"] . ",";
  58. /*$numdays=0;
  59. if(is_numeric(@$_POST["cpnEndDate"])) $numdays = (int)@$_POST["cpnEndDate"];
  60. if($numdays > 0)
  61. $sSQL .= "cpnEndDate='" . date("Y-m-d",(time() + ($numdays*60*60*24))) . "',";
  62. else
  63. $sSQL .= "cpnEndDate='3000-01-01',";*/
  64. if (!empty($_POST["cpnEndDate"])) {
  65. $sSQL .= "cpnEndDate='" . $_POST["cpnEndDate"] . "',";
  66. } else {
  67. $sSQL .= "cpnEndDate='3000-01-01',";
  68. }
  69. if (!empty($_POST["cpnBeginDate"])) {
  70. $sSQL .= "cpnBeginDate='" . $_POST["cpnBeginDate"] . "',";
  71. } else {
  72. $sSQL .= "cpnBeginDate='0000-00-00 00:00:00',";
  73. }
  74. if(is_numeric(@$_POST["cpnDiscount"]) && @$_POST["cpnType"] != "0")
  75. $sSQL .= "cpnDiscount=" . @$_POST["cpnDiscount"] . ",";
  76. else
  77. $sSQL .= "cpnDiscount=0,";
  78. if(is_numeric(@$_POST["cpnThreshold"]))
  79. $sSQL .= "cpnThreshold=" . @$_POST["cpnThreshold"] . ",";
  80. else
  81. $sSQL .= "cpnThreshold=0,";
  82. if(is_numeric(@$_POST["cpnThresholdMax"]))
  83. $sSQL .= "cpnThresholdMax=" . @$_POST["cpnThresholdMax"] . ",";
  84. else
  85. $sSQL .= "cpnThresholdMax=0,";
  86. if(is_numeric(@$_POST["cpnThresholdRepeat"]))
  87. $sSQL .= "cpnThresholdRepeat=" . @$_POST["cpnThresholdRepeat"] . ",";
  88. else
  89. $sSQL .= "cpnThresholdRepeat=0,";
  90. if(is_numeric(@$_POST["cpnQuantity"]))
  91. $sSQL .= "cpnQuantity=" . @$_POST["cpnQuantity"] . ",";
  92. else
  93. $sSQL .= "cpnQuantity=0,";
  94. if(is_numeric(@$_POST["cpnQuantityMax"]))
  95. $sSQL .= "cpnQuantityMax=" . @$_POST["cpnQuantityMax"] . ",";
  96. else
  97. $sSQL .= "cpnQuantityMax=0,";
  98. if(is_numeric(@$_POST["cpnQuantityRepeat"]))
  99. $sSQL .= "cpnQuantityRepeat=" . @$_POST["cpnQuantityRepeat"] . ",";
  100. else
  101. $sSQL .= "cpnQuantityRepeat=0,";
  102. if(trim(@$_POST["cpnNumAvail"]) != "" && is_numeric(@$_POST["cpnNumAvail"]))
  103. $sSQL .= "cpnNumAvail=" . @$_POST["cpnNumAvail"] . ",";
  104. else
  105. $sSQL .= "cpnNumAvail=30000000,";
  106. if(@$_POST["cpnType"]=="0")
  107. $sSQL .= "cpnCntry=" . @$_POST["cpnCntry"] . ",";
  108. else
  109. $sSQL .= "cpnCntry=0,";
  110. $sSQL .= "cpnIsCoupon=" . @$_POST["cpnIsCoupon"] . ",";
  111. if(@$_POST["cpnType"]=="0")
  112. $sSQL .= "cpnSitewide=1,";
  113. else
  114. $sSQL .= "cpnSitewide=" . @$_POST["cpnSitewide"]. ",";
  115. //wholesale only coupon added by Blake 6-6-06
  116. if(@$_POST["cpnIsWholesale"]=="")
  117. $sSQL .= "cpnIsWholesale = 0,";
  118. else
  119. $sSQL .= "cpnIsWholesale = " . @$_POST["cpnIsWholesale"] . ",";
  120. //
  121. if ($_POST["cpnStackable"] == "") {
  122. $sSQL .= "cpnStackable = 0";
  123. } else {
  124. $sSQL .= "cpnStackable = " . $_POST["cpnStackable"];
  125. }
  126. $sSQL .= " WHERE cpnID=" . @$_POST["id"];
  127. mysql_query($sSQL) or print(mysql_error().$sSQL);
  128. $cpnID = @$_POST["id"];
  129. if ($_POST['cpnType'] == 0) {
  130. $sSQL = "SELECT * FROM fsadiscount WHERE cpnID = {$cpnID};";
  131. $result = mysql_query($sSQL) or print(mysql_error().$sSQL);
  132. $buffer = array();
  133. while ($record = mysql_fetch_assoc($result)) {
  134. $buffer[] = $record;
  135. }
  136. mysql_free_result($result);
  137. if (isset($_POST['pz'])) {
  138. foreach ($_POST['pz'] as $pz) {
  139. $data = explode(',', $pz); // 0 = pzID, 1 = methodID
  140. $doInsert = TRUE;
  141. foreach ($buffer as &$record) {
  142. if (($data[0] == $record['pzID']) && ($data[1] == $record['methodID'])) {
  143. $record = NULL;
  144. $doInsert = FALSE;
  145. break;
  146. }
  147. }
  148. unset($record);
  149. if ($doInsert) {
  150. $iSQL = "INSERT INTO fsadiscount (cpnID, pzID, methodID) VALUES ({$cpnID}, {$data[0]}, {$data[1]});";
  151. mysql_query($iSQL) or print(mysql_error().'<br />'.$iSQL);
  152. }
  153. }
  154. }
  155. foreach ($buffer as $record) {
  156. if ($record != NULL) {
  157. $dSQL = "DELETE FROM fsadiscount WHERE ID = {$record['ID']};";
  158. mysql_query($dSQL) or print(mysql_error().'<br />'.$dSQL);
  159. }
  160. }
  161. }
  162. $uSQL = 'UNLOCK TABLES;';
  163. mysql_query($uSQL) or print(mysql_error().'<br />'.$uSQL);
  164. print '<meta http-equiv="refresh" content="3; url=/admin/discounts.php">';
  165. }
  166. else if (@$_POST["act"]=="doaddnew") {
  167. if (!empty($_POST['cpnIsGrp'])) {
  168. /*
  169. // Creates lock
  170. $lSQL = 'LOCK TABLES coupons WRITE, fsadiscount WRITE;';
  171. mysql_query($lSQL) or print(mysql_error().'<br />'.$lSQL);
  172. // Inserts new coupon
  173. */
  174. $qty = $_POST['grpQty'];
  175. if ($_POST['linkGrp']!="none") {
  176. $sql_orig_grp = "SELECT * FROM coupons WHERE cpnGrpCpnID = ".$_POST['linkGrp'];
  177. $res_orig_grp = mysql_query($sql_orig_grp) or print(mysql_error());
  178. $qty = mysql_num_rows($res_orig_grp);
  179. }
  180. $sql = "INSERT INTO grpCpn (grpCpnName, grpCpnQty";
  181. if ($_POST['linkGrp']!="none") {
  182. $sql .= ",grpCpnLinkID)";
  183. }
  184. else{
  185. $sql .= ") ";
  186. }
  187. $sql .= "VALUES ('".$_POST['grpName']."',".$qty;
  188. if($_POST['linkGrp']!="none") {
  189. $sql .= ",".$_POST['linkGrp'].")";
  190. }
  191. else{
  192. $sql .= ")";
  193. }
  194. $res = mysql_query($sql) or die(mysql_error());
  195. $lastID = mysql_insert_id();
  196. for($i=0; $i<$qty; $i++) {
  197. if($_POST['linkGrp']!="none") {
  198. $row_orig_grp = mysql_fetch_assoc($res_orig_grp);
  199. $promoCode = $row_orig_grp['cpnNumber'];
  200. $cpnEnd = $row_orig_grp['cpnEndDate'];
  201. $cpnBegin = $row_orig_grp['cpnBeginDate'];
  202. }else{
  203. $promoCode = getPromoCode();
  204. $cpnEnd = @$_POST["cpnEndDate"];
  205. $cpnBegin = @$_POST["cpnBeginDate"];
  206. }
  207. $sSQL = "INSERT INTO coupons (cpnName";
  208. for($index=2; $index <= $adminlanguages+1; $index++){
  209. if(($adminlangsettings & 1024)==1024) $sSQL .= ",cpnName" . $index;
  210. }
  211. $sSQL .= ",cpnWorkingName,cpnNumber,cpnType,cpnEndDate,cpnDiscount,cpnThreshold,cpnThresholdMax,cpnThresholdRepeat,cpnQuantity,cpnQuantityMax,cpnQuantityRepeat,cpnNumAvail,cpnCntry,cpnIsCoupon,cpnSitewide,cpnIsWholesale,cpnGrpCpnID,cpnBeginDate, cpnStackable) VALUES (";
  212. $sSQL .= "'" . mysql_real_escape_string(unstripslashes(@$_POST["cpnName"])) . "',";
  213. for($index=2; $index <= $adminlanguages+1; $index++){
  214. if(($adminlangsettings & 1024)==1024) $sSQL .= "'" . mysql_real_escape_string(unstripslashes(@$_POST["cpnName" . $index])) . "',";
  215. }
  216. if(trim(@$_POST["cpnWorkingName"]) != "")
  217. $sSQL .= "'" . mysql_real_escape_string(unstripslashes(@$_POST["cpnWorkingName"])) . "',";
  218. else
  219. $sSQL .= "'" . mysql_real_escape_string(unstripslashes(@$_POST["cpnName"])) . "',";
  220. if(@$_POST["cpnIsCoupon"]=="0")
  221. $sSQL .= "'',";
  222. else
  223. $sSQL .= "'" . mysql_real_escape_string($promoCode) . "',";
  224. $sSQL .= @$_POST["cpnType"] . ",";
  225. /*$numdays=0;
  226. if(is_numeric($cpnEnd) && $_POST['linkGrp']=="none") $numdays = (int)$cpnEnd;
  227. if($numdays > 0 && $_POST['linkGrp']=="none")
  228. $sSQL .= "'" . date("Y-m-d",(time() + ($numdays*60*60*24))) . "',";
  229. elseif($_POST['linkGrp']!="none")
  230. $sSQL .= "'".$cpnEnd."',";
  231. else
  232. $sSQL .= "'3000-01-01',";*/
  233. if (!empty($cpnEnd)) {
  234. $sSQL .= "'" . $cpnEnd . "',";
  235. } else {
  236. $sSQL .= "'3000-01-01 00:00:00',";
  237. }
  238. if(is_numeric(@$_POST["cpnDiscount"]) && @$_POST["cpnType"] != "0")
  239. $sSQL .= @$_POST["cpnDiscount"] . ",";
  240. else
  241. $sSQL .= "0,";
  242. if(is_numeric(@$_POST["cpnThreshold"]))
  243. $sSQL .= @$_POST["cpnThreshold"] . ",";
  244. else
  245. $sSQL .= "0,";
  246. if(is_numeric(@$_POST["cpnThresholdMax"]))
  247. $sSQL .= @$_POST["cpnThresholdMax"] . ",";
  248. else
  249. $sSQL .= "0,";
  250. if(is_numeric(@$_POST["cpnThresholdRepeat"]))
  251. $sSQL .= @$_POST["cpnThresholdRepeat"] . ",";
  252. else
  253. $sSQL .= "0,";
  254. if(is_numeric(@$_POST["cpnQuantity"]))
  255. $sSQL .= @$_POST["cpnQuantity"] . ",";
  256. else
  257. $sSQL .= "0,";
  258. if(is_numeric(@$_POST["cpnQuantityMax"]))
  259. $sSQL .= @$_POST["cpnQuantityMax"] . ",";
  260. else
  261. $sSQL .= "0,";
  262. if(is_numeric(@$_POST["cpnQuantityRepeat"]))
  263. $sSQL .= @$_POST["cpnQuantityRepeat"] . ",";
  264. else
  265. $sSQL .= "0,";
  266. if(trim(@$_POST["cpnNumAvail"]) != "" && is_numeric(@$_POST["cpnNumAvail"]))
  267. $sSQL .= @$_POST["cpnNumAvail"] . ",";
  268. else
  269. $sSQL .= "30000000,";
  270. if(@$_POST["cpnType"]=="0")
  271. $sSQL .= @$_POST["cpnCntry"] . ",";
  272. else
  273. $sSQL .= "0,";
  274. $sSQL .= @$_POST["cpnIsCoupon"] . ",";
  275. if(@$_POST["cpnType"]=="0")
  276. $sSQL .= "1,";
  277. else
  278. $sSQL .= @$_POST["cpnSitewide"] . ",";
  279. //wholesale only coupon added by Blake 6-6-06
  280. if(@$_POST["cpnIsWholesale"]=="")
  281. $sSQL .= "0,";
  282. else
  283. $sSQL .= @$_POST["cpnIsWholesale"] . ",";
  284. //
  285. $sSQL .= "'" .$lastID . "',";
  286. if (!empty($cpnBegin)) {
  287. $sSQL .= "'" . $cpnBegin . "',";
  288. } else {
  289. $sSQL .= "'0000-00-00 00:00:00',";
  290. }
  291. if ($_POST["cpnStackable"] == "") {
  292. $sSQL .= "0)";
  293. } else {
  294. $sSQL .= $_POST["cpnStackable"] . ")";
  295. }
  296. mysql_query($sSQL) or print(mysql_error());
  297. /*
  298. $cpnID = mysql_insert_id();
  299. if (($_POST['cpnType'] == 0) && isset($_POST['pz']) && (count($_POST['pz']) > 0)) {
  300. foreach ($_POST['pz'] as $pz) {
  301. $data = explode(',', $pz); // 0 = pzID, 1 = methodID
  302. $iSQL = "INSERT INTO fsadiscount (cpnID, pzID, methodID) VALUES ({$cpnID}, {$data[0]}, {$data[1]});";
  303. mysql_query($iSQL) or print(mysql_error().'<br />'.$iSQL);
  304. }
  305. }
  306. $uSQL = 'UNLOCK TABLES;';
  307. mysql_query($uSQL) or print(mysql_error().'<br />'.$uSQL);
  308. */
  309. }
  310. }
  311. else { // doaddnew: non-group
  312. // Creates lock
  313. $lSQL = 'LOCK TABLES coupons WRITE, fsadiscount WRITE;';
  314. mysql_query($lSQL) or print(mysql_error().'<br />'.$lSQL);
  315. // Inserts new coupon
  316. $sSQL = "INSERT INTO coupons (cpnName";
  317. for($index=2; $index <= $adminlanguages+1; $index++){
  318. if(($adminlangsettings & 1024)==1024) $sSQL .= ",cpnName" . $index;
  319. }
  320. $sSQL .= ",cpnWorkingName,cpnNumber,cpnType,cpnEndDate,cpnDiscount,cpnThreshold,cpnThresholdMax,cpnThresholdRepeat,cpnQuantity,cpnQuantityMax,cpnQuantityRepeat,cpnNumAvail,cpnCntry,cpnIsCoupon,cpnSitewide,cpnIsWholesale,cpnBeginDate, cpnStackable) VALUES (";
  321. $sSQL .= "'" . mysql_real_escape_string(unstripslashes(@$_POST["cpnName"])) . "',";
  322. for($index=2; $index <= $adminlanguages+1; $index++){
  323. if(($adminlangsettings & 1024)==1024) $sSQL .= "'" . mysql_real_escape_string(unstripslashes(@$_POST["cpnName" . $index])) . "',";
  324. }
  325. if(trim(@$_POST["cpnWorkingName"]) != "")
  326. $sSQL .= "'" . mysql_real_escape_string(unstripslashes(@$_POST["cpnWorkingName"])) . "',";
  327. else
  328. $sSQL .= "'" . mysql_real_escape_string(unstripslashes(@$_POST["cpnName"])) . "',";
  329. if(@$_POST["cpnIsCoupon"]=="0")
  330. $sSQL .= "'',";
  331. else
  332. $sSQL .= "'" . mysql_real_escape_string(unstripslashes(@$_POST["cpnNumber"])) . "',";
  333. $sSQL .= @$_POST["cpnType"] . ",";
  334. /*$numdays=0;
  335. if(is_numeric(@$_POST["cpnEndDate"])) $numdays = (int)@$_POST["cpnEndDate"];
  336. if($numdays > 0)
  337. $sSQL .= "'" . date("Y-m-d",(time() + ($numdays*60*60*24))) . "',";
  338. else
  339. $sSQL .= "'3000-01-01',";*/
  340. if (!empty($_POST["cpnEndDate"])) {
  341. $sSQL .= "'" . $_POST["cpnEndDate"] . "',";
  342. } else {
  343. $sSQL .= "'3000-01-01 00:00:00',";
  344. }
  345. if(is_numeric(@$_POST["cpnDiscount"]) && @$_POST["cpnType"] != "0")
  346. $sSQL .= @$_POST["cpnDiscount"] . ",";
  347. else
  348. $sSQL .= "0,";
  349. if(is_numeric(@$_POST["cpnThreshold"]))
  350. $sSQL .= @$_POST["cpnThreshold"] . ",";
  351. else
  352. $sSQL .= "0,";
  353. if(is_numeric(@$_POST["cpnThresholdMax"]))
  354. $sSQL .= @$_POST["cpnThresholdMax"] . ",";
  355. else
  356. $sSQL .= "0,";
  357. if(is_numeric(@$_POST["cpnThresholdRepeat"]))
  358. $sSQL .= @$_POST["cpnThresholdRepeat"] . ",";
  359. else
  360. $sSQL .= "0,";
  361. if(is_numeric(@$_POST["cpnQuantity"]))
  362. $sSQL .= @$_POST["cpnQuantity"] . ",";
  363. else
  364. $sSQL .= "0,";
  365. if(is_numeric(@$_POST["cpnQuantityMax"]))
  366. $sSQL .= @$_POST["cpnQuantityMax"] . ",";
  367. else
  368. $sSQL .= "0,";
  369. if(is_numeric(@$_POST["cpnQuantityRepeat"]))
  370. $sSQL .= @$_POST["cpnQuantityRepeat"] . ",";
  371. else
  372. $sSQL .= "0,";
  373. if(trim(@$_POST["cpnNumAvail"]) != "" && is_numeric(@$_POST["cpnNumAvail"]))
  374. $sSQL .= @$_POST["cpnNumAvail"] . ",";
  375. else
  376. $sSQL .= "30000000,";
  377. if(@$_POST["cpnType"]=="0")
  378. $sSQL .= @$_POST["cpnCntry"] . ",";
  379. else
  380. $sSQL .= "0,";
  381. $sSQL .= @$_POST["cpnIsCoupon"] . ",";
  382. if(@$_POST["cpnType"]=="0")
  383. $sSQL .= "1,";
  384. else
  385. $sSQL .= @$_POST["cpnSitewide"] . ",";
  386. //wholesale only coupon added by Blake 6-6-06
  387. if(@$_POST["cpnIsWholesale"]=="")
  388. $sSQL .= "0,";
  389. else
  390. $sSQL .= @$_POST["cpnIsWholesale"]. ",";
  391. if (!empty($_POST["cpnBeginDate"])) {
  392. $sSQL .= "'" . $_POST["cpnBeginDate"] . "',";
  393. }
  394. else {
  395. $sSQL .= "'0000-00-00 00:00:00',";
  396. }
  397. if ($_POST["cpnStackable"] == "") {
  398. $sSQL .= "0)";
  399. }
  400. else {
  401. $sSQL .= $_POST["cpnStackable"] . ")";
  402. }
  403. mysql_query($sSQL) or print(mysql_error().'<br />'.$sSQL);
  404. $cpnID = mysql_insert_id();
  405. if (($_POST['cpnType'] == 0) && isset($_POST['pz']) && (count($_POST['pz']) > 0)) {
  406. foreach ($_POST['pz'] as $pz) {
  407. $data = explode(',', $pz); // 0 = pzID, 1 = methodID
  408. $iSQL = "INSERT INTO fsadiscount (cpnID, pzID, methodID) VALUES ({$cpnID}, {$data[0]}, {$data[1]});";
  409. mysql_query($iSQL) or print(mysql_error().'<br />'.$iSQL);
  410. }
  411. }
  412. $uSQL = 'UNLOCK TABLES;';
  413. mysql_query($uSQL) or print(mysql_error().'<br />'.$uSQL);
  414. }
  415. print '<meta http-equiv="refresh" content="3; url=/admin/discounts.php">';
  416. }
  417. }
  418. ?>
  419. <link rel="stylesheet" type="text/css" media="all" href="http://assets.ifrogz.com/lib/packages/jscalendar/1.0/calendar-blue2.css" title="win2k-cold-1" />
  420. <script language="JavaScript" type="text/javascript" src="http://assets.ifrogz.com/lib/packages/scriptaculous-js/1.5.1/prototype.js"></script>
  421. <script language="JavaScript" type="text/javascript" src="http://assets.ifrogz.com/lib/packages/jscalendar/1.0/calendar.js"></script>
  422. <script language="JavaScript" type="text/javascript" src="http://assets.ifrogz.com/lib/packages/jscalendar/1.0/lang/calendar-en.js"></script>
  423. <script language="JavaScript" type="text/javascript" src="http://assets.ifrogz.com/lib/packages/jscalendar/1.0/calendar-setup.js"></script>
  424. <script language="JavaScript" type="text/javascript" src="http://assets.ifrogz.com/lib/packages/jquery/1.4.2/jquery.min.js"></script>
  425. <script language="JavaScript" type="text/javascript">
  426. <!--
  427. jQuery.noConflict();
  428. var savebg, savebc, savecol;
  429. function formvalidator(theForm)
  430. {
  431. <?php
  432. if($_POST['act']=="addnew") {
  433. ?>
  434. if($F('cpnIsGrp')==1 && $F('grpQty') == '' && $F('linkGrp')=='none') {
  435. alert("<?php print $yyPlsEntr?> \"<?php print $yyNumCpn?>\".");
  436. theForm.grpQty.focus();
  437. return (false);
  438. }
  439. if($F('cpnIsGrp')==1 && $F('grpName') == '') {
  440. alert("<?php print $yyPlsEntr?> \"<?php print $yyGrpName?>\".");
  441. theForm.grpName.focus();
  442. return (false);
  443. }
  444. <?php
  445. }
  446. ?>
  447. if(theForm.cpnName.value == "")
  448. {
  449. alert("<?php print $yyPlsEntr?> \"<?php print $yyDisTxt?>\".");
  450. theForm.cpnName.focus();
  451. return (false);
  452. }
  453. if(theForm.cpnName.value.length > 255)
  454. {
  455. alert("<?php print $yyMax255?> \"<?php print $yyDisTxt?>\".");
  456. theForm.cpnName.focus();
  457. return (false);
  458. }
  459. if(theForm.cpnType.selectedIndex!=0){
  460. if(theForm.cpnDiscount.value == "")
  461. {
  462. alert("<?php print $yyPlsEntr?> \"<?php print $yyDscAmt?>\".");
  463. theForm.cpnDiscount.focus();
  464. return (false);
  465. }
  466. if(theForm.cpnType.selectedIndex==2){
  467. if(theForm.cpnDiscount.value < 0 || theForm.cpnDiscount.value > 100){
  468. alert("<?php print $yyNum100?> \"<?php print $yyDscAmt?>\".");
  469. theForm.cpnDiscount.focus();
  470. return (false);
  471. }
  472. }
  473. }
  474. if(theForm.cpnIsCoupon.selectedIndex==1){
  475. <?php
  476. if($_POST['act']=="addnew") {
  477. ?>
  478. if($F('cpnIsGrp')!=1) {
  479. <?php
  480. }
  481. ?>
  482. if(theForm.cpnNumber.value == "")
  483. {
  484. alert("<?php print $yyPlsEntr?> \"<?php print $yyCpnCod?>\".");
  485. theForm.cpnNumber.focus();
  486. return (false);
  487. }
  488. var checkOK = "0123456789abcdefghijklmnopqrstuvwxyz-_";
  489. var checkStr = theForm.cpnNumber.value.toLowerCase();
  490. var allValid = true;
  491. for (i = 0; i < checkStr.length; i++)
  492. {
  493. ch = checkStr.charAt(i);
  494. for (j = 0; j < checkOK.length; j++)
  495. if (ch == checkOK.charAt(j))
  496. break;
  497. if (j == checkOK.length){
  498. allValid = false;
  499. break;
  500. }
  501. }
  502. if (!allValid)
  503. {
  504. alert("<?php print $yyAlpha2?> \"<?php print $yyCpnCod?>\".");
  505. theForm.cpnNumber.focus();
  506. return (false);
  507. }
  508. <?php
  509. if($_POST['act']=="addnew") {
  510. ?>
  511. }
  512. <?php
  513. }
  514. ?>
  515. }
  516. var checkOK = "0123456789";
  517. var checkStr = theForm.cpnNumAvail.value;
  518. var allValid = true;
  519. for (i = 0; i < checkStr.length; i++)
  520. {
  521. ch = checkStr.charAt(i);
  522. for (j = 0; j < checkOK.length; j++)
  523. if (ch == checkOK.charAt(j))
  524. break;
  525. if (j == checkOK.length){
  526. allValid = false;
  527. break;
  528. }
  529. }
  530. if (!allValid)
  531. {
  532. alert("<?php print $yyOnlyNum?> \"<?php print $yyNumAvl?>\".");
  533. theForm.cpnNumAvail.focus();
  534. return (false);
  535. }
  536. if(theForm.cpnNumAvail.value != "" && theForm.cpnNumAvail.value > 1000000)
  537. {
  538. alert("<?php print $yyNumMil?> \"<?php print $yyNumAvl?>\"<?php print $yyOrBlank?>");
  539. theForm.cpnNumAvail.focus();
  540. return (false);
  541. }
  542. /*
  543. var checkOK = "0123456789";
  544. var checkStr = theForm.cpnEndDate.value;
  545. var allValid = true;
  546. for (i = 0; i < checkStr.length; i++)
  547. {
  548. ch = checkStr.charAt(i);
  549. for (j = 0; j < checkOK.length; j++)
  550. if (ch == checkOK.charAt(j))
  551. break;
  552. if (j == checkOK.length){
  553. allValid = false;
  554. break;
  555. }
  556. }
  557. if (!allValid)
  558. {
  559. alert("<?php print $yyOnlyNum?> \"<?php print $yyDaysAv?>\".");
  560. theForm.cpnEndDate.focus();
  561. return (false);
  562. }*/
  563. var checkOK = "0123456789.";
  564. var checkStr = theForm.cpnThreshold.value;
  565. var allValid = true;
  566. for (i = 0; i < checkStr.length; i++)
  567. {
  568. ch = checkStr.charAt(i);
  569. for (j = 0; j < checkOK.length; j++)
  570. if (ch == checkOK.charAt(j))
  571. break;
  572. if (j == checkOK.length){
  573. allValid = false;
  574. break;
  575. }
  576. }
  577. if (!allValid)
  578. {
  579. alert("<?php print $yyOnlyDec?> \"<?php print $yyMinPur?>\".");
  580. theForm.cpnThreshold.focus();
  581. return (false);
  582. }
  583. var checkOK = "0123456789.";
  584. var checkStr = theForm.cpnThresholdRepeat.value;
  585. var allValid = true;
  586. for (i = 0; i < checkStr.length; i++)
  587. {
  588. ch = checkStr.charAt(i);
  589. for (j = 0; j < checkOK.length; j++)
  590. if (ch == checkOK.charAt(j))
  591. break;
  592. if (j == checkOK.length){
  593. allValid = false;
  594. break;
  595. }
  596. }
  597. if (!allValid)
  598. {
  599. alert("<?php print $yyOnlyDec?> \"<?php print $yyRepEvy?>\".");
  600. theForm.cpnThresholdRepeat.focus();
  601. return (false);
  602. }
  603. var checkOK = "0123456789.";
  604. var checkStr = theForm.cpnThresholdMax.value;
  605. var allValid = true;
  606. for (i = 0; i < checkStr.length; i++)
  607. {
  608. ch = checkStr.charAt(i);
  609. for (j = 0; j < checkOK.length; j++)
  610. if (ch == checkOK.charAt(j))
  611. break;
  612. if (j == checkOK.length){
  613. allValid = false;
  614. break;
  615. }
  616. }
  617. if (!allValid)
  618. {
  619. alert("<?php print $yyOnlyDec?> \"<?php print $yyMaxPur?>\".");
  620. theForm.cpnThresholdMax.focus();
  621. return (false);
  622. }
  623. var checkOK = "0123456789";
  624. var checkStr = theForm.cpnQuantity.value;
  625. var allValid = true;
  626. for (i = 0; i < checkStr.length; i++)
  627. {
  628. ch = checkStr.charAt(i);
  629. for (j = 0; j < checkOK.length; j++)
  630. if (ch == checkOK.charAt(j))
  631. break;
  632. if (j == checkOK.length){
  633. allValid = false;
  634. break;
  635. }
  636. }
  637. if (!allValid)
  638. {
  639. alert("<?php print $yyOnlyNum?> \"<?php print $yyMinQua?>\".");
  640. theForm.cpnQuantity.focus();
  641. return (false);
  642. }
  643. var checkOK = "0123456789";
  644. var checkStr = theForm.cpnQuantityRepeat.value;
  645. var allValid = true;
  646. for (i = 0; i < checkStr.length; i++)
  647. {
  648. ch = checkStr.charAt(i);
  649. for (j = 0; j < checkOK.length; j++)
  650. if (ch == checkOK.charAt(j))
  651. break;
  652. if (j == checkOK.length){
  653. allValid = false;
  654. break;
  655. }
  656. }
  657. if (!allValid)
  658. {
  659. alert("<?php print $yyOnlyNum?> \"<?php print $yyRepEvy?>\".");
  660. theForm.cpnQuantityRepeat.focus();
  661. return (false);
  662. }
  663. var checkOK = "0123456789";
  664. var checkStr = theForm.cpnQuantityMax.value;
  665. var allValid = true;
  666. for (i = 0; i < checkStr.length; i++)
  667. {
  668. ch = checkStr.charAt(i);
  669. for (j = 0; j < checkOK.length; j++)
  670. if (ch == checkOK.charAt(j))
  671. break;
  672. if (j == checkOK.length){
  673. allValid = false;
  674. break;
  675. }
  676. }
  677. if (!allValid)
  678. {
  679. alert("<?php print $yyOnlyNum?> \"<?php print $yyMaxQua?>\".");
  680. theForm.cpnQuantityMax.focus();
  681. return (false);
  682. }
  683. var checkOK = "0123456789.";
  684. var checkStr = theForm.cpnDiscount.value;
  685. var allValid = true;
  686. for (i = 0; i < checkStr.length; i++)
  687. {
  688. ch = checkStr.charAt(i);
  689. for (j = 0; j < checkOK.length; j++)
  690. if (ch == checkOK.charAt(j))
  691. break;
  692. if (j == checkOK.length){
  693. allValid = false;
  694. break;
  695. }
  696. }
  697. if (!allValid)
  698. {
  699. alert("<?php print $yyOnlyDec?> \"<?php print $yyDscAmt?>\".");
  700. theForm.cpnDiscount.focus();
  701. return (false);
  702. }
  703. document.mainform.cpnNumber.disabled=false;
  704. document.mainform.cpnDiscount.disabled=false;
  705. document.mainform.cpnCntry.disabled=false;
  706. document.mainform.cpnSitewide.disabled=false;
  707. document.mainform.cpnThresholdRepeat.disabled=false;
  708. document.mainform.cpnQuantityRepeat.disabled=false;
  709. return (true);
  710. }
  711. function couponcodeactive(forceactive){
  712. if(document.mainform.cpnIsCoupon.selectedIndex==0){
  713. document.mainform.cpnNumber.style.backgroundColor="#DDDDDD";
  714. document.mainform.cpnNumber.style.borderColor="#aa3300";
  715. document.mainform.cpnNumber.style.color="#aa3300";
  716. document.mainform.cpnNumber.disabled=true;
  717. }
  718. else if(document.mainform.cpnIsCoupon.selectedIndex==1<?=($_POST['act']=='addnew')?' && $F("cpnIsGrp")==0':''?>){
  719. document.mainform.cpnNumber.style.backgroundColor=savebg;
  720. document.mainform.cpnNumber.style.borderColor=savebc;
  721. document.mainform.cpnNumber.style.color=savecol;
  722. document.mainform.cpnNumber.disabled=false;
  723. }
  724. }
  725. function changecouponeffect(forceactive){
  726. if(document.mainform.cpnType.selectedIndex==0){
  727. document.mainform.cpnDiscount.style.backgroundColor="#DDDDDD";
  728. document.mainform.cpnDiscount.style.borderColor="#aa3300";
  729. document.mainform.cpnDiscount.style.color="#aa3300";
  730. document.mainform.cpnDiscount.disabled=true;
  731. document.mainform.cpnCntry.style.backgroundColor=savebg;
  732. document.mainform.cpnCntry.style.borderColor=savebc;
  733. document.mainform.cpnCntry.style.color=savecol;
  734. document.mainform.cpnCntry.disabled=false;
  735. document.mainform.cpnSitewide.style.backgroundColor="#DDDDDD";
  736. document.mainform.cpnSitewide.style.borderColor="#aa3300";
  737. document.mainform.cpnSitewide.style.color="#aa3300";
  738. document.mainform.cpnSitewide.disabled=true;
  739. jQuery('input.ShippingMethod').each(function() {
  740. jQuery('input.ShippingMethod').removeAttr('disabled');
  741. });
  742. }else{
  743. document.mainform.cpnDiscount.style.backgroundColor=savebg;
  744. document.mainform.cpnDiscount.style.borderColor=savebc;
  745. document.mainform.cpnDiscount.style.color=savecol;
  746. document.mainform.cpnDiscount.disabled=false;
  747. document.mainform.cpnCntry.style.backgroundColor="#DDDDDD";
  748. document.mainform.cpnCntry.style.borderColor="#aa3300";
  749. document.mainform.cpnCntry.style.color="#aa3300";
  750. document.mainform.cpnCntry.disabled=true;
  751. document.mainform.cpnSitewide.style.backgroundColor=savebg;
  752. document.mainform.cpnSitewide.style.borderColor=savebc;
  753. document.mainform.cpnSitewide.style.color=savecol;
  754. document.mainform.cpnSitewide.disabled=false;
  755. jQuery('input.ShippingMethod').each(function() {
  756. jQuery('input.ShippingMethod').attr('disabled', 'disabled');
  757. });
  758. }
  759. if(document.mainform.cpnType.selectedIndex==1){
  760. document.mainform.cpnThresholdRepeat.style.backgroundColor=savebg;
  761. document.mainform.cpnThresholdRepeat.style.borderColor=savebc;
  762. document.mainform.cpnThresholdRepeat.style.color=savecol;
  763. document.mainform.cpnThresholdRepeat.disabled=false;
  764. document.mainform.cpnQuantityRepeat.style.backgroundColor=savebg;
  765. document.mainform.cpnQuantityRepeat.style.borderColor=savebc;
  766. document.mainform.cpnQuantityRepeat.style.color=savecol;
  767. document.mainform.cpnQuantityRepeat.disabled=false;
  768. }else{
  769. document.mainform.cpnThresholdRepeat.style.backgroundColor="#DDDDDD";
  770. document.mainform.cpnThresholdRepeat.style.borderColor="#aa3300";
  771. document.mainform.cpnThresholdRepeat.style.color="#aa3300";
  772. document.mainform.cpnThresholdRepeat.disabled=true;
  773. document.mainform.cpnQuantityRepeat.style.backgroundColor="#DDDDDD";
  774. document.mainform.cpnQuantityRepeat.style.borderColor="#aa3300";
  775. document.mainform.cpnQuantityRepeat.style.color="#aa3300";
  776. document.mainform.cpnQuantityRepeat.disabled=true;
  777. }
  778. }
  779. function cpnGrp(oSel) {
  780. var val = $F('cpnIsGrp');
  781. var aTR = document.getElementsByClassName('trGroup');
  782. if(val == 1) {
  783. for(i=0; i<aTR.length; i++) {
  784. aTR[i].style.display = '';
  785. }
  786. $('cpnNumber').disabled=true;
  787. $('cpnNumber').style.backgroundColor="#DDDDDD";
  788. $('cpnNumber').style.borderColor="#aa3300";
  789. }else{
  790. for(i=0; i<aTR.length; i++) {
  791. aTR[i].style.display = 'none';
  792. }
  793. $('grpQty').value = '';
  794. $('linkGrp').selectedIndex = 0;
  795. $('cpnNumber').disabled=false;
  796. $('cpnNumber').style.backgroundColor="";
  797. $('cpnNumber').style.borderColor="";
  798. }
  799. }
  800. function qty() {
  801. if($F('linkGrp')!='none') {
  802. $('grpQty').disabled=true;
  803. $('grpQty').style.backgroundColor="#DDDDDD";
  804. $('grpQty').style.borderColor="#aa3300";
  805. $('cpnEndDate').disabled=true;
  806. $('cpnEndDate').style.backgroundColor="#DDDDDD";
  807. $('cpnEndDate').style.borderColor="#aa3300";
  808. }else{
  809. $('grpQty').disabled=false;
  810. $('grpQty').style.backgroundColor="";
  811. $('grpQty').style.borderColor="";
  812. $('cpnEndDate').disabled=false;
  813. $('cpnEndDate').style.backgroundColor="";
  814. $('cpnEndDate').style.borderColor="";
  815. }
  816. }
  817. //-->
  818. </script>
  819. <table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="" align="center">
  820. <?php if(@$_POST["posted"]=="1" && (@$_POST["act"]=="modify" || @$_POST["act"]=="addnew")){
  821. if(@$_POST["act"]=="modify"){
  822. $sSQL = "SELECT cpnName,cpnName2,cpnName3,cpnWorkingName,cpnNumber,cpnType,cpnEndDate,cpnDiscount,cpnThreshold,cpnThresholdMax,cpnThresholdRepeat,cpnQuantity,cpnQuantityMax,cpnQuantityRepeat,cpnNumAvail,cpnCntry,cpnIsCoupon,cpnSitewide,cpnGrpCpnID,cpnIsWholesale,cpnBeginDate, cpnStackable FROM coupons WHERE cpnID=" . @$_POST["id"];
  823. $result = mysql_query($sSQL) or print(mysql_error());
  824. $rs = mysql_fetch_array($result);
  825. $cpnName = $rs["cpnName"];
  826. for($index=2; $index <= $adminlanguages+1; $index++) {
  827. $cpnNames[$index] = $rs["cpnName" . $index];
  828. }
  829. $cpnWorkingName = $rs["cpnWorkingName"];
  830. $cpnNumber = $rs["cpnNumber"];
  831. $cpnType = $rs["cpnType"];
  832. $cpnEndDate = $rs["cpnEndDate"];
  833. $cpnDiscount = $rs["cpnDiscount"];
  834. $cpnThreshold = $rs["cpnThreshold"];
  835. $cpnThresholdMax = $rs["cpnThresholdMax"];
  836. $cpnThresholdRepeat = $rs["cpnThresholdRepeat"];
  837. $cpnQuantity = $rs["cpnQuantity"];
  838. $cpnQuantityMax = $rs["cpnQuantityMax"];
  839. $cpnQuantityRepeat = $rs["cpnQuantityRepeat"];
  840. $cpnNumAvail = $rs["cpnNumAvail"];
  841. $cpnCntry = $rs["cpnCntry"];
  842. $cpnIsCoupon = $rs["cpnIsCoupon"];
  843. $cpnSitewide = $rs["cpnSitewide"];
  844. $cpnIsWholesale = $rs["cpnIsWholesale"];
  845. $cpnIsGrp = $rs["cpnGrpCpnID"];
  846. $cpnBeginDate = $rs["cpnBeginDate"];
  847. $cpnStackable = $rs["cpnStackable"];
  848. mysql_free_result($result);
  849. }else{
  850. $cpnName = "";
  851. for($index=2; $index <= $adminlanguages+1; $index++)
  852. $cpnNames[$index] = "";
  853. $cpnWorkingName = "";
  854. $cpnNumber = "";
  855. $cpnType = 0;
  856. $cpnEndDate = '3000-01-01 00:00:00';
  857. $cpnDiscount = "";
  858. $cpnThreshold = 0;
  859. $cpnThresholdMax = 0;
  860. $cpnThresholdRepeat = 0;
  861. $cpnQuantity = 0;
  862. $cpnQuantityMax = 0;
  863. $cpnQuantityRepeat = 0;
  864. $cpnNumAvail = 30000000;
  865. $cpnCntry = 0;
  866. $cpnIsCoupon = 0;
  867. $cpnSitewide = 0;
  868. $cpnIsGrp = 0;
  869. $cpnBeginDate = '0000-00-00 00:00:00';
  870. $cpnStackable = 1;
  871. }
  872. ?>
  873. <tr>
  874. <form name="mainform" method="post" action="/admin/discounts.php" onsubmit="return formvalidator(this)">
  875. <td width="100%">
  876. <input type="hidden" name="posted" value="1" />
  877. <?php if(@$_POST["act"]=="modify"){ ?>
  878. <input type="hidden" name="act" value="domodify" />
  879. <input type="hidden" name="id" value="<?php print @$_POST["id"]?>" />
  880. <?php }else{ ?>
  881. <input type="hidden" name="act" value="doaddnew" />
  882. <?php } ?>
  883. <table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="">
  884. <tr>
  885. <td width="100%" colspan="2" align="center"><strong><?php print $yyDscNew?></strong><br />&nbsp;</td>
  886. </tr>
  887. <?php
  888. if(@$_POST["act"]=="addnew"){
  889. ?>
  890. <tr>
  891. <td width="40%" align="right"><strong>Create Coupon Group:</strong></td>
  892. <td width="60%"><select id="cpnIsGrp" name="cpnIsGrp" onchange="cpnGrp(this);">
  893. <option value="0"<?=((int)$cpnIsGrp!=1)?' selected="selected"':''?>>No</option>
  894. <option value="1"<?=((int)$cpnIsGrp==1)?' selected="selected"':''?>>Yes</option>
  895. </select> </td>
  896. </tr>
  897. <tr class="trGroup" style="display: none">
  898. <td width="40%" align="right"><strong>Group Name:</strong></td>
  899. <td width="60%"><input type="text" id="grpName" name="grpName" value="" /></td>
  900. </tr>
  901. <tr class="trGroup" style="display: none">
  902. <td width="40%" align="right"><strong>Number of Coupons:</strong></td>
  903. <td width="60%"><input type="text" id="grpQty" name="grpQty" value="" /></td>
  904. </tr>
  905. <tr class="trGroup" style="display: none">
  906. <td width="40%" align="right"><strong>Link to Group:</strong></td>
  907. <td width="60%">
  908. <select id="linkGrp" name="linkGrp" onchange="qty()">
  909. <?php
  910. $qry = "SELECT * FROM grpCpn WHERE grpCpnLinkID IS NULL OR grpCpnLinkID = ''";
  911. $res = mysql_query($qry) or print(mysql_error());
  912. echo '<option value="none">None</option>'."\n";
  913. while($row = mysql_fetch_assoc($res)) {
  914. echo '<option value="'.$row['grpCpnID'].'">'.$row['grpCpnName'].'</option>'."\n";
  915. }
  916. ?>
  917. </select>
  918. </td>
  919. </tr>
  920. <tr>
  921. <td colspan="2">&nbsp;</td>
  922. </tr>
  923. <?php
  924. }
  925. ?>
  926. <tr>
  927. <td width="40%" align="right"><strong><?php print $yyCpnDsc?>:</strong></td>
  928. <td width="60%"><select name="cpnIsCoupon" size="1" onchange="couponcodeactive(false);">
  929. <option value="0"><?php print $yyDisco?></option>
  930. <option value="1" <?php if((int)$cpnIsCoupon==1) print "selected" ?>><?php print $yyCoupon?></option>
  931. </select></td>
  932. </tr>
  933. <tr>
  934. <td width="40%" align="right"><strong><?php print $yyDscEff?>:</strong></td>
  935. <td width="60%"><select name="cpnType" size="1" onchange="changecouponeffect(false);">
  936. <option value="0"><?php print $yyFrSShp?></option>
  937. <option value="1" <?php if((int)$cpnType==1) print "selected" ?>><?php print $yyFlatDs?></option>
  938. <option value="2" <?php if((int)$cpnType==2) print "selected" ?>><?php print $yyPerDis?></option>
  939. </select></td>
  940. </tr>
  941. <tr>
  942. <td width="40%" align="right"><strong><?php print $yyDisTxt?>:</strong></td>
  943. <td width="60%"><input type="text" name="cpnName" size="30" value="<?php print str_replace('"',"&quot;",$cpnName)?>" /></td>
  944. </tr>
  945. <?php for($index=2; $index <= $adminlanguages+1; $index++){
  946. if(($adminlangsettings & 1024)==1024){ ?>
  947. <tr>
  948. <td width="40%" align="right"><strong><?php print $yyDisTxt . " " . $index?>:</strong></td>
  949. <td width="60%"><input type="text" name="cpnName<?php print $index?>" size="30" value="<?php print str_replace('"',"&quot;",$cpnNames[$index])?>" /></td>
  950. </tr>
  951. <?php }
  952. } ?>
  953. <tr>
  954. <td width="40%" align="right"><strong><?php print $yyWrkNam?>:</strong></td>
  955. <td width="60%"><input type="text" name="cpnWorkingName" size="30" value="<?php print str_replace('"',"&quot;",$cpnWorkingName)?>" /></td>
  956. </tr>
  957. <tr>
  958. <td width="40%" align="right"><strong><?php print $yyCpnCod?>:</strong></td>
  959. <td width="60%"><input type="text" id="cpnNumber" name="cpnNumber" size="30" value="<?php print $cpnNumber?>" /></td>
  960. </tr>
  961. <tr>
  962. <td width="40%" align="right"><strong><?php print $yyNumAvl?>:</strong></td>
  963. <td width="60%"><input type="text" id="cpnNumAvail" name="cpnNumAvail" size="10" value="<?php if((int)$cpnNumAvail != 30000000) print $cpnNumAvail?>" /></td>
  964. </tr>
  965. <?php /*?><tr>
  966. <td width="40%" align="right"><strong><?php print $yyDaysAv?>:</strong></td>
  967. <td width="60%"><input type="text" id="cpnEndDate" name="cpnEndDate" size="10" value="<?php
  968. if($cpnEndDate != '3000-01-01 00:00:00')
  969. if(strtotime($cpnEndDate)-time() < 0) print "Expired"; else print floor((strtotime($cpnEndDate)-time())/(60*60*24))+1; ?>"/></td>
  970. </tr><?php */?>
  971. <tr>
  972. <td width="40%" align="right"><strong><?php print $yyBeginDate?>:</strong></td>
  973. <td width="60%"><input type="text" id="cpnBeginDate" name="cpnBeginDate" size="19" value="<?php if ($cpnBeginDate != "0000-00-00 00:00:00") { echo $cpnBeginDate; }?>" /><button type="reset" id="beginDte">...</button>
  974. <script type="text/javascript">
  975. Calendar.setup({
  976. inputField : "cpnBeginDate", // id of the input field
  977. ifFormat : "%Y-%m-%d 00:00:00", // format of the input field
  978. showsTime : false, // will display a time selector
  979. button : "beginDte", // trigger for the calendar (button ID)
  980. singleClick : true, // double-click mode
  981. step : 1 // show all years in drop-down boxes (instead of every other year as default)
  982. });
  983. </script></td>
  984. </tr>
  985. <tr>
  986. <td width="40%" align="right"><strong><?php print $yyEndDate?>:</strong></td>
  987. <td width="60%"><input type="text" id="cpnEndDate" name="cpnEndDate" size="19" value="<?php
  988. if($cpnEndDate != '3000-01-01 00:00:00')
  989. if(strtotime($cpnEndDate)-time() < 0) print "Expired"; else print $cpnEndDate; ?>" /><button type="reset" id="endDte">...</button>
  990. <script type="text/javascript">
  991. Calendar.setup({
  992. inputField : "cpnEndDate", // id of the input field
  993. ifFormat : "%Y-%m-%d 00:00:00", // format of the input field
  994. showsTime : false, // will display a time selector
  995. button : "endDte", // trigger for the calendar (button ID)
  996. singleClick : true, // double-click mode
  997. step : 1 // show all years in drop-down boxes (instead of every other year as default)
  998. });
  999. </script></td>
  1000. </tr>
  1001. <tr>
  1002. <td width="40%" align="right"><strong><?php print $yyMinPur?>:</strong></td>
  1003. <td width="60%"><input type="text" name="cpnThreshold" size="10" value="<?php if((int)$cpnThreshold>0) print $cpnThreshold?>" /> <strong><?php print $yyRepEvy?>:</strong> <input type="text" name="cpnThresholdRepeat" size="10" value="<?php if((int)$cpnThresholdRepeat > 0) print $cpnThresholdRepeat?>" /></td>
  1004. </tr>
  1005. <tr>
  1006. <td width="40%" align="right"><strong><?php print $yyMaxPur?>:</strong></td>
  1007. <td width="60%"><input type="text" name="cpnThresholdMax" size="10" value="<?php if((int)$cpnThresholdMax>0) print $cpnThresholdMax?>" /></td>
  1008. </tr>
  1009. <tr>
  1010. <td width="40%" align="right"><strong><?php print $yyMinQua?>:</strong></td>
  1011. <td width="60%"><input type="text" name="cpnQuantity" size="10" value="<?php if((int)$cpnQuantity>0) print $cpnQuantity?>" /> <strong><?php print $yyRepEvy?>:</strong> <input type="text" name="cpnQuantityRepeat" size="10" value="<?php if((int)$cpnQuantityRepeat > 0) print $cpnQuantityRepeat?>" /></td>
  1012. </tr>
  1013. <tr>
  1014. <td width="40%" align="right"><strong><?php print $yyMaxQua?>:</strong></td>
  1015. <td width="60%"><input type="text" name="cpnQuantityMax" size="10" value="<?php if((int)$cpnQuantityMax>0) print $cpnQuantityMax?>" /></td>
  1016. </tr>
  1017. <tr>
  1018. <td width="40%" align="right"><strong><?php print $yyDscAmt?>:</strong></td>
  1019. <td width="60%"><input type="text" name="cpnDiscount" size="10" value="<?php print $cpnDiscount?>" /></td>
  1020. </tr>
  1021. <tr>
  1022. <td width="40%" align="right"><strong><?php print $yyScope?>:</strong></td>
  1023. <td width="60%"><select name="cpnSitewide" size="1">
  1024. <option value="0"><?php print $yyIndCat?></option>
  1025. <option value="3" <?php if((int)$cpnSitewide==3) print "selected" ?>><?php print $yyDsCaTo?></option>
  1026. <option value="2" <?php if((int)$cpnSitewide==2) print "selected" ?>><?php print $yyGlInPr?></option>
  1027. <option value="1" <?php if((int)$cpnSitewide==1) print "selected" ?>><?php print $yyGlPrTo?></option>
  1028. </select></td>
  1029. </tr>
  1030. <tr>
  1031. <td width="40%" align="right"><strong><?php print $yyRestr?>:</strong></td>
  1032. <td width="60%"><select name="cpnCntry" size="1">
  1033. <option value="0"><?php print $yyAppAll?></option>
  1034. <option value="1" <?php if((int)$cpnCntry==1) print "selected" ?>><?php print $yyYesRes?></option>
  1035. </select></td>
  1036. </tr>
  1037. <tr>
  1038. <td align="right"><strong>Is Stackable:</strong></td>
  1039. <td><input <?php
  1040. if ($cpnStackable != 0) {
  1041. echo "checked=\"checked\"";
  1042. } ?>type="checkbox" name="cpnStackable" value="1" /></td>
  1043. </tr>
  1044. <tr>
  1045. <td align="right"><strong><?php print $yyAppliesToWS?>:</strong></td>
  1046. <td><input <?php if (!(strcmp($cpnIsWholesale,'1'))) {echo "checked=\"checked\"";} ?> type="checkbox" name="cpnIsWholesale" value="1" /></td>
  1047. </tr>
  1048. <tr>
  1049. <td style="vertical-align: top; text-align: right;"><strong>Applicable Shipping Methods:</strong></td>
  1050. <td>
  1051. <?php
  1052. $iFrogzConnection = DB_Connection_Pool::instance()->get_connection(new DB_DataSource('default_ifrogz'));
  1053. $ResultSet = $iFrogzConnection->query("SELECT * FROM postalzones WHERE pzID <= 100 AND pzName != '';");
  1054. $postalzones = $ResultSet->as_array();
  1055. $ResultSet->free();
  1056. $buffer = '';
  1057. foreach ($postalzones as $record) {
  1058. $buffer .= $record['pzName'] . '<br />';
  1059. for ($i = 1; $i <= 5; $i++) {
  1060. $key = "pzMethodName{$i}";
  1061. if ($record[$key] != '') {
  1062. $isChecked = '';
  1063. if (isset($_POST['id'])) {
  1064. try {
  1065. $ResultSet = $iFrogzConnection->query("SELECT * FROM fsadiscount WHERE cpnID = {$_POST['id']} AND pzID = {$record['pzID']} AND methodID = {$i};");
  1066. $fsadiscount = $ResultSet->as_array();
  1067. if (!empty($fsadiscount)) {
  1068. $isChecked = 'checked="checked" ';
  1069. }
  1070. $ResultSet->free();
  1071. }
  1072. catch (Exception $ex) { }
  1073. }
  1074. $buffer .= "&nbsp;&nbsp;&nbsp;<input class=\"ShippingMethod\" type=\"checkbox\" name=\"pz[]\" value=\"{$record['pzID']},{$i}\" {$isChecked}/>" . $record[$key] . '<br />';
  1075. }
  1076. }
  1077. }
  1078. echo $buffer;
  1079. $iFrogzConnection->close();
  1080. ?>
  1081. </td>
  1082. </tr>
  1083. <?php
  1084. if($_POST['act']!="viewGrp") {
  1085. ?>
  1086. <tr>
  1087. <td width="100%" colspan="2" align="center"><br /><input type="submit" value="<?php print $yySubmit?>" /><br />&nbsp;</td>
  1088. </tr>
  1089. <?php
  1090. }
  1091. ?>
  1092. <tr>
  1093. <td width="100%" colspan="2" align="center"><br />
  1094. <a href="/admin/index.php"><strong><?php print $yyAdmHom?></strong></a><br />
  1095. &nbsp;</td>
  1096. </tr>
  1097. </table>
  1098. </td>
  1099. </form>
  1100. </tr>
  1101. <script language="JavaScript" type="text/javascript">
  1102. <!--
  1103. savebg=document.mainform.cpnNumber.style.backgroundColor;
  1104. savebc=document.mainform.cpnNumber.style.borderColor;
  1105. savecol=document.mainform.cpnNumber.style.color;
  1106. couponcodeactive(false);
  1107. changecouponeffect(false);
  1108. //-->
  1109. </script>
  1110. <?php
  1111. }elseif(@$_POST["posted"]=="1" && @$_POST["act"]=="viewGrp"){
  1112. $sSQL = "SELECT * FROM grpCpn WHERE grpCpnID = " . $_POST['id'];
  1113. $res = mysql_query($sSQL) or print(mysql_error());
  1114. $row = mysql_fetch_assoc($res);
  1115. $grpCpnID = $row['grpCpnID'];
  1116. $grpCpnName = $row['grpCpnName'];
  1117. $grpLinkID = $row['grpCpnLinkID'];
  1118. $grpCpnQty = $row['grpCpnQty'];
  1119. mysql_free_result($res);
  1120. $sSQL = "SELECT * FROM coupons WHERE cpnGrpCpnID = " . $_POST['id'];
  1121. $res = mysql_query($sSQL) or print(mysql_error());
  1122. $rs = mysql_fetch_assoc($res);
  1123. $cpnName = $rs["cpnName"];
  1124. for($index=2; $index <= $adminlanguages+1; $index++)
  1125. $cpnNames[$index] = $rs["cpnName" . $index];
  1126. $cpnWorkingName = $rs["cpnWorkingName"];
  1127. $cpnNumber = $rs["cpnNumber"];
  1128. $cpnType = $rs["cpnType"];
  1129. $cpnEndDate = $rs["cpnEndDate"];
  1130. $cpnDiscount = $rs["cpnDiscount"];
  1131. $cpnThreshold = $rs["cpnThreshold"];
  1132. $cpnThresholdMax = $rs["cpnThresholdMax"];
  1133. $cpnThresholdRepeat = $rs["cpnThresholdRepeat"];
  1134. $cpnQuantity = $rs["cpnQuantity"];
  1135. $cpnQuantityMax = $rs["cpnQuantityMax"];
  1136. $cpnQuantityRepeat = $rs["cpnQuantityRepeat"];
  1137. $cpnNumAvail = $rs["cpnNumAvail"];
  1138. $cpnCntry = $rs["cpnCntry"];
  1139. $cpnIsCoupon = $rs["cpnIsCoupon"];
  1140. $cpnSitewide = $rs["cpnSitewide"];
  1141. $cpnIsGrp = $rs["cpnGrpCpnID"];
  1142. $cpnBeginDate = $rs["cpnBeginDate"];
  1143. mysql_free_result($res);
  1144. ?>
  1145. <tr>
  1146. <form name="mainform" method="post" action="/admin/discounts.php" onsubmit="return formvalidator(this)">
  1147. <td width="100%">
  1148. <input type="hidden" name="posted" value="1" />
  1149. <?php if(@$_POST["act"]=="modify"){ ?>
  1150. <input type="hidden" name="act" value="domodify" />
  1151. <input type="hidden" name="id" value="<?php print @$_POST["id"]?>" />
  1152. <?php }else{ ?>
  1153. <input type="hidden" name="act" value="doaddnew" />
  1154. <?php } ?>
  1155. <table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="">
  1156. <tr>
  1157. <td width="100%" colspan="2" align="center"><strong><?php print $yyDscNew?></strong><br />&nbsp;</td>
  1158. </tr>
  1159. <tr class="trGroup">
  1160. <td width="40%" align="right"><strong>Group Name:</strong></td>
  1161. <td width="60%"><input type="text" id="grpName" name="grpName" value="<?=$grpCpnName?>" disabled="disabled" style="background-color: #DDD; border-color: #aa3300; color: #A30;" /></td>
  1162. </tr>
  1163. <tr class="trGroup">
  1164. <td width="40%" align="right"><strong>Number of Coupons:</strong></td>
  1165. <td width="60%"><input type="text" id="grpQty" name="grpQty" value="<?=$grpCpnQty?>" /></td>
  1166. </tr>
  1167. <tr class="trGroup">
  1168. <td width="40%" align="right"><strong>Link to Group:</strong></td>
  1169. <td width="60%">
  1170. <select id="linkGrp" name="linkGrp" onchange="qty()">
  1171. <?php
  1172. $qry = "SELECT * FROM grpCpn WHERE grpCpnLinkID IS NULL OR grpCpnLinkID = ''";
  1173. $res = mysql_query($qry) or print(mysql_error());
  1174. echo ' <option value="none">None</option>'."\n";
  1175. while($row = mysql_fetch_assoc($res)) {
  1176. ?>
  1177. <option value="<?=$row['grpCpnID']?>"<?=($row['grpCpnID']==$grpLinkID)?'selected="selected"':''?>><?=$row['grpCpnName']?></option>
  1178. <?php
  1179. }
  1180. ?>
  1181. </select>
  1182. </td>
  1183. </tr>
  1184. <tr>
  1185. <td colspan="2">&nbsp;</td>
  1186. </tr>
  1187. <tr>
  1188. <td width="40%" align="right"><strong><?php print $yyCpnDsc?>:</strong></td>
  1189. <td width="60%"><select name="cpnIsCoupon" size="1" onchange="couponcodeactive(false);">
  1190. <option value="0"><?php print $yyDisco?></option>
  1191. <option value="1" <?php if((int)$cpnIsCoupon==1) print "selected" ?>><?php print $yyCoupon?></option>
  1192. </select></td>
  1193. </tr>
  1194. <tr>
  1195. <td width="40%" align="right"><strong><?php print $yyDscEff?>:</strong></td>
  1196. <td width="60%"><select name="cpnType" size="1" onchange="changecouponeffect(false);">
  1197. <option value="0"><?php print $yyFrSShp?></option>
  1198. <option value="1" <?php if((int)$cpnType==1) print "selected" ?>><?php print $yyFlatDs?></option>
  1199. <option value="2" <?php if((int)$cpnType==2) print "selected" ?>><?php print $yyPerDis?></option>
  1200. </select></td>
  1201. </tr>
  1202. <tr>
  1203. <td width="40%" align="right"><strong><?php print $yyDisTxt?>:</strong></td>
  1204. <td width="60%"><input type="text" name="cpnName" size="30" value="<?php print str_replace('"',"&quot;",$cpnName)?>" /></td>
  1205. </tr>
  1206. <?php for($index=2; $index <= $adminlanguages+1; $index++){
  1207. if(($adminlangsettings & 1024)==1024){ ?>
  1208. <tr>
  1209. <td width="40%" align="right"><strong><?php print $yyDisTxt . " " . $index?>:</strong></td>
  1210. <td width="60%"><input type="text" name="cpnName<?php print $index?>" size="30" value="<?php print str_replace('"',"&quot;",$cpnNames[$index])?>" /></td>
  1211. </tr>
  1212. <?php }
  1213. } ?>
  1214. <tr>
  1215. <td width="40%" align="right"><strong><?php print $yyWrkNam?>:</strong></td>
  1216. <td width="60%"><input type="text" name="cpnWorkingName" size="30" value="<?php print str_replace('"',"&quot;",$cpnWorkingName)?>" /></td>
  1217. </tr>
  1218. <tr>
  1219. <td width="40%" align="right"><strong><?php print $yyCpnCod?>:</strong></td>
  1220. <td width="60%"><input type="text" id="cpnNumber" name="cpnNumber" size="30" value="<?php print $cpnNumber?>" /></td>
  1221. </tr>
  1222. <tr>
  1223. <td width="40%" align="right"><strong><?php print $yyNumAvl?>:</strong></td>
  1224. <td width="60%"><input type="text" id="cpnNumAvail" name="cpnNumAvail" size="10" value="<?php if((int)$cpnNumAvail != 30000000) print $cpnNumAvail?>" /></td>
  1225. </tr>
  1226. <?php /*?><tr>
  1227. <td width="40%" align="right"><strong><?php print $yyDaysAv?>:</strong></td>
  1228. <td width="60%"><input type="text" id="cpnEndDate" name="cpnEndDate" size="10" value="<?php
  1229. if($cpnEndDate != '3000-01-01 00:00:00')
  1230. if(strtotime($cpnEndDate)-time() < 0) print "Expired"; else print floor((strtotime($cpnEndDate)-time())/(60*60*24))+1; ?>"/></td>
  1231. </tr><?php */?>
  1232. <tr>
  1233. <td width="40%" align="right"><strong><?php print $yyBeginDate?>:</strong></td>
  1234. <td width="60%"><input type="text" name="cpnBeginDate" size="19" value="<?…

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