Skip to content

Instantly share code, notes, and snippets.

@agarzon
Last active January 9, 2019 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save agarzon/d8634fda108c7a4c5a1c to your computer and use it in GitHub Desktop.
Save agarzon/d8634fda108c7a4c5a1c to your computer and use it in GitHub Desktop.
Generate report with all domains by client and plan (plesk)
SELECT domains.name as domain, Templates.name as plan, domains.status, clients.type, clients.login, clients.pname, clients.email, clients.external_id, Subscriptions.locked, Subscriptions.synchronized, Subscriptions.custom
FROM domains
LEFT JOIN clients ON domains.cl_id = clients.id
LEFT JOIN Subscriptions ON domains.id = Subscriptions.object_id AND Subscriptions.object_type = 'domain'
LEFT JOIN PlansSubscriptions ON Subscriptions.id = PlansSubscriptions.subscription_id
LEFT JOIN Templates ON PlansSubscriptions.plan_id = Templates.id
WHERE clients.type = 'client'
AND clients.parent_id = '1'
AND domains.parentDomainId = '0'
INTO OUTFILE '/tmp/domains-client.csv';
# Reseller
SELECT Templates.name as plan, clients.status, clients.type, clients.login, clients.pname, clients.email, clients.external_id, Subscriptions.locked, Subscriptions.synchronized, Subscriptions.custom
FROM `clients`
LEFT JOIN Subscriptions ON clients.id = Subscriptions.object_id AND Subscriptions.object_type = 'client'
LEFT JOIN PlansSubscriptions ON Subscriptions.id = PlansSubscriptions.subscription_id
LEFT JOIN Templates ON PlansSubscriptions.plan_id = Templates.id
WHERE clients.type = 'reseller'
INTO OUTFILE '/tmp/reseller-client.csv';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment