PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/LANE/reprint.php

https://github.com/joelbrock/is4c_nofc
PHP | 201 lines | 118 code | 52 blank | 31 comment | 30 complexity | 34c323ce7b418436e84b8f70a4029dd2 MD5 | raw file
  1. <?php
  2. /*******************************************************************************
  3. Copyright 2001, 2004 Wedge Community Co-op
  4. This file is part of IS4C.
  5. IS4C is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. IS4C is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. in the file license.txt along with IS4C; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. *********************************************************************************/
  17. // -----------------------------------------------------------
  18. // reprint the specified receipt
  19. // -----------------------------------------------------------
  20. if (!function_exists("pDataConnect")) include("connect.php");
  21. if (!function_exists("tDataConnect")) include("connect.php");
  22. if (!function_exists("gohome")) include("maindisplay.php");
  23. if (!function_exists("writeLine")) include("printLib.php");
  24. if (!function_exists("blueLine")) include("session.php");
  25. if (isset($_POST["selectlist"])) {
  26. $reprnt = strtoupper(trim($_POST["selectlist"]));
  27. }
  28. else {
  29. $reprnt = "";
  30. }
  31. if ($reprnt && strlen($reprnt) >= 1) {
  32. // writeLine(centerString("*** R E P R I N T ***")."\n\n\n");
  33. $title = chr(27).chr(33).chr(5).centerString("*** R E P R I N T ***")."\n\n\n";
  34. $arpspec = explode("::", $reprnt);
  35. $laneno = $arpspec[0];
  36. $cashierNo = $arpspec[1];
  37. $transno = $arpspec[2];
  38. $ref = trim($cashierNo)."-".trim($laneno)."-".trim($transno);
  39. $queryHeader = "select * from rp_receipt_header where register_no = ".$laneno." and emp_no = ".$cashierNo." and trans_no = ".$transno;
  40. $connect = tDataConnect();
  41. $header = sql_query($queryHeader, $connect);
  42. $headerRow = sql_fetch_array($header);
  43. $dateTimeStamp = $headerRow["dateTimeStamp"];
  44. $dateTimeStamp = strtotime($dateTimeStamp);
  45. $_SESSION["memberID"] = $headerRow["memberID"];
  46. $_SESSION["memCouponTLL"] = $headerRow["couponTotal"];
  47. $_SESSION["transDiscount"] = $headerRow["transDiscount"];
  48. $_SESSION["chargeTotal"] = -1*$headerRow["chargeTotal"];
  49. if ($_SESSION["chargeTotal"] != 0) {
  50. $_SESSION["chargetender"] = 1;
  51. } else {
  52. $_SESSION["chargetender"] = 0;
  53. }
  54. $_SESSION["discounttotal"] = $headerRow["discountTTL"];
  55. $_SESSION["memSpecial"] = $headerRow["memSpecial"];
  56. sql_close($connect);
  57. $queryID = "select * from custdata where CardNo = '".$_SESSION["memberID"]."'";
  58. $connID = pDataConnect();
  59. $result = sql_query($queryID, $connID);
  60. $row = sql_fetch_array($result);
  61. if ($row["Type"] == "PC") {
  62. $_SESSION["isMember"] = 1;
  63. }
  64. else {
  65. $_SESSION["isMember"] = 0;
  66. }
  67. $_SESSION["memMsg"] = blueLine($row);
  68. sql_close($connID);
  69. if ($_SESSION["isMember"] == 1) {
  70. $_SESSION["yousaved"] = number_format( $_SESSION["transDiscount"] + $_SESSION["discounttotal"] + $_SESSION["memSpecial"] + $_SESSION["memCouponTTL"], 2);
  71. $_SESSION["couldhavesaved"] = 0;
  72. $_SESSION["specials"] = number_format($_SESSION["discounttotal"] + $_SESSION["memSpecial"], 2);
  73. }
  74. else {
  75. $dblyousaved = number_format($_SESSION["memSpecial"], 2);
  76. $_SESSION["yousaved"] = $_SESSION["discounttotal"];
  77. $_SESSION["couldhavesaved"] = number_format($_SESSION["memSpecial"], 2);
  78. $_SESSION["specials"] = $_SESSION["discounttotal"];
  79. }
  80. // -- Our Reference number for the transaction.
  81. // $ref = trim($_SESSION["CashierNo"])."-".trim($_SESSION["laneno"])."-".trim($_SESSION["transno"]);
  82. // incorrect - commented out by apbw 5/3/05 - correct ref is set above at line 54
  83. // call to transLog, the body of the receipt comes from the view 'receipt'
  84. $query = "select * from rp_receipt where register_no = ".$laneno." and emp_no = ".$cashierNo." and trans_no = ".$transno." order by trans_id";
  85. $db = tDataConnect();
  86. $result = sql_query($query, $db);
  87. $num_rows = sql_num_rows($result);
  88. $receipt = $title.printReceiptHeader($dateTimeStamp, $ref);
  89. // loop through the results to generate the items listing.
  90. for ($i = 0; $i < $num_rows; $i++) {
  91. $row = sql_fetch_array($result);
  92. $receipt .= $row["linetoprint"]."\n";
  93. }
  94. // The Nitty Gritty:
  95. $member = "Member ".trim($_SESSION["memberID"]);
  96. $your_discount = $_SESSION["transDiscount"] + $_SESSION["memCouponTTL"];
  97. if ($_SESSION["transDiscount"] + $_SESSION["memCouponTTL"] + $_SESSION["specials"] > 0) {
  98. $receipt .= "\n".centerString("------------------ YOUR SAVINGS -------------------")."\n";
  99. if ($your_discount > 0) {
  100. $receipt .= " DISCOUNTS: $".number_format($your_discount, 2)."\n";
  101. }
  102. if ($_SESSION["specials"] > 0) {
  103. $receipt .= " SPECIALS: $".number_format($_SESSION["specials"], 2)."\n";
  104. }
  105. $receipt .= centerString("---------------------------------------------------")."\n";
  106. }
  107. $receipt .= "\n";
  108. if (strlen(trim($_SESSION["memberID"])) != 99999) {
  109. $receipt .= centerString("Thank You - ".$member)."\n";
  110. }
  111. else {
  112. $receipt .= centerString("Thank You!")."\n";
  113. }
  114. if ($_SESSION["yousaved"] > 0) {
  115. $receipt .= centerString("You Saved $".number_format($_SESSION["yousaved"]), 2)."\n";
  116. }
  117. if ($_SESSION["couldhavesaved"] > 0 && $_SESSION["yousaved"] > 0) {
  118. $receipt .= centerString("You could have saved an additional $"
  119. .number_format($_SESSION["couldhavesaved"], 2))."\n";
  120. }
  121. elseif ($_SESSION["couldhavesaved"] > 0) {
  122. $receipt .= centerString("You could have saved $"
  123. .number_format($_SESSION["couldhavesaved"]), 2)."\n";
  124. }
  125. $receipt .= centerString($_SESSION["receiptFooter1"])."\n"
  126. .centerString($_SESSION["receiptFooter2"])."\n"
  127. .centerString($_SESSION["receiptFooter3"])."\n"
  128. .centerString($_SESSION["receiptFooter4"])."\n";
  129. if ($_SESSION["chargetender"] != 0 ) { // apbw 03/10/05 Reprint patch
  130. $receipt = $receipt.printChargeFooterCust($dateTimeStamp, $ref); // apbw 03/10/05 Reprint patch
  131. $receipt = $receipt.printChargeFooterStore($dateTimeStamp, $ref); // apbw 03/10/05 Reprint patch
  132. } // apbw 03/10/05 Reprint patch
  133. $receipt = $receipt."\n\n\n\n\n\n\n"; // apbw 03/10/05 Reprint patch
  134. writeLine($receipt.chr(27).chr(105)); // apbw 03/10/05 Reprint patch
  135. $receipt = ""; // apbw 03/10/05 Reprint patch
  136. $_SESSION["memMsg"] = "";
  137. $_SESSION["memberID"] = "0";
  138. $_SESSION["memType"] = 0;
  139. $_SESSION["percentDiscount"] = 0;
  140. getsubtotals();
  141. }
  142. gohome();
  143. ?>