Example #1
0
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);
        }
    }
}
Example #2
0
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();
    }
}
Example #3
0
                } else {
                    staffCharge($strl);
                }
                break;
            default:
                if (is_numeric($strl)) {
                    tender($right, $strl);
                } else {
                    switch ($left) {
                        case "VD":
                            voidupc($strr);
                            break;
                        case "PV":
                            $intAway = 1;
                            $_SESSION["pvsearch"] = $strr;
                            maindisplay("productlist.php");
                            break;
                        case "FN":
                            lastpage();
                            break;
                        default:
                            inputUnknown();
                    }
                }
        }
    } else {
        inputUnknown();
    }
}
if ($intAway == 1) {
    $intAway = 0;