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)); $smarty->assign('CommissionsAmount', $Commissions); $smarty->assign('PaymentsAmount', $Payments); $smarty->assign('CurrencyISO3', currGetAllCurrencies()); break; case 'payments_history': $Payments = affp_getPayments($customerID); $smarty->assign('PaymentsNumber', count($Payments)); $smarty->assign('Payments', html_spchars(affp_getPayments($customerID, '', '', '', 'pID ASC'))); break; case 'settings': $smarty->assign('SettingsSaved', isset($_GET['save_settings'])); $smarty->assign('Settings', affp_getSettings($customerID)); break; case 'attract_guide': $smarty->assign('_AFFP_STRING_ATTRACT_GUIDE', str_replace(array('{URL}', '{aff_percent}', '{login}'), array('http://' . $_SERVER['HTTP_HOST'] . set_query('') . '?refid=' . $customerID, CONF_AFFILIATE_AMOUNT_PERCENT, $_SESSION["log"]), AFFP_STRING_ATTRACT_GUIDE)); break; } $smarty->assign('affiliate_customers', $affp_CustomersNum); $smarty->assign('SubPage', $SubPage); $smarty->assign("main_content_template", "affiliate_program.tpl"); }
/** * Add commission to customer from order * * @param integer - order id */ function affp_addCommissionFromOrder($_orderID) { $Commission = affp_getCommissionByOrder($_orderID); if ($Commission['cID']) { return 0; } $Order = ordGetOrder($_orderID); if ($Order['customerID']) { $RefererID = affp_getReferer($Order['customerID']); } else { $RefererID = $Order['affiliateID']; } if (!$RefererID) { return 0; } $CustomerLogin = regGetLoginById($Order['customerID']); if (!$CustomerLogin) { $CustomerLogin = $Order['customer_email']; } $Commission = array('Amount' => sprintf("%.2f", $Order['currency_value'] * $Order['order_amount'] * CONF_AFFILIATE_AMOUNT_PERCENT / 100), 'CurrencyISO3' => $Order['currency_code'], 'xDateTime' => date("Y-m-d H:i:s"), 'OrderID' => $_orderID, 'CustomerID' => $RefererID, 'Description' => xEscSQL(str_replace(array('{ORDERID}', '{USERLOGIN}'), array($_orderID, $CustomerLogin), AFFP_COMMISSION_DESCRIPTION))); do { if (CONF_AFFILIATE_EMAIL_NEW_COMMISSION) { $Settings = affp_getSettings($RefererID); if (!$Settings['EmailOrders']) { break; } $t = ''; $Email = ''; $FirstName = ''; regGetContactInfo(regGetLoginById($RefererID), $t, $Email, $FirstName, $t, $t, $t); xMailTxt($Email, AFFP_NEW_COMMISSION, 'customer.affiliate.commission_notifi.tpl', array('customer_firstname' => $FirstName, '_AFFP_MAIL_NEW_COMMISSION' => str_replace('{MONEY}', $Commission['Amount'] . ' ' . $Commission['CurrencyISO3'], AFFP_MAIL_NEW_COMMISSION))); } } while (0); affp_addCommission($Commission); }