Author Topic: Self assigning tasks  (Read 10269 times)

pedja

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
Self assigning tasks
« on: May 04, 2010, 11:29:50 am »
I am new with Feng Office. I think it would do the job but I still have some catches to solve.

This one is major: I need to be able to set unassigned tasks and leave users to assign them to themselves.

All I can get is users to be able to click Complete on tasks or being able to edit and assign themselves that way.

What I actually need is this:

- users can complete only tasks they are assigned to

- if task is unassigned, user can click Assign Me button (or similar) to be assigned without need/privilege to edit whole task. Assignment could be automatic, right after request, or postponed to administrator  to approve it.

Cant his be done using Feng Office?

WiZaxx

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Self assigning tasks
« Reply #1 on: May 11, 2010, 10:37:21 am »
I'm afraid I can't see the possibility of self-assigning a task in fengoffice. But for that matter, I never came across an app that let me do it.

Usually one needs to have ownership or high privileges in the system to be able to modify assigniment (as the word say) it is an assignment after all  :D


pedja

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
Re: Self assigning tasks
« Reply #2 on: May 14, 2010, 10:48:28 am »
I am surprised this is considered as rare needed feature.

I find it common that some tasks are published within team and one who can accomplish it can assign it to itself without being forced to negotiate that with his superriors.

Why is that so strange?

Can someone help me out to alter code so that I get this functionality? Basicaly, waht I need is to have Assign Me button instead of Completed button if task is unasigned, and if task is assigned, only assigned user can mark it as completed.

pedja

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
Re: Self assigning tasks
« Reply #3 on: May 14, 2010, 12:46:11 pm »
I tried to do something on my own but I cannot follow source to finish it. Here is what I did.

I edited public\assets\javascript\og\tasks\drawing.js  to display Assign button instead of Complete/Reopen button. Here is the code which I edited:

Code: [Select]

//Draw task actions
sb.append("<td><div id='ogTasksPanelTaskActions" + tgId + "' class='ogTaskActions'><table><tr>");
var renderTo = "ogTasksPanelTaskActions" + tgId + "Assign";
sb.append("<td style='padding-left:8px;'><a href='#' onclick='ogTasks.drawEditTaskForm(" + task.id + ", \"" + group_id + "\")'>");
sb.append("<div class='ico-edit coViewAction' title='" + lang('edit') + "' style='cursor:pointer;height:16px;padding-top:0px'>" + lang('edit') + "</div></a></td>");


// customized to show Assign button instead of Complete button: START

sb.append("<td style='padding-left:8px;'>");

if (! task.assignedToId){
sb.append("<a href='#' onclick='ogTasks.ToggleAssignStatus(" + task.id + ")'>");
sb.append("<div class='ico-complete coViewAction' title='" + lang('assign this task') + "' style='cursor:pointer;height:16px;padding-top:0px'>" + lang('do assign') + "</a></div>");
}

if (task.assignedToId){

sb.append("<a href='#' onclick='ogTasks.ToggleCompleteStatus(" + task.id + ", " + task.status + ")'>");

if (task.status > 0){
sb.append("<div class='ico-reopen coViewAction' title='" + lang('reopen this task') + "' style='cursor:pointer;height:16px;padding-top:0px'>" + lang('reopen') + "</div></a></td>");
} else {
sb.append("<div class='ico-complete coViewAction' title='" + lang('complete this task') + "' style='cursor:pointer;height:16px;padding-top:0px'>" + lang('do complete') + "</div></a></td>");
}

}
sb.append("</tr></table></div></td>");

// customized to show Assign button instead of Complete button: END



I also edited lang.js for two new strings:

Code: [Select]

   'assign this task': 'Assign this task',
   'do assign': 'Assign',


This works fine, I got buttons displayed as I wanted them.

I also added new function to drawing.js to handle new button action:

Code: [Select]

ogTasks.ToggleAssignStatus = function(task_id){
var action = 'assign_task';

og.openLink(og.getUrl('task', action, {id: task_id, quick: true}), {
callback: function(success, data) {
if (!success || data.errorCode) {
} else {
//Set task data
var task = ogTasks.getTask(task_id);
task.setFromTdata(data.task);

//Redraw task, or redraw whole panel
var bottomToolbar = Ext.getCmp('tasksPanelBottomToolbarObject');
var displayCriteria = bottomToolbar.getDisplayCriteria();
if (displayCriteria.group_by != 'status')
this.UpdateTask(task.id);
else
this.draw();
}
},
scope: this
});
}



