Beispiel #1
0
 public function configure()
 {
     $projects = $this->getOption('projects');
     $sf_user = $this->getOption('sf_user');
     $this->widgetSchema['tasks_status_id'] = new sfWidgetFormChoice(array('choices' => app::getItemsChoicesByTable('TasksStatus')));
     $this->setDefault('tasks_status_id', app::getDefaultValueByTable('TasksStatus'));
     $this->widgetSchema['tasks_priority_id'] = new sfWidgetFormChoice(array('choices' => app::getItemsChoicesByTable('TasksPriority')));
     $this->setDefault('tasks_priority_id', app::getDefaultValueByTable('TasksPriority'));
     $this->widgetSchema['tasks_type_id'] = new sfWidgetFormChoice(array('choices' => app::getItemsChoicesByTable('TasksTypes')));
     $this->setDefault('tasks_type_id', app::getDefaultValueByTable('TasksTypes'));
     $this->widgetSchema['tasks_label_id'] = new sfWidgetFormChoice(array('choices' => app::getItemsChoicesByTable('TasksLabels')));
     $this->setDefault('tasks_label_id', app::getDefaultValueByTable('TasksLabels'));
     $this->widgetSchema['tasks_groups_id'] = new sfWidgetFormChoice(array('choices' => app::getItemsChoicesByTable('TasksGroups', true, $projects->getId())));
     $this->widgetSchema['projects_phases_id'] = new sfWidgetFormChoice(array('choices' => app::getItemsChoicesByTable('ProjectsPhases', true, $projects->getId())));
     $this->widgetSchema['versions_id'] = new sfWidgetFormChoice(array('choices' => app::getItemsChoicesByTable('Versions', true, $projects->getId())));
     $this->widgetSchema['progress'] = new sfWidgetFormChoice(array('choices' => Tasks::getProgressChoices()));
     $this->widgetSchema['assigned_to'] = new sfWidgetFormChoice(array('choices' => Users::getChoices(array_merge(array($sf_user->getAttribute('id')), array_filter(explode(',', $projects->getTeam()))), 'tasks'), 'expanded' => true, 'multiple' => true));
     if (Users::hasAccess('edit', 'projects', $sf_user, $projects->getId())) {
         $this->widgetSchema['created_by'] = new sfWidgetFormChoice(array('choices' => Users::getChoices(array_merge(array($sf_user->getAttribute('id')), array_filter(explode(',', $projects->getTeam()))), 'tasks_insert')));
     } else {
         $this->widgetSchema['created_by'] = new sfWidgetFormInputHidden();
     }
     $this->widgetSchema['name']->setAttributes(array('size' => '60', 'class' => 'required'));
     $this->widgetSchema['description']->setAttributes(array('class' => 'editor'));
     $this->widgetSchema['estimated_time']->setAttributes(array('size' => '4'));
     $this->widgetSchema['start_date'] = new sfWidgetFormInput(array(), array('class' => 'datetimepicker'));
     $this->widgetSchema['due_date'] = new sfWidgetFormInput(array(), array('class' => 'datetimepicker'));
     $this->widgetSchema['projects_id'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['closed_date'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['created_at'] = new sfWidgetFormInputHidden();
     $this->setDefault('created_at', date('Y-m-d H:i:s'));
     $this->widgetSchema->setLabels(array('tasks_priority_id' => 'Priority', 'tasks_type_id' => 'Type', 'tasks_label_id' => 'Label', 'projects_phases_id' => 'Phase', 'versions_id' => 'Version', 'tasks_groups_id' => 'Group', 'tasks_status_id' => 'Status', 'estimated_time' => 'Estimated Time', 'start_date' => 'Start Date', 'due_date' => 'Due Date', 'created_by' => 'Created By'));
     unset($this->widgetSchema['discussion_id']);
     unset($this->widgetSchema['tickets_id']);
     unset($this->widgetSchema['work_hours']);
     unset($this->validatorSchema['discussion_id']);
     unset($this->validatorSchema['tickets_id']);
     unset($this->validatorSchema['work_hours']);
 }
Beispiel #2
0
                      <?php 
echo $form['worked_hours']->renderError();
?>
                      <?php 
echo $form['worked_hours'];
?>
                    </td>
                  </tr>
                  <tr>
                    <th><?php 
echo __('Progress');
?>
</th>
                    <td>
                      <?php 
echo select_tag('progress', $tasks->getProgress(), array('choices' => Tasks::getProgressChoices()));
?>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
          
          <table>
          <tr>
            <th><?php 
echo $form['description']->renderLabel();
?>
</th>
            <td>
Beispiel #3
0
 public function executeMultipleEdit(sfWebRequest $request)
 {
     if ($request->hasParameter('projects_id')) {
         $this->forward404Unless($this->projects = Doctrine_Core::getTable('Projects')->createQuery()->addWhere('id=?', $request->getParameter('projects_id'))->fetchOne(), sprintf('Object projects does not exist (%s).', $request->getParameter('projects_id')));
         $this->checkProjectsAccess($this->projects);
         $this->checkTasksAccess('edit', false, $this->projects);
     } else {
         $this->checkTasksAccess('edit');
     }
     $this->fields = array();
     $this->numeric_fields = array();
     $choices = app::getItemsChoicesByTable('TasksPriority', true);
     if (count($choices) > 1) {
         $this->fields['tasks_priority_id'] = array('title' => t::__('Priority'), 'choices' => $choices);
     }
     $choices = app::getItemsChoicesByTable('TasksLabels', true);
     if (count($choices) > 1) {
         $this->fields['tasks_label_id'] = array('title' => t::__('Label'), 'choices' => $choices);
     }
     $choices = app::getItemsChoicesByTable('TasksStatus', true);
     if (count($choices) > 1) {
         $this->fields['tasks_status_id'] = array('title' => t::__('Status'), 'choices' => $choices);
     }
     $choices = app::getItemsChoicesByTable('TasksTypes', true);
     if (count($choices) > 1) {
         $this->fields['tasks_type_id'] = array('title' => t::__('Type'), 'choices' => $choices);
     }
     if ($request->hasParameter('projects_id')) {
         $choices = app::getItemsChoicesByTable('TasksGroups', true, $request->getParameter('projects_id'));
         if (count($choices) > 1) {
             $this->fields['tasks_groups_id'] = array('title' => t::__('Group'), 'choices' => $choices);
         }
         $choices = app::getItemsChoicesByTable('Versions', true, $request->getParameter('projects_id'));
         if (count($choices) > 1) {
             $this->fields['versions_id'] = array('title' => t::__('Version'), 'choices' => $choices);
         }
         $choices = app::getItemsChoicesByTable('ProjectsPhases', true, $request->getParameter('projects_id'));
         if (count($choices) > 1) {
             $this->fields['projects_phases_id'] = array('title' => t::__('Phase'), 'choices' => $choices);
         }
     }
     $this->fields['progress'] = array('title' => t::__('Progress'), 'choices' => Tasks::getProgressChoices());
     $extra_fields = ExtraFieldsList::getFieldsByType('tasks', $this->getUser(), false, array('all' => true));
     $this->numeric_fields['estimated_time'] = array('title' => t::__('Estimated Time'));
     foreach ($extra_fields as $v) {
         if (in_array($v['type'], array('number'))) {
             $this->numeric_fields['extra_field_' . $v['id']] = array('title' => $v['name']);
         }
     }
     if ($request->getParameter('fields')) {
         if (strlen($request->getParameter('selected_items') == 0)) {
             exit;
         }
         foreach ($request->getParameter('fields') as $key => $value) {
             if (strlen($value) == 0 and !is_array($value)) {
                 continue;
             }
             if ($key == 'tasks_status_id') {
                 foreach (explode(',', $request->getParameter('selected_items')) as $pid) {
                     if ($p = Doctrine_Core::getTable('Tasks')->find($pid)) {
                         if ($p->getTasksStatusId() != $value) {
                             $p->setTasksStatusId($value);
                             if (in_array($value, app::getStatusByGroup('closed', 'TasksStatus'))) {
                                 $p->setClosedDate(date('Y-m-d H:i:s'));
                             }
                             if (!in_array($value, app::getStatusByGroup('closed', 'TasksStatus'))) {
                                 $p->setClosedDate(null);
                             }
                             $p->save();
                             if (strlen($p->getAssignedTo()) > 0) {
                                 Tasks::sendNotification($this, $p, array('status' => explode(',', $p->getAssignedTo())), $this->getUser());
                             }
                             $c = new TasksComments();
                             $c->setTasksStatusId($value);
                             $c->setTasksId($pid);
                             $c->setCreatedAt(date('Y-m-d H:i:s'));
                             $c->setCreatedBy($this->getUser()->getAttribute('id'));
                             $c->save();
                         }
                     }
                 }
             } elseif ($key == 'estimated_time') {
                 $action_str = (double) $value;
                 if (in_array(substr($value, 0, 1), array('+', '-', '*', '/'))) {
                     $action_str = 'estimated_time ' . substr($value, 0, 1) . ' ' . (double) substr($value, 1);
                     Doctrine_Query::create()->update('Tasks')->set('estimated_time', 0)->whereIn('id', explode(',', $request->getParameter('selected_items')))->addWhere('estimated_time is null or length(estimated_time)=0')->execute();
                 }
                 Doctrine_Query::create()->update('Tasks')->set('estimated_time', $action_str)->whereIn('id', explode(',', $request->getParameter('selected_items')))->execute();
             } elseif ($key == 'assigned_to') {
                 $tasks_list = Doctrine_Core::getTable('Tasks')->createQuery()->whereIn('id', explode(',', $request->getParameter('selected_items')))->execute();
                 foreach ($tasks_list as $tasks) {
                     $tasks->setAssignedTo(implode(',', $value));
                     $tasks->save();
                     Tasks::sendNotification($this, $tasks, array('new' => $value), $this->getUser());
                     $c = new TasksComments();
                     $c->setDescription(t::__('Assigned To') . ': ' . Users::getNameById(implode(',', $value), ', '));
                     $c->setTasksId($tasks->getId());
                     $c->setCreatedAt(date('Y-m-d H:i:s'));
                     $c->setCreatedBy($this->getUser()->getAttribute('id'));
                     $c->save();
                     $tasks->save();
                 }
             } else {
                 Doctrine_Query::create()->update('Tasks')->set($key, $value)->whereIn('id', explode(',', $request->getParameter('selected_items')))->execute();
             }
         }
         $this->redirect_to($request->getParameter('redirect_to'), $request->getParameter('projects_id'), $request->getParameter('tasks_id'));
     }
 }