-// If we have a TYPE_DROPDOWN custom field - add control to select an option.
-if ($custom_fields && $custom_fields->fields[0] && $custom_fields->fields[0]['type'] == CustomFields::TYPE_DROPDOWN) {
- $form->addInput(array('type'=>'combobox','name'=>'option',
- 'style'=>'width: 250px;',
- 'value'=>$cl_cf_1,
- 'data'=>$custom_fields->options,
- 'empty'=>array(''=>$i18n->get('dropdown.all'))));
+// If we have a TYPE_DROPDOWN custom field - add a control to select an option.
+if ($showCustomFieldDropdown) {
+ $form->addInput(array('type'=>'combobox','name'=>'option',
+ 'style'=>'width: 250px;',
+ 'value'=>$cl_cf_1,
+ 'data'=>$custom_fields->options,
+ 'empty'=>array(''=>$i18n->get('dropdown.all'))));
+}
+
+// Add project dropdown.
+$showProject = MODE_PROJECTS == $trackingMode || MODE_PROJECTS_AND_TASKS == $trackingMode;
+if ($showProject) {
+ if ($user->can('view_reports') || $user->can('view_all_reports')) {
+ $project_list = ttProjectHelper::getProjects(); // All active and inactive projects.
+ } elseif ($user->isClient()) {
+ $project_list = ttProjectHelper::getProjectsForClient();
+ } else {
+ $project_list = ttProjectHelper::getAssignedProjects($user->getUser());
+ }
+ if (count($project_list) == 0) $showProject = false;
+}
+if ($showProject) {
+ $form->addInput(array('type'=>'combobox',
+ 'onchange'=>'fillTaskDropdown(this.value);selectAssignedUsers(this.value);',
+ 'name'=>'project',
+ 'style'=>'width: 250px;',
+ 'data'=>$project_list,
+ 'datakeys'=>array('id','name'),
+ 'empty'=>array(''=>$i18n->get('dropdown.all'))));