function couponcode($upc) { $man_id = substr($upc, 3, 5); $fam = substr($upc, 8, 3); $val = substr($upc, -2); $db = pDataConnect(); $query = "select * from couponcodes where code = '" . $val . "'"; $result = sql_query($query, $db); $num_rows = sql_num_rows($result); if ($num_rows == 0) { boxMsg("coupon type unknown<br>please enter coupon<br>manually"); } else { $row = sql_fetch_array($result); $value = $row["Value"]; $qty = $row["Qty"]; if ($fam == "992") { $value = truncate2($value); $_SESSION["couponupc"] = $upc; $_SESSION["couponamt"] = $value; maindisplay("coupondeptsearch.php"); } else { sql_close($db); $fam = substr($fam, 0, 2); $query = "select " . "max(unitPrice) as total, " . "max(department) as department, " . "sum(ItemQtty) as qty, " . "sum(case when trans_status = 'C' then -1 else quantity end) as couponqtty " . "from localtemptrans where substring(upc, 4, 5) = '" . $man_id . "' " . "group by substring(upc, 4, 5)"; $db = tDataConnect(); $result = sql_query($query, $db); $num_rows = sql_num_rows($result); if ($num_rows > 0) { $row = sql_fetch_array($result); if ($row["couponqtty"] < 1) { boxMsg("Coupon already applied<BR>for this item"); } else { $dept = $row["department"]; $act_qty = $row["qty"]; if ($qty <= $act_qty) { if ($value == 0) { $value = -1 * $row["total"]; } $value = truncate2($value); addcoupon($upc, $dept, $value); lastpage(); } else { boxMsg("coupon requires " . $qty . "items<BR>there are only " . $act_qty . " item(s)<BR>in this transaction"); } } } else { boxMsg("product not found<BR>in transaction"); } // sql_close($db); } } }
function ccEntered($entered) { if ($_SESSION["ttlflag"] != 1) { boxMsg("transaction must be totaled before tender can be accepted"); } elseif ($_SESSION["CCintegrate"] != 1) { xBoxMsg("<img src='graphics/redsquare.gif' alt='Red square'>System not initiated<p><font size=-1>Please process card<br />in standalone</font></p>"); } elseif (pinghost($_SESSION["ccServer"]) != 1) { xBoxMsg("<img src='graphics/redsquare.gif' alt='Red square'>Local system offline<P><font size=-1>Please process card<br />in standalone</font></p>"); } elseif (sys_pcc() == 1) { xBoxMsg("<img src='graphics/redsquare.gif' alt='Red square'>Remote system offline<P><font size=-1>Please process card<br />in standalone</font></p>"); } else { $ccValid = ccValid($entered); if ($ccValid == 0 && $_SESSION["ccSwipe"] == "invalid") { // changed the error message since this usually just means a misread, not necessarily an invalid card --atf 5/16/07 xBoxMsg("Card data invalid; scan again or type in manually<p><font size=-1>[clear] to cancel</font></p>"); } elseif ($ccValid == 0 && $_SESSION["ccType"] = "Unsupported") { xBoxMsg("Card type not supported<p><font size=-1>[clear] to cancel</font></p>"); } else { if ($_SESSION["ccAmtEntered"] != 1) { $_SESSION["ccAmt"] = $_SESSION["amtdue"]; } $ccAmt = $_SESSION["ccAmt"]; if(substr($_SESSION['strEntered'],0,1) == 'V'|| substr($_SESSION['strEntered'],0,1) == 'v'){ // added 04/01/05 by CvR process void....not fully implemented $_SESSION["boxMsg"] = "<b>Voiding credit card amount</b><p><font size='-1'>[enter] to continue<br />or [clear] to cancel</font></p>"; } elseif((substr($_SESSION["strEntered"],0,1) == 'f' || substr($_SESSION["strEntered"],0,1) == 'F') && ($ccAmt <= $_SESSION["amtdue"])){ $_SESSION["boxMsg"] = "<b>Forcing $" . truncate2($ccAmt) . "?</b><p><font size='-1'>[enter] to continue <br />or [clear] to cancel</font></b>"; $_SESSION["ccAmtInvalid"] = 0; } elseif(is_numeric($ccAmt) && ($ccAmt <= $_SESSION["amtdue"])) { $_SESSION["boxMsg"] = "<b>Tendering $" . truncate2($ccAmt) . "?</b><p><font size='-1'>[enter] to continue if correct<br />Enter a different amount if incorrect<br />or [clear] to cancel</font></p>"; $_SESSION["ccAmtInvalid"] = 0; } else { $_SESSION["boxMsg"] = "<b>Invalid entry</b><p><font size='-1'>Enter a different amount<br />or [clear] to cancel</font></p>"; $_SESSION["ccAmtInvalid"] = 1; } ccboxMsgscreen(); } } }
function clubCard($intItemNum) { $query = "select * from localtemptrans where trans_id = " . $intItemNum; $connection = tDataConnect(); $result = sql_query($query, $connection); $row = sql_fetch_array($result); $num_rows = sql_num_rows($result); if ($num_rows > 0) { $strUPC = $row["upc"]; $strDescription = $row["description"]; $dblVolSpecial = $row["VolSpecial"]; $dblquantity = -0.5 * $row["quantity"]; $dblTotal = truncate2(-1 * 0.5 * $row["total"]); // invoked truncate2 rounding function to fix half-penny errors apbw 3/7/05 $strCardNo = $_SESSION["memberID"]; $dblDiscount = $row["discount"]; $dblmemDiscount = $row["memDiscount"]; $intDiscountable = $row["discountable"]; $dblUnitPrice = $row["unitPrice"]; $intScale = nullwrap($row["scale"]); if ($row["foodstamp"] != 0) { $intFoodStamp = 1; } else { $intFoodStamp = 0; } $intdiscounttype = nullwrap($row["discounttype"]); if ($row["voided"] == 20) { boxMsg("Discount already taken"); } elseif ($row["trans_type"] == "T" or $row["trans_status"] == "D" or $row["trans_status"] == "V" or $row["trans_status"] == "C") { boxMsg("Item cannot be discounted"); } elseif (strncasecmp($strDescription, "Club Card", 9) == 0) { //----- edited by abpw 2/15/05 ----- boxMsg("Item cannot be discounted"); } elseif ($_SESSION["tenderTotal"] < 0 and $intFoodStamp == 1 and -1 * $dblTotal > $_SESSION["fsEligible"]) { boxMsg("Item already paid for"); } elseif ($_SESSION["tenderTotal"] < 0 and -1 * $dblTotal > $_SESSION["runningTotal"] - $_SESSION["taxTotal"]) { boxMsg("Item already paid for"); } else { // --- added partial item desc to club card description - apbw 2/15/05 --- addItem($strUPC, "Club Card: " . substr($strDescription, 0, 19), "I", "", "J", $row["department"], $dblquantity, $dblUnitPrice, $dblTotal, 0.5 * $row["regPrice"], $intScale, $row["tax"], $intFoodStamp, $dblDiscount, $dblmemDiscount, $intDiscountable, $intdiscounttype, $dblquantity, $row["volDiscType"], $row["volume"], $dblVolSpecial, 0, 0, 0); $update = "update localtemptrans set voided = 20 where trans_id = " . $intItemNum; $connection = tDataConnect(); sql_query($update, $connection); $_SESSION["TTLflag"] = 0; $_SESSION["TTLRequested"] = 0; lastpage(); } } }
extract($row_times); if ($t % 5 == 0) { #Headings: $site1_name = query_one("SELECT SiteName FROM Sites WHERE SiteID='{$site1}'", $connection); $site1_name = truncate2($site1_name, 60); echo "<div class=\"span-8\" style=\"background-color:#CCCCCC;\"><strong>{$site1_name}</strong></div>\n"; if (isset($site2)) { $site2_name = query_one("SELECT SiteName FROM Sites WHERE SiteID='{$site2}'", $connection); $site2_name = truncate2($site2_name, 60); echo "<div class=\"span-8\" style=\"background-color:#CCCCCC;\"><strong>{$site2_name}</strong></div>\n"; } else { echo "<div class=\"span-8\" style=\"background-color:#CCCCCC;\"> </div>\n"; } if (isset($site3)) { $site3_name = query_one("SELECT SiteName FROM Sites WHERE SiteID='{$site3}'", $connection); $site3_name = truncate2($site3_name, 60); echo "<div class=\"span-8 last\" style=\"background-color:#CCCCCC;\"><strong>{$site3_name}</strong></div>\n"; } else { echo "<div class=\"span-8 last\" style=\"background-color:#CCCCCC;\"> </div>\n"; } } $this_time = $Time . ":%"; #Column 1 for site 1 echo "<div class=\"span-8\">"; $query1 = "SELECT * from Sounds WHERE SiteID={$site1} AND Time LIKE '{$this_time}' AND Date='{$date}' AND SoundStatus!='9' ORDER BY Time LIMIT 1"; $result1 = mysqli_query($connection, $query1) or die(mysqli_error($connection)); $nrows1 = mysqli_num_rows($result1); if ($nrows1 == 1) { $row1 = mysqli_fetch_array($result1); extract($row1); #Check if there are images
function upcscanned($entered) { $hitareflag = 0; $entered = str_replace(".", " ", $entered); if (strlen($entered) == 0 || !$entered) { lastpage(); } else { if ($_SESSION["quantity"] == 0 && $_SESSION["multiple"] == 0) { $quantity = 1; } else { $quantity = $_SESSION["quantity"]; } } $scaleprice = 0; if (substr($entered, 0, 1) == 0 && strlen($entered) == 7) { $p6 = substr($entered, -1); if ($p6 == 0) { $entered = substr($entered, 0, 3) . "00000" . substr($entered, 3, 3); } elseif ($p6 == 1) { $entered = substr($entered, 0, 3) . "10000" . substr($entered, 3, 3); } elseif ($p6 == 2) { $entered = substr($entered, 0, 3) . "20000" . substr($entered, 3, 3); } elseif ($p6 == 3) { $entered = substr($entered, 0, 4) . "00000" . substr($entered, 4, 2); } elseif ($p6 == 4) { $entered = substr($entered, 0, 5) . "00000" . substr($entered, 5, 1); } else { $entered = substr($entered, 0, 6) . "0000" . $p6; } } if (strlen($entered) == 13 && substr($entered, 0, 1) != 0) { $upc = "0" . substr($entered, 0, 12); } else { $upc = substr("0000000000000" . $entered, -13); } if (substr($upc, 0, 3) == "002") { $scaleprice = truncate2(substr($upc, -4) / 100); $upc = substr($upc, 0, 8) . "00000"; } $query = "select * from products where upc = '" . $upc . "' AND inUse = 1"; $db = pDataConnect(); $result = sql_query($query, $db); $num_rows = sql_num_rows($result); $row = sql_fetch_array($result); $normal_price = $row["normal_price"]; $special_price = $row["special_price"]; $cost = 0; $deposit = $row["deposit"]; $dept = $row["department"]; if ($num_rows == 0 && substr($upc, 0, 3) != "005") { $fconn = tDataconnect(); $datetimestamp = strftime("%Y-%m-%d %H:%M:%S %p", time()); $inserterror = "insert into failedscans select " . $upc . " as upc, " . $_SESSION["laneno"] . " as lane_no, " . $_SESSION["CashierNo"] . " as emp_no, " . $_SESSION["transno"] . " as trans_no, " . "'" . $datetimestamp . "' as fdate"; mysql_query($inserterror, $fconn); boxMsg($upc . "<br /><b>is not a valid item</b>"); } elseif ($num_rows == 0 && substr($upc, 0, 3) == "005") { couponcode($upc); } elseif (($dept == 19 || $dept == 20) && $_SESSION["store"] == "rvm" && $_SESSION["msgrepeat"] == 0 && $_SESSION["carded"] == 0) { if ($_SESSION["bdaystatus"] == 99) { $boxMsg = "<b>Enter date of birth from valid ID</b><br />in the form mmddyyyy<p><font size=-1>[Clear] to cancel</font></p>"; } if ($_SESSION["bdaystatus"] == -1) { $boxMsg = "<b>Invalid date of birth</b><br />re-enter in the form mmddyyyy<p><font size=-1>[Clear] to cancel</font></p>"; } if ($_SESSION["bdaystatus"] == 0) { $boxMsg = "<b>Sales of item declined</b><p><font size=-1>[Clear] to cancel</font></p>"; } $_SESSION["boxMsg"] = $boxMsg; bdBoxMsgScreen(); } elseif ($row["scale"] != 0 && $_SESSION["weight"] == 0 && $_SESSION["quantity"] == 0) { if ($_SESSION["wgtRequested"] == 0) { $_SESSION["wgtRequested"] = 1; lastpage(); echo "<script type=\"text/javascript\">\n" . "lockScreen = setTimeout('document.forms[0].elements[0].value = \"" . $_SESSION["strEntered"] . "\"; document.forms[0].submit();', 700)\n" . "</script>"; } else { $_SESSION["SNR"] = 1; boxMsg("please put item on scale"); $_SESSION["wgtRequested"] = 0; } } elseif ($row["scale"] != 0 && $_SESSION["scale"] == 0) { $_SESSION["waitforScale"] = 1; $_SESSION["SNR"] = 1; lastpage(); } elseif ($row["scale"] == 0 && (int) $_SESSION["quantity"] != $_SESSION["quantity"] && $_SESSION["fractions"] != 1) { boxMsg("fractional quantity cannot be accepted for this item"); } elseif ($_SESSION["itemDiscount"] < 0 || $_SESSION["itemDiscount"] > 65) { xboxMsg("item cannot be<br />discounted at " . $_SESSION["itemDiscount"] . "%"); $_SESSION["itemDiscount"] = 0; } else { $mixMatch = 0; $qttyEnforced = $row["qttyEnforced"]; if ($qttyEnforced == 1 && $_SESSION["multiple"] == 0 && $_SESSION["msgrepeat"] == 0) { qttyscreen(); } else { $_SESSION["qttyvalid"] = 1; } if ($_SESSION["qttyvalid"] != 1) { sql_close($db); } else { $upc = $row["upc"]; $description = $row["description"]; $description = str_replace("'", "", $description); $description = str_replace(",", "", $description); $transType = "I"; $transsubType = "CA"; $department = $row["department"]; $unitPrice = $normal_price; $regPrice = $normal_price; $CardNo = $_SESSION["memberID"]; if ($row["scale"] != 0) { $scale = 1; } else { $scale = 0; } if ($row["tax"] != 0 && $_SESSION["toggletax"] == 0) { $tax = $row["tax"]; } elseif ($row["tax"] != 0 && $_SESSION["toggletax"] != 0) { $tax = 0; $_SESSION["toggletax"] = 0; } elseif ($row["tax"] == 0 && $_SESSION["toggletax"] != 0) { $tax = $_SESSION["toggletax"]; $_SESSION["toggletax"] = 0; } else { $tax = 0; } if ($row["foodstamp"] != 0 && $_SESSION["togglefoodstamp"] == 0) { $foodstamp = 1; } elseif ($row["foodstamp"] != 0 && $_SESSION["togglefoodstamp"] == 1) { $foodstamp = 0; $_SESSION["togglefoodstamp"] = 0; } elseif ($row["foodstamp"] == 0 && $_SESSION["togglefoodstamp"] == 1) { $foodstamp = 1; $_SESSION["togglefoodstamp"] = 0; } else { $foodstamp = 0; } if ($scale == 1) { $hitareflag = 0; if ($_SESSION["quantity"] != 0) { $quantity = $_SESSION["quantity"] - $_SESSION["tare"]; } else { $quantity = $_SESSION["weight"] - $_SESSION["tare"]; } if ($quantity <= 0) { $hitareflag = 1; } $_SESSION["tare"] = 0; } $discounttype = nullwrap($row["discounttype"]); $discountable = $row["discount"]; $sale_price = $row["special_price"]; if ($_SESSION["itemDiscount"] > 0 && $_SESSION["itemDiscount"] < 65 && $discounttype != 0) { $discountable = 1; $special_price = number_format($sale_price * (100 - $_SESSION["itemDiscount"]) / 100, 2); $_SESSION["itemDiscount"] = 0; } elseif ($_SESSION["itemDiscount"] > 0 && $_SESSION["itemDiscount"] < 65) { $discountable = 1; $discounttype = 1; $special_price = number_format($normal_price * (100 - $_SESSION["itemDiscount"]) / 100, 2); $_SESSION["itemDiscount"] = 0; } if ($_SESSION["toggleDiscountable"] == 1) { $_SESSION["toggleDiscountable"] = 0; if ($discountable != 0) { $discountable = 0; } else { $discountable = 1; } } if ($_SESSION["nd"] == 1 && $discountable == 7) { $discountable = 3; $_SESSION["nd"] = 0; } if ($discounttype == 2 || $discounttype == 4) { $memDiscount = truncate2($normal_price * $quantity) - truncate2($special_price * $quantity); $discount = 0; $unitPrice = $normal_price; } elseif ($discounttype == 1) { $unitPrice = $special_price; $unitDiscount = $normal_price - $special_price; $discount = $unitDiscount * $quantity; $memDiscount = 0; } else { $unitPrice = $normal_price; $discount = 0; $memDiscount = 0; } if ($_SESSION["isMember"] == 1 && $discounttype == 2) { $unitPrice = nullwrap($special_price); } if ($_SESSION["isStaff"] != 0 && $discounttype == 4) { $unitPrice = nullwrap($special_price); } if ($_SESSION["casediscount"] > 0 && $_SESSION["casediscount"] <= 100) { $casediscount = (100 - $_SESSION["casediscount"]) / 100; $unitPrice = $casediscount * $unitPrice; } //-------------Mix n Match ------------------------------------- $matched = 0; $VolSpecial = nullwrap($row["groupprice"]); $volDiscType = nullwrap($row["pricemethod"]); $volume = nullwrap($row["quantity"]); if ($row["advertised"] != 0) { if ($row["discounttype"] == 2 && $_SESSION["isMember"] == 1 || $row["discounttype"] != 2) { $VolSpecial = nullwrap($row["specialgroupprice"]); $volDiscType = nullwrap($row["specialpricemethod"]); $volume = nullwrap($row["specialquantity"]); } } if ($volDiscType && $volDiscType >= 1) { // If item is on volume discount if (!$row["mixmatchcode"] || $row["mixmatchcode"] == 0) { $mixMatch = 0; $queryt = "select sum(ItemQtty - matched) as mmqtty from localtemptrans where " . "upc = '" . $row["upc"] . "' group by upc"; } else { $mixMatch = $row["mixmatchcode"]; $queryt = "select sum(ItemQtty - matched) as mmqtty, mixMatch from localtemptrans " . "where mixMatch = '" . $mixMatch . "' group by mixMatch"; } if ($volDiscType == 1) { $unitPrice = truncate2($VolSpecial / $volume); } $voladj = $VolSpecial - ($volume - 1) * $unitPrice; // one at special price $newmm = (int) ($quantity / $volume); // number of complete sets $dbt = tDataConnect(); $resultt = sql_query($queryt, $dbt); $num_rowst = sql_num_rows($resultt); if ($num_rowst > 0) { $rowt = sql_fetch_array($resultt); $mmqtty = $rowt["mmqtty"]; // number not in complete sets in localtemptrans } else { $mmqtty = 0; } $newmmtotal = $mmqtty + $quantity % $volume; $na = $newmmtotal % $volume; $quantity = $quantity % $volume; if ($newmm >= 1) { addItem($upc, $description, "I", "", "", $department, $cost, $newmm, truncate2($VolSpecial), truncate2($newmm * $VolSpecial), truncate2($VolSpecial), $scale, $tax, $foodstamp, $discount, $memDiscount, $discountable, $discounttype, $volume * $newmm, $volDiscType, $volume, $VolSpecial, $mixMatch, $volume * $newmm, 0, 0, ''); $newmm = 0; $_SESSION["qttyvalid"] = 0; } if ($newmmtotal >= $volume) { addItem($upc, $description, "I", "", "", $department, $cost, 1, $voladj, $voladj, $voladj, $scale, $tax, $foodstamp, $discount, $memDiscount, $discountable, $discounttype, 1, $volDiscType, $volume, $VolSpecial, $mixMatch, $volume, 0, 0, ''); $quantity = $quantity - 1; $newmmtotal = 0; $_SESSION["qttyvalid"] = 0; } sql_close($dbt); } $total = $unitPrice * $quantity; if (substr($upc, 0, 3) == "002" and $discounttype != 2) { $unitPrice = truncate2($scaleprice); $regPrice = $total; $total = $unitPrice * $quantity; } $total = truncate2($total); $unitPrice = truncate2($unitPrice); if ($upc == "0000000008010" && $_SESSION["msgrepeat"] == 0) { $_SESSION["endorseType"] = "giftcert"; $_SESSION["tenderamt"] = $total; $_SESSION["boxMsg"] = "<b>" . $total . " gift certificate</b><br />insert document<br />press [enter] to endorse<p><font size='-1'>[clear] to cancel</font></p>"; boxMsgscreen(); } elseif ($upc == "0000000008006" && $_SESSION["msgrepeat"] == 0) { $_SESSION["endorseType"] = "stock"; $_SESSION["tenderamt"] = $total; $_SESSION["boxMsg"] = "<B>" . $total . " stock payment</B><br />insert form<br />press [enter] to endorse<P><FONT size='-1'>[clear] to cancel</FONT>"; boxMsgscreen(); } elseif ($upc == "0000000008011" && $_SESSION["msgrepeat"] == 0) { $_SESSION["endorseType"] = "classreg"; $_SESSION["tenderamt"] = $total; $_SESSION["boxMsg"] = "<b>" . $total . " class registration</b><br />insert form<br />press [enter] to endorse<p><font size='-1'>[clear] to cancel</font></p>"; boxMsgscreen(); } elseif ($hitareflag == 1) { boxMsg("item weight must be greater than tare weight"); } else { if ($quantity != 0) { $qtty = $quantity; if ($scale == 1) { goodBeep(); } if ($_SESSION["casediscount"] > 0) { addcdnotify(); $discounttype = 3; $_SESSION["casediscount"] = 0; $quantity = 1; $unitPrice = $total; $regPrice = $total; } if ($_SESSION["ddNotify"] == 1 && $_SESSION["itemPD"] == 10) { $_SESSION["itemPD"] = 0; $discountable = 7; } if ($_SESSION["ddNotify"] == 1 && $discountable == 7) { $intvoided = 22; } else { $intvoided = 0; } addItem($upc, $description, "I", " ", " ", $department, $cost, $quantity, $unitPrice, $total, $regPrice, $scale, $tax, $foodstamp, $discount, $memDiscount, $discountable, $discounttype, $qtty, $volDiscType, $volume, $VolSpecial, $mixMatch, $matched, $intvoided, 0, ''); $_SESSION["msgrepeat"] = 0; $_SESSION["qttyvalid"] = 0; } } if ($deposit && $deposit > 0) { addDeposit($quantity, $deposit, $foodstamp); } if ($tax == 1) { $_SESSION["istaxable"] = 1; } else { $_SESSION["istaxable"] = 0; $_SESSION["voided"] = 0; } if ($discounttype == 1) { $_SESSION["ondiscount"] = 1; $_SESSION["voided"] = 2; adddiscount($discount); } elseif ($discounttype == 2 && $_SESSION["isMember"] == 1) { $_SESSION["ondiscount"] = 1; $_SESSION["voided"] = 2; addmemspecialmsg(); } elseif ($discounttype == 4 && $_SESSION["isStaff"] != 0) { $_SESSION["ondiscount"] = 1; $_SESSION["voided"] = 2; adddiscount($memDiscount); } else { $_SESSION["ondiscount"] = 0; $_SESSION["voided"] = 0; } if ($_SESSION["tare"] != 0) { $_SESSION["tare"] = 0; } $_SESSION["alert"] = ""; $_SESSION["ttlflag"] = 0; $_SESSION["ttlrequested"] = 0; $_SESSION["fntlflag"] = 0; $_SESSION["togglefoodstamp"] = 0; $_SESSION["toggletax"] = 0; $_SESSION["repeat"] = 1; setglobalflags(0); if ($hitareflag != 1) { lastpage(); } } } $_SESSION["quantity"] = 0; $_SESSION["itemPD"] = 0; }
function voidupc($upc) { $lastpageflag = 1; $deliflag = 0; if (strpos($upc, "*") && (strpos($upc, "**") || strpos($upc, "*") == 0 || strpos($upc, "*") == strlen($upc) - 1)) { $upc = "stop"; } elseif (strpos($upc, "*")) { $voidupc = explode("*", $upc); if (!is_numeric($voidupc[0])) { $upc = "stop"; } else { $quantity = $voidupc[0]; $upc = $voidupc[1]; $weight = 0; } } elseif (!is_numeric($upc) && !strpos($upc, "DP")) { $upc = "stop"; } else { $quantity = 1; $weight = $_SESSION["weight"]; } if (is_numeric($upc)) { $upc = substr("0000000000000" . $upc, -13); if (substr($upc, 0, 3) == "002" && substr($upc, -5) != "00000") { $scaleprice = substr($upc, 10, 4) / 100; $upc = substr($upc, 0, 8) . "0000"; $deliflag = 1; } elseif (substr($upc, 0, 3) == "002" && substr($upc, -5) == "00000") { $scaleprice = $_SESSION["scaleprice"]; $deliflag = 1; } } if ($upc == "stop") { inputUnknown(); } else { $db = tDataConnect(); if ($_SESSION["discounttype"] == 3) { $query = "select sum(quantity) as voidable, max(scale), as scale, max(volDiscType) as volDiscType " . "from localtemptrans where upc = '" . $upc . "' and discounttype = 3 and unitPrice = " . $_SESSION["caseprice"] . " group by upc"; } elseif ($deliflag == 0) { $query = "select sum(ItemQtty) as voidable, sum(quantity) as vquantity, max(scale) as scale, " . "max(volDiscType) as volDiscType from localtemptrans where upc = '" . $upc . "' and discounttype <> 3 group by upc, discounttype"; } else { $query = "select sum(ItemQtty) as voidable, sum(quantity) as vquantity, max(scale) as scale, " . "max(volDiscType) as volDiscType from localtemptrans where upc = '" . $upc . "' and unitPrice = " . $scaleprice . " and discounttype <> 3 group by upc"; } if ($_SESSION["ddNotify"] == 1) { $query = "select sum(ItemQtty) as voidable, sum(quantity) as vquantity, max(scale) as scale, " . "max(volDiscType) as volDiscType from localtemptrans where upc = '" . $upc . "' and discounttype <> 3 and discountable = " . $_SESSION["discountable"] . " group by upc, discounttype, discountable"; } $result = sql_query($query, $db); $num_rows = sql_num_rows($result); if ($num_rows == 0) { boxMsg("Item not found"); } else { $row = sql_fetch_array($result); if ($row["scale"] == 1 && $weight > 0) { $quantity = $weight - $_SESSION["tare"]; $_SESSION["tare"] = 0; } $volDiscType = $row["volDiscType"]; $voidable = nullwrap($row["voidable"]); $VolSpecial = 0; $volume = 0; $scale = nullwrap($row["scale"]); if ($voidable == 0 && $quantity == 1) { boxMsg("Items already voided"); } elseif ($voidable == 0 && $quantity > 1) { boxMsg("Items already voided"); } elseif ($scale == 1 && $quantity < 0) { boxMsg("tare weight cannot be greater than item weight"); } elseif ($voidable < $quantity && $row["scale"] == 1) { $message = "Void request exceeds<br />weight of item rung in<p><b>You can void up to " . $row["voidable"] . " lb</b></p>"; boxMsg($message); } elseif ($voidable < $quantity) { $message = "Void request exceeds<br />number of items rung in<p><b>You can void up to " . $row["voidable"] . "</b></p>"; boxMsg($message); } else { unset($result); //--------------------------------Void Item---------------------------- if ($_SESSION["discounttype"] == 3) { $query_upc = "select * from localtemptrans where upc = '" . $upc . "' and discounttype = 3 and unitPrice = " . $_SESSION["caseprice"]; } elseif ($deliflag == 0) { $query_upc = "select * from localtemptrans where upc = '" . $upc . "' and discounttype <> 3"; } else { $query_upc = "select * from localtemptrans where upc = '" . $upc . "' and unitPrice = " . $scaleprice; } $_SESSION["discounttype"] = 9; $result = sql_query($query_upc, $db); $row = sql_fetch_array($result); $ItemQtty = $row["ItemQtty"]; $foodstamp = nullwrap($row["foodstamp"]); $discounttype = nullwrap($row["discounttype"]); $mixMatch = nullwrap($row["mixMatch"]); if ($_SESSION["isMember"] != 1 && $row["discounttype"] == 2 || $_SESSION["isStaff"] == 0 && $row["discounttype"] == 4) { $unitPrice = $row["regPrice"]; } elseif (($_SESSION["isMember"] == 1 && $row["discounttype"] == 2 || $_SESSION["isStaff"] != 0 && $row["discounttype"] == 4) && $row["unitPrice"] == $row["regPrice"]) { $db_p = pDataConnect(); $query_p = "select * from products where upc = '" . $upc . "'"; $result_p = sql_query($query_p, $db_p); $row_p = sql_fetch_array($result_p); $unitPrice = $row_p["special_price"]; sql_close($db_p); } else { $unitPrice = $row["unitPrice"]; } $discount = -1 * $row["discount"]; $memDiscount = -1 * $row["memDiscount"]; $discountable = $row["discountable"]; $cost = 0; if ($_SESSION["ddNotify"] == 1) { $discountable = $_SESSION["discountable"]; } //----------------------mix match--------------------- if ($volDiscType >= 1) { $db_mm = tDataConnect(); $query_mm = "select sum(ItemQtty) as mmqtty from localtemptrans where mixMatch = " . $mixMatch; $result_mm = sql_query($query_mm, $db_mm); $row_mm = sql_fetch_array($result_mm); $mmqtty = nullwrap($row_mm["mmqtty"]); sql_close($db_mm); $db_pq = pDataConnect(); $query_pq = "select * from products where upc = '" . $upc . "'"; $result_pq = sql_query($query_pq, $db_pq); $row_pq = sql_fetch_array($result_pq); if ($volDiscType == 1) { $unitPrice = truncate2($row_pq["groupprice"] / $row_pq["quantity"]); } elseif ($discounttype == 1) { $unitPrice = $row_pq["special_price"]; $VolSpecial = nullwrap($row_pq["specialgroupprice"]); } else { $unitPrice = $row_pq["normal_price"]; $VolSpecial = nullwrap($row_pq["groupprice"]); } if ($row_pq["advertised"] == 0) { $volume = nullwrap($row_pq["quantity"]); } else { $volume = nullwrap($row_pq["specialquantity"]); } sql_close($db_pq); $volmulti = (int) ($quantity / $volume); $vmremainder = $quantity % $volume; if ($mixMatch == 0) { $mm = (int) ($voidable / $volume); $mmremainder = $voidable % $volume; } else { $mm = (int) ($mmqtty / $volume); $mmremainder = $mmqtty % $volume; } if ($volmulti > 0) { addItem($upc, $row["description"], $row["trans_type"], $row["trans_subtype"], "V", $row["department"], $cost, -1 * $volmulti, $VolSpecial, -1 * $volmulti * $VolSpecial, $VolSpecial, 0, $row["tax"], $foodstamp, $discount, $memDiscount, $discountable, $discounttype, -1 * $volmulti * $volume, $volDiscType, $volume, $VolSpecial, $mixMatch, -1 * $volume * $volmulti, 1, 0, ''); $quantity = $vmremainder; } if ($vmremainder > $mmremainder) { $voladj = $row["VolSpecial"] - $unitPrice * ($volume - 1); addItem($upc, $row["description"], $row["trans_type"], $row["trans_subtype"], "V", $row["department"], $cost, -1, $voladj, -1 * $voladj, $voladj, 0, $row["tax"], $foodstamp, $discount, $memDiscount, $discountable, $discounttype, -1, $volDiscType, $volume, $VolSpecial, $mixMatch, -1 * $volume, 1, 0, ''); $quantity = $quantity - 1; } } $quantity = -1 * $quantity; $total = truncate2($quantity * $unitPrice); $CardNo = $_SESSION["memberID"]; $discounttype = nullwrap($row["discounttype"]); if ($discounttype == 3) { $quantity = -1 * $ItemQtty; } if ($_SESSION["tenderTotal"] < 0 && $foodstamp == 1 && -1 * $total > $_SESSION["fsEligible"]) { boxMsg("Item already paid for"); $lastpageflag = 0; } elseif ($_SESSION["tenderTotal"] < 0 && -1 * $total > $_SESSION["runningTotal"] - $_SESSION["taxTotal"]) { boxMsg("Item already paid for"); $lastpageflag = 0; } elseif ($quantity != 0) { addItem($upc, $row["description"], $row["trans_type"], $row["trans_subtype"], "V", $row["department"], $cost, $quantity, $unitPrice, $total, $row["regPrice"], $scale, $row["tax"], $foodstamp, $discount, $memDiscount, $discountable, $discounttype, $quantity, $volDiscType, $volume, $VolSpecial, $mixMatch, 0, 1, 0, ''); if ($row["trans_type"] != "T") { $_SESSION["ttlflag"] = 0; $_SESSION["ttlrequested"] = 0; $_SESSION["discounttype"] = 0; } } if ($lastpageflag == 1) { lastpage(); } else { $lastpageflag = 1; } } } } }
for ($i = 0; $i < $num_rows; $i++) { $row = sql_fetch_array($result); if ($row["advertised"] != 0) { $price = $row["special_price"]; } else { $price = $row["normal_price"]; } if ($row["scale"] != 0) { $Scale = "S"; } else { $Scale = " "; } if (!$price) { $price = "unKnown"; } else { $price = truncate2($price); } echo "<OPTION value='" . $row["upc"] . "' " . $selected . ">" . substr($row["upc"], 7) . " -- " . $row["description"] . " ---- [" . $price . "] " . $Scale . "\n"; $selected = ""; } echo "</SELECT>\n" . "</FORM>\n" . "</TD>\n" . "<TD height='295' width='80' valign='center'>\n" . "<FONT face='arial' color='#004080'><B>[c] to Cancel</B></FONT>" . "</TD>\n" . "</TR></TABLE>\n"; } sql_close($db); } $_SESSION["scan"] = "noScan"; $_SESSION["beep"] = "noBeep"; printfooter(); ?> </BODY> </HTML>
echo "\n<option value=\"{$SiteID}\">{$SiteName} ({$from_date} - {$to_date})</option>"; } echo "</select> (Required)"; $sites = query_several("SELECT Sites.SiteID,Sites.SiteName FROM Sites,Sounds WHERE Sites.SiteID=Sounds.SiteID \n\t\tAND Sounds.SoundStatus!='9' {$qf_check} GROUP BY SiteName", $connection); $nrows_sites = mysqli_num_rows($sites); echo "<p style=\"margin-left:10px;\">Site 2:</p>\n\t\t<select name=\"site2\" class=\"ui-state-default ui-corner-all\">\n\t\t<option></option>"; for ($sc = 0; $sc < $nrows_sites; $sc++) { $row_site = mysqli_fetch_array($sites); extract($row_site); $SiteName = truncate2($SiteName, 60); $from_date = query_one("SELECT DATE_FORMAT(Date,'%d-%b-%Y') AS Date_f from Sounds WHERE SiteID='{$SiteID}' \n\t\t\tAND Sounds.SoundStatus!='9' {$qf_check} ORDER BY Date ASC LIMIT 1", $connection); $to_date = query_one("SELECT DATE_FORMAT(Date,'%d-%b-%Y') AS Date_f from Sounds WHERE SiteID='{$SiteID}' \n\t\t\tAND Sounds.SoundStatus!='9' {$qf_check} ORDER BY Date DESC LIMIT 1", $connection); echo "\n<option value=\"{$SiteID}\">{$SiteName} ({$from_date} - {$to_date})</option>"; } echo "</select>"; $sites = query_several("SELECT Sites.SiteID,Sites.SiteName FROM Sites,Sounds WHERE Sites.SiteID=Sounds.SiteID \n\t\tAND Sounds.SoundStatus!='9' {$qf_check} GROUP BY SiteName", $connection); $nrows_sites = mysqli_num_rows($sites); echo "<p style=\"margin-left:10px;\">Site 3:</p>\n\t\t<select name=\"site3\" class=\"ui-state-default ui-corner-all\">\n\t\t<option></option>"; for ($sc = 0; $sc < $nrows_sites; $sc++) { $row_site = mysqli_fetch_array($sites); extract($row_site); $SiteName = truncate2($SiteName, 60); $from_date = query_one("SELECT DATE_FORMAT(Date,'%d-%b-%Y') AS Date_f from Sounds WHERE SiteID='{$SiteID}' \n\t\t\tAND Sounds.SoundStatus!='9' {$qf_check} ORDER BY Date ASC LIMIT 1", $connection); $to_date = query_one("SELECT DATE_FORMAT(Date,'%d-%b-%Y') AS Date_f from Sounds WHERE SiteID='{$SiteID}' \n\t\t\tAND Sounds.SoundStatus!='9' {$qf_check} ORDER BY Date DESC LIMIT 1", $connection); echo "\n<option value=\"{$SiteID}\">{$SiteName} ({$from_date} - {$to_date})</option>"; } echo "</select>"; echo "<input type=submit value=\" Show comparison \" class=\"fg-button ui-state-default ui-corner-all\">\n\t\t</form>"; } else { echo "<p>There are no sounds with dates in the database.</p>"; }
function needBasedDisc($strl) { if ($_SESSION["needBasedDisc"] != 0) { if (!is_numeric($strl) || $strl > 100 || $strl < 0) { boxMsg("discount invalid"); } else { $query = "select sum(total) as total from localtemptrans where upc = '0000000008005' group by upc"; $db = tDataConnect(); $result = sql_query($query, $db); $num_rows = sql_num_rows($result); if ($num_rows == 0) { $couponTotal = 0; } else { $row = sql_fetch_array($result); $couponTotal = nullwrap($row["total"]); } if ($couponTotal == 0 || $strl == 0) { sql_query("update localtemptrans set percentDiscount = " . $strl, $db); // ------------ NBD gets its own ttl() function. cuz it's special. -------------- $_SESSION["ttlrequested"] = 1; if ($_SESSION["memberID"] == "0") { maindisplay("memsearch.php"); } else { if ($_SESSION["isMember"] == 1) { $query = "INSERT into localtemptrans (datetime, register_no, emp_no, trans_no, upc, description, trans_type, trans_subtype, trans_status, department, quantity, scale, unitPrice, total, regPrice, tax, foodstamp, discount, memDiscount, discountable, discounttype, voided, percentDiscount, ItemQtty, volDiscType, volume, VolSpecial, mixMatch, matched, card_no) select datetime, register_no, emp_no, trans_no, upc, description, trans_type, trans_subtype, trans_status, department, quantity, scale, unitPrice, total, regPrice, tax, foodstamp, discount, memDiscount, discountable, discounttype, voided, percentDiscount, ItemQtty, volDiscType, volume, VolSpecial, mixMatch, matched, card_no from memdiscountadd"; } else { $query = "INSERT into localtemptrans (datetime, register_no, emp_no, trans_no, upc, description, trans_type, trans_subtype, trans_status, department, quantity, scale, unitPrice, total, regPrice, tax, foodstamp, discount, memDiscount, discountable, discounttype, voided, percentDiscount, ItemQtty, volDiscType, volume, VolSpecial, mixMatch, matched, card_no) select datetime, register_no, emp_no, trans_no, upc, description, trans_type, trans_subtype, trans_status, department, quantity, scale, unitPrice, total, regPrice, tax, foodstamp, discount, memDiscount, discountable, discounttype, voided, percentDiscount, ItemQtty, volDiscType, volume, VolSpecial, mixMatch, matched, card_no from memdiscountremove"; } if ($_SESSION["isStaff"] != 0) { $query2 = "INSERT into localtemptrans (datetime, register_no, emp_no, trans_no, upc, description, trans_type, trans_subtype, trans_status, department, quantity, scale, unitPrice, total, regPrice, tax, foodstamp, discount, memDiscount, discountable, discounttype, voided, percentDiscount, ItemQtty, volDiscType, volume, VolSpecial, mixMatch, matched, card_no) select datetime, register_no, emp_no, trans_no, upc, description, trans_type, trans_subtype, trans_status, department, quantity, scale, unitPrice, total, regPrice, tax, foodstamp, discount, memDiscount, discountable, discounttype, voided, percentDiscount, ItemQtty, volDiscType, volume, VolSpecial, mixMatch, matched, card_no from staffdiscountadd"; } else { $query2 = "INSERT into localtemptrans (datetime, register_no, emp_no, trans_no, upc, description, trans_type, trans_subtype, trans_status, department, quantity, scale, unitPrice, total, regPrice, tax, foodstamp, discount, memDiscount, discountable, discounttype, voided, percentDiscount, ItemQtty, volDiscType, volume, VolSpecial, mixMatch, matched, card_no) select datetime, register_no, emp_no, trans_no, upc, description, trans_type, trans_subtype, trans_status, department, quantity, scale, unitPrice, total, regPrice, tax, foodstamp, discount, memDiscount, discountable, discounttype, voided, percentDiscount, ItemQtty, volDiscType, volume, VolSpecial, mixMatch, matched, card_no from staffdiscountremove"; } $mconn = tDataConnect(); $result = sql_query($query, $mconn); $result2 = sql_query($query2, $mconn); $_SESSION["ttlflag"] = 1; setglobalvalue("ttlflag", 1); getsubtotals(); if ($strl > 0) { $discountAmt = truncate2(-1 * ($_SESSION["discountableTotal"] * ($_SESSION["needBasedDisc"] / 100))); addItem($_SESSION["needBasedDisc"] . "FF", $_SESSION["needBasedDisc"] . "% Food For All Discount", "I", "", "C", 0, 0, 1, $discountAmt, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 10, 0, ''); } $amtDue = str_replace(",", "", $_SESSION["amtdue"]); addItem("", "Discount Amt: " . $discountAmt . ", Tax " . truncate2($_SESSION["taxTotal"]), "C", "", "D", 0, 0, 0, $amtDue, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, ''); if ($_SESSION["fntlflag"] == 1) { addItem("", "Foodstamps Eligible", "", "", "D", 0, 0, 0, truncate2($_SESSION["fsEligible"]), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, ''); } } // ------------ end NBDs special ttl() function ------------------ $_SESSION["repeat"] = 0; } lastpage(); } } else { inputUnknown(); } }
function ccXML() { $inxUploaded = 0; //$connect = pDataConnect(); // no longer used? --atf 5/24/07 // cache filenames $remote_inx = remote_inx(); $remote_oux = remote_oux(); $local_inx = local_inx(); // check if PCCharge has both #.inx and #.pro (for any #, not just CashierNo) -- stuck queue, alert FEC --atf 5/24/07 // also note a new return value for ccXML(): -1 means stuck-queue, 0 means some other file copy error $testcmd = "for %f in (\\" . $_SESSION["ccServer"] . "\\" . $_SESSION["ccShare"] . "\\temp\\*.pro) do @if exist \"\\" . $_SESSION["ccServer"] . "\\" . $_SESSION["ccShare"] . "\\temp\\%%~nf.inx\" echo 1"; $teststuck = shell_exec($testcmd); if ($teststuck != "") { return -1; } // end stuck-queue-check $input = $_SESSION["ccSwipe"]; $transno = ccTicket(); $amountIn = $_SESSION["ccAmt"]; $aCCInput = explode("=", $input); // ***** CvR 09/22/05 test for forced transactions ***** END // $input comes from SESSION[ccSwipe] which has track2 data: these characters could not be there, and all digits up to '=' are the card num --atf 5/24/07 $CC = $aCCInput[0]; /* if(substr($input,0,1) == 'F' || substr($input,0,1) == 'f'){ $CC = substr($aCCInput[0], -17); }else{ $CC = substr($aCCInput[0], -16); } */ $expYear = substr($aCCInput[1], 0, 2); $expMonth = substr($aCCInput[1], 2, 2); //-----added 03/31/05 CvR if ($amountIn > 0) { $command = "1"; //action code for transaction sale = 1 } else { $command = "2"; //action code for return = 2 } //----- // in the PCCharge DevKit manual, 'MANUAL_FLAG' is defined as '0=manual, 1=swiped' --atf 5/18/07 $manual = 1; if ($_SESSION["ccManual"] != 0) { $manual = 0; $_SESSION["ccManual"] = 0; } $expDate = $expMonth . $expYear; //set expDate $present = 1; //card present $proc = 'BPAS'; //processor (will be set to CCRD when done testing) $TID = merchantNum(); //merchant ID for processor $user = $_SESSION["CashierNo"]; $trackII = $_SESSION["ccSwipe"]; $amount = truncate2(abs($amountIn)); // $string_out creates the string that will be saved to the *.inx file // of the XML format that PC Charge expects // Note: ref to x-schema requires specific order sequence // could not resolve 'Incomplete Trans' errors; last resort, just turn off XML validation --atf 5/18/07 //'<XML_FILE xmlns="x-schema:.\dtd\stnd.xdr"> $string_out = '<XML_FILE> <XML_REQUEST> <USER_ID>' . $user . '</USER_ID> <COMMAND>' . $command . '</COMMAND> <PROCESSOR_ID>' . $proc . '</PROCESSOR_ID> <MERCH_NUM>' . $TID . '</MERCH_NUM> <ACCT_NUM>' . $CC . '</ACCT_NUM> <EXP_DATE>' . $expDate . '</EXP_DATE> <MANUAL_FLAG>' . $manual . '</MANUAL_FLAG> <TRANS_AMOUNT>' . $amount . '</TRANS_AMOUNT>'; if ($manual == 1) { // counter-intuitive: manual==1 means swiped, not manual, so pass the track data --atf 5/24/07 $string_out .= ' <TRACK_DATA>' . $trackII . '</TRACK_DATA>'; } $string_out .= ' <TICKET_NUM>' . $transno . '</TICKET_NUM> <PRESENT_FLAG>1</PRESENT_FLAG> </XML_REQUEST> </XML_FILE> '; //------added 04/01/05 Tak & CvR-----provide for voiding CC entry on receipt if (substr($input, 0, 1) == 'V' || substr($input, 0, 1) == 'v') { $troutd = $getCCOutW[2]; $command = 3; $string_out = '<XML_FILE xmlns="x-schema:.\\dtd\\stnd.xdr"> <XML_REQUEST> <USER_ID>' . $user . '</USER_ID> <COMMAND>' . $command . '</COMMAND> <TROUTD>' . $troutd . '</TROUTD> </XML_REQUEST> </XML_FILE> '; // echo $string_out; } //---- //below added to log .inx info. To be tested on lane9, etc //added 07/07/05 CvR $trans_id = $_SESSION["LastID"] + 1; $lane = $_SESSION["laneno"]; $trans_no = $_SESSION["transno"]; $now = date('Y-m-d H:i:s'); $dbinx = tDataconnect(); $inxQ = "INSERT INTO INX\r\n VALUES('{$user}','{$command}','{$proc}','{$TID}','{$CC}','{$expDate}','{$manual}','{$trackII}','{$transno}',1,{$amount},'','{$now}','{$trans_id}','{$trans_no}','{$lane}')"; if (sql_query($inxQ, $dbinx)) { //--------- // changed all filename functions (remote_oux(), local_inx(), etc) to variables, cached up top --atf 5/24/07 delete_file($local_inx); // ***** changed local_inx function to variable abpw 3/05/07 ***** $fp = fopen($local_inx, 'w'); // open the file with write permissions -- ***** changed local_inx function to variable abpw 3/05/07 ***** fwrite($fp, $string_out); // write $string_out to the *.inx file fclose($fp); // close the file delete_file($remote_inx); delete_file($remote_oux); $inxUploaded = copy_file($local_inx, $remote_inx); //***** changed local_inx function to variable abpw 3/05/07 ***** } return $inxUploaded; }
function addtransDiscount() { addItem("DISCOUNT", "Discount", "I", "", "", 0, 1, truncate2(-1 * $_SESSION["transDiscount"]), truncate2(-1 * $_SESSION["transDiscount"]), 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0); }
lastpage(); } break; case "BR": if (!is_numeric($strl)) { inputUnknown(); } else { $deposit = $strl / 100; addBottleReturn(1, $deposit, 0); lastpage(); } break; case "TW": if (is_numeric($strl)) { if (strlen($strl) > 4) { boxMsg(truncate2($strl / 100) . " tare not supported"); } elseif ($strl / 100 > $_SESSION["weight"] && $_SESSION["weight"] > 0) { boxMsg("Tare cannot be<br />greater than item weight"); } else { addtare($strl); lastpage(); } } else { inputUnknown(); } break; case "CL": clearinput(); break; case "ID": if ($left != "PV") {
function frankgiftcert() { $ref = trim($_SESSION["CashierNo"]) . "-" . trim($_SESSION["laneno"]) . "-" . trim($_SESSION["transno"]); $time_now = strftime("%m/%d/%y", time()); // apbw 3/10/05 "%D" didn't work - Franking patch $next_year_stamp = mktime(0, 0, 0, date("m"), date("d"), date("Y") + 1); $next_year = strftime("%m/%d/%y", $next_year_stamp); // apbw 3/10/05 "%D" didn't work - Franking patch // lines 200-207 edited 03/24/05 apbw Wedge Printer Swap Patch $output = ""; $output .= str_repeat("\n", 6); $output .= "ref: " . $ref . "\n"; $output .= str_repeat(" ", 5) . $time_now; $output .= str_repeat(" ", 12) . $next_year; $output .= str_repeat("\n", 3); $output .= str_repeat(" ", 75); $output .= "\$" . truncate2($_SESSION["tenderamt"]); endorse($output); }
</td><td id="visita" align="right">visitas:0</td> </tr> <tr> <td colspan="3" id="<?php echo "titulo_Articulo" . $row_rsSubcategoria['Nombre_CatCla']; ?> "><?php echo utf8_encode($row_rsSubcategoria['Titulo_Articulo']); ?> </td> </tr> <tr> <td colspan="3" id="descripcion_clasificado"><?php $descripcion = truncate2($row_rsSubcategoria['Descripcion_Articulo'], 100); echo utf8_encode($descripcion); ?> <a style="color:#333; font-weight:bold;" href="../clasificados/detalle.php?id_art=<?php echo $id_art; ?> "<?php /*"javascript:cargar('../novedades/detalle_noticia.php?id_not=<? echo $id_not?>','featured') */ ?> > Leer Más</a> </td> </tr> <tr> <td colspan="3" id="contacto_clasificado" align="right">contacto:<?php echo utf8_encode($row_rsSubcategoria['Contacto_Telefono']);
</td><td id="visita" align="right">visitas:0</td><!--<td><div id="tipo">OFRECIDO</div><div id="articulo_icono"></div></td>--> </tr> <tr> <td colspan="3" id="<?php echo "titulo_Articulo" . $row_rs_Articulos['Nombre_CatCla']; ?> "><?php echo $row_rs_Articulos['Titulo_Articulo']; ?> </td> </tr> <tr> <td colspan="3" id="descripcion_clasificado"><?php $descripcion = truncate2($row_rs_Articulos['Descripcion_Articulo'], 800); echo $descripcion; ?> <a style="color:#333; font-weight:bold;" href="../clasificados/detalle.php?id_art=<?php echo $id_art; ?> "> Leer Más</a> </td> </tr> <tr> <td colspan="3" id="contacto_clasificado" align="right">contacto:<?php echo utf8_encode($row_rs_Articulos['Contacto_Telefono']); ?> <?php echo $row_rs_Articulos['Contacto_Correo'];
function upcscanned($entered) { $hitareflag = 0; $entered = str_replace(".", " ", $entered); if (strlen($entered) == 0 || !$entered) { lastpage(); } else { if ($_SESSION["quantity"] == 0 && $_SESSION["multiple"] == 0) { $quantity = 1; } else { $quantity = $_SESSION["quantity"]; } } $scaleprice = 0; if (substr($entered, 0, 1) == 0 && strlen($entered) == 7) { $p6 = substr($entered, -1); if ($p6 == 0) { $entered = substr($entered, 0, 3) . "00000" . substr($entered, 3, 3); } elseif ($p6 == 1) { $entered = substr($entered, 0, 3) . "10000" . substr($entered, 4, 3); } elseif ($p6 == 2) { $entered = substr($entered, 0, 3) . "20000" . substr($entered, 4, 3); } elseif ($p6 == 3) { $entered = substr($entered, 0, 4) . "00000" . substr($entered, 4, 2); } elseif ($p6 == 4) { $entered = substr($entered, 0, 5) . "00000" . substr($entered, 6, 1); } else { $entered = substr($entered, 0, 6) . "0000" . $p6; } } if (strlen($entered) == 13 && substr($entered, 0, 1) != 0) { $upc = "0" . substr($entered, 0, 12); } else { $upc = substr("0000000000000" . $entered, -13); } // ccm-rle 10-6-2009 uncommented this line below- this made it show up but it added a 7 to the price. if (substr($upc, 0, 3) == "002") { $scaleprice = truncate2(substr($upc, -4) / 100); $upc = substr($upc, 0, 8) . "00000"; } $query = "select * from products where upc = '" . $upc . "' AND inUse = 1"; $db = pDataConnect(); $result = sql_query($query, $db); $num_rows = sql_num_rows($result); $row = sql_fetch_array($result); $start_date = $row["start_date"]; $end_date = $row["end_date"]; $normal_price = $row["normal_price"]; $sale_start_date = date("Y-n-d H:i:s", $start_date); $sale_end_date = date("Y-n-d H:i:s", $end_date); $special_price = $row["special_price"]; $right_now = date("Y-n-d H:i:s"); $deposit = $row["deposit"]; if ($num_rows == 0 && substr($upc, 0, 3) != "005") { boxMsg($upc . "<BR><B>is not a valid item</B>"); } elseif ($num_rows == 0 && substr($upc, 0, 3) == "005") { couponcode($upc); } elseif ($row["scale"] != 0 && $_SESSION["weight"] == 0 && $_SESSION["quantity"] == 0) { if ($_SESSION["wgtRequested"] == 0) { $_SESSION["wgtRequested"] = 1; lastpage(); echo "<SCRIPT type=\"text/javascript\">\n" . "lockScreen = setTimeout('document.forms[0].elements[0].value = \"" . $_SESSION["strEntered"] . "\"; document.forms[0].submit();', 700)\n" . "</SCRIPT>"; } else { $_SESSION["SNR"] = 1; boxMsg("please put item on scale"); $_SESSION["wgtRequested"] = 0; } } elseif ($row["scale"] != 0 && $_SESSION["scale"] == 0) { $_SESSION["waitforScale"] = 1; $_SESSION["SNR"] = 1; lastpage(); //boxMsg("wait for scale"); } elseif ($row["scale"] == 0 && (int) $_SESSION["quantity"] != $_SESSION["quantity"] && $_SESSION["fractions"] != 1) { boxMsg("fractional quantity cannot be accepted for this item"); } elseif ($_SESSION["itemDiscount"] < 0 || $_SESSION["itemDiscount"] > 101) { xboxMsg("item cannot be<br>discounted at " . $_SESSION["itemDiscount"] . "%"); $_SESSION["itemDiscount"] = 0; } else { $mixMatch = 0; $qttyEnforced = $row["qttyEnforced"]; if ($qttyEnforced == 1 && $_SESSION["multiple"] == 0 && $_SESSION["msgrepeat"] == 0) { qttyscreen(); } else { $_SESSION["qttyvalid"] = 1; } if ($_SESSION["qttyvalid"] != 1) { sql_close($db); } else { $upc = $row["upc"]; $description = $row["description"]; $description = str_replace("'", "", $description); $description = str_replace(",", "", $description); $transType = "I"; $transsubType = "CA"; $department = $row["department"]; $unitPrice = $normal_price; $regPrice = $normal_price; $CardNo = $_SESSION["memberID"]; if ($row["scale"] != 0) { $scale = 1; } else { $scale = 0; } // ccm-rle 9-23-09 below is probably where I need to modify the code to ensure that tax is turned off if an item is toggled for foodstamps. actually the co-op wants this tax to be recorded somewhere that is queriable but not passed onto to the customer so this needs to be further researched if ($row["tax"] != 0 && $_SESSION["toggletax"] == 0) { $tax = $row["tax"]; } elseif ($row["tax"] != 0 && $_SESSION["toggletax"] == 1) { $tax = 0; $_SESSION["toggletax"] = 0; } elseif ($row["tax"] == 0 && $_SESSION["toggletax"] == 1) { $tax = 1; $_SESSION["toggletax"] = 0; } else { $tax = 0; } if ($row["foodstamp"] != 0 && $_SESSION["togglefoodstamp"] == 0) { $foodstamp = 1; } elseif ($row["foodstamp"] != 0 && $_SESSION["togglefoodstamp"] == 1) { $foodstamp = 0; $_SESSION["togglefoodstamp"] = 0; } elseif ($row["foodstamp"] == 0 && $_SESSION["togglefoodstamp"] == 1) { $foodstamp = 1; $_SESSION["togglefoodstamp"] = 0; } else { $foodstamp = 0; } if ($scale == 1) { $hitareflag = 0; if ($_SESSION["quantity"] != 0) { $quantity = $_SESSION["quantity"] - $_SESSION["tare"]; } else { $quantity = $_SESSION["weight"] - $_SESSION["tare"]; } if ($quantity <= 0) { $hitareflag = 1; } $_SESSION["tare"] = 0; } // ccm-rle 9-23-09 - this is where the initial check as to whether an item is discountable happens also seems to have the 65 percent hard limit on a discount set. fannie sets a no discount flag to cause discount to equal 0 if this is checked thus stopping discounts (there was an error in the smarty templates that caused a reversal of the logic. not sure where discounttype comes from or where department discount fields come in yet //ccm-rle 11-11-09 - if the current date is not between the sale start date & end date turn off the discount $discounttype = nullwrap($row["discounttype"]); // if (!($right_now >= $sale_start_date && $right_now <= $sale_end_date)) { $discounttype = 0; } $discountable = $row["discount"]; $sale_price = $row["special_price"]; if ($_SESSION["itemDiscount"] > 0 && $_SESSION["itemDiscount"] < 101 && $discounttype != 0) { $discountable = 0; $special_price = number_format($sale_price * (100 - $_SESSION["itemDiscount"]) / 100, 2); $_SESSION["itemDiscount"] = 0; $upc = "D" . substr($upc, 1); // new by Tak } elseif ($_SESSION["itemDiscount"] > 0 && $_SESSION["itemDiscount"] < 101 && substr($upc, 0, 3) == "002") { $discountable = 0; $discounttype = 1; $special_price = number_format($scaleprice * (100 - $_SESSION["itemDiscount"]) / 100, 2); $_SESSION["itemDiscount"] = 0; $upc = "D" . substr($upc, 1); } elseif ($_SESSION["itemDiscount"] > 0 && $_SESSION["itemDiscount"] < 101) { $discountable = 0; $discounttype = 1; $special_price = number_format($normal_price * (100 - $_SESSION["itemDiscount"]) / 100, 2); $_SESSION["itemDiscount"] = 0; $upc = "D" . substr($upc, 1); // new by Tak } // ccm-rle 9-23-09 this seems to toggle whether an item is discountable but I'm not sure where toggleDiscountable is called or how it is called yet. if ($_SESSION["toggleDiscountable"] == 1) { $_SESSION["toggleDiscountable"] = 0; if ($discountable != 0) { $discountable = 0; } else { $discountable = 1; } } // ccm-rle 9-23-09 - find out where session nd can be set and what sets discountable to 7 if ($_SESSION["nd"] == 1 && $discountable == 7) { $discountable = 3; $_SESSION["nd"] = 0; } if ($discounttype == 2 || $discounttype == 4) { $memDiscount = truncate2($normal_price * $quantity) - truncate2($special_price * $quantity); $discount = 0; $unitPrice = $normal_price; } elseif ($discounttype == 1 && substr($upc, 0, 3) == "D02") { $unitPrice = $special_price; $unitDiscount = $scaleprice - $special_price; $discount = $unitDiscount * $quantity; $memDiscount = 0; } elseif ($discounttype == 1) { $unitPrice = $special_price; $unitDiscount = $normal_price - $special_price; $discount = $unitDiscount * $quantity; $memDiscount = 0; } else { $unitPrice = $normal_price; $discount = 0; $memDiscount = 0; } if ($_SESSION["isMember"] == 1 && $discounttype == 2) { $unitPrice = nullwrap($special_price); } if ($_SESSION["isStaff"] != 0 && $discounttype == 4) { $unitPrice = nullwrap($special_price); } if ($_SESSION["casediscount"] > 0 && $_SESSION["casediscount"] <= 100) { $casediscount = (100 - $_SESSION["casediscount"]) / 100; $unitPrice = $casediscount * $unitPrice; } //-------------Mix n Match ------------------------------------- $matched = 0; $VolSpecial = nullwrap($row["groupprice"]); $volDiscType = nullwrap($row["pricemethod"]); $volume = nullwrap($row["quantity"]); if ($row["advertised"] != 0) { if ($row["discounttype"] == 2 && $_SESSION["isMember"] == 1 || $row["discounttype"] != 2) { $VolSpecial = nullwrap($row["specialgroupprice"]); $volDiscType = nullwrap($row["specialpricemethod"]); $volume = nullwrap($row["specialquantity"]); } } if ($volDiscType && $volDiscType >= 1) { // If item is on volume discount if (!$row["mixmatchcode"] || $row["mixmatchcode"] == 0) { $mixMatch = 0; $queryt = "select sum(ItemQtty - matched) as mmqtty from localtemptrans where " . "upc = '" . $row["upc"] . "' group by upc"; } else { $mixMatch = $row["mixmatchcode"]; $queryt = "select sum(ItemQtty - matched) as mmqtty, mixMatch from localtemptrans " . "where mixMatch = '" . $mixMatch . "' group by mixMatch"; } if ($volDiscType == 1) { $unitPrice = truncate2($VolSpecial / $volume); } $voladj = $VolSpecial - ($volume - 1) * $unitPrice; // one at special price $newmm = (int) ($quantity / $volume); // number of complete sets $dbt = tDataConnect(); $resultt = sql_query($queryt, $dbt); $num_rowst = sql_num_rows($resultt); if ($num_rowst > 0) { $rowt = sql_fetch_array($resultt); $mmqtty = $rowt["mmqtty"]; // number not in complete sets in localtemptrans } else { $mmqtty = 0; } $newmmtotal = $mmqtty + $quantity % $volume; $na = $newmmtotal % $volume; $quantity = $quantity % $volume; if ($newmm >= 1) { addItem($upc, $description, "I", "", "", $department, $newmm, truncate2($VolSpecial), truncate2($newmm * $VolSpecial), truncate2($VolSpecial), $scale, $tax, $foodstamp, $discount, $memDiscount, $discountable, $discounttype, $volume * $newmm, $volDiscType, $volume, $VolSpecial, $mixMatch, $volume * $newmm, 0); $newmm = 0; $_SESSION["qttyvalid"] = 0; } if ($newmmtotal >= $volume) { addItem($upc, $description, "I", "", "", $department, 1, $voladj, $voladj, $voladj, $scale, $tax, $foodstamp, $discount, $memDiscount, $discountable, $discounttype, 1, $volDiscType, $volume, $VolSpecial, $mixMatch, $volume, 0); $quantity = $quantity - 1; $newmmtotal = 0; $_SESSION["qttyvalid"] = 0; } sql_close($dbt); } //-------------------------------------------------------------------------- $total = $unitPrice * $quantity; // ccm-rle 10-06-2009 tried changing it to 02 instead of 002 below if (substr($upc, 0, 3) == "002" and $discounttype != 2) { $unitPrice = truncate2($scaleprice); $regPrice = $total; $total = $unitPrice * $quantity; } $total = truncate2($total); $unitPrice = truncate2($unitPrice); if ($upc == "0000000008010" && $_SESSION["msgrepeat"] == 0) { $_SESSION["endorseType"] = "giftcert"; $_SESSION["tenderamt"] = $total; $_SESSION["boxMsg"] = "<B>" . $total . " gift certificate</B><BR>insert document<BR>press [enter] to endorse<P><FONT size='-1'>[clear] to cancel</FONT>"; boxMsgscreen(); } elseif ($upc == "0000000008006" && $_SESSION["msgrepeat"] == 0) { $_SESSION["endorseType"] = "stock"; $_SESSION["tenderamt"] = $total; $_SESSION["boxMsg"] = "<B>" . $total . " stock payment</B><BR>insert form<BR>press [enter] to endorse<P><FONT size='-1'>[clear] to cancel</FONT>"; boxMsgscreen(); } elseif ($upc == "0000000008011" && $_SESSION["msgrepeat"] == 0) { $_SESSION["endorseType"] = "classreg"; $_SESSION["tenderamt"] = $total; $_SESSION["boxMsg"] = "<B>" . $total . " class registration</B><BR>insert form<BR>press [enter] to endorse<P><FONT size='-1'>[clear] to cancel</FONT>"; boxMsgscreen(); } elseif ($hitareflag == 1) { boxMsg("item weight must be greater than tare weight"); } else { if ($quantity != 0) { $qtty = $quantity; if ($scale == 1) { goodBeep(); } if ($_SESSION["casediscount"] > 0) { addcdnotify(); $discounttype = 3; $_SESSION["casediscount"] = 0; $quantity = 1; $unitPrice = $total; $regPrice = $total; } if ($_SESSION["ddNotify"] == 1 && $_SESSION["itemPD"] == 10) { $_SESSION["itemPD"] = 0; $discountable = 7; } if ($_SESSION["ddNotify"] == 1 && $discountable == 7) { $intvoided = 22; } else { $intvoided = 0; } addItem($upc, $description, "I", " ", " ", $department, $quantity, $unitPrice, $total, $regPrice, $scale, $tax, $foodstamp, $discount, $memDiscount, $discountable, $discounttype, $qtty, $volDiscType, $volume, $VolSpecial, $mixMatch, $matched, $intvoided); $_SESSION["msgrepeat"] = 0; $_SESSION["qttyvalid"] = 0; } } if ($deposit && $deposit > 0) { addDeposit($quantity, $deposit, $foodstamp); } if ($tax == 1) { $_SESSION["istaxable"] = 1; } else { $_SESSION["istaxable"] = 0; $_SESSION["voided"] = 0; } if ($discounttype == 1) { $_SESSION["ondiscount"] = 1; $_SESSION["voided"] = 2; adddiscount($discount); } elseif ($discounttype == 2 && $_SESSION["isMember"] == 1) { $_SESSION["ondiscount"] = 1; $_SESSION["voided"] = 2; adddiscount($memDiscount); } elseif ($discounttype == 4 && $_SESSION["isStaff"] != 0) { $_SESSION["ondiscount"] = 1; $_SESSION["voided"] = 2; adddiscount($memDiscount); } else { $_SESSION["ondiscount"] = 0; $_SESSION["voided"] = 0; } // sql_close($db); if ($_SESSION["tare"] != 0) { $_SESSION["tare"] = 0; } $_SESSION["alert"] = ""; $_SESSION["ttlflag"] = 0; $_SESSION["ttlrequested"] = 0; $_SESSION["fntlflag"] = 0; $_SESSION["togglefoodstamp"] = 0; $_SESSION["toggletax"] = 0; $_SESSION["repeat"] = 1; setglobalflags(0); if ($hitareflag != 1) { lastpage(); } } } $_SESSION["quantity"] = 0; $_SESSION["itemPD"] = 0; }