Beispiel #1
0
function catv_FeeChargeAllUsers($month, $year)
{
    $month = mysql_real_escape_string($month);
    $year = vf($year);
    $catv_conf = catv_LoadConfig();
    $alltariffprices = catv_TariffGetAllPrices();
    $alluseractivity = catv_ActivityGetLastAll();
    $allusers = catv_UsersGetAll();
    $date = curdatetime();
    $admin = whoami();
    if (!empty($allusers)) {
        $usercount = 0;
        // begin user processing
        foreach ($allusers as $io => $eachuser) {
            $usercount = $usercount + 1;
            $monthlyfee = $alltariffprices[$eachuser['tariff']];
            $balance = $eachuser['cash'];
            $discount = $eachuser['discount'];
            if ($catv_conf['FEE_DISCOUNT']) {
                $finalfee = $monthlyfee - $discount;
            } else {
                $finalfee = $monthlyfee;
            }
            $newbalance = $balance - $finalfee;
            //if protect disconnected users
            if ($catv_conf['FEE_ONLY_ACTIVE']) {
                //check is user enabled?
                if ($alluseractivity[$eachuser['id']] != 0) {
                    //do the fee
                    $querycash = "UPDATE `catv_users` SET `cash` = '" . $newbalance . "' WHERE `id` = '" . $eachuser['id'] . "'; " . "\n";
                    nr_query($querycash);
                    //log the fee
                    $queryfee = "INSERT INTO `catv_fees` (`id` ,`date` ,`userid` ,`summ` ,`balance` ,`month` ,`year` ,`admin`) VALUES (NULL , '" . $date . "', '" . $eachuser['id'] . "', '" . $finalfee . "', '" . $balance . "', '" . $month . "', '" . $year . "', '" . $admin . "'); " . "\n";
                    nr_query($queryfee);
                }
            } else {
                //if protection disabled - just do it
                $querycash = "UPDATE `catv_users` SET `cash` = '" . $newbalance . "' WHERE `id` = '" . $eachuser['id'] . "'; " . "\n";
                nr_query($querycash);
                $queryfee = "INSERT INTO `catv_fees` (`id` ,`date` ,`userid` ,`summ` ,`balance` ,`month` ,`year` ,`admin`) VALUES (NULL , '" . $date . "', '" . $eachuser['id'] . "', '" . $finalfee . "', '" . $balance . "', '" . $month . "', '" . $year . "', '" . $admin . "'); " . "\n";
                nr_query($queryfee);
            }
        }
        log_register("CATV MONTHFEECHARGE " . $usercount);
    }
}
Beispiel #2
0
<?php

// check for right of current admin on this module
if (cfr('CATVTARIFFEDIT')) {
    catv_GlobalControlsShow();
    if (wf_CheckGet(array('userid'))) {
        $userid = $_GET['userid'];
        $catv_conf = catv_LoadConfig();
        $alltariffs = catv_TariffGetAllNames();
        $userdata = catv_UserGetData($userid);
        $currenttariff = $userdata['tariff'];
        $realname = $userdata['realname'];
        $address = $userdata['street'] . ' ' . $userdata['build'] . '/' . $userdata['apt'];
        //if someone changing tariff next month
        if (wf_CheckPost(array('newusertariffnm'))) {
            catv_UserSetTariffNM($userid, $_POST['newusertariffnm']);
            rcms_redirect("?module=catv_tariffedit&userid=" . $userid);
        }
        if ($catv_conf['TARIFF_NOW_CHANGE']) {
            //if someone changing tariff now
            if (wf_CheckPost(array('newusertariffnow'))) {
                catv_UserSetTariff($userid, $_POST['newusertariffnow']);
                rcms_redirect("?module=catv_tariffedit&userid=" . $userid);
            }
            show_window($address, $realname);
            $nowinputs = wf_Selector('newusertariffnow', $alltariffs, 'Tariff', $currenttariff, false);
            $nowinputs .= wf_Submit('Change right now');
            $nowform = wf_Form('', 'POST', $nowinputs, 'glamour', '');
            show_window(__('Edit tariff'), $nowform);
        }
        $editinputs = wf_Selector('newusertariffnm', $alltariffs, 'Tariff', $currenttariff, false);