Hi all
I’ve been developing a timesheet module for us to track time spent on client matters and to make checking and invoicing them as easy as possible. I now ran into problems trying to develop an action to convert checked timesheets into invoices. What we are trying to achieve is get employees track their time by creating timesheets, marking their actual and billable time, price (relating to products), text for invoice and so on. All timesheets are then checked by supervisors, and checked and approved timesheets would then be added to an invoice for the client.
I’ve got all other functionality up and running, but I’ve ran into problems trying to collect timesheets to the invoices. After a frustrating evening of debugging I’ve finally found the reason: the get_full_list method doesn’t apparently accept logical operators and so I cannot use multiple ‘where’ criteria. Is this the intended action or am I doing something wrong?
To demonstrate, here’s the code. Note that we are using a custom “Matters” to keep track of client matters, which then can include billable work on projects, cases etc. One can either invoice all timesheets of a matter or just some part of it, e.g. a project or a single case. Currently this depends on the record from which the invoicing action is initiated from.
//// TIMESHEETS ////
// Produce a list of Timesheet beans.
$timesheetBean = BeanFactory::getBean('LWS_Timesheets');
if ($parentmodule != 'LWS_Matters') {
// if we are invoicing only part of a matter (e.g. project), we'll retrieve according to the parent.
$timesheetList = $timesheetBean->get_full_list(
'date_booked',
"parent_id = '" . $parentBean->id . "'",
); //get_full_list
} elseif ($parentmodule == 'LWS_Matters') {
// If we are invoicing full matter, we'll retrieve by the parent matter. TODO: Sort these by parents, if multiple.
$timesheetList = $timesheetBean->get_full_list(
'date_booked',
"lws_matters_id_c = '" . $matterBean->id . "'",
); //get_full_list
} //if
This version seems to work, but I still need to separately filter all records except those with status = ‘Checked’. However the method returned NULL when I tried using AND to add more conditions. To be clear, the same clause worked when I tried in phpmyadmin. Example returning NULL:
// if we are invoicing only part of a matter (e.g. project), we'll retrieve according to the parent.
$timesheetList = $timesheetBean->get_full_list(
'date_booked',
"parent_id = '" . $parentBean->id . "' AND status = 'Checked'",
); //get_full_list
Have I misunderstood something, is this an intended yet undocumented limitation or have I stumbled accross a bug that shouldn’t be there?