nereliz Posted November 29, 2017 Report Posted November 29, 2017 Hi, I would like to built custom reports related to invoices. I do have multi company version so the problem is how to define that the query would return only current company entries? Is where predefined fields for that? Kind Regards, Nerijus Barauskas Quote
0 Blesta Addons Posted November 29, 2017 Report Posted November 29, 2017 you need to leftjoin the client_groups and select only the clients that has client_groups.company_id = (company_id) Quote
0 nereliz Posted November 29, 2017 Author Report Posted November 29, 2017 19 minutes ago, Blesta Addons said: you need to leftjoin the client_groups and select only the clients that has client_groups.company_id = (company_id) So company_id should be manually looked in company list. It would be better to introduce :company_id tag which when will take company_id from the session to reduce human error factor. As you still have company id to load custom report itself and the SQL could be copied and pasted between different companies easily. I have quite allot add-on companies to look after. Regards, Nerijus B. Quote
0 Tyson Posted November 29, 2017 Report Posted November 29, 2017 The custom report system allows you to select any data system-wide, so you can retrieve data for other companies as well if you see fit. Any tags, like one for :company_id, would have to be implemented yourself in the custom report. Even if a :company_id tag were available by default, your custom query would still need to define the appropriate joins in order to filter on it. Because of this, it is still best to define your query and all filters, including company_id, yourself. This also avoids unnecessary coupling between custom reports and current user session information of someone exporting the report. Note as well that reports can be generated via cron, and in the future there will likely be the addition for custom reports to do generated via cron, and in that case there would be no session information available to the report during creation. Quote
0 activa Posted December 4, 2017 Report Posted December 4, 2017 As i know the company_id has nothing to the session it resolved from domain !!! The idea of a tag or var called company_id is brillant . +1 . Quote
0 nereliz Posted December 4, 2017 Author Report Posted December 4, 2017 4 minutes ago, activa said: As i know the company_id has nothing to the session it resolved from domain !!! The idea of a tag or var called company_id is brillant . +1 . Hi, Activa you can get company_id in controllers or modules using Configure::get( "Blesta.company_id" ) or there $this->Session->read( "blesta_company_id" ). So this bit kind of already there, just then you build the SQL report you have to hard code it and do it for each add-on company. I understand you need to add all necessary JOIN statements to be able to use the company id as not all tables have this field. I thought I am missing something I can't relate. Thanks for your responses. Quote
0 Blesta Addons Posted December 4, 2017 Report Posted December 4, 2017 Blesta use in thier cron the fucntion $this->primeCompany($company) to set the company_id and langauge and settings ..ect to run the reports . also for the reports file already it use the company_id that is set in the cron file . so the core reports already support the company_id . Quote
Question
nereliz
Hi,
I would like to built custom reports related to invoices. I do have multi company version so the problem is how to define that the query would return only current company entries? Is where predefined fields for that?
Kind Regards,
Nerijus Barauskas
6 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.