It’s possible, definitely in InvoicePlane V2, but in v1 it’s possible as well.
Issue for V2: [FEATURE] Dashboard needs RecurringInvoices widget · Issue #127 · InvoicePlane/InvoicePlane-v2 · GitHub
Improve / prepare dashboard view
Go to application/modules/dashboard and let’s start with “views”
Those will be your “widgets” you’ll see at the dashboard at the moment.
Add your recurring invoices widget.
Add information to Dashboard Controller
Now you need to make sure the data you desire is sent to the dashboard
For that you go to your Dashboard Controller: application/modules/dashboard/controllers/Dashboard.php
There is a bunch of data gathered for that view
'invoice_status_totals' => $this->mdl_invoice_amounts->get_status_totals($invoice_overview_period),
'quote_status_totals' => $this->mdl_quote_amounts->get_status_totals($quote_overview_period),
Add your desired line there as well, probably comes from $this->mdl_invoices_recurring
See these lines that load the model?
$this->load->model('invoices/mdl_invoices');
Add your line that loads your model as well
Improve Recurring Invoices Model
Back to the model that needs to gather your requested data.
application/modules/invoices/models/Mdl_invoices_recurring.php
Create your own function that gathers this information for you
The SQL
Just think for yourself:
- I want all recurring invoices
- from an overview period that comes fron the settings (invoices in this case)
- grouped by …
- columns x, y, z
Then copy/paste the “default_select” function and give it your name
In your Dashboard Controller use that function with that new name.
Debugging
InvoicePlane added 2 functions some time ago:
dump(): only shows variable and just keeps the script going
dd(): shows variable and stops the script
I would recommend dd() in a heartbeat
But if you’re using the .zip version those 2 functions aren’t available.
In that case just use:
print_r($variable);
die('stopped script execution');
You can dd() or use print_r() at any point, so in the Controller, in the Model or even in the View
Summary
- Change controller
- Change model, add new function
- Change view to use data of that new function
The Model gets data from the database
The Controller gets it from the Model and sends it to the View
The View presents that data to you (in that “widget”)