Last active
July 17, 2021 20:22
-
-
Save Lippur/dcc0e37e605438f28e09a4f83cfacb18 to your computer and use it in GitHub Desktop.
Bulk add credits in WHMCS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
insert into tblcredit (clientid, admin_id, date, description, amount, relid) | |
select userid as clientid, 0, 'DATE', 'DESCRIPTION', creditamount as amount, 0 | |
from ( | |
select round(amount * 0.2, 2) as creditamount, userid, billingcycle, domainstatus | |
from (select userid, amount, billingcycle, domainstatus | |
from tblhosting | |
where billingcycle = 'Monthly') as monthly | |
union | |
select round(amount / 3 * 0.2, 2) as creditamount, userid, billingcycle, domainstatus | |
from (select userid, amount, billingcycle, domainstatus | |
from tblhosting | |
where billingcycle = 'Quarterly') as quarterly | |
union | |
select round(amount / 6 * 0.2, 2) as creditamount, userid, billingcycle, domainstatus | |
from (select userid, amount, billingcycle, domainstatus | |
from tblhosting | |
where billingcycle = 'Semi-Annually') as semiannual | |
union | |
select round(amount / 12 * 0.2, 2) as creditamount, userid, billingcycle, domainstatus | |
from (select userid, amount, billingcycle, domainstatus | |
from tblhosting | |
where billingcycle = 'Annually') as annual | |
) as credit | |
where domainstatus = 'Active' | |
and creditamount > 0; | |
update tblclients join tblcredit on clientid = tblclients.id set credit = credit + amount where date = 'DATE'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment