예제 #1
0
 /**
  * Show for PDF an projet - Hierarchy
  * 
  * @param $pdf object for the output
  * @param $ID of the projet
  */
 static function pdfHierarchyForProjet(PluginPdfSimplePDF $pdf, PluginProjetProjet $appli, $parents = 0)
 {
     global $DB, $CFG_GLPI;
     $ID = $appli->fields['id'];
     if (!$appli->can($ID, "r")) {
         return false;
     }
     if (!plugin_projet_haveRight("projet", "r")) {
         return false;
     }
     $pdf->setColumnsSize(100);
     if ($parents) {
         $pdf->displayTitle('<b>' . __('Parent project', 'projet') . '</b>');
     } else {
         $pdf->displayTitle('<b>' . _n('Child project', 'Child projects', 2, 'projet') . '</b>');
     }
     $first = false;
     $query = "SELECT `" . $appli->gettable() . "`.*  ";
     if ($parents != 0) {
         $parent = "plugin_projet_projets_id_1";
         $child = "plugin_projet_projets_id_2";
     } else {
         $parent = "plugin_projet_projets_id_2";
         $child = "plugin_projet_projets_id_1";
     }
     $query .= " FROM `glpi_plugin_projet_projets`";
     $query .= " LEFT JOIN `glpi_plugin_projet_projets_projets` \n                  ON (`glpi_plugin_projet_projets_projets`.`{$child}` = `glpi_plugin_projet_projets`.`id`)";
     $query .= " WHERE `glpi_plugin_projet_projets_projets`.`{$parent}` = '{$ID}' ";
     if ($appli->maybeTemplate()) {
         $LINK = " AND ";
         if ($first) {
             $LINK = " ";
             $first = false;
         }
         $query .= $LINK . "`" . $appli->getTable() . "`.`is_template` = '0' ";
     }
     // Add is_deleted if item have it
     if ($appli->maybeDeleted()) {
         $LINK = " AND ";
         if ($first) {
             $LINK = " ";
             $first = false;
         }
         $query .= $LINK . "`" . $appli->getTable() . "`.`is_deleted` = '0' ";
     }
     $LINK = " AND ";
     $query .= getEntitiesRestrictRequest(" AND ", $appli->gettable(), '', '', $appli->maybeRecursive());
     $query .= " ORDER BY `" . $appli->gettable() . "`.`name`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if (!$number) {
         $pdf->displayLine(__('No item found'));
     } else {
         if (Session::isMultiEntitiesMode()) {
             $pdf->setColumnsSize(17, 17, 17, 17, 16, 16);
             $pdf->displayTitle('<b><i>' . __('Name'), __('Entity'), __('Progress'), _n('State', 'States', 1), __('Start date'), __('End date') . '</i></b>');
         } else {
             $pdf->setColumnsSize(20, 17, 17, 17, 17);
             $pdf->displayTitle('<b><i>' . __('Name'), __('Progress'), _n('State', 'States', 1), __('Start date'), __('End date') . '</i></b>');
         }
         while ($data = $DB->fetch_array($result)) {
             $items_id_display = "";
             if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                 $items_id_display = " (" . $data["id"] . ")";
             }
             $name = $data["name"] . $items_id_display;
             $entity = Html::clean(Dropdown::getDropdownName("glpi_entities", $data['entities_id']));
             if (Session::isMultiEntitiesMode()) {
                 $pdf->setColumnsSize(17, 17, 17, 17, 16, 16);
                 $pdf->displayLine($name, $entity, PluginProjetProjet::displayProgressBar('100', $data["advance"], array("simple" => true)), Html::clean(Dropdown::getDropdownName("glpi_plugin_projet_projetstates", $data['plugin_projet_projetstates_id'])), Html::convdate($data["date_begin"]), Html::convdate($data["date_end"]));
             } else {
                 $pdf->setColumnsSize(20, 17, 17, 17, 17);
                 $pdf->displayLine($name, PluginProjetProjet::displayProgressBar('100', $data["advance"], array("simple" => true)), Html::clean(Dropdown::getDropdownName("glpi_plugin_projet_projetstates", $data['plugin_projet_projetstates_id'])), Html::convdate($data["date_begin"]), Html::convdate($data["date_end"]));
             }
         }
     }
     $pdf->displaySpace();
 }
예제 #2
0
 /** 
  * show for PDF the projet associated with a device
  * 
  * @param $ID of the device
  * @param $itemtype : type of the device
  * 
  */
 static function PdfFromItems($pdf, $item)
 {
     global $DB, $CFG_GLPI;
     $pdf->setColumnsSize(100);
     $pdf->displayTitle('<b>' . _n('Associated project', 'Associated projects', 2, 'projet') . '</b>');
     $ID = $item->getField('id');
     $itemtype = get_Class($item);
     $canread = $item->can($ID, 'r');
     $canedit = $item->can($ID, 'w');
     $PluginProjetProjet = new PluginProjetProjet();
     $query = "SELECT `glpi_plugin_projet_projets`.* " . " FROM `glpi_plugin_projet_projets_items`,`glpi_plugin_projet_projets` " . " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_projet_projets`.`entities_id`) " . " WHERE `glpi_plugin_projet_projets_items`.`items_id` = '" . $ID . "' \n         AND `glpi_plugin_projet_projets_items`.`itemtype` = '" . $itemtype . "' \n         AND `glpi_plugin_projet_projets_items`.`plugin_projet_projets_id` = `glpi_plugin_projet_projets`.`id` " . getEntitiesRestrictRequest(" AND ", "glpi_plugin_projet_projets", '', '', $PluginProjetProjet->maybeRecursive());
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     if (!$number) {
         $pdf->displayLine(__('No item found'));
     } else {
         if (Session::isMultiEntitiesMode()) {
             $pdf->setColumnsSize(14, 14, 14, 14, 14, 14, 16);
             $pdf->displayTitle('<b><i>' . __('Name'), __('Entity'), __('Comments'), __('Description'), __('Progress'), __('Start date'), __('End date') . '</i></b>');
         } else {
             $pdf->setColumnsSize(17, 17, 17, 17, 17, 17);
             $pdf->displayTitle('<b><i>' . __('Name'), __('Comments'), __('Description'), __('Progress'), __('Start date'), __('End date') . '</i></b>');
         }
         while ($data = $DB->fetch_array($result)) {
             if (Session::isMultiEntitiesMode()) {
                 $pdf->setColumnsSize(14, 14, 14, 14, 14, 14, 16);
                 $pdf->displayLine($data["name"], Html::clean(Dropdown::getDropdownName("glpi_entities", $data['entities_id'])), $data["comment"], $data["description"], PluginProjetProjet::displayProgressBar('100', $data["advance"], array("simple" => true)), Html::convdate($data["date_begin"]), Html::convdate($data["date_end"]));
             } else {
                 $pdf->setColumnsSize(17, 17, 17, 17, 17, 17);
                 $pdf->displayLine($data["name"], $data["comment"], $data["description"], PluginProjetProjet::displayProgressBar('100', $data["advance"], array("simple" => true)), Html::convdate($data["date_begin"]), Html::convdate($data["date_end"]));
             }
         }
     }
 }