예제 #1
0
파일: prehkeys.php 프로젝트: WedgeCoop/IS4C
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();
    }
}
예제 #2
0
파일: void.php 프로젝트: WedgeCoop/IS4C
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;
                }
            }
        }
    }
}
예제 #3
0
파일: pos2.php 프로젝트: WedgeCoop/IS4C
                            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;
    printfooterb();
} else {
    printfooter();
}
if ($_SESSION["End"] == 1) {
    rePoll();
    receipt("full");
}
$_SESSION["away"] = 0;
function pos2_dataError($Type, $msg, $file, $line, $context)
{