Exemple #1
0
 static function showTaskGantt($options = array())
 {
     global $gdata;
     $restrict = " `plugin_projet_projets_id` = '" . $options["plugin_projet_projets_id"] . "' ";
     if ($options["plugin_projet_tasks_id"]) {
         $restrict .= " AND `id` = '" . $options["plugin_projet_tasks_id"] . "' ";
     }
     $restrict .= " AND `is_deleted` = '0'";
     $restrict .= " AND `is_template` = '0'";
     $restrict .= " AND `show_gantt` = '1'";
     $tasks = getAllDatasFromTable("glpi_plugin_projet_tasks", $restrict);
     $prefix = $options["prefix"];
     if (!empty($tasks)) {
         foreach ($tasks as $task) {
             $prefix .= "-";
             //nom
             $gantt_t_name = $prefix . " " . $task["name"];
             //color
             $int = hexdec(PluginProjetTaskState::getStatusColor($task["plugin_projet_taskstates_id"]));
             $gantt_t_bgcolor = array(0xff & $int >> 0x10, 0xff & $int >> 0x8, 0xff & $int);
             $projet = new PluginProjetProjet();
             if ($projet->getFromDB($options["plugin_projet_projets_id"])) {
                 $gantt_t_date_begin = $projet->fields["date_begin"];
                 $gantt_t_date_end = $projet->fields["date_end"];
             } else {
                 $gantt_t_date_begin = date("Y-m-d");
                 $gantt_t_date_end = date("Y-m-d");
             }
             $plan = new PluginProjetTaskPlanning();
             $plan->getFromDBbyTask($task["id"]);
             if (!empty($plan->fields["begin"])) {
                 $gantt_t_date_begin = $plan->fields["begin"];
             }
             if (!empty($plan->fields["end"])) {
                 $gantt_t_date_end = $plan->fields["end"];
             }
             $gdata[] = array("type" => 'phase', "task" => $task["id"], "projet" => $options["plugin_projet_projets_id"], "name" => $gantt_t_name, "begin" => $gantt_t_date_begin, "end" => $gantt_t_date_end, "advance" => $task["advance"], "bg_color" => $gantt_t_bgcolor);
             if ($task["depends"] == 1) {
                 $gdata[] = array("type" => 'dependency', "projet" => $options["plugin_projet_projets_id"], "name" => $gantt_t_name, "date_begin" => $gantt_t_date_begin);
             }
             $restrictchild = " `plugin_projet_projets_id` = '" . $options["plugin_projet_projets_id"] . "'";
             $condition = " `plugin_projet_tasks_id_2` = '" . $task["id"] . "' ";
             $tasks_tasks = getAllDatasFromTable("glpi_plugin_projet_tasks_tasks", $condition);
             $tab = array();
             if (!empty($tasks_tasks)) {
                 foreach ($tasks_tasks as $tasks_task) {
                     $tab[] = $tasks_task['plugin_projet_tasks_id_1'];
                 }
             }
             if (!empty($tab)) {
                 $restrictchild .= " AND `id` IN (" . implode(',', $tab) . ")";
             }
             $restrictchild .= " AND `is_deleted` = '0'";
             $restrictchild .= " AND `is_template` = '0'";
             $restrictchild .= " AND `show_gantt` = '1'";
             $restrictchild .= " ORDER BY `plugin_projet_taskstates_id` DESC";
             $childs = getAllDatasFromTable("glpi_plugin_projet_tasks", $restrictchild);
             if (!empty($childs) && !empty($tab)) {
                 foreach ($childs as $child) {
                     $params = array('plugin_projet_projets_id' => $options["plugin_projet_projets_id"], 'plugin_projet_tasks_id' => $child["id"], 'parent' => 1, 'prefix' => $prefix);
                     self::showTaskGantt($params);
                 }
             }
         }
     }
 }
