Esempio n. 1
0
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if (!$withtemplate) {
         switch ($item->getType()) {
             case 'Supplier':
                 if (Session::haveRight("contract", "r")) {
                     if ($_SESSION['glpishow_count_on_tabs']) {
                         return self::createTabEntry(Contract::getTypeName(2), self::countForSupplier($item));
                     }
                     return Contract::getTypeName(2);
                 }
                 break;
             case 'Contract':
                 if (Session::haveRight("contact_enterprise", "r")) {
                     if ($_SESSION['glpishow_count_on_tabs']) {
                         return self::createTabEntry(Supplier::getTypeName(2), self::countForContract($item));
                     }
                     return Supplier::getTypeName(2);
                 }
                 break;
         }
     }
     return '';
 }
Esempio n. 2
0
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if (!$withtemplate) {
         $nb = 0;
         switch ($item->getType()) {
             case 'Supplier':
                 if (Contract::canView()) {
                     if ($_SESSION['glpishow_count_on_tabs']) {
                         $nb = self::countForSupplier($item);
                     }
                     return self::createTabEntry(Contract::getTypeName(Session::getPluralNumber()), $nb);
                 }
                 break;
             case 'Contract':
                 if (Session::haveRight("contact_enterprise", READ)) {
                     if ($_SESSION['glpishow_count_on_tabs']) {
                         $nb = self::countForContract($item);
                     }
                     return self::createTabEntry(Supplier::getTypeName(Session::getPluralNumber()), $nb);
                 }
                 break;
         }
     }
     return '';
 }
