Jump to content

Auto-Close Account


Recommended Posts

Here's a sql query we run daily, which will set a customer to inactive if they have no services, domains, open invoices, and are not affiliates. You can change 'Inactive' to 'Closed'.

 

update  tblclients c
set     status = 'Inactive'
where	status = 'Active'
and     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

  • 3 weeks later...
Here's a sql query we run daily, which will set a customer to inactive if they have no services, domains, open invoices, and are not affiliates. You can change 'Inactive' to 'Closed'.

 

update  tblclients c
set     status = 'Inactive'
where    status = 'Active'
and     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);

 

This is exactly what I am after, works perfectly for me and did what I wanted it to do. Is there a way this can be implemented in to a script, or can we simply just run this as a daily task...? :-P

Link to comment
Share on other sites

new update be up in hrs that now you can disable closed account :)

 

Actually didn't work very well after paying for it, I set it to "CLOSE" accounts after 365 days and set them inactive from periods before that date after they no longer had active services with us, surprisingly it closed random accounts and left accounts inactive way back from 2009 :roll:

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