Exemple #2
0
function plugin_projet_displayConfigItem($type, $ID, $data, $num)
{
    global $CFG_GLPI, $DB;
    $searchopt =& Search::getOptions($type);
    $table = $searchopt[$ID]["table"];
    $field = $searchopt[$ID]["field"];
    switch ($type) {
        case 'PluginProjetProjet':
            switch ($table . '.' . $field) {
                case "glpi_plugin_projet_projetstates.name":
                    return " style=\"background-color:" . PluginProjetProjetState::getStatusColor($data["ITEM_" . $num . "_2"]) . ";\" ";
                    break;
            }
            break;
        case 'PluginProjetTask':
            switch ($table . '.' . $field) {
                case "glpi_plugin_projet_tasks.priority":
                    return " style=\"background-color:" . $_SESSION["glpipriority_" . $data["ITEM_{$num}"]] . ";\" ";
                    break;
                case "glpi_plugin_projet_taskstates.name":
                    return " style=\"background-color:" . PluginProjetTaskState::getStatusColor($data["ITEM_" . $num . "_2"]) . ";\" ";
                    break;
            }
            break;
        case 'PluginProjetProjetState':
            switch ($table . '.' . $field) {
                case "glpi_plugin_projet_projetstates.color":
                    return " style=\"background-color:" . PluginProjetProjetState::getStatusColor($data["ITEM_" . $num . "_2"]) . ";\" ";
                    break;
            }
            break;
        case 'PluginProjetTaskState':
            switch ($table . '.' . $field) {
                case "glpi_plugin_projet_taskstates.color":
                    return " style=\"background-color:" . PluginProjetTaskState::getStatusColor($data["ITEM_" . $num . "_2"]) . ";\" ";
                    break;
            }
            break;
    }
    return "";
}
 static function showHierarchy($ID, $parents = 0)
 {
     global $DB, $CFG_GLPI;
     $first = false;
     $projet = new PluginProjetTask();
     $query = "SELECT `glpi_plugin_projet_tasks`.*  ";
     if ($parents != 0) {
         $parent = "plugin_projet_tasks_id_1";
         $child = "plugin_projet_tasks_id_2";
     } else {
         $parent = "plugin_projet_tasks_id_2";
         $child = "plugin_projet_tasks_id_1";
     }
     $query .= " FROM `glpi_plugin_projet_tasks`";
     $query .= " LEFT JOIN `glpi_plugin_projet_tasks_tasks` \n                  ON (`glpi_plugin_projet_tasks_tasks`.`{$child}` = `glpi_plugin_projet_tasks`.`id`)";
     $query .= " WHERE `glpi_plugin_projet_tasks_tasks`.`{$parent}` = '{$ID}' ";
     if ($projet->maybeTemplate()) {
         $LINK = " AND ";
         if ($first) {
             $LINK = " ";
             $first = false;
         }
         $query .= $LINK . "`glpi_plugin_projet_tasks`.`is_template` = '0' ";
     }
     // Add is_deleted if item have it
     if ($projet->maybeDeleted()) {
         $LINK = " AND ";
         if ($first) {
             $LINK = " ";
             $first = false;
         }
         $query .= $LINK . "`glpi_plugin_projet_tasks`.`is_deleted` = '0' ";
     }
     $LINK = " AND ";
     $query .= getEntitiesRestrictRequest(" AND ", "glpi_plugin_projet_tasks", '', '', $projet->maybeRecursive());
     $query .= " ORDER BY `glpi_plugin_projet_tasks`.`name`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     if (Session::isMultiEntitiesMode()) {
         $colsup = 1;
     } else {
         $colsup = 0;
     }
     if ($number != "0") {
         echo "<div align='center'><table class='tab_cadre_fixe'>";
         $title = _n('Child task', 'Child tasks', 2, 'projet');
         if ($parents != 0) {
             $title = __('Parent task', 'projet');
         }
         echo "<tr><th colspan='" . (7 + $colsup) . "'>" . $title . "</th></tr>";
         echo "<tr><th>" . __('Name') . "</th>";
         if (Session::isMultiEntitiesMode()) {
             echo "<th>" . __('Entity') . "</th>";
         }
         echo "<th>" . __('Progress') . "</th>";
         echo "<th>" . _n('User', 'Users', 1) . "</th>";
         echo "<th>" . _n('Group', 'Groups', 1) . "</th>";
         echo "<th>" . __('State') . "</th>";
         echo "</tr>";
         while ($data = $DB->fetch_array($result)) {
             $start = 0;
             $output_type = Search::HTML_OUTPUT;
             $del = false;
             if ($data["is_deleted"] == '0') {
                 echo "<tr class='tab_bg_1'>";
             } else {
                 echo "<tr class='tab_bg_1" . ($data["is_deleted"] == '1' ? "_2" : "") . "'>";
             }
             echo Search::showItem($output_type, "<a href=\"./task.form.php?id=" . $data["id"] . "\">" . $data["name"] . ($_SESSION["glpiis_ids_visible"] || empty($data["name"]) ? ' (' . $data["id"] . ') ' : '') . "</a>", $item_num, $i - $start + 1, '');
             if (Session::isMultiEntitiesMode()) {
                 echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
             }
             echo Search::showItem($output_type, PluginProjetProjet::displayProgressBar('100', $data["advance"], array("simple" => true)), $item_num, $i - $start + 1, "align='center'");
             echo Search::showItem($output_type, getUserName($data['users_id']), $item_num, $i - $start + 1, '');
             echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_groups", $data['groups_id']), $item_num, $i - $start + 1, '');
             echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_plugin_projet_taskstates", $data['plugin_projet_taskstates_id']), $item_num, $i - $start + 1, "bgcolor='" . PluginProjetTaskState::getStatusColor($data['plugin_projet_taskstates_id']) . "' align='center'");
             echo "</tr>";
         }
         echo "</table></div>";
     }
 }
 function post_updateItem($history = 1)
 {
     global $CFG_GLPI;
     $fup = new PluginProjetTask();
     $fup->getFromDB($this->input["plugin_projet_tasks_id"]);
     $timestart = strtotime($this->input["begin"]);
     $timeend = strtotime($this->input["end"]);
     $updates2[] = "actiontime";
     $fup->fields["actiontime"] = $timeend - $timestart;
     $updates2[] = "plugin_projet_taskstates_id";
     $fup->fields["plugin_projet_taskstates_id"] = PluginProjetTaskState::getStatusForPlanning();
     $fup->updateInDB($updates2);
 }