home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / tasks / todo.php < prev    next >
Encoding:
PHP Script  |  2004-01-29  |  7.3 KB  |  223 lines

  1. <?php /* TASKS $Id: todo.php,v 1.24 2004/01/29 09:47:02 ajdonnison Exp $ */
  2.  
  3. $project_id = intval( dPgetParam( $_GET, 'project_id', 0 ) );
  4. $date = intval( dPgetParam( $_GET, 'date', '' ) );
  5.  
  6. // check permissions
  7. $canEdit = !getDenyEdit( $m );
  8.  
  9. // retrieve any state parameters
  10. if (isset( $_POST['show_form'] )) {
  11.     $AppUI->setState( 'TaskDayShowArc', dPgetParam( $_POST, 'show_arc_proj', 0 ) );
  12.     $AppUI->setState( 'TaskDayShowLow', dPgetParam( $_POST, 'show_low_task', 0 ) );
  13. }
  14. $showArcProjs = $AppUI->getState( 'TaskDayShowArc' ) !== NULL ? $AppUI->getState( 'TaskDayShowArc' ) : 0;
  15. $showLowTasks = $AppUI->getState( 'TaskDayShowLow' ) !== NULL ? $AppUI->getState( 'TaskDayShowLow' ) : 1;
  16.  
  17. // if task priority set and items selected, do some work
  18. $task_priority = dPgetParam( $_POST, 'task_priority', 99 );
  19. $selected = dPgetParam( $_POST, 'selected', 0 );
  20.  
  21. if ($selected && count( $selected )) {
  22.     foreach ($selected as $key => $val) {
  23.         if ( $task_priority == 'c' ) {
  24.             // mark task as completed
  25.             $sql = "UPDATE tasks SET task_percent_complete=100 WHERE task_id=$val";
  26.         } else if ( $task_priority == 'd' ) {
  27.             // delete task
  28.             $sql = "DELETE FROM tasks WHERE task_id=$val";
  29.         } else if ( $task_priority > -2 && $task_priority < 2 ) {
  30.             // set priority
  31.             $sql = "UPDATE tasks SET task_priority=$task_priority WHERE task_id=$val";
  32.         }
  33.         db_exec( $sql );
  34.         echo db_error();        
  35.     }
  36. }
  37.  
  38. $AppUI->savePlace();
  39.  
  40. // query my sub-tasks (ignoring task parents)
  41.  
  42. $sql = "
  43.          SELECT a.*,
  44.          project_name, project_id, project_color_identifier,
  45.          parent.task_name as parent_name
  46.          FROM projects, tasks AS a, user_tasks
  47.          LEFT JOIN tasks AS b ON a.task_id=b.task_parent and a.task_id != b.task_id
  48.            LEFT JOIN tasks AS parent ON a.task_parent = parent.task_id
  49.          WHERE user_tasks.task_id = a.task_id
  50.          AND b.task_id IS NULL
  51.          AND user_tasks.user_id = $AppUI->user_id
  52.          AND (a.task_percent_complete < 100 OR a.task_percent_complete IS NULL)
  53.          AND a.task_start_date != ''
  54.          AND a.task_end_date != ''
  55.          AND project_id = a.task_project" .          
  56.   (!$showArcProjs ? " AND project_active = 1" : "") .
  57.   (!$showLowTasks ? " AND a.task_priority >= 0" : "") .  
  58.   " GROUP BY a.task_id
  59.     ORDER BY a.task_start_date, task_priority DESC
  60. ";
  61. //echo "<pre>$sql</pre>";
  62. $tasks = db_loadList( $sql );
  63.  
  64. $priorities = array(
  65.     '1' => 'high',
  66.     '0' => 'normal',
  67.         '-1' => 'low'
  68. );
  69.  
  70. $durnTypes = dPgetSysVal( 'TaskDurationType' );
  71.  
  72. if (!@$min_view) {
  73.     $titleBlock = new CTitleBlock( 'My Tasks To Do', 'applet-48.png', $m, "$m.$a" );
  74.     $titleBlock->addCrumb( "?m=tasks", "tasks list" );
  75.     $titleBlock->show();
  76. }
  77. ?>
  78.  
  79. <table width="100%" border="0" cellpadding="1" cellspacing="0">
  80. <form name="form_buttons" method="post" action="index.php?<?php echo "m=$m&a=$a&date=$date";?>">
  81. <input type="hidden" name="show_form" value="1" />
  82.  
  83. <tr>
  84.     <td align="right" width="100%">
  85.         <?php echo $AppUI->_('Show'); ?>:
  86.     </td>
  87.     <td>
  88.         <input type=checkbox name="show_arc_proj" onclick="document.form_buttons.submit()" <?php echo $showArcProjs ? 'checked="checked"' : ""; ?> />
  89.     </td>
  90.     <td nowrap="nowrap">
  91.         <?php echo $AppUI->_('Archived Projects'); ?>
  92.     </td>
  93.     <td>
  94.         <input type=checkbox name="show_low_task" onclick="document.form_buttons.submit()" <?php echo $showLowTasks ? 'checked="checked"' : ""; ?> />
  95.     </td>
  96.     <td nowrap="nowrap">
  97.         <?php echo $AppUI->_('Low Priority Tasks'); ?>
  98.     </td>
  99. </tr>
  100. </form>
  101. </table>
  102.  
  103. <table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl">
  104. <form name="form" method="post" action="index.php?<?php echo "m=$m&a=$a&date=$date";?>">
  105. <tr>
  106.     <th width="20" colspan="2"><?php echo $AppUI->_('Progress');?></th>
  107.     <th width="15" align="center"><?php echo $AppUI->_('P');?></th>
  108.     <th colspan="2"><?php echo $AppUI->_('Task / Project');?></th>
  109.     <th nowrap><?php echo $AppUI->_('Start Date');?></th>
  110.     <th nowrap><?php echo $AppUI->_('Duration');?></th>
  111.     <th nowrap><?php echo $AppUI->_('Finish Date');?></th>
  112.     <th nowrap><?php echo $AppUI->_('Due In');?></th>
  113.     <th width="0"> </th>
  114. </tr>
  115.  
  116. <?php
  117.  
  118. /*** Tasks listing ***/
  119. $now = new CDate();
  120. $df = $AppUI->getPref('SHDATEFORMAT');
  121.  
  122. foreach ($tasks as $a) {
  123.     $style = '';
  124.     $sign = 1;
  125.     $start = intval( @$a["task_start_date"] ) ? new CDate( $a["task_start_date"] ) : null;
  126.     $end = intval( @$a["task_end_date"] ) ? new CDate( $a["task_end_date"] ) : null;
  127.     
  128.     if (!$end) {
  129.         $end = $start;
  130.         $end->addSeconds( @$a["task_duration"]*$a["task_duration_type"]*SEC_HOUR );
  131.     }
  132.  
  133.     if ($now->after( $start ) && $a["task_percent_complete"] == 0) {
  134.         $style = 'background-color:#ffeebb';
  135.     } else if ($now->after( $start )) {
  136.         $style = 'background-color:#e6eedd';
  137.     }
  138.  
  139.     if ($now->after( $end )) {
  140.         $sign = -1;
  141.         $style = 'background-color:#cc6666;color:#ffffff';
  142.     } 
  143.  
  144.     $days = $now->dateDiff( $end ) * $sign;
  145.  
  146. ?>
  147. <tr>
  148.     <td>
  149. <?php if ($canEdit) { ?>
  150.         <a href="./index.php?m=tasks&a=addedit&task_id=<?php echo $a["task_id"];?>"><img src="./images/icons/pencil.gif" alt="Edit Task" border="0" width="12" height="12"></a>
  151. <?php } ?>
  152.     </td>
  153.     <td align="right">
  154.         <?php echo intval($a["task_percent_complete"]);?>%
  155.     </td>
  156.  
  157.     <td>
  158. <?php if ($a["task_priority"] < 0 ) {
  159.     echo "<img src='./images/icons/low.gif' width=13 height=16>";
  160. } else if ($a["task_priority"] > 0) {
  161.     echo "<img src='./images/icons/" . $a["task_priority"] .".gif' width=13 height=16>";
  162. }?>
  163.     </td>
  164.  
  165.     <td width="50%">
  166.         <a href="./index.php?m=tasks&a=view&task_id=<?php echo $a["task_id"];?>" title='<?php echo ( isset($a['parent_name']) ? '*** ' . $AppUI->_('Parent Task') . " ***\n" . htmlspecialchars($a['parent_name'], ENT_QUOTES) . "\n\n" : '' ) . '*** ' . $AppUI->_('Description') . " ***\n" . htmlspecialchars($a['task_description'], ENT_QUOTES) ?>'><?php echo htmlspecialchars($a["task_name"], ENT_QUOTES);?></a>
  167.     </td>
  168.     <td width="50%">
  169.         <a href="./index.php?m=projects&a=view&project_id=<?php echo $a["project_id"];?>">
  170.             <span style="padding:2px;background-color:#<?php echo $a['project_color_identifier'];?>;color:<?php echo bestColor( $a["project_color_identifier"] );?>"><?php echo $a["project_name"];?></span>
  171.         </a>
  172.     </td>
  173.     <td nowrap style="<?php echo $style;?>"><?php echo $start->format( $df );?></td>
  174.     <td style="<?php echo $style;?>">
  175. <?php
  176.     echo $a['task_duration'] . ' ' . $AppUI->_( $durnTypes[$a['task_duration_type']] );
  177. ?>
  178.     </td>
  179.  
  180.     <td nowrap style="<?php echo $style;?>"><?php echo $end->format( $df );?></td>
  181.  
  182.     <td nowrap align="right" style="<?php echo $style;?>">
  183.         <?php echo $days; ?>
  184.     </td>
  185.     <td>
  186.         <input type=checkbox name="selected[]" value="<?php echo $a["task_id"] ?>">
  187.     </td>
  188. </tr>
  189. <?php } ?>
  190. <tr>
  191.     <td colspan="7" align="right" height="30">
  192.         <input type="submit" class="button" value="<?php echo $AppUI->_('update task');?>">
  193.     </td>
  194.     <td colspan="3" align="center">
  195. <?php
  196. foreach($priorities as $k => $v) {
  197.     $options[$k] = $AppUI->_('set priority to ' . $v);
  198. }
  199. $options['c'] = $AppUI->_('mark as finished');
  200. $options['d'] = $AppUI->_('delete');
  201. echo arraySelect( $options, 'task_priority', 'size="1" class="text"', '0' );
  202. ?>
  203.     </td>
  204. </form>
  205. </table>
  206.  
  207. <table>
  208. <tr>
  209.     <td><?php echo $AppUI->_('Key');?>:</td>
  210.     <td>   </td>
  211.     <td bgcolor="#ffffff">   </td>
  212.     <td>=<?php echo $AppUI->_('Future Task');?></td>
  213.     <td bgcolor="#e6eedd">   </td>
  214.     <td>=<?php echo $AppUI->_('Started and on time');?></td>
  215.     <td>   </td>
  216.     <td bgcolor="#ffeebb">   </td>
  217.     <td>=<?php echo $AppUI->_('Should have started');?></td>
  218.     <td>   </td>
  219.     <td bgcolor="#CC6666">   </td>
  220.     <td>=<?php echo $AppUI->_('Overdue');?></td>
  221. </tr>
  222. </table>
  223.