- $sql = "update tt_log l
- left join tt_user_project_binds upb on (upb.user_id = l.user_id and upb.project_id = l.project_id)
- set l.invoice_id = $last_id
- where l.status = 1 and l.client_id = $client_id $project_part and l.invoice_id is NULL
- and l.date >= ".$mdb2->quote($start)." and l.date <= ".$mdb2->quote($end)."
- and l.billable = 1"; // l.billable * upb.rate * time_to_sec(l.duration)/3600 > 0";
+ $sql = "update tt_log l".
+ " left join tt_user_project_binds upb on (upb.user_id = l.user_id and upb.project_id = l.project_id)".
+ " set l.invoice_id = $last_id".
+ " where l.status = 1 and l.client_id = $client_id $project_part and l.invoice_id is null".
+ " and l.group_id = $group_id and l.org_id = $org_id".
+ " and l.date >= ".$mdb2->quote($start)." and l.date <= ".$mdb2->quote($end).
+ " and l.billable = 1"; // l.billable * upb.rate * time_to_sec(l.duration)/3600 > 0";