/** * Sets credit for user, logs it, sets expire date and redirects in main profile * * @param string $user_login * @param float $tariffprice * @param int $sc_price * @param string $scend * @param int $sc_cashtypeid * * @return void */ function zbs_CreditDoTheCredit($user_login, $tariffprice, $sc_price, $scend, $sc_cashtypeid) { zbs_CreditLogPush($user_login); billing_setcredit($user_login, $tariffprice + $sc_price); billing_setcreditexpire($user_login, $scend); zbs_PaymentLog($user_login, '-' . $sc_price, $sc_cashtypeid, "SCFEE"); billing_addcash($user_login, '-' . $sc_price); show_window('', __('Now you have a credit')); rcms_redirect("index.php"); }
//check is tariff changing is enabled? if ($tc_enabled) { //check is TC allowed for current user tariff plan if (in_array($user_tariff, $tc_tariffenabledfrom)) { //tariff change subroutines if (isset($_POST['newtariff'])) { $change_prices = zbs_TariffGetChangePrice($tc_tariffsallowed, $user_tariff, $tc_priceup, $tc_pricedown, $tc_pricesimilar); if (in_array($_POST['newtariff'], $tc_tariffsallowed)) { // agreement check if (isset($_POST['agree'])) { // and not enought money, set credit if ($user_cash < $change_prices[$_POST['newtariff']]) { //if TC_CREDIT option enabled if ($tc_credit) { $newcredit = $change_prices[$_POST['newtariff']] + $user_credit; billing_setcredit($user_login, $newcredit); // check for current credit expirity - added in 0.5.7 // without this check this conflicts with SC_ module if (!$user_credit_expire) { //set credit expire date for month from this moment $timestamp = time(); $monthOffset = $timestamp + 2678400; // 31 days in seconds $creditend = date("Y-m-d", $monthOffset); billing_setcreditexpire($user_login, $creditend); } } } //TC change fee anyway zbs_PaymentLog($user_login, '-' . $change_prices[$_POST['newtariff']], $tc_cashtypeid, "TCHANGE:" . $_POST['newtariff']); billing_addcash($user_login, '-' . $change_prices[$_POST['newtariff']]);
function setcredit($login, $credit) { $login = trim($login); $credit = trim($credit); billing_setcredit($login, $credit); }