Ejemplo n.º 1
0
 /**
  * Show for PDF an projet
  * 
  * @param $pdf object for the output
  * @param $ID of the projet
  */
 static function pdfGanttForProjet(PluginPdfSimplePDF $pdf, PluginProjetProjet $appli)
 {
     global $CFG_GLPI, $gtitle, $gdata, $gconst, $gdate_begin, $gdate_end;
     $ID = $appli->fields['id'];
     if (!$appli->can($ID, "r")) {
         return false;
     }
     if (!plugin_projet_haveRight("projet", "r")) {
         return false;
     }
     //nom
     $gantt_p_name = $appli->fields["name"];
     //type de gantt
     $int = hexdec(PluginProjetProjetState::getStatusColor($appli->fields["plugin_projet_projetstates_id"]));
     $gantt_p_bgcolor = array(0xff & $int >> 0x10, 0xff & $int >> 0x8, 0xff & $int);
     $gantt_p_date_begin = date("Y-m-d");
     $gantt_p_date_end = date("Y-m-d");
     if (!empty($appli->fields["date_begin"])) {
         $gantt_p_date_begin = $appli->fields["date_begin"];
     }
     if (!empty($appli->fields["date_end"])) {
         $gantt_p_date_end = $appli->fields["date_end"];
     }
     $gdata[] = array("type" => 'group', "projet" => $ID, "name" => $gantt_p_name, "date_begin" => $gantt_p_date_begin, "date_end" => $gantt_p_date_end, "advance" => $appli->fields["advance"], "bg_color" => $gantt_p_bgcolor);
     PluginProjetTask::showTaskTreeGantt(array('plugin_projet_projets_id' => $ID));
     if (!empty($gdate_begin) && !empty($gdate_end)) {
         $gtitle = $gtitle . "<DateBeg> / <DateEnd>";
         $gdate_begin = date("Y", $gdate_begin) . "-" . date("m", $gdate_begin) . "-" . date("d", $gdate_begin);
         $gdate_end = date("Y", $gdate_end) . "-" . date("m", $gdate_end) . "-" . date("d", $gdate_end);
     }
     $ImgName = self::writeGantt($gtitle, $gdata, $gconst, $gdate_begin, $gdate_end);
     $image = GLPI_PLUGIN_DOC_DIR . "/projet/" . $ImgName;
     $pdf->newPage();
     $pdf->setColumnsSize(100);
     $pdf->displayTitle('<b>' . __('Gantt', 'projet') . '</b>');
     $size = GetImageSize($image);
     $src_w = $size[0];
     $src_h = $size[1];
     $pdf->addPngFromFile($image, $src_w / 2, $src_h / 2);
     $pdf->displaySpace();
     unlink($image);
 }
Ejemplo n.º 2
0
 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>";
     }
 }
