/**
 * Add sidebars to project overview page
 *
 * @param array $sidebars
 * @param Project $project
 * @param User $user
 */
function frosso_estimated_cost_handle_on_project_overview_sidebars(&$sidebars, Project &$project, User &$user)
{
    if (($user->canUseReports() || $project->isLeader($user)) && $project->canEdit($user)) {
        $arguments = array('conditions' => array('project_id = ? AND type = ? AND state >= ? AND visibility >= ? AND completed_on IS NULL', $project->getId(), 'Milestone', STATE_VISIBLE, VISIBILITY_NORMAL));
        $milestones = DataManager::find($arguments, TABLE_PREFIX . 'project_objects', DataManager::CLASS_NAME_FROM_TABLE, 'RemediaMilestone');
        if (is_foreachable($milestones)) {
            $result = array();
            $view = SmartyForAngie::getInstance()->createTemplate(AngieApplication::getViewPath('eta_project_sidebar', 'sidebar', FROSSO_EC_MODULE, AngieApplication::INTERFACE_DEFAULT));
            $view->assign(array('milestones' => $milestones, 'logged_user' => $user));
            $sidebars[] = array('label' => lang('ETA for this project'), 'is_important' => false, 'id' => 'project_milestones_complete', 'body' => $view->fetch());
        }
    }
}
 /**
  * Delete Project Icon
  *
  * @param void
  * @return null
  */
 function delete_icon()
 {
     if ($this->active_project->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_project->canEdit($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     if ($this->request->isSubmitted()) {
         unlink($this->active_project->getIconPath());
         unlink($this->active_project->getIconPath(true));
         cache_remove('project_icons');
         if ($this->request->isAsyncCall()) {
             $this->serveData(array('message' => lang('Icon successfully removed'), 'icon' => $this->active_project->getIconUrl(true)), 'delete', null, FORMAT_JSON);
         } else {
             $this->redirectToUrl($this->active_project->getEditIconUrl());
         }
     } else {
         $this->httpError(HTTP_ERR_BAD_REQUEST);
     }
     // if
 }
 /**
  * Show team for a project
  **/
 function showTeam(Project $project)
 {
     global $DB, $CFG_GLPI;
     $ID = $project->fields['id'];
     $canedit = $project->canEdit($ID);
     echo "<div class='center'>";
     $rand = mt_rand();
     $nb = 0;
     $nb = $project->getTeamCount();
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='projectteam_form{$rand}' id='projectteam_form{$rand}' ";
         echo " method='post' action='" . Toolbox::getItemTypeFormURL('ProjectTeam') . "'>";
         echo "<input type='hidden' name='projects_id' value='{$ID}'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='2'>" . __('Add a team member') . "</tr>";
         echo "<tr class='tab_bg_2'><td>";
         $params = array('itemtypes' => ProjectTeam::$available_types, 'entity_restrict' => $project->fields['is_recursive'] ? getSonsOf('glpi_entities', $project->fields['entities_id']) : $project->fields['entities_id']);
         $addrand = Dropdown::showSelectItemFromItemtypes($params);
         echo "</td>";
         echo "<td width='20%'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\"\n               class='submit'>";
         echo "</td>";
         echo "</tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $nb) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $nb, 'container' => 'mass' . __CLASS__ . $rand);
         //                     'specific_actions'
         //                         => array('delete' => _x('button', 'Delete permanently')) );
         //
         //          if ($this->fields['users_id'] != Session::getLoginUserID()) {
         //             $massiveactionparams['confirm']
         //                = __('Caution! You are not the author of this element. Delete targets can result in loss of access to that element.');
         //          }
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov table-striped table-hover'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && $nb) {
         $header_begin .= "<th width='10'>";
         $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_end .= "</th>";
     }
     $header_end .= "<th>" . __('Type') . "</th>";
     $header_end .= "<th>" . _n('Member', 'Members', Session::getPluralNumber()) . "</th>";
     $header_end .= "</tr>";
     echo $header_begin . $header_top . $header_end;
     foreach (ProjectTeam::$available_types as $type) {
         if (isset($project->team[$type]) && count($project->team[$type])) {
             if ($item = getItemForItemtype($type)) {
                 foreach ($project->team[$type] as $data) {
                     $item->getFromDB($data['items_id']);
                     echo "<tr class='tab_bg_2'>";
                     if ($canedit) {
                         echo "<td>";
                         Html::showMassiveActionCheckBox('ProjectTeam', $data["id"]);
                         echo "</td>";
                     }
                     echo "<td>" . $item->getTypeName(1) . "</td>";
                     echo "<td>" . $item->getLink() . "</td>";
                     echo "</tr>";
                 }
             }
         }
     }
     if ($nb) {
         echo $header_begin . $header_bottom . $header_end;
     }
     echo "</table>";
     if ($canedit && $nb) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
     // Add items
     return true;
 }
 /**
  * Show tickets for a project
  *
  * @param $project Project object
  **/
 static function showForProject(Project $project)
 {
     global $DB, $CFG_GLPI;
     $ID = $project->getField('id');
     if (!$project->can($ID, READ)) {
         return false;
     }
     $canedit = $project->canEdit($ID);
     $rand = mt_rand();
     $showentities = Session::isMultiEntitiesMode();
     $query = "SELECT DISTINCT `glpi_changes_projects`.`id` AS linkID,\n                                `glpi_changes`.*\n                FROM `glpi_changes_projects`\n                LEFT JOIN `glpi_changes`\n                     ON (`glpi_changes_projects`.`changes_id` = `glpi_changes`.`id`)\n                WHERE `glpi_changes_projects`.`projects_id` = '{$ID}'\n                ORDER BY `glpi_changes`.`name`";
     $result = $DB->query($query);
     $changes = array();
     $used = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $changes[$data['id']] = $data;
             $used[$data['id']] = $data['id'];
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='changeproject_form{$rand}' id='changeproject_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a change') . "</th></tr>";
         echo "<tr class='tab_bg_2'><td>";
         echo "<input type='hidden' name='projects_id' value='{$ID}'>";
         Change::dropdown(array('used' => $used, 'entity' => $project->getEntityID(), 'entity_sons' => $project->isRecursive()));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr></table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $numrows) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov table-striped table-hover'>";
     echo "<tr class='noHover'><th colspan='12'>" . Change::getTypeName($numrows) . "</th></tr>";
     if ($numrows) {
         Change::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
         Session::initNavigateListItems('Change', sprintf(__('%1$s = %2$s'), Project::getTypeName(1), $project->fields["name"]));
         $i = 0;
         foreach ($changes as $data) {
             Session::addToNavigateListItems('Change', $data["id"]);
             Change::showShort($data['id'], array('row_num' => $i, 'type_for_massiveaction' => __CLASS__, 'id_for_massiveaction' => $data['linkID']));
             $i++;
         }
         Change::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
     }
     echo "</table>";
     if ($canedit && $numrows) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
