I want to set expectations about the complexity of this task. I'm not in the habit of critiquing one of the smartest programmers I know, however, while
@edossantos_sipcaller offers a valid solution, querying the CDR records directly is not at all straightforward.
First, you would need to get a list of CDR files, open each file one at a time, parse the data, evaluate the call chain field (list of extensions that touched the call) and repeat for every CDR file (if CDR is configured for one file per call). This also suggests that you cannot delete any CDR files for a specified amount of time (how far back in history you want to go). This approach is complex and would require time and resources for every single call.
The suggestion by
@ConceptsWeb has the potential to be more efficient given that the data is collected automatically and saved in a database as each call takes place, however, this means your CFD application needs to know how to authenticate to the CRM and GET the required data. Perhaps the "CRM" is just a simple database with the necessary APIs? This entire solution is also complicated.
The third approach is perhaps the most complex solution -- subscribe to the 3CX real-time call events and save the data yourself in a database and then have the CFD query this database..
While the three of us are capable programmers (
@edossantos_sipcaller,
@ConceptsWeb, and
@VoIPTools), we have to recognize that none of the above options are out-of-the-box solutions. All the proposed solutions require a fairly capable programmer and are not something most 3CX Admins can do, let alone a typical 3CX customer.