-// Do we need to show checkboxes?
-if ($bean->getAttribute('chpaid') ||
- ($client_id && $bean->getAttribute('chinvoice') && ('no_grouping' == $bean->getAttribute('group_by')) && !$user->isClient())) {
- if ($user->can('manage_invoices'))
- $smarty->assign('use_checkboxes', true);
+// Do we need to show checkboxes? We show them in the following 4 situations:
+// - We can approve items.
+// - We can mark items as paid.
+// - We can sssign items to invoices.
+// - We can assign items to a timesheet.
+// Determine these conditions separately.
+if ($bean->getAttribute('chapproved') && ($user->can('approve_reports') || $user->can('approve_all_reports')))
+ $useMarkApproved = true;
+if ($bean->getAttribute('chpaid') && $user->can('manage_invoices'))
+ $useMarkPaid = true;
+if ($bean->getAttribute('chinvoice') && $client_id && 'no_grouping' == $bean->getAttribute('group_by1') && !$user->isClient() && $user->can('manage_invoices'))
+ $useAssignToInvoice = true;
+if ($bean->getAttribute('chtimesheet')) {
+ $timesheets = ttTimesheetHelper::getMatchingTimesheets($options);
+ if ($timesheets) $useAssignToTimesheet = true;
+}
+
+$use_checkboxes = $useMarkApproved || $useMarkPaid || $useAssignToInvoice || $useAssignToTimesheet;
+if ($use_checkboxes)
+ $smarty->assign('use_checkboxes', true);
+
+// Controls for "Mark approved" block.
+if ($useMarkApproved) {
+ $mark_approved_select_options = array('1'=>$i18n->get('dropdown.all'),'2'=>$i18n->get('dropdown.select'));
+ $form->addInput(array('type'=>'combobox',
+ 'name'=>'mark_approved_select_options',
+ 'data'=>$mark_approved_select_options,
+ 'value'=>$cl_mark_approved_select_option));
+ $mark_approved_action_options = array('1'=>$i18n->get('dropdown.approved'),'2'=>$i18n->get('dropdown.not_approved'));
+ $form->addInput(array('type'=>'combobox',
+ 'name'=>'mark_approved_action_options',
+ 'data'=>$mark_approved_action_options,
+ 'value'=>$cl_mark_approved_action_option));
+ $form->addInput(array('type'=>'submit','name'=>'btn_mark_approved','value'=>$i18n->get('button.submit')));
+ $smarty->assign('use_mark_approved', true);