Wow, creepy, this is exactly the thing I came here today to ask. I posted a question about this almost 7 1/2 years ago, I feel like I’ve tried everything out there, and still no solution that wouldn’t require rewriting half of it to make me happy. (Invoice Ninja is the closest I’ve found, but it would still require me editing the source to fix a couple of bugs and add quite a few features that it doesn’t have, or change the way some of them work.)
Today I’ve been looking through tons of MODX extras and of course reading tutorials on Bob’s website (
https://bobsguides.com/blog.html). I’ve started collecting links that will allow me to start building this thing, but I’m concerned some of the instructions and extras may be outdated.
Also, I’ve decided I want to create this in the manager rather than creating resources and abusing form customization like I normally do in the manager interface. Give it its own menu option and keep it separate from everything else. Note my other concern is that I’ve never actually done this before.
My list of features is almost identical to yours, except I’m not doing estimates, but it shouldn’t be a lot different than projects, I wouldn’t think. Pardon a long post (really, all my posts tend to be long, sorry), but I’d like to list them along with the methods I’m considering and see what everyone thinks.
Note: I’m writing this expecting to do a lot of custom programming. If you’re not a coder, I’ll include links to extras that will handle a decent bit of the functionality. Sorry I couldn’t link the links, I had them nicely formatted, but as a “new user” I’m apparently only allowed to include two. (I only registered here today, unfortunately it doesn’t know that I registered on the other one back before there was a Revo and I was doing everything in Evo. )
While I could use Class Extender (
https://bobsguides.com/classextender-class.html) on the users, there’s so much extra involved with this that I want to do it using CMPs (
https://bobsguides.com/blog.htmltags/custom+manager+page). CMPGenerator (
https://docs.modx.com/extras/revo/cmpgenerator) might be an alternative to doing it manually, but it doesn’t look like it’s been updated in at least four years, and Bob’s tutorials are from last year. (And doing it manually means I actually understand what I’m doing.)
Similar to the above. (And I don’t feel like rewriting these paragraphs, so I’ll just say here that if I was using resources instead of CMPs, I’d be using the extras below on the client page as well, so the interface would just have one page with the children hidden.) The projects would be listed (along with an add button and a link to view them) on the appropriate client page as well as their own menu option/page. I’ve done this on resources by using Collections (
https://docs.modx.com/extras/revo/collections), and GridClassKey
(https://docs.modx.com/extras/revo/gridclasskey) is one I found today that looks cool that I’m going to try in the future (snippets on a grid!). Anyway, it would work something like that, assuming I can find the right code to copy. (Hey @bobray, I don’t suppose you have any sample code for the CMP you talk about here (
https://bobsguides.com/blog.html/2013/05/22/debugging-cmps-a-horror-story/)? Either way, I suspect I’ll be using that debugging advice quite a bit.) Project numbering could just be a bit of code that increments the previous project number for that client. Expenses could be added in a similar way that tasks are added.
Again, similar to the above, its own menu option. Mostly I think I’d be using this for recurring invoices (listing different hosting plans), but you could use them for other types of services you offer, or just put “Web Development” or similar and have another field on the invoice if you want to enter something more specific. This one is really optional, a description field is probably enough,
Creating Invoices from Projects
I’d output these in a PDF and save on the server. For that, I might create a resource that acts as a template, or depending on how the code I use works, a template on the server. (Or a couple/few of them if I used different ones for different things.) I’d probably generate it on the project page and simply use code to add up the time and get whatever other info you want and fill out the template and save in a directory for that client. You could invoice multiple projects by using checkboxes on the client page, but that’s more complicated than I need for v1. Once the invoice is generated and saved in the DB, something like PDFResource (
https://modx.com/extras/package/pdfresource) could be used to generate the PDF. Although I think you’d have to create a temp resource to use that, which seems like a bit of a waste to me, so I’d probably use mPDF (
http://www.mpdf1.com/) directly (or some other PDF generator if I find a better/easier one). Once the PDF is created, I’d display it to proof-read it, and have a button that ran some code to generate an email, attach the PDF, email it to the client, and update the invoice (in the db) noting that it was mailed and the date/time. If you want to email it as HTML and don’t mind creating a temp resource (or are saving everything as separate resources), there’s EmailResource (
https://bobsguides.com/emailresource-plugin-tutorial.html), although I think you’d have to modify it to send to a user rather than a group. There’s also Notify (
https://bobsguides.com/notify-tutorial.html), although as-is, I’m not sure it would work for this. Personally, if I wanted to send a link to an invoice, I’d just use code and send the client a link that went to a page that displayed the invoice. (Obviously you’d want to obfuscate the URL parameters so people couldn’t just guess invoice numbers. I don’t want/need to have a client portal any time soon.) One advantage of displaying the invoice on the server is that you could add links to things like PayPal. You can do that in the PDF, but I’m not sure if that works on all viewers and it tends to give security warnings.
I’m going to use web hosting as an example. Associated with each client that I hosted would be the start date for their hosting period, domain(s), etc. I could add an end date, but it would be easier/better just to calculate it in code. (Ex: Date of October 16 = October 16, 2019 - October 15, 2020.) I’d run code once a day/night with CronManager (
https://docs.modx.com/extras/revo/cronmanager), check if any invoices were due, generate them, and then for each, send myself an email notification with a link to the page to view and email the invoice. (I don’t want it sending out anything without me having looked it over first.) Like everything else, I’d also have a page where I could view a list of all hosting clients.
I haven’t given much thought to this yet, but it could just simply be done with another cron job that checks when the invoice was sent and emails the client X (Y, Z,whatever) days afterward, You could also create code that would add late fees. If I did that, I’d generate a new invoice, not overwrite the old one but I’d add code that redirected to the latest one for the client if I was linking to them online,
Eventually I’d probably add reporting. Once I have all the code for generating the interface, it would just be a matter of querying whatever fields I wanted and displaying them.
I haven’t given much thought to this either, but it would be nice to have. (Later.) It could show upcoming recurring invoices as well as anything else you wanted to add.
I’d probably also figure out how to create a transport package (
https://bobsguides.com/mycomponent-tutorial.html) so I could share this with the world, because really, this is going to be a lot of work for me to be the only one using it. And testers are really nice to have.
Thankfully I’ll only be using this for myself to start with. Assigning projects/tasks to other people wouldn’t be that difficult, but definitely not something I want to deal with yet.
So yeah, I definitely think it’s feasible (especially after writing it out), just do it in stages. (For example, I’d start by creating clients, projects, tasks, products, and recurring charges (the code for those would be pretty similar), and keep generating invoices manually until I had time to get to the next part.) As for biting off more than you can chew, I’m probably doing the same. Keeps things interesting, though.
If you’re not a coder, just take it slowly and look for more extras to handle what you want if you don’t have it. (Suggestions welcome!) Or if I actually manage to get started on this, I may have some code I could turn into a snippet for you. (Can you PM people in this forum?)
Learning to create CMPs and connect the various pages usefully is going to be my biggest challenge. (Anyone know if you can use snippets in CMPs?) The rest of it seems pretty easy in comparison.
Ok, wall-of-text complete. I hope there was something useful for you (or someone) in all of that.