Jump to content

inactive to closed clients


Recommended Posts

I've recently merged over from moderbill and it seems all of our clients that were listed as inactive with moderbill are getting auto-batched. Somehow I need to change all inactive clients to closed. Is there a fast and easy way to do this or am I going to have to go client by client?? Any help will be much appreciated!

 

Thanks.

Link to comment
Share on other sites

Execute this query directly against the WHMCS database, via phpMyAdmin or some such:

 

update   tblclients
set      status = 'Closed'
where    status = 'Inactive'

 

Simple as that. Backup your database first, of course.

 

Or, do something perhaps more thorough - close all accounts with no active or pending services, no unpaid invoices, and who are not affiliates:

 

update  tblclients c
set     status = 'Closed'
where   not exists (select 1 from tblhosting where userid = c.id and domainstatus in ('Active', 'Pending'))
and     not exists (select 1 from tbldomains where userid = c.id and status in ('Active', 'Pending', 'Pending Transfer'))
and     not exists (select 1 from tblinvoices where userid = c.id and status = 'Unpaid')
and     not exists (select 1 from tblaffiliates where clientid = c.id)

Link to comment
Share on other sites

Just in case anyone uses this, I figured I should post one modification - the addition of "Suspended" to the list of hosting statuses which should be disregarded in closing accounts.

 

update  tblclients c
set     status = 'Closed'
where   not exists (select 1 from tblhosting where userid = c.id and domainstatus in ('Active', 'Pending', 'Suspended'))
and     not exists (select 1 from tbldomains where userid = c.id and status in ('Active', 'Pending', 'Pending Transfer'))
and     not exists (select 1 from tblinvoices where userid = c.id and status = 'Unpaid')
and     not exists (select 1 from tblaffiliates where clientid = c.id)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated