TheDesignspace
dotProject Recipe: add a completion checkbox to todo list


March 19, 2007
Dotproject | PHP | Snippets

To allow one-click completion of a task, we added a checkbox to the task "to-do" lists in dotProject.

Usually I try to borrow functions from other places in the application and adapt them to the new location. In this case the completion function was borrowed from the "progress" drop-down menu, on the add-edit Task screen.

The check box submits the same values as if 100% were selected from the drop-down menu.

completionCheckbox.jpg

In modules/tasks/tasks.class.php, search for the first row of the task listing table

$s = "\n"\n\t<tr style='".$style."' id='taskRow'">"

This is the area where the HTML for the task list table is generated. Find the spot in the list of table cells where you want to insert the checkbox, and add:

$s .= "\n\t<td align=\"center\" width=\"15\">";



$s .= "<form name='taskCompleteForm".$a['task_id']."' action='?m=tasks&a=view' method='post'>";

$s .= "<input name='dosql' type='hidden' value='do_task_aed' />";

$s .= "<input type = 'hidden' name='task_id' value='".$a['task_id']."'>";

$s .= "<input type = 'hidden' name='task_percent_complete' value='100'>";

$s .= "<input type='checkbox' name='completeIt' onclick='document.taskCompleteForm".$a['task_id'].".submit();'>";

$s .= intval( $a["task_percent_complete"] ).'%';

$s .= "</form>";

Posted by ellen at March 19, 2007 11:44 AM | TrackBack

 Comments
 Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?



Recommended Reading