Пример #1
0
<?php

#handler for new customers by links
if (isset($_GET['refid'])) {
    $_RefererLogin = regGetLoginById(intval($_GET['refid']));
    if ($_RefererLogin) {
        session_register('s_RefererLogin');
        $_SESSION['s_RefererLogin'] = $_RefererLogin;
        $_SESSION['refid'] = intval($_GET['refid']);
        Redirect(set_query(''));
    }
}
if (isset($_SESSION["log"]) && (isset($_GET["affiliate"]) || isset($_POST["affiliate"])) && CONF_AFFILIATE_PROGRAM_ENABLED) {
    $SubPage = isset($_GET['sub']) ? $_GET['sub'] : 'balance';
    $fACTION = isset($_POST['fACTION']) ? $_POST['fACTION'] : '';
    $customerID = regGetIdByLogin($_SESSION["log"]);
    $affp_CustomersNum = affp_getCustomersNum($customerID);
    #post-requests handler
    switch ($fACTION) {
        case 'SAVE_SETTINGS':
            affp_saveSettings($customerID, isset($_POST['EmailOrders']), isset($_POST['EmailPayments']));
            Redirect(set_query('save_settings=ok'));
            break;
    }
    #loading data for subpages
    switch ($SubPage) {
        case 'balance':
            $Commissions = affp_getCommissionsAmount($customerID);
            $Payments = affp_getPaymentsAmount($customerID);
            $smarty->assign('CommissionsNumber', count($Commissions));
            $smarty->assign('PaymentsNumber', count($Payments));
Пример #2
0
                 }
                 if (isset($_GET["direction"])) {
                     $callBackParam["direction"] = $_GET["direction"];
                 }
                 $count = 0;
                 $navigatorHtml = GetNavigatorHtml(_getUrlToNavigate_ORDER_HISTORY(), 20, 'ordGetOrders', $callBackParam, $orders, $offset, $count);
                 $smarty->hassign("urlToSubmit", _getUrlToSubmit_ORDER_HISTORY());
                 $smarty->hassign("urlToSort", _getUrlToSort_ORDER_HISTORY());
                 $smarty->assign("navigator", $navigatorHtml);
                 $smarty->assign("order_statuses", ostGetOrderStatues());
                 $smarty->assign("orders", $orders);
             }
             if ($_GET["customer_details"] == "visit_log") {
                 $callBackParam = array();
                 $visits = array();
                 $callBackParam["log"] = regGetLoginById($_GET["customerID"]);
                 $count = 0;
                 $navigatorHtml = GetNavigatorHtml(_getUrlToNavigate_VISIT_LOG(), 20, 'stGetVisitsByLogin', $callBackParam, $visits, $offset, $count);
                 $smarty->assign("navigator", $navigatorHtml);
                 $smarty->assign("visits", $visits);
             }
             if ($_GET['customer_details'] == 'affiliate') {
                 $customerID = $_GET["customerID"];
                 require 'core/includes/admin/sub/custord_custlist_affiliate.php';
             }
             $smarty->assign("customerID", $_GET["customerID"]);
             $smarty->assign("customer_details", $_GET["customer_details"]);
         }
     }
     $smarty->assign("admin_sub_dpt", "custord_custlist.tpl");
 }
Пример #3
0
function stChangeOrderStatus($orderID, $statusID, $comment = '', $notify = 0)
{
    $q_status_name = db_query("select status_name from " . ORDER_STATUES_TABLE . " where statusID=" . (int) $statusID);
    list($status_name) = db_fetch_row($q_status_name);
    $sql = "insert into " . ORDER_STATUS_CHANGE_LOG_TABLE . " ( orderID, status_name, status_change_time, status_comment ) " . " values( " . (int) $orderID . ", '" . xToText($status_name) . "', '" . xEscSQL(get_current_time()) . "', '" . xToText(trim($comment)) . "' ) ";
    db_query($sql);
    if ($notify) {
        $Order = ordGetOrder($orderID);
        $t = '';
        $Email = '';
        $FirstName = '';
        regGetContactInfo(regGetLoginById($Order['customerID']), $t, $Email, $FirstName, $t, $t, $t);
        if (!$Email) {
            $Email = $Order['customer_email'];
        }
        if (!$FirstName) {
            $FirstName = $Order['customer_firstname'];
        }
        xMailTxt($Email, STRING_CHANGE_ORDER_STATUS, 'customer.order.change_status.tpl', array('customer_firstname' => $FirstName, '_MSG_CHANGE_ORDER_STATUS' => str_replace(array('{STATUS}', '{ORDERID}'), array($status_name == 'STRING_CANCELED_ORDER_STATUS' ? STRING_CANCELED_ORDER_STATUS : $status_name, $orderID), MSG_CHANGE_ORDER_STATUS), '_ADMIN_COMMENT' => $comment));
    }
}
Пример #4
0
function regVerifyToDelete($customerID)
{
    if (!$customerID) {
        return 0;
    }
    $q = db_query("select count(*) from " . CUSTOMERS_TABLE . " where customerID=" . (int) $customerID);
    $row = db_fetch_row($q);
    if (regIsAdminiatrator(regGetLoginById($customerID))) {
        return false;
    }
    return $row[0] == 1;
}
Пример #5
0
         $Payment[0]['xDate'] = $Payment[0]['xDate'];
         $Payment[0]['customerLogin'] = regGetLoginById($Payment[0]['customerID']);
         $smarty->assign('Payment', html_spchars($Payment[0]));
     }
     $smarty->display("admin/custord_edit_payment.tpl");
     exit(1);
     break;
 case 'edit_commission':
     #this part for edit commission
     if (isset($error_message)) {
         $smarty->assign('Commission', html_spchars($_POST['COMMISSION']));
         $smarty->assign('error_message', $error_message);
     } else {
         $Commission = affp_getCommissions('', $_GET['cID']);
         $Commission[0]['xDateTime'] = $Commission[0]['xDateTime'];
         $Commission[0]['customerLogin'] = regGetLoginById($Commission[0]['customerID']);
         $smarty->assign('Commission', html_spchars($Commission[0]));
     }
     $smarty->display("admin/custord_edit_commission.tpl");
     exit(1);
     break;
 default:
     #this part will display all tables
     /**
      * check from-date and till-date
      */
     if (isset($_POST['from'])) {
         $_GET['from'] = $_POST['from'];
     }
     if (isset($_POST['till'])) {
         $_GET['till'] = $_POST['till'];
Пример #6
0
function serExportCustomersToExcel($customers)
{
    $maxCountAddress = 0;
    foreach ($customers as $customer) {
        $q = db_query("select count(*) from " . CUSTOMER_ADDRESSES_TABLE . " where customerID=" . $customer["customerID"]);
        $countAddress = db_fetch_row($q);
        $countAddress = $countAddress[0];
        if ($maxCountAddress < $countAddress) {
            $maxCountAddress = $countAddress;
        }
    }
    // open file to write
    $f = fopen("core/temp/customers.csv", "w");
    // head table generate
    $headLine = "Login;First name;Last name;Email;Group;Registered;Newsletter subscription;";
    $q = db_query("select reg_field_ID, reg_field_name from " . CUSTOMER_REG_FIELDS_TABLE . " order by sort_order ");
    while ($row = db_fetch_row($q)) {
        $headLine .= _filterBadSymbolsToExcel($row["reg_field_name"]) . ";";
    }
    for ($i = 1; $i <= $maxCountAddress; $i++) {
        $headLine .= "Address " . $i . ";";
    }
    fputs($f, $headLine . "\n");
    foreach ($customers as $customer) {
        $q = db_query("select Login, first_name, last_name, Email, custgroupID, reg_datetime, subscribed4news from " . CUSTOMERS_TABLE . " where addressID=" . (int) $customer["addressID"]);
        $row_cust = db_fetch_row($q);
        if ($row_cust["custgroupID"] != null) {
            $q = db_query("select custgroup_name from " . CUSTGROUPS_TABLE . " where custgroupID=" . $row_cust["custgroupID"]);
            $row = db_fetch_row($q);
            $row_cust["custgroup_name"] = $row["custgroup_name"];
        } else {
            $row_cust["custgroup_name"] = "";
        }
        if ($row_cust["subscribed4news"]) {
            $row_cust["subscribed4news"] = "+";
        } else {
            $row_cust["subscribed4news"] = "";
        }
        $line = "";
        $line .= _filterBadSymbolsToExcel($row_cust["Login"]) . ";";
        $line .= _filterBadSymbolsToExcel($row_cust["first_name"]) . ";";
        $line .= _filterBadSymbolsToExcel($row_cust["last_name"]) . ";";
        $line .= _filterBadSymbolsToExcel($row_cust["Email"]) . ";";
        $line .= _filterBadSymbolsToExcel($row_cust["custgroup_name"]) . ";";
        $line .= _filterBadSymbolsToExcel($row_cust["reg_datetime"]) . ";";
        $line .= $row_cust["subscribed4news"] . ";";
        $q_reg_param = db_query("select reg_field_ID, reg_field_name from " . CUSTOMER_REG_FIELDS_TABLE . " order by sort_order ");
        while ($row = db_fetch_row($q_reg_param)) {
            $q_reg_value = db_query("select reg_field_value from " . CUSTOMER_REG_FIELDS_VALUES_TABLE . " where reg_field_ID=" . $row["reg_field_ID"] . " AND customerID=" . $customer["customerID"]);
            $value = db_fetch_row($q_reg_value);
            $value = $value["reg_field_value"];
            $line .= _filterBadSymbolsToExcel($value) . ";";
        }
        $countAddress = 0;
        $addresses = regGetAllAddressesByLogin(regGetLoginById($customer["customerID"]));
        foreach ($addresses as $address) {
            $line .= " " . _filterBadSymbolsToExcel(regGetAddressStr($address["addressID"])) . ";";
            $countAddress++;
        }
        for ($i = 1; $i <= $maxCountAddress - $countAddress; $i++) {
            $line .= ";";
        }
        fputs($f, $line . "\n");
    }
    fclose($f);
}
Пример #7
0
/**
 * Return array with commission information by order id
 *
 * @param integer $_OrderID
 * @return array
 */
function affp_getCommissionByOrder($_OrderID)
{
    $sql = "select cID, customerID, Amount, CurrencyISO3, xDateTime, Description, CustomerID\n                FROM " . AFFILIATE_COMMISSIONS_TABLE . "\n                WHERE OrderID=" . (int) $_OrderID;
    $commission = db_fetch_row(db_query($sql));
    if (!$commission['cID']) {
        return $commission;
    }
    $commission['CustomerLogin'] = regGetLoginById($commission['customerID']);
    $commission['Amount'] = sprintf("%.2f", $commission['Amount']);
    list($_t) = explode(' ', $commission['xDateTime']);
    $commission['xDateTime'] = TransformDATEToTemplate($_t);
    return $commission;
}
Пример #8
0
                $smarty->assign('newCommissionStatus', '1');
            }
            if (isset($_GET['delete_pay'])) {
                $smarty->assign('delete_payment', 1);
            }
            if (isset($_GET['delete_commission'])) {
                $smarty->assign('delete_commission', 1);
            }
            $smarty->assign('CurrDate', $CurrDate);
            $smarty->assign('show_tables', $show_tables);
            $smarty->assign('from', html_spchars($_GET['from']));
            $smarty->assign('till', html_spchars($_GET['till']));
            $smarty->assign('Error_DateFormat', $error_date_format);
            $smarty->assign('REQUEST_URI', $XREQUEST_URI);
            $smarty->assign('htmlEmailNewCommission', settingCallHtmlFunction('CONF_AFFILIATE_EMAIL_NEW_COMMISSION'));
            $smarty->assign('htmlEmailNewPayment', settingCallHtmlFunction('CONF_AFFILIATE_EMAIL_NEW_PAYMENT'));
            $smarty->assign('htmlEnabledSettings', settingCallHtmlFunction('CONF_AFFILIATE_PROGRAM_ENABLED'));
            $smarty->assign('htmlAmountPercent', settingCallHtmlFunction('CONF_AFFILIATE_AMOUNT_PERCENT'));
            $smarty->assign("admin_sub_dpt", "custord_affiliate.tpl");
            if (!isset($_POST['NEW_PAYMENT'])) {
                $smarty->assign('NEW_PAYMENT', array('xDate' => $CurrDate));
            }
            if (!isset($_POST['NEW_COMMISSION'])) {
                $smarty->assign('NEW_COMMISSION', array('xDate' => $CurrDate));
            }
            if (isset($_GET['edCustomerID'])) {
                $smarty->assign('edCustomerLogin', regGetLoginById(intval($_GET['edCustomerID'])));
            }
            break;
    }
}