Esempio n. 3
0
        $ent->check($_POST["id"], 'd');
        $ent->delete($_POST);
        Event::log($_POST["id"], "suppliers", 4, "financial", sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
        $ent->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $ent->check($_POST["id"], 'd');
            $ent->restore($_POST);
            Event::log($_POST["id"], "suppliers", 4, "financial", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
            $ent->redirectToList();
        } else {
            if (isset($_POST["purge"])) {
                $ent->check($_POST["id"], 'd');
                $ent->delete($_POST, 1);
                Event::log($_POST["id"], "suppliers", 4, "financial", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
                $ent->redirectToList();
            } else {
                if (isset($_POST["update"])) {
                    $ent->check($_POST["id"], 'w');
                    $ent->update($_POST);
                    Event::log($_POST["id"], "suppliers", 4, "financial", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
                    Html::back();
                } else {
                    Html::header(Supplier::getTypeName(2), '', "financial", "supplier");
                    $ent->showForm($_GET["id"]);
                    Html::footer();
                }
            }
        }
    }
}
Esempio n. 4
0
        $ent->check($_POST["id"], DELETE);
        $ent->delete($_POST);
        Event::log($_POST["id"], "suppliers", 4, "financial", sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
        $ent->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $ent->check($_POST["id"], DELETE);
            $ent->restore($_POST);
            Event::log($_POST["id"], "suppliers", 4, "financial", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
            $ent->redirectToList();
        } else {
            if (isset($_POST["purge"])) {
                $ent->check($_POST["id"], PURGE);
                $ent->delete($_POST, 1);
                Event::log($_POST["id"], "suppliers", 4, "financial", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
                $ent->redirectToList();
            } else {
                if (isset($_POST["update"])) {
                    $ent->check($_POST["id"], UPDATE);
                    $ent->update($_POST);
                    Event::log($_POST["id"], "suppliers", 4, "financial", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
                    Html::back();
                } else {
                    Html::header(Supplier::getTypeName(Session::getPluralNumber()), '', "management", "supplier");
                    $ent->display(array('id' => $_GET["id"]));
                    Html::footer();
                }
            }
        }
    }
}
 /**
  * Show webapplications associated to an item
  *
  * @since version 0.84
  *
  * @param $item            Supplier object for which associated webapplications must be displayed
  * @param $withtemplate    (default '')
  **/
 static function showForSupplier(Supplier $item, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $ID = $item->getField('id');
     if ($item->isNewID($ID)) {
         return false;
     }
     if (!Session::haveRight("plugin_webapplications", READ)) {
         return false;
     }
     if (!$item->can($item->fields['id'], READ)) {
         return false;
     }
     if (empty($withtemplate)) {
         $withtemplate = 0;
     }
     $rand = mt_rand();
     $is_recursive = $item->isRecursive();
     $query = "SELECT `glpi_entities`.`id` AS entity,\n                        `glpi_plugin_webapplications_webapplications`.`id` AS assocID,\n                       `glpi_plugin_webapplications_webapplications`.`name` AS assocName,\n                       `glpi_plugin_webapplications_webapplications`.*\n                FROM `glpi_plugin_webapplications_webapplications`\n                LEFT JOIN `glpi_entities` ON (`glpi_plugin_webapplications_webapplications`.`entities_id`=`glpi_entities`.`id`)\n                WHERE `glpi_plugin_webapplications_webapplications`.`suppliers_id` = '{$ID}' ";
     $query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_webapplications_webapplications", '', '', true);
     $query .= " ORDER BY `assocName`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     $webs = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $webs[$data['assocID']] = $data;
         }
     }
     echo "<div class='spaced'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th>" . __('Name') . "</th>";
     if (Session::isMultiEntitiesMode()) {
         echo "<th>" . __('Entity') . "</th>";
     }
     echo "<th>" . PluginWebapplicationsWebapplicationType::getTypeName(1) . "</th>";
     echo "<th>" . __('URL') . "</th>";
     echo "<th>" . __('Server') . "</th>";
     echo "<th>" . __('Language') . "</th>";
     echo "<th>" . __('Version') . "</th>";
     echo "<th>" . __('Comments') . "</th>";
     echo "</tr>";
     $used = array();
     if ($number) {
         Session::initNavigateListItems('PluginWebapplicationsWebapplication', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
         $web = new PluginWebapplicationsWebapplication();
         foreach ($webs as $data) {
             $webID = $data["id"];
             $link = NOT_AVAILABLE;
             if ($web->getFromDB($webID)) {
                 $link = $web->getLink();
             }
             Session::addToNavigateListItems('PluginWebapplicationsWebapplication', $webID);
             $assocID = $data["assocID"];
             echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
             echo "<td class='center'>{$link}</td>";
             if (Session::isMultiEntitiesMode()) {
                 echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
             }
             echo "<td>" . Dropdown::getDropdownName("glpi_plugin_webapplications_webapplicationtypes", $data["plugin_webapplications_webapplicationtypes_id"]) . "</td>";
             $link = Toolbox::substr($data["address"], 0, 30) . "...";
             echo "<td class='center'>" . "<a href=\"" . str_replace("&", "&amp;", $data["address"]) . "\" target=\"_blank\">" . "<u>" . $link . "</u></a></td>";
             echo "<td>" . Dropdown::getDropdownName("glpi_plugin_webapplications_webapplicationservertypes", $data["plugin_webapplications_webapplicationservertypes_id"]) . "</td>";
             echo "<td>" . Dropdown::getDropdownName("glpi_plugin_webapplications_webapplicationtechnics", $data["plugin_webapplications_webapplicationtechnics_id"]) . "</td>";
             echo "<td>" . $data["version"] . "</td>";
             echo "<td>" . $data["comment"] . "</td>";
             echo "</tr>";
             $i++;
         }
     }
     echo "</table>";
     echo "</div>";
 }
 /**
  * Show contacts asociated to an enterprise
  **/
 static function showForSupplier(Supplier $supplier)
 {
     global $DB, $CFG_GLPI;
     $instID = $supplier->fields['id'];
     if (!$supplier->can($instID, READ)) {
         return false;
     }
     $canedit = $supplier->can($instID, UPDATE);
     $rand = mt_rand();
     $query = "SELECT `glpi_contacts`.*,\n                       `glpi_contacts_suppliers`.`id` AS ID_ent,\n                       `glpi_entities`.`id` AS entity\n                FROM `glpi_contacts_suppliers`, `glpi_contacts`\n                LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id`=`glpi_contacts`.`entities_id`)\n                WHERE `glpi_contacts_suppliers`.`contacts_id`=`glpi_contacts`.`id`\n                      AND `glpi_contacts_suppliers`.`suppliers_id` = '{$instID}'" . getEntitiesRestrictRequest(" AND", "glpi_contacts", '', '', true) . "\n                ORDER BY `glpi_entities`.`completename`, `glpi_contacts`.`name`";
     $result = $DB->query($query);
     $contacts = array();
     $used = array();
     if ($number = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $contacts[$data['ID_ent']] = $data;
             $used[$data['id']] = $data['id'];
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='contactsupplier_form{$rand}' id='contactsupplier_form{$rand}'\n                method='post' action='";
         echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='2'>" . __('Add a contact') . "</tr>";
         echo "<tr class='tab_bg_2'><td class='center'>";
         echo "<input type='hidden' name='suppliers_id' value='{$instID}'>";
         Contact::dropdown(array('used' => $used, 'entity' => $supplier->fields["entities_id"], 'entity_sons' => $supplier->fields["is_recursive"]));
         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 ($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) {
         $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>" . __('Phone') . "</th>";
     $header_end .= "<th>" . __('Phone 2') . "</th>";
     $header_end .= "<th>" . __('Mobile phone') . "</th>";
     $header_end .= "<th>" . __('Fax') . "</th>";
     $header_end .= "<th>" . _n('Email', 'Emails', 1) . "</th>";
     $header_end .= "<th>" . __('Type') . "</th>";
     $header_end .= "</tr>";
     echo $header_begin . $header_top . $header_end;
     $used = array();
     if ($number) {
         Session::initNavigateListItems('Contact', sprintf(__('%1$s = %2$s'), Supplier::getTypeName(1), $supplier->getName()));
         foreach ($contacts as $data) {
             $ID = $data["ID_ent"];
             $used[$data["id"]] = $data["id"];
             Session::addToNavigateListItems('Contact', $data["id"]);
             echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
             if ($canedit) {
                 echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["ID_ent"]) . "</td>";
             }
             echo "<td class='center'>";
             echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/contact.form.php?id=" . $data["id"] . "'>" . sprintf(__('%1$s %2$s'), $data["name"], $data["firstname"]) . "</a></td>";
             echo "<td class='center' width='100'>" . Dropdown::getDropdownName("glpi_entities", $data["entity"]);
             echo "</td>";
             echo "<td class='center' width='100'>" . $data["phone"] . "</td>";
             echo "<td class='center' width='100'>" . $data["phone2"] . "</td>";
             echo "<td class='center' width='100'>" . $data["mobile"] . "</td>";
             echo "<td class='center' width='100'>" . $data["fax"] . "</td>";
             echo "<td class='center'>";
             echo "<a href='mailto:" . $data["email"] . "'>" . $data["email"] . "</a></td>";
             echo "<td class='center'>" . Dropdown::getDropdownName("glpi_contacttypes", $data["contacttypes_id"]) . "</td>";
             echo "</tr>";
         }
         echo $header_begin . $header_bottom . $header_end;
     }
     echo "</table>";
     if ($canedit && $number) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }