-// Add checkboxes for fields.
-if (in_array('cl', explode(',', $user->plugins)))
- $form->addInput(array('type'=>'checkbox','name'=>'chclient','data'=>1));
-if (($user->canManageTeam() || $user->isClient()) && in_array('iv', explode(',', $user->plugins)))
- $form->addInput(array('type'=>'checkbox','name'=>'chinvoice','data'=>1));
-if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode)
- $form->addInput(array('type'=>'checkbox','name'=>'chproject','data'=>1));
-if (MODE_PROJECTS_AND_TASKS == $user->tracking_mode)
- $form->addInput(array('type'=>'checkbox','name'=>'chtask','data'=>1));
-if ((TYPE_START_FINISH == $user->record_type) || (TYPE_ALL == $user->record_type)) {
- $form->addInput(array('type'=>'checkbox','name'=>'chstart','data'=>1));
- $form->addInput(array('type'=>'checkbox','name'=>'chfinish','data'=>1));
-}
-$form->addInput(array('type'=>'checkbox','name'=>'chduration','data'=>1));
-$form->addInput(array('type'=>'checkbox','name'=>'chnote','data'=>1));
-if (defined('COST_ON_REPORTS') && isTrue(COST_ON_REPORTS))
- $form->addInput(array('type'=>'checkbox','name'=>'chcost','data'=>1));
-// If we have a custom field - add a checkbox for it.
-if ($custom_fields && $custom_fields->fields[0])
- $form->addInput(array('type'=>'checkbox','name'=>'chcf_1','data'=>1));
+// Add checkboxes for "Show fields" block.
+if ($showClient)
+ $form->addInput(array('type'=>'checkbox','name'=>'chclient'));
+if ($showProject)
+ $form->addInput(array('type'=>'checkbox','name'=>'chproject'));
+if ($showTask)
+ $form->addInput(array('type'=>'checkbox','name'=>'chtask'));
+if ($showCustomFieldCheckbox)
+ $form->addInput(array('type'=>'checkbox','name'=>'chcf_1'));
+if ($showInvoiceCheckbox)
+ $form->addInput(array('type'=>'checkbox','name'=>'chinvoice'));
+if ($showPaidStatus)
+ $form->addInput(array('type'=>'checkbox','name'=>'chpaid'));
+$showIP = $user->can('view_reports') || $user->can('view_all_reports');
+if ($showIP)
+ $form->addInput(array('type'=>'checkbox','name'=>'chip'));
+$recordType = $user->getRecordType();
+$showStart = TYPE_START_FINISH == $recordType || TYPE_ALL == $recordType;
+$showFinish = $showStart;
+if ($showStart)
+ $form->addInput(array('type'=>'checkbox','name'=>'chstart'));
+if ($showFinish)
+ $form->addInput(array('type'=>'checkbox','name'=>'chfinish'));
+$form->addInput(array('type'=>'checkbox','name'=>'chduration'));
+$form->addInput(array('type'=>'checkbox','name'=>'chnote'));
+$form->addInput(array('type'=>'checkbox','name'=>'chcost'));
+$showWorkUnits = $user->isPluginEnabled('wu');
+if ($showWorkUnits)
+ $form->addInput(array('type'=>'checkbox','name'=>'chunits'));
+if ($showTimesheetCheckbox)
+ $form->addInput(array('type'=>'checkbox','name'=>'chtimesheet'));
+if ($showApproved)
+ $form->addInput(array('type'=>'checkbox','name'=>'chapproved'));
+$showFiles = $user->isPluginEnabled('at');
+if ($showFiles)
+ $form->addInput(array('type'=>'checkbox','name'=>'chfiles'));
+
+// Add a hidden control for timesheet_user_id (who to generate a timesheet for).
+if ($showTimesheetCheckbox)
+ $form->addInput(array('type'=>'hidden','name'=>'timesheet_user_id'));