Beispiel #1
0
function sendEmailOnPurcase($course_id, $order_id, $order_expiration, $plan_id)
{
    $all_emails = getOnPurchaseEmails($course_id);
    $order = getOrderDetails($order_id);
    $all_plans = getPlanExpiration();
    $guru_configs = getConfigs();
    if (isset($all_emails) && count($all_emails) > 0) {
        foreach ($all_emails as $email_key => $email_value) {
            submitEmail($email_value, $course_id, $order["0"], $order_expiration, $all_plans[$plan_id]["name"], $guru_configs);
        }
    }
}
Beispiel #2
0
function getOrdersSort($sort, $mulai, $akhir)
{
    $res = array();
    $conn = new mysqli($GLOBALS['servername'], $GLOBALS['dbuser'], $GLOBALS['dbpass'], $GLOBALS['dbname']);
    if ($conn->connect_error) {
        die("Connection failed " . $conn->connect_error);
    }
    $query = 'SELECT * FROM orders';
    $param = '';
    if ($mulai !== '' || $akhir !== '') {
        if (strpos($param, 'WHERE') === false) {
            $param .= ' WHERE';
        }
        if ($mulai !== '') {
            $param .= " date >= '" . $mulai . "'";
        }
        if ($akhir !== '') {
            if (strlen($param) > 6) {
                $param .= ' AND';
            }
            $param .= " date <= '" . $akhir . "'";
        }
    }
    switch ($sort) {
        case 'A-Z':
            $param .= ' ORDER BY name';
            break;
        case 'Z-A':
            $param .= ' ORDER BY name DESC';
            break;
        case 'sudah':
            if (strpos($param, 'WHERE') === false) {
                $param .= ' WHERE';
            }
            if (strlen($param) > 6) {
                $param .= ' AND';
            }
            $param .= ' isprocessed = 1';
            break;
        case 'belum':
            if (strpos($param, 'WHERE') === false) {
                $param .= ' WHERE';
            }
            if (strlen($param) > 6) {
                $param .= ' AND';
            }
            $param .= ' isprocessed = 0';
            break;
    }
    $result = $conn->query($query . $param);
    $strresult = '';
    if ($result->num_rows > 0) {
        while ($item = $result->fetch_assoc()) {
            $single = new stdClass();
            $single->id = $item['id'];
            $single->custname = $item['name'];
            $single->address = $item['address'];
            $single->phone = $item['phone'];
            $single->email = $item['email'];
            $single->information = $item['information'];
            $single->date = (string) $item['date'];
            $single->isprocessed = (bool) $item['isprocessed'];
            $details = getOrderDetails($single->id);
            $totalprice = 0;
            foreach ($details as $detail) {
                $totalprice += (int) $detail->price * (int) $detail->amount;
            }
            $single->orderedproducts = count($details);
            $randomquery = 'SELECT * FROM `randomnumbers` WHERE `associatedorder` = ' . $single->id;
            $randomres = $conn->query($randomquery);
            if ($randomres->num_rows > 0) {
                while ($rand = $randomres->fetch_assoc()) {
                    $totalprice += (int) $rand['randomnumber'];
                    $single->randomnum = (int) $rand['randomnumber'];
                }
            }
            $single->totalprice = $totalprice;
            array_push($res, $single);
        }
        switch ($sort) {
            case 'sedikit-banyak':
                usort($res, 'sortByAmount');
                break;
            case 'banyak-sedikit':
                usort($res, 'sortByAmountDesc');
                break;
            case 'murah-mahal':
                usort($res, 'sortByPrice');
                break;
            case 'mahal-murah':
                usort($res, 'sortByPriceDesc');
                break;
        }
    }
    return $res;
}
Beispiel #3
0
function getOrders()
{
    $res = array();
    $conn = new mysqli($GLOBALS['servername'], $GLOBALS['dbuser'], $GLOBALS['dbpass'], $GLOBALS['dbname']);
    if ($conn->connect_error) {
        die("Connection failed " . $conn->connect_error);
    }
    $query = 'SELECT * FROM orders ORDER BY name';
    $result = $conn->query($query);
    $strresult = '';
    if ($result->num_rows > 0) {
        while ($item = $result->fetch_assoc()) {
            $single = new stdClass();
            $single->id = $item['id'];
            $single->custname = $item['name'];
            $single->address = $item['address'];
            $single->phone = $item['phone'];
            $single->email = $item['email'];
            $single->information = $item['information'];
            $single->date = (string) $item['date'];
            $single->isprocessed = (bool) $item['isprocessed'];
            $details = getOrderDetails($single->id);
            $totalprice = 0;
            foreach ($details as $detail) {
                $totalprice += (int) $detail->price * (int) $detail->amount;
            }
            $single->orderedproducts = count($details);
            $randomquery = 'SELECT * FROM `randomnumbers` WHERE `associatedorder` = ' . $single->id;
            $randomres = $conn->query($randomquery);
            if ($randomres->num_rows > 0) {
                while ($rand = $randomres->fetch_assoc()) {
                    $totalprice += (int) $rand['randomnumber'];
                    $single->randomnum = (int) $rand['randomnumber'];
                }
            }
            $single->totalprice = $totalprice;
            array_push($res, $single);
        }
    }
    return $res;
}