Example #1
0
// registration form
if (isset($_GET["user_details"]) && isset($_SESSION["log"])) {
    $cust_password = null;
    $Email = null;
    $first_name = null;
    $last_name = null;
    $subscribed4news = null;
    $additional_field_values = null;
    regGetContactInfo($_SESSION["log"], $cust_password, $Email, $first_name, $last_name, $subscribed4news, $additional_field_values);
    $smarty->assign("additional_field_values", $additional_field_values);
    $smarty->assign("first_name", $first_name);
    $smarty->assign("last_name", $last_name);
    $smarty->assign("Email", $Email);
    $smarty->assign("login", $_SESSION["log"]);
    $customerID = regGetIdByLogin($_SESSION["log"]);
    $custgroup = GetCustomerGroupByCustomerId($customerID);
    $smarty->assign("custgroup_name", $custgroup["custgroup_name"]);
    $smarty->assign('affiliate_customers', affp_getCustomersNum($customerID));
    if (CONF_DISCOUNT_TYPE == '2') {
        if ($custgroup["custgroup_discount"] > 0) {
            $smarty->assign("discount", $custgroup["custgroup_discount"]);
        }
    }
    if (CONF_DISCOUNT_TYPE == '4' || CONF_DISCOUNT_TYPE == '5') {
        if ($custgroup["custgroup_discount"] > 0) {
            $smarty->assign("min_discount", $custgroup["custgroup_discount"]);
        }
    }
    $defaultAddressID = regGetDefaultAddressIDByLogin($_SESSION["log"]);
    $addressStr = regGetAddressStr($defaultAddressID);
    $smarty->assign("addressStr", $addressStr);
Example #2
0
function regGetCustomers($callBackParam, &$count_row, $navigatorParams = null)
{
    if ($navigatorParams != null) {
        $offset = $navigatorParams["offset"];
        $CountRowOnPage = $navigatorParams["CountRowOnPage"];
    } else {
        $offset = 0;
        $CountRowOnPage = 0;
    }
    $where_clause = "";
    if (isset($callBackParam["Login"])) {
        $callBackParam["Login"] = xEscSQL($callBackParam["Login"]);
        $where_clause .= " Login LIKE '%" . $callBackParam["Login"] . "%' ";
    }
    if (isset($callBackParam["first_name"])) {
        $callBackParam["first_name"] = xEscSQL($callBackParam["first_name"]);
        if ($where_clause != "") {
            $where_clause .= " AND ";
        }
        $where_clause .= " first_name LIKE '%" . $callBackParam["first_name"] . "%' ";
    }
    if (isset($callBackParam["last_name"])) {
        $callBackParam["last_name"] = xEscSQL($callBackParam["last_name"]);
        if ($where_clause != "") {
            $where_clause .= " AND ";
        }
        $where_clause .= " last_name LIKE '%" . $callBackParam["last_name"] . "%' ";
    }
    if (isset($callBackParam["email"])) {
        $callBackParam["email"] = xEscSQL($callBackParam["email"]);
        if ($where_clause != "") {
            $where_clause .= " AND ";
        }
        $where_clause .= " Email LIKE '%" . $callBackParam["email"] . "%' ";
    }
    if (isset($callBackParam["groupID"])) {
        if ($callBackParam["groupID"] != 0) {
            if ($where_clause != "") {
                $where_clause .= " AND ";
            }
            $where_clause .= " custgroupID = " . (int) $callBackParam["groupID"] . " ";
        }
    }
    if (isset($callBackParam["ActState"])) {
        switch ($callBackParam["ActState"]) {
            #activated
            case 1:
                if ($where_clause != "") {
                    $where_clause .= " AND ";
                }
                $where_clause .= " (ActivationCode='' OR ActivationCode IS NULL)";
                break;
                #not activated
            #not activated
            case 0:
                if ($where_clause != "") {
                    $where_clause .= " AND ";
                }
                $where_clause .= " ActivationCode!=''";
                break;
        }
    }
    if ($where_clause != "") {
        $where_clause = " where " . $where_clause;
    }
    $order_clause = "";
    if (isset($callBackParam["sort"])) {
        $order_clause .= " order by " . xEscSQL($callBackParam["sort"]) . " ";
        if (isset($callBackParam["direction"])) {
            if ($callBackParam["direction"] == "ASC") {
                $order_clause .= " ASC ";
            } else {
                $order_clause .= " DESC ";
            }
        }
    }
    $q = db_query("select customerID, Login, cust_password, Email, first_name, last_name, subscribed4news, " . " custgroupID, addressID, reg_datetime, ActivationCode " . " from " . CUSTOMERS_TABLE . " " . $where_clause . " " . $order_clause);
    $data = array();
    $i = 0;
    //var_dump ($navigatorParams);
    while ($row = db_fetch_row($q)) {
        if ($i >= $offset && $i < $offset + $CountRowOnPage || $navigatorParams == null) {
            $group = GetCustomerGroupByCustomerId($row["customerID"]);
            $row["custgroup_name"] = $group["custgroup_name"];
            $row["allowToDelete"] = regVerifyToDelete($row["customerID"]);
            $row["reg_datetime"] = format_datetime($row["reg_datetime"]);
            $data[] = $row;
        }
        $i++;
    }
    $count_row = $i;
    return $data;
}
Example #3
0
function dscCalculateDiscount($orderPrice, $log)
{
    $discount = array("discount_percent" => 0, "discount_standart_unit" => 0, "discount_current_unit" => 0, "rest_standart_unit" => 0, "rest_current_unit" => 0, "priceUnit" => getPriceUnit());
    $customerID = (int) regGetIdByLogin($log);
    switch (CONF_DISCOUNT_TYPE) {
        // discount is switched off
        case 1:
            return $discount;
            break;
            // discount is based on customer group
        // discount is based on customer group
        case 2:
            if (!is_bool($customerID = regGetIdByLogin($log))) {
                $customer_group = GetCustomerGroupByCustomerId($customerID);
                if ($customer_group) {
                    $discount["discount_percent"] = $customer_group["custgroup_discount"];
                } else {
                    $discount["discount_percent"] = 0;
                }
            } else {
                return $discount;
            }
            break;
            // discount is calculated with help general order price
        // discount is calculated with help general order price
        case 3:
            $discount["discount_percent"] = _calculateGeneralPriceDiscount($orderPrice, $log);
            break;
            // discount equals to discount is based on customer group plus
            //                discount calculated with help general order price
        // discount equals to discount is based on customer group plus
        //                discount calculated with help general order price
        case 4:
            if (!is_bool($customerID)) {
                $customer_group = GetCustomerGroupByCustomerId($customerID);
                if (!$customer_group) {
                    $customer_group = array("custgroup_discount" => 0);
                }
            } else {
                $customer_group["custgroup_discount"] = 0;
            }
            $discount["discount_percent"] = $customer_group["custgroup_discount"] + _calculateGeneralPriceDiscount($orderPrice, $log);
            break;
            // discount is calculated as MAX( discount is based on customer group,
            //                        discount calculated with help general order price  )
        // discount is calculated as MAX( discount is based on customer group,
        //                        discount calculated with help general order price  )
        case 5:
            if (!is_bool($customerID)) {
                $customer_group = GetCustomerGroupByCustomerId($customerID);
            } else {
                $customer_group["custgroup_discount"] = 0;
            }
            if ($customer_group["custgroup_discount"] >= _calculateGeneralPriceDiscount($orderPrice, $log)) {
                $discount["discount_percent"] = $customer_group["custgroup_discount"];
            } else {
                $discount["discount_percent"] = _calculateGeneralPriceDiscount($orderPrice, $log);
            }
            break;
    }
    $discount["discount_standart_unit"] = (double) $orderPrice / 100 * (double) $discount["discount_percent"];
    $discount["discount_current_unit"] = show_priceWithOutUnit($discount["discount_standart_unit"]);
    $discount["rest_standart_unit"] = $orderPrice - $discount["discount_standart_unit"];
    $discount["rest_current_unit"] = show_priceWithOutUnit($discount["rest_standart_unit"]);
    return $discount;
}