Example #5
0
 /**
  * Print the HTML array for Items linked to a project
  *
  * @param $project Project object
  *
  * @return Nothing (display)
  **/
 static function showForProject(Project $project)
 {
     global $DB, $CFG_GLPI;
     $instID = $project->fields['id'];
     if (!$project->can($instID, READ)) {
         return false;
     }
     $canedit = $project->canEdit($instID);
     $rand = mt_rand();
     $query = "SELECT DISTINCT `itemtype`\n                FROM `glpi_items_projects`\n                WHERE `glpi_items_projects`.`projects_id` = '{$instID}'\n                ORDER BY `itemtype`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='projectitem_form{$rand}' id='projectitem_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td>";
         Dropdown::showSelectItemFromItemtypes(array('itemtypes' => $CFG_GLPI["project_asset_types"], 'entity_restrict' => $project->fields['is_recursive'] ? getSonsOf('glpi_entities', $project->fields['entities_id']) : $project->fields['entities_id']));
         echo "</td><td class='center' width='30%'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "<input type='hidden' name='projects_id' value='{$instID}'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && $number) {
         $header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_top .= "</th>";
         $header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_bottom .= "</th>";
     }
     $header_end .= "<th>" . __('Type') . "</th>";
     $header_end .= "<th>" . __('Entity') . "</th>";
     $header_end .= "<th>" . __('Name') . "</th>";
     $header_end .= "<th>" . __('Serial number') . "</th>";
     $header_end .= "<th>" . __('Inventory number') . "</th></tr>";
     echo $header_begin . $header_top . $header_end;
     $totalnb = 0;
     for ($i = 0; $i < $number; $i++) {
         $itemtype = $DB->result($result, $i, "itemtype");
         if (!($item = getItemForItemtype($itemtype))) {
             continue;
         }
         if ($item->canView()) {
             $itemtable = getTableForItemType($itemtype);
             $query = "SELECT `{$itemtable}`.*,\n                                 `glpi_items_projects`.`id` AS IDD,\n                                 `glpi_entities`.`id` AS entity\n                          FROM `glpi_items_projects`,\n                               `{$itemtable}`";
             if ($itemtype != 'Entity') {
                 $query .= " LEFT JOIN `glpi_entities`\n                                 ON (`{$itemtable}`.`entities_id` = `glpi_entities`.`id`) ";
             }
             $query .= " WHERE `{$itemtable}`.`id` = `glpi_items_projects`.`items_id`\n                              AND `glpi_items_projects`.`itemtype` = '{$itemtype}'\n                              AND `glpi_items_projects`.`projects_id` = '{$instID}'";
             if ($item->maybeTemplate()) {
                 $query .= " AND `{$itemtable}`.`is_template` = '0'";
             }
             $query .= getEntitiesRestrictRequest(" AND", $itemtable, '', '', $item->maybeRecursive()) . "\n                      ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`name`";
             $result_linked = $DB->query($query);
             $nb = $DB->numrows($result_linked);
             for ($prem = true; $data = $DB->fetch_assoc($result_linked); $prem = false) {
                 $name = $data["name"];
                 if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                     $name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]);
                 }
                 $link = $item::getFormURLWithID($data['id']);
                 $namelink = "<a href=\"" . $link . "\">" . $name . "</a>";
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td width='10'>";
                     Html::showMassiveActionCheckBox(__CLASS__, $data["IDD"]);
                     echo "</td>";
                 }
                 if ($prem) {
                     $typename = $item->getTypeName($nb);
                     echo "<td class='center top' rowspan='{$nb}'>" . ($nb > 1 ? sprintf(__('%1$s: %2$s'), $typename, $nb) : $typename) . "</td>";
                 }
                 echo "<td class='center'>";
                 echo Dropdown::getDropdownName("glpi_entities", $data['entity']) . "</td>";
                 echo "<td class='center" . (isset($data['is_deleted']) && $data['is_deleted'] ? " tab_bg_2_2'" : "'");
                 echo ">" . $namelink . "</td>";
                 echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>";
                 echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>";
                 echo "</tr>";
             }
             $totalnb += $nb;
         }
     }
     if ($totalnb > 0) {
         echo "<tr class='tab_bg_2'>";
         echo "<td class='center' colspan='2'>" . ($totalnb > 0 ? sprintf(__('%1$s = %2$s'), __('Total'), $totalnb) : "&nbsp;");
         echo "</td><td colspan='4'>&nbsp;</td></tr> ";
     }
     echo "</table>";
     if ($canedit && $number) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }