示例#1
0
foreach ($projects as $k => $p) {
    $tnums = count($p['tasks']);
    //echo '<pre>'; print_r($p['tasks']); echo '</pre>';
    if ($tnums > 0 || $project_id == $p['project_id']) {
        if ($task_sort_item1 != '') {
            if ($task_sort_item2 != '' && $task_sort_item1 != $task_sort_item2) {
                $p['tasks'] = array_csort($p['tasks'], $task_sort_item1, $task_sort_order1, $task_sort_type1, $task_sort_item2, $task_sort_order2, $task_sort_type2);
            } else {
                $p['tasks'] = array_csort($p['tasks'], $task_sort_item1, $task_sort_order1, $task_sort_type1);
            }
        }
        for ($i = 0; $i < $tnums; $i++) {
            $t = $p['tasks'][$i];
            if ($t['task_parent'] == $t['task_id']) {
                showtask_pr($t, 0);
                findchild_pr($p['tasks'], $t['task_id']);
            }
        }
    }
}
?>
</table >
<?php 
global $project_id, $m;
global $st_projects_arr;
$df = $AppUI->getPref('SHDATEFORMAT');
$projectPriority = w2PgetSysVal('ProjectPriority');
$projectStatus = w2PgetSysVal('ProjectStatus');
?>
<table class="tbl" cellspacing="1" cellpadding="2" border="0" width="100%">
<td align="center">
示例#2
0
          ** as it is normally done in array_csort function in order to economise
          ** cpu time as we have to go through the array there anyway
          */
         for ($j = 0; $j < count($p['tasks']); $j++) {
             if ($p['tasks'][$j]['task_end_date'] == '0000-00-00 00:00:00') {
                 $p['tasks'][$j]['task_end_date'] = calcEndByStartAndDuration($p['tasks'][$j]);
             }
         }
     }
     for ($i = 0; $i < $tnums; $i++) {
         $t = $p['tasks'][$i];
         if ($t["task_parent"] == $t["task_id"]) {
             $is_opened = in_array($t["task_id"], $tasks_opened);
             showtask_pr($t, 0, $is_opened);
             if ($is_opened || $t["task_dynamic"] == 0) {
                 findchild_pr($p['tasks'], $t["task_id"]);
             }
         }
     }
     // check that any 'orphaned' user tasks are also display
     for ($i = 0; $i < $tnums; $i++) {
         if (!in_array($p['tasks'][$i]["task_id"], $done)) {
             if ($p['tasks'][$i]["task_dynamic"] && in_array($p['tasks'][$i]["task_parent"], $tasks_closed)) {
                 closeOpenedTask($p['tasks'][$i]["task_id"]);
             }
             if (in_array($p['tasks'][$i]["task_parent"], $tasks_opened)) {
                 showtask_pr($p['tasks'][$i], 1, false);
             }
         }
     }
 }
function findchild_pr(&$tarr, $parent, $level = 0)
{
    global $projects;
    $level = $level + 1;
    $n = count($tarr);
    for ($x = 0; $x < $n; $x++) {
        if ($tarr[$x]['task_parent'] == $parent && $tarr[$x]['task_parent'] != $tarr[$x]['task_id']) {
            echo showtask_pr($tarr[$x], $level);
            findchild_pr($tarr, $tarr[$x]['task_id'], $level);
        }
    }
}
function findchild_pr(&$tarr, $parent, $level = 0)
{
    global $projects;
    global $tasks_opened;
    $level = $level + 1;
    $n = count($tarr);
    for ($x = 0; $x < $n; $x++) {
        if ($tarr[$x]["task_parent"] == $parent && $tarr[$x]["task_parent"] != $tarr[$x]["task_id"]) {
            $is_opened = in_array($tarr[$x]["task_id"], $tasks_opened);
            showtask_pr($tarr[$x], $level, $is_opened);
            if ($is_opened || !$tarr[$x]["task_dynamic"]) {
                findchild_pr($tarr, $tarr[$x]["task_id"], $level);
            }
        }
    }
}