Exemplo n.º 1
0
function getSalesSummaryByDistrict($suppNo, $distNo = null)
{
    //if distNo not set --> get all district and return an array
    // $districts[distNo] --> result
    include_once "District.php";
    if (!isset($distNo)) {
        $result = getAllDistricts();
        while ($row = $result->fetch_array()) {
            $districts[$row[distNo]] = getSalesSummaryByDistrict($suppNo, $row[distNo], "Sold", "DESC");
        }
        return $districts;
    }
    $query = "SELECT District." . distNo . ", District." . distName . ", OrderLine." . prodNo . ", Product." . prodName . ", Product." . prodPhoto . ", Product." . catNo . ", Category." . catName . ", SUM(OrderLine." . qty . ") AS Sold " . "FROM OrderLine " . "JOIN CustOrder ON OrderLine." . ordNo . " = CustOrder." . ordNo . " " . "JOIN Product ON Product." . prodNo . " = OrderLine." . prodNo . " " . "JOIN Category ON Product." . catNo . " = Category." . catNo . " " . "JOIN District ON CustOrder." . distNo . " = District." . distNo . " " . "WHERE Product." . suppNo . " = '{$suppNo}' " . "AND District." . distNo . " = '{$distNo}' " . "AND " . isDeleted . " = 0 " . "GROUP BY Product." . prodNo . " " . DB::genOrderByStr(func_get_args(), func_num_args(), 2);
    return DB::query($query);
}
Exemplo n.º 2
0
    case 1:
        $chart = getSalesSummaryByGender($suppNo);
        $chart = $chart["M"];
        break;
    case 2:
        $chart = getSalesSummaryByGender($suppNo);
        $chart = $chart["F"];
        break;
    case 3:
        $chart = getSalesSummaryByDistrict($suppNo, "DST01");
        break;
    case 4:
        $chart = getSalesSummaryByDistrict($suppNo, "DST02");
        break;
    case 5:
        $chart = getSalesSummaryByDistrict($suppNo, "DST03");
        break;
    case 6:
        if (isset($_POST[catNo])) {
            $chart = getSalesSummaryByCat($suppNo, $_POST[catNo]);
            break;
        } else {
            return null;
        }
}
if (!$chart) {
    return json_encode($array);
}
while ($row = $chart->fetch_assoc()) {
    $newArr["label"] = $row[prodName];
    $newArr["y"] = intval($row["Sold"]);