if (!empty($project_tasks)) { $project_tasks = " OR (history_table = 'tasks' AND history_item IN ({$project_tasks})) "; } if (!empty($project_files)) { $project_files = " OR (history_table = 'files' AND history_item IN ({$project_files})) "; } $filter .= ($filter ? ' AND ' : '') . ("((history_table = 'projects' AND history_item = " . $project_id . ')' . $project_tasks . $project_files . ')'); } if ($filter) { $q->addWhere($filter); } $q->addOrder('history_date DESC'); $q->setLimit($limit, $offset); $my_history = $q->loadList(); $history = $my_history; $count = $q->foundRows(); $pages = (int) ($count / $limit) + 1; $max_pages = 20; $first_page = $pages > $max_pages ? max($page - (int) ($max_pages / 2), 1) : 1; $last_page = $pages > $max_pages ? min($first_page + $max_pages - 1, $pages) : $pages; ?> <table width="100%" cellspacing="1" cellpadding="0" border="0"> <tr> <td nowrap align="right"> <form name="filter" action="?m=history" method="post" > <?php echo $AppUI->_('Changes to'); ?> : <select name="filter" onChange="document.filter.submit()">
} if ($company_id) { $q3->addWhere('p.project_company = ' . $company_id); } if ($project_id) { $q3->addWhere('f.file_project = ' . $project_id); } if ($task_id) { $q3->addWhere('f.file_task = ' . $task_id); } $files = array(); $file_versions = array(); if ($canRead) { $q2->includeCount(); $files = $q2->loadList(); $xpg_totalrecs = $q2->foundRows(); $file_versions = $q3->loadHashList('file_id'); } $r->dropTemp('files_count_max'); $r->exec(); // How many pages are we dealing with here ?? $xpg_total_pages = $xpg_totalrecs > $xpg_pagesize ? ceil($xpg_totalrecs / $xpg_pagesize) : 1; shownavbar($xpg_totalrecs, $xpg_pagesize, $xpg_total_pages, $page); ?> <script type="text/JavaScript"> function expand(id) { var element = document.getElementById(id); element.style.display = (element.style.display == '' || element.style.display == "none") ? "block" : "none"; } </script>
function process_dependencies($i) { global $tasks, $option_advance_if_possible; if ($tasks[$i]["fixed"]) { return; } log_info("<div style='padding-left: 1em'>Dependecies for '" . $tasks[$i]["task_name"] . "':<br />"); // query dependencies for this task $q = new DBQuery(); $q->addTable('tasks', 't'); $q->addTable('task_dependencies', 'td'); $q->addQuery('t.*'); $q->addWhere('task_id=dependencies_req_task_id and dependencies_task_id=' . (int) $tasks[$i]['task_id']); $q->includeCount(); $q->exec(); if ($q->foundRows() != 0) { $all_fixed = true; $latest_end_date = null; // store dependencies in an array (for adding more entries on the fly) $dependencies = array(); while ($row = $q->fetchRow()) { array_push($dependencies, $row); } $d = 0; while ($d < count($dependencies)) { $row = $dependencies[$d]; $index = search_task($row["task_id"]); if ($index == -1) { // task is not listed => it's a task group // => $i depends on all its subtasks // => add all subtasks to the dependencies array log_info("- task '" . $row["task_name"] . "' is a task group (processing subtask's dependencies)"); $children = get_last_children($row); // replace this taskgroup with all its subtasks array_splice($dependencies, $d, 1, $children); continue; } log_info(" - '" . $tasks[$index]["task_name"] . ($tasks[$index]["fixed"] ? " (FIXED)" : "") . "'"); // TODO: Detect dependencies loops (A->B, B->C, C->A) process_dependencies($index); if (!$tasks[$index]["fixed"]) { $all_fixed = false; } else { // ignore dependencies of finished tasks if option is enabled if (!$option_advance_if_possible || $tasks[$index]["task_percent_complete"] != 100) { // get latest end_date $end_date = db_dateTime2unix($tasks[$index]["task_end_date"]); if (!$latest_end_date || $end_date > $latest_end_date) { $latest_end_date = $end_date; $dep_on_task = $row; } } else { log_info("this task is complete => don't check dependency"); } $d++; } } if ($all_fixed) { // this task depends only on fixated tasks log_info("all dependencies are fixed"); fixate_task($i, $latest_end_date, $dep_on_task); } else { log_error("task has not fixed dependencies"); } } else { // task has no dependencies log_info("no dependencies => "); fixate_task($i, time(), ""); } log_info("</div><br />\n"); }