getSuppliersNames() public method

Get the entreprise name for the contract
public getSuppliersNames ( ) : string
return string of names (HTML)
Esempio n. 1
0
 static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
 {
     global $DB, $CFG_GLPIG;
     if (!Session::haveRight("contract", "r")) {
         return false;
     }
     $type = $item->getType();
     $ID = $item->getField('id');
     $con = new Contract();
     $query = "SELECT *\n                FROM `glpi_contracts_items`\n                WHERE `glpi_contracts_items`.`items_id` = '" . $ID . "'\n                      AND `glpi_contracts_items`.`itemtype` = '" . $type . "'";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = $j = 0;
     $pdf->setColumnsSize(100);
     if ($number > 0) {
         $pdf->displayTitle('<b>' . _N('Associated contract', 'Associated contracts', 2) . '</b>');
         $pdf->setColumnsSize(19, 19, 19, 16, 11, 16);
         $pdf->displayTitle(__('Name'), _x('phone', 'Number'), __('Contract type'), __('Supplier'), __('Start date'), __('Initial contract period'));
         $i++;
         while ($j < $number) {
             $cID = $DB->result($result, $j, "contracts_id");
             $assocID = $DB->result($result, $j, "id");
             if ($con->getFromDB($cID)) {
                 $pdf->displayLine(empty($con->fields["name"]) ? "(" . $con->fields["id"] . ")" : $con->fields["name"], $con->fields["num"], Html::clean(Dropdown::getDropdownName("glpi_contracttypes", $con->fields["contracttypes_id"])), str_replace("<br>", " ", $con->getSuppliersNames()), Html::convDate($con->fields["begin_date"]), sprintf(_n('%d month', '%d months', $con->fields["duration"]), $con->fields["duration"]));
             }
             $j++;
         }
     } else {
         $pdf->displayTitle("<b>" . __('No item found') . "</b>");
     }
     $pdf->displaySpace();
 }
 /**
  * Print an HTML array of contract associated to an object
  *
  * @since version 0.84
  *
  * @param $item            CommonDBTM object wanted
  * @param $withtemplate    not used (to be deleted) (default '')
  *
  * @return Nothing (display)
  **/
 static function showForItem(CommonDBTM $item, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $itemtype = $item->getType();
     $ID = $item->fields['id'];
     if (!Contract::canView() || !$item->can($ID, READ)) {
         return false;
     }
     $canedit = $item->can($ID, UPDATE);
     $rand = mt_rand();
     $query = "SELECT `glpi_contracts_items`.*\n                FROM `glpi_contracts_items`,\n                     `glpi_contracts`\n                LEFT JOIN `glpi_entities` ON (`glpi_contracts`.`entities_id`=`glpi_entities`.`id`)\n                WHERE `glpi_contracts`.`id`=`glpi_contracts_items`.`contracts_id`\n                      AND `glpi_contracts_items`.`items_id` = '{$ID}'\n                      AND `glpi_contracts_items`.`itemtype` = '{$itemtype}'" . getEntitiesRestrictRequest(" AND", "glpi_contracts", '', '', true) . "\n                ORDER BY `glpi_contracts`.`name`";
     $result = $DB->query($query);
     $contracts = array();
     $used = array();
     if ($number = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $contracts[$data['id']] = $data;
             $used[$data['contracts_id']] = $data['contracts_id'];
         }
     }
     if ($canedit && $withtemplate != 2) {
         echo "<div class='firstbloc'>";
         echo "<form name='contractitem_form{$rand}' id='contractitem_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<input type='hidden' name='items_id' value='{$ID}'>";
         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a contract') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td>";
         Contract::dropdown(array('entity' => $item->getEntityID(), 'used' => $used));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($withtemplate != 2) {
         if ($canedit && $number) {
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $massiveactionparams = array('num_displayed' => $number, 'container' => 'mass' . __CLASS__ . $rand);
             Html::showMassiveActions($massiveactionparams);
         }
     }
     echo "<table class='tab_cadre_fixehov'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && $number && $withtemplate != 2) {
         $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>" . __('Name') . "</th>";
     $header_end .= "<th>" . __('Entity') . "</th>";
     $header_end .= "<th>" . _x('phone', 'Number') . "</th>";
     $header_end .= "<th>" . __('Contract type') . "</th>";
     $header_end .= "<th>" . __('Supplier') . "</th>";
     $header_end .= "<th>" . __('Start date') . "</th>";
     $header_end .= "<th>" . __('Initial contract period') . "</th>";
     $header_end .= "</tr>";
     echo $header_begin . $header_top . $header_end;
     if ($number > 0) {
         Session::initNavigateListItems(__CLASS__, sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
         foreach ($contracts as $data) {
             $cID = $data["contracts_id"];
             Session::addToNavigateListItems(__CLASS__, $cID);
             $contracts[] = $cID;
             $assocID = $data["id"];
             $con = new Contract();
             $con->getFromDB($cID);
             echo "<tr class='tab_bg_1" . ($con->fields["is_deleted"] ? "_2" : "") . "'>";
             if ($canedit && $withtemplate != 2) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
                 echo "</td>";
             }
             echo "<td class='center b'>";
             $name = $con->fields["name"];
             if ($_SESSION["glpiis_ids_visible"] || empty($con->fields["name"])) {
                 $name = sprintf(__('%1$s (%2$s)'), $name, $con->fields["id"]);
             }
             echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/contract.form.php?id={$cID}'>" . $name;
             echo "</a></td>";
             echo "<td class='center'>";
             echo Dropdown::getDropdownName("glpi_entities", $con->fields["entities_id"]) . "</td>";
             echo "<td class='center'>" . $con->fields["num"] . "</td>";
             echo "<td class='center'>";
             echo Dropdown::getDropdownName("glpi_contracttypes", $con->fields["contracttypes_id"]) . "</td>";
             echo "<td class='center'>" . $con->getSuppliersNames() . "</td>";
             echo "<td class='center'>" . Html::convDate($con->fields["begin_date"]) . "</td>";
             echo "<td class='center'>" . sprintf(__('%1$s %2$s'), $con->fields["duration"], _n('month', 'months', $con->fields["duration"]));
             if ($con->fields["begin_date"] != '' && !empty($con->fields["begin_date"])) {
                 echo " -> " . Infocom::getWarrantyExpir($con->fields["begin_date"], $con->fields["duration"], 0, true);
             }
             echo "</td>";
             echo "</tr>";
         }
         echo $header_begin . $header_bottom . $header_end;
     }
     echo "</table>";
     if ($canedit && $number && $withtemplate != 2) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
Esempio n. 3
0
 /**
  * Print an HTML array of contract associated to an object
  *
  *
  *@param $item CommonDBTM : object wanted
  *@param $withtemplate='' not used (to be deleted)
  *
  *@return Nothing (display)
  *
  **/
 static function showAssociated(CommonDBTM $item, $withtemplate = '')
 {
     global $DB, $CFG_GLPI, $LANG;
     $itemtype = $item->getType();
     $ID = $item->fields['id'];
     if (!haveRight("contract", "r") || !$item->can($ID, "r")) {
         return false;
     }
     $canedit = $item->can($ID, "w");
     $query = "SELECT `glpi_contracts_items`.*\n                FROM `glpi_contracts_items`,\n                     `glpi_contracts`\n                LEFT JOIN `glpi_entities` ON (`glpi_contracts`.`entities_id`=`glpi_entities`.`id`)\n                WHERE `glpi_contracts`.`id`=`glpi_contracts_items`.`contracts_id`\n                      AND `glpi_contracts_items`.`items_id` = '{$ID}'\n                      AND `glpi_contracts_items`.`itemtype` = '{$itemtype}'" . getEntitiesRestrictRequest(" AND", "glpi_contracts", '', '', true) . "\n                ORDER BY `glpi_contracts`.`name`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     echo "<div class='spaced'>";
     if ($withtemplate != 2) {
         echo "<form method='post' action=\"" . $CFG_GLPI["root_doc"] . "/front/contract.form.php\">";
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='8'>";
     if ($number == 0) {
         echo $LANG['financial'][58];
     } else {
         if ($number == 1) {
             echo $LANG['financial'][63];
         } else {
             echo $LANG['financial'][66];
         }
     }
     echo "</th></tr>";
     echo "<tr><th>" . $LANG['common'][16] . "</th>";
     echo "<th>" . $LANG['entity'][0] . "</th>";
     echo "<th>" . $LANG['financial'][4] . "</th>";
     echo "<th>" . $LANG['financial'][6] . "</th>";
     echo "<th>" . $LANG['financial'][26] . "</th>";
     echo "<th>" . $LANG['search'][8] . "</th>";
     echo "<th>" . $LANG['financial'][8] . "</th>";
     if ($withtemplate != 2) {
         echo "<th>&nbsp;</th>";
     }
     echo "</tr>";
     if ($number > 0) {
         initNavigateListItems('Contract', $item->getTypeName() . " = " . $item->getName());
     }
     $contracts = array();
     while ($i < $number) {
         $cID = $DB->result($result, $i, "contracts_id");
         addToNavigateListItems('Contract', $cID);
         $contracts[] = $cID;
         $assocID = $DB->result($result, $i, "id");
         $con = new Contract();
         $con->getFromDB($cID);
         echo "<tr class='tab_bg_1" . ($con->fields["is_deleted"] ? "_2" : "") . "'>";
         echo "<td class='center'>";
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/contract.form.php?id={$cID}'>";
         echo "<strong>" . $con->fields["name"];
         if ($_SESSION["glpiis_ids_visible"] || empty($con->fields["name"])) {
             echo " (" . $con->fields["id"] . ")";
         }
         echo "</strong></a></td>";
         echo "<td class='center'>";
         echo Dropdown::getDropdownName("glpi_entities", $con->fields["entities_id"]) . "</td>";
         echo "<td class='center'>" . $con->fields["num"] . "</td>";
         echo "<td class='center'>";
         echo Dropdown::getDropdownName("glpi_contracttypes", $con->fields["contracttypes_id"]) . "</td>";
         echo "<td class='center'>" . $con->getSuppliersNames() . "</td>";
         echo "<td class='center'>" . convDate($con->fields["begin_date"]) . "</td>";
         echo "<td class='center'>" . $con->fields["duration"] . " " . $LANG['financial'][57];
         if ($con->fields["begin_date"] != '' && !empty($con->fields["begin_date"])) {
             echo " -> " . getWarrantyExpir($con->fields["begin_date"], $con->fields["duration"]);
         }
         echo "</td>";
         if ($withtemplate != 2) {
             echo "<td class='tab_bg_2 center'>";
             if ($canedit) {
                 echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/contract.form.php?deleteitem=deleteitem&amp;id={$assocID}&amp;contracts_id={$cID}'>";
                 echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/delete2.png' alt='" . $LANG['buttons'][6] . "'></a>";
             } else {
                 echo "&nbsp;";
             }
             echo "</td>";
         }
         echo "</tr>";
         $i++;
     }
     $q = "SELECT *\n            FROM `glpi_contracts`\n            WHERE `is_deleted` = '0' " . getEntitiesRestrictRequest("AND", "glpi_contracts", "entities_id", $item->getEntityID(), true);
     $result = $DB->query($q);
     $nb = $DB->numrows($result);
     if ($canedit) {
         if ($withtemplate != 2 && $nb > count($contracts)) {
             echo "<tr class='tab_bg_1'><td class='right' colspan='3'>";
             echo "<input type='hidden' name='items_id' value='{$ID}'>";
             echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
             self::dropdown(array('entity' => $item->getEntityID(), 'used' => $contracts));
             echo "</td><td class='center'>";
             echo "<input type='submit' name='additem' value=\"" . $LANG['buttons'][8] . "\"\n                   class='submit'>";
             echo "</td>";
             echo "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
         }
     }
     echo "</table>";
     if ($withtemplate != 2) {
         echo "</form>";
     }
     echo "</div>";
 }