Then, I edited  \application\controllers\TaskController.class.php  and added new funtion:

Code: [Select]

/**
* Assign task
*
* @access public
* @param void
* @return null
*/
function assign_task() {
$this->assign();
return;
}


Nw, when I click Assign button I get error message:

Error: Requested task does not exist

This seems like all I did was correct, but Assign() method cannot get correct task_id because it expects it in $_POST but action call passes that value in some other manner which I cannot figure out by examining code of other similar actions

Can anyone help me with some advice?
« Last Edit: May 14, 2010, 01:00:23 pm by pedja »

WiZaxx

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Self assigning tasks
« Reply #4 on: May 14, 2010, 04:01:27 pm »
@pedja
don't get me wrong, the fact that I never came across the need of it, does't mean it is useless.
I actually believe it is a cool feature that I never had to use or seen before; and as such I hope someone can help you figure out what you are missing.

Cheers,

pedja

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
Re: Self assigning tasks
« Reply #5 on: May 17, 2010, 09:52:36 am »
Can anyone give me some hints?

I feel like I am pretty close to solution but I lack experience with Feng Office source.

pedja

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
Re: Self assigning tasks
« Reply #6 on: May 17, 2010, 12:18:07 pm »
I managed to get something to work.

I made method assign_task() by copying assign() and altering it so it now reads task_id sent as controller parameter and gets current logged in user instead getting these information via $_POST

Code: [Select]

/**
* Assign task
*
* @access public
* @param void
* @return null
*/
function assign_task() {

ajx_current("empty");

$task_id = get_id();

$task = ProjectTasks::findById($task_id);
if(!($task instanceof ProjectTask)) {
flash_error(lang('task list dnx'));
ajx_current("empty");
return;
} // if

if(!$task->canEdit(logged_user())) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
} // if

try{
DB::beginWork();

//$company_id = array_var($assigned_to, 0, 0);
//$user_id = array_var($assigned_to, 1, 0);


$company_id = 0;
$user_id = logged_user()->getId();


if ($company_id < 0) $company_id = 0;
if ($user_id < 0) $user_id = 0;

$can_assign = can_assign_task_to_company_user(logged_user(), $task, $company_id, $user_id);
if ($can_assign !== true) {
flash_error($can_assign);
return;
}

$task->setAssignedToCompanyId($company_id);
$task->setAssignedToUserId($user_id);

$task->save();



DB::commit();
ajx_extra_data(array("id" => $task_id));


$redirect_to = array_var($_GET, 'redirect_to', false);
if (array_var($_GET, 'quick', false) && !$task->isRepetitive()) {
ajx_current("empty");
ajx_extra_data(array("task" => $task->getArrayInfo()));
} else {
ajx_current("reload");
}
flash_success(lang('success complete task'));


} catch(Exception $e) {
DB::rollback();
flash_error($e->getMessage());
} // try

}


So, I made it to work by altering source. It far from my knowledge how to achieve this by some kind of plugin. Next time I update Feng Office I would have to do this alternation to source again.

What is the proper way to propose this to be included in master source?

« Last Edit: May 17, 2010, 12:22:19 pm by pedja »

pedja

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
Re: Self assigning tasks
« Reply #7 on: May 17, 2010, 01:15:19 pm »
Previous changes allow Assign To Me button in Tasks list. I wanted this to show up in Dashboard too, so I changed this:


\application\views\dashboard\widget_pending_tasks.php

Code: [Select]

<td><?php if ($stCount 0) echo "(" lang('subtask count all open'$stCount$task->countOpenSubTasks()) . ')'?></td>
<td><?php if (!is_null($task->getDueDate())){
if ($task->getRemainingDays() >= 0)
if ($task->getRemainingDays() == 0)
echo lang('due today');
else
echo lang('due in x days'$task->getRemainingDays());
else
echo lang('overdue by x days', -$task->getRemainingDays());
}?>
</td>
<td style="text-align:right">
<?php

// modification to who Assign To Me button START