Ejemplo n.º 3
0
You should have received a copy of the GNU General Public License
along with Projet. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
if (!isset($_GET["plugin_projet_projets_id"])) {
    $_GET["plugin_projet_projets_id"] = 0;
}
$task = new PluginProjetTask();
$task_item = new PluginProjetTask_Item();
$task_task = new PluginProjetTask_Task();
//add tasks
if (isset($_POST['add'])) {
    $task->check(-1, 'w', $_POST);
    $newID = $task->add($_POST);
    Html::back();
} else {
    if (isset($_POST["update"])) {
        $task->check($_POST['id'], 'w');
        $task->update($_POST);
        Html::back();
    } else {
        if (isset($_POST["delete"])) {
            $task->check($_POST['id'], 'w');
Ejemplo n.º 4
0
 function showForm($ID, $options = array())
 {
     if (!Session::haveRight("profile", "r")) {
         return false;
     }
     $prof = new Profile();
     if ($ID) {
         $this->getFromDBByProfile($ID);
         $prof->getFromDB($ID);
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_2'>";
     echo "<th colspan='4'>" . sprintf(__('%1$s - %2$s'), self::getTypeName(1), $prof->fields["name"]) . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . PluginProjetProjet::getTypeName(2) . ":</td><td>";
     Profile::dropdownNoneReadWrite("projet", $this->fields["projet"], 1, 1, 1);
     echo "</td>";
     echo "<td>" . PluginProjetTask::getTypeName(2) . ":</td><td>";
     if ($prof->fields['interface'] != 'helpdesk') {
         Profile::dropdownNoneReadWrite("task", $this->fields["task"], 1, 1, 1);
     } else {
         _e('No access');
         // No access;
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Associable items to a ticket') . " - " . PluginProjetProjet::getTypeName(2) . "</td><td>";
     if ($prof->fields['create_ticket']) {
         Dropdown::showYesNo("open_ticket", $this->fields["open_ticket"]);
     } else {
         echo Dropdown::getYesNo(0);
     }
     echo "</td>";
     echo "<td></td><td>";
     echo "</td>";
     echo "</tr>";
     echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">";
     $options['candel'] = false;
     $this->showFormButtons($options);
 }
Ejemplo n.º 5
0
 static function getAlreadyPlannedInformation($val)
 {
     global $CFG_GLPI;
     $out = "";
     $out .= PluginProjetProjet::getTypeName() . " - " . PluginProjetTask::getTypeName() . ' : ' . Html::convDateTime($val["begin"]) . ' -> ' . Html::convDateTime($val["end"]) . ' : ';
     $out .= "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/projet/front/projet.form.php?id=" . $val["plugin_projet_tasks_id"] . "'>";
     $out .= Html::resume_text($val["name"], 80) . '</a>';
     return $out;
 }
Ejemplo n.º 6
0
 function showItemFromPlugin($instID, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     if (empty($withtemplate)) {
         $withtemplate = 0;
     }
     $PluginProjetTask = new PluginProjetTask();
     if ($PluginProjetTask->getFromDB($instID)) {
         $plugin_projet_projets_id = $PluginProjetTask->fields["plugin_projet_projets_id"];
         $PluginProjetProjet = new PluginProjetProjet();
         $PluginProjetProjet->getFromDB($plugin_projet_projets_id);
         $canedit = $PluginProjetProjet->can($plugin_projet_projets_id, 'w');
         $query = "SELECT `items_id`, `itemtype` \n               FROM `" . $this->getTable() . "` \n               WHERE `plugin_projet_tasks_id` = '{$instID}' \n               ORDER BY `itemtype` ";
         $result = $DB->query($query);
         $number = $DB->numrows($result);
         echo "<form method='post' name='addtaskitem' action=\"./task.form.php\">";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr>";
         echo "<th colspan='" . ($canedit ? 3 : 2) . "'>" . _n('Associated item', 'Associated items', 2);
         echo "</th></tr>";
         echo "<tr><th>" . _n('Type', 'Types', 2) . "</th>";
         echo "<th>" . __('Name') . "</th>";
         if ($canedit && $this->canCreate() && $withtemplate < 2) {
             echo "<th>&nbsp;</th>";
         }
         echo "</tr>";
         $used = array();
         if ($number != "0") {
             for ($i = 0; $i < $number; $i++) {
                 $type = $DB->result($result, $i, "itemtype");
                 $items_id = $DB->result($result, $i, "items_id");
                 if (!class_exists($type)) {
                     continue;
                 }
                 $item = new $type();
                 if ($item->canView()) {
                     $table = getTableForItemType($type);
                     $query = "SELECT `" . $table . "`.*, `" . $this->getTable() . "`.`id` as items_id \n                        FROM `" . $this->getTable() . "` \n                        INNER JOIN `" . $table . "` ON (`" . $table . "`.`id` = `" . $this->getTable() . "`.`items_id`) \n                        WHERE `" . $this->getTable() . "`.`itemtype` = '" . $type . "' \n                        AND `" . $this->getTable() . "`.`items_id` = '" . $items_id . "' \n                        AND `" . $this->getTable() . "`.`plugin_projet_tasks_id` = '{$instID}' ";
                     $query .= "ORDER BY `" . $table . "`.`name` ";
                     $result_linked = $DB->query($query);
                     if ($DB->numrows($result_linked)) {
                         while ($data = $DB->fetch_assoc($result_linked)) {
                             $ID = "";
                             $itemID = $data["id"];
                             $used[] = $itemID;
                             if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                                 $ID = " (" . $data["id"] . ")";
                             }
                             $itemname = $data["name"];
                             if ($type == 'User') {
                                 $itemname = getUserName($itemID);
                             }
                             $link = Toolbox::getItemTypeFormURL($type);
                             $name = "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $itemname . "{$ID}</a>";
                             echo "<tr class='tab_bg_1'>";
                             echo "<td class='center'>" . $item->getTypeName() . "</td>";
                             echo "<td class='center' " . (isset($data['is_deleted']) && $data['is_deleted'] == '1' ? "class='tab_bg_2_2'" : "") . ">" . $name . "</td>";
                             if ($canedit && $this->canCreate() && $withtemplate < 2) {
                                 echo "<td class='center tab_bg_2'>";
                                 Html::showSimpleForm($CFG_GLPI['root_doc'] . '/plugins/projet/front/task.form.php', 'deletetaskitem', _x('button', 'Delete permanently'), array('id' => $data['items_id']));
                                 echo "</td>";
                             }
                             echo "</tr>";
                         }
                     }
                 }
             }
         }
         if ($canedit && $this->canCreate() && $withtemplate < 2) {
             echo "<tr class='tab_bg_1'><td colspan='2' class='right'>";
             echo "<input type='hidden' name='plugin_projet_tasks_id' value='{$instID}'>";
             $this->dropdownTaskItems($plugin_projet_projets_id, "item_item", $used);
             echo "</td>";
             echo "<td class='center' colspan='2' class='tab_bg_2'>";
             echo "<input type='submit' name='addtaskitem' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
             echo "</td></tr>";
             echo "</table></div>";
         } else {
             echo "</table></div>";
         }
         Html::closeForm();
         echo "<br>";
     }
 }
Ejemplo n.º 7
0
Projet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

Projet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Projet. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
$task = new PluginProjetTask();
Html::header(PluginProjetProjet::getTypeName(2), '', "plugins", "projet");
if ($task->canView() || Session::haveRight("config", "w")) {
    Search::manageGetValues("PluginProjetTask");
    //if $_GET["plugin_projet_projets_id"] exist this show list of tasks from a projet
    //else show all tasks
    if (isset($_GET["plugin_projet_projets_id"]) && !empty($_GET["plugin_projet_projets_id"])) {
        $_GET["field"] = array(0 => "23");
        $_GET["contains"] = array(0 => $_GET["plugin_projet_projets_id"]);
    }
    Search::showGenericSearch("PluginProjetTask", $_GET);
    Search::showList("PluginProjetTask", $_GET);
} else {
    Html::displayRightError();
}
Html::footer();