if (! $task->isAssigned()){

?>


<a class='internalLink' href='<?php echo $task->getAssignUrl() ?>' title="<?php echo lang('assign this task')?>"><?php echo lang('do assign')?></a>

<?php

} else {

?>


<a class='internalLink' href='<?php echo $task->getCompleteUrl() ?>' title="<?php echo lang('complete task')?>"><?php echo lang('do complete')?></a>

<?php



// modification to who Assign To Me button END

?>


</td>
</tr>

<?php // foreach ?>
<?php if ($c >= 10) {?>
<tr class="dashSMTC" style="display:none">



and also needed to add language items into \language\en_us\ site_interface.php

Code: [Select]

  'assign this task' => 'Assign this task to me',
  'do assign' => 'Assign to me',


Finally, i had to add new method to \application\models\project_tasks\ProjectTask.class.php

Code: [Select]


/**
* Return assign task URL
*
* @access public
* @param string $redirect_to Redirect to this URL (referer will be used if this URL is not provided)
* @return string
*/
function getAssignUrl($redirect_to = null) {
$params = array(
        'id' => $this->getId()
); // array

if(trim($redirect_to)) {
$params['redirect_to'] = $redirect_to;
} // if

return get_url('task', 'assign_task', $params);
} // getAssignUrl




Now, dashboard too shows functional Assign To Me button in pending tasks.

« Last Edit: May 17, 2010, 01:21:11 pm by pedja »

pedja

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
Re: Self assigning tasks
« Reply #8 on: May 19, 2010, 11:15:43 am »
Do I have to pay for advice?

cabeza

  • Administrator
  • Hero Member
  • *****
  • Posts: 1004
    • View Profile
    • Feng Office
Re: Self assigning tasks
« Reply #9 on: June 30, 2010, 02:06:19 pm »
Thanks for sharing it pedja.

How did you manage permissions? Are users with read-only access able to auto-assign tasks and complete them?

Best,
Marcos

PS: Answering your questions on payment. Read this post, and pay special attention to the three bullets at the end.

damendieta

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Re: Self assigning tasks
« Reply #10 on: June 30, 2010, 07:09:15 pm »
HI my friend. I really don't understand why you need to change the code. I do it all the time but with FO as is.

When I want to my staff auto assign a task for themselves I use: "don't assign" or I assign it to a company.

Then, my staff knows that if a task has no assignee or the assignee is a company they can assign it to themselves.

Maybe it can help you.

Other thing. I always use end date in task so my people use the calendar as a list of things to do.

Another idea that can help you is use "Client companies" as departments. Example:

Your company is the owner company.

And you have this client companies:

My Company - Marketing
My Company - HHRR
My Company - Sales
My Company - Whatever you need

Or just:

Marketing
HHRR
Sales
Whatever you need.

So, if you want that someone in the Marketing deparment sees the task when he sees his calendar, you assign the task to  " My Company - Marketing", this way he can see it and he can assign it to himself by editing the task.

I hope it helps you.

Keep it simple.

Bye.



 

pedja

  • Jr. Member
  • **
  • Posts: 82
    • View Profile
Re: Self assigning tasks
« Reply #11 on: July 06, 2010, 09:19:26 am »
Thanks for sharing it pedja.

No problem. Note that I did not ask anyone to pay me for that.

Quote
How did you manage permissions? Are users with read-only access able to auto-assign tasks and complete them?

I did not mess with permissions. Originaly, user is offered to Complete task, so if he can Complete, I had no need to change his permissions, as he certainly should be able to Assign task to himself.

Quote
PS: Answering your questions on payment. Read this post, and pay special attention to the three bullets at the end.

There was no need to point it out. It is already clear that FengOffice stuff is not quite wiling to help until they are hired to.

I really don't understand why you need to change the code. I do it all the time but with FO as is.

It is because as it works by default is not useful for me. I do not want to harras peopel asking them to have row of clicks to get to the point where they can assign task to themselves. I wanted it done in one click, so I made it.

Also I do not see point in allowing someone to mark task as Completed even if it is not assigned not just to him, but noone else. So, I replaced Completed with Assign button.

Quote
Another idea that can help you is use "Client companies" as departments.

We do not have departments, We have teams, and usualy one person belongs to several teams. Thus we cannot use companies, as they do not allow such organization.

Quote
I hope it helps you.

Thanks for your efforts.